<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Tully Rankin</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/" />
    <link rel="self" type="application/atom+xml" href="http://www.tullyrankin.com/atom.xml" />
    <id>tag:,2009-03-23:/3</id>
    <updated>2010-03-05T08:59:56Z</updated>
    <subtitle>My blog includes various articles on Linux, PHP, BASH, Programming, Security, and other technology related topics.</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.24-en</generator>

<entry>
    <title>Packet Storm ATOM Feed</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/packet-storm-atom-feed.html" />
    <id>tag:www.tullyrankin.com,2010://3.110</id>

    <published>2010-03-05T07:35:09Z</published>
    <updated>2010-03-05T08:59:56Z</updated>

    <summary>I was searching around Packet Storm today and wanted to add there new files as a RSS/ATOM feed on my browser. I didn&apos;t find a link for this, so I created one in PHP. Below is the code that creates...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phpatomdomtidypacketstorm" label="php atom dom tidy packetstorm" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>I was searching around Packet Storm today and wanted to add there new files as a RSS/ATOM feed on my browser. I didn't find a link for this, so I created one in PHP. Below is the code that creates the atom.xml file.<br /><br /> <a href="/code/packetstorm_atom.txt">Click Here To View</a><br /><br />
<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/<em><br />&nbsp;</em>&nbsp;Connects&nbsp;to&nbsp;packstormsecurity.org&nbsp;and&nbsp;created&nbsp;a&nbsp;<br />&nbsp;<em>&nbsp;atom&nbsp;feed&nbsp;of&nbsp;the&nbsp;last&nbsp;20&nbsp;uploaded&nbsp;files.<br />&nbsp;</em>&nbsp;<br />&nbsp;<em>&nbsp;@requires&nbsp;php-curl&nbsp;php-tidy<br />&nbsp;</em>&nbsp;@author&nbsp;Tully&nbsp;Rankin<br />&nbsp;<em>&nbsp;@url&nbsp;&nbsp;&nbsp;&nbsp;http://www.TullyRankin.com<br />&nbsp;</em>/<br /></span><span style="color: #0000BB">$ch&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl<em>init</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'http://www.packetstormsecurity.org/last20.html'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$site&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'http://www.packetstormsecurity.org'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">curl</em>setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT<em>URL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl</em>setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT<em>HEADER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl</em>setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT<em>RETURNTRANSFER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl</em>exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl<em>close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$tidy</em>config&nbsp;</span><span style="color: #007700">=&nbsp;array(&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'clean'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'output-xhtml'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'show-body-only'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'wrap'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">0<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$tidy&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">tidy<em>parse</em>string</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$tidy<em>config</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'UTF8'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cleanRepair</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$xhtml&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg</em>replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'/\&lt;spacer.*\&gt;/'</span><span style="color: #007700">,</span><span style="color: #DD0000">''</span><span style="color: #007700">,</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$xml&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$xml</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadHTML</span><span style="color: #007700">(</span><span style="color: #0000BB">$xhtml</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$body&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$xml</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"body"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$links&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$body</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"a"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />foreach(</span><span style="color: #0000BB">$links&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">)&nbsp;<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$link</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getAttribute</span><span style="color: #007700">(</span><span style="color: #DD0000">"class"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"fname"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$files</span><span style="color: #007700">[</span><span style="color: #0000BB">$x</span><span style="color: #007700">][</span><span style="color: #DD0000">'name'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">nodeValue</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$files</span><span style="color: #007700">[</span><span style="color: #0000BB">$x</span><span style="color: #007700">][</span><span style="color: #DD0000">'link'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getAttribute</span><span style="color: #007700">(</span><span style="color: #DD0000">"href"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$x</span><span style="color: #007700">++;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$tables&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$body</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"table"</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$tables&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$table</span><span style="color: #007700">)&nbsp;<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$table</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getAttribute</span><span style="color: #007700">(</span><span style="color: #DD0000">"class"</span><span style="color: #007700">)&nbsp;!=&nbsp;</span><span style="color: #DD0000">"fbox2"</span><span style="color: #007700">)&nbsp;continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$tRows&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$table</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"tr"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: #0000BB">$tRows&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getAttribute</span><span style="color: #007700">(</span><span style="color: #DD0000">"class"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"finfo"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"td"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;!=&nbsp;</span><span style="color: #0000BB">null&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"td"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">getAttribute</span><span style="color: #007700">(</span><span style="color: #DD0000">"valign"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"top"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$td&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">"td"</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$td</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">nodeValue</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$fileNames&nbsp;</span><span style="color: #007700">=&nbsp;array();<br />foreach&nbsp;(</span><span style="color: #0000BB">$files&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">)&nbsp;<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">[</span><span style="color: #DD0000">'link'</span><span style="color: #007700">],</span><span style="color: #0000BB">0</span><span style="color: #007700">,</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"/"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$content</span><span style="color: #007700">[</span><span style="color: #0000BB">$x</span><span style="color: #007700">][</span><span style="color: #DD0000">'name'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$content</span><span style="color: #007700">[</span><span style="color: #0000BB">$x</span><span style="color: #007700">][</span><span style="color: #DD0000">'link'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$site</span><span style="color: #007700">.</span><span style="color: #0000BB">$file</span><span style="color: #007700">[</span><span style="color: #DD0000">'link'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$content</span><span style="color: #007700">[</span><span style="color: #0000BB">$x</span><span style="color: #007700">][</span><span style="color: #DD0000">'text'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$text</span><span style="color: #007700">[</span><span style="color: #0000BB">$x</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$x</span><span style="color: #007700">++;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;&nbsp;</span><span style="color: #DD0000">'&lt;?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?&gt;<br />&lt;feed&nbsp;xmlns="http://www.w3.org/2005/Atom"&gt;<br />&lt;title&gt;PacketStorm&nbsp;Security&lt;/title&gt;<br />&lt;link&nbsp;rel="alternate"&nbsp;type="text/html"&nbsp;href="http://www.tullyrankin.com/"&nbsp;/&gt;<br />&lt;link&nbsp;rel="self"&nbsp;type="application/atom+xml"&nbsp;href="http://www.tullyrankin.com/atom.xml"&nbsp;/&gt;<br />&lt;id&gt;&lt;/id&gt;<br />&lt;updated&gt;2010-03-03&lt;/updated&gt;<br />&lt;subtitle&gt;Security&nbsp;Feed&lt;/subtitle&gt;<br />'</span><span style="color: #007700">;<br />foreach&nbsp;(</span><span style="color: #0000BB">$content&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$node</span><span style="color: #007700">)&nbsp;<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;entry&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;title&gt;{$node['name']}&lt;/title&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;link&nbsp;href=\"{$node['link']}\"&nbsp;/&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;summary&gt;{$node['text']}&lt;/summary&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;/entry&gt;"</span><span style="color: #007700">;<br />}&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"&lt;/feed&gt;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$conn&nbsp;</span><span style="color: #007700">=&nbsp;@</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'packetstorm.xml'</span><span style="color: #007700">,</span><span style="color: #DD0000">'w+'</span><span style="color: #007700">);<br /><br />if&nbsp;(@</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;===&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'&lt;h1&gt;Could&nbsp;Not&nbsp;create&nbsp;feed&lt;/h1&gt;'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />}<br />else<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;h1&gt;Created&nbsp;new&nbsp;packetstorm.xml&nbsp;file!&lt;/h1&gt;'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">);<br /></span>
</span>
</code></p>
]]>
        

    </content>
</entry>

<entry>
    <title>PHP Class Passwd</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/php-class-passwd.html" />
    <id>tag:www.tullyrankin.com,2010://3.109</id>

    <published>2010-02-06T07:01:10Z</published>
    <updated>2010-02-06T07:20:10Z</updated>

    <summary><![CDATA[Just for fun, I wrote a short simple class to parse the Linux "passwd" file. The class has functions to return the content in either html or text for the command line. The difference being one has "&lt;br /&gt;" statements...]]></summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phplinuxpasswdclassoop" label="php linux passwd class oop" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[Just for fun, I wrote a short simple class to parse the Linux "passwd" file. The class has functions to return the content in either html or text for the command line. The difference being one has "&lt;br /&gt;" statements and the other has "\n" for new lines. The class also contains a function to search for a user, and a function to delete a user. <br /><br /><br />/**<br />&nbsp;* Class is used to read, search, and manipulate linux passwd file.<br />&nbsp;* <br />&nbsp;* @author&nbsp; Tully Rankin<br />&nbsp;* @website www.tullyrankin.com<br />&nbsp;*/<br />class ReadPasswd {<br />&nbsp;&nbsp;&nbsp; private $file;<br />&nbsp;&nbsp;&nbsp; private $fileData;<br />&nbsp;&nbsp;&nbsp; private $error;<br /><br />&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp; &nbsp;* Initialize the class and add contents of<br />&nbsp;&nbsp;&nbsp; &nbsp;* the password file into the variable file.<br />&nbsp;&nbsp;&nbsp; &nbsp;*/<br />&nbsp;&nbsp;&nbsp; function __construct($file) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try{<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (is_file($file)) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;fileData = file($file);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;file = $file;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; throw new Exception("Couldn't open file.");<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (Exception $e) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;error[] = $e-&gt;getMessage();<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp; &nbsp;* Returns string of all rows of data from the passwd file. <br />&nbsp;&nbsp;&nbsp; &nbsp;* Use this file if your trying to display in the browser.<br />&nbsp;&nbsp;&nbsp; &nbsp;* <br />&nbsp;&nbsp;&nbsp; &nbsp;* @type Public<br />&nbsp;&nbsp;&nbsp; &nbsp;* @return String<br />&nbsp;&nbsp;&nbsp; &nbsp;*/ <br />&nbsp;&nbsp;&nbsp; public function getAllHTML() {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach ($this-&gt;fileData as $content)<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $temp = explode(':', $content);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "&lt;b&gt;Username:&nbsp; {$temp[0]} &lt;/b&gt;&lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Validation: {$temp[1]} &lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "User Identifier: {$temp[2]} &lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Group Identifier: {$temp[3]} &lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Gecos Field: {$temp[4]} &lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Home Directory: {$temp[5]} &lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Shell: {$temp[6]} &lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "&lt;br /&gt;";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $output;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp; &nbsp;* Returns string of all rows of data from the passwd file. This is<br />&nbsp;&nbsp;&nbsp; &nbsp;* used if running the command from the command line.<br />&nbsp;&nbsp;&nbsp; &nbsp;* <br />&nbsp;&nbsp;&nbsp; &nbsp;* @type Public<br />&nbsp;&nbsp;&nbsp; &nbsp;* @return String<br />&nbsp;&nbsp;&nbsp; &nbsp;*/ <br />&nbsp;&nbsp;&nbsp; public function getAllCLI() {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach ($this-&gt;fileData as $content)<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $temp = explode(':', $content);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Username: {$temp[0]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Validation: {$temp[1]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "User Identifier: {$temp[2]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Group Identifier: {$temp[3]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Gecos Field: {$temp[4]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Home Directory: {$temp[5]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "Shell: {$temp[6]} \n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $output .= "\n";<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $output;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp; &nbsp;* Searches for a user. Will return an array with<br />&nbsp;&nbsp;&nbsp; &nbsp;* the users credentials unless the second param is set.<br />&nbsp;&nbsp;&nbsp; &nbsp;* If true is set on the second parameter then the function<br />&nbsp;&nbsp;&nbsp; &nbsp;* will withold add the the user information to the returned array.<br />&nbsp;&nbsp;&nbsp; &nbsp;* <br />&nbsp;&nbsp;&nbsp; &nbsp;* @type Public<br />&nbsp;&nbsp;&nbsp; &nbsp;* @params String, Boolean<br />&nbsp;&nbsp;&nbsp; &nbsp;* @return Array<br />&nbsp;&nbsp;&nbsp; &nbsp;*/<br />&nbsp;&nbsp;&nbsp; public function searchUser($user,$data=0) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try{<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data = array();<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (is_string($user)) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach($this-&gt;fileData as $line)<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $temp = explode(':', $line);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (in_array($user,$temp))<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($data) return 1;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['username'] = $temp[0];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['validation'] = $temp[1];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['user_identifier'] = $temp[2];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['group_identifier'] = $temp[3];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['gecos'] = $temp[4];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['home_directory'] = $temp[5];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $data['shell'] = $temp[6];<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; throw new Exception('A search error has occured.');<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (Exception $e) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $this-&gt;error[] = $e-&gt;getMessage();<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; return $data;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp; &nbsp;* Getter for Error Exception Array<br />&nbsp;&nbsp;&nbsp; &nbsp;* @type Public<br />&nbsp;&nbsp;&nbsp; &nbsp;* @return Array<br />&nbsp;&nbsp;&nbsp; &nbsp;*/<br />&nbsp;&nbsp;&nbsp; public function getError() {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $this-&gt;error;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; /*<br />&nbsp;&nbsp;&nbsp; &nbsp;* Removes user from passwd file<br />&nbsp;&nbsp;&nbsp; &nbsp;* @type public<br />&nbsp;&nbsp;&nbsp; &nbsp;* @return Boolean<br />&nbsp;&nbsp;&nbsp; &nbsp;*/<br />&nbsp;&nbsp;&nbsp; public function deleteUser($user) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; try{<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ($this-&gt;searchUser($user,1))<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach ($this-&gt;fileData as $line) <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $lines = explode(":",$line);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!in_array($user,$lines))<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $final .= $line;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(!file_put_contents($this-&gt;file,$final))<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; throw new Exception("Could not delete user.");<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; throw new Exception("User doesn't exist.");<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } catch (Exception $e) {<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echo $this-&gt;error[] = $e-&gt;getMessage();<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp; <br />}<br /><br /><p><br /></p>
]]>
        

    </content>
</entry>

<entry>
    <title>Simple AJAX Example</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/simple-ajax-example.html" />
    <id>tag:www.tullyrankin.com,2010://3.108</id>

    <published>2010-01-31T22:30:59Z</published>
    <updated>2010-01-31T23:17:40Z</updated>

    <summary>I started re-writing a lot of my old code today to use AJAX. AJAX stands for (Asynchronous Javascript and XML) and is a way of making your web applications more interactive. So for example, you can refresh results on the...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="ajaxphpmysqljavascript" label="ajax php mysql javascript" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>I started re-writing a lot of my old code today to use AJAX. AJAX
stands for (Asynchronous Javascript and XML) and is a way of making
your web applications more interactive. So for example, you can refresh
results on the page from a form without having to reload the page. The
example that I'm going to show you is a name suggestion form. It will
display a html form input and will return results from a mysql database
that start with whatever char/chars you type in real time.<br />
<br />
The form page looks like the following...<br />
<br />
<code><span style="color: #000000">
&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;Simple&nbsp;Ajax&nbsp;Example&lt;/title&gt;<br />&lt;script&nbsp;type="text/javascript"&gt;<br />var&nbsp;xmlhttp;<br /><br />function&nbsp;showUser(str)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;xmlhttp=GetXmlHttpObject();<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(xmlhttp==null)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert&nbsp;("Browser&nbsp;does&nbsp;not&nbsp;support&nbsp;HTTP&nbsp;Request");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;url="getNames.php";<br />&nbsp;&nbsp;&nbsp;&nbsp;url=url+"?name="+str.value;<br />&nbsp;&nbsp;&nbsp;&nbsp;url=url+"&amp;nocache="+Math.random();<br />&nbsp;&nbsp;&nbsp;&nbsp;xmlhttp.onreadystatechange=stateChanged;<br />&nbsp;&nbsp;&nbsp;&nbsp;xmlhttp.open("GET",url,true);<br />&nbsp;&nbsp;&nbsp;&nbsp;xmlhttp.send(null);<br />}<br /><br />function&nbsp;stateChanged()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(xmlhttp.readyState==4)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById("nameHint").innerHTML=xmlhttp.responseText;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />function&nbsp;GetXmlHttpObject()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(window.XMLHttpRequest)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;code&nbsp;for&nbsp;IE7+,&nbsp;Firefox,&nbsp;Chrome,&nbsp;Opera,&nbsp;Safari<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;new&nbsp;XMLHttpRequest();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(window.ActiveXObject)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;code&nbsp;for&nbsp;IE6,&nbsp;IE5<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;new&nbsp;ActiveXObject("Microsoft.XMLHTTP");<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />return&nbsp;null;<br />}<br />&lt;/script&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br /><br />&lt;form&nbsp;name="formName"&nbsp;id="formName"&gt;<br />&lt;input&nbsp;type="text"&nbsp;name="name"&nbsp;id="name"&nbsp;onKeyUp="showUser(this)"&gt;<br />&lt;/form&gt;<br /><br />&lt;span&nbsp;id="nameHint"&nbsp;name="nameHint"&gt;&lt;/span&gt;<br /><br /><br />&lt;/body&gt;<br />&lt;/html&gt;</span>
</code>
<br />
<br />
The form calls getNames.php with the params name=[Input Field Value].
The Input field value is the value of whatever you type into the form
text input. The code that processes this request is below:<br />
<br />
<br />
<br /></p>

<p><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strip<em>tags</span><span style="color: #007700">(</span><span style="color: #0000BB">$</em>GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">]);<br /><br />if&nbsp;(!empty(</span><span style="color: #0000BB">$name</span><span style="color: #007700">))&nbsp;<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$con&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql<em>connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'127.0.0.1'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'root'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'1234'</span><span style="color: #007700">))<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">mysql</em>select<em>db</span><span style="color: #007700">(</span><span style="color: #DD0000">'test'</span><span style="color: #007700">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Could&nbsp;not&nbsp;connect&nbsp;to&nbsp;database'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$sql&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;name&nbsp;FROM&nbsp;names&nbsp;WHERE&nbsp;name&nbsp;like&nbsp;'%s'"</span><span style="color: #007700">,&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">mysql</em>real<em>escape</em>string</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">.</span><span style="color: #DD0000">'%'</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql<em>query</span><span style="color: #007700">(</span><span style="color: #0000BB">$sql</span><span style="color: #007700">,</span><span style="color: #0000BB">$con</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Bad&nbsp;Query'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$rowCount&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql</em>num<em>rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql</em>fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">))&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$names</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /><br />if&nbsp;(</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$names</span><span style="color: #007700">)&nbsp;&gt;&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;ul&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(</span><span style="color: #0000BB">$names&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;li&gt;$name&lt;/li&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;/ul&gt;'</span><span style="color: #007700">;<br />}</span>
</span>
</code></p>

<p><br />
<br />
As you can see, the getNames.php file first looks at the GET value for the name Parameter. I also have it wrapped in the strip<em>tags function
which will eliminate the chance of a user entering any kind of tags
that may end up breaking or altering the script. Next, I check to see
if the $name value is empty. The script will not display anything if the $name value is empty or there is no results. Now the script can connect to a mysql server and select the correct DB. Now I write
the query using the sprintf function. This allows me to alter multiple
variables in the string. I use the %s for string and have
mysql</em>real<em>escape</em>string function return the $name variable. The
mysql<em>real</em>escape_string prepends backslashes to the following
characters "\x00, \n, \r, \, ', " and \x1a". <br />
<br />
I now query the database with the $sql string that I just created. I
create the variable rowCount which will return the # of rows returned
from the query. Next we loop through the results and add each name to
the $names variable. <br />
<br />
We now have all the results in an array and need to display the result. I first check to see if the array is not empty. I do this by using the count() function on the $names array. If the count is greater then 0 we will display each of the rows returned in a unordered list &lt;ul&gt; tag.<br /><br />This is by far the simplest AJAX example. We could have returned the results as JSON and looped through them better in the index.php page. I will write a more technical and more advanced example in the near future. <br /></p>
]]>
        

    </content>
</entry>

<entry>
    <title>Parse Apache Config for DocumentRoot in C</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/parse-apache-config-for-documentroot-in-c.html" />
    <id>tag:www.tullyrankin.com,2009://3.107</id>

    <published>2009-12-22T10:05:25Z</published>
    <updated>2009-12-22T10:14:07Z</updated>

    <summary>So I am now on my second week of learning the C language. I have been writing a lot of small programs just to get the hang of the code. I have written simple calculators, guess my number games, and...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="capacheparse" label="c apache parse" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>So I am now on my second week of learning the C language. I have been writing a lot of small programs just to get the hang of the code. I have written simple calculators, guess my number games, and simple quizzes. Tonight I was working on code that could parse a apache config and only display the DocumentRoot. The code I wrote to do this is shown below.<br /><br /><br /> </p>

<p><code><span style="color: #000000"></p>

<h1>include&nbsp;&lt;stdlib.h&gt;<br />#include&nbsp;&lt;string.h&gt;<br />#define&nbsp;MAXLINE&nbsp;128<br /><br />FILE&nbsp;<em>file;<br /><br />int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;</em>argv[])<br />{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;i,x;<br />&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;line[MAXLINE];<br />&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;<em>&nbsp;temp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(argc&nbsp;==&nbsp;1)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts("You&nbsp;must&nbsp;enter&nbsp;a&nbsp;file/files&nbsp;to&nbsp;search.");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(1);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(i=1;&nbsp;i&lt;argc;i++)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file&nbsp;=&nbsp;fopen(argv[i],&nbsp;"r");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(file&nbsp;==&nbsp;NULL)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts("Could'nt&nbsp;open&nbsp;file");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(1);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(&nbsp;(fgets(line,&nbsp;MAXLINE,&nbsp;file))&nbsp;!=&nbsp;NULL)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp&nbsp;=&nbsp;malloc(sizeof&nbsp;(char)&nbsp;</em>&nbsp;128);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(i=0;&nbsp;i&lt;MAXLINE;&nbsp;i++)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp[i]&nbsp;=&nbsp;line[i];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;while&nbsp;(line[i]&nbsp;!=&nbsp;'\n');<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;temp[i]&nbsp;=&nbsp;'\0';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(strstr(temp,&nbsp;"DocumentRoot")&nbsp;!=&nbsp;NULL)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%s\n",&nbsp;temp);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free(temp);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span></h1>
]]>
        

    </content>
</entry>

<entry>
    <title>Youtube URL to Embed Code</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/youtube-url-to-embed-code.html" />
    <id>tag:www.tullyrankin.com,2009://3.106</id>

    <published>2009-12-07T08:18:46Z</published>
    <updated>2009-12-07T08:33:28Z</updated>

    <summary>Working on a new site and wanted to add a function to add embed code from YouTube. I am limiting the amount of html that is allowed to be posted by the users. I also wanted to make sure the...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="youtubeconvertembed" label="youtube convert embed" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>Working on a new site and wanted to add a function to add embed code from YouTube. I am limiting the amount of html that is allowed to be posted by the users. I also wanted to make sure the user could only embed a video from YouTube. The function I'm working on takes the URL of the YouTube page and parses the source for the embed code. Below is an example on how I am getting the data. The actual function does a lot more filtering of the URL string.<br /><br /><br /><br /><br /> <code><span style="color: #000000">
&lt;p&gt;<br />&lt;form&nbsp;action="#"&nbsp;method="get"&gt;<br />&lt;input&nbsp;type="text"&nbsp;name="url"&nbsp;value="YOUTUBE&nbsp;URL"&gt;<br />&lt;input&nbsp;type="submit"&nbsp;name="submit"&nbsp;value="Get&nbsp;Embed&nbsp;Code"&gt;<br />&lt;/form&gt;<br />&lt;/p&gt;<br /><br /><br /><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$<em>GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'url'</span><span style="color: #007700">]&nbsp;!=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">file</em>get<em>contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$</em>GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'url'</span><span style="color: #007700">]);<br />&nbsp;</span><span style="color: #0000BB">$url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg<em>match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/(input&nbsp;id="embed).*(\/&gt;)/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$arr</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">$url&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg</em>match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/(&amp;lt;).<em>(\/object&amp;gt;)/'</span><span style="color: #007700">,</span><span style="color: #0000BB">$arr</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br />&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">html_entity_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]);<br /><br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;b&gt;The&nbsp;Video...&lt;/b&gt;&lt;br&nbsp;/&gt;'</span><span style="color: #007700">;<br />&nbsp;echo&nbsp;</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'&lt;br&nbsp;/&gt;&lt;br&nbsp;/&gt;'</span><span style="color: #007700">;<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">'&lt;b&gt;The&nbsp;embed&nbsp;code...&lt;/b&gt;&lt;br&nbsp;/&gt;'</span><span style="color: #007700">;<br />&nbsp;echo&nbsp;</span><span style="color: #0000BB">htmlentities</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'&lt;br&nbsp;/&gt;&lt;br&nbsp;/&gt;'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;<br /></span><br />&lt;br&nbsp;/&gt;<br />&lt;b&gt;How&nbsp;to&nbsp;get&nbsp;the&nbsp;embed&nbsp;code&nbsp;from&nbsp;the&nbsp;linux&nbsp;Command&nbsp;line.&lt;/b&gt;<br />&lt;br&nbsp;/&gt;curl&nbsp;'http://www.youtube.com/watch?v=vFMh2oeob18'&nbsp;|&nbsp;egrep&nbsp;'((input&nbsp;id="embed).</em>/&gt;)'&nbsp;|&nbsp;egrep&nbsp;-o&nbsp;'(&amp;lt;).*(/object&amp;gt;)'<br /><br /></span>
</code></p>
]]>
        

    </content>
</entry>

<entry>
    <title>PHP Decorator Pattern</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/php-decorator-pattern.html" />
    <id>tag:www.tullyrankin.com,2009://3.105</id>

    <published>2009-12-02T08:56:19Z</published>
    <updated>2009-12-02T09:11:20Z</updated>

    <summary>I read &quot;PHP Objects, Patterns, and Practice, Second Edition&quot; a while back but nothing really kicked in. I have yet again started studying various design patterns. I have started reading &quot;Head First Design Patterns&quot; and feel this book is easier...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phpdecoratorpattern" label="php decorator pattern" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>I read "PHP Objects, Patterns, and Practice, Second Edition" a while back but nothing really kicked in. I have yet again started studying various design patterns. I have started reading "Head First Design Patterns" and feel this book is easier to understand. I also recently finished the "Head Fist SQL" book which was written very well. <br /><br />So today I have been studying the Decorator Pattern. Wiki defines it as follows: "In <a href="http://en.wikipedia.org/wiki/Object-oriented_programming" title="Object-oriented programming">object-oriented programming</a>, the <b>decorator pattern</b> is a <a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29" title="Design pattern (computer science)">design pattern</a> that allows new/additional behaviour to be added to an existing <a href="http://en.wikipedia.org/wiki/Object_%28computer_science%29" title="Object (computer science)">object</a> dynamically". Basically what it allows is for you to extend a class without being part of that "family". You create a Decorator class and then extend onto that class. Below is a simple example in PHP of the pattern<br /><br /><br /></p>

<p><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /><br /></span><span style="color: #FF8000">/<em><br />&nbsp;</em>&nbsp;Example&nbsp;of&nbsp;Decorator&nbsp;Pattern&nbsp;in&nbsp;PHP<br />&nbsp;<em><br /></em>/<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">ReadStr&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB"><strong>construct</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">display</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">StrDecorator&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">ReadStr&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;</span><span style="color: #0000BB">$readStr</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB"></strong>construct</span><span style="color: #007700">(</span><span style="color: #0000BB">ReadStr&nbsp;$readStr</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">readStr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$readStr</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">readStr</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">display</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">StrToUpperDecorator&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">StrDecorator&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000BB">$strDecorator</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB"><strong>construct</span><span style="color: #007700">(</span><span style="color: #0000BB">StrDecorator&nbsp;$strDecorator</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">strDecorator&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$strDecorator</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stringToUpper</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">stringToUpper</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">strDecorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtoupper</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">strDecorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">StrReverseDecorator&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">StrDecorator&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000BB">$strDecorator</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB"></strong>construct</span><span style="color: #007700">(</span><span style="color: #0000BB">StrDecorator&nbsp;$strDecorator</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">strDecorator&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$strDecorator</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stringReverse</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">stringReverse</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">strDecorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strrev</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">strDecorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">str</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$readStr&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReadStr</span><span style="color: #007700">(</span><span style="color: #DD0000">'Decorator&nbsp;Pattern!'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$decorator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">StrDecorator</span><span style="color: #007700">(</span><span style="color: #0000BB">$readStr</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$decorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$strToUpper&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">StrToUpperDecorator</span><span style="color: #007700">(</span><span style="color: #0000BB">$decorator</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$decorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$strReverse&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">StrReverseDecorator</span><span style="color: #007700">(</span><span style="color: #0000BB">$decorator</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$decorator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">display</span><span style="color: #007700">();<br /><br /></span>
</span>
</code></p>
]]>
        

    </content>
</entry>

<entry>
    <title>MYSQL LOAD_FILE SQL Injection</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/mysql-load-file-sql-injection.html" />
    <id>tag:www.tullyrankin.com,2009://3.104</id>

    <published>2009-07-31T04:17:40Z</published>
    <updated>2009-07-31T04:35:12Z</updated>

    <summary>So today I was reading up on some SQL injection techniques, and came across one that I had not seen before. I found out that it is possible to use a UNION SELECT with the built-in MYSQL LOADFILE function, to...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="sqlinjectionhexperl" label="sql injection hex perl" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>So today I was reading up on some SQL injection techniques, and came across one that I had not seen before. I found out that it is possible to use a UNION SELECT with the built-in MYSQL LOAD<em>FILE function, to read the contents of any file on the system. This only works if the user has been granted permission to use the LOAD</em>FILE function, and of course MYSQL DAEMON must have permission to read the file. Also, I found out that the LOAD<em>FILE function can read use with HEX decimal characters. <br /><br />Example Injection: www.example.com/article.php?id=1+union+select+LOAD</em>FILE(0x2f6574632f706173737764)<br /><br />This will return the contents of the /etc/passwd on a linux machine.<br /><br />I also came across a handy perl script today that will encode a given string into HEX. <br /><br />Perl HEX converter:<br /><br />
<br />
<b>Note: There is a underscore between LOAD and FILE.</b>
<br /><br />
<code><span style="color: #000000">
print&nbsp;"Enter&nbsp;string&nbsp;to&nbsp;encode:";<br />$str=&lt;STDIN&gt;;chomp&nbsp;$str;<br /><br />$enc&nbsp;=&nbsp;encode($str);&nbsp;print&nbsp;"Hex&nbsp;Encoded&nbsp;value:&nbsp;0x$enc\n";<br /><br /><br />sub&nbsp;encode{&nbsp;#Sub&nbsp;to&nbsp;encode<br />@subvar=@<em>;<br />my&nbsp;$sqlstr&nbsp;=$subvar[0];<br /><br />@ASCII&nbsp;=&nbsp;unpack("C*",&nbsp;$sqlstr);<br />foreach&nbsp;$line&nbsp;(@ASCII)&nbsp;{<br /><br />$encoded&nbsp;=&nbsp;sprintf('%lx',$line);<br />$encoded</em>command&nbsp;.=&nbsp;$encoded;<br /><br />}<br />return&nbsp;$encoded_command;<br /><br />}<br /></span></p>
]]>
        

    </content>
</entry>

<entry>
    <title>PHP Mail Script</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/php-mail-script.html" />
    <id>tag:www.tullyrankin.com,2009://3.103</id>

    <published>2009-07-30T03:22:52Z</published>
    <updated>2009-07-30T03:56:49Z</updated>

    <summary>Today I wrote a command line PHP mail script. You are able to do this manually with programs such as Netcat or Telnet, but this just makes it easier and quicker. Once you run the script from the command line...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phpmailcommandline" label="php mail command line" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>Today I wrote a command line PHP mail script. You are able to do this manually with programs such as Netcat or Telnet, but this just makes it easier and quicker. Once you run the script from the command line it will ask you for the host, recipient, email to mail from, subject, and message. This can be used quickly to test out a mail server. <br /><br /><br /></p>

<p><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$argc&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;script&nbsp;does&nbsp;not&nbsp;take&nbsp;any&nbsp;arguments.\n"</span><span style="color: #007700">;<br />&nbsp;exit;<br />}<br />function&nbsp;</span><span style="color: #0000BB">read&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$length</span><span style="color: #007700">=</span><span style="color: #DD0000">'255'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;if&nbsp;(!isset&nbsp;(</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'StdinPointer'</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'StdinPointer'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">fopen&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">"php://stdin"</span><span style="color: #007700">,</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br />&nbsp;}<br />&nbsp;</span><span style="color: #0000BB">$line&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fgets&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$GLOBALS</span><span style="color: #007700">[</span><span style="color: #DD0000">'StdinPointer'</span><span style="color: #007700">],</span><span style="color: #0000BB">$length</span><span style="color: #007700">);<br />&nbsp;return&nbsp;</span><span style="color: #0000BB">trim&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$line</span><span style="color: #007700">);<br />}&nbsp;<br />echo&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Enter&nbsp;Mail&nbsp;Server&nbsp;IP&nbsp;Address:&nbsp;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$host&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">read</span><span style="color: #007700">(</span><span style="color: #0000BB">30</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"RCPT:&nbsp;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$rcpt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">read</span><span style="color: #007700">(</span><span style="color: #0000BB">40</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Mail&nbsp;From:&nbsp;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$from&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">read</span><span style="color: #007700">(</span><span style="color: #0000BB">40</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Subject:&nbsp;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$subject&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">read</span><span style="color: #007700">(</span><span style="color: #0000BB">25</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Message:&nbsp;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$message&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">read</span><span style="color: #007700">(</span><span style="color: #0000BB">500</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />if&nbsp;(&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">)&nbsp;&nbsp;||&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$rcpt</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">)&nbsp;||&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$from</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">)&nbsp;||&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$subject</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">)&nbsp;||&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</span><span style="color: #0000BB">strlen</span><span style="color: #007700">(</span><span style="color: #0000BB">$message</span><span style="color: #007700">)&nbsp;&lt;&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">)&nbsp;)&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"You&nbsp;need&nbsp;to&nbsp;enter&nbsp;all&nbsp;fields&nbsp;properly.\n"</span><span style="color: #007700">;<br />&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fsockopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">,</span><span style="color: #0000BB">25</span><span style="color: #007700">,</span><span style="color: #0000BB">$errstr</span><span style="color: #007700">,</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$fp</span><span style="color: #007700">)&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"$errstr&nbsp;($errno)"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"helo&nbsp;h4x0r\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"mail&nbsp;from:$from\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"rcpt&nbsp;to:$rcpt\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"data\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"Subject:$subject\r\n\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"$message\r\n.\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$out</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />}&nbsp;<br /></span><span style="color: #0000BB">?&gt;<br /></span>
</span></p>
]]>
        

    </content>
</entry>

<entry>
    <title>PHP HTTP Script</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/php-http-script.html" />
    <id>tag:www.tullyrankin.com,2009://3.102</id>

    <published>2009-07-29T03:30:25Z</published>
    <updated>2009-07-30T03:44:06Z</updated>

    <summary>This is a simple script I wrote to do GET/OPTIONS/HEAD requests to a website. It&apos;s a command line PHP script which uses fsockopen to connect to the server. This comes in handy when you need to see headers received from...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phphttpheaderscript" label="PHP http header script" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>This is a simple script I wrote to do GET/OPTIONS/HEAD requests to a website. It's a command line PHP script which uses fsockopen to connect to the server. This comes in handy when you need to see headers received from a website. Also, it's good to see what is returned by the OPTIONS directive. <br /><br /><br /> </p>

<p><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$argc&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">)&nbsp;{<br />echo&nbsp;</span><span style="color: #DD0000">"<br />---------------------------------------------------\n<br />HTTP&nbsp;Check&nbsp;Headers&nbsp;Script&nbsp;(Written&nbsp;by&nbsp;Tully&nbsp;Rankin)\n<br />Usage:&nbsp;headers.php&nbsp;[site]&nbsp;[get|head|options]&nbsp;file\n<br />Example:&nbsp;headers.php&nbsp;www.example.com&nbsp;get&nbsp;/\n<br />---------------------------------------------------<br />"</span><span style="color: #007700">;<br />&nbsp;exit;<br />}&nbsp;else&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$site&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$argv</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">];<br />}<br /><br /></span><span style="color: #0000BB">$request&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtolower</span><span style="color: #007700">(</span><span style="color: #0000BB">$argv</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$argv</span><span style="color: #007700">[</span><span style="color: #0000BB">3</span><span style="color: #007700">];<br /><br />if&nbsp;(</span><span style="color: #0000BB">$request&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"get"</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"GET&nbsp;$file&nbsp;HTTP/1.1\r\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"Host:&nbsp;$site\r\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=</span><span style="color: #DD0000">"Connection:&nbsp;Close\r\n\r\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;if&nbsp;(</span><span style="color: #0000BB">$request&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"options"</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"OPTIONS&nbsp;$file&nbsp;HTTP/1.1\r\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"Host:&nbsp;$site\r\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=</span><span style="color: #DD0000">"Connection:&nbsp;Close\r\n\r\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;if&nbsp;(</span><span style="color: #0000BB">$request&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"head"</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"HEAD&nbsp;$file&nbsp;HTTP/1.1\r\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"Host:&nbsp;$site\r\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=</span><span style="color: #DD0000">"Connection:&nbsp;Close\r\n\r\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Incorrect&nbsp;Request&nbsp;Type\n"</span><span style="color: #007700">;<br />&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fsockopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$site</span><span style="color: #007700">,</span><span style="color: #0000BB">80</span><span style="color: #007700">,</span><span style="color: #0000BB">$errstr</span><span style="color: #007700">,</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$fp</span><span style="color: #007700">)&nbsp;{<br />&nbsp;echo&nbsp;</span><span style="color: #DD0000">"$errstr&nbsp;($errno)"</span><span style="color: #007700">;<br />&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$out</span><span style="color: #007700">);<br />&nbsp;&nbsp;while&nbsp;(!</span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">fgets</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1024</span><span style="color: #007700">);<br />&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />&nbsp;}<br />&nbsp;<br />&nbsp;</span><span style="color: #0000BB">?&gt;<br /></span>
</span></p>
]]>
        

    </content>
</entry>

<entry>
    <title>PHP Site Scanner</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/php-site-scanner.html" />
    <id>tag:www.tullyrankin.com,2009://3.101</id>

    <published>2009-07-28T04:55:55Z</published>
    <updated>2009-07-30T03:45:27Z</updated>

    <summary>This is a script I wrote to go through a list of URLS and return the Server Response code. This can be used to look for site vulnerabilities such as hidden directories. This example only has a few pages in...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phpvulnerabilityscanner" label="php vulnerability scanner" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p>This is a script I wrote to go through a list of URLS and return the Server Response code. This can be used to look for site vulnerabilities such as hidden directories. This example only has a few pages in the array. If you have a big list of common directories, the best way would be to have the script load those directories line by line from the file. Also, if you were looking for a particular response code you could either pipe the output to grep, or add the response code after the "HTTP/1.1" in the strstr function.<br /><br /></p>

<p><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$host&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"www.google.com"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">80</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$pages&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"/cgi-bin"</span><span style="color: #007700">,</span><span style="color: #DD0000">"/admin"</span><span style="color: #007700">,</span><span style="color: #DD0000">"/test"</span><span style="color: #007700">,</span><span style="color: #DD0000">"/beta"</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$pages&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$page</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fsockopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">,</span><span style="color: #0000BB">$port</span><span style="color: #007700">,</span><span style="color: #0000BB">$errno</span><span style="color: #007700">,</span><span style="color: #0000BB">$errstr</span><span style="color: #007700">,</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br />&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$fp</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"$errstr&nbsp;($errno)"</span><span style="color: #007700">;<br />&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"GET&nbsp;$page&nbsp;HTTP/1.1\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"Host:&nbsp;$host\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">$out&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">"Connection:&nbsp;Close\r\n\r\n"</span><span style="color: #007700">;<br />&nbsp;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,</span><span style="color: #0000BB">$out</span><span style="color: #007700">);<br />&nbsp;while&nbsp;(!</span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fread</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20</span><span style="color: #007700">);<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">strstr</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">,</span><span style="color: #DD0000">'HTTP/1.1'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&nbsp;Site:&nbsp;$host&nbsp;\n&nbsp;Page:&nbsp;$page&nbsp;\n&nbsp;Code:&nbsp;$data&nbsp;\n\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}&nbsp;<br />&nbsp;}&nbsp;<br />&nbsp;unset(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />&nbsp;unset(</span><span style="color: #0000BB">$out</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">?&gt;<br /></span></p>
]]>
        

    </content>
</entry>

<entry>
    <title>HTTP Protocol</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/http-protocol.html" />
    <id>tag:www.tullyrankin.com,2009://3.100</id>

    <published>2009-07-22T04:42:13Z</published>
    <updated>2009-07-22T04:43:48Z</updated>

    <summary><![CDATA[HTTP Requests All HTTP messages (requests and responses) consist of one or more headers, each on a separate line, followed by a mandatory blank line, followed by an optional message body. &nbsp; The first line of every HTTP request consists...]]></summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="httpprotocolsecurity" label="http protocol security" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p class="MsoNormal"><b style="">HTTP Requests<o:p></o:p></b></p>

<p class="MsoNormal">All HTTP messages (requests and responses) consist of one or
more headers, each on a separate line, followed by a mandatory blank line,
followed by an optional message body.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><u>The first line of every HTTP request consists of three
items, separated by spaces:<o:p></o:p></u></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">A very
     indicated the HTTP method. The most commonly used method is GET, whose
     function is to retrieve a resource from the web server. GET requests do
     not have a message body, so there is no further data following the blank
     line after the message headers.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">The
     requested URL. The URL functions as a name for the resource being
     requested, together with an optional query string containing parameters
     that the client is passing to that resource. </li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">The
     HTTP version being used. The only HTTP versions in common use on the
     Internet are 1.0 and 1.1, and most browsers use version 1.1 by default.
     There are a few differences between the specifications of these two
     versions; however, the only difference you are likely to encounter when
     attacking web applications is that in version 1.1 the host request header
     is mandatory.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">HTTP Responses<o:p></o:p></b></p>

<p class="MsoNormal">The first line of every HTTP response consists of three
items, separated by spaces:</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">The
     HTTP version being used.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">A
     numeric status code indicating the result of the request. 200 is the most
     common status code; it means that the request was successful and the
     requested resource is being treturned.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">A
     textual "reason phrase" further describing the status of the response.
     This can have any value and is not used for any purpose by current
     browsers.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">HTTP Methods<o:p></o:p></b></p>

<p class="MsoNormal">The two main methods are GET and POST. There are others such
as the following:</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">HEAD -
     This functions in the same way as a GET request except that the server
     should not return a message body in its response. The server should return
     the same headers that it would have returned to the corresponding GET
     request. Hence, this method can be used for checking whether a resource is
     present before making a GET request for it.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">TRACE
     - This method is designed for diagnostic purposes. The server should
     return in the response body the exact contents of the request message that
     it received. This can be used to detect the effect of any proxy servers
     between the client and server that may manipulate the request. It can also
     sometimes be used as part of an attack against other applications users.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">OPTIONS
     - This method asks the server to report the HTTP methods that are
     available for a particular resource. The server will typically return a
     response containing an Allow header that lists the available methods.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">PUT -
     This method attempts to upload the specified resource to the server, using
     the content contained in the body of the request. If this method is
     enabled, then you may be able to leverage it to attack the application;
     for example, by uploading an arbitrary script and executing this on the
     server.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">[NOTE] </p>

<p class="MsoNormal">The correct technical term for a URL is actually URI (or
uniform resource identifier), but his term is really only used in formal
specifications.)</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">HTTP Headers<o:p></o:p></b></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style=""><i style="">General Headers<o:p></o:p></i></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Connection
     - This is used to inform the other end of the communication whether it
     should close the TCP connection after the HTTP transation has completed or
     keep it open for further messages.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Content
     Encoding - This is used to specify what kind of encoding is being used for
     the content contained in the message body, such as gzip, which is used by
     some applications to compress responses for faster transmission.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Content-Length
     - This is used to specify the length of the message body, in bytes (except
     in the case of responses to HEAD requests, when it indicates the length of
     the body in the response to the corresponding GET request).</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Content-Type
     - This is used to specify the type of content contained in the message
     body; for example, text/html for HTML documents.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Transfer-Encoding
     - This is used to specify any encoding that was performed on the message
     body to facilitate its transfer over HTTP. It is normally used to specify
     chunked encoding when this is employed.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style=""><i style="">Request Headers<o:p></o:p></i></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Accept
     - This is used to tell the server what kinds of content the client is
     willing to accept, such as image types, office document formats, and so
     on.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Accept-Encoding
     - This is used to tell the server what kinds of content encoding the
     client is willing to accept.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Authorization
     - This is used to submit credentials to the server for one of the built-in
     HTTP authentication types.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Cookie
     - This is used to submit cookies to the server which were previously
     issued by it.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Host -
     This is used to specify the hostname that appeared in the full URL being
     requested.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">If-Modified-Since
     - This is used to specify the time at which the browser last received the
     requested resource. If the resource has not changed since that time, the
     server may instruct the client to use its cached copy, using a response
     with status code 304.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">If-None-Match
     - This is used to specify an entity tag, which is an identifier denoting
     the contents of the message body. The browser submits the entity tag that
     the server issued with the requested resource when it was last received.
     The server can use the entity tag to determine whether the browser may use
     its cached copy of the resource. </li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Referer
     - This is used to specify the URL from which the current request
     originated.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">User-Agent
     - This is used to provide information about the browser or other client
     software that generated the request.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style=""><i style="">Response Headers<o:p></o:p></i></b></p>

<p class="MsoNormal"><b style=""><i style=""><o:p>&nbsp;</o:p></i></b></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Cache-Control
     - This is used to pass caching directives to the browser (for example,
     no-cache)</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">ETag -
     This is used to specify an entity tag. Clients can submit this identifier
     in future requests for the same resource in the If-None-Match header to
     notify the server which version of the resource the browser currently
     holds in its cache.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Expires
     - This is used to instruct the browser how long the contents of the message
     body are valid for. The browser may use the cached copy of this resource
     until this time.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Location
     - This is used in redirection responses (those with a status code starting
     with a 3) to specify the target of the redirect.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Pragma
     - This is used to pass caching directive to the browser (for example, no
     cache).</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Server
     - This is used to provide information about the web server software being
     used.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Set-Cookie
     - This is used to issue cookies to the browser that it will submit back to
     the server in subsequent requests.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">WWW-Authenticate
     - This is used in responses with a 401 status code to provide details of
     the type(s) of authentication supported by the server.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Cookies<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">The
     cookie mechanism enabled the server to send items of data to the client,
     which the client stores and resubmits back to the server.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Expires
     - Used to set a date until which the cookie is valid. This will cause the
     browser to save the cookie to persistent storage, and it will be reused in
     subsequent browser sessions until the expiration date is reached. If this
     attribute is not set, the cookie is used only in the current browser
     session.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Domain
     - Used to specify the domain for which the cookie is valid. This must be
     the same or a parent of the domain from which the cookie is received.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Path -
     Used to specify the URL path for which the cookie is valid.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Secure
     - If this attribute is set, the the cookie will only ever be submitted in
     the HTTPS requests.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">HttpOnly
     - If this attribute is set, then the cookie cannot be directly accessed
     via client-side JavaScript, although not all browsers support this
     restriction.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Status Codes <o:p></o:p></b></p>

<p class="MsoNormal">Each HTTP response message must contain a status code in its
first line, indicating the result of the request. The status codes fall into
five groups, accoding to the first digit of the code.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">1xx - Informational.</p>

<p class="MsoNormal">2xx - The request was successful.</p>

<p class="MsoNormal">3xx - The client is redirected to a different resource.</p>

<p class="MsoNormal">4xx - The request contains an error of some kind.</p>

<p class="MsoNormal">5xx - The server encountered an error fulfilling the
request.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">Some of the common Status Codes you will encounter when
trying to hack a web application are as follows:</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">100 Continue - This response is sent in some circumstances
when a client submits a request containing a body. The response indicates that
the request headers were received and that the client should continue sending
the body. The server will then return a second response when the request has
been completed.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">200 Ok - This indicates that the request was successful and
the response body contains the result of the request.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">201 Created - This is returned in response to a PUT request
to indicate that the request was successful.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">301 Moved Permanently - This redirects the browser
permanently to a different URL, which is specified in the Location header. The
client should use the new URL in the future rather than the original.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">302 Found - This redirects the browser temporarily to a
different URL, which is specified in the Location header. The client should
revert to the original URL in subsequent requests.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">304 Not Modified - This instructs the browser to use its
cached copy of the requested resource. The server uses the If-Modified-Since
and If-None-Match request headers to determine whether the client has the
latest version of the resource.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">400 Bad Request - This indicates that the client submitted
an invalid HTTP request. You will probably encounter this when you have
modified a request in certain invalid ways, for example by placing a space
character into the URL.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">401 Unauthorized - The server requires HTTP authentication
before the request will be granted. The WWW-Authenticate header contains
details of the type(s) of authentication supported.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">403 Forbidden - This indicates that no one is allowed to
access the requested resource, regardless of authentication. </p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">404 Not Found - This indicates that the requested resource
does not exist.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">405 Method Not Allowed - This indicates that the method used
in the request is not supported for the specified URL. For example, you may
receive this status code if you attempt to use the PUT method where it is not
supported.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">413 Request Entity Too Large - If you are probing for buffer
overflow vulnerabilities in native code, and so submitting long strings of
data, this indicates that the body of your request is too large for the server
to handle.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">414 Request URI Too Long - Similar to the previous response,
this indicates that the URL used in the request is too large for the server to
handle.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">500 Internal Server Error - This indicates that the server
encountered an error fulfilling the request. This normally occurs when you have
submitted unexpected input that caused an unhandled error somewhere within the
application's processing. You should review the full contents of the server's
response closely for any details indicating the nature of the error.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">503 Service Unavailable - This normally indicates that,
although the web server itself Is functioning and able to respond to requests,
the application accessed via the server is not responding. You should verify
whether this is the result of any action that you have performed.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">[NOTE]</p>

<p class="MsoNormal">SSL has now strictly been superseded by transport layer
security (TLS), but the latter is still normally referred to using the older
name.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">HTTP Authentication<o:p></o:p></b></p>

<p class="MsoNormal">The HTTP protocol includes its own mechanisms for
authenticating users, using various authentication schemes, including:</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Basic</b> - This is a
very simple authentication mechanism that sends user credentials as a<span style="">&nbsp; </span>Base64-encoded string in a request header
with each message.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">NTLM </b>- This is a
challenge-response mechanism and uses a version of the Windows NTLM protocol.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Digest </b>- This is
a challenge-response mechanism and uses MD5 checksums of a nonce with the
user's credentials.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
]]>
        

    </content>
</entry>

<entry>
    <title>PHP string functions and regular expressions</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/php-string-functions-and-regular-expressions.html" />
    <id>tag:www.tullyrankin.com,2009://3.98</id>

    <published>2009-07-02T03:33:19Z</published>
    <updated>2009-07-02T03:41:38Z</updated>

    <summary><![CDATA[PHP String Functions &amp; Regular Expressions &nbsp; String Functions &nbsp; Function What it does Example Concatenation Add's strings together. $x . $t &nbsp;&nbsp;&nbsp;&nbsp; Addslashes($str) Returns a string with backslashes before characters that need to be quoted in database queries etc....]]></summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="phpfunctionsstringregularexpressions" label="php functions string regular expressions" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="font-size: 20pt;">PHP String Functions &amp; Regular
Expressions<o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><span style="font-size: 20pt;"><o:p>&nbsp;</o:p></span></b></p>

<p class="MsoNormal"><b style="">String Functions<o:p></o:p></b></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<table class="MsoTableGrid" style="border: medium none ; margin-left: 23.4pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0" width="504" height="875">
 <tbody><tr style="height: 16.8pt;">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 124.8pt; height: 16.8pt;" valign="top" width="166">
  <p class="MsoNormal"><b style="">Function<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 16.8pt;" valign="top" width="192">
  <p class="MsoNormal"><b style="">What it does<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 16.8pt;" valign="top" width="145">
  <p class="MsoNormal"><b style="">Example<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="height: 17.75pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 17.75pt;" valign="top" width="166">
  <p class="MsoNormal">Concatenation</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 17.75pt;" valign="top" width="192">
  <p class="MsoNormal">Add's strings together. </p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 17.75pt;" valign="top" width="145">
  <p class="MsoNormal">$x . $t</p>
  </td>
 </tr>
 <tr style="height: 154.05pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 154.05pt;" valign="top" width="166">
  <p class="MsoNormal" style="text-indent: -0.2in;">&nbsp;&nbsp;&nbsp;&nbsp; Addslashes($str)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 154.05pt;" valign="top" width="192">
  <p class="MsoNormal">Returns a string with backslashes before characters that
  need to be quoted in database queries etc. These characters are single quote
  (<i>'</i>), double quote (<i>"</i>), backslash (<i>\</i>) and NUL (the <tt><b><span style="font-size: 10pt;">NULL</span></b></tt> byte).</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 154.05pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>addslashes</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$str</span></tt> )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="height: 51.35pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 51.35pt;" valign="top" width="166">
  <p class="MsoNormal">Rtrim($x)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 51.35pt;" valign="top" width="192">
  <p class="refpurpose"><span class="refname">rtrim</span> -- <span class="dc-title">Strip
  whitespace (or other characters) from the end of a string</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 51.35pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>rtrim</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$str</span></tt> [, <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$charlist</span></tt>
  ] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="height: 51.35pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 51.35pt;" valign="top" width="166">
  <p class="MsoNormal">Ltrim($x)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 51.35pt;" valign="top" width="192">
  <p class="parardfs-comment">Strip whitespace (or other characters) from the
  beginning of a string. <span class="refname"><o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 51.35pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>ltrim</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$str</span></tt> [, <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$charlist</span></tt>
  ] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="height: 35.5pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 35.5pt;" valign="top" width="166">
  <p class="MsoNormal">Strlen($x)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 35.5pt;" valign="top" width="192">
  <p class="parardfs-comment">Returns the length of the given <tt><i><span style="font-size: 10pt;">string</span></i></tt> . </p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 35.5pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>strlen</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt> )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="height: 35.5pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 35.5pt;" valign="top" width="166">
  <p class="refpurpose"><span class="refname">Strpos($str,$x)</span></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 35.5pt;" valign="top" width="192">
  <p class="refpurpose"><span class="dc-title">Find position of first occurrence of
  a string</span></p>
  <p class="parardfs-comment"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 35.5pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>strpos</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$haystack</span></tt> , <span class="type"><a href="http://us.php.net/manual/en/language.pseudo-types.php#language.types.mixed">mixed</a></span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$needle</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$offset</span></tt><span class="initializer">= 0</span>
  ] )</p>
  <p class="MsoNormal"><code><span style="font-size: 10pt; color: rgb(0, 0, 187);"><o:p>&nbsp;</o:p></span></code></p>
  </td>
 </tr>
 <tr style="height: 35.5pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 35.5pt;" valign="top" width="166">
  <p class="refpurpose"><span class="refname">Explode($d,$str)<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 35.5pt;" valign="top" width="192">
  <p class="refpurpose"><span class="refname">explode</span> -- <span class="dc-title">Split a string by string</span></p>
  <p class="refpurpose"><span class="dc-title"><o:p>&nbsp;</o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 35.5pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">array</span> <span class="methodname"><b>explode</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$delimiter</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$limit</span></tt> ] )</p>
  <p class="MsoNormal"><code><span style="font-size: 10pt; color: rgb(0, 0, 187);"><o:p>&nbsp;</o:p></span></code></p>
  </td>
 </tr>
 <tr style="height: 35.5pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 35.5pt;" valign="top" width="166">
  <p class="refpurpose"><span class="refname">implode($d,$str)<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 35.5pt;" valign="top" width="192">
  <p class="refpurpose"><span class="dc-title">Join array elements with a string.<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 35.5pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>implode</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$glue</span></tt> , <span class="type">array</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pieces</span></tt>
  )</p>
  <p class="MsoNormal"><code><span style="font-size: 10pt; color: rgb(0, 0, 187);"><o:p>&nbsp;</o:p></span></code></p>
  </td>
 </tr>
 <tr style="height: 35.5pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 35.5pt;" valign="top" width="166">
  <p class="refpurpose"><span class="refname">Soundex($str)<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 35.5pt;" valign="top" width="192">
  <p class="refpurpose"><span class="dc-title">Calculate the soundex key of a
  string.<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 35.5pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>soundex</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$str</span></tt> )<code><span style="font-family: &quot;Times New Roman&quot;;"><o:p></o:p></span></code></p>
  </td>
 </tr>
 <tr style="height: 35.5pt;">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 124.8pt; height: 35.5pt;" valign="top" width="166">
  <p class="refpurpose"><span class="refname">Metaphone($str)<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 144.1pt; height: 35.5pt;" valign="top" width="192">
  <p class="refpurpose"><span class="dc-title">Calculate the metaphone key of a
  string<o:p></o:p></span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 109.1pt; height: 35.5pt;" valign="top" width="145">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>metaphone</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$str</span></tt> [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$phones</span></tt><span class="initializer">= 0</span> ] )</p>
  <p class="MsoNormal"><code><span style="font-size: 10pt; color: rgb(0, 0, 187);"><o:p>&nbsp;</o:p></span></code></p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Regular Functions<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Function<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Description<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Example<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Ereg($p,$str,[$m])</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Regular expression match</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>ereg</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt>
  [, <span class="type">array</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">&amp;$regs</span></tt> ] )</p>
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>eregi</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt>
  [, <span class="type">array</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">&amp;$regs</span></tt> ] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Eregi($p,$str, [$m])</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Case insensitive regular expression
  match</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>eregi</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt>
  [, <span class="type">array</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">&amp;$regs</span></tt> ] )</p>
  <p class="MsoNormal"><span style="">&nbsp;</span></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Ereg_replace($p,$r,$str)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Replace regular expression</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>ereg_replace</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$replacement</span></tt>
  , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt> )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Sql_regcase($p)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Make regular expression for case
  insensitive match</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">string</span> <span class="methodname"><b>sql_regcase</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt> )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><st1:city w:st="on"><st1:place w:st="on">Split</st1:place></st1:city>($p,$str,[$limit])</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Split string into array by regular
  expression</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">array</span> <span class="methodname"><b>split</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$string</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$limit</span></tt> ] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Preg_match()</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Perform a regular expression match</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>preg_match</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$subject</span></tt>
  [, <span class="type">array</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">&amp;$matches</span></tt> [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$flags</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$offset</span></tt> ]]] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Preg_match_all()</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Perform a global regular expression
  match</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">int</span> <span class="methodname"><b>preg_match_all</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$subject</span></tt>
  , <span class="type">array</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">&amp;$matches</span></tt> [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$flags</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$offset</span></tt> ]] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Preg_replace()</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Perform a regular expression search
  and replace</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type"><a href="http://us.php.net/manual/en/language.pseudo-types.php#language.types.mixed">mixed</a></span>
  <span class="methodname"><b>preg_replace</b></span> ( <span class="type"><a href="http://us.php.net/manual/en/language.pseudo-types.php#language.types.mixed">mixed</a></span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt>
  , <span class="type"><a href="http://us.php.net/manual/en/language.pseudo-types.php#language.types.mixed">mixed</a></span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$replacement</span></tt>
  , <span class="type"><a href="http://us.php.net/manual/en/language.pseudo-types.php#language.types.mixed">mixed</a></span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$subject</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$limit</span></tt><span class="initializer">= -1</span>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">&amp;$count</span></tt> ]] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Preg_split()</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="dc-title">Split string by a regular expression</span></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><span class="type">array</span> <span class="methodname"><b>preg_split</b></span>
  ( <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$pattern</span></tt> , <span class="type">string</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$subject</span></tt>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$limit</span></tt><span class="initializer">= -1</span>
  [, <span class="type">int</span><span class="methodparam"> </span><tt><span style="font-size: 10pt;">$flags</span></tt><span class="initializer">= 0</span>
  ]] )</p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style="">MetaCharacters<o:p></o:p></b></p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">. <span style="">&nbsp;</span></p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Any <u>ONE</u> Character</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">[A-Z0-9] </p>
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Any one of the chars</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">[^a-cx-z]</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Not one of the chars</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">^</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Begins with</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">$</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">End with</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">X{2}</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">2 consecutive "x"</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">X{2,5}</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Between 2 and 5 consecutive "x"</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">X?</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">0 or 1 "x"</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">X+</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">1 or more "x"</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">\d</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Digit</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">\D</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Non-digit</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">\w</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Word</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">\W</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Non-word</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">\s</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Space char</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">\S</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Not a space char</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">(x|z)</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">X or Z</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
]]>
        

    </content>
</entry>

<entry>
    <title>Linux Boot Process</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/linux-boot-process.html" />
    <id>tag:www.tullyrankin.com,2009://3.97</id>

    <published>2009-05-23T02:54:15Z</published>
    <updated>2009-05-23T02:56:27Z</updated>

    <summary>Variable information about your system, such as the amount of RAM installed, the geometry of your hard drives, and the type of floppy disk installed, are stored in the CMOS chip. The BIOS uses the data in the CMOS chip...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="linuxbootprocess" label="linux boot process" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<p class="MsoNormal"><o:p></o:p>Variable information about your system, such as the amount
of RAM installed, the geometry of your hard drives, and the type of floppy disk
installed, are stored in the CMOS chip. The BIOS uses the data in the CMOS chip
to address these devices.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Bootloader Phase<o:p></o:p></b></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">The bootloader is software that the BIOS can load from the
MBR of the hard that will allow the CPU to access the disk and load the
operating system into RAM. The do this, the bootloader is configured with the
location of the operating system files on the hard disk drive.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">After loading the bootloader software into memory, the BIOS
turns control of the ystem over to the bootloader.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">With later Linux kernels, the bootloader may also create a
temporary, virtual file system in your system RAM called a ramdisk. This file
system is called initrd image.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">The term "initrd" stands for initial ramdisk.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">This image contains a basic file system that can be used to
complete a variety of startup taks. The reason the initrd iamge is used is
because Linux systems can use a wide variety of devices for the root (/) file
system.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Kernal Phase<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal">After the kernel loads, several key things happen, including
the following:</p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">The
     kernel initializes the basic hardware in your system using the various
     settings in your BIOS and your CMOS chips.</li><li class="MsoNormal" style="">The
     kernel searches for and uses the initrd file system to run the linuxrc
     program to set up the system.</li><li class="MsoNormal" style="">When
     linuxrc has finished executing, the initrd file system is dismounted and
     the ramdisk is destroyed.</li><li class="MsoNormal" style="">The
     kernel probes for new hardware and loads the appropriate driver modules.</li><li class="MsoNormal" style="">The
     real root (/) file is mounted.</li><li class="MsoNormal" style="">The
     kernel loads the init process.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Lilo Bootloader<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Most
     current Linux distributions use the GRUB bootloader instead of LILO by default.*</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">The bootloader configuration file for LILO is found in
/etc/lilo.conf</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">The following are options in the configuration file:</p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Section<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Option<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Description<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Global Options</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">menu -scheme</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Describes the colors used in the LILO boot menu. The
  system is:</p>
  <p class="MsoNormal"><i style="">Text_color:highlight_color:border_color:title_color<o:p></o:p></i></p>
  <p class="MsoNormal">You use 2 values for each section. The first is the
  forground color and the second is the background color.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Timeout</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Sets the timeout period in 1/10<sup>th</sup> seconds
  before the default menu item is automatically run. The default is usually 80
  which gives the user 8 seconds to select a menu item.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Lba32</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Tells lilo to ignore the hard drive's physical geometry
  and use logical block addressing. This allows LILO to work with disks that
  have more than 1023 cylinders (which all modern hard drive do).</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Change-rules</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Defines boot-time changes to partition type numbers.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Reset</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies that all default change-rules are removed.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Read-only</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies that the rool (/) file system be mounted
  read-only at first. After checking the integrity of the file system, the
  kernel will usually remount the file system in read-write mode.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Prompt</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies that the boot: prompt be displayed.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Default</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the default image that will be loaded if the
  user doesn't make a selection.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Message</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the location of the image file that LILO will
  display.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Boot</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the device that contains the boot sector.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Image Options</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Image</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the path to the boot image of a Linux kernel.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Label</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies a name for the image.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Append</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Appends the specified options to the parameters that are
  passed to the kernel by LILO. This is ually only used if the system uses
  hardware the kernel is having a difficult time auto-detecting.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Vga</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the VGA text mode that should be used while the
  system is booting.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Initrd</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the initial ramdisk image to be loaded with the
  kernel.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Root</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the device that should be mounted as root.</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">You must type lilo in
the command prompt after making changes.<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style="">Grub Bootloader (
Grand Unified Bootloader)<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal">Grub is separated in chunks called stages. These include the
following:</p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Stage
     1 - This stage of GRUB is usually stored in the MBR. Its only real job is
     to point to the location of Stage 2.</li><li class="MsoNormal" style="">Stage
     2 - This stage of GRUB is stored in a disk partition. When loaded by Stage
     1, Stage 2 presents a graphical menu on the screen that allows the user to
     select the kernel image that should be loaded. Like LILO, you can
     configure GRUB with a default image and a timeout value. If the user
     doesn't select an option within the timeout period, the system will
     automatically boot the default kernel image.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Like LILO, it's also
possible to install Stage 1 in the boot partition. In addition, there may
actually be a GRUB stage 1.5 on some deployments. Stage 1 can either load Stage
2 directly, or it may point to stage 1.5, which resides in the first 30kb after
the MBR of the hard disk. Stage 1.5 then loads Stage 2.<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal">To initially install grub you would enter <b style="">grub-install device</b>. The device would
be the device whose MBR you want to install stage 1 into. Example: grub-install
/dev/had</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">Grub references disks differently then LILO. The following
is GRUB:</p>

<p class="MsoNormal"><i style="">Hddrive_number,partition_number<o:p></o:p></i></p>

<p class="MsoNormal"><i style=""><o:p>&nbsp;</o:p></i></p>

<p class="MsoNormal">GRUB Configuration File Option:</p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Section<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Option<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Description<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Global</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Color</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the colors to be used in the GRUB menu.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Default</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the menu item that will be booted automatically
  if the user doesn't make a manual selection.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Timeout</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the number of seconds to wait until the default
  menu item is automatically booted.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Gfxmenu</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the location of the image file that will be used
  to display the graphical GRUB boot menu.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Title</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Title</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the title of the menu item in the GRUB boot
  menu.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Root</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the location of the partition that is to be
  mounted as the GRUB root.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Kernel</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the location of the Linux kernel.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Initrd</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies the initrd image that should be used by GRUB to
  create the initial ramdisk image during boot.</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style="">Runlevels<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal"><b style="">Runlevel<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal"><b style="">Description<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">0</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Halts the system</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">1</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Runs Linux in single-user mode. The command-line interface
  is used.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">2</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Runs Linux in multi-user mode with networking disabled.
  The command-line interface is used.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">3</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Runs Linux in multi-user mode with networking enabled. The
  command-line interface is used.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">4</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Unused</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">5</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Runs Linux in multi-user mode with networking enabled. The
  graphical user interface is used.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">6</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Reboot</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">The syntax for
commands within the inittab file is </b><i style="">identifier:runlevel:action:command<b style="">. </b></i><b style="">The wait action specified in these commands tells the init process to
wait until the scripts for the specified runlevel have finished running before
moving on. <o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal">[ init completes the following tasks as it initializes a
BSD-type system ]</p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Runs
     the /etc/init.d/boot script to prepare the system.</li><li class="MsoNormal" style="">Processes
     /etc/inittab to determine the appropriate runlevel and scripts.</li><li class="MsoNormal" style="">Runs
     the scripts in the appropriate runlevel directory in /etc/init.d.</li><li class="MsoNormal" style="">Runs
     the /etc/init.d/boot.local script.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">[ init completes the following taks on a V-type system ]</p>

<ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Runs
     the /etc/rc.d/sysinit script to prepare the system</li><li class="MsoNormal" style="">Processes
     /etc/inittab to determine the appropriate runlevel and scripts.</li><li class="MsoNormal" style="">Runs
     the scripts in the appropriate runlevel directory in /etc/rc.d/.</li><li class="MsoNormal" style="">Runs
     the /etc/rc.d/rc.local script.</li></ul>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Important Files in
/etc/init.d<o:p></o:p></b></p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">File<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Init Style<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Function<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Rc</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">BSD and System V</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">This script is used to switch between runlevels while the
  system is running.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Halt</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">BSD</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">This script can stop or reboot your system. It is run if
  the current runlevel is changed to 0 or 6.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Boot</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">BSD</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">This script is run by init when the system first starts.
  It runs the scripts contained in /etc/init.d/boot.d. These scripts accomplish
  a variety of startup tasks, such as loading kernel modules, verifying the
  file systems, and setting the system clock.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Boot.local</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">BSD</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">This script is also run by init at startup. It contains
  additional startup commands. This script is extremely useful. If you want to
  run a particular command automatically at startup, you can insert the command
  into this file with a text editor.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Rc.sysinit</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">System V</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">This script's function is similar to the boot script on a
  BSD-type system. It's used to set the path, check the file system for errors,
  set the system clock, etc.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Rc.local</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">System V</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">This script's function is similar to that of the
  boot.local script on a BSD-type system. You can add your own commands to this
  script to ensure they are run every time the system boots.</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">You can change runlevels by typing <b style="">init runlevel</b> example: init 3</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">If you look inside an
rcx.d directory within your distribution's init directory, you will see two
scripts for each system process. One starts with an "S" and one starts with a
"K". The scripts that start with S are used to start a process while the
scripts that start with "K" are used to kill a process. These are the scripts
employed when switching between runlevels on the fly as just described.<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>chkconfig -
updates and queries runlevel information for system services</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">SYNOPSIS</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>chkconfig
--list [name]</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>chkconfig --add
name</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>chkconfig --<st1:state w:st="on"><st1:place w:st="on">del</st1:place></st1:state> name</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>chkconfig
[--level levels] name &lt;on|off|reset&gt;</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>chkconfig
[--level levels] name</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
]]>
        

    </content>
</entry>

<entry>
    <title>linux processes</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/linux-processes.html" />
    <id>tag:www.tullyrankin.com,2009://3.96</id>

    <published>2009-05-17T07:47:47Z</published>
    <updated>2009-05-17T07:48:53Z</updated>

    <summary>ProcessesBinary Executables - These are programs that were orginally created as a text file using a programming language, such as C or C++. The text file was then run through a compiler to create a binary file that can be...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="linuxprocesses" label="linux processes" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[Processes<br /><br />Binary Executables - These are programs that were orginally created as a text file using a programming language, such as C or C++. The text file was then run through a compiler to create a binary file that can be processed by the CPU. <br /><br />Internal shell commands - Some of the commands you enter at the shell prompt are actual binary files in the file system that are loaded and run by the CPU. For example, when you enter rpm at the shell prompt, you load the rpm binary file into memory. Other commands, however, are binary executables. Instead, they are commands that are rolled into the shell program itself. For example, if you enter exit at a shell prompt, you are actually running an internal shell command. There is no executable file in the file system named "exit". Instead, the computer code associated with the exit function is stored within the shell program code itself.<br /><br />Shell scripts - These are text files that are executed through the shell itself. You can include commands to run binary executables within the text of any shell script.<br /><br />Newer, dual-core CPUs can actually execute more than one process at a time. Because there are two cores within the CPU, one core can execute one process while the other core works on another.<br /><br />System processes are usually (but not always) noted with a "d" at the end of the name, which stands for daemon.<br /><br />Any process running on a Linux system can launch additional processes. The process that launched the new process is called the parent process. The new process itself is called the child process. This parent/child relationship constitutes the herdity of Linux processes.<br /><br />Whenever a process is created on a Linux system, it is assigned two resources:<br /><br />Process ID (PID) Number - This is a number assigned to each process that uniquely identifies it on the system.<br /><br />Parent Process ID (PPID) Number - This is the PID of the process parent process.<br /><br />The process of creating a new subshell and running the command process within it is called forking.<br /><br />Type types of init scripts:<br /><br />System V - Linux distributions that use System V init scripts store them in the /etc/rc.d directory. Within /etc/rc.d are a series of subdirectories named rc.0 through rc6.d. Each of these directories is associated with a particular runlevel. Within each of these subdirectories are symbolic links that point to the init scripts for your system daemons, which reside in /etc/rc.d/init.d. Red Hat Linux and Fedora use System V-type init scripts.<br /><br />BSD - Other Linux distributions use BSD-style init scripts. These scripts reside in the /etc/init.d directory. Within /etc/init.d are a services of directories named rc0.d through rc6.d. As with System V init scripts, these directories are associated with specific runlevels. These directories contain links that point to the init scripts in /etc/init.d.SUSE Linux uses this type of init script.<br /><br />[ Using Top ]<br /><br />The following are the columns are used in the top display:<br /><br />PID - The process ID of the process.<br />USER - The name of the user that owns the process.<br />PR - The priority assigned to the process.<br />NI - This is the nice value of the process.<br />VIRT - The amount of virtual memory used by the process.<br />RED - The amount of physical RAM the process is using(its resident size) in kilobytes.<br />SHR - The amount of shared memory used by the process.<br />S - The status of the process. Possible vales include:<br />&nbsp;D - Uninterruptibly sleeping.<br />&nbsp;R - Running.<br />&nbsp;S - Sleeping.<br />&nbsp;T - Traced or stopped.<br />&nbsp;Z - Zombied.<br />%CPU - The percentage of CPU time used by the process.<br />%MEM - The percentage of available physical RAM used by the process.<br />TIME+ - The total amount of CPU time the process has consumed since being started.<br />COMMAND - The name of the command that was entered to start the process.<br /><br />A zombied process is one where the process has finished executing and exited, but the process' parent didn't get notified that it was finished and hasn't released the child process' PID. A zombied process may eventually clear up on it's own. It if doesn't you may need to manually kill the parent process.<br /><br />You can add columns to top by pressing the letter F and selecting a column<br /><br />[ PS ]<br /><br />By default the PS shows the following:<br /><br />PID - The process ID of the process.<br />TTY - The name of the terminal session (shell) that the process is running within.<br />TIME - The amount of CPU time used by the process.<br />CMD - The name of the command that was entered to create the process.<br /><br />If there is a ? in the TTY process it means it is a system process.<br /><br />The -f option will add the follwing to PS output:<br /><br />UID - The user ID of the process' owner.<br />PPID - The PID of the process' parent process.<br />C - The amount of prcessor time utilized by the process.<br />STIME - The time that the process started.<br /><br />You can view much more info by adding the -l Option. This would add the following:<br /><br />F - The flags associated with the process. This column used the following codes:<br />&nbsp;1 - Forked, but didn't execute.<br />&nbsp;4 - Used root privileges.<br />S - The state of the process. This column uses the following codes:<br />&nbsp;D - Uninterruptible sleep.<br />&nbsp;R - Running<br />&nbsp;S - Interruptible sleep.<br />&nbsp;T - Stopped or traced.<br />&nbsp;Z - Zombied.<br />PRI - The priority of the process.<br />NI - The nice value of the process.<br />SZ - The size of the process.<br />WCHAN - The name of the kernel function which the process is sleeping. You will see a dash (-) in this column if the process is currently running.<br /><br /><br />[ Setting Priorities with nice ]<br />Nice - Used to set a nice value for a process.<br />renice - Used to change the nice value for a running process.<br /><br />Nice values are from -20 to +19. The lower the number the higher the priority.<br /><br />To start a process with a given nice value use the following command:<br />nice -n nice_level command<br /><br />You can't set a negative nice value unless you are root. Normal users are restricted to 0 or higher.<br /><br />[renice]<br /><br />The syntax of changing a already running processes nice value is as follows:<br />renice -n nice_value PID<br /><br />[ Background / Foreground Processes ]<br />To put a program in the background use a &amp; symbol. Example: "firefox &amp;". This will then put the firefox application in the background so you can use the firefox application but still be able to run more commands at the command prompt. When you do this command it will then display 2 numbers. Example "1 4212". These two numbers display the job # and the PID.<br /><br />To view all background jobs you type "jobs" in the command prompt.<br /><br />You can switch between background and foreground processes with the folling commands:<br /><br />fg - This command will move a background process to the foreground. The synwax is "fg job_id".<br />bg - This command will move a foreground process to the background. To use this utility, you must first assign the foreground job as a background job ID. This is done by pressing CTRL-Z. When you do, you'll see the process stop and a background job ID assigned to the process. You can then enter "bg job_id" to move the process to the background.<br /><br />[ Ending Running Processes ]<br />The kill command will terminate a process. The syntax is as follows:<br />kill -signal PID<br /><br />There are many kill signals you can use. Here are a few:<br /><br />SIGHUP - This is kill signal 1. This signal restarts the process. After a restart, the process will have exactly the same PID that it had before. This is a very useful option for restarting a service for which you've made changes in a configuration file.<br /><br />SIGINT - This is kill signal 2. This signal sends a CTRL-C key sequence to the process.<br /><br />SIGKILL - This is kill signal 9. This is a brute-force signal that kills the process. If the process was hung badly, this option will force it to stop. However, the process may not clean up after itself if this signal is used. The resources allocated to the process may remain allocated until the system is restarted.<br /><br />SIGTERM - This is kill signal 15. This signal tells the process to terminate immediately. This is the default signal sent by the kill if you omit a signal in the command line. This signal allows the process to clean up after itself before exiting.<br /><br /><br />A good sequence when trying to kill a hung process is as follows:<br />1. Send a SIGINT first. If it doesn't respond, then go on to step 2.<br />2. Send a SIGTERM. Usually, this will fix the problem and allow the process to exit cleanly. If it doesn't then go on to step 3.<br />3. Send a SIGKILL.<br /><br />[ Schedule Processes ]<br /><br />The at daemon is good for setting a job to run once a specific time. The service is called atd and can be started as follows: "/etc/init.d/atd start"<br /><br />You need to specify which users can and which users cannot create at jobs. This can be done by editing the following files:<br /><br />/etc/at.allow - Users listed in this file are allowed to create at jobs.<br />/etc/at.deny - Users listed in this file are not allowed to create at jobs.<br /><br />There are many formats you can use for the at command time. The following displays these formats:<br /><br />Fixed<br />&nbsp;HH:MM - Specifies the exact hour and minute when the commands should be run. The at daemon assumes that the hour and minute specified is today unless that time is already past; then is assume it is tomorrow. You can also add am or pm to specify morning or afternoon.<br />&nbsp;Noon - Specifies that a command be run at 12:00 PM.<br />&nbsp;Midnight - Specifies that a command be run at 12:00 AM.<br />&nbsp;Teatime - Specifies that a command be run at 4:00 PM.<br />&nbsp;MMDDYY or MM/DD/YY or MM.DD.YY - These all specify the exact month, date, and year when a command is to be run.<br />&nbsp;HH:MM MMDDYY - Specifies the exact month, date, year, and time when a command is to be run.<br />Relative<br />&nbsp;now - Specifies that the command be run immediately.<br />&nbsp;now + value - Specifies that the command be run at a certain time in the future. For example, you could enter any of the following:<br />&nbsp; now + 5 minutes<br />&nbsp; now + 2 hours<br />&nbsp; now + 3 days<br />&nbsp;today - Specifies that the command be run today. You&nbsp; can mix this value with a fixed value from above, such as 2 pm today.<br />&nbsp;tomorrow - Specifies that the command be run tomorrow. You can also mix this value with a fixed value, such as 2 pm tomorrow.<br /><br />The following is an example on how to use the atd daemon.<br /><br />#at now + 10 minutes<br />at&gt; echo "This is my command" | wall<br /><br />You can run multiple command by hitting enter after each command you wish to run. When you are done entering the commands you wish to run you would press CTRL+D.<br /><br />You can view a list of at jobs in the queue by typing "atq" at the command line.<br /><br />To remove a job from the at queue you would type "atrm job_number" at the command line.<br /><br />[ Using the cron Daemon ]<br /><br />The cron uses many different directories to look for scheduled jobs. It will first check the /etc/crontab file which then checks the following:<br /><br />/etc/cron.hourly - Contains cron scripts that are run every hour.<br />/etc/cron.daily - Contains cron scripts that are run every day.<br />/etc/cron.weekly - Contains cron scripts that are run once a week.<br />/etc/cron.monthly - Contains cron scripts that are run once a month.<br />/etc/cron.d - This file has jobs that run at specific times.<br /><br />Crontab File Fields <br />1 - Minutes. This field specifies the minutes past the hour that the command should be run.<br />2 - Hour. This field specifies the hour of the day when the command should be run. The cron daemon prefers military time, so you should use a value of 0 to 23 in this field.<br />3 - Day. This field specifies the day of the month that the command should be run.<br />4 - Month. This field specifies the month of the year when the command should be run.<br />5 - Day of the week. Sunday is 0 and Saturday is 6.<br />6 - The name of the command, including the full path, to be run.<br /><br />Example crontab entry in /etc/cron.d<br />5 23 * * 1-6 /bin/tar -cvf /bin/tar -cvf /media/usb/backup.tar /home<br /><br />The last line specifies that the command be run at 5 minutes after 11:00pm (23) every day (*) of every month (*) on Monday (1) through Saturday (6).<br /><br />** System cron jobs run as the root user ***<br /><br />User created crontabs are created in /var/spool/cron/tabs with there username as the filename. <br /><br />If you don't want to allow users to be able to create cron files you can restrict or allow users in the /etc/cron.allo and /etc/cron.deny files.<br /><br />If you create a /etc/cron.allow file ONLY users that are in that file are able to create cron files.<br /><br />Users can create and edit there crontab by using the following commands:<br /><br />crontab -e&nbsp; This command opens up vi to edit your crontab file. If you don't have one it will create it.<br />crontab -l This command will display your crontab file.<br />crontab -r This will remove your crontab file.<br /><br /> ]]>
        
    </content>
</entry>

<entry>
    <title>Linux Shell Notes</title>
    <link rel="alternate" type="text/html" href="http://www.tullyrankin.com/linux-shell-notes.html" />
    <id>tag:www.tullyrankin.com,2009://3.95</id>

    <published>2009-05-16T02:25:20Z</published>
    <updated>2009-05-16T02:27:18Z</updated>

    <summary> Bash Configuration File Type of Shell Function ~/.bashrc Non-login shells (Although login shells on most distributions read this file as well. It is usually called from one of the configuration files listed below. Stores individual user&apos;s shell preferences. /etc/profile...</summary>
    <author>
        <name>Tully</name>
        
    </author>
    
    <category term="linuxshellbash" label="linux shell bash" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en-us" xml:base="http://www.tullyrankin.com/">
        <![CDATA[<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Bash Configuration
  File<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Type of Shell<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal"><b style="">Function<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">~/.bashrc</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Non-login shells (Although login shells on most
  distributions read this file as well. It is usually called from one of the
  configuration files listed below.</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Stores individual user's shell preferences.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">/etc/profile</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Login shells</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Contains configuration parameters that are applied
  system-wide</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">~/.bash_profile</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Login shells</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Stores individual users' shell preferences</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">~/.bash_login</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Login shells</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Stores individual users' shell preferences</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">~/.profile</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Login shells</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Stores individual users' shell preferences</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">~/bash_logout</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Login shells</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197">
  <p class="MsoNormal">Specifies actions to be performed when a user logs out
  from the shell.</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Commonly Used
Environment Variables<o:p></o:p></b></p>

<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0">
 <tbody><tr style="">
  <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal"><b style="">Environment
  Variable<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal"><b style="">Stores<o:p></o:p></b></p>
  </td>
  <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal"><b style="">Default Values<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">BASH and SHELL</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The full path to the shell executable</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">/bin/bash</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">CPU</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The type of CPU installed in the system</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Depends on your system. An Intel Pentium IV computer would
  have a value of i686.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">DISPLAY</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The location where your X Windows display should be sent</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">0.0 (the local video card and monitor)</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">ENV</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The name of the file bash read to configure its
  environment</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">~/.bashrc</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">EUID</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The user ID (UID) of the current user</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">The UID number of the current user</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">HISTFILE</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to the bash command history file</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">~/.bash_history</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">HISTSIZE</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The number of commands saved in the command history</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">1000</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">HOME</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to the current user's home directory</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">The current user's home directory.</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">HOST and HOSTNAME</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The hostname of the system</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">The hostname you assigned when you installed the system</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">INFODIR</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to your system's info program</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">/usr/local/info:/usr/share/info:/usr/info</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">LOGNAME</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The username of the current user</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">The username of the current user</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">MAIL</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to the current user's mailbox file</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">/var/spool/mail/username</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">MANPATH</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to your system's man program</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">/usr/local/man:/usr/share/man:/usr/X11R6/man:/opt/gnome/share/man</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">OLDPWD</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to the prior current directory</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Depends on what your prior current directory was</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">OSTYPE</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The type of operating system currently running</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Linux</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">PATH</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">A list of directories to be searched when running a
  command from the shell prompt</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Depends on your distribution</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">PS1</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The characters used to create the shell prompt</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Depends on your distribution</p>
  </td>
 </tr>
 <tr style="">
  <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 70.8pt;" valign="top" width="94">
  <p class="MsoNormal">PWD</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 150.6pt;" valign="top" width="201">
  <p class="MsoNormal">The path to the current working directory</p>
  </td>
  <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 221.4pt;" valign="top" width="295">
  <p class="MsoNormal">Depends on what your current directory is</p>
  </td>
 </tr>
</tbody></table>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">You can use the <b style="">set </b>command
to view all your variables in a linux system. You can also use the <b style="">env </b>command to see your system
environment variables.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">You must type <b style="">export
VARIABLE</b> to use a new or changes variable on a new shell.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">File descriptors:</p>

<p class="MsoNormal"><b style="">Stdin - </b>This file
descriptor stands for standard input. Standard input is the input provided to a
particular command to process. The stdin for a command is represented by the
number 0.</p>

<p class="MsoNormal"><b style="">Stdout - </b>This
file descriptor stands for standard output. Standard output is simply the
output from a particular command. For example, the directory listing generated
by the ls command is its stdout. The stdout for a command is represented by the
number 1.</p>

<p class="MsoNormal"><b style="">Stderr - </b>This
file descriptor stands for standard error. Standard error is the error code
generated, if any, by a command. The stderr for a command is represented by the
number 2.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Cat file &gt; output</b>
- will save stdout ( no errors )</p>

<p class="MsoNormal"><b style="">Cat file 1&gt; output
</b><span style="">&nbsp;</span>- will save stdout<span style="">&nbsp; </span>( no errors )</p>

<p class="MsoNormal"><b style="">Cat file 2&gt;<span style="">&nbsp; </span>output <span style="">&nbsp;</span></b>- will save stderr ( ERRORS )</p>

<p class="MsoNormal"><b style="">Cat file 1&gt; output
2&gt;&amp;1 </b>- This will put both stdout and stderr in the same file.</p>

<p class="MsoNormal"><b style="">Cat file 1&gt;&gt;
output 2&gt;&amp;1 </b>- This will output both stdout and stderr to the same
file.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Sed Commands<o:p></o:p></b></p>

<p class="MsoNormal"><b style="">s - </b>Replaces
instances of a specified text string with another text string. The syntax for
using the s command is <b style="">sed
s/term1/term2/</b>.</p>

<p class="MsoNormal"><b style="">d - </b>Deletes the
specified text. For example, to delete every line of text from the stdin that
contains the term "eos", you would enter <b style="">sed
/eos/d</b>.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">AWK character outputs<o:p></o:p></b></p>

<p class="MsoNormal"><b style="">\t </b>- Inserts a
tab character</p>

<p class="MsoNormal"><b style="">\n </b>- Adds a new
line character.</p>

<p class="MsoNormal"><b style="">\f </b>- Adds a
formfeed character.</p>

<p class="MsoNormal"><b style="">\r </b>- Adds a
carrieage return character.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Shell Scripts<o:p></o:p></b></p>

<p class="MsoNormal">All variables are interpreted as text unless defined
otherwise. To declare a variable to be an integer use the following code: <b style="">declare -i VAR</b>.</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">If/Then/Else
statement structure:<o:p></o:p></b></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">If <i style="">condition </i>then</p>

<p class="MsoNormal"><span style="">&nbsp;</span>Commands</p>

<p class="MsoNormal">Else</p>

<p class="MsoNormal"><span style="">&nbsp;</span>Commands </p>

<p class="MsoNormal">Fi</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal">Check if a directory/file exists.</p>

<p class="MsoNormal"><b style="">If [ -e $VAR ]; then<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><span style="">&nbsp;</span>Echo "exists";<o:p></o:p></b></p>

<p class="MsoNormal"><b style="">Fi<o:p></o:p></b></p>

<p class="MsoNormal"><b style=""><o:p>&nbsp;</o:p></b></p>

<p class="MsoNormal"><b style="">Case Syntax<o:p></o:p></b></p>

<p class="MsoNormal">Case variable in</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response_1
) commands</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response_2
) commands</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response_3
) commands</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal">Esac</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Example:<o:p></o:p></b></p>

<p class="MsoNormal">Read NAME</p>

<p class="MsoNormal">Case $NAME in</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Tully )
echo "Your name is Tully!"</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Tullyr )
echo "Awesome Tullyr!"</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Rankin )
echo "You have my last name!"</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>* ) echo
"Your name is not cool"</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>;;</p>

<p class="MsoNormal">Esace</p>

<p class="MsoNormal">Exit0</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">While Loops<o:p></o:p></b></p>

<p class="MsoNormal">While condition</p>

<p class="MsoNormal">Do</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Script
commands</p>

<p class="MsoNormal">Done</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><b style="">Until loop<o:p></o:p></b></p>

<p class="MsoNormal">Until condition</p>

<p class="MsoNormal">Do</p>

<p class="MsoNormal"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Script
commands</p>

<p class="MsoNormal">Done</p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>

<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
]]>
        

    </content>
</entry>

</feed>
