<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>AskApache</title>
	
	<link>http://www.askapache.com</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Thu, 26 Apr 2012 11:29:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<feedburner:info uri="apache/htaccess" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.askapache.com/apache/htaccess" /><feedburner:emailServiceId>apache/htaccess</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.askapache.com/apache/htaccess" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.askapache.com%2Fapache%2Fhtaccess" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:browserFriendly>Thanks for your Interest, you are very nice!</feedburner:browserFriendly><item>
		<title>Show or Hide WordPress Admin Bar Plugin</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/2zYF9Q1whxc/hide-admin-bar.html</link>
		<comments>http://www.askapache.com/wordpress/hide-admin-bar.html#comments</comments>
		<pubDate>Thu, 19 Apr 2012 06:15:14 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress Plugin]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=7121</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/wordpress/hide-admin-bar.html"><img src="http://uploads.askapache.com/2012/04/profile-no-admin-bar-300x258.png" alt="WordPress No Admin Bar" title="WordPress No Admin Bar" width="300" height="258" /></a>The Admin Bar in WordPress is always shown when in the backend administration area no matter what.<br /><br />You are given the option to show/hide the admin bar when <em>viewing the site</em>, but there is no option to show/hide the admin bar when <em>using the backend</em>... So I created a plugin to provide that option on profile pages.<br /><br /><em>Why hide the admin bar in backend?</em><br />Normally I like the admin-bar and usually have it enabled, but it's nice to be able to switch it on/off from the "Edit Profile" page.  The biggest reason for not loading/showing the admin_bar in the backend is <strong>SPEED</strong>.  Here are 2 instances where I hide it-<br /><br /> &#160;&#160;&#160;&#160;&#183; <strong>Sites with many authors/admins</strong><br /> &#160;&#160;&#160;&#160;&#183; <strong>Moderating Comments on a Mobile Phone</strong><br /><br />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/wordpress/hide-admin-bar.html"></a><a href="http://www.askapache.com/wordpress/hide-admin-bar.html"><cite>AskApache.com</cite></a></p><p><a class="IFL" href="http://uploads.askapache.com/2012/04/profile-no-admin-bar.png"><img src="http://uploads.askapache.com/2012/04/profile-no-admin-bar.png" alt="WordPress No Admin Bar" title="WordPress No Admin Bar" width="537" height="462" /></a>The Admin Bar in WordPress is always shown when in the backend administration area no matter what.<br /><br />You are given the option to show/hide the admin bar when <em>viewing the site</em>, but there is no option to show/hide the admin bar when <em>using the backend</em>... So I created a plugin to provide that option on profile pages.<br /><br /><em>Why hide the admin bar in backend?</em><br />Normally I like the admin-bar and usually have it enabled, but it's nice to be able to switch it on/off from the "Edit Profile" page.  The biggest reason for not loading/showing the admin_bar in the backend is <strong>SPEED</strong>.  Here are 2 instances where I hide it-<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp;&middot; <strong>Sites with many authors/admins</strong><br /> &nbsp;&nbsp;&nbsp;&nbsp;&middot; <strong>Moderating Comments on a Mobile Phone</strong><br /><br />
I occasionally enjoy moderating blog comments using my Android mobile phone and a browser like Opera or Dolphin.... hiding the admin_bar improves Load Speed, Page Rendering Speed, and Scroll Speed. Basically everything.<br /><br />The wp-admin-bar causes additional CSS, JavaScript, and HTML to be added to every page, increasing request size and time of every request!  The jQuery used for the admin_bar keeps it floating at the top using javascript, meaning it gets executed on resize/scroll/load - MAJOR PAIN!<br class="C" /></p>


<h2>Plugin for Hiding/Showing the WP AdminBar</h2>
<p><img class="IFL" src="http://uploads.askapache.com/2012/04/profile-with-adminbar.png" alt="WordPress with Admin Bar" title="WordPress with Admin Bar" width="537" height="462" /><br /><br /><br /><br /><br /><br />This plugin provides the option of hiding the admin bar when in_admin.  It not only hides the admin_bar, it actually prevents the admin_bar class from even loading, at least in WP version 3.4-beta2-20509 thanks to the <code>wp_admin_bar_class</code> filter.<br /><br />Follow the Installation steps below and/or read on to see how it works.. it's an incredibly simple plugin and easy to extend for other purposes.<br class="C" /></p>


<h3>Installation Steps</h3>
<ol>
<li>Download the plugin file: <a href='http://uploads.askapache.com/2012/04/askapache-adminbar-prefs.txt'>askapache-adminbar-prefs.txt</a></li>
<li>Save to <code>/wp-content/plugins/askapache-adminbar-prefs/askapache-adminbar-prefs.php</code></li>
<li>Enable/Disable the plugin from the Plugins Page</li>
<li>Show/Hide admin_bar from the 'Edit Profile' Page</li>
</ol>

<h3>Add Checkbox Option to Profile Page</h3>
<pre>
function askapache_adminbar_personal_options( $profileuser )
{
 global $wpdb, $wp_query;
 $show_admin_bar_backend=_get_admin_bar_pref( &#039;backend&#039;, $profileuser-&gt;ID );
?&gt;
&lt;tr class="show-admin-bar-backend"&gt;
&lt;th scope="row"&gt;Toolbar2&lt;/th&gt;
&lt;td&gt;&lt;fieldset&gt;&lt;legend class="screen-reader-text"&gt;&lt;span&gt;Toolbar2&lt;/span&gt;&lt;/legend&gt;
&lt;label for="admin_bar_backend"&gt;
&lt;input name="admin_bar_backend" type="checkbox" id="admin_bar_backend" value="1"&lt;?php checked( _get_admin_bar_pref( &#039;backend&#039;, $profileuser-&gt;ID ) ); ?&gt; /&gt;
Show Toolbar when in backend&lt;/label&gt;&lt;br /&gt;
&lt;/fieldset&gt;
&lt;/td&gt;
&lt;/tr&gt;&lt;?php
}
add_action( &#039;personal_options&#039;, &#039;askapache_adminbar_personal_options&#039;, 10, 1 );
</pre>



<h3>Save preference when a profile updated</h3>
<pre>
function askapache_adminbar_handle_post($useridtoedit)
{
 global $wpdb, $wp_query, $current_user;
 $show_admin_bar_backend=_get_admin_bar_pref( &#039;backend&#039;, $useridtoedit );
 
 $userID=(int)$useridtoedit;
 if ( !current_user_can(&#039;edit_user&#039;, $userID) ) wp_die(__(&#039;You do not have permission to edit this user.&#039;));
 
 $show_admin_bar_backend=(isset( $_POST[&#039;admin_bar_backend&#039;] ) ? &#039;true&#039; : &#039;false&#039;);
 update_user_option($userID, "show_admin_bar_backend", $show_admin_bar_backend);
}
add_action( &#039;personal_options_update&#039;, &#039;askapache_adminbar_handle_post&#039;, 10, 1);
add_action( &#039;edit_user_profile_update&#039;, &#039;askapache_adminbar_handle_post&#039;, 10, 1);
</pre>




<h3>Remove admin_bar from backend</h3>
<p>Now we need to hook into <code>init</code> to either show/hide the admin_bar while in the backend (<code>in_admin()</code>) based on the users preference.</p>
<ol>
<li>Fetches the users preference for showing the admin_bar in the backend</li>
<li>Removes the wp_admin_bar class from even loading (<code>wp_admin_bar_class</code> filter)</li>
<li>Returns false to the <code>show_admin_bar</code> filter</li>
<li>Overrules the <code>admin-bar</code> css applied to the body</li>
</ol>
<pre>
function askapache_adminbar_personal_options_init()
{
 global $wpdb, $wp_query, $current_user;
 $show_admin_bar_backend=_get_admin_bar_pref( &#039;backend&#039;, $current_user-&gt;ID );
 if(!$show_admin_bar_backend &amp;&amp; is_admin())
 {
  add_filter(&#039;wp_admin_bar_class&#039;, create_function(&#039;&#039;, &#039;return "none".rand(1000,666666);&#039;), 9999999);
  add_filter(&#039;show_admin_bar&#039;, create_function(&#039;&#039;, &#039;return false;&#039;), 999999);
  add_action(&#039;admin_head&#039;, create_function(&#039;&#039;, &#039;echo \&#039;&lt;style type="text/css"&gt;body.admin-bar {padding-top:0 !important;}&lt;/style&gt;\&#039;;&#039;));
 }
}
add_action( &#039;init&#039;, &#039;askapache_adminbar_personal_options_init&#039;,0); 
</pre>

<h2>Add to Core WordPress</h2>
<p>I'm sure this will be added to the dev version of WordPress by someone (volunteers?) and eventually integrated into stable.  Note this was built and used on WordPress 3.4-beta2-20509.</p><p><a href="http://www.askapache.com/wordpress/hide-admin-bar.html"></a><a href="http://www.askapache.com/wordpress/hide-admin-bar.html">Show or Hide WordPress Admin Bar Plugin</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/esIv3FZGmCUpAGo7AQOfx6BuDbk/0/da"><img src="http://feedads.g.doubleclick.net/~a/esIv3FZGmCUpAGo7AQOfx6BuDbk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/esIv3FZGmCUpAGo7AQOfx6BuDbk/1/da"><img src="http://feedads.g.doubleclick.net/~a/esIv3FZGmCUpAGo7AQOfx6BuDbk/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/2zYF9Q1whxc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/wordpress/hide-admin-bar.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/wordpress/hide-admin-bar.html</feedburner:origLink></item>
		<item>
		<title>Optimized Vimrc with 256 Colorscheme</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/wXxpUz6HwbQ/fast-vimrc.html</link>
		<comments>http://www.askapache.com/linux/fast-vimrc.html#comments</comments>
		<pubDate>Sun, 26 Feb 2012 18:15:32 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=7062</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/linux/fast-vimrc.html"><img src="http://uploads.askapache.com/2012/02/vimrc-colorscheme.png" alt="askapachecode 256color colorscheme and vimrc screenshot" title="askapachecode 256color colorscheme and vimrc screenshot" width="525" height="277" class="size-full wp-image-7074" /></a><strong>This is not your everyday vimrc</strong>.  This is <em>my</em> personalized vimrc.. works especially great on remote servers, in tmux, screen, etc. <br /><br />This doesn't require a git checkout, a vim update, a bash update, an OS update, a plugin.  No.  1 vimrc, 1 colorscheme, just use curl to download and it's on.  I use this on <a href="http://archlinux.org/">Arch Linux</a>, NetBSD, FreeBSD, OpenBSD, Debian, Ubuntu, Cent OS, Red Hat, and that's mostly it so far. <br />If you aren't already using vim as your primary editor in a powerful way, you are gonna owe me for this.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/linux/fast-vimrc.html"></a><a href="http://www.askapache.com/linux/fast-vimrc.html"><cite>AskApache.com</cite></a></p><p>This is 90% geared for purely console/terminal/pty/tty/ssh/putty/telnet/tmux/screen users.  I've only just the past couple years started understanding why it was key to learn vim, in the past I never had the patience for it and preferred nano-like editors.  Now vim is all I use when on linux, it's so much more productive.. especially with a customized vimrc file.  This doesn't require a git checkout, a vim update, a bash update, an OS update, a plugin.  No.  This is a single file that I use on <a href="http://archlinux.org/">Arch Linux</a>, NetBSD, FreeBSD, OpenBSD, Debian, Ubuntu, Cent OS, Red Hat, and that's it so far.  This is geared for users who use SSH more than anything else.  Of course, it works perfect on an X enabled box locally as well.</p>

<h2>ScreenShot</h2>
<p><a href="http://uploads.askapache.com/2012/02/vimrc-screenshot.png"><img src="http://uploads.askapache.com/2012/02/vimrc-screenshot.png" alt="Screenshot of this vimrc in action" title="Screenshot of this vimrc in action" width="911" height="987" class="size-full wp-image-7073" /></a></p>

<h2>Setup</h2>
<p>I install this as <code>/etc/vimrc</code> if possible.  Individual users can use a vim config file in their home directories.</p>
<pre>source /etc/vimrc</pre>
<p>To install for a single user just save it in their home dir at <code>/home/username/.vimrc</code></p>

<h2>Portability</h2>
<p>For the portability needed to work on many different systems, this doesn't rely on any plugins other than those built into the default installation of vim 7.0.
It works well on all types of consoles, and depending on the TERM environment variable (and whether it has the right term capabilities) it will load 256 color support or not.  Usually on a new system I just scp this right over and it works without any modifications.  But an ongoing Work in progress.</p>



<h2>Optimized Vimrc</h2>
<p>Download - <a href='http://uploads.askapache.com/2012/02/vimrc.txt'>Optimized vimrc</a></p>
<pre>" Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
&nbsp;
" For all key mappings like &#039;, .&#039; to reload vimrc
let maplocalleader=&#039;,&#039;
&nbsp;
" BACKUPS, SWAPFILES, VIEWDIR, TMPDIR  "{{{1
" ================================================================================================================================================================
&nbsp;
" SET RUNTIMEPATH {{{3
if isdirectory(expand("$HOME/.vim"))
  let $VIMRUNTIME=expand("$HOME/.vim")
  set runtimepath=$VIMRUNTIME
endif
&nbsp;
" IF BKDIR IS NOT SET OR EMPTY, SET {{{3
if $BKDIR == ""
  let $BKDIR=expand("$HOME/.bk")
  if !isdirectory(expand("$BKDIR"))
    call mkdir(expand("$BKDIR"), "p", 0700)
  endif
endif
&nbsp;
" MAKE DIRS IF mkdir exists {{{3
if exists("*mkdir")
  if !isdirectory(expand("$BKDIR/.vim/viewdir"))|call mkdir(expand("$BKDIR/.vim/viewdir"), "p", 0700)|endif
  if !isdirectory(expand("$BKDIR/.vim/tmp"))|call mkdir(expand("$BKDIR/.vim/tmp"), "p", 0700)|endif
  if !isdirectory(expand("$BKDIR/.vim/backups"))|call mkdir(expand("$BKDIR/.vim/backups"), "p", 0700)|endif
endif
&nbsp;
" SETTINGS USING NEW DIRS {{{3
let &amp;dir=expand("$BKDIR") . "/.vim"
let &amp;viewdir=expand("$BKDIR") . "/.vim/viewdir"
let &amp;backupdir=expand("$BKDIR") . "/.vim/backups"
"let &amp;verbosefile=expand("$BKDIR") . "/.vim/vim-messages.
&nbsp;
" VIMINFO {{{3
" COMMENTED OUT {{{4
"  "       Maximum number of lines saved for each register
"  %       When included, save and restore the buffer lis
"  &#039;       Maximum number of previously edited files for which the marks are remembere
"  /       Maximum number of items in the search pattern history to be saved
"  :        Maximum number of items in the command-line history
"  &lt;       Maximum number of lines saved for each register.
"   @       Maximum number of items in the input-line history
"  h       Disable the effect of &#039;hlsearch&#039; when loading the viminfo
"  n       Name of the viminfo file.  The name must immediately follow the &#039;n&#039;.  Must be the last oneEnvironment variables are expanded when opening the file, not when setting the option
"  r       Removable media.  The argument is a string
"  s       Maximum size of an item in Kbyte
"   }}}4 COMMENTED OUT
let &amp;viminfo="%200,&#039;200,/800,h,&lt;500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/.vim/tmp,n" . expand("$BKDIR") ."/.vim/.vinfo"
&nbsp;
" CUSTOM FUNCTIONS "{{{1
" ================================================================================================================================================================
if !exists("AskApacheLoaded")
  let AskApacheLoaded=1
&nbsp;
  " FUNCTION - LastMod {{{3
  " Warning, this is controlled by an autocmd triggered when closing the file that updates the file (in a great way)
  " Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
  function! LastMod()
    exe "silent! 1,20s/Updated: .*/" . printf(&#039;Updated: %s by %s@%s&#039;, strftime("%c"), expand("$LOGNAME"), hostname()) . "/e"
  endfunction
&nbsp;
  " FUNCTION - LastModNow {{{3
  " An even better version than LastMod()
  function! LastModNow()
    call setline(line(&#039;.&#039;), printf(&#039;%sUpdated: %s by %s@%s&#039;, printf(&amp;commentstring, &#039; &#039;), strftime("%c"), expand("$LOGNAME"), hostname()))
    "printf(&#039;%sUpdated: %s by %s@%s&#039;, printf(&amp;commentstring, &#039; &#039;), strftime("%c"), expand("$LOGNAME"), hostname())\|dd\|j\|dd&lt;CR&gt;&lt;ESC&gt;
    "printf(&#039;Updated: %s by %s %s&#039;, strftime("%c"), expand("$LOGNAME@$HOSTNAME")) ."/e"
  endfunction
&nbsp;
  " FUNCTION - AppendModeline {{{3
  " Append modeline after last line in buffer.  Use substitute() instead of printf() to handle &#039;%%s&#039; modeline
  function! AppendModeline()
    let l:modeline = printf(" vim: set ft=%s ts=%d sw=%d tw=%d foldmethod=%s :", &amp;filetype, &amp;tabstop, &amp;shiftwidth, &amp;textwidth, &amp;foldmethod)
    let l:modeline = substitute(&amp;commentstring, "%s", l:modeline, "")
    call append(line("$"), l:modeline)
  endfunction
&nbsp;
  " FUNCTION - LastModAAZZZ {{{3
  " AA_UPDATED=&#039;01/24/12-00:56:00&#039;
  function! LastModAAZZZ()
    exe "1,50s/AA_UPDATED=.*/AA_UPDATED=&#039;" . strftime("%c") . "&#039;"
  endfunction
&nbsp;
  " FUNCTION - StripTrailingWhitespace {{{3
  " automatically remove trailing whitespace before write
  function! StripTrailingWhitespace()
    normal mZ
    %s/\s\+$//e
    if line("&#039;Z") != line(".")|echo "Stripped whitespace\n"|endif
    normal `Z
  endfunction
&nbsp;
  " FUNCTION - MyTabL {{{3
  function! MyTabL()
    let s = &#039;&#039;|let t = tabpagenr()|let i = 1
    while i &lt;= tabpagenr(&#039;$&#039;)
      let bl = tabpagebuflist(i)|let wn = tabpagewinnr(i)
      let s .= &#039;%&#039; . i . &#039;T&#039;. (i == t ? &#039;%1*&#039; : &#039;%2*&#039;) . &#039;%*&#039; . (i == t ? &#039; %#TabLineSel# &#039; : &#039;%#TabLine#&#039;)
      let file = (i == t ? fnamemodify(bufname(bl[wn - 1]), &#039;:p&#039;) : fnamemodify(bufname(bl[wn - 1]), &#039;:t&#039;) )|if file == &#039;&#039;|let file = &#039;[No Name]&#039;|endif
      let s .= i.&#039; &#039;. file .(i == t ? &#039; &#039; : &#039;&#039;)|let i += 1
    endwhile
    let s .= &#039;%T%#TabLineFill#%=&#039; . (tabpagenr(&#039;$&#039;) &gt; 1 ? &#039;%999XX&#039; : &#039;X&#039;)
    return s
  endfunction
&nbsp;
  " FUNCTION - DiffWithSaved {{{3
  " Diff with saved version of the file
  function! s:DiffWithSaved()
    let filetype=&amp;ft
    diffthis
    vnew | r # | normal! 1Gdd
    diffthis
    exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
  endfunction
  com! DiffSaved call s:DiffWithSaved()
&nbsp;
  " FUNCTION - ShowWhitespace() {{{3
  function! ShowWhitespace(flags)
    let bad = &#039;&#039;
    let pat = []
    for c in split(a:flags, &#039;\zs&#039;)
      if c == &#039;e&#039;
        call add(pat, &#039;\s\+$&#039;)
      elseif c == &#039;i&#039;
        call add(pat, &#039;^\t*\zs \+&#039;)
      elseif c == &#039;s&#039;
        call add(pat, &#039; \+\ze\t&#039;)
      elseif c == &#039;t&#039;
        call add(pat, &#039;[^\t]\zs\t\+&#039;)
      else
        let bad .= c
      endif
    endfor
&nbsp;
    if len(pat) &gt; 0
      let s = join(pat, &#039;\|&#039;)
      exec &#039;syntax match ExtraWhitespace "&#039;.s.&#039;" containedin=ALL&#039;
    else
      syntax clear ExtraWhitespace
    endif
&nbsp;
    if len(bad) &gt; 0|echo &#039;ShowWhitespace ignored: &#039;.bad|endif
  endfunction
&nbsp;
  " FUNCTION - ToggleShowWhitespace {{{3
  " I use this all the time, it&#039;s mapped to , ts
  function! ToggleShowWhitespace()
    if !exists(&#039;b:ws_show&#039;)|let b:ws_show = 0|endif
    if !exists(&#039;b:ws_flags&#039;)|let b:ws_flags = &#039;est&#039;|endif
    let b:ws_show = !b:ws_show
    if b:ws_show|call ShowWhitespace(b:ws_flags)|else|call ShowWhitespace(&#039;&#039;)|endif
  endfunction
&nbsp;
endif
&nbsp;
" DYNAMIC SETTINGS / COLORS / TERMINAL {{{1
" ================================================================================================================================================================
&nbsp;
" DISABLE MOUSE NO GOOEYS {{{3
if has(&#039;mouse&#039;)|set mouse=|endif
&nbsp;
" SET TITLESTRING {{{3
if has(&#039;title&#039;)|set titlestring=%t%(\ [%R%M]%)|endif
&nbsp;
" SET TABLINE {{{3
if exists("*s:MyTabL")|set tabline=%!MyTabL()|endif
&nbsp;
let g:vimsyn_folding=&#039;af&#039;
&nbsp;
"DISABLE FILETYPE-SPECIFIC MAPS {{{3
let no_plugin_maps=1
&nbsp;
"}}}1 DYNAMIC SETTINGS / COLORS / TERMINAL
&nbsp;
" OPTIONS "{{{1
" ===========================================================================================================================================================================
&nbsp;
" BACKUP, FILE OPTIONS {{{2
" ================================================================================
set backup        " Make a backup before overwriting a file.  Leave it around after the file has been successfully written.
set backupcopy=auto " When writing a file and a backup is made, this option tells how it&#039;s done.  This is a comma separated list of words. - value: yes,no,auto - no:rename the file and write a new one
&nbsp;
set swapfile
set swapsync=fsync
&nbsp;
"}}}2 BACKUP, FILE OPTIONS
&nbsp;
" BASIC SETTINGS "{{{2
" ================================================================================
set nocompatible    " vim, not vi.. must be first, because it changes other options as a side effect
set modeline
&nbsp;
set statusline=%M%h%y\ %t\ %F\ %p%%\ %l/%L\ %=[%{&amp;ff},%{&amp;ft}]\ [a=\%03.3b]\ [h=\%02.2B]\ [%l,%v]
set title titlelen=150 titlestring=%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
&nbsp;
"set tags=tags;/      " search recursively up for tags
&nbsp;
set ttyfast        " we have a fast terminal
set scrolljump=5    " when scrolling up down, show at least 5 lines
"set ttyscroll=999    " make vim redraw screen instead of scrolling when there are more than 3 lines to be scrolled
&nbsp;
"set tw=500        " default textwidth is a max of 5
&nbsp;
set undolevels=10    " 50 undos - saved in memory
set updatecount=250    " switch every 250 chars, save swap
&nbsp;
set whichwrap+=b,s,&lt;,&gt;,h,l,[,]      " backspaces and cursor keys wrap to
"set wildignore+=*.o,*~,.lo,*.exe,*.bak  " ignore object files
"set wildmenu              " menu has tab completion
"set wildmode=longest:full        " *wild* mode
set nowrap
&nbsp;
set autoindent smartindent    " auto/smart indent
&nbsp;
set autoread          " watch for file changes
&nbsp;
set backspace=indent,eol,start  " backspace over all kinds of things
&nbsp;
set cmdheight=1          " command line two lines high
set complete=.,w,b,u,U,t,i,d  " do lots of scanning on tab completion
set cursorline          " show the cursor line
"set enc=utf-8 fenc=utf-8    " utf-8
&nbsp;
set history=3000        " keep 3000 lines of command line history
&nbsp;
set keywordprg=TERM=mostlike\ man\ -s\ -Pless
&nbsp;
set laststatus=2
&nbsp;
"set lazyredraw          " don&#039;t redraw when don&#039;t have to
set linebreak          " wrap at &#039;breakat&#039; instead of last char
set magic            " Enable the "magic"
&nbsp;
set maxmem=25123  " 24 MB -  max mem in Kbyte to use for one buffer.  Max is 2000000
&nbsp;
set noautowrite          " don&#039;t automagically write on :next
&nbsp;
set noexpandtab          " no expand tabs to spaces"
set noruler          " show the line number on the bar
set nospell
set nohidden          " close the buffer when I close a tab (I use tabs more than buffers)
&nbsp;
set noerrorbells visualbell t_vb= " Disable ALL bells
&nbsp;
set number          " line numbers
&nbsp;
set pastetoggle=&lt;F11&gt;
&nbsp;
set scrolloff=3        " keep at least 3 lines above/below
set shiftwidth=3      " shift width
&nbsp;
set showcmd          " Show us the command we&#039;re typing
set showfulltag        " show full completion tags
set showmode        " show the mode all the time
&nbsp;
set sidescroll=2      " if wrap is off, this is fasster for horizontal scrolling
set sidescrolloff=2      "keep at least 5 lines left/right
&nbsp;
set noguipty
&nbsp;
set splitright
set splitbelow
&nbsp;
set restorescreen=on " restore screen contents when vim exits -  disable withset t_ti= t_te=
&nbsp;
"set sessionoptions=word,blank,buffers,curdir,folds,globals,help,localoptions,resize,sesdir,tabpages,winpos,winsize
set winheight=25
set winminheight=1  " minimal value for window height
"set winheight=30  " set the minimal window height
set equalalways    " all the windows are automatically sized same
set eadirection=both  " only equalalways for horizontally split windows
&nbsp;
set hlsearch
&nbsp;
set laststatus=2
&nbsp;
set tabstop=4
set softtabstop=4
&nbsp;
set shiftwidth=3
set switchbuf=usetab
&nbsp;
set commentstring=#%s
&nbsp;
set tabpagemax=55
set showtabline=2    " 2 always, 1 only if multiple tabs
set smarttab      " tab and backspace are smart
&nbsp;
set foldmethod=marker
set foldenable
set foldcolumn=6        " the blank left-most bar left of the numbered lines
&nbsp;
set incsearch          " incremental search
"set ignorecase          " search ignoring case
set sc              " override &#039;ignorecase&#039; when pattern has upper case characters
set smartcase          " Ignore case when searching lowercase
&nbsp;
set showmatch          " show matching bracket
set diffopt=filler,iwhite    " ignore all whitespace and sync"
set stal=2
&nbsp;
"}}}1 OPTIONS
&nbsp;
" PLUGIN SETTINGS {{{1
" ================================================================================================================================================================
" Settings for :TOhtml "{{{3
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
"}}}1 PLUGIN SETTINGS
&nbsp;
" COLORSCHEME IF MORE THAN 2 COLORS lol {{{1
" ================================================================================================================================================================
if &amp;t_Co &gt; 2
&nbsp;
  if &amp;term =~ "256"
&nbsp;
    set bg=dark t_Co=256 vb
    let &amp;t_vb="\&lt;Esc&gt;[?5h\&lt;Esc&gt;[?5l"  " flash screen for visual bell
&nbsp;
    if filereadable(expand("$VIMRUNTIME/colors/askapachecode.vim"))
      colorscheme askapachecode
    elseif filereadable(expand("$HOME/.vim/colors/askapachecode.vim"))
      colorscheme askapachecode
    else
      colorscheme default
    endif
&nbsp;
    filetype indent plugin on
    syntax on
&nbsp;
  else
    " things like cfdisk, crontab -e, visudo, vless, etc.
    set term=linux
    set t_Co=8
    syntax off
    filetype indent plugin off
&nbsp;
  endif
&nbsp;
endif
&nbsp;
"}}}1
&nbsp;
" AUTOCOMMANDS "{{{1
" ===========================================================================================================================================================================
"if !exists(":DiffOrig") | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | endif
&nbsp;
" auto load extensions for different file types
if has(&#039;autocmd&#039;)
&nbsp;
  if !exists("autocommands_loaded")
    let autocommands_loaded = 1
&nbsp;
    " JUMP TO LAST POS {{{3
    " When editing a file, always jump to the last known cursor position. Don&#039;t do it when the position is invalid or when inside an event handler
    " (happens when dropping a file on gvim). Also don&#039;t do it when the mark is in the first line, that is the default position when opening a file.
    au BufReadPost * if line("&#039;\"") &gt; 1 &amp;&amp; line("&#039;\"") &lt;= line("$") | exe "normal! g`\"" | endif
&nbsp;
    " CLEARMATCHES ON BUFWINLEAVE {{{3
    au BufWinLeave * call clearmatches()
&nbsp;
    " STRIP TRAILING WHITESPACE {{{3
    autocmd BufWritePre *.cpp,*.hpp,*.i :call StripTrailingWhitespace()
&nbsp;
    " AA_ZZZ LAST MOD {{{3
    autocmd BufWritePre,FileWritePre,TabLeave zzz_askapache-bash.sh ks|call LastModAAZZZ()|&#039;s
&nbsp;
    " SET VIM SETTINGS FOR AA_ZZZ SCRIPTS {{{3
    autocmd BufRead /etc/ZZZ/*.sh,.bash_profile,.bash_login,.bashrc,.bash_login_user,.bash_logout setlocal ts=4 sw=3 ft=sh foldmethod=marker tw=500 foldcolumn=7
&nbsp;
    " INSERT CURRENT DATE AND TIME IN A *.SH FILE WHEN WRITING IT {{{3
    autocmd BufWritePre,FileWritePre *.*   ks|call LastMod()|&#039;s
&nbsp;
    " IMPROVE LEGIBILITY {{{3
    autocmd BufRead quickfix setlocal nobuflisted wrap number
&nbsp;
    " SAVE BACKUPFILE AS BACKUPDIR/FILENAME-06-13-1331 {{{3
    autocmd BufWritePre * let &amp;bex = strftime("-%m-%d-%H%M")
&nbsp;
    " TMUX FILETYPE {{{3
    autocmd BufRead tmux.conf,.tmux.conf,.tmux*,*/tmux-sessions/* setlocal filetype=tmux foldmethod=marker
&nbsp;
    " APACHE2 FILETYPE {{{3
    autocmd BufRead /opt/a*/conf/*,/etc/httpd/*.conf setlocal filetype=apache
&nbsp;
    " SH FILETYPES {{{3
    autocmd BufRead *.sh,*.cron,*.bash setlocal filetype=sh
&nbsp;
    " SYSLOG-NG FILETYPE {{{3
    autocmd BufRead syslog-ng.conf setlocal filetype=syslog-ng
&nbsp;
    " COMMENTSTRING FOR VIM "{{{3
    au FileType vim setlocal commentstring="%s
&nbsp;
    " COMMENTSTRING FOR XDEFAULTS "{{{3
    au FileType xdefaults setlocal foldmethod=marker foldlevel=2 commentstring=!%s
&nbsp;
    " VIMRC {{{3
    augroup vimrc
      au BufReadPre * setlocal foldmethod=indent
      au BufWinEnter * if &amp;fdm == &#039;indent&#039; | set foldmethod=manual | endif
      au BufRead *.vim,vimrc,*.vimrc set filetype=vim ts=3 sw=3 tw=500 foldmethod=marker foldcolumn=6
    augroup END
&nbsp;
    " AUTOMKVIEWS {{{3
    " Warning - this will save your settings for each file you edit and restore those settings when opened again - can fill up quick
    au BufWinLeave *.sh,*.conf,*.vim,*.c,*.txt,.htaccess,*.cgi,*.php,*.html,*.conf,vimrc mkview
    au BufWinEnter *.sh,*.conf,*.vim,*.c,*.txt,.htaccess,*.cgi,*.php,*.html,*.conf,vimrc silent loadview
    " }}}3
&nbsp;
    " MAN RUNTIME - TODO REPLACE WITH TMUXES CTRL-M BINDING {{{3
    " Lets you type :Man anymanpage and it will load in vim, color-coded and searchable
    "runtime ftplugin/man.vim
&nbsp;
  endif
&nbsp;
endif
"}}}1
&nbsp;
" MAPS "{{{1
" ===========================================================================================================================================================================
&nbsp;
" FUNCTION MAPS {{{2
" ---------------------------------
" APPEND MODELINE {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;ml :call AppendModeline()&lt;CR&gt;
&nbsp;
" SHOW WHITESPACE {{{3
nnoremap &lt;LocalLeader&gt;ts :call ToggleShowWhitespace()&lt;CR&gt;
&nbsp;
" SUDO A WRITE {{{3
command! W :execute &#039;:silent w !sudo tee % &gt; /dev/null&#039; | :edit!
"cmap w!! %!sudo tee &gt; /dev/null %
" :w !sudo tee &gt; /dev/null %
&nbsp;
" SET TABLINE {{{3
" My Personal Fav, inserts last-modified manually on current line when you press &lt;F12&gt; key
" call setline(1, printf(&#039;%sUpdated: %s by %s@%s&#039;, printf(&amp;commentstring, &#039; &#039;), strftime("%c"), expand("$LOGNAME"), hostname()))
if exists("*s:LastModNow")
  map &lt;silent&gt; &lt;F12&gt; :call LastModNow()&lt;CR&gt;
endif
&nbsp;
" RELOAD VIMRC FILES {{{3
map &lt;LocalLeader&gt;. :mkview&lt;CR&gt;:unlet! AskApacheLoaded autocommands_loaded&lt;CR&gt;:mapclear&lt;CR&gt;:source /etc/vimrc&lt;CR&gt;:echoerr &#039;VIMRC RELOADED&#039;&lt;CR&gt;
&nbsp;
" SCROLLING MAPS {{{3
map &lt;PageDown&gt; :set scroll=0&lt;CR&gt;:set scroll^=2&lt;CR&gt;:set scroll-=1&lt;CR&gt;&lt;C-D&gt;:set scroll=0&lt;CR&gt;
map &lt;PageUp&gt; :set scroll=0&lt;CR&gt;:set scroll^=2&lt;CR&gt;:set scroll-=1&lt;CR&gt;&lt;C-U&gt;:set scroll=0&lt;CR&gt;
nnoremap &lt;silent&gt; &lt;PageUp&gt; &lt;C-U&gt;&lt;C-U&gt;
vnoremap &lt;silent&gt; &lt;PageUp&gt; &lt;C-U&gt;&lt;C-U&gt;
inoremap &lt;silent&gt; &lt;PageUp&gt; &lt;C-\&gt;&lt;C-O&gt;&lt;C-U&gt;&lt;C-\&gt;&lt;C-O&gt;&lt;C-U&gt;
nnoremap &lt;silent&gt; &lt;PageDown&gt; &lt;C-D&gt;&lt;C-D&gt;
vnoremap &lt;silent&gt; &lt;PageDown&gt; &lt;C-D&gt;&lt;C-D&gt;
inoremap &lt;silent&gt; &lt;PageDown&gt; &lt;C-\&gt;&lt;C-O&gt;&lt;C-D&gt;&lt;C-\&gt;&lt;C-O&gt;&lt;C-D&gt;
"}}}3
&nbsp;
" KEY MAPS {{{2
" physically map keys to produce different key, type CTRL-V in insert mode followed by any key to see how vim sees it
" ----------------------------------------
imap &lt;ESC&gt;[8~ &lt;End&gt;
map &lt;ESC&gt;[8~ &lt;End&gt;
&nbsp;
imap &lt;ESC&gt;[7~ &lt;Home&gt;
map &lt;ESC&gt;[7~ &lt;Home&gt;
&nbsp;
" Basic Maps  {{{2
" ----------------------------------------
" TOGGLE PASTE MODE {{{3
map &lt;LocalLeader&gt;pm :set nonumber! foldcolumn=0&lt;CR&gt;
&nbsp;
" REINDENT FILE {{{3
map &lt;LocalLeader&gt;ri G=gg&lt;CR&gt;
&nbsp;
" CLEAR SPACES AT END OF LINE {{{3
map &lt;LocalLeader&gt;cs :%s/\s\+$//e&lt;CR&gt;
&nbsp;
" Y YANKS FROM CURSOR TO $ {{{3
map Y y$
&nbsp;
" DON&#039;T USE EX MODE, USE Q FOR FORMATTING {{{3
map Q gq
map! ^H ^?
&nbsp;
" NEXT SEARCH RESULT {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;cn :cn&lt;CR&gt;
&nbsp;
" WRAP? {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;ww :ww
&nbsp;
" ERR INSERTION {{{3
"map &lt;silent&gt; &lt;LocalLeader&gt;e &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s&#039;, &#039;_err "$0 $FUNCNAME:$LINENO FAILED WITH ARGS= $*"&#039;)&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
&nbsp;
" CUSTOM LINES FOR CODING {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;l1 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;=&#039;, 160))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
map &lt;silent&gt; &lt;LocalLeader&gt;l2 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;=&#039;, 80))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
map &lt;silent&gt; &lt;LocalLeader&gt;l3 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;-&#039;, 40))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
map &lt;silent&gt; &lt;LocalLeader&gt;l4 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;-&#039;, 20))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
&nbsp;
" CHANGE DIRECTORY TO THAT OF CURRENT FILE {{{3
nmap &lt;LocalLeader&gt;cd :cd%:p:h&lt;CR&gt;
&nbsp;
" CHANGE LOCAL DIRECTORY TO THAT OF CURRENT FILE {{{3
nmap &lt;LocalLeader&gt;lcd :lcd%:p:h&lt;CR&gt;
&nbsp;
" TOGGLE WRAPPING {{{3
nmap &lt;LocalLeader&gt;ww :set wrap!&lt;CR&gt;
nmap &lt;LocalLeader&gt;wo :set wrap&lt;CR&gt;
&nbsp;
" TABS "{{{2
" ---------------------------------
&nbsp;
" CREATE A NEW TAB {{{3
map &lt;LocalLeader&gt;tc :tabnew %&lt;CR&gt;
&nbsp;
" LAST TAB {{{3
map &lt;LocalLeader&gt;t&lt;Space&gt; :tablast&lt;CR&gt;
&nbsp;
" CLOSE A TAB {{{3
map &lt;LocalLeader&gt;tk :tabclose&lt;CR&gt;
&nbsp;
" NEXT TAB {{{3
map &lt;LocalLeader&gt;tn :tabnext&lt;CR&gt;
&nbsp;
" PREVIOUS TAB {{{3
map &lt;LocalLeader&gt;tp :tabprev&lt;CR&gt;
&nbsp;
" FOLDS   "{{{2
" ---------------------------------
" Fold with paren begin/end matching
nmap F zf%
&nbsp;
" When I use ,sf - return to syntax folding with a big foldcolumn
nmap &lt;LocalLeader&gt;sf :set foldcolumn=6 foldmethod=syntax&lt;cr&gt;
"}}}2
&nbsp;
"}}}1
&nbsp;
" HILITE "{{{1
" ===========================================================================================================================================================================
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17
"}}}
&nbsp;
</pre>


<h2>Colorscheme</h2>
<p>Here is a colorscheme file optimized for 256 colors.  It will work if saved in <code>~/.vim/colors/askapachecode.vim</code> or likewise in your runtimepath.  Additionally, you could just paste it in the bottom of the above vimrc.  The code really needs to be cleaned up, but it looks awesome.</p>
<p>Download - <a href='http://uploads.askapache.com/2012/02/askapachecode.txt'>askapachecode - 256 Colors Vim Colorscheme</a></p>
<p><code>~/.vim/colors/askapachecode.vim</code></p>
<pre>
" Vim color file -- askapachecode
" Maintainer: AskApache &lt;webmaster@askapache.com&gt;
" Updated: Wed Feb 22 14:10:54 2012 by galileo@galileo
&nbsp;
set background=dark
hi clear
&nbsp;
if exists("syntax_on")|syntax reset|endif
&nbsp;
let g:colors_name="askapachecode"
&nbsp;
" Vim &gt;= 7.0 specific colors
if version &gt;= 700
 hi CursorLine ctermbg=236
 hi CursorColumn ctermbg=236
 hi MatchParen ctermfg=157 ctermbg=237 cterm=bold
 hi Pmenu ctermfg=255 ctermbg=238
 hi PmenuSel ctermfg=0 ctermbg=148
endif
&nbsp;
" General colors
hi Cursor ctermbg=241
hi Normal ctermfg=253 ctermbg=232
hi NonText ctermfg=244 ctermbg=235
hi LineNr ctermfg=244 ctermbg=232
hi StatusLine ctermfg=253 ctermbg=238 cterm=italic
hi StatusLineNC ctermfg=246 ctermbg=238
hi VertSplit ctermfg=238 ctermbg=238
hi Folded ctermbg=4 ctermfg=248
hi Title ctermfg=254 cterm=bold
hi Visual ctermfg=254 ctermbg=4
hi SpecialKey ctermfg=244 ctermbg=236
&nbsp;
hi pythonOperator ctermfg=103
&nbsp;
hi Search cterm=NONE  
&nbsp;
" basic highlight groups (:help highlight-groups) {{{1
&nbsp;
" text {{{2
hi Normal ctermfg=white ctermbg=black cterm=NONE
hi Folded ctermfg=lightgray ctermbg=black cterm=underline
hi LineNr ctermfg=darkgray ctermbg=NONE cterm=NONE
hi Directory ctermfg=cyan ctermbg=NONE cterm=NONE
hi NonText ctermfg=yellow ctermbg=NONE cterm=NONE
hi SpecialKey ctermfg=green ctermbg=NONE cterm=NONE
&nbsp;
hi DiffAdd ctermfg=white ctermbg=darkblue cterm=NONE
hi DiffChange ctermfg=black ctermbg=darkmagenta cterm=NONE
hi DiffDelete ctermfg=black ctermbg=red cterm=bold
hi DiffText ctermfg=white ctermbg=green cterm=bold
&nbsp;
" borders / separators / menus {{{2
hi FoldColumn ctermfg=lightgray ctermbg=darkgray cterm=NONE
hi SignColumn ctermfg=lightgray ctermbg=darkgray cterm=NONE
hi Pmenu ctermfg=white ctermbg=darkgray cterm=NONE
hi PmenuSel ctermfg=white ctermbg=lightblue cterm=NONE
hi PmenuSbar ctermfg=black ctermbg=black cterm=NONE
hi PmenuThumb ctermfg=gray ctermbg=gray cterm=NONE
&nbsp;
hi StatusLine ctermfg=black ctermbg=white cterm=bold
hi StatusLineNC ctermfg=darkgray ctermbg=white cterm=NONE
hi WildMenu ctermfg=white ctermbg=darkblue cterm=bold
hi VertSplit ctermfg=white ctermbg=white cterm=NONE
&nbsp;
if &amp;t_Co == 256|hi TabLine ctermfg=15 ctermbg=242 term=underline|else|hi TabLine ctermfg=grey ctermbg=white term=underline|endif
"hi TabLine ctermfg=white ctermbg=white cterm=NONE
hi TabLineFill ctermfg=grey ctermbg=white cterm=NONE
"hi TabLineSel ctermfg=black ctermbg=green cterm=NONE
hi TabLineSel ctermfg=green ctermbg=black term=bold
"hi TabLineSel term=bold cterm=bold
"hi TabLineFill term=reverse cterm=reverse 
"hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242
&nbsp;
"hi Menu
"hi Scrollbar
"hi Tooltip
&nbsp;
" cursor / dynamic / other {{{2
hi Cursor ctermfg=black ctermbg=white cterm=NONE
hi CursorIM ctermfg=black ctermbg=white cterm=reverse
hi CursorLine ctermfg=NONE ctermbg=NONE cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=NONE cterm=NONE
&nbsp;
hi Visual ctermfg=white ctermbg=lightblue cterm=NONE
hi IncSearch ctermfg=white ctermbg=yellow cterm=NONE
hi Search ctermfg=white ctermbg=darkgreen cterm=NONE
&nbsp;
" LISTINGS / MESSAGES {{{2
hi ModeMsg ctermfg=yellow ctermbg=NONE cterm=NONE
hi Title ctermfg=red ctermbg=NONE cterm=bold
hi Question ctermfg=green ctermbg=NONE cterm=NONE
hi MoreMsg ctermfg=green ctermbg=NONE cterm=NONE
hi ErrorMsg ctermfg=white ctermbg=red cterm=bold
hi WarningMsg ctermfg=yellow ctermbg=NONE cterm=bold
&nbsp;
hi Directory term=bold ctermfg=4 "{{{
hi ErrorMsg term=standout ctermfg=15 ctermbg=1  
hi IncSearch term=reverse cterm=reverse 
hi Search term=NONE ctermfg=255 ctermbg=135
hi MoreMsg term=bold ctermfg=2  
hi ModeMsg term=bold cterm=bold 
hi LineNr term=underline ctermfg=244 ctermbg=232  
hi Question term=standout ctermfg=2  
hi StatusLine term=bold,reverse cterm=italic ctermfg=253 ctermbg=238   
hi StatusLineNC term=reverse cterm=reverse ctermfg=246 ctermbg=238  
hi VertSplit term=reverse cterm=reverse ctermfg=238 ctermbg=238  
hi Title term=bold cterm=bold ctermfg=254  
hi Visual term=reverse ctermfg=254 ctermbg=4  
hi VisualNOS term=bold,underline cterm=bold,underline
hi WarningMsg term=standout ctermfg=1 
hi WildMenu term=standout ctermfg=0 ctermbg=11  
hi Folded term=standout cterm=BOLD ctermfg=7 ctermbg=27
hi FoldColumn term=NONE cterm=NONE ctermfg=75 ctermbg=16
hi IncSearch term=bold,underline cterm=bold,underline ctermfg=7 ctermbg=9
hi DiffAdd term=bold ctermbg=12 
hi DiffChange term=bold ctermbg=13 
hi DiffDelete term=bold ctermfg=12 ctermbg=14   
hi DiffText term=reverse cterm=bold ctermbg=9  
hi SpellBad term=reverse ctermbg=9  
hi SpellCap term=reverse ctermbg=12  
hi SpellRare term=reverse ctermbg=13  
hi SpellLocal term=underline ctermbg=14  
hi Pmenu ctermfg=255 ctermbg=238  
hi PmenuSel ctermfg=0 ctermbg=148  
hi PmenuSbar ctermbg=7 
hi PmenuThumb cterm=reverse 
hi TabLine term=underline cterm=underline ctermfg=0 ctermbg=7  
hi TabLineSel term=bold cterm=bold 
hi TabLineFill term=reverse cterm=reverse 
hi CursorLine term=underline cterm=bold ctermbg=234
hi Cursor ctermbg=241 
hi MatchParen term=reverse cterm=bold ctermfg=157 ctermbg=237   
hi Error term=reverse ctermfg=15 ctermbg=9  
&nbsp;
" :hi TabLineSel|hi TabLineFill|hi TabLine
"hi TabLineSel term=bold cterm=bold 
"hi TabLineFill term=reverse cterm=reverse 
"hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242 
hi ExtraWhitespace ctermbg=red
hi Comment term=none ctermfg=darkgrey 
hi Constant term=underline ctermfg=Magenta 
hi Special term=bold ctermfg=DarkMagenta 
hi Identifier term=underline cterm=bold ctermfg=Cyan 
hi Statement term=bold ctermfg=Yellow 
hi PreProc term=underline ctermfg=LightBlue 
hi Type term=underline ctermfg=LightGreen 
hi Repeat term=underline ctermfg=White 
hi Operator ctermfg=Red 
hi Ignore ctermfg=black 
hi Error term=reverse ctermbg=Red ctermfg=White 
hi Todo term=standout ctermbg=Yellow ctermfg=Black 
&nbsp;
" COMMON GROUPS THAT LINK TO DEFAULT HIGHLIGHTING.
&nbsp;
hi Function ctermfg=85
hi String ctermfg=204
hi Statement term=bold cterm=bold ctermfg=81
hi Function term=bold cterm=bold ctermfg=32
hi Number ctermfg=129
hi Conditional term=bold cterm=bold ctermfg=47
hi Special term=underline ctermfg=191
hi Normal ctermfg=7
hi PreProc ctermfg=141
" Syntax highlighting
hi Comment ctermfg=244
hi Todo ctermfg=245
hi Boolean ctermfg=148
hi String ctermfg=148
hi Identifier ctermfg=148
hi Function ctermfg=124
hi Type ctermfg=103
hi Statement ctermfg=103
hi Keyword ctermfg=81
hi Constant ctermfg=81
hi Number ctermfg=81
hi Special ctermfg=81
hi PreProc ctermfg=230
" Code-specific colors
 
&nbsp;
" SYNTAX HIGHLIGHTING GROUPS (:HELP GROUP-NAME) {{{2
hi FoldColumn ctermbg=0 ctermfg=2
hi Folded cterm=none ctermfg=2
hi NonText cterm=NONE ctermfg=NONE 
hi StatusLine ctermfg=black ctermbg=White cterm=bold
hi StatusLineNC ctermfg=White ctermbg=green cterm=NONE
hi CursorLine cterm=bold term=bold
&nbsp;
" FINAL THOUGHTS "{{{2
"syn region myFold start="{" end="}" transparent fold
hi Search term=reverse ctermfg=0 ctermbg=11
hi LineNr term=underline ctermfg=244 ctermbg=232
hi MatchParen ctermfg=15 ctermbg=242
hi String ctermfg=10
hi Constant ctermfg=14
hi Identifier ctermfg=14
hi Operator ctermfg=13
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17
</pre>


<h2>Additional Resources</h2>
<ol>
<li><a href="http://spf13.com/post/perfect-vimrc-vim-config-file">The perfect .vimrc vim config file</a></li>
</ol><p><a href="http://www.askapache.com/linux/fast-vimrc.html"></a><a href="http://www.askapache.com/linux/fast-vimrc.html">Optimized Vimrc with 256 Colorscheme</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/R0aO9xp5H_J0ghnoOmpjmsDlX7M/0/da"><img src="http://feedads.g.doubleclick.net/~a/R0aO9xp5H_J0ghnoOmpjmsDlX7M/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/R0aO9xp5H_J0ghnoOmpjmsDlX7M/1/da"><img src="http://feedads.g.doubleclick.net/~a/R0aO9xp5H_J0ghnoOmpjmsDlX7M/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/wXxpUz6HwbQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/fast-vimrc.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.askapache.com/linux/fast-vimrc.html</feedburner:origLink></item>
		<item>
		<title>Mod_Rewrite Security</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/5slFQRIRKic/mod_rewrite.html</link>
		<comments>http://www.askapache.com/security/mod_rewrite.html#comments</comments>
		<pubDate>Sat, 18 Feb 2012 06:54:18 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[RewriteCond]]></category>
		<category><![CDATA[RewriteRule]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=7045</guid>
		<description><![CDATA[<p><a class="hs hs13" href="http://www.askapache.com/security/mod_rewrite.html" title="Mod_Rewrite Artwork"></a>These are a few of the mod_rewrite uses that <a href="http://blogsecurity.net/">BlogSecurity</a> declared <strong>pushed the boundaries of Mod_Rewrite!</strong>  Some of these snippets are quite exotic and unlike anything you may have seen before, also only for those who understand them as they can kill a website pretty quick.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/security/mod_rewrite.html"></a><a href="http://www.askapache.com/security/mod_rewrite.html"><cite>AskApache.com</cite></a></p><p>Here are some <a href="http://www.askapache.com/htaccess/htaccess.html" title="Htaccess Tutorial">specific htaccess</a> examples taken mostly from my WordPress Password Protection plugin, which does alot more than password protection as you will see from the following mod_rewrite examples. These are a few of the mod_rewrite uses that <a href="http://blogsecurity.net/">BlogSecurity</a> declared <strong>pushed the boundaries of Mod_Rewrite!</strong>  Some of these snippets are quite exotic and unlike anything you may have seen before, also only for those who understand them as they can kill a website pretty quick.</p>

<h4>Directory Protection</h4>
<p>Enable the DirectoryIndex Protection, preventing directory index listings and defaulting. [<a href="/htaccess/htaccess.html">Disable</a>]</p>
<pre>
Options -Indexes
DirectoryIndex index.html index.php /index.php
</pre>

<h4>Password Protect wp-login.php</h4>
<p>Requires a valid user/pass to access the login page[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-401">401</a>]</p>
<pre>
&lt;Files wp-login.php&gt;
Order Deny,Allow
Deny from All
Satisfy Any
AuthName "Protected By AskApache"
AuthUserFile /home/askapache.com/.htpasswda1
AuthType Basic
Require valid-user
&lt;/Files&gt;
</pre>


<h4>Password Protect wp-admin</h4>
<p>Requires a valid user/pass to access any non-static (css, js, images) file in this directory.[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-401">401</a>]</p>
<pre>
Options -ExecCGI -Indexes +FollowSymLinks -Includes
DirectoryIndex index.php /index.php
Order Deny,Allow
Deny from All
Satisfy Any
AuthName "Protected By AskApache"
AuthUserFile /home/askapache.com/.htpasswda1
AuthType Basic
Require valid-user
&lt;FilesMatch "\.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$"&gt;
Allow from All
&lt;/FilesMatch&gt;
&lt;FilesMatch "(async-upload)\.php$"&gt;
&lt;IfModule mod_security.c&gt;
SecFilterEngine Off
&lt;/IfModule&gt;
Allow from All
&lt;/FilesMatch&gt;
</pre>

<h4>Protect wp-content</h4>
<p>Denies any Direct request for files ending in .php with a 403 Forbidden.. May break plugins/themes [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-401">401</a>]</p>
<pre>
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /wp-content/.*$ [NC]
RewriteCond %{REQUEST_FILENAME} !^.+flexible-upload-wp25js.php$
RewriteCond %{REQUEST_FILENAME} ^.+\.(php|html|htm|txt)$
RewriteRule .* - [F,NS,L]
</pre>

<h4>Protect wp-includes</h4>
<p>Denies any Direct request for files ending in .php with a 403 Forbidden.. May break plugins/themes [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /wp-includes/.*$ [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ /wp-includes/js/.+/.+\ HTTP/ [NC]
RewriteCond %{REQUEST_FILENAME} ^.+\.php$
RewriteRule .* - [F,NS,L]
</pre>

<h4>Common Exploits</h4>
<p>Block common exploit requests with 403 Forbidden. These can help alot, may break some plugins. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ ///.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\=?(http|ftp|ssl|https):/.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\?\?.*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(asp|ini|dll).*\ HTTP/ [NC,OR]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.(htpasswd|htaccess|aahtpasswd).*\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>Stop Hotlinking</h4>
<p>Denies any request for static files (images, css, etc) if referrer is not local site or empty. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{HTTP_REFERER} !^http://www.askapache.com.*$ [NC]
RewriteRule \.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$ - [F,NS,L]
</pre>

<h4>Safe Request Methods</h4>
<p>Denies any request not using <a href="http://www.askapache.com/online-tools/request-method-scanner/">GET,PROPFIND,POST,OPTIONS,PUT,HEAD</a>[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST|PROPFIND|OPTIONS|PUT)$ [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>Forbid Proxies</h4>
<p>Denies any POST Request using a Proxy Server. Can still access site, but not comment.  See <a href="http://perishablepress.com/press/2008/04/20/how-to-block-proxy-servers-via-htaccess/">Perishable Press</a> [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:VIA}%{HTTP:FORWARDED}%{HTTP:USERAGENT_VIA}%{HTTP:X_FORWARDED_FOR}%{HTTP:PROXY_CONNECTION} !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}%{HTTP:HTTP_PC_REMOTE_ADDR}%{HTTP:HTTP_CLIENT_IP} !^$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>Real wp-comments-post.php</h4>
<p>Denies any POST attempt made to a non-existing wp-comments-post.php[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*/wp-comments-post\.php.*\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>HTTP PROTOCOL</h4>
<p>Denies any badly formed HTTP PROTOCOL in the request, 0.9, 1.0, and 1.1 only[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ .+\ HTTP/(0\.9|1\.0|1\.1) [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>SPECIFY CHARACTERS</h4>
<p>Denies any request for a url containing characters other than "a-zA-Z0-9.+/-?=&amp;"  - REALLY helps but may break your site depending on your links. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&amp;amp;]+\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>BAD Content Length</h4>
<p>Denies any POST request that doesnt have a Content-Length Header[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:Content-Length} ^$
RewriteCond %{REQUEST_URI} !^/(wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>BAD Content Type</h4>
<p>Denies any POST request with a content type other than application/x-www-form-urlencoded|multipart/form-data[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP:Content-Type} !^(application/x-www-form-urlencoded|multipart/form-data.*(boundary.*)?)$ [NC]
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>Missing HTTP_HOST</h4>
<p>Denies requests that dont contain a HTTP HOST Header.[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteCond %{HTTP_HOST} ^$
RewriteRule .* - [F,NS,L]
</pre>

<h4>Bogus Graphics Exploit</h4>
<p>Denies obvious exploit using bogus graphics[<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{HTTP:Content-Disposition} \.php [NC]
RewriteCond %{HTTP:Content-Type} image/.+ [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>No UserAgent, Not POST</h4>
<p>Denies POST requests by blank user-agents.  May prevent a small number of visitors from POSTING. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>No Referer, No Comment</h4>
<p>Denies any comment attempt with a blank HTTP_REFERER field, highly indicative of spam.  May prevent some visitors from POSTING. [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*/wp-comments-post\.php.*\ HTTP/ [NC]
RewriteCond %{HTTP_REFERER} ^-?$
RewriteRule .* - [F,NS,L]
</pre>

<h4>Trackback Spam</h4>
<p>Denies obvious trackback spam.  See Holy Shmoly! [<a href="/htaccess/apache-status-code-headers-errordocument.html#status-403">403</a>]</p>
<pre>
RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{HTTP_USER_AGENT} ^.*(opera|mozilla|firefox|msie|safari).*$ [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.+/trackback/?\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]
</pre>

<h4>Map all URIs except those corresponding to existing files to a handler</h4>
<pre>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule . /script.php
</pre>

<h4>Map any request to a handler</h4>
<p>In the case where all URIs should be sent to the same place (including potentially requests for static content) the method to use depends on the type of the handler. For php scripts, use:
For other handlers such as php scripts, use:</p>
<pre>
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/script.php
RewriteRule .* /script.php
</pre>

<h4>And for CGI scripts:</h4>
<pre>
ScriptAliasMatch .* /var/www/script.cgi
</pre>

<h4>Map URIs corresponding to existing files to a handler instead</h4>
<pre>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteCond %{REQUEST_URI} !=/script.php
RewriteRule .* /script.php
</pre>
<p>If the existing files you wish to have handled by your script have a common set of file extensions distinct from that of the hander, you can bypass mod_rewrite and use instead mod_actions. Let's say you want all .html and .tpl files to be dealt with by your script:</p>
<pre>
Action foo-action /script.php
AddHandler foo-action html tpl
</pre>

<h4>Deny access if var=val contains the string foo.</h4>
<pre>
RewriteCond %{QUERY_STRING} foo
RewriteRule ^/url - [F]
</pre>

<h4>Removing the Query String</h4>
<pre>
RewriteRule ^/url /url?
</pre>

<h4>Adding to the Query String</h4>
<p>Keep the existing query string using the Query String Append flag, but add var=val to the end.</p>
<pre>
RewriteRule ^/url /url?var=val [QSA]
</pre>

<h4>Rewriting For Certain Query Strings</h4>
<p>Rewrite URLs like http://askapache.com/url1?var=val to http://askapache.com/url2?var=val but don't rewrite if val isn't present.</p>
<pre>
RewriteCond %{QUERY_STRING} val
RewriteRule ^/url1 /url2
</pre>

<h4>Modifying the Query String</h4>
<p>Change any single instance of val in the query string to other_val when accessing /path. Note that %1 and %2 are back-references to the matched part of the regular expression in the previous RewriteCond.</p>
<pre>
RewriteCond %{QUERY_STRING} ^(.*)val(.*)$
RewriteRule /path /path?%1other_val%2
</pre>
<hr class="C" />
<p><a href="http://www.askapache.com/security/mod_rewrite.html"></a><a href="http://www.askapache.com/security/mod_rewrite.html">Mod_Rewrite Security</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/AF-WvN91KP4CZzM4UVJYMpnS16A/0/da"><img src="http://feedads.g.doubleclick.net/~a/AF-WvN91KP4CZzM4UVJYMpnS16A/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/AF-WvN91KP4CZzM4UVJYMpnS16A/1/da"><img src="http://feedads.g.doubleclick.net/~a/AF-WvN91KP4CZzM4UVJYMpnS16A/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/5slFQRIRKic" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/security/mod_rewrite.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.askapache.com/security/mod_rewrite.html</feedburner:origLink></item>
		<item>
		<title>Chmod, Umask, Stat, Fileperms, and File Permissions</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/zRJWsA1FD3E/chmod-stat.html</link>
		<comments>http://www.askapache.com/security/chmod-stat.html#comments</comments>
		<pubDate>Fri, 17 Feb 2012 11:16:56 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[File Permissions]]></category>
		<category><![CDATA[umask]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=1800</guid>
		<description><![CDATA[<p><a class="IFL" id="id8" href="http://www.askapache.com/security/chmod-umask-fileperms-stat-tricks.html"></a>Unix file permissions are one of the more difficult subjects to grasp.. Well, ok maybe "grasp" isn't the word.. Master is the right word.. Unix file permissions is a hard topic to fully master, mainly I think because there aren't many instances when a computer user encounters them seriously, and bitwise is oldschool.  This contains a listing of all possible permission masks and bits from a linux, php, and web hosting view.... cuz you guys <em>AskApache Regs</em> Rock! <br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/security/chmod-stat.html"></a><a href="http://www.askapache.com/security/chmod-stat.html"><cite>AskApache.com</cite></a></p><p><a class="IFL" id="id8" href="http://www.askapache.com/security/chmod-stat.html"></a>Unix file permissions are one of the more difficult subjects to grasp.. Well, ok maybe "grasp" isn't the word.. Master is the right word.. Unix file permissions is a hard topic to fully master, mainly I think because there aren't many instances when a computer user encounters them.   Windows has been trying to figure it out for decades with little progress, so don't feel bad if you don't know much about it.  <strong>Unless you're with the program</strong> and running Mac or any other <a href="http://www.archlinux.org/">BSD/Unix</a> based OS you've never had the ability to secure your system in this most basic and fundamental way.  Usually the first time someone encounters file permissions it's because their website was cracked.. <br class="C" /></p>

<h3>.htaccess</h3>
<p><kbd>$ chmod 604 .htaccess</kbd></p>
<pre>
604 -rw----r--  /home/askapache/cgi-bin/.htaccess
</pre>


<h3>php.cgi</h3>
<p><kbd>$ chmod 711 php.cgi</kbd></p>
<pre>
$ 711 -rwx--x--x  /home/askapache/cgi-bin/php.cgi
</pre>


<h3>.php.ini</h3>
<p><kbd>$ chmod 600 php.ini</kbd></p>
<pre>
$ 600 -rw-------  /home/askapache/cgi-bin/php.ini
</pre>

<p>I'm in the process of developing an updated version of the .htaccess security plugin, and one thing I have been working on is file permissions.  Some people had problems trying to create files on their server and I realized it was bad programming on my part..  so I began researching permissions in detail. I went deep into the source code of Apache (<em>which is why this site is called AskApache, BTW</em>), PHP, Python, Ocaml, Perl, Ruby, and POSIX operating systems and got a pretty good handle on it now..</p>

<h2>Tips before we dig in</h2>
<p>Here's a few things I've learned that I didn't know before (using php).</p>

<h3>Deleting Files and Directories</h3>
<p>Deleting a file may require chmodding the file to 666 or even 777 before you are able to delete it.  You also might have to chmod the parent directory of the file as well.  Also, you may have to chdir to the directory the file is in.  And lastly you may have to change the owner or group of the file.  Further than that you can try renaming the file first then deleting it..</p>
<p>Deleting a directory means you need to remove every file in it first.  It needs to be empty.  And if your file system uses NFS or some other networked FS you might have even more problems deleting files.  If the file you are trying to delete is being used by say, Apache or php then you might have to kill that process first.</p>

<h3>Creating Files in Restrictive Environments</h3>
<p>My research has been geared to try and make my code as robust as possible, I'm throwing everything but the kitchen sink into some of these functions because so many people are on such different types of servers.  To create a file in a restrictive environment is a fun excercise to take.. You can write a file using many different functions, but there are some tricks if they all fail.  One trick is instead of trying to "write" the data to the file, you can UPLOAD the data to the server and let PHP handle the file as if you used an upload form.  I like to use fsockopen to do it, as some installations have been setup to prevent this type of fake upload.</p>
<p>Then there are the various other hacks like using an ftp connection (if you know the user/pass) to send the file from php, using ssh from php, whatever is available on the hosts php installation.  In addition to those more involved workarounds you can often get around this problem by doing little hacks discussed at php.net in the comments for various functions.  Such as changing the umask, changing directories with chdir first, creating a temporary file using a function like tempfile and then renaming or copying the tempfile to your desired file which sometimes gives you the permissions needed to write to the location.</p>
<p>If the php installation is newer than you can also look into creating your own stream context to pass write the data direct.</p>


<h2>Stat Function</h2>
<p>I've created a stat function in php that goes farther than the normal stat function... Just give the function a file to stat, and it returns an array of information.  </p>
<pre>
function askapache_stat($filename) {
 clearstatcache();
 $ss=@stat($filename);
 if(!$ss) die("Couldnt stat {$filename}");
 $file_convert=array(0140000=&gt;&#039;ssocket&#039;,0120000=&gt;&#039;llink&#039;,0100000=&gt;&#039;-file&#039;,0060000=&gt;&#039;bblock&#039;,0040000=&gt;&#039;ddir&#039;,0020000=&gt;&#039;cchar&#039;,0010000=&gt;&#039;pfifo&#039;);
 $p=$ss[&#039;mode&#039;];
 $t=decoct($ss[&#039;mode&#039;] &amp; 0170000);
 $str = (array_key_exists(octdec($t),$file_convert)) ? $file_convert[octdec($t)]{0} : &#039;u&#039;;
 $str.=(($p&amp;0x0100)?&#039;r&#039;:&#039;-&#039;).(($p&amp;0x0080)?&#039;w&#039;:&#039;-&#039;).(($p&amp;0x0040)?(($p&amp;0x0800)?&#039;s&#039;:&#039;x&#039;):(($p&amp;0x0800)?&#039;S&#039;:&#039;-&#039;));
 $str.=(($p&amp;0x0020)?&#039;r&#039;:&#039;-&#039;).(($p&amp;0x0010)?&#039;w&#039;:&#039;-&#039;).(($p&amp;0x0008)?(($p&amp;0x0400)?&#039;s&#039;:&#039;x&#039;):(($p&amp;0x0400)?&#039;S&#039;:&#039;-&#039;));
 $str.=(($p&amp;0x0004)?&#039;r&#039;:&#039;-&#039;).(($p&amp;0x0002)?&#039;w&#039;:&#039;-&#039;).(($p&amp;0x0001)?(($p&amp;0x0200)?&#039;t&#039;:&#039;x&#039;):(($p&amp;0x0200)?&#039;T&#039;:&#039;-&#039;));
&nbsp;
 $s=array(
 &#039;perms&#039;=&gt;array(
  &#039;umask&#039;=&gt;sprintf("%04o",umask()),
  &#039;human&#039;=&gt;$str,
  &#039;octal1&#039;=&gt;sprintf("%o", ($ss[&#039;mode&#039;] &amp; 000777)),
  &#039;octal2&#039;=&gt;sprintf("0%o", 0777 &amp; $p),
  &#039;decimal&#039;=&gt;sprintf("%04o", $p),
  &#039;fileperms&#039;=&gt;@fileperms($filename),
  &#039;mode1&#039;=&gt;$p,
  &#039;mode2&#039;=&gt;$ss[&#039;mode&#039;]),
&nbsp;
 &#039;filetype&#039;=&gt;array(
  &#039;type&#039;=&gt;substr($file_convert[octdec($t)],1),
  &#039;type_octal&#039;=&gt;sprintf("%07o", octdec($t)),
  &#039;is_file&#039;=&gt;@is_file($filename),
  &#039;is_dir&#039;=&gt;@is_dir($filename),
  &#039;is_link&#039;=&gt;@is_link($filename),
  &#039;is_readable&#039;=&gt; @is_readable($filename),
  &#039;is_writable&#039;=&gt; @is_writable($filename)),
&nbsp;
 &#039;owner&#039;=&gt;array(
  &#039;fileowner&#039;=&gt;$ss[&#039;uid&#039;],
  &#039;filegroup&#039;=&gt;$ss[&#039;gid&#039;],
  &#039;owner_name&#039;=&gt;(function_exists(&#039;posix_getpwuid&#039;)) ? @reset(@posix_getpwuid($ss[&#039;uid&#039;])) : &#039;&#039;,
  &#039;group_name&#039;=&gt;(function_exists(&#039;posix_getgrgid&#039;)) ? @reset(@posix_getgrgid($ss[&#039;gid&#039;])) : &#039;&#039;),
&nbsp;
 &#039;file&#039;=&gt;array(
  &#039;filename&#039;=&gt;$filename,
  &#039;realpath&#039;=&gt;(@realpath($filename) != $filename) ? @realpath($filename) : &#039;&#039;,
  &#039;dirname&#039;=&gt;@dirname($filename),
  &#039;basename&#039;=&gt;@basename($filename)),
&nbsp;
 &#039;device&#039;=&gt;array(
  &#039;device&#039;=&gt;$ss[&#039;dev&#039;], //Device
  &#039;device_number&#039;=&gt;$ss[&#039;rdev&#039;], //Device number, if device.
  &#039;inode&#039;=&gt;$ss[&#039;ino&#039;], //File serial number
  &#039;link_count&#039;=&gt;$ss[&#039;nlink&#039;], //link count
  &#039;link_to&#039;=&gt;($s[&#039;type&#039;]==&#039;link&#039;) ? @readlink($filename) : &#039;&#039;),
&nbsp;
 &#039;size&#039;=&gt;array(
  &#039;size&#039;=&gt;$ss[&#039;size&#039;], //Size of file, in bytes.
  &#039;blocks&#039;=&gt;$ss[&#039;blocks&#039;], //Number 512-byte blocks allocated
  &#039;block_size&#039;=&gt; $ss[&#039;blksize&#039;]), //Optimal block size for I/O.
&nbsp;
 &#039;time&#039;=&gt;array(
  &#039;mtime&#039;=&gt;$ss[&#039;mtime&#039;], //Time of last modification
  &#039;atime&#039;=&gt;$ss[&#039;atime&#039;], //Time of last access.
  &#039;ctime&#039;=&gt;$ss[&#039;ctime&#039;], //Time of last status change
  &#039;accessed&#039;=&gt;@date(&#039;Y M D H:i:s&#039;,$ss[&#039;atime&#039;]),
  &#039;modified&#039;=&gt;@date(&#039;Y M D H:i:s&#039;,$ss[&#039;mtime&#039;]),
  &#039;created&#039;=&gt;@date(&#039;Y M D H:i:s&#039;,$ss[&#039;ctime&#039;])),
 );
&nbsp;
 clearstatcache();
 return $s;
}
</pre>


<h3>PHP Stat Function Output</h2>
<p>Example output, say from <code>print_r(askapache_stat( __FILE__ ) );</code></p>
<pre>
Array(
[perms] =&gt; Array
  (
  [umask] =&gt; 0022
  [human] =&gt; -rw-r--r--
  [octal1] =&gt; 644
  [octal2] =&gt; 0644
  [decimal] =&gt; 100644
  [fileperms] =&gt; 33188
  [mode1] =&gt; 33188
  [mode2] =&gt; 33188
  )
&nbsp;
[filetype] =&gt; Array
  (
  [type] =&gt; file
  [type_octal] =&gt; 0100000
  [is_file] =&gt; 1
  [is_dir] =&gt;
  [is_link] =&gt;
  [is_readable] =&gt; 1
  [is_writable] =&gt; 1
  )
&nbsp;
[owner] =&gt; Array
  (
  [fileowner] =&gt; 035483
  [filegroup] =&gt; 23472
  [owner_name] =&gt; askapache
  [group_name] =&gt; grp22558
  )
&nbsp;
[file] =&gt; Array
  (
  [filename] =&gt; /home/askapache/askapache-stat/public_html/ok/g.php
  [realpath] =&gt;
  [dirname] =&gt; /home/askapache/askapache-stat/public_html/ok
  [basename] =&gt; g.php
  )
&nbsp;
[device] =&gt; Array
  (
  [device] =&gt; 25
  [device_number] =&gt; 0
  [inode] =&gt; 92455020
  [link_count] =&gt; 1
  [link_to] =&gt;
  )
&nbsp;
[size] =&gt; Array
  (
  [size] =&gt; 2652
  [blocks] =&gt; 8
  [block_size] =&gt; 8192
  )
&nbsp;
[time] =&gt; Array
  (
  [mtime] =&gt; 1227685253
  [atime] =&gt; 1227685138
  [ctime] =&gt; 1227685253
  [accessed] =&gt; 2008 Nov Tue 23:38:58
  [modified] =&gt; 2008 Nov Tue 23:40:53
  [created] =&gt; 2008 Nov Tue 23:40:53
  )
)
</pre>






<h2><a id="chmod-0-to-7777"></a>Every Permission 0000 to 0777</h2>
<p><a class="IFL" href="http://uploads.askapache.com/2008/11/danger-chmod-screenshot.png"><img src="http://uploads.askapache.com/2008/11/danger-chmod-screenshot.png" alt="chmod, umask, file permissions test" title="chmod, umask, file permissions test" /></a>This shows what each numeric permission does to a REGULAR file.  I'll provide the code to do this below so you can do the same thing on your server.<br class="C" /></p>
<dl class="dlsm" style="border-right:1px solid #CCC;">
<dt><kbd>chmod 0</kbd></dt>
<dd><code>----------</code></dd>
<dt><kbd>chmod 1</kbd></dt>
<dd><code>---------x</code></dd>
<dt><kbd>chmod 2</kbd></dt>
<dd><code>--------w-</code></dd>
<dt><kbd>chmod 3</kbd></dt>
<dd><code>--------wx</code></dd>
<dt><kbd>chmod 4</kbd></dt>
<dd><code>-------r--</code></dd>
<dt><kbd>chmod 5</kbd></dt>
<dd><code>-------r-x</code></dd>
<dt><kbd>chmod 6</kbd></dt>
<dd><code>-------rw-</code></dd>
<dt><kbd>chmod 7</kbd></dt>
<dd><code>-------rwx</code></dd>
<dt><kbd>chmod 10</kbd></dt>
<dd><code>------x---</code></dd>
<dt><kbd>chmod 11</kbd></dt>
<dd><code>------x--x</code></dd>
<dt><kbd>chmod 12</kbd></dt>
<dd><code>------x-w-</code></dd>
<dt><kbd>chmod 13</kbd></dt>
<dd><code>------x-wx</code></dd>
<dt><kbd>chmod 14</kbd></dt>
<dd><code>------xr--</code></dd>
<dt><kbd>chmod 15</kbd></dt>
<dd><code>------xr-x</code></dd>
<dt><kbd>chmod 16</kbd></dt>
<dd><code>------xrw-</code></dd>
<dt><kbd>chmod 17</kbd></dt>
<dd><code>------xrwx</code></dd>
<dt><kbd>chmod 20</kbd></dt>
<dd><code>-----w----</code></dd>
<dt><kbd>chmod 21</kbd></dt>
<dd><code>-----w---x</code></dd>
<dt><kbd>chmod 22</kbd></dt>
<dd><code>-----w--w-</code></dd>
<dt><kbd>chmod 23</kbd></dt>
<dd><code>-----w--wx</code></dd>
<dt><kbd>chmod 24</kbd></dt>
<dd><code>-----w-r--</code></dd>
<dt><kbd>chmod 25</kbd></dt>
<dd><code>-----w-r-x</code></dd>
<dt><kbd>chmod 26</kbd></dt>
<dd><code>-----w-rw-</code></dd>
<dt><kbd>chmod 27</kbd></dt>
<dd><code>-----w-rwx</code></dd>
<dt><kbd>chmod 30</kbd></dt>
<dd><code>-----wx---</code></dd>
<dt><kbd>chmod 31</kbd></dt>
<dd><code>-----wx--x</code></dd>
<dt><kbd>chmod 32</kbd></dt>
<dd><code>-----wx-w-</code></dd>
<dt><kbd>chmod 33</kbd></dt>
<dd><code>-----wx-wx</code></dd>
<dt><kbd>chmod 34</kbd></dt>
<dd><code>-----wxr--</code></dd>
<dt><kbd>chmod 35</kbd></dt>
<dd><code>-----wxr-x</code></dd>
<dt><kbd>chmod 36</kbd></dt>
<dd><code>-----wxrw-</code></dd>
<dt><kbd>chmod 37</kbd></dt>
<dd><code>-----wxrwx</code></dd>
<dt><kbd>chmod 40</kbd></dt>
<dd><code>----r-----</code></dd>
<dt><kbd>chmod 41</kbd></dt>
<dd><code>----r----x</code></dd>
<dt><kbd>chmod 42</kbd></dt>
<dd><code>----r---w-</code></dd>
<dt><kbd>chmod 43</kbd></dt>
<dd><code>----r---wx</code></dd>
<dt><kbd>chmod 44</kbd></dt>
<dd><code>----r--r--</code></dd>
<dt><kbd>chmod 45</kbd></dt>
<dd><code>----r--r-x</code></dd>
<dt><kbd>chmod 46</kbd></dt>
<dd><code>----r--rw-</code></dd>
<dt><kbd>chmod 47</kbd></dt>
<dd><code>----r--rwx</code></dd>
<dt><kbd>chmod 50</kbd></dt>
<dd><code>----r-x---</code></dd>
<dt><kbd>chmod 51</kbd></dt>
<dd><code>----r-x--x</code></dd>
<dt><kbd>chmod 52</kbd></dt>
<dd><code>----r-x-w-</code></dd>
<dt><kbd>chmod 53</kbd></dt>
<dd><code>----r-x-wx</code></dd>
<dt><kbd>chmod 54</kbd></dt>
<dd><code>----r-xr--</code></dd>
<dt><kbd>chmod 55</kbd></dt>
<dd><code>----r-xr-x</code></dd>
<dt><kbd>chmod 56</kbd></dt>
<dd><code>----r-xrw-</code></dd>
<dt><kbd>chmod 57</kbd></dt>
<dd><code>----r-xrwx</code></dd>
<dt><kbd>chmod 60</kbd></dt>
<dd><code>----rw----</code></dd>
<dt><kbd>chmod 61</kbd></dt>
<dd><code>----rw---x</code></dd>
<dt><kbd>chmod 62</kbd></dt>
<dd><code>----rw--w-</code></dd>
<dt><kbd>chmod 63</kbd></dt>
<dd><code>----rw--wx</code></dd>
<dt><kbd>chmod 64</kbd></dt>
<dd><code>----rw-r--</code></dd>
<dt><kbd>chmod 65</kbd></dt>
<dd><code>----rw-r-x</code></dd>
<dt><kbd>chmod 66</kbd></dt>
<dd><code>----rw-rw-</code></dd>
<dt><kbd>chmod 67</kbd></dt>
<dd><code>----rw-rwx</code></dd>
<dt><kbd>chmod 70</kbd></dt>
<dd><code>----rwx---</code></dd>
<dt><kbd>chmod 71</kbd></dt>
<dd><code>----rwx--x</code></dd>
<dt><kbd>chmod 72</kbd></dt>
<dd><code>----rwx-w-</code></dd>
<dt><kbd>chmod 73</kbd></dt>
<dd><code>----rwx-wx</code></dd>
<dt><kbd>chmod 74</kbd></dt>
<dd><code>----rwxr--</code></dd>
<dt><kbd>chmod 75</kbd></dt>
<dd><code>----rwxr-x</code></dd>
<dt><kbd>chmod 76</kbd></dt>
<dd><code>----rwxrw-</code></dd>
<dt><kbd>chmod 77</kbd></dt>
<dd><code>----rwxrwx</code></dd>
<dt><kbd>chmod 100</kbd></dt>
<dd><code>---x------</code></dd>
<dt><kbd>chmod 101</kbd></dt>
<dd><code>---x-----x</code></dd>
<dt><kbd>chmod 102</kbd></dt>
<dd><code>---x----w-</code></dd>
<dt><kbd>chmod 103</kbd></dt>
<dd><code>---x----wx</code></dd>
<dt><kbd>chmod 104</kbd></dt>
<dd><code>---x---r--</code></dd>
<dt><kbd>chmod 105</kbd></dt>
<dd><code>---x---r-x</code></dd>
<dt><kbd>chmod 106</kbd></dt>
<dd><code>---x---rw-</code></dd>
<dt><kbd>chmod 107</kbd></dt>
<dd><code>---x---rwx</code></dd>
<dt><kbd>chmod 110</kbd></dt>
<dd><code>---x--x---</code></dd>
<dt><kbd>chmod 111</kbd></dt>
<dd><code>---x--x--x</code></dd>
<dt><kbd>chmod 112</kbd></dt>
<dd><code>---x--x-w-</code></dd>
<dt><kbd>chmod 113</kbd></dt>
<dd><code>---x--x-wx</code></dd>
<dt><kbd>chmod 114</kbd></dt>
<dd><code>---x--xr--</code></dd>
<dt><kbd>chmod 115</kbd></dt>
<dd><code>---x--xr-x</code></dd>
<dt><kbd>chmod 116</kbd></dt>
<dd><code>---x--xrw-</code></dd>
<dt><kbd>chmod 117</kbd></dt>
<dd><code>---x--xrwx</code></dd>
<dt><kbd>chmod 120</kbd></dt>
<dd><code>---x-w----</code></dd>
<dt><kbd>chmod 121</kbd></dt>
<dd><code>---x-w---x</code></dd>
<dt><kbd>chmod 122</kbd></dt>
<dd><code>---x-w--w-</code></dd>
<dt><kbd>chmod 123</kbd></dt>
<dd><code>---x-w--wx</code></dd>
<dt><kbd>chmod 124</kbd></dt>
<dd><code>---x-w-r--</code></dd>
<dt><kbd>chmod 125</kbd></dt>
<dd><code>---x-w-r-x</code></dd>
<dt><kbd>chmod 126</kbd></dt>
<dd><code>---x-w-rw-</code></dd>
<dt><kbd>chmod 127</kbd></dt>
<dd><code>---x-w-rwx</code></dd>
<dt><kbd>chmod 130</kbd></dt>
<dd><code>---x-wx---</code></dd>
<dt><kbd>chmod 131</kbd></dt>
<dd><code>---x-wx--x</code></dd>
<dt><kbd>chmod 132</kbd></dt>
<dd><code>---x-wx-w-</code></dd>
<dt><kbd>chmod 133</kbd></dt>
<dd><code>---x-wx-wx</code></dd>
<dt><kbd>chmod 134</kbd></dt>
<dd><code>---x-wxr--</code></dd>
<dt><kbd>chmod 135</kbd></dt>
<dd><code>---x-wxr-x</code></dd>
<dt><kbd>chmod 136</kbd></dt>
<dd><code>---x-wxrw-</code></dd>
<dt><kbd>chmod 137</kbd></dt>
<dd><code>---x-wxrwx</code></dd>
<dt><kbd>chmod 140</kbd></dt>
<dd><code>---xr-----</code></dd>
<dt><kbd>chmod 141</kbd></dt>
<dd><code>---xr----x</code></dd>
<dt><kbd>chmod 142</kbd></dt>
<dd><code>---xr---w-</code></dd>
<dt><kbd>chmod 143</kbd></dt>
<dd><code>---xr---wx</code></dd>
<dt><kbd>chmod 144</kbd></dt>
<dd><code>---xr--r--</code></dd>
<dt><kbd>chmod 145</kbd></dt>
<dd><code>---xr--r-x</code></dd>
<dt><kbd>chmod 146</kbd></dt>
<dd><code>---xr--rw-</code></dd>
<dt><kbd>chmod 147</kbd></dt>
<dd><code>---xr--rwx</code></dd>
<dt><kbd>chmod 150</kbd></dt>
<dd><code>---xr-x---</code></dd>
<dt><kbd>chmod 151</kbd></dt>
<dd><code>---xr-x--x</code></dd>
<dt><kbd>chmod 152</kbd></dt>
<dd><code>---xr-x-w-</code></dd>
<dt><kbd>chmod 153</kbd></dt>
<dd><code>---xr-x-wx</code></dd>
<dt><kbd>chmod 154</kbd></dt>
<dd><code>---xr-xr--</code></dd>
<dt><kbd>chmod 155</kbd></dt>
<dd><code>---xr-xr-x</code></dd>
<dt><kbd>chmod 156</kbd></dt>
<dd><code>---xr-xrw-</code></dd>
<dt><kbd>chmod 157</kbd></dt>
<dd><code>---xr-xrwx</code></dd>
<dt><kbd>chmod 160</kbd></dt>
<dd><code>---xrw----</code></dd>
<dt><kbd>chmod 161</kbd></dt>
<dd><code>---xrw---x</code></dd>
<dt><kbd>chmod 162</kbd></dt>
<dd><code>---xrw--w-</code></dd>
<dt><kbd>chmod 163</kbd></dt>
<dd><code>---xrw--wx</code></dd>
<dt><kbd>chmod 164</kbd></dt>
<dd><code>---xrw-r--</code></dd>
<dt><kbd>chmod 165</kbd></dt>
<dd><code>---xrw-r-x</code></dd>
<dt><kbd>chmod 166</kbd></dt>
<dd><code>---xrw-rw-</code></dd>
<dt><kbd>chmod 167</kbd></dt>
<dd><code>---xrw-rwx</code></dd>
<dt><kbd>chmod 170</kbd></dt>
<dd><code>---xrwx---</code></dd>
<dt><kbd>chmod 171</kbd></dt>
<dd><code>---xrwx--x</code></dd>
<dt><kbd>chmod 172</kbd></dt>
<dd><code>---xrwx-w-</code></dd>
<dt><kbd>chmod 173</kbd></dt>
<dd><code>---xrwx-wx</code></dd>
<dt><kbd>chmod 174</kbd></dt>
<dd><code>---xrwxr--</code></dd>
<dt><kbd>chmod 175</kbd></dt>
<dd><code>---xrwxr-x</code></dd>
<dt><kbd>chmod 176</kbd></dt>
<dd><code>---xrwxrw-</code></dd>
<dt><kbd>chmod 177</kbd></dt>
<dd><code>---xrwxrwx</code></dd>
<dt><kbd>chmod 200</kbd></dt>
<dd><code>--w-------</code></dd>
<dt><kbd>chmod 201</kbd></dt>
<dd><code>--w------x</code></dd>
<dt><kbd>chmod 202</kbd></dt>
<dd><code>--w-----w-</code></dd>
<dt><kbd>chmod 203</kbd></dt>
<dd><code>--w-----wx</code></dd>
<dt><kbd>chmod 204</kbd></dt>
<dd><code>--w----r--</code></dd>
<dt><kbd>chmod 205</kbd></dt>
<dd><code>--w----r-x</code></dd>
<dt><kbd>chmod 206</kbd></dt>
<dd><code>--w----rw-</code></dd>
<dt><kbd>chmod 207</kbd></dt>
<dd><code>--w----rwx</code></dd>
<dt><kbd>chmod 210</kbd></dt>
<dd><code>--w---x---</code></dd>
<dt><kbd>chmod 211</kbd></dt>
<dd><code>--w---x--x</code></dd>
<dt><kbd>chmod 212</kbd></dt>
<dd><code>--w---x-w-</code></dd>
<dt><kbd>chmod 213</kbd></dt>
<dd><code>--w---x-wx</code></dd>
<dt><kbd>chmod 214</kbd></dt>
<dd><code>--w---xr--</code></dd>
<dt><kbd>chmod 215</kbd></dt>
<dd><code>--w---xr-x</code></dd>
<dt><kbd>chmod 216</kbd></dt>
<dd><code>--w---xrw-</code></dd>
<dt><kbd>chmod 217</kbd></dt>
<dd><code>--w---xrwx</code></dd>
<dt><kbd>chmod 220</kbd></dt>
<dd><code>--w--w----</code></dd>
<dt><kbd>chmod 221</kbd></dt>
<dd><code>--w--w---x</code></dd>
<dt><kbd>chmod 222</kbd></dt>
<dd><code>--w--w--w-</code></dd>
<dt><kbd>chmod 223</kbd></dt>
<dd><code>--w--w--wx</code></dd>
<dt><kbd>chmod 224</kbd></dt>
<dd><code>--w--w-r--</code></dd>
<dt><kbd>chmod 225</kbd></dt>
<dd><code>--w--w-r-x</code></dd>
<dt><kbd>chmod 226</kbd></dt>
<dd><code>--w--w-rw-</code></dd>
<dt><kbd>chmod 227</kbd></dt>
<dd><code>--w--w-rwx</code></dd>
<dt><kbd>chmod 230</kbd></dt>
<dd><code>--w--wx---</code></dd>
<dt><kbd>chmod 231</kbd></dt>
<dd><code>--w--wx--x</code></dd>
<dt><kbd>chmod 232</kbd></dt>
<dd><code>--w--wx-w-</code></dd>
<dt><kbd>chmod 233</kbd></dt>
<dd><code>--w--wx-wx</code></dd>
<dt><kbd>chmod 234</kbd></dt>
<dd><code>--w--wxr--</code></dd>
<dt><kbd>chmod 235</kbd></dt>
<dd><code>--w--wxr-x</code></dd>
<dt><kbd>chmod 236</kbd></dt>
<dd><code>--w--wxrw-</code></dd>
<dt><kbd>chmod 237</kbd></dt>
<dd><code>--w--wxrwx</code></dd>
<dt><kbd>chmod 240</kbd></dt>
<dd><code>--w-r-----</code></dd>
<dt><kbd>chmod 241</kbd></dt>
<dd><code>--w-r----x</code></dd>
<dt><kbd>chmod 242</kbd></dt>
<dd><code>--w-r---w-</code></dd>
<dt><kbd>chmod 243</kbd></dt>
<dd><code>--w-r---wx</code></dd>
<dt><kbd>chmod 244</kbd></dt>
<dd><code>--w-r--r--</code></dd>
<dt><kbd>chmod 245</kbd></dt>
<dd><code>--w-r--r-x</code></dd>
<dt><kbd>chmod 246</kbd></dt>
<dd><code>--w-r--rw-</code></dd>
<dt><kbd>chmod 247</kbd></dt>
<dd><code>--w-r--rwx</code></dd>
<dt><kbd>chmod 250</kbd></dt>
<dd><code>--w-r-x---</code></dd>
<dt><kbd>chmod 251</kbd></dt>
<dd><code>--w-r-x--x</code></dd>
<dt><kbd>chmod 252</kbd></dt>
<dd><code>--w-r-x-w-</code></dd>
<dt><kbd>chmod 253</kbd></dt>
<dd><code>--w-r-x-wx</code></dd>
<dt><kbd>chmod 254</kbd></dt>
<dd><code>--w-r-xr--</code></dd>
<dt><kbd>chmod 255</kbd></dt>
<dd><code>--w-r-xr-x</code></dd>
<dt><kbd>chmod 256</kbd></dt>
<dd><code>--w-r-xrw-</code></dd>
<dt><kbd>chmod 257</kbd></dt>
<dd><code>--w-r-xrwx</code></dd>
<dt><kbd>chmod 260</kbd></dt>
<dd><code>--w-rw----</code></dd>
<dt><kbd>chmod 261</kbd></dt>
<dd><code>--w-rw---x</code></dd>
<dt><kbd>chmod 262</kbd></dt>
<dd><code>--w-rw--w-</code></dd>
<dt><kbd>chmod 263</kbd></dt>
<dd><code>--w-rw--wx</code></dd>
<dt><kbd>chmod 264</kbd></dt>
<dd><code>--w-rw-r--</code></dd>
<dt><kbd>chmod 265</kbd></dt>
<dd><code>--w-rw-r-x</code></dd>
<dt><kbd>chmod 266</kbd></dt>
<dd><code>--w-rw-rw-</code></dd>
<dt><kbd>chmod 267</kbd></dt>
<dd><code>--w-rw-rwx</code></dd>
<dt><kbd>chmod 270</kbd></dt>
<dd><code>--w-rwx---</code></dd>
<dt><kbd>chmod 271</kbd></dt>
<dd><code>--w-rwx--x</code></dd>
<dt><kbd>chmod 272</kbd></dt>
<dd><code>--w-rwx-w-</code></dd>
<dt><kbd>chmod 273</kbd></dt>
<dd><code>--w-rwx-wx</code></dd>
<dt><kbd>chmod 274</kbd></dt>
<dd><code>--w-rwxr--</code></dd>
<dt><kbd>chmod 275</kbd></dt>
<dd><code>--w-rwxr-x</code></dd>
<dt><kbd>chmod 276</kbd></dt>
<dd><code>--w-rwxrw-</code></dd>
<dt><kbd>chmod 277</kbd></dt>
<dd><code>--w-rwxrwx</code></dd>
<dt><kbd>chmod 300</kbd></dt>
<dd><code>--wx------</code></dd>
<dt><kbd>chmod 301</kbd></dt>
<dd><code>--wx-----x</code></dd>
<dt><kbd>chmod 302</kbd></dt>
<dd><code>--wx----w-</code></dd>
<dt><kbd>chmod 303</kbd></dt>
<dd><code>--wx----wx</code></dd>
<dt><kbd>chmod 304</kbd></dt>
<dd><code>--wx---r--</code></dd>
<dt><kbd>chmod 305</kbd></dt>
<dd><code>--wx---r-x</code></dd>
<dt><kbd>chmod 306</kbd></dt>
<dd><code>--wx---rw-</code></dd>
<dt><kbd>chmod 307</kbd></dt>
<dd><code>--wx---rwx</code></dd>
<dt><kbd>chmod 310</kbd></dt>
<dd><code>--wx--x---</code></dd>
<dt><kbd>chmod 311</kbd></dt>
<dd><code>--wx--x--x</code></dd>
<dt><kbd>chmod 312</kbd></dt>
<dd><code>--wx--x-w-</code></dd>
<dt><kbd>chmod 313</kbd></dt>
<dd><code>--wx--x-wx</code></dd>
<dt><kbd>chmod 314</kbd></dt>
<dd><code>--wx--xr--</code></dd>
<dt><kbd>chmod 315</kbd></dt>
<dd><code>--wx--xr-x</code></dd>
<dt><kbd>chmod 316</kbd></dt>
<dd><code>--wx--xrw-</code></dd>
<dt><kbd>chmod 317</kbd></dt>
<dd><code>--wx--xrwx</code></dd>
<dt><kbd>chmod 320</kbd></dt>
<dd><code>--wx-w----</code></dd>
<dt><kbd>chmod 321</kbd></dt>
<dd><code>--wx-w---x</code></dd>
<dt><kbd>chmod 322</kbd></dt>
<dd><code>--wx-w--w-</code></dd>
<dt><kbd>chmod 323</kbd></dt>
<dd><code>--wx-w--wx</code></dd>
<dt><kbd>chmod 324</kbd></dt>
<dd><code>--wx-w-r--</code></dd>
<dt><kbd>chmod 325</kbd></dt>
<dd><code>--wx-w-r-x</code></dd>
<dt><kbd>chmod 326</kbd></dt>
<dd><code>--wx-w-rw-</code></dd>
<dt><kbd>chmod 327</kbd></dt>
<dd><code>--wx-w-rwx</code></dd>
<dt><kbd>chmod 330</kbd></dt>
<dd><code>--wx-wx---</code></dd>
<dt><kbd>chmod 331</kbd></dt>
<dd><code>--wx-wx--x</code></dd>
<dt><kbd>chmod 332</kbd></dt>
<dd><code>--wx-wx-w-</code></dd>
<dt><kbd>chmod 333</kbd></dt>
<dd><code>--wx-wx-wx</code></dd>
<dt><kbd>chmod 334</kbd></dt>
<dd><code>--wx-wxr--</code></dd>
<dt><kbd>chmod 335</kbd></dt>
<dd><code>--wx-wxr-x</code></dd>
<dt><kbd>chmod 336</kbd></dt>
<dd><code>--wx-wxrw-</code></dd>
<dt><kbd>chmod 337</kbd></dt>
<dd><code>--wx-wxrwx</code></dd>
<dt><kbd>chmod 340</kbd></dt>
<dd><code>--wxr-----</code></dd>
<dt><kbd>chmod 341</kbd></dt>
<dd><code>--wxr----x</code></dd>
<dt><kbd>chmod 342</kbd></dt>
<dd><code>--wxr---w-</code></dd>
<dt><kbd>chmod 343</kbd></dt>
<dd><code>--wxr---wx</code></dd>
<dt><kbd>chmod 344</kbd></dt>
<dd><code>--wxr--r--</code></dd>
<dt><kbd>chmod 345</kbd></dt>
<dd><code>--wxr--r-x</code></dd>
<dt><kbd>chmod 346</kbd></dt>
<dd><code>--wxr--rw-</code></dd>
<dt><kbd>chmod 347</kbd></dt>
<dd><code>--wxr--rwx</code></dd>
<dt><kbd>chmod 350</kbd></dt>
<dd><code>--wxr-x---</code></dd>
<dt><kbd>chmod 351</kbd></dt>
<dd><code>--wxr-x--x</code></dd>
<dt><kbd>chmod 352</kbd></dt>
<dd><code>--wxr-x-w-</code></dd>
<dt><kbd>chmod 353</kbd></dt>
<dd><code>--wxr-x-wx</code></dd>
<dt><kbd>chmod 354</kbd></dt>
<dd><code>--wxr-xr--</code></dd>
<dt><kbd>chmod 355</kbd></dt>
<dd><code>--wxr-xr-x</code></dd>
<dt><kbd>chmod 356</kbd></dt>
<dd><code>--wxr-xrw-</code></dd>
<dt><kbd>chmod 357</kbd></dt>
<dd><code>--wxr-xrwx</code></dd>
<dt><kbd>chmod 360</kbd></dt>
<dd><code>--wxrw----</code></dd>
<dt><kbd>chmod 361</kbd></dt>
<dd><code>--wxrw---x</code></dd>
<dt><kbd>chmod 362</kbd></dt>
<dd><code>--wxrw--w-</code></dd>
<dt><kbd>chmod 363</kbd></dt>
<dd><code>--wxrw--wx</code></dd>
<dt><kbd>chmod 364</kbd></dt>
<dd><code>--wxrw-r--</code></dd>
<dt><kbd>chmod 365</kbd></dt>
<dd><code>--wxrw-r-x</code></dd>
<dt><kbd>chmod 366</kbd></dt>
<dd><code>--wxrw-rw-</code></dd>
<dt><kbd>chmod 367</kbd></dt>
<dd><code>--wxrw-rwx</code></dd>
<dt><kbd>chmod 370</kbd></dt>
<dd><code>--wxrwx---</code></dd>
<dt><kbd>chmod 371</kbd></dt>
<dd><code>--wxrwx--x</code></dd>
<dt><kbd>chmod 372</kbd></dt>
<dd><code>--wxrwx-w-</code></dd>
<dt><kbd>chmod 373</kbd></dt>
<dd><code>--wxrwx-wx</code></dd>
<dt><kbd>chmod 374</kbd></dt>
<dd><code>--wxrwxr--</code></dd>
<dt><kbd>chmod 375</kbd></dt>
<dd><code>--wxrwxr-x</code></dd>
<dt><kbd>chmod 376</kbd></dt>
<dd><code>--wxrwxrw-</code></dd>
<dt><kbd>chmod 377</kbd></dt>
<dd><code>--wxrwxrwx</code></dd>
<dt><kbd>chmod 400</kbd></dt>
<dd><code>-r--------</code></dd>
<dt><kbd>chmod 401</kbd></dt>
<dd><code>-r-------x</code></dd>
<dt><kbd>chmod 402</kbd></dt>
<dd><code>-r------w-</code></dd>
<dt><kbd>chmod 403</kbd></dt>
<dd><code>-r------wx</code></dd>
<dt><kbd>chmod 404</kbd></dt>
<dd><code>-r-----r--</code></dd>
<dt><kbd>chmod 405</kbd></dt>
<dd><code>-r-----r-x</code></dd>
<dt><kbd>chmod 406</kbd></dt>
<dd><code>-r-----rw-</code></dd>
<dt><kbd>chmod 407</kbd></dt>
<dd><code>-r-----rwx</code></dd>
<dt><kbd>chmod 410</kbd></dt>
<dd><code>-r----x---</code></dd>
<dt><kbd>chmod 411</kbd></dt>
<dd><code>-r----x--x</code></dd>
<dt><kbd>chmod 412</kbd></dt>
<dd><code>-r----x-w-</code></dd>
<dt><kbd>chmod 413</kbd></dt>
<dd><code>-r----x-wx</code></dd>
<dt><kbd>chmod 414</kbd></dt>
<dd><code>-r----xr--</code></dd>
<dt><kbd>chmod 415</kbd></dt>
<dd><code>-r----xr-x</code></dd>
<dt><kbd>chmod 416</kbd></dt>
<dd><code>-r----xrw-</code></dd>
<dt><kbd>chmod 417</kbd></dt>
<dd><code>-r----xrwx</code></dd>
<dt><kbd>chmod 420</kbd></dt>
<dd><code>-r---w----</code></dd>
<dt><kbd>chmod 421</kbd></dt>
<dd><code>-r---w---x</code></dd>
<dt><kbd>chmod 422</kbd></dt>
<dd><code>-r---w--w-</code></dd>
<dt><kbd>chmod 423</kbd></dt>
<dd><code>-r---w--wx</code></dd>
<dt><kbd>chmod 424</kbd></dt>
<dd><code>-r---w-r--</code></dd>
<dt><kbd>chmod 425</kbd></dt>
<dd><code>-r---w-r-x</code></dd>
<dt><kbd>chmod 426</kbd></dt>
<dd><code>-r---w-rw-</code></dd>
<dt><kbd>chmod 427</kbd></dt>
<dd><code>-r---w-rwx</code></dd>
<dt><kbd>chmod 430</kbd></dt>
<dd><code>-r---wx---</code></dd>
<dt><kbd>chmod 431</kbd></dt>
<dd><code>-r---wx--x</code></dd>
<dt><kbd>chmod 432</kbd></dt>
<dd><code>-r---wx-w-</code></dd>
<dt><kbd>chmod 433</kbd></dt>
<dd><code>-r---wx-wx</code></dd>
<dt><kbd>chmod 434</kbd></dt>
<dd><code>-r---wxr--</code></dd>
<dt><kbd>chmod 435</kbd></dt>
<dd><code>-r---wxr-x</code></dd>
<dt><kbd>chmod 436</kbd></dt>
<dd><code>-r---wxrw-</code></dd>
<dt><kbd>chmod 437</kbd></dt>
<dd><code>-r---wxrwx</code></dd>
<dt><kbd>chmod 440</kbd></dt>
<dd><code>-r--r-----</code></dd>
<dt><kbd>chmod 441</kbd></dt>
<dd><code>-r--r----x</code></dd>
<dt><kbd>chmod 442</kbd></dt>
<dd><code>-r--r---w-</code></dd>
<dt><kbd>chmod 443</kbd></dt>
<dd><code>-r--r---wx</code></dd>
<dt><kbd>chmod 444</kbd></dt>
<dd><code>-r--r--r--</code></dd>
<dt><kbd>chmod 445</kbd></dt>
<dd><code>-r--r--r-x</code></dd>
<dt><kbd>chmod 446</kbd></dt>
<dd><code>-r--r--rw-</code></dd>
<dt><kbd>chmod 447</kbd></dt>
<dd><code>-r--r--rwx</code></dd>
<dt><kbd>chmod 450</kbd></dt>
<dd><code>-r--r-x---</code></dd>
<dt><kbd>chmod 451</kbd></dt>
<dd><code>-r--r-x--x</code></dd>
<dt><kbd>chmod 452</kbd></dt>
<dd><code>-r--r-x-w-</code></dd>
<dt><kbd>chmod 453</kbd></dt>
<dd><code>-r--r-x-wx</code></dd>
<dt><kbd>chmod 454</kbd></dt>
<dd><code>-r--r-xr--</code></dd>
<dt><kbd>chmod 455</kbd></dt>
<dd><code>-r--r-xr-x</code></dd>
<dt><kbd>chmod 456</kbd></dt>
<dd><code>-r--r-xrw-</code></dd>
<dt><kbd>chmod 457</kbd></dt>
<dd><code>-r--r-xrwx</code></dd>
<dt><kbd>chmod 460</kbd></dt>
<dd><code>-r--rw----</code></dd>
<dt><kbd>chmod 461</kbd></dt>
<dd><code>-r--rw---x</code></dd>
<dt><kbd>chmod 462</kbd></dt>
<dd><code>-r--rw--w-</code></dd>
<dt><kbd>chmod 463</kbd></dt>
<dd><code>-r--rw--wx</code></dd>
<dt><kbd>chmod 464</kbd></dt>
<dd><code>-r--rw-r--</code></dd>
<dt><kbd>chmod 465</kbd></dt>
<dd><code>-r--rw-r-x</code></dd>
<dt><kbd>chmod 466</kbd></dt>
<dd><code>-r--rw-rw-</code></dd>
<dt><kbd>chmod 467</kbd></dt>
<dd><code>-r--rw-rwx</code></dd>
<dt><kbd>chmod 470</kbd></dt>
<dd><code>-r--rwx---</code></dd>
<dt><kbd>chmod 471</kbd></dt>
<dd><code>-r--rwx--x</code></dd>
<dt><kbd>chmod 472</kbd></dt>
<dd><code>-r--rwx-w-</code></dd>
<dt><kbd>chmod 473</kbd></dt>
<dd><code>-r--rwx-wx</code></dd>
<dt><kbd>chmod 474</kbd></dt>
<dd><code>-r--rwxr--</code></dd>
<dt><kbd>chmod 475</kbd></dt>
<dd><code>-r--rwxr-x</code></dd>
<dt><kbd>chmod 476</kbd></dt>
<dd><code>-r--rwxrw-</code></dd>
<dt><kbd>chmod 477</kbd></dt>
<dd><code>-r--rwxrwx</code></dd>
<dt><kbd>chmod 500</kbd></dt>
<dd><code>-r-x------</code></dd>
<dt><kbd>chmod 501</kbd></dt>
<dd><code>-r-x-----x</code></dd>
<dt><kbd>chmod 502</kbd></dt>
<dd><code>-r-x----w-</code></dd>
<dt><kbd>chmod 503</kbd></dt>
<dd><code>-r-x----wx</code></dd>
<dt><kbd>chmod 504</kbd></dt>
<dd><code>-r-x---r--</code></dd>
<dt><kbd>chmod 505</kbd></dt>
<dd><code>-r-x---r-x</code></dd>
<dt><kbd>chmod 506</kbd></dt>
<dd><code>-r-x---rw-</code></dd>
<dt><kbd>chmod 507</kbd></dt>
<dd><code>-r-x---rwx</code></dd>
<dt><kbd>chmod 510</kbd></dt>
<dd><code>-r-x--x---</code></dd>
<dt><kbd>chmod 511</kbd></dt>
<dd><code>-r-x--x--x</code></dd>
<dt><kbd>chmod 512</kbd></dt>
<dd><code>-r-x--x-w-</code></dd>
<dt><kbd>chmod 513</kbd></dt>
<dd><code>-r-x--x-wx</code></dd>
<dt><kbd>chmod 514</kbd></dt>
<dd><code>-r-x--xr--</code></dd>
<dt><kbd>chmod 515</kbd></dt>
<dd><code>-r-x--xr-x</code></dd>
<dt><kbd>chmod 516</kbd></dt>
<dd><code>-r-x--xrw-</code></dd>
<dt><kbd>chmod 517</kbd></dt>
<dd><code>-r-x--xrwx</code></dd>
<dt><kbd>chmod 520</kbd></dt>
<dd><code>-r-x-w----</code></dd>
<dt><kbd>chmod 521</kbd></dt>
<dd><code>-r-x-w---x</code></dd>
<dt><kbd>chmod 522</kbd></dt>
<dd><code>-r-x-w--w-</code></dd>
<dt><kbd>chmod 523</kbd></dt>
<dd><code>-r-x-w--wx</code></dd>
<dt><kbd>chmod 524</kbd></dt>
<dd><code>-r-x-w-r--</code></dd>
<dt><kbd>chmod 525</kbd></dt>
<dd><code>-r-x-w-r-x</code></dd>
<dt><kbd>chmod 526</kbd></dt>
<dd><code>-r-x-w-rw-</code></dd>
<dt><kbd>chmod 527</kbd></dt>
<dd><code>-r-x-w-rwx</code></dd>
<dt><kbd>chmod 530</kbd></dt>
<dd><code>-r-x-wx---</code></dd>
<dt><kbd>chmod 531</kbd></dt>
<dd><code>-r-x-wx--x</code></dd>
<dt><kbd>chmod 532</kbd></dt>
<dd><code>-r-x-wx-w-</code></dd>
<dt><kbd>chmod 533</kbd></dt>
<dd><code>-r-x-wx-wx</code></dd>
<dt><kbd>chmod 534</kbd></dt>
<dd><code>-r-x-wxr--</code></dd>
<dt><kbd>chmod 535</kbd></dt>
<dd><code>-r-x-wxr-x</code></dd>
<dt><kbd>chmod 536</kbd></dt>
<dd><code>-r-x-wxrw-</code></dd>
<dt><kbd>chmod 537</kbd></dt>
<dd><code>-r-x-wxrwx</code></dd>
<dt><kbd>chmod 540</kbd></dt>
<dd><code>-r-xr-----</code></dd>
<dt><kbd>chmod 541</kbd></dt>
<dd><code>-r-xr----x</code></dd>
<dt><kbd>chmod 542</kbd></dt>
<dd><code>-r-xr---w-</code></dd>
<dt><kbd>chmod 543</kbd></dt>
<dd><code>-r-xr---wx</code></dd>
<dt><kbd>chmod 544</kbd></dt>
<dd><code>-r-xr--r--</code></dd>
<dt><kbd>chmod 545</kbd></dt>
<dd><code>-r-xr--r-x</code></dd>
<dt><kbd>chmod 546</kbd></dt>
<dd><code>-r-xr--rw-</code></dd>
<dt><kbd>chmod 547</kbd></dt>
<dd><code>-r-xr--rwx</code></dd>
<dt><kbd>chmod 550</kbd></dt>
<dd><code>-r-xr-x---</code></dd>
<dt><kbd>chmod 551</kbd></dt>
<dd><code>-r-xr-x--x</code></dd>
<dt><kbd>chmod 552</kbd></dt>
<dd><code>-r-xr-x-w-</code></dd>
<dt><kbd>chmod 553</kbd></dt>
<dd><code>-r-xr-x-wx</code></dd>
<dt><kbd>chmod 554</kbd></dt>
<dd><code>-r-xr-xr--</code></dd>
<dt><kbd>chmod 555</kbd></dt>
<dd><code>-r-xr-xr-x</code></dd>
<dt><kbd>chmod 556</kbd></dt>
<dd><code>-r-xr-xrw-</code></dd>
<dt><kbd>chmod 557</kbd></dt>
<dd><code>-r-xr-xrwx</code></dd>
<dt><kbd>chmod 560</kbd></dt>
<dd><code>-r-xrw----</code></dd>
<dt><kbd>chmod 561</kbd></dt>
<dd><code>-r-xrw---x</code></dd>
<dt><kbd>chmod 562</kbd></dt>
<dd><code>-r-xrw--w-</code></dd>
<dt><kbd>chmod 563</kbd></dt>
<dd><code>-r-xrw--wx</code></dd>
<dt><kbd>chmod 564</kbd></dt>
<dd><code>-r-xrw-r--</code></dd>
<dt><kbd>chmod 565</kbd></dt>
<dd><code>-r-xrw-r-x</code></dd>
<dt><kbd>chmod 566</kbd></dt>
<dd><code>-r-xrw-rw-</code></dd>
<dt><kbd>chmod 567</kbd></dt>
<dd><code>-r-xrw-rwx</code></dd>
<dt><kbd>chmod 570</kbd></dt>
<dd><code>-r-xrwx---</code></dd>
<dt><kbd>chmod 571</kbd></dt>
<dd><code>-r-xrwx--x</code></dd>
<dt><kbd>chmod 572</kbd></dt>
<dd><code>-r-xrwx-w-</code></dd>
<dt><kbd>chmod 573</kbd></dt>
<dd><code>-r-xrwx-wx</code></dd>
<dt><kbd>chmod 574</kbd></dt>
<dd><code>-r-xrwxr--</code></dd>
<dt><kbd>chmod 575</kbd></dt>
<dd><code>-r-xrwxr-x</code></dd>
<dt><kbd>chmod 576</kbd></dt>
<dd><code>-r-xrwxrw-</code></dd>
<dt><kbd>chmod 577</kbd></dt>
<dd><code>-r-xrwxrwx</code></dd>
<dt><kbd>chmod 600</kbd></dt>
<dd><code>-rw-------</code></dd>
<dt><kbd>chmod 601</kbd></dt>
<dd><code>-rw------x</code></dd>
<dt><kbd>chmod 602</kbd></dt>
<dd><code>-rw-----w-</code></dd>
<dt><kbd>chmod 603</kbd></dt>
<dd><code>-rw-----wx</code></dd>
<dt><kbd>chmod 604</kbd></dt>
<dd><code>-rw----r--</code></dd>
<dt><kbd>chmod 605</kbd></dt>
<dd><code>-rw----r-x</code></dd>
<dt><kbd>chmod 606</kbd></dt>
<dd><code>-rw----rw-</code></dd>
<dt><kbd>chmod 607</kbd></dt>
<dd><code>-rw----rwx</code></dd>
<dt><kbd>chmod 610</kbd></dt>
<dd><code>-rw---x---</code></dd>
<dt><kbd>chmod 611</kbd></dt>
<dd><code>-rw---x--x</code></dd>
<dt><kbd>chmod 612</kbd></dt>
<dd><code>-rw---x-w-</code></dd>
<dt><kbd>chmod 613</kbd></dt>
<dd><code>-rw---x-wx</code></dd>
<dt><kbd>chmod 614</kbd></dt>
<dd><code>-rw---xr--</code></dd>
<dt><kbd>chmod 615</kbd></dt>
<dd><code>-rw---xr-x</code></dd>
<dt><kbd>chmod 616</kbd></dt>
<dd><code>-rw---xrw-</code></dd>
<dt><kbd>chmod 617</kbd></dt>
<dd><code>-rw---xrwx</code></dd>
<dt><kbd>chmod 620</kbd></dt>
<dd><code>-rw--w----</code></dd>
<dt><kbd>chmod 621</kbd></dt>
<dd><code>-rw--w---x</code></dd>
<dt><kbd>chmod 622</kbd></dt>
<dd><code>-rw--w--w-</code></dd>
<dt><kbd>chmod 623</kbd></dt>
<dd><code>-rw--w--wx</code></dd>
<dt><kbd>chmod 624</kbd></dt>
<dd><code>-rw--w-r--</code></dd>
<dt><kbd>chmod 625</kbd></dt>
<dd><code>-rw--w-r-x</code></dd>
<dt><kbd>chmod 626</kbd></dt>
<dd><code>-rw--w-rw-</code></dd>
<dt><kbd>chmod 627</kbd></dt>
<dd><code>-rw--w-rwx</code></dd>
<dt><kbd>chmod 630</kbd></dt>
<dd><code>-rw--wx---</code></dd>
<dt><kbd>chmod 631</kbd></dt>
<dd><code>-rw--wx--x</code></dd>
<dt><kbd>chmod 632</kbd></dt>
<dd><code>-rw--wx-w-</code></dd>
<dt><kbd>chmod 633</kbd></dt>
<dd><code>-rw--wx-wx</code></dd>
<dt><kbd>chmod 634</kbd></dt>
<dd><code>-rw--wxr--</code></dd>
<dt><kbd>chmod 635</kbd></dt>
<dd><code>-rw--wxr-x</code></dd>
<dt><kbd>chmod 636</kbd></dt>
<dd><code>-rw--wxrw-</code></dd>
<dt><kbd>chmod 637</kbd></dt>
<dd><code>-rw--wxrwx</code></dd>
<dt><kbd>chmod 640</kbd></dt>
<dd><code>-rw-r-----</code></dd>
<dt><kbd>chmod 641</kbd></dt>
<dd><code>-rw-r----x</code></dd>
<dt><kbd>chmod 642</kbd></dt>
<dd><code>-rw-r---w-</code></dd>
<dt><kbd>chmod 643</kbd></dt>
<dd><code>-rw-r---wx</code></dd>
<dt><kbd>chmod 644</kbd></dt>
<dd><code>-rw-r--r--</code></dd>
<dt><kbd>chmod 645</kbd></dt>
<dd><code>-rw-r--r-x</code></dd>
<dt><kbd>chmod 646</kbd></dt>
<dd><code>-rw-r--rw-</code></dd>
<dt><kbd>chmod 647</kbd></dt>
<dd><code>-rw-r--rwx</code></dd>
<dt><kbd>chmod 650</kbd></dt>
<dd><code>-rw-r-x---</code></dd>
<dt><kbd>chmod 651</kbd></dt>
<dd><code>-rw-r-x--x</code></dd>
<dt><kbd>chmod 652</kbd></dt>
<dd><code>-rw-r-x-w-</code></dd>
<dt><kbd>chmod 653</kbd></dt>
<dd><code>-rw-r-x-wx</code></dd>
<dt><kbd>chmod 654</kbd></dt>
<dd><code>-rw-r-xr--</code></dd>
<dt><kbd>chmod 655</kbd></dt>
<dd><code>-rw-r-xr-x</code></dd>
<dt><kbd>chmod 656</kbd></dt>
<dd><code>-rw-r-xrw-</code></dd>
<dt><kbd>chmod 657</kbd></dt>
<dd><code>-rw-r-xrwx</code></dd>
<dt><kbd>chmod 660</kbd></dt>
<dd><code>-rw-rw----</code></dd>
<dt><kbd>chmod 661</kbd></dt>
<dd><code>-rw-rw---x</code></dd>
<dt><kbd>chmod 662</kbd></dt>
<dd><code>-rw-rw--w-</code></dd>
<dt><kbd>chmod 663</kbd></dt>
<dd><code>-rw-rw--wx</code></dd>
<dt><kbd>chmod 664</kbd></dt>
<dd><code>-rw-rw-r--</code></dd>
<dt><kbd>chmod 665</kbd></dt>
<dd><code>-rw-rw-r-x</code></dd>
<dt><kbd>chmod 666</kbd></dt>
<dd><code>-rw-rw-rw-</code></dd>
<dt><kbd>chmod 667</kbd></dt>
<dd><code>-rw-rw-rwx</code></dd>
<dt><kbd>chmod 670</kbd></dt>
<dd><code>-rw-rwx---</code></dd>
<dt><kbd>chmod 671</kbd></dt>
<dd><code>-rw-rwx--x</code></dd>
<dt><kbd>chmod 672</kbd></dt>
<dd><code>-rw-rwx-w-</code></dd>
<dt><kbd>chmod 673</kbd></dt>
<dd><code>-rw-rwx-wx</code></dd>
<dt><kbd>chmod 674</kbd></dt>
<dd><code>-rw-rwxr--</code></dd>
<dt><kbd>chmod 675</kbd></dt>
<dd><code>-rw-rwxr-x</code></dd>
<dt><kbd>chmod 676</kbd></dt>
<dd><code>-rw-rwxrw-</code></dd>
<dt><kbd>chmod 677</kbd></dt>
<dd><code>-rw-rwxrwx</code></dd>
<dt><kbd>chmod 700</kbd></dt>
<dd><code>-rwx------</code></dd>
<dt><kbd>chmod 701</kbd></dt>
<dd><code>-rwx-----x</code></dd>
<dt><kbd>chmod 702</kbd></dt>
<dd><code>-rwx----w-</code></dd>
<dt><kbd>chmod 703</kbd></dt>
<dd><code>-rwx----wx</code></dd>
<dt><kbd>chmod 704</kbd></dt>
<dd><code>-rwx---r--</code></dd>
<dt><kbd>chmod 705</kbd></dt>
<dd><code>-rwx---r-x</code></dd>
<dt><kbd>chmod 706</kbd></dt>
<dd><code>-rwx---rw-</code></dd>
<dt><kbd>chmod 707</kbd></dt>
<dd><code>-rwx---rwx</code></dd>
<dt><kbd>chmod 710</kbd></dt>
<dd><code>-rwx--x---</code></dd>
<dt><kbd>chmod 711</kbd></dt>
<dd><code>-rwx--x--x</code></dd>
<dt><kbd>chmod 712</kbd></dt>
<dd><code>-rwx--x-w-</code></dd>
<dt><kbd>chmod 713</kbd></dt>
<dd><code>-rwx--x-wx</code></dd>
<dt><kbd>chmod 714</kbd></dt>
<dd><code>-rwx--xr--</code></dd>
<dt><kbd>chmod 715</kbd></dt>
<dd><code>-rwx--xr-x</code></dd>
<dt><kbd>chmod 716</kbd></dt>
<dd><code>-rwx--xrw-</code></dd>
<dt><kbd>chmod 717</kbd></dt>
<dd><code>-rwx--xrwx</code></dd>
<dt><kbd>chmod 720</kbd></dt>
<dd><code>-rwx-w----</code></dd>
<dt><kbd>chmod 721</kbd></dt>
<dd><code>-rwx-w---x</code></dd>
<dt><kbd>chmod 722</kbd></dt>
<dd><code>-rwx-w--w-</code></dd>
<dt><kbd>chmod 723</kbd></dt>
<dd><code>-rwx-w--wx</code></dd>
<dt><kbd>chmod 724</kbd></dt>
<dd><code>-rwx-w-r--</code></dd>
<dt><kbd>chmod 725</kbd></dt>
<dd><code>-rwx-w-r-x</code></dd>
<dt><kbd>chmod 726</kbd></dt>
<dd><code>-rwx-w-rw-</code></dd>
<dt><kbd>chmod 727</kbd></dt>
<dd><code>-rwx-w-rwx</code></dd>
<dt><kbd>chmod 730</kbd></dt>
<dd><code>-rwx-wx---</code></dd>
<dt><kbd>chmod 731</kbd></dt>
<dd><code>-rwx-wx--x</code></dd>
<dt><kbd>chmod 732</kbd></dt>
<dd><code>-rwx-wx-w-</code></dd>
<dt><kbd>chmod 733</kbd></dt>
<dd><code>-rwx-wx-wx</code></dd>
<dt><kbd>chmod 734</kbd></dt>
<dd><code>-rwx-wxr--</code></dd>
<dt><kbd>chmod 735</kbd></dt>
<dd><code>-rwx-wxr-x</code></dd>
<dt><kbd>chmod 736</kbd></dt>
<dd><code>-rwx-wxrw-</code></dd>
<dt><kbd>chmod 737</kbd></dt>
<dd><code>-rwx-wxrwx</code></dd>
<dt><kbd>chmod 740</kbd></dt>
<dd><code>-rwxr-----</code></dd>
<dt><kbd>chmod 741</kbd></dt>
<dd><code>-rwxr----x</code></dd>
<dt><kbd>chmod 742</kbd></dt>
<dd><code>-rwxr---w-</code></dd>
<dt><kbd>chmod 743</kbd></dt>
<dd><code>-rwxr---wx</code></dd>
<dt><kbd>chmod 744</kbd></dt>
<dd><code>-rwxr--r--</code></dd>
<dt><kbd>chmod 745</kbd></dt>
<dd><code>-rwxr--r-x</code></dd>
<dt><kbd>chmod 746</kbd></dt>
<dd><code>-rwxr--rw-</code></dd>
<dt><kbd>chmod 747</kbd></dt>
<dd><code>-rwxr--rwx</code></dd>
<dt><kbd>chmod 750</kbd></dt>
<dd><code>-rwxr-x---</code></dd>
<dt><kbd>chmod 751</kbd></dt>
<dd><code>-rwxr-x--x</code></dd>
<dt><kbd>chmod 752</kbd></dt>
<dd><code>-rwxr-x-w-</code></dd>
<dt><kbd>chmod 753</kbd></dt>
<dd><code>-rwxr-x-wx</code></dd>
<dt><kbd>chmod 754</kbd></dt>
<dd><code>-rwxr-xr--</code></dd>
<dt><kbd>chmod 755</kbd></dt>
<dd><code>-rwxr-xr-x</code></dd>
<dt><kbd>chmod 756</kbd></dt>
<dd><code>-rwxr-xrw-</code></dd>
<dt><kbd>chmod 757</kbd></dt>
<dd><code>-rwxr-xrwx</code></dd>
<dt><kbd>chmod 760</kbd></dt>
<dd><code>-rwxrw----</code></dd>
<dt><kbd>chmod 761</kbd></dt>
<dd><code>-rwxrw---x</code></dd>
<dt><kbd>chmod 762</kbd></dt>
<dd><code>-rwxrw--w-</code></dd>
<dt><kbd>chmod 763</kbd></dt>
<dd><code>-rwxrw--wx</code></dd>
<dt><kbd>chmod 764</kbd></dt>
<dd><code>-rwxrw-r--</code></dd>
<dt><kbd>chmod 765</kbd></dt>
<dd><code>-rwxrw-r-x</code></dd>
<dt><kbd>chmod 766</kbd></dt>
<dd><code>-rwxrw-rw-</code></dd>
<dt><kbd>chmod 767</kbd></dt>
<dd><code>-rwxrw-rwx</code></dd>
<dt><kbd>chmod 770</kbd></dt>
<dd><code>-rwxrwx---</code></dd>
<dt><kbd>chmod 771</kbd></dt>
<dd><code>-rwxrwx--x</code></dd>
<dt><kbd>chmod 772</kbd></dt>
<dd><code>-rwxrwx-w-</code></dd>
<dt><kbd>chmod 773</kbd></dt>
<dd><code>-rwxrwx-wx</code></dd>
<dt><kbd>chmod 774</kbd></dt>
<dd><code>-rwxrwxr--</code></dd>
<dt><kbd>chmod 775</kbd></dt>
<dd><code>-rwxrwxr-x</code></dd>
<dt><kbd>chmod 776</kbd></dt>
<dd><code>-rwxrwxrw-</code></dd>
<dt><kbd>chmod 777</kbd></dt>
<dd><code>-rwxrwxrwx</code></dd>
</dl>
<hr class="C" />




<h2>Congratulations!</h2>
<p>Here's my custom stat function, which I am definately not finished with, so check back in a couple days and if you find any improvements please hook me up with a comment!</p>

<pre>
function askapache_stat( $filename ) {
$p=@fileperms($filename);
$s=@stat($filename);
$str=&#039;&#039;;
$t=decoct($s[&#039;mode&#039;] &amp; 0170000);
&nbsp;
switch (octdec($t)) {
case 0140000: $str = &#039;s&#039;; $stat[&#039;type&#039;]=&#039;socket&#039;; break;
case 0120000: $str = &#039;l&#039;; $stat[&#039;type&#039;]=&#039;link&#039;; break;
case 0100000: $str = &#039;-&#039;; $stat[&#039;type&#039;]=&#039;file&#039;; break;
case 0060000: $str = &#039;b&#039;; $stat[&#039;type&#039;]=&#039;block&#039;; break;
case 0040000: $str = &#039;d&#039;; $stat[&#039;type&#039;]=&#039;dir&#039;; break;
case 0020000: $str = &#039;c&#039;; $stat[&#039;type&#039;]=&#039;char&#039;; break;
case 0010000: $str = &#039;p&#039;; $stat[&#039;type&#039;]=&#039;fifo&#039;; break;
default: $str = &#039;u&#039;; $stat[&#039;type&#039;]=&#039;unknown&#039;; break;
}
&nbsp;
$stat[&#039;type_octal&#039;] = sprintf("%07o", octdec($t));
&nbsp;
$str .= (($p&amp;0x0100)?&#039;r&#039;:&#039;-&#039;).(($p&amp;0x0080)?&#039;w&#039;:&#039;-&#039;).(($p&amp;0x0040)?(($p&amp;0x0800)?&#039;s&#039;:&#039;x&#039;):(($p&amp;0x0800)?&#039;S&#039;:&#039;-&#039;));
$str .= (($p&amp;0x0020)?&#039;r&#039;:&#039;-&#039;).(($p&amp;0x0010)?&#039;w&#039;:&#039;-&#039;).(($p&amp;0x0008)?(($p&amp;0x0400)?&#039;s&#039;:&#039;x&#039;):(($p&amp;0x0400)?&#039;S&#039;:&#039;-&#039;));
$str .= (($p&amp;0x0004)?&#039;r&#039;:&#039;-&#039;).(($p&amp;0x0002)?&#039;w&#039;:&#039;-&#039;).(($p&amp;0x0001)?(($p&amp;0x0200)?&#039;t&#039;:&#039;x&#039;):(($p&amp;0x0200)?&#039;T&#039;:&#039;-&#039;));
&nbsp;
$stat[&#039;default_umask&#039;]=sprintf("%04o",umask());
$stat[&#039;perm_human&#039;]=$str;
$stat[&#039;perm_octal1&#039;] = sprintf( "%o", ( $s[&#039;mode&#039;] &amp; 00777 ) );
$stat[&#039;perm_octal2&#039;] = sprintf("0%o", 0777 &amp; $p);
$stat[&#039;perm_dec&#039;] = sprintf("%04o", $p);
$stat[&#039;perm_mode&#039;]=$s[&#039;mode&#039;];   // File mode.
&nbsp;
$stat[&#039;file&#039;] = @realpath($filename);
$stat[&#039;basename&#039;] = basename( $filename );
&nbsp;
$stat[&#039;user_id&#039;] = $s[&#039;uid&#039;];
$stat[&#039;group_id&#039;] = $s[&#039;gid&#039;];
&nbsp;
$stat[&#039;device&#039;]=$s[&#039;dev&#039;];      // Device
$stat[&#039;device_number&#039;]=$s[&#039;rdev&#039;];    // Device number, if device.
$stat[&#039;inode&#039;]=$s[&#039;ino&#039;];      // File serial number
$stat[&#039;link_count&#039;]=$s[&#039;nlink&#039;];    // link count
if($stat[&#039;type&#039;]==&#039;link&#039;)$stat[&#039;link_to&#039;]=@readlink( $filename );
&nbsp;
$stat[&#039;size&#039;]=$s[&#039;size&#039;];    // Size of file, in bytes.
$stat[&#039;block_size&#039;]=$s[&#039;blksize&#039;];  // Optimal block size for I/O.
$stat[&#039;blocks&#039;]=$s[&#039;blocks&#039;];  // Number 512-byte blocks allocated
&nbsp;
$stat[&#039;time_access&#039;]=@date( &#039;Y M D H:i:s&#039;,$s[&#039;atime&#039;]);    // Time of last access.
$stat[&#039;time_modified&#039;]=@date( &#039;Y M D H:i:s&#039;,$s[&#039;mtime&#039;]);    // Time of last modification
$stat[&#039;time_created&#039;]=@date( &#039;Y M D H:i:s&#039;,$s[&#039;ctime&#039;]);    // Time of last status change
&nbsp;
clearstatcache();
return $stat;
}
&nbsp;
header(&#039;Content-Type: text/plain&#039;);
$stat=askapache_stat(__FILE__);
print_r($stat);
</pre>






<h3>Defining Permission Bits</h3>
<pre>
!defined(&#039;S_IFMT&#039;) &amp;&amp; define(&#039;S_IFMT&#039;, 0170000); //  mask for all types
!defined(&#039;S_IFSOCK&#039;) &amp;&amp; define(&#039;S_IFSOCK&#039;, 0140000); // type: socket
!defined(&#039;S_IFLNK&#039;) &amp;&amp; define(&#039;S_IFLNK&#039;, 0120000); // type:  symbolic link
!defined(&#039;S_IFREG&#039;) &amp;&amp; define(&#039;S_IFREG&#039;, 0100000); // type:  regular file
!defined(&#039;S_IFBLK&#039;) &amp;&amp; define(&#039;S_IFBLK&#039;, 0060000); // type:  block device
!defined(&#039;S_IFDIR&#039;) &amp;&amp; define(&#039;S_IFDIR&#039;, 0040000); // type:  directory
!defined(&#039;S_IFCHR&#039;) &amp;&amp; define(&#039;S_IFCHR&#039;, 0020000); // type:  character device
!defined(&#039;S_IFIFO&#039;) &amp;&amp; define(&#039;S_IFIFO&#039;, 0010000); // type:  fifo
&nbsp;
!defined(&#039;S_ISUID&#039;) &amp;&amp; define(&#039;S_ISUID&#039;, 0004000); // set-uid bit
!defined(&#039;S_ISGID&#039;) &amp;&amp; define(&#039;S_ISGID&#039;, 0002000); // set-gid bit
!defined(&#039;S_ISVTX&#039;) &amp;&amp; define(&#039;S_ISVTX&#039;, 0001000); // sticky bit
!defined(&#039;S_IRWXU&#039;) &amp;&amp; define(&#039;S_IRWXU&#039;, 00700); //  mask for owner permissions
!defined(&#039;S_IRUSR&#039;) &amp;&amp; define(&#039;S_IRUSR&#039;, 00400); //  owner: read permission
!defined(&#039;S_IWUSR&#039;) &amp;&amp; define(&#039;S_IWUSR&#039;, 00200); //  owner: write permission
!defined(&#039;S_IXUSR&#039;) &amp;&amp; define(&#039;S_IXUSR&#039;, 00100); //  owner: execute permission
!defined(&#039;S_IRWXG&#039;) &amp;&amp; define(&#039;S_IRWXG&#039;, 00070); //  mask for group permissions
!defined(&#039;S_IRGRP&#039;) &amp;&amp; define(&#039;S_IRGRP&#039;, 00040); //  group: read permission
!defined(&#039;S_IWGRP&#039;) &amp;&amp; define(&#039;S_IWGRP&#039;, 00020); //  group: write permission
!defined(&#039;S_IXGRP&#039;) &amp;&amp; define(&#039;S_IXGRP&#039;, 00010); //  group: execute permission
!defined(&#039;S_IRWXO&#039;) &amp;&amp; define(&#039;S_IRWXO&#039;, 00007); //  mask for others permissions
!defined(&#039;S_IROTH&#039;) &amp;&amp; define(&#039;S_IROTH&#039;, 00004); //  others:  read permission
!defined(&#039;S_IWOTH&#039;) &amp;&amp; define(&#039;S_IWOTH&#039;, 00002); //  others:  write permission
!defined(&#039;S_IXOTH&#039;) &amp;&amp; define(&#039;S_IXOTH&#039;, 00001); //  others:  execute permission
&nbsp;
!defined(&#039;S_IRWXUGO&#039;) &amp;&amp; define(&#039;S_IRWXUGO&#039;, (S_IRWXU | S_IRWXG | S_IRWXO));
!defined(&#039;S_IALLUGO&#039;) &amp;&amp; define(&#039;S_IALLUGO&#039;, (S_ISUID | S_ISGID | S_ISVTX | S_IRWXUGO));
!defined(&#039;S_IRUGO&#039;) &amp;&amp; define(&#039;S_IRUGO&#039;, (S_IRUSR | S_IRGRP | S_IROTH));
!defined(&#039;S_IWUGO&#039;) &amp;&amp; define(&#039;S_IWUGO&#039;, (S_IWUSR | S_IWGRP | S_IWOTH));
!defined(&#039;S_IXUGO&#039;) &amp;&amp; define(&#039;S_IXUGO&#039;, (S_IXUSR | S_IXGRP | S_IXOTH));
!defined(&#039;S_IRWUGO&#039;) &amp;&amp; define(&#039;S_IRWUGO&#039;, (S_IRUGO | S_IWUGO));
</pre>




<h2>How File Permissions Work</h2>
<p>When PHP is installed on your server by you or whoever runs the server, it uses the file permissions that are used by the Operating System running the server..  If you are smart or just lucky than you are running some type of BSD/Unix/Solaris/Linux/Sun based Operating system and PHP won't have any problems.  If you are running on a Locked, proprietary OS like Windows, PHP will still work but it has to use a lot of shortcuts and hacks to basically "Pretend" to act like the OS is BSD/Unix, and some key features just won't be available.</p>

<h2>The OS Permission Bits</h2>
<p>Here's the file permissions my Linux server uses, and which PHP automatically uses.  The code basically just defines the default permissions for files, and defines the file atributes for each file that you can access by using the stat function, which I've improved upon to make things easier.</p>
<p>Download: <a href='http://uploads.askapache.com/2008/11/stat.h' title="POSIX Standard: 5.6 File Characteristics">POSIX Standard: 5.6 File Characteristics<code>sys/stat.h</code></a></p>
<h3>Protection bits for File Owner</h3>
<pre>
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
</pre>

<h3>Protection bits for File Group</h3>
<pre>
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
</pre>

<h3>Protection bits for All Others</h3>
<pre>
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
</pre>


<h2>Some Example Permissions</h2>
<p><code>0477</code>  // owner has read only, other and group has rwx
<code>0677</code>  // owner has rw only, other and group has rwx</p>

<p><code>0444</code>  // all have read only
<code>0666</code>  // all have rw only</p>

<p><code>0400</code>  // owner has read only, group and others have no permission
<code>0600</code> // owner has rw only, group and others have no permission</p>

<p><code>0470</code>  // owner has read only, group has rwx, others have no permission
<code>0407</code>  // owner has read only, other has rwx, group has no permission</p>

<p><code>0670</code>  // owner has rw only, group has rwx, others have no permission
<code>0607</code>  // owner has rw only, group has no permission and others have rwx</p>


<h2>What's a File</h2>
<p>A file is not merely its contents, a name, and a file type. A file also has an owner (a user ID), a group (a group ID), permissions (what the owner can do with the file, what people in the group can do, and what everyone else can do), various timestamps, and other information. Collectively, we call these a file's attributes.</p>

<h2>Structure of File Mode Bits</h2>
<p>The file mode bits have two parts: the file permission bits, which control ordinary access to the file, and special mode bits, which affect only some files.</p>
<p>There are three kinds of permissions that a user can have for a file:</p>
<ol>
<li>permission to read the file. For directories, this means permission to list the contents of the directory.</li>
<li>permission to write to (change) the file. For directories, this means permission to create and remove files in the directory.</li>
<li>permission to execute the file (run it as a program). For directories, this means permission to access files in the directory.</li>
</ol>

<p>There are three categories of users who may have different permissions to perform any of the above operations on a file:</p>
<ol>
<li>the file's owner.</li>
<li>other users who are in the file's group</li>
<li>everyone else.</li>
</ol>

<p>Files are given an owner and group when they are created. Usually the owner is the current user and the group is the group of the directory the file is in, but this varies with the operating system, the file system the file is created on, and the way the file is created. You can change the owner and group of a file by using the <strong>chown</strong> and <strong>chgrp</strong> commands.</p>
<p>In addition to the three sets of three permissions listed above, the file mode bits have three special components, which affect only executable files (programs) and, on most systems, directories:</p>
<ol>
<li>Set the process's effective user ID to that of the file upon execution (called the set-user-ID bit, or sometimes the setuid bit). For directories on a few systems, give files created in the directory the same owner as the directory, no matter who creates them, and set the set-user-ID bit of newly-created subdirectories.</li>
<li>Set the process's effective group ID to that of the file upon execution (called the set-group-ID bit, or sometimes the setgid bit). For directories on most systems, give files created in the directory the same group as the directory, no matter what group the user who creates them is in, and set the set-group-ID bit of newly-created subdirectories.</li>
<li>Prevent unprivileged users from removing or renaming a file in a directory unless they own the file or the directory; this is called the restricted deletion flag for the directory, and is commonly found on world-writable directories like /tmp.</li>
</ol>

<p>For regular files on some older systems, save the program's text image on the swap device so it will load more quickly when run; this is called the <code>sticky bit</code>.</p>



<h2>Setting Permissions</h2>
<p>The basic symbolic operations on a file's permissions are adding, removing, and setting the permission that certain users have to read, write, and execute or search the file. These operations have the following format:</p>
<p><code>users operation permissions</code></p>

<p>The spaces between the three parts above are shown for readability only; symbolic modes cannot contain spaces.  The users part tells which users' access to the file is changed. It consists of one or more of the following letters (or it can be empty). When more than one of these letters is given, the order that they are in does not matter.</p>
<ul>
<li><strong>u</strong> - the user who owns the file.</li>
<li><strong>g</strong> - other users who are in the file's group.</li>
<li><strong>o</strong> - all other users.</li>
<li><strong>a</strong> - all users; the same as ugo.</li>
</ul>

<p>The operation part tells how to change the affected users' access to the file, and is one of the following symbols:</p>
<ul>
<li><strong>+</strong> - to add the permissions to whatever permissions the users already have for the file.</li>
<li><strong>-</strong> - to remove the permissions from whatever permissions the users already have for the file.</li>
<li><strong>=</strong> - to make the permissions the only permissions that the users have for the file.</li>
</ul>

<p>The permissions part tells what kind of access to the file should be changed; it is normally zero or more of the following letters. As with the users part, the order does not matter when more than one letter is given. Omitting the permissions part is useful only with the = operation, where it gives the specified users no access at all to the file.</p>

<ul>
<li><strong>r</strong> - the permission the users have to read the file.</li>
<li><strong>w</strong> - the permission the users have to write to the file.</li>
<li><strong>x</strong> - the permission the users have to execute the file, or search it if it is a directory.</li>
</ul>

<p>For example, to give everyone permission to read and write a regular file, but not to execute it, use:</p>
<pre>
a=rw
</pre>

<p>To remove write permission for all users other than the file's owner, use:</p>
<pre>
go-w
</pre>

<p>The above command does not affect the access that the owner of the file has to it, nor does it affect whether other users can read or execute the file.</p>

<p>To give everyone except a file's owner no permission to do anything with that file, use the mode below. Other users could still remove the file, if they have write permission on the directory it is in.</p>
<pre>
go=
</pre>

<p>Another way to specify the same thing is:</p>
<pre>
og-rwx
</pre>



<h2>Copying Existing Permissions</h2>
<p>You can base a file's permissions on its existing permissions. To do this, instead of using a series of <strong>r, w, or x</strong> letters after the operator, you use the letter <strong>u, g, or o</strong>. For example, the mode</p>
<pre>
o+g
</pre>

<p>adds the permissions for users who are in a file's group to the permissions that other users have for the file. Thus, if the file started out as mode 664 (rw-rw-r--), the above mode would change it to mode 666 (rw-rw-rw-). If the file had started out as mode 741 (rwxr----x), the above mode would change it to mode 745 (rwxr--r-x). The - and = operations work analogously.</p>






<h2>Umask and Protection</h2>
<p>If the users part of a symbolic mode is omitted, it defaults to a (affect all users), except that any permissions that are set in the system variable umask are not affected. The value of umask can be set using the umask command. Its default value varies from system to system.</p>

<p>Omitting the users part of a symbolic mode is generally not useful with operations other than +. It is useful with + because it allows you to use umask as an easily customizable protection against giving away more permission to files than you intended to.  As an example, if umask has the value 2, which removes write permission for users who are not in the file's group, then the mode:</p>
<pre>
+w
</pre>

<p>adds permission to write to the file to its owner and to other users who are in the file's group, but not to other users. In contrast, the mode:</p>
<pre>
a+w
</pre>

<p>ignores umask, and does give write permission for the file to all users.</p>




<h2>Directories, Set-User-ID and Set-Group-ID Bits</h2>
<p>On most systems, if a directory's set-group-ID bit is set, newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set-group-ID bit of the parent directory. On a few systems, a directory's set-user-ID bit has a similar effect on the ownership of new subfiles and the set-user-ID bits of new subdirectories. These mechanisms let users share files more easily, by lessening the need to use chmod or chown to share new files.</p>

<p>These convenience mechanisms rely on the set-user-ID and set-group-ID bits of directories. If commands like chmod and mkdir routinely cleared these bits on directories, the mechanisms would be less convenient and it would be harder to share files. Therefore, a command like chmod does not affect the set-user-ID or set-group-ID bits of a directory unless the user specifically mentions them in a symbolic mode, or sets them in a numeric mode. For example, on systems that support set-group-ID inheritance:</p>

<pre>
# These commands leave the set-user-ID and
# set-group-ID bits of the subdirectories alone,
# so that they retain their default values.
mkdir A B C
chmod 755 A
chmod 0755 B
chmod u=rwx,go=rx C
mkdir -m 755 D
mkdir -m 0755 E
mkdir -m u=rwx,go=rx F
</pre>

<p>If you want to try to set these bits, you must mention them explicitly in the symbolic or numeric modes, e.g.:</p>
<pre>
# These commands try to set the set-user-ID
# and set-group-ID bits of the subdirectories.
mkdir G H
chmod 6755 G
chmod u=rwx,go=rx,a+s H
mkdir -m 6755 I
mkdir -m u=rwx,go=rx,a+s J
</pre>

<p>If you want to try to clear these bits, you must mention them explicitly in a symbolic mode, e.g.:</p>
<pre>
# This command tries to clear the set-user-ID
# and set-group-ID bits of the directory D.
chmod a-s D
</pre>











<h2>Numeric Modes</h2>
<p>The permissions granted to the user, to other users in the file's group, and to other users not in the file's group each require three bits, which are represented as one octal digit. The three special mode bits also require one bit each, and they are as a group represented as another octal digit. Here is how the bits are arranged, starting with the lowest valued bit:</p>

<h3>Other users not in the file's group:</h3>
<pre>
1 Execute/search
2 Write
4 Read
</pre>

<h3>Other users in the file's group:</h3>
<pre>
10 Execute/search
20 Write
40 Read
</pre>

<h3>The file's owner:</h3>
<pre>
100 Execute/search
200 Write
400 Read
</pre>

<h3>Special mode bits:</h3>
<pre>
1000 Restricted deletion flag or sticky bit
2000 Set group ID on execution
4000 Set user ID on execution
</pre>

<p>For example, numeric <code>mode 4755</code> corresponds to symbolic mode <code>u=rwxs,go=rx</code>, and numeric m<code>ode 664</code> corresponds to symbolic mode <code>ug=rw,o=r</code>. Numeric <code>mode 0</code> corresponds to symbolic mode <code>a=</code>.</p>




<h2>Apache's Internal Bits (hex)</h2>
<pre>
#define APR_FPROT_USETID   0x8000 /* Set user id */
#define APR_FPROT_UREAD   0x0400 /* Read by user */
#define APR_FPROT_UWRITE   0x0200 /* Write by user */
#define APR_FPROT_UEXECUTE 0x0100 /* Execute by user */
&nbsp;
#define APR_FPROT_GSETID   0x4000 /* Set group id */
#define APR_FPROT_GREAD   0x0040 /* Read by group */
#define APR_FPROT_GWRITE   0x0020 /* Write by group */
#define APR_FPROT_GEXECUTE 0x0010 /* Execute by group */
&nbsp;
#define APR_FPROT_WSTICKY 0x2000 /* Sticky bit */
#define APR_FPROT_WREAD   0x0004 /* Read by others */
#define APR_FPROT_WWRITE 0x0002 /* Write by others */
#define APR_FPROT_WEXECUTE 0x0001 /* Execute by others */
&nbsp;
#define APR_FPROT_OS_DEFAULT  0x0FFF /* use OS&#039;s default permissions */
&nbsp;
/* additional permission flags for apr_file_copy  and apr_file_append */
#define APR_FPROT_FILE_SOURCE_PERMS 0x1000 /* Copy source file&#039;s permissions */
</pre>


<p>Download: <a href='http://uploads.askapache.com/2008/11/fileacc.c' title="A file to put ALL of the accessor functions for apr_file_t types"><code>httpd-2.2.10/srclib/apr/file_io/unix/fileacc.c</code></a> Here's some interesting bitmasking done by Apache that uses the defined bits set earlier by stat.h</p>
<pre>
apr_unix_perms2mode(perms){
 mode=0;
 if (perms &amp; APR_USETID) mode |= S_ISUID;
 if (perms &amp; APR_UREAD)  mode |= S_IRUSR;
 if (perms &amp; APR_UWRITE) mode |= S_IWUSR;
 if (perms &amp; APR_UEXECUTE) mode |= S_IXUSR;
&nbsp;
 if (perms &amp; APR_GSETID) mode |= S_ISGID;
 if (perms &amp; APR_GREAD)  mode |= S_IRGRP;
 if (perms &amp; APR_GWRITE) mode |= S_IWGRP;
 if (perms &amp; APR_GEXECUTE) mode |= S_IXGRP;
&nbsp;
 if (perms &amp; APR_WSTICKY) mode |= S_ISVTX;
 if (perms &amp; APR_WREAD)  mode |= S_IROTH;
 if (perms &amp; APR_WWRITE) mode |= S_IWOTH;
 if (perms &amp; APR_WEXECUTE) mode |= S_IXOTH;
 return mode;
}
&nbsp;
apr_unix_mode2perms(mode){
 perms = 0;
 if (mode &amp; S_ISUID)perms |= APR_USETID;
 if (mode &amp; S_IRUSR)perms |= APR_UREAD;
 if (mode &amp; S_IWUSR)perms |= APR_UWRITE;
 if (mode &amp; S_IXUSR)perms |= APR_UEXECUTE;
&nbsp;
 if (mode &amp; S_ISGID)perms |= APR_GSETID;
 if (mode &amp; S_IRGRP)perms |= APR_GREAD;
 if (mode &amp; S_IWGRP)perms |= APR_GWRITE;
 if (mode &amp; S_IXGRP)perms |= APR_GEXECUTE;
&nbsp;
 if (mode &amp; S_ISVTX)perms |= APR_WSTICKY;
 if (mode &amp; S_IROTH)perms |= APR_WREAD;
 if (mode &amp; S_IWOTH)perms |= APR_WWRITE;
 if (mode &amp; S_IXOTH)perms |= APR_WEXECUTE;
 return perms;
}
</pre>





<h2>umask</h2>
<pre>
umask(int mask){
 arg1;
 int oldumask;
 int arg_count = ZEND_NUM_ARGS();
 oldumask = umask(077);
&nbsp;
 if (BG(umask) == -1) BG(umask) = oldumask;
 if (arg_count == 0) umask(oldumask);
&nbsp;
 convert_to_long_ex(arg1);
 umask(Z_LVAL_PP(arg1));
 RETURN_LONG(oldumask);
}
</pre>

















<h2>File Attributes</h2>
<p>Each file will have attributes based on the type of OS.. Using the stat command you can view them.</p>

<h3>Viewing stat results</h3>
<pre>
* %a - Access rights in octal
* %A - Access rights in human readable form
* %b - Number of blocks allocated (see %B)
* %B - The size in bytes of each block reported by %b
* %d - Device number in decimal
* %D - Device number in hex
* %f - Raw mode in hex
* %F - File type
* %g - Group ID of owner
* %G - Group name of owner
* %h - Number of hard links
* %i - Inode number
* %n - File name
* %N - Quoted file name with dereference if symbolic link
* %o - I/O block size
* %s - Total size, in bytes
* %t - Major device type in hex
* %T - Minor device type in hex
* %u - User ID of owner
* %U - User name of owner
* %x - Time of last access
* %X - Time of last access as seconds since Epoch
* %y - Time of last modification
* %Y - Time of last modification as seconds since Epoch
* %z - Time of last change
* %Z - Time of last change as seconds since Epoch
</pre>




<h2>The OS Attribute Bits</h2>
<p>These defined values are what allows your operating system to determine the type of file being accessed. </p>
<pre>
#define S_IFMT   00170000  /* These bits determine file type. */
#define S_IFSOCK 0140000  /* Socket file */
#define S_IFLNK   0120000  /* Symbolic Link */
#define S_IFREG   0100000  /* Regular file */
#define S_IFDIR   0040000  /* Directory */
#define S_IFIFO  0010000   /* FIFO first-in-first-out file */
&nbsp;
/* Such devices can be read either a character at a time or a "block" (many characters) at a time,
hence we say there are block special files and character special files. */
#define S_IFBLK   0060000  /* Block device */
#define S_IFCHR  0020000  /* Character device */
</pre>

<h3>Special Permission Bits</h3>
<pre>
#define S_ISUID  0004000  /* Set user ID on execution.  */
#define S_ISGID  0002000  /* Set group ID on execution.  */
#define S_ISVTX  0001000 /* Save swapped text after use (sticky).  */
</pre>

<h3>Bitmasking to determine Filetype</h3>
<pre>
#define S_ISLNK(m) (((m) &amp; S_IFMT) == S_IFLNK)
#define S_ISREG(m) (((m) &amp; S_IFMT) == S_IFREG)
#define S_ISDIR(m) (((m) &amp; S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) &amp; S_IFMT) == S_IFCHR)
#define S_ISBLK(m) (((m) &amp; S_IFMT) == S_IFBLK)
#define S_ISFIFO(m) (((m) &amp; S_IFMT) == S_IFIFO)
#define S_ISSOCK(m) (((m) &amp; S_IFMT) == S_IFSOCK)
</pre>

<h3>Default Permission Masks</h3>
<pre>
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
#define S_IRUGO  (S_IRUSR|S_IRGRP|S_IROTH)
#define S_IWUGO  (S_IWUSR|S_IWGRP|S_IWOTH)
#define S_IXUGO  (S_IXUSR|S_IXGRP|S_IXOTH)
</pre>


<p>Download: <a href='http://uploads.askapache.com/2008/11/filestat.c' title="handles file stat"><code>httpd-2.2.10/srclib/apr/file_io/unix/filestat.c</code></a>, this file shows a simple way to determine the type of file.</p>
<pre>
filetype_from_mode(mode){
 type;
 switch (mode &amp; S_IFMT) {
  case S_IFREG:  type = APR_REG;  break;
  case S_IFDIR:  type = APR_DIR;  break;
  case S_IFLNK:  type = APR_LNK;  break;
&nbsp;
  case S_IFCHR:  type = APR_CHR;  break;
  case S_IFBLK:  type = APR_BLK;  break;
  case S_IFFIFO: type = APR_PIPE; break;
  case S_IFSOCK: type = APR_SOCK; break;
  default: type = APR_UNKFILE;
 }
 return type;
}
</pre>

<h3>Apache Stat Bits</h3>
<pre>
#define APR_FINFO_LINK  0x00000001 /* Stat the link not the file itself if it is a link */
#define APR_FINFO_MTIME  0x00000010 /* Modification Time */
#define APR_FINFO_CTIME  0x00000020 /* Creation or inode-changed time */
#define APR_FINFO_ATIME  0x00000040 /* Access Time */
#define APR_FINFO_SIZE  0x00000100 /* Size of the file */
#define APR_FINFO_CSIZE  0x00000200 /* Storage size consumed by the file */
#define APR_FINFO_DEV  0x00001000 /* Device */
#define APR_FINFO_INODE  0x00002000 /* Inode */
#define APR_FINFO_NLINK  0x00004000 /* Number of links */
#define APR_FINFO_TYPE  0x00008000 /* Type */
#define APR_FINFO_USER  0x00010000 /* User */
#define APR_FINFO_GROUP  0x00020000 /* Group */
#define APR_FINFO_UPROT  0x00100000 /* User protection bits */
#define APR_FINFO_GPROT  0x00200000 /* Group protection bits */
#define APR_FINFO_WPROT  0x00400000 /* World protection bits */
#define APR_FINFO_ICASE  0x01000000 /* if dev is case insensitive */
#define APR_FINFO_NAME  0x02000000 /* name in proper case */
#define APR_FINFO_MIN  0x00008170 /* type, mtime, ctime, atime, size */
#define APR_FINFO_IDENT  0x00003000 /* dev and inode */
#define APR_FINFO_OWNER  0x00030000 /* user and group */
#define APR_FINFO_PROT  0x00700000 /* all protections */
#define APR_FINFO_NORM  0x0073b170 /* an atomic unix apr_stat() */
#define APR_FINFO_DIRENT 0x02000000 /* an atomic unix apr_dir_read() */
</pre>

<h3>The Apache file information structure.</h3>
<pre>
apr_uid_t user;  /* The user id that owns the file */
apr_gid_t group;  /* The group id that owns the file */
apr_ino_t inode; /* The inode of the file. */
apr_dev_t device; /* The id of the device the file is on. */
apr_int32_t nlink; /* The number of hard links to the file. */
apr_off_t size;  /* The size of the file */
apr_off_t csize; /* The storage size consumed by the file */
apr_time_t atime; /* The time the file was last accessed */
apr_time_t mtime; /* The time the file was last modified */
apr_time_t ctime; /* The time the file was created, or the inode was last changed */
const char *fname; /* The pathname of the file (possibly unrooted) */
const char *name; /* The file&#039;s name (no path) in filesystem case */
</pre>



<h3>File Time Attributes</h3>
<blockquote><cite><a href="http://php.net/manual/en/function.touch.php">touch</a></cite>
<p>If changing both the access and modification times to the current time, touch can change the timestamps for files that the user running it does not own but has write permission for. Otherwise, the user must own the files.</p>
</blockquote>

<p>Although touch provides options for changing two of the times the times of last access and modification of a file, there is actually a third one as well: the inode change time. This is often referred to as a file's ctime. The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change. Changing the permissions doesn't access the file, so the atime doesn't change, nor does it modify the file, so the mtime doesn't change. Yet, something about the file itself has changed, and this must be noted somewhere. This is the job of the ctime field. This is necessary, so that, for example, a backup program can make a fresh copy of the file, including the new permissions value. Another operation that modifies a file's ctime without affecting the others is renaming. In any case, it is not possible, in normal operations, for a user to change the ctime field to a user-specified value.</p>
</blockquote>













<a name="Shared_hosting_user_security"></a>
<h2>Shared hosting user security </h2>
<ul>
	<li><a href="#Shared_hosting_user_security">Shared hosting user security</a></li>
	<li><a href="#Apache_Security">Apache Security</a></li>
	<li><a href="#Multiuser_security_setup_example">Multiuser security setup example</a></li>
	<li><a href="#SSH_key_fingerprints">SSH key fingerprints</a></li>
	<li><a href="#External_Links">External Links</a></li>
</ul>
<p>WebHost allows you to create multiple users per account. Each user can have domain assigned to its home home directory accessible via FTP or SSH/SCP. The problem with multiple users on the same account is that they share the same default unix group, and default permissions allow their files to be easily modified by the members of this group. Usually this doesn't pose a problem as each user is probably trusted by account owner to not to mess with others files, but if one of the users have their web application hacked then all other users on the same account will be in danger. </p>
<p>By default all files in your account are created with 644 privileges and directories are with 775. That means any user can read your files and any user from the same account can move and add files in your freshly made directories. Your home directory is different, though. By default it carries 751 attribute meaning that only members of your group can see your files, but can't add any new. These group access schemes are possible, because every user in your account has its primary/default group set to "pgxxxxxx", which is assigned to every new file you create by default. The normal way to secure users from web-intrusion is to assign a separate group to the web-server user, removing it from default group. This way, exploited scripts will not be able to traverse into home directories of other users on your account. To allow account users to update centralized web-site they could be added to web-site group explicitly. But this "normal way" doesn't work with DreamHost, because you can't delete web-user from the default group and unless you set access for every new file explicitly, it will be possible for an intruder to read it. </p>
<p>To make managing privileges easier in interactive sessions "umask 007" command can be specified in your .bash_profile - this makes all new files carry xx0 mask. You also need to control your scripts (web based or cron/shell) so that they set mask for critical files explicitly. To secure account users from access by means of hacked user script you would also like to define another group for every user in your account and change group ownership of the user's home directory to that group with "set gid" bit set (and optional umask 007 in .bash_profile). </p>
<p>Therefore, to secure your users from web-intrusion you need to: </p>
<ol>
	<li>Add a separate user and group for every domain where apache will be running </li>
	<li>Add a separate group for other user accounts </li>
	<li>Change the default group for new files created by your users by changing the group of their home directory and setting "set gid" bit for it (it is impossible to do this with FTP accounts, therefore you will need to login in each account via SSH) </li>
	<li>Add users who need access to web-site into the web-user group </li>
	<li>Optionally set umask 007 in .bash_profile for every user to tweak default WebHost775/664 permissions to something like 770/660 for directories and files that are not meant to be read by Apache (660 could also be used for all web scripts including .php as they are not read by dhapache CGI, but merely executed) </li>
</ol>
<h2><a name="Apache_Security"></a>Apache Security </h2>
<p>All your web files that need to be read by Apache should be readable by everyone as Apache itself is run under dhapache user. However, executable scripts like .php are executed under your own user and do not have to be world readable as they are not actually read by Apache, but executed via <a href="http://en.wikipedia.org/wiki/suEXEC">suEXEC</a>. Quite the opposite - to prevent your code or database settings from being messed by any third-parties you SHOULD set permissions to these files explicitly to something like 640 or even 600 depending on who do you trust. </p>
<a name="Multiuser_security_setup_example"></a>
<h2>Multiuser security setup example </h2>
<p>For our example, we will create a <em>rainforce_www</em> user and a <em>aapp_www</em> group for serving web files with apache and setup a <em>rainforce</em> user with a 'aapp<em> group to manage mail and keep other files on DH privately. Since these records already exist, you will need to subsitute your own names.</em> </p>
<ul>
	<li>Login to create the users <em>rainforce_www</em> and <em>rainforce</em> with shell access. </li>
	<li>Create two groups - <em>aapp_www</em> and <em>aapp</em>. Note that users created in previous step are still members of the same default <em>pg</em>xxxxxx group. </li>
	<li>Add <em>rainforce_www</em> to 'the 'aapp_www<em> group and </em>rainforce<em> to both the </em>aapp_www<em> and </em>aapp<em> groups</em> </li>
	<li>Move your domain to <em>rainforce_www</em> account (mine is rainforce.org) </li>
	<li>Now login to SSH with your <em>rainforce_www</em> user and change the default group for your home directory with "sgid" bit set to make all current and new files/directories created in this directory have the same <em>aapp_www</em> group. </li>
</ul>
<pre>
 $ chgrp -R aapp_www .
 $ chmod 2751 .
 $ chmod 2771 rainforce.org
</pre>
<p>By setting 2771 the directory will be writable by the owner, the group and will be only executable by others. The contents of an executable only directory cannot be listed, but the files inside it can be read (if the permissions of the file allow it). It is important that the directory can be executable in order to allow static content (e.g. .html files) inside it to be read. Remember that directories you don't want anyone to have web access to, should be 0770 (writable by the owner and group, or 0750 writable by the owner and readable by group). Such strict permissions should by applied to password files, php include files or databases files (such as SQLite, BDB, etc). </p>
<ul>
	<li>Do the same for <em>rainforce</em> user, but specify <em>aapp</em> group instead. </li>
</ul>
<pre>
 $ chgrp -R aapp .
 $ chmod 2751 .
</pre>
<ul>
	<li>Optionally modify umask in .bash_profile in user's home to 007 to make all files created by this user have 660 permissions set by default. If you want that newly created files by accessible by the web, you need to manually setup it's permissions to 664. </li>
</ul>
<p>Now I can login as the user "rainforce" and update the web-site in the ../rainforce_www/rainforce.org directory. There is one more setup needed. Because files copied from other accounts can have 644 permissions set instead of 664, you need a script which will update permissions to 664 or 660 to allow other group members modify such files. </p>
<h2><a name="SSH_key_fingerprints"></a>SSH key fingerprints </h2>
<p>Just gen your own I guess </p>
<h2>External Links </h2>
<ul>
	<li><a href="http://oldfield.wattle.id.au/luv/permissions.html" title="http://oldfield.wattle.id.au/luv/permissions.html" rel="nofollow">Introduction to Unix file permissions</a> </li>
	<li><a href="http://www.perlfect.com/articles/chmod.shtml" title="http://www.perlfect.com/articles/chmod.shtml" rel="nofollow">Understanding UNIX permission and chmod</a> </li>
</ul>
<p>Original Article from <a href="http://wiki.dreamhost.com/index.php?title=Security">DreamHost Wiki</a></p>
<p>Content is available under <a href="http://www.gnu.org/copyleft/fdl.html" class="external " title="http://www.gnu.org/copyleft/fdl.html" rel="nofollow">GNU Free Documentation License 1.2</a>.</p>





<h2>Example File Permission Bits</h2>

<h3><code>/usr/lib/w3m/cgi-bin/dirlist.cgi</code></h3>
<pre>
sub utype {
  local($_) = @_;
  local(%T) = (
    0010000, &#039;PIPE&#039;,
    0020000, &#039;CHR&#039;,
    0040000, &#039;DIR&#039;,
    0060000, &#039;BLK&#039;,
    0100000, &#039;FILE&#039;,
    0120000, &#039;LINK&#039;,
    0140000, &#039;SOCK&#039;,
  );
  return $T{($_ &amp; 0170000)} || &#039;FILE&#039;;
}
&nbsp;
sub umode {
  local($_) = @_;
  local(%T) = (
    0010000, &#039;p&#039;,
    0020000, &#039;c&#039;,
    0040000, &#039;d&#039;,
    0060000, &#039;b&#039;,
    0100000, &#039;-&#039;,
    0120000, &#039;l&#039;,
    0140000, &#039;s&#039;,
  );
&nbsp;
  return ($T{($_ &amp; 0170000)} || &#039;-&#039;)
     . (($_ &amp; 00400) ? &#039;r&#039; : &#039;-&#039;)
     . (($_ &amp; 00200) ? &#039;w&#039; : &#039;-&#039;)
     . (($_ &amp; 04000) ? &#039;s&#039; :
       (($_ &amp; 00100) ? &#039;x&#039; : &#039;-&#039;))
     . (($_ &amp; 00040) ? &#039;r&#039; : &#039;-&#039;)
     . (($_ &amp; 00020) ? &#039;w&#039; : &#039;-&#039;)
     . (($_ &amp; 02000) ? &#039;s&#039; :
       (($_ &amp; 00010) ? &#039;x&#039; : &#039;-&#039;))
     . (($_ &amp; 00004) ? &#039;r&#039; : &#039;-&#039;)
     . (($_ &amp; 00002) ? &#039;w&#039; : &#039;-&#039;)
     . (($_ &amp; 01000) ? &#039;t&#039; :
       (($_ &amp; 00001) ? &#039;x&#039; : &#039;-&#039;));
}
</pre>

<h3><code>/usr/lib/perl/5.8.4/linux/stat.ph</code></h3>
<pre>
        eval &#039;sub S_IFMT () {00170000;}&#039; unless defined(&amp;S_IFMT);
        eval &#039;sub S_IFSOCK () {0140000;}&#039; unless defined(&amp;S_IFSOCK);
        eval &#039;sub S_IFLNK () {0120000;}&#039; unless defined(&amp;S_IFLNK);
        eval &#039;sub S_IFREG () {0100000;}&#039; unless defined(&amp;S_IFREG);
        eval &#039;sub S_IFBLK () {0060000;}&#039; unless defined(&amp;S_IFBLK);
        eval &#039;sub S_IFDIR () {0040000;}&#039; unless defined(&amp;S_IFDIR);
        eval &#039;sub S_IFCHR () {0020000;}&#039; unless defined(&amp;S_IFCHR);
        eval &#039;sub S_IFIFO () {0010000;}&#039; unless defined(&amp;S_IFIFO);
        eval &#039;sub S_ISUID () {0004000;}&#039; unless defined(&amp;S_ISUID);
        eval &#039;sub S_ISGID () {0002000;}&#039; unless defined(&amp;S_ISGID);
        eval &#039;sub S_ISVTX () {0001000;}&#039; unless defined(&amp;S_ISVTX);
        eval &#039;sub S_ISLNK {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFLNK));
        }&#039; unless defined(&amp;S_ISLNK);
        eval &#039;sub S_ISREG {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFREG));
        }&#039; unless defined(&amp;S_ISREG);
        eval &#039;sub S_ISDIR {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFDIR));
        }&#039; unless defined(&amp;S_ISDIR);
        eval &#039;sub S_ISCHR {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFCHR));
        }&#039; unless defined(&amp;S_ISCHR);
        eval &#039;sub S_ISBLK {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFBLK));
        }&#039; unless defined(&amp;S_ISBLK);
        eval &#039;sub S_ISFIFO {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFIFO));
        }&#039; unless defined(&amp;S_ISFIFO);
        eval &#039;sub S_ISSOCK {
            local($m) = @_;
            eval q(((($m) &amp;  &amp;S_IFMT) ==  &amp;S_IFSOCK));
        }&#039; unless defined(&amp;S_ISSOCK);
        eval &#039;sub S_IRWXU () {00700;}&#039; unless defined(&amp;S_IRWXU);
        eval &#039;sub S_IRUSR () {00400;}&#039; unless defined(&amp;S_IRUSR);
        eval &#039;sub S_IWUSR () {00200;}&#039; unless defined(&amp;S_IWUSR);
        eval &#039;sub S_IXUSR () {00100;}&#039; unless defined(&amp;S_IXUSR);
        eval &#039;sub S_IRWXG () {00070;}&#039; unless defined(&amp;S_IRWXG);
        eval &#039;sub S_IRGRP () {00040;}&#039; unless defined(&amp;S_IRGRP);
        eval &#039;sub S_IWGRP () {00020;}&#039; unless defined(&amp;S_IWGRP);
        eval &#039;sub S_IXGRP () {00010;}&#039; unless defined(&amp;S_IXGRP);
        eval &#039;sub S_IRWXO () {00007;}&#039; unless defined(&amp;S_IRWXO);
        eval &#039;sub S_IROTH () {00004;}&#039; unless defined(&amp;S_IROTH);
        eval &#039;sub S_IWOTH () {00002;}&#039; unless defined(&amp;S_IWOTH);
        eval &#039;sub S_IXOTH () {00001;}&#039; unless defined(&amp;S_IXOTH);
    }
    if(defined(&amp;__KERNEL__)) {
        eval &#039;sub S_IRWXUGO () {( &amp;S_IRWXU| &amp;S_IRWXG| &amp;S_IRWXO);}&#039; unless defined(&amp;S_IRWXUGO);
        eval &#039;sub S_IALLUGO () {( &amp;S_ISUID| &amp;S_ISGID| &amp;S_ISVTX| &amp;S_IRWXUGO);}&#039; unless defined(&amp;S_IALLUGO);
        eval &#039;sub S_IRUGO () {( &amp;S_IRUSR| &amp;S_IRGRP| &amp;S_IROTH);}&#039; unless defined(&amp;S_IRUGO);
        eval &#039;sub S_IWUGO () {( &amp;S_IWUSR| &amp;S_IWGRP| &amp;S_IWOTH);}&#039; unless defined(&amp;S_IWUGO);
        eval &#039;sub S_IXUGO () {( &amp;S_IXUSR| &amp;S_IXGRP| &amp;S_IXOTH);}&#039; unless defined(&amp;S_IXUGO);
        require &#039;linux/types.ph&#039;;
        require &#039;linux/time.ph&#039;;
    }
&nbsp;
</pre>

<p><a href="http://ftp.mozilla.org/pub/mozilla.org/mozilla/releases/mozilla1.8a2/src/mozilla-source-1.8a2.tar.bz2 ">Mozilla-Source 1.8a2</a></p>
<pre>
/* notice that these valuse are octal. */
const PERM_IRWXU = 00700;  /* read, write, execute/search by owner */
const PERM_IRUSR = 00400;  /* read permission, owner */
const PERM_IWUSR = 00200;  /* write permission, owner */
const PERM_IXUSR = 00100;  /* execute/search permission, owner */
const PERM_IRWXG = 00070;  /* read, write, execute/search by group */
const PERM_IRGRP = 00040;  /* read permission, group */
const PERM_IWGRP = 00020;  /* write permission, group */
const PERM_IXGRP = 00010;  /* execute/search permission, group */
const PERM_IRWXO = 00007;  /* read, write, execute/search by others */
const PERM_IROTH = 00004;  /* read permission, others */
const PERM_IWOTH = 00002;  /* write permission, others */
const PERM_IXOTH = 00001;  /* execute/search permission, others */
&nbsp;
const MODE_RDONLY   = 0x01;
const MODE_WRONLY   = 0x02;
const MODE_RDWR     = 0x04;
const MODE_CREATE   = 0x08;
const MODE_APPEND   = 0x10;
const MODE_TRUNCATE = 0x20;
const MODE_SYNC     = 0x40;
const MODE_EXCL     = 0x80;
</pre>


<h3><code>/usr/include/libpng12/png.h</code></h3>
<pre>
/* Transform masks for the high-level interface */
#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */
#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */
#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */
#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */
#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */
#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */
#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */
#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */
#define PNG_TRANSFORM_BGR            0x0080    /* read and write */
#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */
#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */
#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */
#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* WRITE only */
</pre>


<h3><code>/usr/lib/python2.4/stat.py</code></h3>
<pre>
# Extract bits from the mode
&nbsp;
def S_IMODE(mode):
    return mode &amp; 07777
&nbsp;
def S_IFMT(mode):
    return mode &amp; 0170000
&nbsp;
# Constants used as S_IFMT() for various file types
# (not all are implemented on all systems)
&nbsp;
S_IFDIR  = 0040000
S_IFCHR  = 0020000
S_IFBLK  = 0060000
S_IFREG  = 0100000
S_IFIFO  = 0010000
S_IFLNK  = 0120000
S_IFSOCK = 0140000
&nbsp;
# Functions to test for each file type
&nbsp;
def S_ISDIR(mode):
    return S_IFMT(mode) == S_IFDIR
&nbsp;
def S_ISCHR(mode):
    return S_IFMT(mode) == S_IFCHR
&nbsp;
def S_ISBLK(mode):
    return S_IFMT(mode) == S_IFBLK
&nbsp;
def S_ISREG(mode):
    return S_IFMT(mode) == S_IFREG
&nbsp;
def S_ISFIFO(mode):
    return S_IFMT(mode) == S_IFIFO
&nbsp;
def S_ISLNK(mode):
    return S_IFMT(mode) == S_IFLNK
&nbsp;
def S_ISSOCK(mode):
    return S_IFMT(mode) == S_IFSOCK
&nbsp;
# Names for permission bits
&nbsp;
S_ISUID = 04000
S_ISGID = 02000
S_ENFMT = S_ISGID
S_ISVTX = 01000
S_IREAD = 00400
S_IWRITE = 00200
S_IEXEC = 00100
S_IRWXU = 00700
S_IRUSR = 00400
S_IWUSR = 00200
S_IXUSR = 00100
S_IRWXG = 00070
S_IRGRP = 00040
S_IWGRP = 00020
S_IXGRP = 00010
S_IRWXO = 00007
S_IROTH = 00004
S_IWOTH = 00002
S_IXOTH = 00001
</pre>


<h3><code>/usr/include/bits/stat.h</code></h3>
<pre>
/* Encoding of the file mode.  */
&nbsp;
#define __S_IFMT        0170000 /* These bits determine file type.  */
&nbsp;
/* File types.  */
#define __S_IFDIR       0040000 /* Directory.  */
#define __S_IFCHR       0020000 /* Character device.  */
#define __S_IFBLK       0060000 /* Block device.  */
#define __S_IFREG       0100000 /* Regular file.  */
#define __S_IFIFO       0010000 /* FIFO.  */
#define __S_IFLNK       0120000 /* Symbolic link.  */
#define __S_IFSOCK      0140000 /* Socket.  */
&nbsp;
/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
   they do it by enforcing the correct use of the macros.  */
#define __S_TYPEISMQ(buf)  ((buf)-&gt;st_mode - (buf)-&gt;st_mode)
#define __S_TYPEISSEM(buf) ((buf)-&gt;st_mode - (buf)-&gt;st_mode)
#define __S_TYPEISSHM(buf) ((buf)-&gt;st_mode - (buf)-&gt;st_mode)
&nbsp;
/* Protection bits.  */
&nbsp;
#define __S_ISUID       04000   /* Set user ID on execution.  */
#define __S_ISGID       02000   /* Set group ID on execution.  */
#define __S_ISVTX       01000   /* Save swapped text after use (sticky).  */
#define __S_IREAD       0400    /* Read by owner.  */
#define __S_IWRITE      0200    /* Write by owner.  */
#define __S_IEXEC       0100    /* Execute by owner.  */
</pre>



<h3><code>/usr/include/linux/nfs.h</code></h3>
<pre>
#define NFS_FIFO_DEV    (-1)
#define NFSMODE_FMT     0170000
#define NFSMODE_DIR     0040000
#define NFSMODE_CHR     0020000
#define NFSMODE_BLK     0060000
#define NFSMODE_REG     0100000
#define NFSMODE_LNK     0120000
#define NFSMODE_SOCK    0140000
#define NFSMODE_FIFO    0010000
</pre>


<h3><code>/usr/include/linux/nfs3.h</code></h3>
<pre>
#define NFS3_FIFO_DEV           (-1)
#define NFS3MODE_FMT            0170000
#define NFS3MODE_DIR            0040000
#define NFS3MODE_CHR            0020000
#define NFS3MODE_BLK            0060000
#define NFS3MODE_REG            0100000
#define NFS3MODE_LNK            0120000
#define NFS3MODE_SOCK           0140000
#define NFS3MODE_FIFO           0010000
&nbsp;
/* Flags for access() call */
#define NFS3_ACCESS_READ        0x0001
#define NFS3_ACCESS_LOOKUP      0x0002
#define NFS3_ACCESS_MODIFY      0x0004
#define NFS3_ACCESS_EXTEND      0x0008
#define NFS3_ACCESS_DELETE      0x0010
#define NFS3_ACCESS_EXECUTE     0x0020
#define NFS3_ACCESS_FULL        0x003f
</pre>


<h3><code>/usr/include/linux/stat.h</code></h3>
<pre>
#define S_IFMT  00170000
#define S_IFSOCK 0140000
#define S_IFLNK  0120000
#define S_IFREG  0100000
#define S_IFBLK  0060000
#define S_IFDIR  0040000
#define S_IFCHR  0020000
#define S_IFIFO  0010000
#define S_ISUID  0004000
#define S_ISGID  0002000
#define S_ISVTX  0001000
&nbsp;
#define S_ISLNK(m)      (((m) &amp; S_IFMT) == S_IFLNK)
#define S_ISREG(m)      (((m) &amp; S_IFMT) == S_IFREG)
#define S_ISDIR(m)      (((m) &amp; S_IFMT) == S_IFDIR)
#define S_ISCHR(m)      (((m) &amp; S_IFMT) == S_IFCHR)
#define S_ISBLK(m)      (((m) &amp; S_IFMT) == S_IFBLK)
#define S_ISFIFO(m)     (((m) &amp; S_IFMT) == S_IFIFO)
#define S_ISSOCK(m)     (((m) &amp; S_IFMT) == S_IFSOCK)
&nbsp;
#define S_IRWXU 00700
#define S_IRUSR 00400
#define S_IWUSR 00200
#define S_IXUSR 00100
&nbsp;
#define S_IRWXG 00070
#define S_IRGRP 00040
#define S_IWGRP 00020
#define S_IXGRP 00010
&nbsp;
#define S_IRWXO 00007
#define S_IROTH 00004
#define S_IWOTH 00002
#define S_IXOTH 00001
</pre>











<h2>Further File Permissions Reading</h2>
<h3>Related PHP Functions</h3>
<ul>
<li><a href="http://php.net/manual/en/function.fileperms.php">fileperms</a></li>
<li><a href="http://php.net/manual/en/function.stat.php">stat</a></li>
<li><a href="http://php.net/manual/en/function.chmod.php">chmod</a></li>
<li><a href="http://php.net/manual/en/function.clearstatcache.php">clearstatcache</a></li>
<li><a href="http://php.net/manual/en/function.chown.php">chown</a></li>
<li><a href="http://php.net/manual/en/function.chgrp.php">chgrp</a></li>
<li><a href="http://php.net/manual/en/function.lchown.php">lchown</a></li>
<li><a href="http://php.net/manual/en/function.lchgrp.php">lchgrp</a></li>
<li><a href="http://php.net/manual/en/function.touch.php">touch</a></li>
<li><a href="http://php.net/manual/en/function.lstat.php">lstat</a></li>
<li><a href="http://php.net/manual/en/function.fstat.php">filestat</a></li>
<li><a href="http://php.net/manual/en/function.fileatime.php">fileatime</a></li>
<li><a href="http://php.net/manual/en/function.filectime.php">filectime</a></li>
<li><a href="http://php.net/manual/en/function.filegroup.php">filegroup</a></li>
<li><a href="http://php.net/manual/en/function.fileinode.php">fileinode</a></li>
<li><a href="http://php.net/manual/en/function.filemtime.php">filemtime</a></li>
<li><a href="http://php.net/manual/en/function.fileowner.php">fileowner</a></li>
<li><a href="http://php.net/manual/en/function.filesize.php">filesize</a></li>
<li><a href="http://php.net/manual/en/function.filetype.php">filetype</a></li>
<li><a href="http://php.net/manual/en/function.is-writable.php">is_writable</a></li>
<li><a href="http://php.net/manual/en/function.is-readable.php">is_readable</a></li>
<li><a href="http://php.net/manual/en/function.is-executable.php">is_executable</a></li>
<li><a href="http://php.net/manual/en/function.is-file.php">is_file</a></li>
<li><a href="http://php.net/manual/en/function.is-dir.php">is_dir</a></li>
<li><a href="http://php.net/manual/en/function.is-link.php">is_link</a></li>
<li><a href="http://php.net/manual/en/function.file-exists.php">file_exists</a></li>
<li><a href="http://php.net/manual/en/function.disk-total-space.php">disk_total_space</a></li>
<li><a href="http://php.net/manual/en/function.disk-free-space.php">disk_free_space</a></li>
</ul>


<h3>Special file types</h3>
<ul>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#link-invocation">link invocation</a>:  Make a hard link via the link syscall</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#ln-invocation">ln invocation</a>: Make links between files</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#mkdir-invocation">mkdir invocation</a>: Make directories</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#mkfifo-invocation">mkfifo invocation</a>: Make FIFOs (named pipes)</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#mknod-invocation">mknod invocation</a>: Make block or character special files</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#readlink-invocation">readlink invocation</a>: Print the referent of a symbolic link</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#rmdir-invocation">rmdir invocation</a>: Remove empty directories</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#unlink-invocation">unlink invocation</a>: Remove files via unlink syscall</li>
</ul>


<h3>Changing file attributes</h3>
<ul>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#chown-invocation">chown invocation</a>: Change file owner and group</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#chgrp-invocation">chgrp invocation</a>: Change group ownership</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#chmod-invocation">chmod invocation</a>: Change access permissions</li>
<li><a href="http://www.gnu.org/software/coreutils/manual/coreutils.html#touch-invocation">touch invocation</a>: Change file timestamps</li>
</ul><p><a href="http://www.askapache.com/security/chmod-stat.html"></a><a href="http://www.askapache.com/security/chmod-stat.html">Chmod, Umask, Stat, Fileperms, and File Permissions</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/hxqVYbxvaLS6aLjLCl2qAq9rCyM/0/da"><img src="http://feedads.g.doubleclick.net/~a/hxqVYbxvaLS6aLjLCl2qAq9rCyM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/hxqVYbxvaLS6aLjLCl2qAq9rCyM/1/da"><img src="http://feedads.g.doubleclick.net/~a/hxqVYbxvaLS6aLjLCl2qAq9rCyM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/zRJWsA1FD3E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/security/chmod-stat.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.askapache.com/security/chmod-stat.html</feedburner:origLink></item>
		<item>
		<title>PirateBay and Anonymous SOPA Press Releases</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/Pcg4NqY2CwY/piratebay-sopa.html</link>
		<comments>http://www.askapache.com/hacking/piratebay-sopa.html#comments</comments>
		<pubDate>Thu, 19 Jan 2012 21:12:58 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Anonymous]]></category>
		<category><![CDATA[PirateBay]]></category>
		<category><![CDATA[SOPA]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=6991</guid>
		<description><![CDATA[<p><strong>SOPA: Anonymous Lists Their Demands</strong></p>
<blockquote><p><strong>A rallying cry on the occassion of the Web's first mass blackout</strong></p>
<p>As we watch the web go dark today in protest against the SOPA/PIPA censorship bills, let's take a moment and reflect on why this fight is so important. We may have learned that free speech is what makes America great, or instinctively resist attempts at silencing our voices. But these are abstract principles, divorced from the real world and our daily lives.</p>
<p>Free speech is the foundation of a free society. We can have the vote all we want. We can donate money wherever we want. But unless we're able to talk to each other and figure out collectively _what_ we want, those things don't matter.</p>
<p>We believe a healthy society doesn't allow its artists, musicians and other creators to starve. The copyright industry has been justly criticized for abusing the political process in a desperate attempt to maintain its role as a cultural gatekeeper, a business model made obsolete by a digital age of free copies. But the RIAA, MPAA &#038; IFPI deserve our opprobrium for making enormous profits while often leaving the very artists it claims to represent *poorer* than they would be as independents.[1] While the public may have greater access to the few artists deemed sufficiently marketable to gain mass media promotion, fewer and fewer of us are making art and music in our own lives.</p>
<p>We call upon all freedom loving Internauts to join us. We further call upon our legislators, bureaucrats and the media &#038; telecommunications industries to immediately begin implementing our demands. The future of free speech is bright, and clear - either stand with us or get out of the way.</p></blockquote>

<p><strong>PirateBay Press Release regarding SOPA...</strong></p>
<blockquote><p>So, the whole basis of this industry, that today is screaming about losing control over immaterial rights, is that they circumvented immaterial rights. They copied (or put in their terminology: "stole") other peoples creative works, without paying for it. They did it in order to make a huge profit. Today, they're all successful and most of the studios are on the Fortune 500 list of the richest companies in the world. Congratulations - it's all based on being able to re-use other peoples creative works. And today they hold the rights to what other people create. If you want to get something released, you have to abide to their rules. The ones they created after circumventing other peoples rules.</p>
<p>The reason they are always complainting about "pirates" today is simple. We've done what they did. We circumvented the rules they created and created our own. We crushed their monopoly by giving people something more efficient. We allow people to have direct communication between eachother, circumventing the profitable middle man, that in some cases take over 107% of the profits (yes, you pay to work for them). It's all based on the fact that we're competition. We've proven that their existance in their current form is no longer needed. We're just better than they are.</p></blockquote>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/hacking/piratebay-sopa.html"></a><a href="http://www.askapache.com/hacking/piratebay-sopa.html"><cite>AskApache.com</cite></a></p><h2>PirateBay SOPA Press Release</h2>
<h3>INTERNETS, 18th of January 2012.</h3>
<h3>PRESS RELEASE, FOR IMMEDIATE RELEASE</h3>
<p>Over a century ago Thomas Edison got the patent for a device which would "do for the eye what the phonograph does for the ear". He called it the Kinetoscope. He was not only amongst the first to record video, he was also the first person to own the copyright to a motion picture.</p>
<p>Because of Edisons patents for the motion pictures it was close to financially impossible to create motion pictures in the North american east coast. The movie studios therefor relocated to California, and founded what we today call Hollywood. The reason was mostly because there was no patent. There was also no copyright to speak of, so the studios could copy old stories and make movies out of them - like Fantasia, one of Disneys biggest hits ever.</p>
<p>So, the whole basis of this industry, that today is screaming about losing control over immaterial rights, is that they circumvented immaterial rights. They copied (or put in their terminology: "stole") other peoples creative works, without paying for it. They did it in order to make a huge profit. Today, they're all successful and most of the studios are on the Fortune 500 list of the richest companies in the world. Congratulations - it's all based on being able to re-use other peoples creative works. And today they hold the rights to what other people create. If you want to get something released, you have to abide to their rules. The ones they created after circumventing other peoples rules.</p>
<p>The reason they are always complainting about "pirates" today is simple. We've done what they did. We circumvented the rules they created and created our own. We crushed their monopoly by giving people something more efficient. We allow people to have direct communication between eachother, circumventing the profitable middle man, that in some cases take over 107% of the profits (yes, you pay to work for them). It's all based on the fact that we're competition. We've proven that their existance in their current form is no longer needed. We're just better than they are.</p>
<p>And the funny part is that our rules are very similar to the founding ideas of the USA. We fight for freedom of speech. We see all people as equal. We believe that the public, not the elite, should rule the nation. We believe that laws should be created to serve the public, not the rich corporations.</p>
<p>The Pirate Bay is truly an international community. The team is spread all over the globe - but we've stayed out of the USA. We have Swedish roots and a swedish friend said this: The word SOPA means "trash" in Swedish. The word PIPA means "a pipe" in Swedish. This is of course not a coincidence. They want to make the internet inte a one way pipe, with them at the top, shoving trash through the pipe down to the rest of us obedient consumers.  The public opinion on this matter is clear. Ask anyone on the street and you'll learn that noone wants to be fed with trash. Why the US government want the american people to be fed with trash is beyond our imagination but we hope that you will stop them, before we all drown.</p>
<p>SOPA can't do anything to stop TPB. Worst case we'll change top level domain from our current .org to one of the hundreds of other names that we already also use. In countries where TPB is blocked, China and Saudi Arabia springs to mind, they block hundreds of our domain names. And did it work? Not really. To fix the "problem of piracy" one should go to the source of the problem. The entertainment industry say they're creating "culture" but what they really do is stuff like selling overpriced plushy dolls and making 11 year old girls become anorexic. Either from working in the factories that creates the dolls for basically no salary or by watching movies and tv shows that make them think that they're fat.</p>
<p>In the great Sid Meiers computer game Civilization you can build Wonders of the world. One of the most powerful ones is Hollywood. With that you control all culture and media in the world. Rupert Murdoch was happy with MySpace and had no problems with their own piracy until it failed. Now he's complainting that Google is the biggest source of piracy in the world - because he's jealous. He wants to retain his mind control over people and clearly you'd get a more honest view of things on Wikipedia and Google than on Fox News.</p>
<p>Some facts (years, dates) are probably wrong in this press release. The reason is that we can't access this information when Wikipedia is blacked out. Because of pressure from our failing competitors. We're sorry for that.</p>
<p><cite><a href="https://static.thepiratebay.org/legal/sopa.txt">THE PIRATE BAY, (K)2012</a></cite></p>


<h2>Anonymous Hackers SOPA Statement</h2>
<h3>Bright, and Clear: The Future of Free Speech</h3>
<p><strong>A rallying cry on the occassion of the Web's first mass blackout</strong></p>
<p>As we watch the web go dark today in protest against the SOPA/PIPA censorship bills, let's take a moment and reflect on why this fight is so important. We may have learned that free speech is what makes America great, or instinctively resist attempts at silencing our voices. But these are abstract principles, divorced from the real world and our daily lives.</p>
<p>Free speech is the foundation of a free society. We can have the vote all we want. We can donate money wherever we want. But unless we're able to talk to each other and figure out collectively _what_ we want, those things don't matter.</p>
<p>We believe a healthy society doesn't allow its artists, musicians and other creators to starve. The copyright industry has been justly criticized for abusing the political process in a desperate attempt to maintain its role as a cultural gatekeeper, a business model made obsolete by a digital age of free copies. But the RIAA, MPAA & IFPI deserve our opprobrium for making enormous profits while often leaving the very artists it claims to represent *poorer* than they would be as independents.[1] While the public may have greater access to the few artists deemed sufficiently marketable to gain mass media promotion, fewer and fewer of us are making art and music in our own lives.</p>
<p>It's time we make a stand for a better world - not merely take rearguard actions to preserve a status quo that is _already_ failing us. Accordingly, we present the following list of demands:</p>
<ul>
<li>We call on national legislatures to not only reject ACTA efforts to globalize the American intellectual property regime, but to abolish the WIPO.</li>
<li>We demand the elimination of the DMCA's registration requirement for qualification under the "safe harbor" provision. It's absurd that a website owner needs to mail in a form and pay a $100+ fee to the government to register a contact for copyright violations. A web page at a standard location (a la robots.txt) should suffice.</li>
<li>We expect courts to apply penalties just as severe to rightsholders who issue abusive takedown notices as those applied to copyright violators.</li>
<li>No more Jammie Thomases. Any penalties for copyright infringement must be sane and reasonable and not based unsubstantiated, outlandish claims of harm.</li>
<li>The Department of Justice must begin an anti-trust investigation into the copyright industry, with a specific focus on collusion between rightsholders and ISPs in monitoring Internet users, and payola and cross ownership with mass media.</li>
<li>We demand an end to sales of radio frequencies into private hands. We hold that spectrum is a form of speech - it rightly belongs to the people and is not the government's to auction off to begin with.</li>
<li>We demand that ISPs stop interfering with file sharing via BitTorrent or any other protocol.</li>
<li>We recognize a right of total ownership, not merely licensing, of products we have purchased and a right to tinker and modify them as we see fit. The Library of Congress should not be determining the acceptable boundaries of technology.</li>
<li>We reject the principle of contributory infringement entirely. While there may be bad uses, there is no bad code.</li>
<li>We expect legislators and judges to make efforts to educate themselves about the technologies they oversee, and to call on and respect the opinions of technical experts when necessary. The Internet makes nerds of us all.</li>
<li>All research receiving any public funding, directly or indirectly, must be placed in the public domain upon publication.</li>
<li>For the sake of innovation and competitiveness, the US Patent & Trade Office must immediately cease issuing software and business method patents, and declare all such existing patents null and void. We unequivocally reject any patents on mathematical formulas and genes or other naturally-occurring substances (human or otherwise).</li>
<li>Copyright and patent terms must be reduced to reasonable lengths (two and five years from the time of creation, respectively). Works should only be eligible for the length of protection in the effect when created - the continuing extension of terms to protect Disney's ownership of Mickey Mouse must cease.</li>
<li>We recognize a broad right of "fair use" as essential to a vibrant and creative culture. We will remix, sample, mash up, translate, perform, parody and otherwise create derivative works as we see fit.</li>
<li>Courts must accord bloggers the same rights as mainstream reporters. The right to a free press originally meant a literal, physical printing press - not membership in some government sanctioned elite. Blogs are the modern day digital equivalent.</li>
</ul>
<p>We call upon all freedom loving Internauts to join us. We further call upon our legislators, bureaucrats and the media & telecommunications industries to immediately begin implementing our demands. The future of free speech is bright, and clear - either stand with us or get out of the way.  <a href="http://www.negativland.com/albini.html">[1]</a></p>


<h2>KeepTheWebOpen - Fight Back!</h2>
<p>The <a href="http://keepthewebopen.com">KeepTheWebOpen</a> site shows how the world may fundamentally be changed for the better... soon.. maybe...</p><p><a href="http://www.askapache.com/hacking/piratebay-sopa.html"></a><a href="http://www.askapache.com/hacking/piratebay-sopa.html">PirateBay and Anonymous SOPA Press Releases</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/9O2ZmrgY4G-mjsCdOY5wibaxrG8/0/da"><img src="http://feedads.g.doubleclick.net/~a/9O2ZmrgY4G-mjsCdOY5wibaxrG8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9O2ZmrgY4G-mjsCdOY5wibaxrG8/1/da"><img src="http://feedads.g.doubleclick.net/~a/9O2ZmrgY4G-mjsCdOY5wibaxrG8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/Pcg4NqY2CwY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/hacking/piratebay-sopa.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.askapache.com/hacking/piratebay-sopa.html</feedburner:origLink></item>
		<item>
		<title>K-Swiss MFCEO Internet Commercial</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/uz1aZslQMEI/kenny-powers.html</link>
		<comments>http://www.askapache.com/design/kenny-powers.html#comments</comments>
		<pubDate>Wed, 14 Dec 2011 05:05:49 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=6970</guid>
		<description><![CDATA[<p>Kenny Powers Internet Commercial</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/design/kenny-powers.html"></a><a href="http://www.askapache.com/design/kenny-powers.html"><cite>AskApache.com</cite></a></p><div><div style="width:640px;height:360px;display:block;overflow:hidden;border:30px solid #fff;float:left;"><p id="youtubekpowers"></p></div></div><p><a href="http://www.askapache.com/design/kenny-powers.html"></a><a href="http://www.askapache.com/design/kenny-powers.html">K-Swiss MFCEO Internet Commercial</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/V6QLcAJDVa8SNq_HAbirs5hw16Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/V6QLcAJDVa8SNq_HAbirs5hw16Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/V6QLcAJDVa8SNq_HAbirs5hw16Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/V6QLcAJDVa8SNq_HAbirs5hw16Q/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/uz1aZslQMEI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/design/kenny-powers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/design/kenny-powers.html</feedburner:origLink></item>
		<item>
		<title>Drug Dealer Girl</title>
		<link>http://feedproxy.google.com/~r/apache/htaccess/~3/u9BYo9rLOjA/drug-dealer-girl.html</link>
		<comments>http://www.askapache.com/design/drug-dealer-girl.html#comments</comments>
		<pubDate>Wed, 02 Nov 2011 04:07:36 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=5460</guid>
		<description><![CDATA[<p>Youtube Music</>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/design/drug-dealer-girl.html"></a><a href="http://www.askapache.com/design/drug-dealer-girl.html"><cite>AskApache.com</cite></a></p><div><div style="width:480px;height:320px;display:block;overflow:hidden;border:30px solid #fff;float:left;"><p id="youtubedealergirl"></p></div></div><p><a href="http://www.askapache.com/design/drug-dealer-girl.html"></a><a href="http://www.askapache.com/design/drug-dealer-girl.html">Drug Dealer Girl</a> originally appeared on <cite>AskApache.com</cite> </p>
<p><a href="http://feedads.g.doubleclick.net/~a/oXzTs7hywFNFb_tR0BGHScAQnio/0/da"><img src="http://feedads.g.doubleclick.net/~a/oXzTs7hywFNFb_tR0BGHScAQnio/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/oXzTs7hywFNFb_tR0BGHScAQnio/1/da"><img src="http://feedads.g.doubleclick.net/~a/oXzTs7hywFNFb_tR0BGHScAQnio/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/apache/htaccess/~4/u9BYo9rLOjA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/design/drug-dealer-girl.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.askapache.com/design/drug-dealer-girl.html</feedburner:origLink></item>
	</channel>
</rss>

