<?xml version="1.0" encoding="UTF-8" standalone="no"?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>PHP Funda</title><description>This site allows users/developer to Learn Basic PHP,Get Basic PHP Functions,PHP Code,Advanced PHP Code freely without any cost or 0(zero) cost.</description><managingEditor>noreply@blogger.com (Unknown)</managingEditor><pubDate>Wed, 28 Aug 2024 16:47:13 -0700</pubDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">51</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/">25</openSearch:itemsPerPage><link>http://phpfunda.blogspot.com/</link><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:keywords>php,code,free,tutorial,material,ebooks,download,software</itunes:keywords><itunes:summary>It is used to learn PHP. It provides predefine code for special tasks like striptag, HTML making , date time related code and many more....</itunes:summary><itunes:subtitle>Php Funda</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Gadgets"/></itunes:category><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><title>How to use a CIDR netmask to block an IP address range using .htaccess</title><link>http://phpfunda.blogspot.com/2011/11/how-to-use-cidr-netmask-to-block-ip.html</link><category>Apache</category><category>Article</category><category>Code</category><category>Example</category><category>Mod Rewrite</category><category>Open Source</category><category>SEO</category><category>tips</category><category>Web crawler</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 1 Nov 2011 00:03:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-5489080334835214752</guid><description>&lt;p&gt;This article explains why you must sometimes use CIDR netmask notation to ban an IP address range using Apache .htaccess, and how to do it. It is intended to supplement the basic   Apache information about mod_access in the documentation at &lt;a title="Go to the Apache documentation for mod_access: order, allow, deny directives." href="http://httpd.apache.org/docs/1.3/mod/mod_access.html"&gt; http://httpd.apache.org/docs/1.3/mod/mod_access.html&lt;/a&gt;. &lt;/p&gt;&lt;br /&gt;&lt;h2&gt;An IP address is a 32-bit binary number that uniquely identifies a computer on the internet &lt;/h2&gt;&lt;br /&gt;&lt;p&gt;32-bit binary is hard to remember :   11000000010000000000000000000000 &lt;br&gt;&lt;br /&gt;  Decimal notation isn't much easier: 3225419776 &lt;br&gt;&lt;br /&gt;  So it is usually written like this     :  192.64.0.0 &lt;/p&gt;&lt;br /&gt;&lt;p&gt;You get this "dotted-quad notation" by breaking the 32 bits into 4 groups of 8 and then converting   each group to decimal: &lt;/p&gt;&lt;br /&gt;&lt;table align="center" border="1" cellpadding="10"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;11000000&lt;/td&gt;&lt;td&gt;01000000&lt;/td&gt;&lt;td&gt;00000000&lt;/td&gt;&lt;td&gt;00000000&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;192&lt;/td&gt;&lt;td&gt;64&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p align="center"&gt;192.64.0.0 &lt;/p&gt;&lt;br /&gt;&lt;p&gt;That makes it easier to remember, but it creates problems if you try to use it for   calculations&lt;a href="http://25yearsofprogramming.com/blog/20070803.htm"&gt;.&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;An IP address contains two pieces of information: &lt;/h3&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;The leftmost binary digits are the &lt;strong&gt;unique ID of the network&lt;/strong&gt; (usually your Internet Service Provider,    ISP) through which you are connected to the internet. &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;The remaining binary digits are your &lt;strong&gt;unique ID as an individual user&lt;/strong&gt; on that   network. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  &lt;p&gt;&lt;strong&gt;The &lt;em&gt;number&lt;/em&gt; of leftmost digits used for network ID is not the same   for every network. In CIDR notation, the /nn part says how many of the leftmost    bits indicate the network. &lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt;If the network uses exactly the leftmost 8, 16, or 24 bits for its ID, then   the dividing line between network and user falls on one of the period boundaries   of the dotted-quad notation, and one of the partial IP notations will work: &lt;/p&gt;&lt;br /&gt;&lt;table border="1" cellpadding="10"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;.htaccess partial IP address&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Equivalent CIDR&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;deny from 192&lt;/td&gt;&lt;td&gt;deny from 192.0.0.0/8&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;deny from 192.64&lt;/td&gt;&lt;td&gt;deny from 192.64.0.0/16&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;deny from 192.64.0&lt;/td&gt;&lt;td&gt;deny from 192.64.0.0/24&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Each quad that you don't specify is treated as a wildcard that can take any   value from 0 to 255. So the first example bans any IP address that starts with   192., followed by anything. &lt;/p&gt;&lt;br /&gt;&lt;h2&gt;When to use CIDR notation&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;If the network &lt;em&gt;doesn't&lt;/em&gt; use exactly 8, 16, or 24 bits for the network part of   the IP address,   the dividing line between network and user &lt;em&gt;does not&lt;/em&gt; fall on a period   boundary of dotted-quad notation, and you need to use a CIDR netmask. &lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Example CIDR/netmask: &lt;/h3&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;192.64.0.0/10 &lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;This says the base address of the network is 192.64.0.0 and   the first 10 bits are the network: &lt;/p&gt;&lt;br /&gt;&lt;p&gt;192 64 0 0 = &lt;strong&gt;11000000 01&lt;/strong&gt;000000 00000000 00000000 &lt;/p&gt;&lt;br /&gt;&lt;p&gt;192 is the first 8 bits, but two more bits are part of the network   ID, too. The 9th bit is 0 and the 10th is 1, and that is where the 64   comes from. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;The full range of this network in quad notation is 192.64.0.0 -   192.127.255.255. Note that the 64 in the second position doesn't remain   constant. The first 2 bits are always the same, but the righthand 6 will be   different for different users. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;The simple notations for an .htaccess ban won't work. Why not? &lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;deny from 192 would ban the range    192.0.0.0 - 192.255.255.255, which will   ban some users that are &lt;em&gt;not&lt;/em&gt; coming from this network. &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;deny from 192.64 would ban the   range 192.64.0.0 - 192.64.255.255, which is    insufficient to ban &lt;em&gt;all&lt;/em&gt; the users that &lt;em&gt;are&lt;/em&gt; coming from this network. &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;So the answer is CIDR notation and an .htaccess line that says: &lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;deny from 192.64.0.0/10 &lt;/p&gt;&lt;br /&gt;&lt;p&gt;This says the base address is 192.64.0.0, and the first 10 bits identify the   network (those are always the same for all users who are on that network). &lt;/p&gt;&lt;br /&gt;&lt;h2&gt;To ban a specific IP range in htaccess &lt;/h2&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Figure out, from your website access logs or elsewhere, the IP addresses you want to ban. Look   them up in a WhoIs database such as &lt;a title="Domain Tools is one of many WhoIs lookup services." href="http://whois.domaintools.com/"&gt;http://whois.domaintools.com/&lt;/a&gt;. &lt;br&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Determine whether you need to use a CIDR netmask. If the IP address    range in the report looks like one of these, with each quad after the    leading one(s) showing a rull range of 0-255, then you can use one of the    simpler methods: &lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    192.&lt;strong&gt;0.0.0&lt;/strong&gt; - 192.&lt;strong&gt;255.255.255   &lt;/strong&gt;-- Use deny from 192&lt;br&gt;&lt;br /&gt;    192.64.&lt;strong&gt;0.0&lt;/strong&gt; - 192.64.&lt;strong&gt;255.255   &lt;/strong&gt;-- Use deny from    192.64&lt;br&gt;&lt;br /&gt;    192.64.128.&lt;strong&gt;0&lt;/strong&gt; - 192.64.128.&lt;strong&gt;255 &lt;/strong&gt;-- Use deny from 192.64.128&lt;br&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;For anything else, you need CIDR. At Domain Tools, the CIDR netmask   is sometimes shown in the report for that   IP address, several lines down in the report. If it is, that's all you   need. You're ready to create the line in your .htaccess file.   Go to Step 5.&lt;br&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;If the CIDR wasn't given, you can calculate it yourself with a netmask   calculator such as &lt;a title="Go to this netmask calculator website." href="http://jodies.de/ipcalc"&gt;http://jodies.de/ipcalc&lt;/a&gt;. &lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    a) Enter the base (lowest) address.  &lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    b) You can simply determine the netmask (the /nn part) by trial and error,    or you can calculate the minimum size to start with: take the rightmost    nonzero quad of the &lt;em&gt;base&lt;/em&gt; address and convert it to binary in your    head or in Windows Calculator. Find the rightmost "1". The netmask will have    to be sufficient to include all of the previous quads (at 8 bits each), plus    all the digits in this quad up to its rightmost "1". That's the minimum. But    it might include some of the trailing zeroes, too. &lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    c) Keep using trial and   error for the netmask until &lt;strong&gt;HostMin&lt;/strong&gt; and &lt;strong&gt;HostMax&lt;/strong&gt; match the &lt;strong&gt;IP address range&lt;/strong&gt; you saw in the Domain Tools report. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  &lt;p&gt;Note that final quads of 0 and 255 are reserved, so: &lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    The    calculated &lt;strong&gt;HostMin&lt;/strong&gt; will be &lt;strong&gt;nnn&lt;/strong&gt;&lt;strong&gt;.nnn.nnn.1&lt;/strong&gt;,    not &lt;strong&gt;nnn.nnn.nnn.0&lt;/strong&gt; &lt;br&gt;&lt;br /&gt;    The calculated &lt;strong&gt;HostMax&lt;/strong&gt; will be &lt;strong&gt;nnn.nnn.nnn.254&lt;/strong&gt; not &lt;strong&gt;nnn.nnn.nnn.255&lt;/strong&gt; &lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    The &lt;strong&gt;Hosts/Net&lt;/strong&gt; line tells you how many users this network might have,    which can help decide whether you really want to ban the entire range. &lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;ol start="5"&gt;&lt;br /&gt;  &lt;li&gt;Edit your public_html/.htaccess file to add the "deny from" line:&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  &lt;ol type="1"&gt;&lt;br /&gt;    &lt;li&gt;Go to &lt;strong&gt;cPanel &amp;gt; File Manager&lt;/strong&gt;. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt;Navigate to the file &lt;strong&gt;public_html/.htaccess&lt;/strong&gt;. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt;Click on its &lt;strong&gt;file name&lt;/strong&gt; (not the icon next to it). &lt;/li&gt;&lt;br /&gt;    &lt;li&gt;In the upper right corner of the screen, click &lt;strong&gt;Edit File&lt;/strong&gt;. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt;&lt;strong&gt;Make a     backup copy:&lt;/strong&gt; Copy all the text in the file, and &lt;strong&gt;save it into a     file on your local computer&lt;/strong&gt; so you can put it back into .htaccess if     something goes wrong. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt;Backup made?     Ok, now you can edit the file. On a blank line in a part of the file that is &lt;em&gt;not&lt;/em&gt; between    HTML-style tags like &amp;lt;tag&amp;gt;&amp;lt;/tag&amp;gt;, type the line: &lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;      &lt;strong&gt;deny from     nnn.nnn.nnn.nnn/nn &lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;      &lt;/strong&gt;Replace the nnn's with the IP/netmask you calculated for this range.&lt;strong&gt;&lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;      &lt;/strong&gt;Further explanation: some lines of your .htaccess file might be    contained between tags that look like HTML tags where the opening tag looks    like &amp;lt;tag&amp;gt; and the closing tag looks like &amp;lt;/tag&amp;gt;. Insert this new    line in a part of the file that is &lt;strong&gt;not&lt;/strong&gt; between any of these pairs of tags. &lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;      Depending on what is in your .htaccess, you might need to use your judgment whether to use the &lt;strong&gt;order&lt;/strong&gt; and &lt;strong&gt;allow&lt;/strong&gt; directives     that are also provided by mod_access. See the link to Apache at the top     of this article for more information. That is beyond the scope of this     article, and it will require your judgment. I'd suggest adding only the     "deny from" line at first and seeing if it works as expected. What     is expected: you can access your website; most other people can, too;     when the denied party tries, your logs will show a result code of 403     Forbidden. &lt;br&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;  &lt;/ol&gt;&lt;br /&gt;&lt;/blockquote&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Magento Template Path Hints For Admin side</title><link>http://phpfunda.blogspot.com/2011/08/magento-template-path-hints-for-admin.html</link><category>Article</category><category>Code</category><category>magento</category><category>MySQL</category><category>Open Source</category><category>PHP</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 9 Aug 2011 00:29:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-2004167473044858481</guid><description>&lt;p&gt;If you love template path hints in   Magento for quickly figuring out which template file or block you need   to edit or override and have a requirement for some admin side coding,   you are going to love this.&lt;/p&gt;
&lt;br /&gt;&lt;p&gt;You might not have thought it was possible to enable template path hints in admin, but it is!&lt;/p&gt;
&lt;br /&gt;&lt;p&gt;Just run this query:&lt;/p&gt;
&lt;br /&gt;&lt;div&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div&gt;&lt;strong&gt;SQL:
&lt;br /&gt;  &lt;/strong&gt;
&lt;br /&gt;  &lt;div id="sql-1"&gt;
&lt;br /&gt;      &lt;div&gt;
&lt;br /&gt;        &lt;div&gt;INSERT INTO core_config_data (scope, scope_id, path, value)
&lt;br /&gt;              VALUES ('default', 0, 'dev/debug/template_hints', 1),
&lt;br /&gt;              ('default', 0, 'dev/debug/template_hints_blocks', 1); 
&lt;br /&gt;          &lt;div&gt;&lt;/div&gt;
&lt;br /&gt;        &lt;/div&gt;
&lt;br /&gt;    &lt;/div&gt;
&lt;br /&gt;  &lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;p&gt;To disable them again, run this query&lt;/p&gt;
&lt;br /&gt;&lt;div&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div&gt;&lt;strong&gt;SQL:&lt;/strong&gt;
&lt;br /&gt;  &lt;div id="sql-2"&gt;
&lt;br /&gt;      &lt;div&gt;
&lt;br /&gt;        &lt;div&gt;UPDATE core_config_data SET value = 0 WHERE scope = 'default' AND scope_id = 0 AND path ='dev/debug/template_hints' &lt;/div&gt;
&lt;br /&gt;    &lt;/div&gt;
&lt;br /&gt;  &lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;p&gt;To enable again run this query&lt;/p&gt;
&lt;br /&gt;&lt;div&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div&gt;&lt;strong&gt;SQL&lt;/strong&gt;:
&lt;br /&gt;  &lt;div id="sql-3"&gt;
&lt;br /&gt;      &lt;div&gt;
&lt;br /&gt;        &lt;div&gt;UPDATE core_config_data SET value = 1 WHERE scope = 'default' AND scope_id = 0 AND path ='dev/debug/template_hints' &lt;/div&gt;
&lt;br /&gt;    &lt;/div&gt;
&lt;br /&gt;  &lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Back Up and Restore a MySQL Database</title><link>http://phpfunda.blogspot.com/2009/10/back-up-and-restore-mysql-database.html</link><category>Article</category><category>Code</category><category>Free Code</category><category>MySQL</category><author>noreply@blogger.com (Unknown)</author><pubDate>Sat, 10 Oct 2009 01:01:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-8588634281230444872</guid><description>&lt;p&gt;&lt;strong&gt;Back up From the Command Line (using mysqldump)&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If you have shell or telnet access to your web server, you can  backup your MySQL data by using the mysqldump command. This&amp;nbsp;command  connects to the MySQL server and creates an SQL dump file. The dump  file contains the SQL statements necessary to re-create the database.  Here is the proper syntax: &lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysqldump --opt -u [uname] -p[pass] [dbname] &amp;gt; [backupfile.sql]&lt;/div&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;&lt;strong&gt;[uname]&lt;/strong&gt; Your database username &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&lt;strong&gt;[pass]&lt;/strong&gt; The password for your database (note there is no space between -p and the password) &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&lt;strong&gt;[dbname]&lt;/strong&gt; The name of your database &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&lt;strong&gt;[backupfile.sql]&lt;/strong&gt; The filename for your database backup &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&lt;strong&gt;[--opt]&lt;/strong&gt; The mysqldump option &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;For example, to backup a database named 'Tutorials' with the  username 'root' and&amp;nbsp;with no password&amp;nbsp;to a file tut_backup.sql, you  should accomplish this command:&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysqldump&amp;nbsp;-u root -p Tutorials &amp;gt; tut_backup.sql&lt;/div&gt;&lt;br /&gt;&lt;p&gt;This command will backup the 'Tutorials' database into a file called  tut_backup.sql which will contain all the SQL statements needed to  re-create the database. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;With mysqldump command you can specify certain tables of your  database you want to backup. For example, to back up only&amp;nbsp;php_tutorials  and&amp;nbsp;asp_tutorials tables from the 'Tutorials' database accomplish the  command below.&amp;nbsp;Each table name has to be separated by space.&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysqldump&amp;nbsp;-u root -p Tutorials php_tutorials asp_tutorials &amp;gt; tut_backup.sql&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Sometimes it is necessary to back up more that one database at once.  In this case you can use the --database option followed by the list of  databases you would like to backup. Each database name has to be  separated by space.&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysqldump -u root -p --databases&amp;nbsp;Tutorials&amp;nbsp;Articles Comments &amp;gt; content_backup.sql &lt;/div&gt;&lt;br /&gt;&lt;p&gt;If you want to&amp;nbsp;back up all the databases in the server at&amp;nbsp;one  time&amp;nbsp;you should use the --all-databases option. It tells MySQL to dump  all the databases it has in storage.&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysqldump -u root -p --all-databases &amp;gt; alldb_backup.sql &lt;/div&gt;&lt;br /&gt;&lt;p&gt;The mysqldump&amp;nbsp;command has also some&amp;nbsp;other useful options:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;--add-drop-table:&lt;/strong&gt; Tells MySQL to add a DROP TABLE statement before each CREATE TABLE in the dump.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;--no-data:&lt;/strong&gt; Dumps only the database structure, not the contents. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;--add-locks:&lt;/strong&gt; Adds the LOCK TABLES and UNLOCK TABLES statements you can see in the dump file.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The mysqldump command has advantages and disadvantages. The  advantages of using mysqldump are that it is simple to use and it takes  care of table locking issues for you. The disadvantage is that the  command locks tables. If the size of your tables is very  big&amp;nbsp;mysqldump&amp;nbsp;can lock out users for a long period of time.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a name="compress"&gt;&lt;/a&gt;&lt;strong&gt;Back up your MySQL Database with Compress&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If your mysql database is very big, you might want to compress the  output of mysqldump. Just use the mysql backup command below and pipe  the output to gzip, then you will get the output as gzip file.&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysqldump -u [uname]&amp;nbsp;-p[pass] [dbname] | gzip -9 &amp;gt; [backupfile.sql.gz]&lt;/div&gt;&lt;br /&gt;&lt;p&gt;If you want to extract the .gz file, use the command below:&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ gunzip [backupfile.sql.gz]&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;a name="restore"&gt;&lt;/a&gt;&lt;strong&gt;Restoring your MySQL Database&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Above we backup the Tutorials database into tut_backup.sql file.&amp;nbsp;To  re-create the Tutorials database you should follow two steps:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;Create an appropriately named database on the target machine &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Load the file using the mysql command:&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div&gt;$ mysql -u [uname] -p[pass] [db_to_restore] &amp;lt; [backupfile.sql]&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Have a look how you can restore your tut_backup.sql file to the Tutorials database.&lt;/p&gt;&lt;br /&gt;&lt;div&gt;$ mysql -u&amp;nbsp;root -p Tutorials &amp;lt; tut_backup.sql&lt;/div&gt;&lt;br /&gt;&lt;p&gt;To restore compressed backup files you can do the following:&lt;/p&gt;&lt;br /&gt;&lt;div&gt;gunzip &amp;lt; [backupfile.sql.gz] | mysql -u&amp;nbsp;[uname] -p[pass] [dbname]&lt;/div&gt;&lt;br /&gt;&lt;p&gt;If you need to restore a database that already exists, you'll need  to use mysqlimport command. The syntax for mysqlimport is as follows:&lt;/p&gt;&lt;br /&gt;&lt;div&gt;mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql]&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>Disable the Enter key on HTML form</title><link>http://phpfunda.blogspot.com/2009/10/disable-enter-key-on-html-form.html</link><category>Code</category><category>Free Code</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Sat, 10 Oct 2009 00:53:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-2585215025516886951</guid><description>&lt;p&gt;&lt;br /&gt;&lt;strong&gt;How to disable the Enter key on HTML form&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Normally when you have a form with several text input fields, it is  undesirable that the form gets submitted when the user hits ENTER in a  field. Some people are pressing the enter key instead of the tab key to  get to the next field. They often do that by accident or  they  are accustomed to terminate field input that way. If a browser regards  hitting ENTER in a text input field as a request to submit the form  immediately, there is no sure way to prevent that. &lt;/p&gt;&lt;br /&gt;                  &lt;p&gt;Add the below script to the &amp;lt;head&amp;gt; section of your page. The  following code disables the enter key so that visitors of your web page  can only use the tab key to get to the next field. &lt;/p&gt;&lt;br /&gt;              &lt;div&gt;&amp;lt;script type="text/javascript"&amp;gt; &lt;br&gt;&lt;br /&gt;                  &lt;br&gt;&lt;br /&gt;                function stopRKey(evt) { &lt;br&gt;&lt;br /&gt;                &amp;nbsp; var evt = (evt) ? evt : ((event) ? event : null); &lt;br&gt;&lt;br /&gt;                &amp;nbsp; var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); &lt;br&gt;&lt;br /&gt;                &amp;nbsp; if ((evt.keyCode == 13) &amp;amp;&amp;amp; (node.type=="text"))&amp;nbsp; {return false;} &lt;br&gt;&lt;br /&gt;                } &lt;br&gt;&lt;br /&gt;                &lt;br&gt;&lt;br /&gt;                document.onkeypress = stopRKey; &lt;br&gt;&lt;br /&gt;                &lt;br&gt;&lt;br /&gt;                &amp;lt;/script&amp;gt; &lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Flash image upload with PHP</title><link>http://phpfunda.blogspot.com/2009/10/flash-image-upload-with-php.html</link><category>Article</category><category>Code</category><category>Example</category><category>Free Code</category><category>PHP</category><author>noreply@blogger.com (Unknown)</author><pubDate>Wed, 7 Oct 2009 05:53:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-6053094506959253704</guid><description>&lt;strong&gt;Flash Code&lt;/strong&gt;&lt;br /&gt;&lt;pre dir="ltr"&gt;System.security.allowDomain("www.tshirtsetc.co.uk");  import flash.net.FileReference;    // The listener object listens for FileReference events.  var listener:Object = new Object();    listener.onSelect = function(selectedFile:FileReference):Void {      upWin._x = 200;    selectedFile.upload("./upload.php");  };    // the file is starting to upload.  listener.onOpen = function(selectedFile:FileReference):Void {    _root.upWin.results_txt.text = String("Uploading " + selectedFile.name + "\n");  };    listener.onHTTPError = function(file:FileReference, httpError:Number):Void {      _root.upWin.results_txt.text = String("HTTPError number: "+httpError +"\nFile: "+ file.name);  }    listener.onIOError = function(file:FileReference):Void {   _root.upWin.results_txt.text = String("IOError: "+ file.name);  }    listener.onSecurityError = function(file:FileReference, errorString:String):Void {      _root.upWin.results_txt.text = String("SecurityError: "+SecurityError+"\nFile: "+ file.name);      }    listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {   upWin.loadBar._width = Number(bytesLoaded)/Number(bytesTotal)*300;  }    // the file has uploaded  listener.onComplete = function(selectedFile:FileReference):Void {    upWin.results_txt.text = String("Upload finished.\nNow downloading " + selectedFile.name + " to player\n");        if(position_txt.text == String("Front")){    attachMovie("trans", "transHolder", -16161, {_x:150, _y:120});     downloadImage1(selectedFile.name);    }else{    if(position_txt.text == String("Back")){     attachMovie("trans2", "transHolder2", -16162, {_x:450, _y:120});       downloadImage2(selectedFile.name);    }else{    if(position_txt.text == String("LSleeve")){     attachMovie("trans3", "transHolder3", -16163, {_x:150, _y:120});       downloadImage3(selectedFile.name);    }else{    if(position_txt.text == String("RSleeve")){     attachMovie("trans4", "transHolder4", -16164, {_x:450, _y:120});       downloadImage4(selectedFile.name);    }    }    }    }    Itotal_txt.text = Number(3.00);    _root.upWin._x = 2000;  };    var imageFile:FileReference = new FileReference();  imageFile.addListener(listener);     imageMovie.uploadBtn.onPress = uploadImage;  imageMovie.uploadBtn2.onPress = uploadImage;  imageMovie2.uploadBtn3.onPress = uploadImage;  imageMovie2.uploadBtn4.onPress = uploadImage;    // Call the uploadImage() function, opens a file browser dialog.  function uploadImage(event:Object):Void {    imageFile.browse([{description: "Image Files", extension: "*.jpg;*.gif;*.png"}]);  }    // If the image does not download, the event object's total property  // will equal -1. In that case, display am error message  function imageDownloaded(event:Object):Void {    if(event.total == -1) {      _root.upWin.results_txt.text = String("error");        }  }    // show uploaded image in scrollPane  function downloadImage1(file:Object):Void {   transHolder.umbongo.loadMovie("./uploaded/" + file);  }    // show uploaded image in scrollPane  function downloadImage2(file:Object):Void {   transHolder2.umbongo2.loadMovie("./uploaded/" + file);  }    // show uploaded image in scrollPane  function downloadImage3(file:Object):Void {   transHolder3.umbongo3.loadMovie("./uploaded/" + file);  }    // show uploaded image in scrollPane  function downloadImage4(file:Object):Void {   var randomNum:Number = Math.round(Math.random()*(10000-0))+0;   transHolder4.umbongo4.loadMovie("./uploaded/" + file);  }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Server Side - PHP Code&lt;/strong&gt;&lt;br /&gt;&lt;pre dir="ltr"&gt;&amp;lt;?php    move_uploaded_file($_FILES['Filedata']['tmp_name'], './uploaded/'.$_FILES['Filedata']['name']);  copy('./uploaded/'.$_FILES['Filedata']['name'], './timeStamped/'.time().$_FILES['Filedata']['name']);    ?&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For more information goto http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001054.html</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Understanding mod_rewrite Directives Convertion</title><link>http://phpfunda.blogspot.com/2009/10/understanding-modrewrite-directives.html</link><category>Apache</category><category>Article</category><category>Free Code</category><category>Mod Rewrite</category><category>SEO</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 6 Oct 2009 03:14:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-4459749791042695434</guid><description>&lt;span style="font-weight:bold;"&gt;Converting mod_rewrite directives&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt; &lt;span style="font-weight:bold;"&gt; Overview&lt;/span&gt;&lt;br /&gt;  &lt;p&gt; The URL Rewriting engine in Abyss Web Server is comparable to the  mod_rewrite module in Apache. Both offer similar features but they are  not fully equivalent. &lt;/p&gt;&lt;br /&gt;  &lt;p&gt; This article explains how to convert  mod_rewrite directives to URL Rewriting parameters in Abyss Web Server.  In most cases, the conversion straightforward. But in some rare cases,  and for some of the most obscure features of mod_rewrite, conversion is  possible provided that you change or &lt;em&gt;rewrite&lt;/em&gt; the rules. &lt;/p&gt;&lt;br /&gt;  &lt;h3&gt;mod_rewrite directives syntax&lt;/h3&gt;&lt;br /&gt;  &lt;p&gt; mod_rewrite directives are put in .htaccess files (in subdirectories) or in the main configuration file httpd.conf. &lt;/p&gt;&lt;br /&gt;  &lt;p&gt; The following directives are related to mod_rewrite and will be used for conversions: &lt;/p&gt;&lt;br /&gt;  &lt;p&gt; RewriteBase&lt;br&gt;&lt;br /&gt;    RewriteCond&lt;br&gt;&lt;br /&gt;    RewriteRule&lt;/p&gt;&lt;br /&gt;  &lt;p&gt; A typical configuration of mod_rewrite looks as follows: &lt;/p&gt;&lt;br /&gt;  &lt;p&gt; # Some comments&lt;br&gt;&lt;br /&gt;    RewriteBase&amp;nbsp;&lt;em&gt;PATH&lt;/em&gt;&lt;br&gt;&lt;br /&gt;    &lt;br&gt;&lt;br /&gt;    RewriteCond %{&lt;em&gt;VARIABLE1&lt;/em&gt;}&amp;nbsp;&lt;em&gt;CONDITION1&lt;/em&gt;&lt;br&gt;&lt;br /&gt;    RewriteCond %{&lt;em&gt;VARIABLE2&lt;/em&gt;}&amp;nbsp;&lt;em&gt;CONDITION2&lt;/em&gt;&lt;br&gt;&lt;br /&gt;    RewriteRule&amp;nbsp;&lt;em&gt;REGEX&lt;/em&gt;&amp;nbsp;&lt;em&gt;REPLACEMENT&lt;/em&gt;&amp;nbsp;[&lt;em&gt;FLAGS&lt;/em&gt;]&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;RewriteBase is optional. By default, the base path is the current location of the directory where the .htaccess file is. Each time a RewriteRule is found, the base path is updated with the parameter following the directive. The base path is useful when processing RewriteRule parameters. &lt;/p&gt;&lt;br /&gt;  &lt;p&gt;RewriteCond is also optional. 0 or more RewriteCond directives can precede a given RewriteRule declaration. &lt;/p&gt;&lt;br /&gt;  &lt;p&gt;RewriteRule is mandatory and ends the declaration of a rule. More sequences of RewriteBase/RewriteCond/RewriteRule could follow to define other rules. &lt;/p&gt;&lt;br /&gt;  &lt;p&gt; Lines which start with #  are comments and should be ignored. Lines referencing other directives  are also to be ignored during the conversion as they are not related to  mod_rewrite. &lt;/p&gt;&lt;br /&gt;  &lt;h3&gt;Starting the conversion&lt;/h3&gt;&lt;br /&gt;  &lt;p&gt; For each RewriteRule directive, you should create a URL Rewriting rule. &lt;/p&gt;&lt;br /&gt;  &lt;ul&gt;&lt;br /&gt;    &lt;li&gt; Locate the RewriteRule you'll convert. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; Locate  all the RewriteCond directives that precede it directly (there are 0 or more of them). &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; Locate the last RewriteBase directive preceding the RewriteRule you'll convert. You may not find a RewriteBase in some cases. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; If you've found a RewriteBase  directive, the base path of the current rule will be the path that is  referenced in that directive. Otherwise, the base path is the virtual  path of the directory where the .htaccess file you're converting is located. For example, if there is no RewriteBase, if the .htaccess file you're converting is inside C:\sites\firstsite\forum, and if your &lt;strong&gt;Documents Path&lt;/strong&gt; is C:\sites\firstsite\, then the base path is /forum. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; Now open Abyss Web Server console, press the &lt;strong&gt;Configure&lt;/strong&gt; associated with the host you'll add the URL rewriting rules to, and select &lt;strong&gt;URL Rewriting&lt;/strong&gt;. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; Press &lt;strong&gt;Add&lt;/strong&gt; in &lt;strong&gt;URL Rewriting rules&lt;/strong&gt; table to create a new rule. &lt;/li&gt;&lt;br /&gt;  &lt;/ul&gt;&lt;br /&gt;  &lt;h3&gt;Conversion of the RewriteRule directive&lt;/h3&gt;&lt;br /&gt;  &lt;ul&gt;&lt;br /&gt;    &lt;li&gt; The RewriteRule directive has the following syntax:&lt;br /&gt;      &lt;p&gt; RewriteRule&amp;nbsp;&lt;em&gt;REGEX&lt;/em&gt;&amp;nbsp;&lt;em&gt;REPLACEMENT&lt;/em&gt;&amp;nbsp;[&lt;em&gt;FLAGS&lt;/em&gt;] &lt;/p&gt;&lt;br /&gt;      [&lt;em&gt;FLAGS&lt;/em&gt;] is optional an may not be always present. &lt;br&gt;&lt;br /&gt;      &lt;em&gt;REGEX&lt;/em&gt; is a regular expression. If it starts with ^ but the next character is not /,  the regular expression is referencing a relative path. In such a case,  you must prepend it with the base path of the rule before using it in  Abyss Web Server. &lt;br&gt;&lt;br /&gt;      For example, if the base path is /forum and the RewriteRule directive is:&lt;br /&gt;      &lt;p&gt; RewriteRule ^test/(.*)$ index.php?testId=$1&lt;/p&gt;&lt;br /&gt;      then the regular expression we'll use will be:&lt;br /&gt;      &lt;p&gt; ^/forum/test/(.*)$&lt;/p&gt;&lt;br /&gt;      If &lt;em&gt;REPLACEMENT&lt;/em&gt; does not start with / and is not full URL (starting with http:// or similar), the base path should be prepended too. In the above example, the &lt;em&gt;REPLACEMENT&lt;/em&gt; that must be taken into account is:&lt;br /&gt;      &lt;p&gt; /forum/index.php?testId=$1&lt;/p&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; In the Abyss Web Server console, enter in &lt;strong&gt;Virtual Path Regular Expression&lt;/strong&gt; the regular expression used in RewriteRule (after prepending it with the base path if it starts with ^ but the next character is not /). &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; Enter in &lt;strong&gt;Redirect to&lt;/strong&gt; the replacement string used in RewriteRule (after prepending it with the base path if it does not start / and is not full URL). &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; If the RewriteRule directive has flags, convert each one of them as explained below:&lt;br /&gt;      &lt;dl&gt;&lt;br /&gt;        &lt;dt&gt;chain/C (chained with next rule)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; From Apache manual: "&lt;em&gt;This  flag chains the current rule with the next rule (which itself can be  chained with the following rule, and so on). This has the following  effect: if a rule matches, then processing continues as usual - the  flag has no effect. If the rule does not match, then all following  chained rules are skipped.&lt;/em&gt;" No direct conversion is possible unless you reorder your URL Rewriting rules and correctly set the &lt;strong&gt;Next Action&lt;/strong&gt; in Abyss Web Server for each rule. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;cookie/CO=&lt;em&gt;NAME&lt;/em&gt;:&lt;em&gt;VAL&lt;/em&gt;:&lt;em&gt;domain&lt;/em&gt;[:&lt;em&gt;lifetime&lt;/em&gt;[:&lt;em&gt;path&lt;/em&gt;]] (set cookie)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;env/E=VAR:VAL (set environment variable)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;forbidden/F (force URL to be forbidden)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;If this rule matches&lt;/strong&gt; to &lt;strong&gt;Report an error to the client&lt;/strong&gt; and set &lt;strong&gt;Status Code&lt;/strong&gt; to &lt;strong&gt;403 - Forbidden&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;gone/G (force URL to be gone)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;If this rule matches&lt;/strong&gt; to &lt;strong&gt;Report an error to the client&lt;/strong&gt; and set &lt;strong&gt;Status Code&lt;/strong&gt; to &lt;strong&gt;410 - Gone&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;last/L (last rule)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Next Action&lt;/strong&gt; to &lt;strong&gt;Stop matching&lt;/strong&gt;&lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;next/N (next round)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Next Action&lt;/strong&gt; to &lt;strong&gt;Stop matching&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;nocase/NC (no case)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Uncheck &lt;strong&gt;Case Sensitive&lt;/strong&gt;&lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;noescape/NE (no URI escaping of output)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Uncheck &lt;strong&gt;Escape Redirection Location&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;nosubreq/NS (not for internal sub-requests)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Uncheck &lt;strong&gt;Apply to subrequests too&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;proxy/P (force proxy)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;passthrough/PT (pass through to next handler)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;qsappend/QSA (query string append)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Check &lt;strong&gt;Append Query String&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;redirect/R[=&lt;em&gt;code&lt;/em&gt;] (force redirect)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;If this rule matches&lt;/strong&gt; to &lt;strong&gt;Perform an external redirection&lt;/strong&gt; and set &lt;strong&gt;Status Code&lt;/strong&gt; to the value of &lt;em&gt;code&lt;/em&gt; if available or to 302. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;skip/S=&lt;em&gt;num&lt;/em&gt; (skip next rule(s))&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; From Apache manual: "&lt;em&gt;This flag forces the rewriting engine to skip the next &lt;em&gt;num&lt;/em&gt; rules in sequence, if the current rule matches.&lt;/em&gt;" No direct conversion is possible unless you reorder your URL Rewriting rules and correctly set the &lt;strong&gt;Next Action&lt;/strong&gt; in Abyss Web Server for each rule. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;type/T=&lt;em&gt;MIME-type&lt;/em&gt; (force MIME type)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;      &lt;/dl&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;  &lt;/ul&gt;&lt;br /&gt;  &lt;h3&gt;Conversion of the RewriteCond directives&lt;/h3&gt;&lt;br /&gt;  &lt;p&gt; Now it's time to convert the RewriteCond directives associated with the RewriteRule we're working on. Remember that only the RewriteCond immediately preceding the RewriteRule are to be taken into account. If there are no RewriteCond directives, conversion is over. &lt;/p&gt;&lt;br /&gt;  &lt;ul&gt;&lt;br /&gt;    &lt;li&gt; A RewriteCond directive has the form:&lt;br /&gt;      &lt;p&gt; RewriteCond %{&lt;em&gt;VARIABLE&lt;/em&gt;}&amp;nbsp;&lt;em&gt;COND&lt;/em&gt;&amp;nbsp;[&lt;em&gt;FLAGS&lt;/em&gt;] &lt;/p&gt;&lt;br /&gt;      If the first argument of the RewriteCond you're converting contains a string which is not conforming to the syntax %{&lt;em&gt;VARIABLE&lt;/em&gt;}, it will be impossible to convert the mod_rewrite rule to an Abyss Web Server URL Rewriting rule. &lt;br&gt;&lt;br /&gt;      [&lt;em&gt;FLAGS&lt;/em&gt;] are optional and may not be always present. &lt;br&gt;&lt;br /&gt;      For each RewriteCond, press &lt;strong&gt;Add&lt;/strong&gt; in the &lt;strong&gt;Conditions&lt;/strong&gt; table and enter the value of VARIABLE in the &lt;strong&gt;Variable&lt;/strong&gt; field. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; If &lt;em&gt;COND&lt;/em&gt; is a regular expression preceded by !, select &lt;strong&gt;Does not match with&lt;/strong&gt; in &lt;strong&gt;Operator&lt;/strong&gt;. If it is a regular expression not preceded by !, set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Matches with&lt;/strong&gt;. Next enter the regular expression in &lt;strong&gt;Regular Expression&lt;/strong&gt; field. &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; Otherwise, &lt;em&gt;COND&lt;/em&gt; is one of the following tests:&lt;br /&gt;      &lt;dl&gt;&lt;br /&gt;        &lt;dt&gt;&amp;lt;&lt;em&gt;VALUE&lt;/em&gt; (lexicographically precedes)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;&amp;lt;&lt;/strong&gt; and enter &lt;em&gt;VALUE&lt;/em&gt; in the field &lt;strong&gt;Value&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;!&amp;lt;&lt;em&gt;VALUE&lt;/em&gt;&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;&amp;gt;=&lt;/strong&gt; and enter &lt;em&gt;VALUE&lt;/em&gt; in the field &lt;strong&gt;Value&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;&amp;gt;&lt;em&gt;VALUE&lt;/em&gt; (lexicographically follows)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;&amp;gt;&lt;/strong&gt; and enter &lt;em&gt;VALUE&lt;/em&gt; in the field &lt;strong&gt;Value&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;!&amp;gt;&lt;em&gt;VALUE&lt;/em&gt;&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;&amp;lt;=&lt;/strong&gt; and enter &lt;em&gt;VALUE&lt;/em&gt; in the field &lt;strong&gt;Value&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;=&lt;em&gt;VALUE&lt;/em&gt; (lexicographically equal)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;=&lt;/strong&gt; and enter &lt;em&gt;VALUE&lt;/em&gt; in the field &lt;strong&gt;Value&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;!=&lt;em&gt;VALUE&lt;/em&gt;&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Is different from&lt;/strong&gt; and enter &lt;em&gt;VALUE&lt;/em&gt; in the field &lt;strong&gt;Value&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;-d (is directory)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Is a directory&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;!-d&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Is not a directory&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;-f (is regular file)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Is a file&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;!-f&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Is not a file&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;-s (is regular file, with size)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Exists and is not an empty file&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;!-s&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Set &lt;strong&gt;Operator&lt;/strong&gt; to &lt;strong&gt;Does not exist and is an empty file&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;-l/!-l (is/isn't symbolic link)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;-F/!-F (is/isn't existing file, via subrequest)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;-U/!-U (is/isn't existing URL, via subrequest)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; No equivalent in Abyss Web Server. &lt;/dd&gt;&lt;br /&gt;      &lt;/dl&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;    &lt;li&gt; If &lt;em&gt;FLAGS&lt;/em&gt; are present, their conversion should be done as follows:&lt;br /&gt;      &lt;dl&gt;&lt;br /&gt;        &lt;dt&gt;nocase/NC (no case)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; Uncheck &lt;strong&gt;Case Sensitive&lt;/strong&gt;. &lt;/dd&gt;&lt;br /&gt;        &lt;dt&gt;ornext/OR (or next condition)&lt;/dt&gt;&lt;br /&gt;        &lt;dd&gt; The only case where a direct conversion is possible is when you have two or more consecutive RewriteCond operating on the same variable. In such a case, the regular expressions of each condition have to be concatenated with a | sign. For example:&lt;br /&gt;          &lt;p&gt; RewriteCond %{HTTP_USER_AGENT}  Mozilla  [OR]&lt;br&gt;&lt;br /&gt;            RewriteCond %{HTTP_USER_AGENT}  Opera  [OR]&lt;br&gt;&lt;br /&gt;            RewriteCond %{HTTP_USER_AGENT}  Lynx &lt;/p&gt;&lt;br /&gt;          could be combined in a single RewriteCond:&lt;br /&gt;          &lt;p&gt; RewriteCond %{HTTP_USER_AGENT}  Mozilla|Opera|Lynx &lt;/p&gt;&lt;br /&gt;          and thus it suffices to have a single condition on variable HTTP_USER_AGENT which checks if its value matches with  Mozilla|Opera|Lynx. &lt;/dd&gt;&lt;br /&gt;      &lt;/dl&gt;&lt;br /&gt;    &lt;/li&gt;&lt;br /&gt;  &lt;/ul&gt;&lt;br /&gt;&lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Mod-Rewrite Tricks and Tips - .Htaccess rewrites rules</title><link>http://phpfunda.blogspot.com/2009/10/mod-rewrite-tricks-and-tips-htaccess.html</link><category>Apache</category><category>Article</category><category>Example</category><category>Free Code</category><category>SEO</category><category>tips</category><category>Web crawler</category><author>noreply@blogger.com (Unknown)</author><pubDate>Mon, 5 Oct 2009 03:56:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-6543844279050099495</guid><description>&lt;style&gt;&lt;br /&gt;pre{letter-spacing:normal; word-spacing:normal; text-transform:none; color:#000; border:1px solid #333; font-family:Consolas,Monaco,"Courier New",Courier,monospace; background:#F0F0F0 none repeat scroll 0 0; padding:11px; font-size:11px; line-height:1.5; white-space:pre-wrap; max-width:100%; overflow:auto; margin:1.5em 0}pre.pre{white-space:pre}pre.normal{white-space:normal}pre.prenowrap{white-space:nowrap}pre.prewrap{white-space:pre}pre.preline{white-space:pre}&lt;br /&gt;&lt;br /&gt;pre{background-color:#eaeaf9; border:1px dotted #bfbfcc}dl pre.a{background:#eaf9ea; border:1px dotted #a4aea4}&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you really want to take a look, check out the &lt;strong&gt;mod_rewrite.c&lt;/strong&gt; and &lt;strong&gt;mod_rewrite.h&lt;/strong&gt; files.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Be aware that mod_rewrite (&lt;em&gt;RewriteRule, RewriteBase, and RewriteCond&lt;/em&gt;)  code is executed for each and every HTTP request that accesses a file  in or below the directory where the code resides, so it&amp;rsquo;s always good  to limit the code to certain circumstances if readily identifiable.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;For example&lt;/strong&gt;, to limit the next 5 RewriteRules to  only be applied to .html and .php files, you can use the following  code, which tests if the url does not end in .html or .php and if it  doesn&amp;rsquo;t, it will skip the next 5 RewriteRules.&lt;/p&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;pre&gt;RewriteRule !\.(html|php)$ - [S=5]  &lt;br /&gt;RewriteRule ^.*-(vf12|vf13|vf5|vf35|vf1|vf10|vf33|vf8).+$ - [S=1]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;.htaccess rewrite examples should begin with:&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;Options +FollowSymLinks  &amp;nbsp;  &lt;br /&gt;RewriteEngine On  RewriteBase /  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Require the www&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;Options +FollowSymLinks &lt;br /&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com$ [NC]  &lt;br /&gt;RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Loop Stopping Code&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Sometimes your rewrites cause infinite loops, stop it with one of these rewrite code snippets.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]  &lt;br /&gt;RewriteRule .* - [L]  &amp;nbsp;  &lt;br /&gt;RewriteCond %{ENV:REDIRECT_STATUS} 200  &lt;br /&gt;RewriteRule .* - [L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Cache-Friendly File Names&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;This is probably my favorite, and I use it on every site I work on.  It allows me to update my javascript and css files in my visitors  cache&amp;rsquo;s simply by naming them differently in the html, on the server  they stay the same name. This rewrites all files for /zap/j/anything-anynumber.js to /zap/j/anything.js and /zap/c/anything-anynumber.css to /zap/c/anything.css&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteRule ^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;SEO friendly link for non-flash browsers&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;When you use flash on your site and you properly supply a link to  download flash that shows up for non-flash aware browsers, it is nice  to use a shortcut to keep your code clean and your external links to a  minimum. This code allows me to link to site.com/getflash/ for non-flash aware browsers.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteRule ^getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash [NC,L,R=307]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Removing the Query_String&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;On many sites, the page will be displayed for both page.html and  page.html?anything=anything, which hurts your SEO with duplicate  content. An easy way to fix this issue is to redirect external requests  containing a query string to the same uri without the query_string.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/  &lt;br /&gt;RewriteCond %{QUERY_STRING} !^$  &lt;br /&gt;RewriteRule .* http://www.askapache.com%{REQUEST_URI}? [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Sending requests to a php script&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;This .htaccess rewrite example invisibly rewrites requests for all Adobe pdf files to be handled by /cgi-bin/pdf-script.php&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteRule ^(.+)\.pdf$  /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Setting the language variable based on Client&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;For sites using multiviews or with multiple language capabilities,  it is nice to be able to send the correct language automatically based  on the clients preferred language.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteCond %{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]  &lt;br /&gt;RewriteRule ^(.*)$ - [env=prefer-language:%1]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Deny Access To Everyone Except PHP fopen&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;This allows access to all files by php fopen, but denies anyone else.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{THE_REQUEST} ^.+$ [NC]  &lt;br /&gt;RewriteRule .* - [F,L]  &lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If you are looking for ways to block or deny specific requests/visitors, then you should definately read &lt;a href="http://perishablepress.com/press/2009/02/03/eight-ways-to-blacklist-with-apaches-mod_rewrite/" title="Eight Ways to Blacklist with Apache&amp;rsquo;s mod_rewrite"&gt;Blacklist with mod_rewrite&lt;/a&gt;.  I give it a 10/10&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Deny access to anything in a subfolder except php fopen&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;This can be very handy if you want to serve media files or special downloads but only through a php proxy script.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]  &lt;br /&gt;RewriteRule .* - [F,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Require no www&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;Options +FollowSymLinks  &lt;br /&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{HTTP_HOST} !^yourdomain\.com$ [NC]  &lt;br /&gt;RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Check for a key in QUERY_STRING&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Uses a RewriteCond Directive to check QUERY_STRING for passkey, if it doesn&amp;rsquo;t find it it  redirects all requests for anything in the /logged-in/ directory to the  /login.php script.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  RewriteBase /  &lt;br /&gt;RewriteCond %{QUERY_STRING} !passkey  &lt;br /&gt;RewriteRule ^/logged-in/(.*)$ /login.php [L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Removes the QUERY_STRING from the URL&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;If the QUERY_STRING has any value at all besides blank than the?at the end of /login.php? tells mod_rewrite to remove the QUERY_STRING from login.php and redirect.&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  RewriteBase /  &lt;br /&gt;RewriteCond %{QUERY_STRING} .  &lt;br /&gt;RewriteRule ^login.php /login.php? [L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Fix for infinite loops&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;An error message related to this isRequest exceeded the limit  of 10 internal redirects due to probable configuration error. Use  'LimitInternalRecursion' to increase the limit if necessary. Use  'LogLevel debug' to get a backtrace.or you may seeRequest exceeded the limit,probable configuration error,Use 'LogLevel debug' to get a backtrace, orUse 'LimitInternalRecursion' to increase the limit if necessary&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteCond %{ENV:REDIRECT_STATUS} 200  &lt;br /&gt;RewriteRule .* - [L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;External Redirect .php files to .html files (SEO friendly)&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteRule ^(.*)\.php$ /$1.html [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Internal Redirect .php files to .html files (SEO friendly)&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Redirects all files that end in .html to be served from filename.php  so it looks like all your pages are .html but really they are .php&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;RewriteRule ^(.*)\.html$ $1.php [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;block access to files during certain hours of the day&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;Options +FollowSymLinks  &lt;br /&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;# If the hour is 16 (4 PM) Then deny all access  &lt;br /&gt;RewriteCond %{TIME_HOUR} ^16$  &lt;br /&gt;RewriteRule ^.*$ - [F,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Rewrite underscores to hyphens for SEO URL&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;Options +FollowSymLinks  &lt;br /&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &amp;nbsp;  &lt;br /&gt;RewriteRule !\.(html|php)$ - [S=4]  &lt;br /&gt;RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]  &lt;br /&gt;RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]  &lt;br /&gt;RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]  &lt;br /&gt;RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]  &amp;nbsp;  &lt;br /&gt;RewriteCond %{ENV:uscor} ^Yes$  &lt;br /&gt;RewriteRule (.*) http://d.com/$1 [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Require the www without hardcoding&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;Options +FollowSymLinks  &lt;br /&gt;RewriteEngine On  RewriteBase /  &lt;br /&gt;RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]  &lt;br /&gt;RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$     [NC]  &lt;br /&gt;RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Require no subdomain&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{HTTP_HOST} \.([a-z-]+\.[a-z]{2,6})$ [NC]  &lt;br /&gt;RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Require no subdomain&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{HTTP_HOST} \.([^\.]+\.[^\.0-9]+)$  &lt;br /&gt;RewriteRule ^(.*)$ http://%1/$1 [R=301,L]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Redirecting Wordpress Feeds to Feedburner&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{REQUEST_URI} ^/feed\.gif$  &lt;br /&gt;RewriteRule .* - [L]  &amp;nbsp;  &lt;br /&gt;RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]  &lt;br /&gt;RewriteRule ^feed/?.*$ http://feeds.feedburner.com/apache/htaccess [L,R=302]  &amp;nbsp;  &lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f  &lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-d  &lt;br /&gt;RewriteRule . /index.php [L] &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Only allow GET and PUT Request Methods&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{REQUEST_METHOD} !^(GET|PUT)  &lt;br /&gt;RewriteRule .* - [F]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Prevent Files image/file hotlinking and bandwidth stealing&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;RewriteBase /  &lt;br /&gt;RewriteCond %{HTTP_REFERER} !^$  &lt;br /&gt;RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]  &lt;br /&gt;RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]  &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Stop browser prefetching&lt;/h2&gt;&lt;br /&gt;&lt;pre&gt;RewriteEngine On  &lt;br /&gt;SetEnvIfNoCase X-Forwarded-For .+ proxy=yes  &lt;br /&gt;SetEnvIfNoCase X-moz prefetch no_access=yes  &amp;nbsp;  &lt;br /&gt;# block pre-fetch requests with X-moz headers  &lt;br /&gt;RewriteCond %{ENV:no_access} yes  &lt;br /&gt;RewriteRule .* - [F,L]  &lt;/pre&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>27 Apache Request Methods for rewritecond in htaccess</title><link>http://phpfunda.blogspot.com/2009/10/27-apache-request-methods-for.html</link><category>Apache</category><category>Article</category><category>Code</category><category>Mod Rewrite</category><category>SEO</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Mon, 5 Oct 2009 03:55:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-85864773765510143</guid><description>&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The Request Method, as supplied in the REQUEST_METHOD meta-variable,  identifies the processing method to be applied by the script in  producing a response.&lt;br&gt;&lt;br /&gt;The script author can choose to implement the methods most appropriate for the particular application.&lt;br&gt;&lt;br /&gt;If the script receives a request with a method it does not support it SHOULD reject it with an error.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;List of the 27 Request Methods Recognized by Apache&lt;/strong&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;GET&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;PUT&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;POST&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;DELETE&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;CONNECT&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;OPTIONS&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;TRACE&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;PATCH&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;PROPFIND&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;PROPPATCH&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;MKCOL&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;COPY&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;MOVE&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;LOCK&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;UNLOCK&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;VERSION_CONTROL&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;CHECKOUT&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;UNCHECKOUT&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;CHECKIN&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;UPDATE&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;LABEL&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;REPORT&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;MKWORKSPACE&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;MKACTIVITY&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;BASELINE_CONTROL&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;MERGE&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;INVALID&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;strong&gt;GET&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The GET method indicates that the script should produce a document  based on the meta-variable values. By convention, the GET method is  &amp;rsquo;safe&amp;rsquo; and &amp;lsquo;idempotent&amp;rsquo; and SHOULD NOT have the significance of taking  an action other than producing a document.&lt;br&gt;&lt;br /&gt;The meaning of the GET method may be modified and refined by protocol-specific meta-variables.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;POST&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The POST method is used to request the script perform processing and  produce a document based on the data in the request message-body, in  addition to meta-variable values. A common use is form submission in  HTML [18], intended to initiate processing by the script that has a  permanent affect, such a change in a database.&lt;br&gt;&lt;br /&gt;The script MUST check the value of the CONTENT_LENGTH variable  before reading the attached message-body, and SHOULD check the  CONTENT_TYPE value before processing it.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;HEAD&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The HEAD method requests the script to do sufficient processing to  return the response header fields, without providing a response  message-body. The script MUST NOT provide a response message-body for a  HEAD request. If it does, then the server MUST discard the message-body  when reading the response from the script.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;OPTIONS&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The OPTIONS method represents a request for information about the  communication options available on the request/response chain  identified by the Request-URI. This method allows the client to  determine the options and/or requirements associated with a resource,  or the capabilities of a server, without implying a resource action or  initiating a resource retrieval.&lt;br&gt;&lt;br /&gt;Responses to this method are not cacheable.&lt;br&gt;&lt;br /&gt;If the OPTIONS request includes an entity-body (as indicated by the  presence of Content-Length or Transfer-Encoding), then the media type  MUST be indicated by a Content-Type field. Although this specification  does not define any use for such a body, future extensions to HTTP  might use the OPTIONS body to make more detailed queries on the server.  A server that does not support such an extension MAY discard the  request body.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If the Request-URI is an asterisk (&amp;ldquo;*&amp;rdquo;), the OPTIONS request is  intended to apply to the server in general rather than to a specific  resource. Since a server&amp;rsquo;s communication options typically depend on  the resource, the &amp;ldquo;*&amp;rdquo; request is only useful as a &amp;ldquo;ping&amp;rdquo; or &amp;ldquo;no-op&amp;rdquo;  type of method; it does nothing beyond allowing the client to test the  capabilities of the server. For example, this can be used to test a  proxy for HTTP/1.1 compliance (or lack thereof). If the Request-URI is  not an asterisk, the OPTIONS request applies only to the options that  are available when communicating with that resource.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;A 200 response SHOULD include any header fields that indicate  optional features implemented by the server and applicable to that  resource (e.g., Allow), possibly including extensions not defined by  this specification. The response body, if any, SHOULD also include  information about the communication options. The format for such a body  is not defined by this specification, but might be defined by future  extensions to HTTP. Content negotiation MAY be used to select the  appropriate response format. If no response body is included, the  response MUST include a Content-Length field with a field-value of &amp;ldquo;0&amp;Prime;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The Max-Forwards request-header field MAY be used to target a  specific proxy in the request chain. When a proxy receives an OPTIONS  request on an absoluteURI for which request forwarding is permitted,  the proxy MUST check for a Max-Forwards field. If the Max-Forwards  field-value is zero (&amp;ldquo;0&amp;Prime;), the proxy MUST NOT forward the message;  instead, the proxy SHOULD respond with its own communication options.  If the Max-Forwards field-value is an integer greater than zero, the  proxy MUST decrement the field-value when it forwards the request. If  no Max-Forwards field is present in the request, then the forwarded  request MUST NOT include a Max-Forwards field. &lt;/p&gt;&lt;br /&gt;&lt;strong&gt;PUT&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The PUT method requests that the enclosed entity be stored under the  supplied Request-URI. If the Request-URI refers to an already existing  resource, the enclosed entity SHOULD be considered as a modified  version of the one residing on the origin server. If the Request-URI  does not point to an existing resource, and that URI is capable of  being defined as a new resource by the requesting user agent, the  origin server can create the resource with that URI. If a new resource  is created, the origin server MUST inform the user agent via the 201  (Created) response. If an existing resource is modified, either the 200  (OK) or 204 (No Content) response codes SHOULD be sent to indicate  successful completion of the request. If the resource could not be  created or modified with the Request-URI, an appropriate error response  SHOULD be given that reflects the nature of the problem. The recipient  of the entity MUST NOT ignore any Content-* (e.g. Content-Range)  headers that it does not understand or implement and MUST return a 501  (Not Implemented) response in such cases.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If the request passes through a cache and the Request-URI identifies  one or more currently cached entities, those entries SHOULD be treated  as stale. Responses to this method are not cacheable.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The fundamental difference between the POST and PUT requests is  reflected in the different meaning of the Request-URI. The URI in a  POST request identifies the resource that will handle the enclosed  entity. That resource might be a data-accepting process, a gateway to  some other protocol, or a separate entity that accepts annotations. In  contrast, the URI in a PUT request identifies the entity enclosed with  the request &amp;mdash; the user agent knows what URI is intended and the server  MUST NOT attempt to apply the request to some other resource. If the  server desires that the request be applied to a different URI, it MUST  send a 301 (Moved Permanently) response; the user agent MAY then make  its own decision regarding whether or not to redirect the request.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;A single resource MAY be identified by many different URIs. For  example, an article might have a URI for identifying &amp;ldquo;the current  version&amp;rdquo; which is separate from the URI identifying each particular  version. In this case, a PUT request on a general URI might result in  several other URIs being defined by the origin server.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;HTTP/1.1 does not define how a PUT method affects the state of an origin server.&lt;br&gt;&lt;br /&gt;  PUT requests MUST obey the message transmission requirements.&lt;br&gt;&lt;br /&gt;Unless otherwise specified for a particular entity-header, the  entity-headers in the PUT request SHOULD be applied to the resource  created or modified by the PUT.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;DELETE&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The DELETE method requests that the origin server delete the  resource identified by the Request-URI. This method MAY be overridden  by human intervention (or other means) on the origin server. The client  cannot be guaranteed that the operation has been carried out, even if  the status code returned from the origin server indicates that the  action has been completed successfully. However, the server SHOULD NOT  indicate success unless, at the time the response is given, it intends  to delete the resource or move it to an inaccessible location.&lt;br&gt;&lt;br /&gt;A successful response SHOULD be 200 (OK) if the response includes an  entity describing the status, 202 (Accepted) if the action has not yet  been enacted, or 204 (No Content) if the action has been enacted but  the response does not include an entity.&lt;br&gt;&lt;br /&gt;If the request passes through a cache and the Request-URI identifies  one or more currently cached entities, those entries SHOULD be treated  as stale. Responses to this method are not cacheable.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;TRACE&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;The TRACE method is used to invoke a remote, application-layer loop-  back of the request message. The final recipient of the request SHOULD  reflect the message received back to the client as the entity-body of a  200 (OK) response. The final recipient is either the origin server or  the first proxy or gateway to receive a Max-Forwards value of zero (0)  in the request (see section 14.31). A TRACE request MUST NOT include an  entity.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;TRACE allows the client to see what is being received at the other  end of the request chain and use that data for testing or diagnostic  information. The value of the Via header field (section 14.45) is of  particular interest, since it acts as a trace of the request chain. Use  of the Max-Forwards header field allows the client to limit the length  of the request chain, which is useful for testing a chain of proxies  forwarding messages in an infinite loop.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If the request is valid, the response SHOULD contain the entire  request message in the entity-body, with a Content-Type of  &amp;ldquo;message/http&amp;rdquo;. Responses to this method MUST NOT be cached.&lt;/p&gt;&lt;br /&gt;&lt;strong&gt;CONNECT&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;This specification reserves the method name CONNECT for use with a  proxy that can dynamically switch to being a tunnel e.g. SSL tunneling.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>PHP Fatal error : Out of memory Problem</title><link>http://phpfunda.blogspot.com/2009/09/php-fatal-error-out-of-memory-problem.html</link><category>Apache</category><category>Article</category><category>Code</category><category>Ebook</category><category>Example</category><category>Free Code</category><category>Linux</category><category>PHP</category><category>SEO</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Wed, 2 Sep 2009 23:24:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-2637811885105469998</guid><description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;PHP Fatal error:  Out of memory&lt;/strong&gt;Problem. Let see how to solve this problem using various techniques. &lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The first thing I could think of was to restart the Apache &lt;em&gt;httpd &lt;/em&gt;service. This immediately solved the issue. but I knew this is not a permanent fix for the issue. When I researched further, I got to know that the  &lt;br /&gt;  error comes when certain PHP scripts require more memory than PHP was allowed by default.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So the &lt;strong&gt;solution is to increase the memory allocated&lt;/strong&gt; for&lt;br /&gt;  &lt;br /&gt;PHP. How to do that? There are 4 possible ways -&lt;/p&gt;&lt;br /&gt;&lt;p&gt;1. Try looking for the &lt;em&gt; php.ini&lt;/em&gt; file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say &amp;ldquo;check.php&amp;rdquo; and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in &lt;em&gt;/usr/local/lib/php.ini&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Open the php.ini file in a text editor like TextPad (not in Notepad) and change the values for &lt;em&gt;memory_limit&lt;/em&gt;.  By default you should see memory_limit = 8M. Try changing it to 12M. If  it doesn&amp;rsquo;t work, increase it to 16M or even 24M and so on.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;2. In case you can&amp;rsquo;t find the php.ini file or do not have access to it, then open up the file which was throwing the error (test.php in my case) and add a line below just after &lt;strong&gt;ini_set(&amp;rsquo;memory_limit&amp;rsquo;, lsquo;12M&amp;rsquo;);&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;3. You can even consider adding a line in &lt;em&gt;.htaccess&lt;/em&gt; file which will resolve the issue.&lt;br&gt; php_value memory_limit 32M&lt;/p&gt;&lt;br /&gt;&lt;p&gt;4. Or else, Try adding this line to your &lt;em&gt;wp-config.php&lt;/em&gt; file:&lt;br&gt;&lt;br /&gt;  Increasing memory allocated to PHP&lt;br&gt;define('WP_MEMORY_LIMIT', '32M');&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If none of the above things solve your issue, then talk to you host.&lt;br&gt;&lt;br /&gt;  &lt;br&gt; Note: I am now worrying on which PHP script required an increase in memory allocation. The analysis won&amp;rsquo;t be so easy though.&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">27</thr:total></item><item><title>Optimize MySQL response time Techniques</title><link>http://phpfunda.blogspot.com/2009/08/optimize-mysql-response-time-techniques.html</link><category>Article</category><category>Example</category><category>MySQL</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Sun, 16 Aug 2009 21:43:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-8631215290703294011</guid><description>&lt;p&gt;High loaded / Heavy Traffic website can get slow to respond when a lot of different  visitors visit sites querying the same mysql database server, making it  slow to respond.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;There is many ways you can improve mysql server response time: &lt;/p&gt;&lt;br /&gt;&lt;p&gt; - by modifying the cache size&lt;br /&gt;  - stopping dns resolution ....&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Let's see how to implement that.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Sometime it may happen when we got  troubles with our databases  system. The mysql servers were slow to respond, but when we were  logging into those machines, the load was fine, there were quite a few  queries going on, but mysql didn't report it was overwhelmed.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;1. Disable DNS Hostname Lookup&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;After seeking out the reason why the traffic wasn't going flawlessly,  we determine that the mysql server was doing loads of name resolution  queries!!!! What for? Why would that machine to a hostname resolution  when only local network machines connect to it.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Seeking out in mysqld manual page, we found that this could be disabled by adding the &lt;strong&gt;--skip-name-resolve&lt;/strong&gt; switch.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Under debian based system, such as ubuntu, knoppix ... and on most linux distribution, &lt;strong&gt;mysql configuration files&lt;/strong&gt; are located in &lt;strong&gt;/etc/mysql/my.cnf&lt;/strong&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In order to apply the --skip-name-resolve switch when you start &lt;strong&gt;mysqld&lt;/strong&gt;, simply add:&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  &lt;p&gt;[mysqld]&lt;br /&gt;    .....&lt;br /&gt;    ......&lt;br /&gt;    skip-name-resolve&lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;NOTE:&lt;/strong&gt; When this option is activated, you can &lt;strong&gt;only use IP numbers &lt;/strong&gt;in the &lt;strong&gt;MySQL Grant table&lt;/strong&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;With DNS hostname resolution:&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;div&gt;date; mysql -u root -h 192.168.1.4 ; date&lt;br /&gt;  Fri Jul 21 23:56:58 CEST 2006&lt;br /&gt;  ERROR 1130 (00000): Host '192.168.1.3' is not allowed to connect to this MySQL server&lt;br&gt;&lt;br /&gt;  Fri Jul 21 23:57:00 CEST 2006&lt;/div&gt;&lt;br /&gt;&lt;p&gt;it take 2-3 seconds before the server reply that the client IP is not allowed to connect.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Once DNS hostname lookup is disabled:&lt;/p&gt;&lt;br /&gt;&lt;div&gt;date; mysql -u root -h 192.168.1.4 ; date&lt;br&gt;&lt;br /&gt;  Fri Jul 21 23:56:37 CEST 2006&lt;br&gt;&lt;br /&gt;  ERROR 1130 (00000): Host '192.168.1.3' is not allowed to connect to this MySQL server&lt;br&gt;&lt;br /&gt;  Fri Jul 21 23:56:37 CEST 2006&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The server is replying instantly.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;2. Activate Query Cache&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;After we resolved that issue, we started seeing the database server  load increasing, the response time was good after the previous change,  but now, we had to lighten a bit the mysql database server's load.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;By checking the Query cache memory:&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  mysql&amp;gt; SHOW STATUS LIKE 'Qcache%';&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt; we could see that no query cache memory was  left. It was neccessary to increase the query cache size.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;To get an overview of your query_cache variables state, use the following syntax:&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  mysql&amp;gt;  SHOW VARIABLES LIKE '%query_cache%';&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt; You need to have the query cache enabled in the first place  (have_query_cache | YES) and make sure that query_cache_type is set to  ON. This is usually activated by default on most linux distribution.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Now, you can increase the query cache size (let say you want 50M) using:&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  mysql&amp;gt; SET GLOBAL query_cache_size = 52428800;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt; If you want this setting to be kept when restarting mysql, add:&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;  [mysqld]&lt;br /&gt;  ...&lt;br /&gt;  ...&lt;br /&gt;  query_cache_size        = 52428800;&lt;/p&gt;&lt;br /&gt;  query_cache_type        = 1&lt;/p&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;3. Summary:&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;After doing those changes, there were much more queries resolved  from the cache, the effect was that the server was responding quickly  without calculating too much has most of the queries where cached.&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Protecting Script using SQL injection For MySQL with PHP</title><link>http://phpfunda.blogspot.com/2009/06/protecting-script-using-sql-injection.html</link><category>Article</category><category>Code</category><category>Example</category><category>Free Code</category><category>MySQL</category><category>PHP</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Wed, 10 Jun 2009 06:03:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-7337601586406131440</guid><description>&lt;p&gt;If you are running a dynamic website coded in PHP, chances are you'll be using&lt;br /&gt;    MySQL for storing content or information.&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;MySQL is very well suited for running anything from small personal websites to large corporate&lt;br /&gt;    systems, as it is both simple to use and scalable.&amp;nbsp; However, it is easy to overlook potential&lt;br /&gt;    security problems, especially if you don't have much experience.&lt;/p&gt;&lt;br /&gt;  &lt;h3&gt;Example&lt;/h3&gt;&lt;br /&gt;  &lt;p&gt;For instance, you may have a login script for a secure page of your site: &lt;br&gt;&lt;br /&gt;      &lt;code&gt; &lt;br&gt;&lt;br /&gt;        &lt;span style="color: #0000BB"&gt;&amp;lt;?php &lt;br&gt;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #FF8000"&gt;#&amp;nbsp;Database&amp;nbsp;connection&amp;nbsp;code&amp;nbsp;here &lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;            &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$result&lt;/span&gt;&lt;span style="color: #007700"&gt;=&lt;/span&gt;&lt;span style="color: #0000BB"&gt;mysql_query&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;users&amp;nbsp;where &lt;br&gt;&lt;br /&gt;              &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;user="'&lt;/span&gt;&lt;span style="color: #007700"&gt;.&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$_POST&lt;/span&gt;&lt;span style="color: #007700"&gt;[&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'username'&lt;/span&gt;&lt;span style="color: #007700"&gt;].&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'"&amp;nbsp;and&amp;nbsp;pass="'&lt;/span&gt;&lt;span style="color: #007700"&gt;.&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$_POST&lt;/span&gt;&lt;span style="color: #007700"&gt;[&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'password'&lt;/span&gt;&lt;span style="color: #007700"&gt;].&lt;/span&gt;&lt;span style="color: #DD0000"&gt;'"'&lt;/span&gt;&lt;span style="color: #007700"&gt;); &lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;                &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;mysql_num_rows&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$result&lt;/span&gt;&lt;span style="color: #007700"&gt;)==&lt;/span&gt;&lt;span style="color: #0000BB"&gt;0&lt;/span&gt;&lt;span style="color: #007700"&gt;): &lt;br&gt;&lt;br /&gt;                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #FF8000"&gt;#&amp;nbsp;Username&amp;nbsp;or&amp;nbsp;password&amp;nbsp;incorrect &lt;br&gt;&lt;br /&gt;                    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;exit; &lt;br&gt;&lt;br /&gt;                      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;endif; &lt;br&gt;&lt;br /&gt;      &lt;br&gt;&lt;br /&gt;                      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #FF8000"&gt;#&amp;nbsp;Send&amp;nbsp;user&amp;nbsp;protected&amp;nbsp;page &lt;br&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;span style="color: #0000BB"&gt;?&amp;gt; &lt;br&gt;&lt;br /&gt;                          &lt;/span&gt; &lt;/code&gt;&lt;br&gt;&lt;br /&gt;    So for instance, if somebody sent &lt;code class="stringcode"&gt;&amp;quot; or &amp;quot;&amp;quot;=&amp;quot;&lt;/code&gt; for the username and the password,&lt;br /&gt;    the SQL query sent to the database would read: &lt;code class="stringcode"&gt;select * from users where user=&amp;quot;&amp;quot; or&lt;br /&gt;      &amp;quot;&amp;quot;=&amp;quot;&amp;quot; and pass=&amp;quot;&amp;quot; or &amp;quot;&amp;quot;=&amp;quot;&amp;quot;&lt;/code&gt;, which would allow access to the protected page without a&lt;br /&gt;    valid username or password.&amp;nbsp; This method is called &lt;i&gt;SQL Injection&lt;/i&gt;.&lt;/p&gt;&lt;br /&gt;  &lt;h3&gt;Escaping&lt;/h3&gt;&lt;br /&gt;  &lt;p&gt;To prevent this from happening, the data provided by the user need to be 'escaped' - this means&lt;br /&gt;    putting backslashes in front of quotes, backslashes and other special characters.&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;This means that the MySQL engine will recognise that the quotes are part of the string, which&lt;br /&gt;    prevents SQL injection.&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;PHP has a built in function that is intended for escaping strings, called &lt;code class="stringcode"&gt;addslashes()&lt;/code&gt;.&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;For instance, passing the form data from our example through addslashes would result in &lt;code class="stringcode"&gt;select * from users where user=&amp;quot;\&amp;quot; or \&amp;quot;\&amp;quot;=\&amp;quot;&amp;quot;&lt;br /&gt;    and pass=&amp;quot;\&amp;quot; or \&amp;quot;\&amp;quot;=\&amp;quot;&amp;quot;&lt;/code&gt; being passed to the database, which can&lt;br /&gt;    be correctly interpreted by MySQL.&lt;/p&gt;&lt;br /&gt;  &lt;h3&gt;Magic Quotes&lt;/h3&gt;&lt;br /&gt;  &lt;p&gt;PHP has a feature called 'Magic Quotes', which automatically escapes get, post and cookie data, as if&lt;br /&gt;    addslashes had been called on them.&amp;nbsp; The idea of this is to prevent scripts written by&lt;br /&gt;    inexperienced coders being vulnerable to SQL injection.&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;However, there are several problems with this feature:&lt;/p&gt;&lt;br /&gt;  &lt;ul&gt;&lt;br /&gt;    &lt;li&gt;Addslashes doesn't escape data &lt;i&gt;exactly&lt;/i&gt; right for MySQL databases. (The MySQL function&lt;br /&gt;      MySQL_real_escape_string() should really be used instead)&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;Magic quotes can give programmers a false sense of security, and makes scripts completely&lt;br /&gt;      vulnerable if the option is turned off.&lt;/li&gt;&lt;br /&gt;    &lt;li&gt;It has the irritating side effect that form inputs used in other parts of scripts have slashes added to&lt;br /&gt;      them, which can be very puzzling for beginners, and adds extra coding to remove them again.&lt;/li&gt;&lt;br /&gt;  &lt;/ul&gt;&lt;br /&gt;  &lt;p&gt;Because of these reasons, magic quotes are turned off by default in PHP 5, although they are on&lt;br /&gt;    by default in PHP 4.&lt;/p&gt;&lt;br /&gt;  &lt;strong&gt;Best Practice  &lt;/strong&gt;&lt;br /&gt;  &lt;p&gt;To keep your code portable and protected against vulnerabilities whether Magic Quotes is enabled or not,&lt;br /&gt;    it is best to use a function similar to the one below: &lt;br&gt;&lt;br /&gt;    &lt;code&gt; &lt;br&gt;&lt;br /&gt;      &lt;span style="color: #0000BB"&gt;&amp;lt;?php &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;function&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;proper_escape&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$datastring&lt;/span&gt;&lt;span style="color: #007700"&gt;)&amp;nbsp;{ &lt;br&gt;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #FF8000"&gt;#&amp;nbsp;Strip&amp;nbsp;slashes&amp;nbsp;if&amp;nbsp;data&amp;nbsp;has&amp;nbsp;already&amp;nbsp;been&amp;nbsp;escaped&amp;nbsp;by&amp;nbsp;magic&amp;nbsp;quotes &lt;br&gt;&lt;br /&gt;            &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;if(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;get_magic_quotes_gpc&lt;/span&gt;&lt;span style="color: #007700"&gt;()): &lt;br&gt;&lt;br /&gt;              &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$datastring&lt;/span&gt;&lt;span style="color: #007700"&gt;=&lt;/span&gt;&lt;span style="color: #0000BB"&gt;stripslashes&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$datastring&lt;/span&gt;&lt;span style="color: #007700"&gt;); &lt;br&gt;&lt;br /&gt;                &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;endif; &lt;br&gt;&lt;br /&gt;                &lt;br&gt;&lt;br /&gt;                &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #FF8000"&gt;#&amp;nbsp;Escape&amp;nbsp;string&amp;nbsp;properly&amp;nbsp;&amp;amp;&amp;nbsp;return &lt;br&gt;&lt;br /&gt;                  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="color: #007700"&gt;return&amp;nbsp;&lt;/span&gt;&lt;span style="color: #0000BB"&gt;mysql_real_escape_string&lt;/span&gt;&lt;span style="color: #007700"&gt;(&lt;/span&gt;&lt;span style="color: #0000BB"&gt;$datastring&lt;/span&gt;&lt;span style="color: #007700"&gt;); &lt;br&gt;&lt;br /&gt;                    &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br&gt;&lt;br /&gt;                    &lt;/span&gt;&lt;span style="color: #0000BB"&gt;?&amp;gt; &lt;br&gt;&lt;br /&gt;                    &lt;/span&gt; &lt;/code&gt;&lt;/p&gt;&lt;br /&gt;  &lt;p&gt;Call this when sending input data to the MySQL database like: &lt;code class="stringcode"&gt;proper_escape($_POST['username'])&lt;/code&gt;.&lt;/p&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;  &lt;strong&gt;Links&lt;/strong&gt;&lt;br /&gt;&lt;p&gt; &lt;a href="http://uk.php.net/magic_quotes"&gt;Magic Quotes&lt;/a&gt; reference at php.net.&lt;br&gt;&lt;br /&gt;    Reference for &lt;a href="http://uk.php.net/mysql_real_escape_string"&gt;mysql_real_escape_string&lt;/a&gt; at php.net. &lt;/p&gt;&lt;br /&gt;--&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>MySQL Regular Expressions - Part 3</title><link>http://phpfunda.blogspot.com/2009/01/mysql-regular-expressions-part-3.html</link><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 20 Jan 2009 04:11:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-5973345623194151363</guid><description>&lt;h2&gt;&lt;span class="mw-headline"&gt;What are Regular Expressions? &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;The term &lt;i&gt;regular expressions&lt;/i&gt; is one of those technical terms where the words do very little to explain what the technology does. regular expressions are a feature common to many programming languages and are a topic on which entire can, and indeed, have been written. Fortunately (or unfortunately depending on your perspective), MySQL does not provide as extensive support for regualr expressions as some other programming languages. This is good in that it makes the subject area easier to learn, but may be frustrating if you are already proficient with the rich regular expression syntax available in other languages. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Regular expressions are essentially a set of instructions using a predefined syntax for matching text in a variety of flexible ways. For example, you might want to extract all the occurrences of a particular word sequence from a block of text. You might also want to perform a search for a particular piece of text and replace it with some alternate text. &lt;/p&gt;&lt;br /&gt;&lt;a name="Regular_Expression_Character_Matching"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Regular Expression Character Matching &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;In order to introduce the &lt;i&gt;REGEXP&lt;/i&gt; operator, we will begin by looking at a use of regular expressions that could similarly be used with the &lt;i&gt;LIKE&lt;/i&gt; operator. As in the previous chapter we need to retrieve rows from a table taking into consideration the difference in spelling of the color gray (grey). To perform this retrieval we will use the regex dot character matching (.). Rather like the &lt;i&gt;LIKE&lt;/i&gt; underscore wildcard, this character indicates that any character in this position in the text will be considered a match. For example: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'Gr.y Computer Case';&lt;br /&gt;+-----------+--------------------+-------------------+&lt;br /&gt;| prod_code | prod_name          | prod_desc         |&lt;br /&gt;+-----------+--------------------+-------------------+&lt;br /&gt;|        11 | Grey Computer Case | ATX PC CASE       |&lt;br /&gt;|        12 | Gray Computer Case | ATX PC CASE (USA) |&lt;br /&gt;+-----------+--------------------+-------------------+&lt;br /&gt;2 rows in set (0.05 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;p&gt;So far we haven't done anything that could not have been achieved using wildcards. Regular expressions, however, do not stop here. &lt;/p&gt;&lt;br /&gt;&lt;a name="Matching_from_a_Group_of_Characters"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Matching from a Group of Characters &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;One problem with the approach outlined above is that any letter between the 'Gr' and the 'y' would have registered as a match. In reality we are only interested in words that contain either an 'a' or an 'e' in that location. Fortunately, regular expressions allow us to specify a group of acceptable character matches for any character position. The syntax for this requires that the characters be places in square brackets at the desired location in the match text. For example: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'Gr[ae]y Computer Case';&lt;br /&gt;+-----------+--------------------+-------------------+&lt;br /&gt;| prod_code | prod_name          | prod_desc         |&lt;br /&gt;+-----------+--------------------+-------------------+&lt;br /&gt;|        11 | Grey Computer Case | ATX PC CASE       |&lt;br /&gt;|        12 | Gray Computer Case | ATX PC CASE (USA) |&lt;br /&gt;+-----------+--------------------+-------------------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Use of this syntax ensures that only the words 'Grey' and 'Gray&lt;i&gt; will match the search criteria. There is no limit to the number of characters that can be grouped in the brackets when using this filtering technique.&lt;/i&gt; &lt;/p&gt;&lt;br /&gt;&lt;a name="Matching_from_a_Range_of_Characters"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Matching from a Range of Characters &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;The character group matching syntax can be extended to cover range of characters. For example, instead of declaring a regular expression to cover the letters between A and F as [ABCDEF] we could simply specify a range of characters using the '-' character between the upper and lower ranges [A-F]. We could, for example, list a product based on certian model numbers which begin with numbers ranging from 1 to 6: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'CD-RW Model [1-6]543';&lt;br /&gt;+-----------+------------------+-----------+&lt;br /&gt;| prod_code | prod_name        | prod_desc |&lt;br /&gt;+-----------+------------------+-----------+&lt;br /&gt;|         1 | CD-RW Model 4543 | CD Writer |&lt;br /&gt;|        14 | CD-RW Model 5543 | CD Writer |&lt;br /&gt;|        15 | CD-RW Model 6543 | CD Writer |&lt;br /&gt;|        16 | CD-RW Model 2543 | CD Writer |&lt;br /&gt;+-----------+------------------+-----------+&lt;br /&gt;4 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a name="Handling_Special_Characters"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Handling Special Characters &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;As you have seen, regular expressions assign special meaning to particular characters. For example the dot (.) and square brackets ([]) all have special meaning. Those who studying critical thinking at college will already be questioning what to do if the character sequence that is the subject of a search contains one or more of these characters. Obviously if you are are looking for the following text that looks like a regular expression, the text for which you want to search is, itself, going to be viewed as regular expression syntax. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;To address this issue, a concept known as &lt;i&gt;escaping&lt;/i&gt; is used. In SQL, escaping involves preceding any characters that may be mis-interpreted as a regular expression special character with double back slashes (\\). For example, suppose we have a row in our product table which reads as follows: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;+-----------+--------------------+-----------+&lt;br /&gt;| prod_code | prod_name          | prod_desc |&lt;br /&gt;+-----------+--------------------+-----------+&lt;br /&gt;|        17 | CD-RW Model [7543] | CD Writer |&lt;br /&gt;+-----------+--------------------+-----------+&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;If we were to search for this without regard to the fact that the prod_name value contains regular expression special characters we will not get what we wanted: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'CD-RW Model [7543]';&lt;br /&gt;+-----------+------------------+-----------+&lt;br /&gt;| prod_code | prod_name        | prod_desc |&lt;br /&gt;+-----------+------------------+-----------+&lt;br /&gt;|         1 | CD-RW Model 4543 | CD Writer |&lt;br /&gt;|        14 | CD-RW Model 5543 | CD Writer |&lt;br /&gt;+-----------+------------------+-----------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The cause of the problem is that the regular expression has been interpreted as a search for any entries that read 'CD-RW Model' followed by either a 7, 5, 4 or 3. Clearly, what we wanted was the actual text [7543]. If instead we escape the brackets with the \\ escape sequence we get the result we want: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'CD-RW Model \\[7543\\]';&lt;br /&gt;+-----------+--------------------+-----------+&lt;br /&gt;| prod_code | prod_name          | prod_desc |&lt;br /&gt;+-----------+--------------------+-----------+&lt;br /&gt;|        17 | CD-RW Model [7543] | CD Writer |&lt;br /&gt;+-----------+--------------------+-----------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;a name="Regular_Expressions_and_Whitespace_Characters"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Regular Expressions and Whitespace Characters &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Regular expression syntax also provides a mechanism to reference whitespace characters such as tabs, carriage returns and line feeds. These are referenced in a regular expression using &lt;i&gt;metacharacters&lt;/i&gt;. These metacharacters are outlined in the following table: &lt;/p&gt;&lt;br /&gt;&lt;table border="1" cellspacing="0"&gt;&lt;br /&gt;  &lt;tr style="background:#efefef;"&gt;&lt;br /&gt;    &lt;th&gt;Metacharacter&lt;br /&gt;    &lt;th&gt;Description&lt;/th&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;\\n&lt;br /&gt;    &lt;td&gt;New line (line feed)&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;\\f&lt;br /&gt;    &lt;td&gt;Form feed&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;\\t&lt;br /&gt;    &lt;td&gt;Tab&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;\\r&lt;br /&gt;    &lt;td&gt;Carriage return&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;\\v&lt;br /&gt;    &lt;td&gt;Vertical tab&lt;/td&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;a name="Matching_by_Character_Type"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Matching by Character Type &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Another useful regular expression trick is to match characters by type or &lt;i&gt;class&lt;/i&gt;. For example we might need to specify that a character must be a letter, a number or a alphanumeric. This involves the use of some special class definitions outlines in the following table. Some examples of these special classes in action follow the table: &lt;/p&gt;&lt;br /&gt;&lt;table border="1" cellspacing="0"&gt;&lt;br /&gt;  &lt;tr style="background:#efefef;"&gt;&lt;br /&gt;    &lt;th&gt;Class Keyword&lt;br /&gt;    &lt;th&gt;Description of Matches&lt;/th&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:alnum:]]&lt;br /&gt;    &lt;td&gt;Alphanumeric - any number or letter. Equivalent to [a-z], [A-Z] and [0-9]&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:alpha:]]&lt;br /&gt;    &lt;td&gt;Alpha - any letter. Equivalent to [a-z] and [A-Z]&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:blank:]]&lt;br /&gt;    &lt;td&gt;Space or Tab. Equivalent to [\\t] and [ ]&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:cntrl:]]&lt;br /&gt;    &lt;td&gt;ASCII Control Character&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:digit:]]&lt;br /&gt;    &lt;td&gt;Numeric. Equivalent to [0-9]&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:graph:]]&lt;br /&gt;    &lt;td&gt;Any character with the exception of space&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:lower:]]&lt;br /&gt;    &lt;td&gt;Lower case letters. Equivalent to [a-z]&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:print:]]&lt;br /&gt;    &lt;td&gt;Any printable character&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:punct:]]&lt;br /&gt;    &lt;td&gt;Characters that are neither control characters, nor alphanumeric (i.e punctuation characters)&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:space:]]&lt;br /&gt;    &lt;td&gt;Any whitespace character (tab, new line, form feed, space etc)&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:upper:]]&lt;br /&gt;    &lt;td&gt;Upper case letters. Equivalent to [A-Z]&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:xdigit:]]&lt;br /&gt;    &lt;td&gt;Any hexadecimal digit. Equivalent to [A-F], [a-f] and [0-9]&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;Let's now look at some examples. Suppose in our product database we have two products with similar names, the 'One&amp;amp;One VoIP Headset' and the "One2One USB Hub'. In order to retrieve the 'One2One' product we would use the [:digit:] character class: &lt;/p&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'One[[:digit:]]One';&lt;br /&gt;+-----------+-----------------+----------------+&lt;br /&gt;| prod_code | prod_name       | prod_desc      |&lt;br /&gt;+-----------+-----------------+----------------+&lt;br /&gt;|        19 | One2One USB Hub | 4 Port USB Hub |&lt;br /&gt;+-----------+-----------------+----------------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Similarly, to extract the 'One&amp;amp;One' product we would use the [:punct:] class: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP 'One[[:punct:]]One';&lt;br /&gt;+-----------+----------------------+----------------+&lt;br /&gt;| prod_code | prod_name            | prod_desc      |&lt;br /&gt;+-----------+----------------------+----------------+&lt;br /&gt;|        18 | One&amp;amp;One VoIP Headset | Stereo Headset |&lt;br /&gt;+-----------+----------------------+----------------+&lt;br /&gt;1 row in set (0.02 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a name="Regular_Expression_Repetition_Metacharacters"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Regular Expression Repetition Metacharacters &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;In addition to allowing searches on single instances, regular expressions can also be written to look for repetition in text. this is achieved using a set of &lt;i&gt;repetition metacharacters&lt;/i&gt;: &lt;/p&gt;&lt;br /&gt;&lt;table border="1" cellspacing="0"&gt;&lt;br /&gt;  &lt;tr style="background:#efefef;"&gt;&lt;br /&gt;    &lt;th&gt;Metacharacter&lt;br /&gt;    &lt;th&gt;Description&lt;/th&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;*&lt;br /&gt;    &lt;td&gt;Any number of matches&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;+&lt;br /&gt;    &lt;td&gt;One or more matches&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;{n}&lt;br /&gt;    &lt;td&gt;&lt;i&gt;n&lt;/i&gt; number of matches&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;{n,}&lt;br /&gt;    &lt;td&gt;Not less than &lt;i&gt;n&lt;/i&gt; number of matches&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;{n1,n2}&lt;br /&gt;    &lt;td&gt;A range of matches between n1 and n2&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;?&lt;br /&gt;    &lt;td&gt;Optional single character match (character my be present or not to qualify for a match)&lt;/td&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;As always, example do a much better job of demonstrating a concept than data in a table. Let's begin by searching for all 4 digit number sequences in our prod_name column: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP '[[:digit:]]{3}';&lt;br /&gt;+-----------+---------------------+-----------------+&lt;br /&gt;| prod_code | prod_name           | prod_desc       |&lt;br /&gt;+-----------+---------------------+-----------------+&lt;br /&gt;|         1 | CD-RW Model 4543    | CD Writer       |&lt;br /&gt;|         2 | EasyTech Mouse 7632 | Cordless Mouse  |&lt;br /&gt;|         3 | WildTech 250Gb 1700 | SATA Disk Drive |&lt;br /&gt;|         7 | Dell XPS 400        | Desktop PC      |&lt;br /&gt;|        14 | CD-RW Model 5543    | CD Writer       |&lt;br /&gt;|        15 | CD-RW Model 6543    | CD Writer       |&lt;br /&gt;|        16 | CD-RW Model 2543    | CD Writer       |&lt;br /&gt;|        17 | CD-RW Model [7543]  | CD Writer       |&lt;br /&gt;+-----------+---------------------+-----------------+&lt;br /&gt;8 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;In the above example we have indicated that we are looking for any sequence of 3 digits by using the &lt;i&gt;&lt;a href="/index.php?title=Digit:&amp;amp;action=edit" class="new" title="Digit:"&gt;digit:&lt;/a&gt;{3}&lt;/i&gt; regular expression. In this case we have picked up entries with both 3 and 4 digits in a sequence. Suppose, instead we wanted only 4 digit sequences: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_name REGEXP '[[:digit:]]{4,}';&lt;br /&gt;+-----------+---------------------+-----------------+&lt;br /&gt;| prod_code | prod_name           | prod_desc       |&lt;br /&gt;+-----------+---------------------+-----------------+&lt;br /&gt;|         1 | CD-RW Model 4543    | CD Writer       |&lt;br /&gt;|         2 | EasyTech Mouse 7632 | Cordless Mouse  |&lt;br /&gt;|         3 | WildTech 250Gb 1700 | SATA Disk Drive |&lt;br /&gt;|        14 | CD-RW Model 5543    | CD Writer       |&lt;br /&gt;|        15 | CD-RW Model 6543    | CD Writer       |&lt;br /&gt;|        16 | CD-RW Model 2543    | CD Writer       |&lt;br /&gt;|        17 | CD-RW Model [7543]  | CD Writer       |&lt;br /&gt;+-----------+---------------------+-----------------+&lt;br /&gt;7 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Here we see that our Dell XPS 400 is no longer listed because it has only 3 digits. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;The '?' metacharacter is particularly useful when we need to allow for plural words. For example, we may want to list any product descriptions where the word Drive or Drives is used. To achieve this we simply follow the 's' with a '?', thereby making the trailing 's' optional for a match: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;mysql&amp;gt; SELECT * FROM product WHERE prod_desc REGEXP 'Drives?';&lt;br /&gt;+-----------+------------------------+--------------------+&lt;br /&gt;| prod_code | prod_name              | prod_desc          |&lt;br /&gt;+-----------+------------------------+--------------------+&lt;br /&gt;|         3 | WildTech 250Gb 1700    | SATA Disk Drive    |&lt;br /&gt;|        20 | MasterSlave Multi-pack | 5 SATA Disk Drives |&lt;br /&gt;+-----------+------------------------+--------------------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a name="Matching_by_Text_Position"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;&lt;span class="mw-headline"&gt; Matching by Text Position &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;The final area of regular expressions to cover in this chapter involves matching based on the location of text in a string. For example, we may want to find a particular match that requires that a word appears at the beginning or end of a piece of text. Once again, this requires the use of some special metacharacters: &lt;/p&gt;&lt;br /&gt;&lt;table border="1" cellspacing="0"&gt;&lt;br /&gt;  &lt;tr style="background:#efefef;"&gt;&lt;br /&gt;    &lt;th&gt;Metacharacter&lt;br /&gt;    &lt;th&gt;Description&lt;/th&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;^&lt;br /&gt;    &lt;td&gt;Beginning of text&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;$&lt;br /&gt;    &lt;td&gt;End of text&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:&amp;lt;:]]&lt;br /&gt;    &lt;td&gt;Start of word&lt;/td&gt;&lt;br /&gt;  &lt;tr&gt;&lt;br /&gt;    &lt;td&gt;[[:&amp;gt;:]]&lt;br /&gt;    &lt;td&gt;End of word&lt;/td&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;For example, to search for text that begins with a digit: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT prod_desc FROM product WHERE prod_desc REGEXP '^[[:digit:]]';&lt;br /&gt;+--------------------+&lt;br /&gt;| prod_desc          |&lt;br /&gt;+--------------------+&lt;br /&gt;| 4 Port USB Hub     |&lt;br /&gt;| 5 SATA Disk Drives |&lt;br /&gt;+--------------------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Similarly, to search for text which ends in the word 'Phone': &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT prod_desc FROM product WHERE prod_desc REGEXP 'Phone$';&lt;br /&gt;+--------------+&lt;br /&gt;| prod_desc    |&lt;br /&gt;+--------------+&lt;br /&gt;| Smart Phone  |&lt;br /&gt;| Mobile Phone |&lt;br /&gt;+--------------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;We can also find instances where string of characters are a separate word. For example if we search for the word 'one' we might get the following: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT prod_name FROM product WHERE prod_name REGEXP 'one';&lt;br /&gt;+----------------------+&lt;br /&gt;| prod_name            |&lt;br /&gt;+----------------------+&lt;br /&gt;| Apple iPhone 8Gb     |&lt;br /&gt;| One2One USB Hub      |&lt;br /&gt;| Level One Firewall   |&lt;br /&gt;+----------------------+&lt;br /&gt;3 rows in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;As we can see from the above example, because the word 'Phone' contains the word 'one' we have retrieved more rows than we anticipated. Using the beginning and and end of word metacharacters we can isolate the instances of 'one' which are a standalone word: &lt;/p&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;gt; SELECT prod_name FROM product WHERE prod_name REGEXP '[[:&amp;lt;:]]One[[:&amp;gt;:]]';&lt;br /&gt;+----------------------+&lt;br /&gt;| prod_name            |&lt;br /&gt;+----------------------+&lt;br /&gt;| Level One Firewall   |&lt;br /&gt;+----------------------+&lt;br /&gt;1 row in set (0.00 sec)&lt;/pre&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>MySQL Regular Expressions - Part 2</title><link>http://phpfunda.blogspot.com/2009/01/mysql-regular-expressions-part-2.html</link><category>Article</category><category>Example</category><category>Free Code</category><category>MySQL</category><category>PHP</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 20 Jan 2009 02:14:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-3108866313789240131</guid><description>&lt;div id="post_message_6997"&gt;&lt;br /&gt;  &lt;h2&gt;Regular Expressions in MySQL&lt;/h2&gt;&lt;br /&gt;  &lt;p&gt;&lt;span class="articleheading"&gt;&lt;a name="intro"&gt;&lt;/a&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    A very interesting and useful capability of MySQL is to incorporate Regular Expressions (regex) in SQL queries. The regular expression support in MySQL is extensive. Let's take a look at using Regular Expressions in queries and the supported metacharacters.&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    &lt;span class="articleheading"&gt;&lt;a name="using"&gt;&lt;/a&gt;Using Regular Expressions in queries&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    A simple example of using Regular Expressions in a SQL query would be to select all names from a table that start with 'A'.&lt;br /&gt;&lt;br /&gt;  &lt;/p&gt;&lt;br /&gt;  &lt;div style="margin:20px; margin-top:5px"&gt;&lt;br /&gt;    &lt;div class="smallfont" style="margin-bottom:2px"&gt;Code: SQL&lt;/div&gt;&lt;br /&gt;    &lt;pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:640px; height:52px; overflow:auto"&gt;&lt;div dir="ltr" style="text-align:left;"&gt;&lt;div class="sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;REGEXP&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'^A'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687194&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687194&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  A slight modification in the above example to look for names starting with 'A' or 'D' or 'F' will look like this.&lt;br /&gt;&lt;br /&gt;  &lt;div style="margin:20px; margin-top:5px"&gt;&lt;br /&gt;    &lt;div class="smallfont" style="margin-bottom:2px"&gt;Code: SQL&lt;/div&gt;&lt;br /&gt;    &lt;pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:640px; height:52px; overflow:auto"&gt;&lt;div dir="ltr" style="text-align:left;"&gt;&lt;div class="sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;REGEXP&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'^(A|D|F)'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  If we want to select all names ending with 'P', then the SQL query goes like this&lt;br /&gt;&lt;br /&gt;  &lt;div style="margin:20px; margin-top:5px"&gt;&lt;br /&gt;    &lt;div class="smallfont" style="margin-bottom:2px"&gt;Code: SQL&lt;/div&gt;&lt;br /&gt;    &lt;pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:640px; height:52px; overflow:auto"&gt;&lt;div dir="ltr" style="text-align:left;"&gt;&lt;div class="sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;REGEXP&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'P$'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  We can use much complex patterns in our SQL queries, but first let's have a look at various MySQL Regular Expression metacharacters.&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  &lt;span class="articleheading"&gt;&lt;a name="regex"&gt;&lt;/a&gt;Regular Expression Metacharacters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  &lt;b&gt;*&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches zero or more instances of the string preceding it&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;+&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches one or more instances of the string preceding it&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;?&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches zero or one instances of the string preceding it&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;.&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches any single character, except a newline&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[xyz]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches any of x, y, or z (match one of enclosed characters)&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[^xyz]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches any character not enclosed &lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[A-Z]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches any uppercase letter&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[a-z]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches any lowercase letter&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[0-9]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches any digit&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;^&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Anchors the match from the beginning&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;$&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Anchors the match to the end&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;|&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Separates alternatives&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;{n,m}&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;String must occur at least n times, but not more than m times&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;{n}&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;String must occur exactly n times&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;{n,}&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;String must occur at least n times&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[[:&amp;lt;:]]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches beginning of words&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[[:&amp;gt;:]]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;Matches ending of words&lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;[:class:]&lt;/b&gt;&lt;br /&gt;  &lt;blockquote&gt;match a character class i.e., &lt;br /&gt;&lt;br /&gt;      &lt;br /&gt;&lt;br /&gt;      &lt;i&gt;[:alpha:] &lt;/i&gt;for letters&lt;br /&gt;&lt;br /&gt;      &lt;i&gt;[:space:]&lt;/i&gt; for whitespace&lt;br /&gt;&lt;br /&gt;      &lt;i&gt;[:punct:]&lt;/i&gt; for punctuation&lt;br /&gt;&lt;br /&gt;      &lt;i&gt;[:upper:]&lt;/i&gt; for upper case letters &lt;br /&gt;&lt;br /&gt;  &lt;/blockquote&gt;&lt;br /&gt;  &lt;b&gt;Extras&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  MySQL interprets a backslash (\) character as an escape character. To use a backslash in a regular expression, you must escape it with another backslash (\\).&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687194&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687194&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  Whether the Regular Expression match is case sensitive or otherwise is decided by the collation method of the table. If your collation method name ends with &lt;b&gt;ci &lt;/b&gt;then the comparison/match is case-insensitive, else if it end in &lt;b&gt;cs &lt;/b&gt;then the match is case sensitive.&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  &lt;span class="articleheading"&gt;&lt;a name="eg"&gt;&lt;/a&gt;Examples&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  Checking only for numbers&lt;br /&gt;&lt;br /&gt;  &lt;div style="margin:20px; margin-top:5px"&gt;&lt;br /&gt;    &lt;div class="smallfont" style="margin-bottom:2px"&gt;Code: SQL&lt;/div&gt;&lt;br /&gt;    &lt;pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:640px; height:84px; overflow:auto"&gt;&lt;div dir="ltr" style="text-align:left;"&gt;&lt;div class="sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; age &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/span&gt; age &lt;span style="color: #993333; font-weight: bold;"&gt;REGEXP&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'^&amp;#91;0-9&amp;#93;+$'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;/* starts, ends and contains numbers */&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  Contains a specific word, for example the skill PHP in skill sets&lt;br /&gt;&lt;br /&gt;  &lt;div style="margin:20px; margin-top:5px"&gt;&lt;br /&gt;    &lt;div class="smallfont" style="margin-bottom:2px"&gt;Code: SQL&lt;/div&gt;&lt;br /&gt;    &lt;pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:640px; height:52px; overflow:auto"&gt;&lt;div dir="ltr" style="text-align:left;"&gt;&lt;div class="sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/span&gt; skill_sets &lt;span style="color: #993333; font-weight: bold;"&gt;REGEXP&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'&amp;#91;&amp;#91;:&amp;lt;:&amp;#93;&amp;#93;php&amp;#91;&amp;#91;:&amp;gt;:&amp;#93;&amp;#93;'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;  Fetching records where employees have entered their 10-digit mobile number as the contact number.&lt;br /&gt;&lt;br /&gt;  &lt;div style="margin:20px; margin-top:5px"&gt;&lt;br /&gt;    &lt;div class="smallfont" style="margin-bottom:2px"&gt;Code: SQL&lt;/div&gt;&lt;br /&gt;    &lt;pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:640px; height:52px; overflow:auto"&gt;&lt;div dir="ltr" style="text-align:left;"&gt;&lt;div class="sql"&gt;&lt;span style="color: #993333; font-weight: bold;"&gt;SELECT&lt;/span&gt; name &lt;span style="color: #993333; font-weight: bold;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: #993333; font-weight: bold;"&gt;WHERE&lt;/span&gt; contact_no &lt;span style="color: #993333; font-weight: bold;"&gt;REGEXP&lt;/span&gt; &lt;span style="color: #ff0000;"&gt;'^&amp;#91;0-9&amp;#93;{10}$'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For more information refer &lt;a href="http://dev.mysql.com/doc/refman/5.1/en/regexp.html"&gt;http://dev.mysql.com/doc/refman/5.1/en/regexp.html&lt;/a&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>MySQL Regular Expressions - Part 1</title><link>http://phpfunda.blogspot.com/2009/01/mysql-regular-expressions-part-1.html</link><category>Article</category><category>Example</category><category>Free Code</category><category>MySQL</category><category>PHP</category><category>tips</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 20 Jan 2009 02:02:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-7715137712329913756</guid><description>&lt;P&gt; &lt;br /&gt;A regular expression (regex) is a powerful way of specifying a complex search.&lt;br /&gt; &lt;br /&gt;&lt;/P&gt; &lt;br /&gt;&lt;P&gt; &lt;br /&gt;MySQL uses Henry Spencer's implementation of regular&lt;br /&gt;expressions, which is aimed at conformance with POSIX&lt;br /&gt;1003.2. MySQL uses the extended version.&lt;br /&gt; &lt;br /&gt;&lt;/P&gt; &lt;br /&gt;&lt;P&gt; &lt;br /&gt;This is a simplistic reference that skips the details. To get more exact&lt;br /&gt;information, see Henry Spencer's &lt;code&gt;regex(7)&lt;/code&gt; manual page that is&lt;br /&gt;included in the source distribution. See section &lt;A HREF="http://ific.uv.es/informatica/manuales/MySQL-4.1.1/manual_Credits.html#Credits"&gt;C  Credits&lt;/A&gt;.&lt;/P&gt; &lt;br /&gt;&lt;P&gt; &lt;br /&gt;A regular expression describes a set of strings. The simplest regexp is&lt;br /&gt;one that has no special characters in it. For example, the regexp&lt;br /&gt;&lt;code&gt;hello&lt;/code&gt; matches &lt;code&gt;hello&lt;/code&gt; and nothing else.&lt;br /&gt; &lt;br /&gt;&lt;/P&gt; &lt;br /&gt;&lt;P&gt; &lt;br /&gt;Non-trivial regular expressions use certain special constructs so that&lt;br /&gt;they can match more than one string. For example, the regexp&lt;br /&gt;&lt;code&gt;hello|word&lt;/code&gt; matches either the string &lt;code&gt;hello&lt;/code&gt; or the string&lt;br /&gt;&lt;code&gt;word&lt;/code&gt;.&lt;br /&gt; &lt;br /&gt;&lt;/P&gt; &lt;br /&gt;&lt;P&gt; &lt;br /&gt;As a more complex example, the regexp &lt;code&gt;B[an]*s&lt;/code&gt; matches any of the&lt;br /&gt;strings &lt;code&gt;Bananas&lt;/code&gt;, &lt;code&gt;Baaaaas&lt;/code&gt;, &lt;code&gt;Bs&lt;/code&gt;, and any other string&lt;br /&gt;starting with a &lt;code&gt;B&lt;/code&gt;, ending with an &lt;code&gt;s&lt;/code&gt;, and containing any&lt;br /&gt;number of &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;n&lt;/code&gt; characters in between.&lt;br /&gt; &lt;br /&gt;&lt;/P&gt; &lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687194&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687194&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;P&gt; &lt;br /&gt;A regular expression may use any of the following special&lt;br /&gt;characters/constructs:&lt;br /&gt;&lt;DL COMPACT&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;^&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match the beginning of a string.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "fo\nfo" REGEXP "^fo$";           -&amp;#62; 0&lt;br /&gt;mysql&amp;#62; SELECT "fofo" REGEXP "^fo";              -&amp;#62; 1&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;$&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match the end of a string.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "fo\no" REGEXP "^fo\no$";         -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "fo\no" REGEXP "^fo$";            -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;.&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match any character (including newline).&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "fofo" REGEXP "^f.*";             -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "fo\nfo" REGEXP "^f.*";           -&amp;#62; 1&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;a*&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match any sequence of zero or more &lt;code&gt;a&lt;/code&gt; characters.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "Ban" REGEXP "^Ba*n";             -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "Baaan" REGEXP "^Ba*n";           -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "Bn" REGEXP "^Ba*n";              -&amp;#62; 1&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;a+&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match any sequence of one or more &lt;code&gt;a&lt;/code&gt; characters.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "Ban" REGEXP "^Ba+n";             -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "Bn" REGEXP "^Ba+n";              -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;a?&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match either zero or one &lt;code&gt;a&lt;/code&gt; character.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "Bn" REGEXP "^Ba?n";              -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "Ban" REGEXP "^Ba?n";             -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "Baan" REGEXP "^Ba?n";            -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;de|abc&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match either of the sequences &lt;code&gt;de&lt;/code&gt; or &lt;code&gt;abc&lt;/code&gt;.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "pi" REGEXP "pi|apa";             -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "axe" REGEXP "pi|apa";            -&amp;#62; 0&lt;br /&gt;mysql&amp;#62; SELECT "apa" REGEXP "pi|apa";            -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "apa" REGEXP "^(pi|apa)$";        -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "pi" REGEXP "^(pi|apa)$";         -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "pix" REGEXP "^(pi|apa)$";        -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687194&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687194&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;DT&gt;&lt;code&gt;(abc)*&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Match zero or more instances of the sequence &lt;code&gt;abc&lt;/code&gt;.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "pi" REGEXP "^(pi)*$";            -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "pip" REGEXP "^(pi)*$";           -&amp;#62; 0&lt;br /&gt;mysql&amp;#62; SELECT "pipi" REGEXP "^(pi)*$";          -&amp;#62; 1&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;{1}&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;{2,3}&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;The is a more general way of writing regexps that match many&lt;br /&gt;occurrences of the previous atom.&lt;br /&gt;&lt;DL COMPACT&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;a*&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Can be written as &lt;code&gt;a{0,}&lt;/code&gt;.&lt;br /&gt;&lt;DT&gt;&lt;code&gt;a+&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Can be written as &lt;code&gt;a{1,}&lt;/code&gt;.&lt;br /&gt;&lt;DT&gt;&lt;code&gt;a?&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Can be written as &lt;code&gt;a{0,1}&lt;/code&gt;.&lt;br /&gt;&lt;/DL&gt; &lt;br /&gt;To be more precise, an atom followed by a bound containing one integer&lt;br /&gt;&lt;code&gt;i&lt;/code&gt; and no comma matches a sequence of exactly &lt;code&gt;i&lt;/code&gt; matches of&lt;br /&gt;the atom. An atom followed by a bound containing one integer &lt;code&gt;i&lt;/code&gt; &lt;br /&gt;and a comma matches a sequence of &lt;code&gt;i&lt;/code&gt; or more matches of the atom.&lt;br /&gt;An atom followed by a bound containing two integers &lt;code&gt;i&lt;/code&gt; and&lt;br /&gt;&lt;code&gt;j&lt;/code&gt; matches a sequence of &lt;code&gt;i&lt;/code&gt; through &lt;code&gt;j&lt;/code&gt; (inclusive)&lt;br /&gt;matches of the atom.&lt;br /&gt; &lt;br /&gt;Both arguments must be in the range from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;RE_DUP_MAX&lt;/code&gt; &lt;br /&gt;(default 255), inclusive.  If there are two arguments, the second must be&lt;br /&gt;greater than or equal to the first.&lt;br /&gt;&lt;DT&gt;&lt;code&gt;[a-dX]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;[^a-dX]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Matches&lt;br /&gt;any character which is (or is not, if ^ is used) either &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;b&lt;/code&gt;,&lt;br /&gt;&lt;code&gt;c&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt; or &lt;code&gt;X&lt;/code&gt;. To include a literal &lt;code&gt;]&lt;/code&gt; character,&lt;br /&gt;it must immediately follow the opening bracket &lt;code&gt;[&lt;/code&gt;.  To include a&lt;br /&gt;literal &lt;code&gt;-&lt;/code&gt; character, it must be written first or last. So&lt;br /&gt;&lt;code&gt;[0-9]&lt;/code&gt; matches any decimal digit. Any character that does not have&lt;br /&gt;a defined meaning inside a &lt;code&gt;[]&lt;/code&gt; pair has no special meaning and&lt;br /&gt;matches only itself.&lt;br /&gt; &lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687194&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687194&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "aXbc" REGEXP "[a-dXYZ]";         -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "aXbc" REGEXP "^[a-dXYZ]$";       -&amp;#62; 0&lt;br /&gt;mysql&amp;#62; SELECT "aXbc" REGEXP "^[a-dXYZ]+$";      -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "aXbc" REGEXP "^[^a-dXYZ]+$";     -&amp;#62; 0&lt;br /&gt;mysql&amp;#62; SELECT "gheis" REGEXP "^[^a-dXYZ]+$";    -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "gheisa" REGEXP "^[^a-dXYZ]+$";   -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;[[.characters.]]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;The sequence of characters of that collating element. The sequence is a&lt;br /&gt;single element of the bracket expression's list. A bracket expression&lt;br /&gt;containing a multi-character collating element can thus match more than&lt;br /&gt;one character, for example, if the collating sequence includes a &lt;code&gt;ch&lt;/code&gt; &lt;br /&gt;collating element, then the regular expression &lt;code&gt;[[.ch.]]*c&lt;/code&gt; matches the&lt;br /&gt;first five characters of &lt;code&gt;chchcc&lt;/code&gt;.&lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;[=character_class=]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;An equivalence class, standing for the sequences of characters of all&lt;br /&gt;collating elements equivalent to that one, including itself.&lt;br /&gt; &lt;br /&gt;For example, if &lt;code&gt;o&lt;/code&gt; and &lt;code&gt;(+)&lt;/code&gt; are the members of an&lt;br /&gt;equivalence class, then &lt;code&gt;[[=o=]]&lt;/code&gt;, &lt;code&gt;[[=(+)=]]&lt;/code&gt;, and&lt;br /&gt;&lt;code&gt;[o(+)]&lt;/code&gt; are all synonymous. An equivalence class may not be an&lt;br /&gt;endpoint of a range.&lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;[:character_class:]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;Within a bracket expression, the name of a character class enclosed in&lt;br /&gt;&lt;code&gt;[:&lt;/code&gt; and &lt;code&gt;:]&lt;/code&gt; stands for the list of all characters belonging&lt;br /&gt;to that class. Standard character class names are:&lt;br /&gt; &lt;br /&gt;&lt;TABLE BORDER WIDTH="100%"&gt; &lt;br /&gt;&lt;TR&gt;&lt;TD&gt;&lt;strong&gt;Name&lt;/strong&gt; &lt;/TD&gt;&lt;TD&gt; &lt;strong&gt;Name&lt;/strong&gt; &lt;/TD&gt;&lt;TD&gt; &lt;strong&gt;Name&lt;/strong&gt; &lt;br /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;br /&gt;&lt;TR&gt;&lt;TD&gt;alnum &lt;/TD&gt;&lt;TD&gt; digit &lt;/TD&gt;&lt;TD&gt; punct&lt;br /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;br /&gt;&lt;TR&gt;&lt;TD&gt;alpha &lt;/TD&gt;&lt;TD&gt; graph &lt;/TD&gt;&lt;TD&gt; space&lt;br /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;br /&gt;&lt;TR&gt;&lt;TD&gt;blank &lt;/TD&gt;&lt;TD&gt; lower &lt;/TD&gt;&lt;TD&gt; upper&lt;br /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;br /&gt;&lt;TR&gt;&lt;TD&gt;cntrl &lt;/TD&gt;&lt;TD&gt; print &lt;/TD&gt;&lt;TD&gt; xdigit&lt;br /&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;br /&gt;&lt;/TABLE&gt; &lt;br /&gt; &lt;br /&gt;These stand for the character classes defined in the &lt;code&gt;ctype(3)&lt;/code&gt; manual&lt;br /&gt;page. A locale may provide others. A character class may not be used as an&lt;br /&gt;endpoint of a range.&lt;br /&gt; &lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687194&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687194&amp;afsid=1"&gt;&lt;img border="0" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" height="60"/&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "justalnums" REGEXP "[[:alnum:]]+";       -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "!!" REGEXP "[[:alnum:]]+";               -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;[[:&amp;#60;:]]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;&lt;DT&gt;&lt;code&gt;[[:&amp;#62;:]]&lt;/code&gt; &lt;br /&gt;&lt;DD&gt; &lt;br /&gt;These match the null string at the beginning and end of a word&lt;br /&gt;respectively.  A word is defined as a sequence of word characters which&lt;br /&gt;is neither preceded nor followed by word characters. A word character is&lt;br /&gt;an alnum character (as defined by &lt;code&gt;ctype(3)&lt;/code&gt;) or an underscore&lt;br /&gt;(&lt;code&gt;_&lt;/code&gt;).&lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "a word a" REGEXP "[[:&amp;#60;:]]word[[:&amp;#62;:]]";      -&amp;#62; 1&lt;br /&gt;mysql&amp;#62; SELECT "a xword a" REGEXP "[[:&amp;#60;:]]word[[:&amp;#62;:]]";     -&amp;#62; 0&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;/DL&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;pre&gt; &lt;br /&gt;mysql&amp;#62; SELECT "weeknights" REGEXP "^(wee|week)(knights|nights)$"; -&amp;#62; 1&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt; &lt;br /&gt;&lt;P&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Date Diffrence In Days</title><link>http://phpfunda.blogspot.com/2008/11/date-diffrence-in-days.html</link><category>Article</category><category>Code</category><category>Ebook</category><category>Example</category><category>Free Code</category><category>Javascript</category><author>noreply@blogger.com (Unknown)</author><pubDate>Wed, 26 Nov 2008 04:26:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-3356095245384290435</guid><description>&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;&lt;strong&gt;This code will give you the diffrence  between the two dates in days.Some time it is required in the program  to get diff. between two dates.It is so small and very efficient code. &lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="code-comment"&gt;&lt;br /&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt; Any source code blocks look like this&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        t1=&lt;span class="code-string"&gt;&amp;quot;&lt;/span&gt;&lt;span class="code-string"&gt;10/10/2006&amp;quot;&lt;/span&gt; ;&lt;br /&gt;&lt;br /&gt;        t2=&lt;span class="code-string"&gt;&amp;quot;&lt;/span&gt;&lt;span class="code-string"&gt;15/10/2006&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;   &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Total time for one day&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;        var one_day=1000*&lt;span class="code-digit"&gt;60&lt;/span&gt;*&lt;span class="code-digit"&gt;60&lt;/span&gt;*&lt;span class="code-digit"&gt;24&lt;/span&gt;; &lt;br /&gt;&lt;br /&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Here we need to split the inputed dates to convert them into standard format&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;for&lt;/span&gt; furter execution&lt;br /&gt;        var x=t1.split(&lt;span class="code-string"&gt;&amp;quot;&lt;/span&gt;&lt;span class="code-string"&gt;/&amp;quot;&lt;/span&gt;);     &lt;br /&gt;        var y=t2.split(&lt;span class="code-string"&gt;&amp;quot;&lt;/span&gt;&lt;span class="code-string"&gt;/&amp;quot;&lt;/span&gt;);&lt;br /&gt;  &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;date format(Fullyear,month,date) &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        var date1=new Date(x[&lt;span class="code-digit"&gt;2&lt;/span&gt;],(x[&lt;span class="code-digit"&gt;1&lt;/span&gt;]-&lt;span class="code-digit"&gt;1&lt;/span&gt;),x[&lt;span class="code-digit"&gt;0&lt;/span&gt;]);&lt;br /&gt;  &lt;br /&gt;        var date2=new Date(y[&lt;span class="code-digit"&gt;2&lt;/span&gt;],(y[&lt;span class="code-digit"&gt;1&lt;/span&gt;]-&lt;span class="code-digit"&gt;1&lt;/span&gt;),y[&lt;span class="code-digit"&gt;0&lt;/span&gt;])&lt;br /&gt;        var month1=x[&lt;span class="code-digit"&gt;1&lt;/span&gt;]-&lt;span class="code-digit"&gt;1&lt;/span&gt;;&lt;br /&gt;        var month2=y[&lt;span class="code-digit"&gt;1&lt;/span&gt;]-&lt;span class="code-digit"&gt;1&lt;/span&gt;;&lt;br /&gt;        &lt;br /&gt;        &lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;Calculate difference between the two dates, and convert to days&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;               &lt;br /&gt;        _Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day)); &lt;br /&gt;&lt;span class="code-comment"&gt;//&lt;/span&gt;&lt;span class="code-comment"&gt;_Diff gives the diffrence between the two dates.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Mod Rewrite Tips and Examples</title><link>http://phpfunda.blogspot.com/2008/08/mod-rewrite-tips-and-examples.html</link><category>Apache</category><category>Article</category><category>Code</category><category>Example</category><category>Free Code</category><category>Mod Rewrite</category><category>PHP</category><category>tips</category><category>Web crawler</category><author>noreply@blogger.com (Unknown)</author><pubDate>Fri, 22 Aug 2008 04:13:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-8749660871592940749</guid><description>&lt;p&gt;For example, to limit the next 5 RewriteRules to only be applied to .html and .php files, you can use the following code, which tests if the url does not end in .html or .php and if it doesn&amp;rsquo;t, it will skip the next 5 RewriteRules.&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteRule !\.(html|php)$ - [S=5]&lt;br&gt;&lt;br /&gt;  RewriteRule ^.*-(vf12|vf13|vf5|vf35|vf1|vf10|vf33|vf8).+$ - [S=1]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  .htaccess rewrite examples should begin with:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Options +FollowSymLinks&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Require the www&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Options +FollowSymLinks&lt;br&gt;&lt;br /&gt;  RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Loop Stopping Code&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Sometimes your rewrites cause infinite loops, stop it with one of these rewrite code snippets.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteCond %{ENV:REDIRECT_STATUS} 200&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [L]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Cache-Friendly File Names&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This is probably my favorite, and I use it on every site I work on.  It allows me to update my javascript and css files in my visitors cache&amp;rsquo;s simply by naming them differently in the html, on the server they stay the same name.  This rewrites all files for /zap/j/anything-anynumber.js to /zap/j/anything.js and /zap/c/anything-anynumber.css to /zap/c/anything.css&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteRule ^zap/(j|c)/([a-z]+)-([0-9]+)\.(js|css)$ /zap/$1/$2.$4 [L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;SEO friendly link for non-flash browsers&lt;/p&gt;&lt;br /&gt;&lt;p&gt;When you use flash on your site and you properly supply a link to download flash that shows up for non-flash aware browsers, it is nice to use a shortcut to keep your code clean and your external links to a minimum.  This code allows me to link to site.com/getflash/ for non-flash aware browsers.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteRule ^getflash/?$ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash [NC,L,R=307]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;Removing the Query_String&lt;/p&gt;&lt;br /&gt;&lt;p&gt;On many sites, the page will be displayed for both page.html and page.html?anything=anything, which hurts your SEO with duplicate content.  An easy way to fix this issue is to redirect external requests containing a query string to the same uri without the query_string.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteCond %{THE_REQUEST} ^GET\ /.*\;.*\ HTTP/&lt;br&gt;&lt;br /&gt;  RewriteCond %{QUERY_STRING} !^$&lt;br&gt;&lt;br /&gt;  RewriteRule .* http://www.askapache.com%{REQUEST_URI}? [R=301,L]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Sending requests to a php script&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This .htaccess rewrite example invisibly rewrites requests for all Adobe pdf files to be handled by /cgi-bin/pdf-script.php&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteRule ^(.+)\.pdf$  /cgi-bin/pdf-script.php?file=$1.pdf [L,NC,QSA]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Setting the language variable based on Client&lt;/p&gt;&lt;br /&gt;&lt;p&gt;For sites using multiviews or with multiple language capabilities, it is nice to be able to send the correct language automatically based on the clients preferred language.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteCond %{HTTP:Accept-Language} ^.*(de|es|fr|it|ja|ru|en).*$ [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule ^(.*)$ - [env=prefer-language:%1]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  Deny Access To Everyone Except PHP fopen&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This allows access to all files by php fopen, but denies anyone else.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{THE_REQUEST} ^.+$ [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [F,L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Deny access to anything in a subfolder except php fopen&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This can be very handy if you want to serve media files or special downloads but only through a php proxy script.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+)/.*\ HTTP [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [F,L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Require no www&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Options +FollowSymLinks&lt;br&gt;&lt;br /&gt;  RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_HOST} !^askapache\.com$ [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule ^(.*)$ http://askapache.com/$1 [R=301,L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Check for a key in QUERY_STRING&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Uses a RewriteCond Directive to check QUERY_STRING for passkey, if it doesn&amp;rsquo;t find it it redirects all requests for anything in the /logged-in/ directory to the /login.php script.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{QUERY_STRING} !passkey&lt;br&gt;&lt;br /&gt;  RewriteRule ^/logged-in/(.*)$ /login.php [L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Removes the QUERY_STRING from the URL&lt;/p&gt;&lt;br /&gt;&lt;p&gt;If the QUERY_STRING has any value at all besides blank than the?at the end of /login.php? tells mod_rewrite to remove the QUERY_STRING from login.php and redirect.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{QUERY_STRING} .&lt;br&gt;&lt;br /&gt;  RewriteRule ^login.php /login.php? [L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Fix for infinite loops&lt;/p&gt;&lt;br /&gt;&lt;p&gt;An error message related to this isRequest exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.or you may seeRequest exceeded the limit,probable configuration error,Use 'LogLevel debug' to get a backtrace, orUse 'LimitInternalRecursion' to increase the limit if necessary&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteCond %{ENV:REDIRECT_STATUS} 200&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [L]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;External Redirect .php files to .html files (SEO friendly)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteRule ^(.*)\.php$ /$1.html [R=301,L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Internal Redirect .php files to .html files (SEO friendly)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Redirects all files that end in .html to be served from filename.php  so it looks like all your pages are .html but really they are .php&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteRule ^(.*)\.html$ $1.php [R=301,L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;block access to files during certain hours of the day&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Options +FollowSymLinks&lt;br&gt;&lt;br /&gt;  RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  # If the hour is 16 (4 PM) Then deny all access&lt;br&gt;&lt;br /&gt;  RewriteCond %{TIME_HOUR} ^16$&lt;br&gt;&lt;br /&gt;  RewriteRule ^.*$ - [F,L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;Rewrite underscores to hyphens for SEO URL&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Converts all underscores &amp;ldquo;_&amp;rdquo; in urls to hyphens &amp;ldquo;-&amp;rdquo; for SEO benefits&amp;hellip;  See the full article for more info.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Options +FollowSymLinks&lt;br&gt;&lt;br /&gt;  RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteRule !\.(html|php)$ - [S=4]&lt;br&gt;&lt;br /&gt;  RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]&lt;br&gt;&lt;br /&gt;  RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]&lt;br&gt;&lt;br /&gt;  RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]&lt;br&gt;&lt;br /&gt;  RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteCond %{ENV:uscor} ^Yes$&lt;br&gt;&lt;br /&gt;  RewriteRule (.*) http://d.com/$1 [R=301,L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  Require the www without hardcoding&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Options +FollowSymLinks&lt;br&gt;&lt;br /&gt;  RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$     [NC]&lt;br&gt;&lt;br /&gt;RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Require no subdomain&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_HOST} \.([a-z-]+\.[a-z]{2,6})$ [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Require no subdomain&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_HOST} \.([^\.]+\.[^\.0-9]+)$&lt;br&gt;&lt;br /&gt;  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;Redirecting Wordpress Feeds to Feedburner&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Full article:Redirecting Wordpress Feeds to Feedburner&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{REQUEST_URI} ^/feed\.gif$&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC] &lt;br&gt;&lt;br /&gt;  RewriteRule ^feed/?.*$ http://feeds.feedburner.com/apache/htaccess [L,R=302]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  RewriteCond %{REQUEST_FILENAME} !-f&lt;br&gt;&lt;br /&gt;  RewriteCond %{REQUEST_FILENAME} !-d&lt;br&gt;&lt;br /&gt;  RewriteRule . /index.php [L]&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  Only allow GET and PUT Request Methods&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Article: Request Methods&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{REQUEST_METHOD} !^(GET|PUT)&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [F]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Prevent Files image/file hotlinking and bandwidth stealing&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  RewriteBase /&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_REFERER} !^$&lt;br&gt;&lt;br /&gt;  RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]&lt;br&gt;&lt;br /&gt;  RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]&lt;br&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Stop browser prefetching&lt;/p&gt;&lt;br /&gt;&lt;p&gt;RewriteEngine On&lt;br&gt;&lt;br /&gt;  SetEnvIfNoCase X-Forwarded-For .+ proxy=yes&lt;br&gt;&lt;br /&gt;  SetEnvIfNoCase X-moz prefetch no_access=yes&lt;br&gt;&lt;br /&gt;  &lt;br&gt;&lt;br /&gt;  # block pre-fetch requests with X-moz headers&lt;br&gt;&lt;br /&gt;  RewriteCond %{ENV:no_access} yes&lt;br&gt;&lt;br /&gt;  RewriteRule .* - [F,L]&lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Make a prefetching hint for Firefox.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Header append Link     &amp;quot;&lt;br&gt;&lt;br /&gt;&amp;lt;/index.htm&amp;gt;&lt;br&gt;&lt;br /&gt;; rel=prefetch&amp;quot;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule, to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, of server variables, environment variables, HTTP headers, or time stamps. Even external database lookups in various formats can be used to achieve highly granular URL matching.&lt;/p&gt;&lt;br /&gt;&lt;p&gt; This module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess) and can generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even to an internal proxy throughput.&lt;/p&gt;&lt;br /&gt;&lt;p&gt; Further details, discussion, and examples, are provided in the detailed mod_rewrite documentation.&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><title>Ebook Of Open Source CMS</title><link>http://phpfunda.blogspot.com/2008/08/ebook-of-open-source-cms.html</link><category>Article</category><category>CMS</category><category>Content management System</category><category>Ebook</category><category>MySQL</category><category>PHP</category><category>SEO</category><author>noreply@blogger.com (Unknown)</author><pubDate>Thu, 14 Aug 2008 04:59:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-5007341120526038127</guid><description>&lt;span style="font-weight:bold;"&gt;Apress.Building.Online.Communities.With.Drupal.phpBB.and.WordPress.Dec.2005&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;Free Ebook for Apress Building Online Communities With Drupal phpBB and WordPress Dec 2005 Please Download this ebook freely and learn. &lt;br /&gt;&lt;br /&gt;Dowanload Link :- &lt;a href="http://hotsoftwareslist.blogspot.com/2008/08/apressbuildingonlinecommunitieswithdrup.html"&gt;Click here&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;Br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Free e-book Pro Drupal Development (John K. VanDyk and Matt Westgate)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Download Link :- &lt;a href="http://hotsoftwareslist.blogspot.com/2008/08/free-e-book-pro-drupal-development-john.html"&gt;Click Here&lt;/a&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>PDF Protection</title><link>http://phpfunda.blogspot.com/2008/06/pdf-protection.html</link><category>Article</category><category>Code</category><category>Ebook</category><category>Example</category><category>Free Code</category><category>PHP</category><author>noreply@blogger.com (Unknown)</author><pubDate>Fri, 13 Jun 2008 01:14:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-525092603998697663</guid><description>&lt;h4&gt;Informations&lt;/h4&gt;&lt;br /&gt;Author: &lt;a href="mailto:klemen@virtuni.net?subject=Protection"&gt;Klemen Vodopivec&lt;/a&gt;&lt;br&gt;&lt;br /&gt;License: Freeware&lt;br /&gt;&lt;h4&gt;Description&lt;/h4&gt;&lt;br /&gt;This script allows to protect the PDF, that is to say prevent people from copying its content,  print it or modify it.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;SetProtection([&lt;strong&gt;array&lt;/strong&gt; permissions [, &lt;strong&gt;string&lt;/strong&gt; user_pass [, &lt;strong&gt;string&lt;/strong&gt; owner_pass]]])&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;u&gt;permissions&lt;/u&gt;: the set of permissions. Empty by default (only viewing is allowed).&lt;br&gt;&lt;br /&gt;&lt;u&gt;user_pass&lt;/u&gt;: user password. Empty by default.&lt;br&gt;&lt;br /&gt;&lt;u&gt;owner_pass&lt;/u&gt;: owner password. If not specified, a random value is used.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;The permission array is composed of values taken from the following ones:&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;copy: copy text and images to the clipboard &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;print: print the document &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;modify: modify it (except for annotations and forms) &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;annot-forms: add annotations and forms &lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Remark: the protection against modification is for people who have the full Acrobat product.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;If you don't set any password, the document will open as usual. If you set a user password, the  PDF viewer will ask for it before displaying the document. The master password, if different  from the user one, can be used to get full access.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Note: protecting a document requires to encrypt it, which increases the processing time a lot.  This can cause a PHP time-out in some cases, especially if the document contains images or fonts.&lt;br /&gt;&lt;h4&gt;Source&lt;/h4&gt;&lt;br /&gt;&lt;table bordercolorlight="#B0B0E0" bordercolordark="#000000" bgcolor="#f0f5ff" border="2" cellpadding="6" cellspacing="0" width="100%"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;      &lt;td&gt;&amp;lt;?php&lt;br&gt;&lt;br /&gt;        /****************************************************************************&lt;br&gt;&lt;br /&gt;        * Software: FPDF_Protection&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * Version:&amp;nbsp;&amp;nbsp;1.02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2005/05/08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;Klemen VODOPIVEC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * License:&amp;nbsp;&amp;nbsp;Freeware&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * You may use and modify this software as you wish as stated in original&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * FPDF package.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * Thanks: Cpdf (http://www.ros.co.nz/pdf) was my working sample of how to&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        * implement protection in pdf.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        ****************************************************************************/&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        require('fpdf.php');&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        class FPDF_Protection extends FPDF&lt;br&gt;&lt;br /&gt;        {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $encrypted;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//whether document is protected&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Uvalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//U entry in pdf document&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Ovalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//O entry in pdf document&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Pvalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//P entry in pdf document&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $enc_obj_id;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//encryption object id&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $last_rc4_key;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//last RC4 key encrypted (cached for optimisation)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $last_rc4_key_c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//last RC4 computed key&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function FPDF_Protection($orientation='P',$unit='mm',$format='A4')&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::FPDF($orientation,$unit,$format);&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encrypted=false;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key='';&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;padding="\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08".&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Function to set permissions as well as user and owner passwords&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - permissions is an array with values taken from the following list:&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;copy, print, modify, annot-forms&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;If a value is present it means that the permission is granted&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - If a user password is set, user will be prompted before document is opened&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - If an owner password is set, document can be opened in privilege mode with no&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;restriction if that password is entered&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function SetProtection($permissions=array(),$user_pass='',$owner_pass=null)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$options = array('print' =&amp;gt; 4, 'modify' =&amp;gt; 8, 'copy' =&amp;gt; 16, 'annot-forms' =&amp;gt; 32 );&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$protection = 192;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach($permissions as $permission){&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!isset($options[$permission]))&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Error('Incorrect permission: '.$permission);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$protection += $options[$permission];&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($owner_pass === null)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_pass = uniqid(rand());&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encrypted = true;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_generateencryptionkey($user_pass, $owner_pass, $protection);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        /****************************************************************************&lt;br&gt;&lt;br /&gt;        *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private methods&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&lt;br&gt;&lt;br /&gt;        ****************************************************************************/&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putstream($s)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s = $this-&amp;gt;_RC4($this-&amp;gt;_objectkey($this-&amp;gt;n), $s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_putstream($s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _textstring($s)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s = $this-&amp;gt;_RC4($this-&amp;gt;_objectkey($this-&amp;gt;n), $s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return parent::_textstring($s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute key depending on object number where the encrypted data is stored&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _objectkey($n)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return substr($this-&amp;gt;_md5_16($this-&amp;gt;encryption_key.pack('VXxx',$n)),0,10);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Escape special characters&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _escape($s)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace('\\','\\\\',$s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace(')','\\)',$s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace('(','\\(',$s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace("\r",'\\r',$s);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $s;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putresources()&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_putresources();&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_newobj();&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;enc_obj_id = $this-&amp;gt;n;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('&amp;lt;&amp;lt;');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_putencryption();&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('&amp;gt;&amp;gt;');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('endobj');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putencryption()&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/Filter /Standard');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/V 1');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/R 2');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/O ('.$this-&amp;gt;_escape($this-&amp;gt;Ovalue).')');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/U ('.$this-&amp;gt;_escape($this-&amp;gt;Uvalue).')');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/P '.$this-&amp;gt;Pvalue);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _puttrailer()&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_puttrailer();&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/Encrypt '.$this-&amp;gt;enc_obj_id.' 0 R');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/ID [()()]');&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* RC4 is the standard encryption algorithm used in PDF format&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _RC4($key, $text)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;last_rc4_key != $key) {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$k = str_repeat($key, 256/strlen($key)+1);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4 = range(0,255);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$j = 0;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for ($i=0; $i&amp;lt;256; $i++){&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$t = $rc4[$i];&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$j = ($j + $t + ord($k{$i})) % 256;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$i] = $rc4[$j];&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$j] = $t;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key = $key;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key_c = $rc4;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else {&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4 = $this-&amp;gt;last_rc4_key_c;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$len = strlen($text);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a = 0;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$b = 0;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$out = '';&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for ($i=0; $i&amp;lt;$len; $i++){&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a = ($a+1)%256;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$t= $rc4[$a];&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$b = ($b+$t)%256;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$a] = $rc4[$b];&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$b] = $t;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$k = $rc4[($rc4[$a]+$rc4[$b])%256];&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$out.=chr(ord($text{$i}) ^ $k);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $out;&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Get MD5 as binary string&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _md5_16($string)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return pack('H*',md5($string));&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute O value&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _Ovalue($user_pass, $owner_pass)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tmp = $this-&amp;gt;_md5_16($owner_pass);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_RC4_key = substr($tmp,0,5);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $this-&amp;gt;_RC4($owner_RC4_key, $user_pass);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute U value&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _Uvalue()&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $this-&amp;gt;_RC4($this-&amp;gt;encryption_key, $this-&amp;gt;padding);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/**&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute encryption key&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _generateencryptionkey($user_pass, $owner_pass, $protection)&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Pad passwords&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$user_pass = substr($user_pass.$this-&amp;gt;padding,0,32);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_pass = substr($owner_pass.$this-&amp;gt;padding,0,32);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute O value&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Ovalue = $this-&amp;gt;_Ovalue($user_pass,$owner_pass);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute encyption key&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tmp = $this-&amp;gt;_md5_16($user_pass.$this-&amp;gt;Ovalue.chr($protection)."\xFF\xFF\xFF");&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encryption_key = substr($tmp,0,5);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute U value&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Uvalue = $this-&amp;gt;_Uvalue();&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute P value&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Pvalue = -(($protection^255)+1);&lt;br&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&lt;br /&gt;        }&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        ?&amp;gt; &lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;  &lt;/tbody&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;h4&gt;Example&lt;/h4&gt;&lt;br /&gt;This example shows how to allow only printing.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;table bordercolorlight="#B0B0E0" bordercolordark="#000000" bgcolor="#f0f5ff" border="2" cellpadding="6" cellspacing="0" width="100%"&gt;&lt;br /&gt;  &lt;tbody&gt;&lt;br /&gt;    &lt;tr&gt;&lt;br /&gt;      &lt;td&gt;&amp;lt;?php&lt;br&gt;&lt;br /&gt;        define('FPDF_FONTPATH','font/');&lt;br&gt;&lt;br /&gt;        require('fpdf_protection.php');&lt;br&gt;&lt;br /&gt;        &lt;br&gt;&lt;br /&gt;        $pdf=new FPDF_Protection();&lt;br&gt;&lt;br /&gt;        $pdf-&amp;gt;SetProtection(array('print'));&lt;br&gt;&lt;br /&gt;        $pdf-&amp;gt;Open();&lt;br&gt;&lt;br /&gt;        $pdf-&amp;gt;AddPage();&lt;br&gt;&lt;br /&gt;        $pdf-&amp;gt;SetFont('Arial');&lt;br&gt;&lt;br /&gt;        $pdf-&amp;gt;Write(10,'You can print me but not copy my text.');&lt;br&gt;&lt;br /&gt;        $pdf-&amp;gt;Output();&lt;br&gt;&lt;br /&gt;        ?&amp;gt; &lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;  &lt;/tbody&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;View the result &lt;a href="http://www.fpdf.org/en/script/ex37.pdf" target="_blank"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;h4&gt;Download&lt;/h4&gt;&lt;br /&gt;&lt;a href="http://www.fpdf.org/en/script/dl.php?id=37&amp;amp;f=zip"&gt;ZIP&lt;/a&gt; | &lt;a href="http://www.fpdf.org/en/script/dl.php?id=37&amp;amp;f=tgz"&gt;TGZ&lt;/a&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><enclosure length="1554" type="application/pdf" url="http://www.fpdf.org/en/script/ex37.pdf"/><itunes:explicit>no</itunes:explicit><itunes:subtitle>Informations Author: Klemen Vodopivec License: Freeware Description This script allows to protect the PDF, that is to say prevent people from copying its content, print it or modify it. SetProtection([array permissions [, string user_pass [, string owner_pass]]]) permissions: the set of permissions. Empty by default (only viewing is allowed). user_pass: user password. Empty by default. owner_pass: owner password. If not specified, a random value is used. The permission array is composed of values taken from the following ones: copy: copy text and images to the clipboard print: print the document modify: modify it (except for annotations and forms) annot-forms: add annotations and forms Remark: the protection against modification is for people who have the full Acrobat product. If you don't set any password, the document will open as usual. If you set a user password, the PDF viewer will ask for it before displaying the document. The master password, if different from the user one, can be used to get full access. Note: protecting a document requires to encrypt it, which increases the processing time a lot. This can cause a PHP time-out in some cases, especially if the document contains images or fonts. Source &amp;lt;?php /**************************************************************************** * Software: FPDF_Protection&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Version:&amp;nbsp;&amp;nbsp;1.02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2005/05/08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;Klemen VODOPIVEC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * License:&amp;nbsp;&amp;nbsp;Freeware&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * You may use and modify this software as you wish as stated in original&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * FPDF package.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Thanks: Cpdf (http://www.ros.co.nz/pdf) was my working sample of how to&amp;nbsp;&amp;nbsp;&amp;nbsp;* * implement protection in pdf.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* ****************************************************************************/ require('fpdf.php'); class FPDF_Protection extends FPDF { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $encrypted;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//whether document is protected &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Uvalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//U entry in pdf document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Ovalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//O entry in pdf document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Pvalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//P entry in pdf document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $enc_obj_id;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//encryption object id &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $last_rc4_key;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//last RC4 key encrypted (cached for optimisation) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $last_rc4_key_c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//last RC4 computed key &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function FPDF_Protection($orientation='P',$unit='mm',$format='A4') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::FPDF($orientation,$unit,$format); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encrypted=false; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key=''; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;padding="\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08". &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Function to set permissions as well as user and owner passwords &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - permissions is an array with values taken from the following list: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;copy, print, modify, annot-forms &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;If a value is present it means that the permission is granted &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - If a user password is set, user will be prompted before document is opened &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - If an owner password is set, document can be opened in privilege mode with no &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;restriction if that password is entered &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function SetProtection($permissions=array(),$user_pass='',$owner_pass=null) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$options = array('print' =&amp;gt; 4, 'modify' =&amp;gt; 8, 'copy' =&amp;gt; 16, 'annot-forms' =&amp;gt; 32 ); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$protection = 192; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach($permissions as $permission){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!isset($options[$permission])) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Error('Incorrect permission: '.$permission); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$protection += $options[$permission]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($owner_pass === null) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_pass = uniqid(rand()); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encrypted = true; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_generateencryptionkey($user_pass, $owner_pass, $protection); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} /**************************************************************************** *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private methods&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* ****************************************************************************/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putstream($s) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s = $this-&amp;gt;_RC4($this-&amp;gt;_objectkey($this-&amp;gt;n), $s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_putstream($s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _textstring($s) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s = $this-&amp;gt;_RC4($this-&amp;gt;_objectkey($this-&amp;gt;n), $s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return parent::_textstring($s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute key depending on object number where the encrypted data is stored &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _objectkey($n) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return substr($this-&amp;gt;_md5_16($this-&amp;gt;encryption_key.pack('VXxx',$n)),0,10); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Escape special characters &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _escape($s) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace('\\','\\\\',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace(')','\\)',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace('(','\\(',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace("\r",'\\r',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $s; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putresources() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_putresources(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_newobj(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;enc_obj_id = $this-&amp;gt;n; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('&amp;lt;&amp;lt;'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_putencryption(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('&amp;gt;&amp;gt;'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('endobj'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putencryption() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/Filter /Standard'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/V 1'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/R 2'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/O ('.$this-&amp;gt;_escape($this-&amp;gt;Ovalue).')'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/U ('.$this-&amp;gt;_escape($this-&amp;gt;Uvalue).')'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/P '.$this-&amp;gt;Pvalue); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _puttrailer() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_puttrailer(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/Encrypt '.$this-&amp;gt;enc_obj_id.' 0 R'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/ID [()()]'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* RC4 is the standard encryption algorithm used in PDF format &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _RC4($key, $text) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;last_rc4_key != $key) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$k = str_repeat($key, 256/strlen($key)+1); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4 = range(0,255); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$j = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for ($i=0; $i&amp;lt;256; $i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$t = $rc4[$i]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$j = ($j + $t + ord($k{$i})) % 256; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$i] = $rc4[$j]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$j] = $t; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key = $key; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key_c = $rc4; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4 = $this-&amp;gt;last_rc4_key_c; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$len = strlen($text); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$b = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$out = ''; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for ($i=0; $i&amp;lt;$len; $i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a = ($a+1)%256; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$t= $rc4[$a]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$b = ($b+$t)%256; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$a] = $rc4[$b]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$b] = $t; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$k = $rc4[($rc4[$a]+$rc4[$b])%256]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$out.=chr(ord($text{$i}) ^ $k); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $out; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Get MD5 as binary string &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _md5_16($string) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return pack('H*',md5($string)); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute O value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _Ovalue($user_pass, $owner_pass) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tmp = $this-&amp;gt;_md5_16($owner_pass); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_RC4_key = substr($tmp,0,5); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $this-&amp;gt;_RC4($owner_RC4_key, $user_pass); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute U value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _Uvalue() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $this-&amp;gt;_RC4($this-&amp;gt;encryption_key, $this-&amp;gt;padding); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute encryption key &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _generateencryptionkey($user_pass, $owner_pass, $protection) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Pad passwords &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$user_pass = substr($user_pass.$this-&amp;gt;padding,0,32); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_pass = substr($owner_pass.$this-&amp;gt;padding,0,32); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute O value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Ovalue = $this-&amp;gt;_Ovalue($user_pass,$owner_pass); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute encyption key &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tmp = $this-&amp;gt;_md5_16($user_pass.$this-&amp;gt;Ovalue.chr($protection)."\xFF\xFF\xFF"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encryption_key = substr($tmp,0,5); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute U value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Uvalue = $this-&amp;gt;_Uvalue(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute P value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Pvalue = -(($protection^255)+1); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} } ?&amp;gt; Example This example shows how to allow only printing. &amp;lt;?php define('FPDF_FONTPATH','font/'); require('fpdf_protection.php'); $pdf=new FPDF_Protection(); $pdf-&amp;gt;SetProtection(array('print')); $pdf-&amp;gt;Open(); $pdf-&amp;gt;AddPage(); $pdf-&amp;gt;SetFont('Arial'); $pdf-&amp;gt;Write(10,'You can print me but not copy my text.'); $pdf-&amp;gt;Output(); ?&amp;gt; View the result here. Download ZIP | TGZ</itunes:subtitle><itunes:author>noreply@blogger.com (Unknown)</itunes:author><itunes:summary>Informations Author: Klemen Vodopivec License: Freeware Description This script allows to protect the PDF, that is to say prevent people from copying its content, print it or modify it. SetProtection([array permissions [, string user_pass [, string owner_pass]]]) permissions: the set of permissions. Empty by default (only viewing is allowed). user_pass: user password. Empty by default. owner_pass: owner password. If not specified, a random value is used. The permission array is composed of values taken from the following ones: copy: copy text and images to the clipboard print: print the document modify: modify it (except for annotations and forms) annot-forms: add annotations and forms Remark: the protection against modification is for people who have the full Acrobat product. If you don't set any password, the document will open as usual. If you set a user password, the PDF viewer will ask for it before displaying the document. The master password, if different from the user one, can be used to get full access. Note: protecting a document requires to encrypt it, which increases the processing time a lot. This can cause a PHP time-out in some cases, especially if the document contains images or fonts. Source &amp;lt;?php /**************************************************************************** * Software: FPDF_Protection&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Version:&amp;nbsp;&amp;nbsp;1.02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2005/05/08&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Author:&amp;nbsp;&amp;nbsp;&amp;nbsp;Klemen VODOPIVEC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * License:&amp;nbsp;&amp;nbsp;Freeware&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * You may use and modify this software as you wish as stated in original&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * FPDF package.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* * Thanks: Cpdf (http://www.ros.co.nz/pdf) was my working sample of how to&amp;nbsp;&amp;nbsp;&amp;nbsp;* * implement protection in pdf.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* ****************************************************************************/ require('fpdf.php'); class FPDF_Protection extends FPDF { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $encrypted;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//whether document is protected &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Uvalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//U entry in pdf document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Ovalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//O entry in pdf document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $Pvalue;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//P entry in pdf document &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $enc_obj_id;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//encryption object id &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $last_rc4_key;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//last RC4 key encrypted (cached for optimisation) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var $last_rc4_key_c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//last RC4 computed key &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function FPDF_Protection($orientation='P',$unit='mm',$format='A4') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::FPDF($orientation,$unit,$format); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encrypted=false; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key=''; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;padding="\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08". &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Function to set permissions as well as user and owner passwords &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - permissions is an array with values taken from the following list: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;copy, print, modify, annot-forms &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;If a value is present it means that the permission is granted &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - If a user password is set, user will be prompted before document is opened &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* - If an owner password is set, document can be opened in privilege mode with no &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;restriction if that password is entered &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function SetProtection($permissions=array(),$user_pass='',$owner_pass=null) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$options = array('print' =&amp;gt; 4, 'modify' =&amp;gt; 8, 'copy' =&amp;gt; 16, 'annot-forms' =&amp;gt; 32 ); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$protection = 192; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach($permissions as $permission){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!isset($options[$permission])) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Error('Incorrect permission: '.$permission); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$protection += $options[$permission]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($owner_pass === null) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_pass = uniqid(rand()); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encrypted = true; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_generateencryptionkey($user_pass, $owner_pass, $protection); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} /**************************************************************************** *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Private methods&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* *&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* ****************************************************************************/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putstream($s) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s = $this-&amp;gt;_RC4($this-&amp;gt;_objectkey($this-&amp;gt;n), $s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_putstream($s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _textstring($s) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s = $this-&amp;gt;_RC4($this-&amp;gt;_objectkey($this-&amp;gt;n), $s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return parent::_textstring($s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute key depending on object number where the encrypted data is stored &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _objectkey($n) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return substr($this-&amp;gt;_md5_16($this-&amp;gt;encryption_key.pack('VXxx',$n)),0,10); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Escape special characters &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _escape($s) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace('\\','\\\\',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace(')','\\)',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace('(','\\(',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$s=str_replace("\r",'\\r',$s); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $s; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putresources() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_putresources(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_newobj(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;enc_obj_id = $this-&amp;gt;n; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('&amp;lt;&amp;lt;'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_putencryption(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('&amp;gt;&amp;gt;'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('endobj'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _putencryption() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/Filter /Standard'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/V 1'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/R 2'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/O ('.$this-&amp;gt;_escape($this-&amp;gt;Ovalue).')'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/U ('.$this-&amp;gt;_escape($this-&amp;gt;Uvalue).')'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/P '.$this-&amp;gt;Pvalue); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _puttrailer() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;parent::_puttrailer(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;encrypted) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/Encrypt '.$this-&amp;gt;enc_obj_id.' 0 R'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;_out('/ID [()()]'); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* RC4 is the standard encryption algorithm used in PDF format &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _RC4($key, $text) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($this-&amp;gt;last_rc4_key != $key) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$k = str_repeat($key, 256/strlen($key)+1); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4 = range(0,255); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$j = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for ($i=0; $i&amp;lt;256; $i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$t = $rc4[$i]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$j = ($j + $t + ord($k{$i})) % 256; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$i] = $rc4[$j]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$j] = $t; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key = $key; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;last_rc4_key_c = $rc4; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4 = $this-&amp;gt;last_rc4_key_c; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$len = strlen($text); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$b = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$out = ''; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for ($i=0; $i&amp;lt;$len; $i++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$a = ($a+1)%256; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$t= $rc4[$a]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$b = ($b+$t)%256; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$a] = $rc4[$b]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rc4[$b] = $t; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$k = $rc4[($rc4[$a]+$rc4[$b])%256]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$out.=chr(ord($text{$i}) ^ $k); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $out; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Get MD5 as binary string &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _md5_16($string) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return pack('H*',md5($string)); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute O value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _Ovalue($user_pass, $owner_pass) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tmp = $this-&amp;gt;_md5_16($owner_pass); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_RC4_key = substr($tmp,0,5); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $this-&amp;gt;_RC4($owner_RC4_key, $user_pass); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute U value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _Uvalue() &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $this-&amp;gt;_RC4($this-&amp;gt;encryption_key, $this-&amp;gt;padding); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/** &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Compute encryption key &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;function _generateencryptionkey($user_pass, $owner_pass, $protection) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Pad passwords &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$user_pass = substr($user_pass.$this-&amp;gt;padding,0,32); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$owner_pass = substr($owner_pass.$this-&amp;gt;padding,0,32); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute O value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Ovalue = $this-&amp;gt;_Ovalue($user_pass,$owner_pass); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute encyption key &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tmp = $this-&amp;gt;_md5_16($user_pass.$this-&amp;gt;Ovalue.chr($protection)."\xFF\xFF\xFF"); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;encryption_key = substr($tmp,0,5); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute U value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Uvalue = $this-&amp;gt;_Uvalue(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Compute P value &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$this-&amp;gt;Pvalue = -(($protection^255)+1); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} } ?&amp;gt; Example This example shows how to allow only printing. &amp;lt;?php define('FPDF_FONTPATH','font/'); require('fpdf_protection.php'); $pdf=new FPDF_Protection(); $pdf-&amp;gt;SetProtection(array('print')); $pdf-&amp;gt;Open(); $pdf-&amp;gt;AddPage(); $pdf-&amp;gt;SetFont('Arial'); $pdf-&amp;gt;Write(10,'You can print me but not copy my text.'); $pdf-&amp;gt;Output(); ?&amp;gt; View the result here. Download ZIP | TGZ</itunes:summary><itunes:keywords>php,code,free,tutorial,material,ebooks,download,software</itunes:keywords></item><item><title>Get metadata on MySQL databases</title><link>http://phpfunda.blogspot.com/2008/06/get-metadata-on-mysql-databases.html</link><category>Code</category><category>Free Code</category><category>MySQL</category><category>PHP</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 10 Jun 2008 03:39:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-6563276410969241923</guid><description>Getting information about databases if essential if you want to write generic and scalable applications. This code shows you how to get information such as all databases on the server, all tables in each database and all field and field info for each table. Even if you do not need to build on this code, you might want to copy the code which prints out all databases, tables and field information plus examples. Its a great way to get an overview of the tables you are working on for a project.&lt;br /&gt;&lt;br /&gt;&amp;lt;? &lt;br&gt;&lt;br /&gt;//getting metadata on MySQL databases &lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;//output the structure of a table &lt;br&gt;&lt;br /&gt;$connection_1 = mysql_connect("localhost"); &lt;br&gt;&lt;br /&gt;$fields = mysql_list_fields("cmphp","rights"); &lt;br&gt;&lt;br /&gt;for($i=0;$i&amp;lt;mysql_num_fields($fields);$i++) { &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;echo mysql_field_name($fields,$i)." (".mysql_field_len($fields,$i).") - ".mysql_field_type($fields,$i)."&amp;lt;br&amp;gt;"; &lt;br&gt;&lt;br /&gt;} &lt;br&gt;&lt;br /&gt;mysql_close; &lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;//show the structure of ALL tables in ALL databases on the server &lt;br&gt;&lt;br /&gt;$server_connection_1 = mysql_connect("localhost"); &lt;br&gt;&lt;br /&gt;$databases = mysql_query("SHOW DATABASES"); &lt;br&gt;&lt;br /&gt;while($database = mysql_fetch_row($databases)) { &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;echo '&amp;lt;h2&amp;gt;DATABASE: '.$database[0].'&amp;lt;/h2&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;$database_connection_1 = mysql_select_db($database[0]); &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;$tables = mysql_query("SHOW TABLES"); &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;while($table = mysql_fetch_row($tables)){ &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;table border="1" cellpadding="5" width="500"&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;tr&amp;gt;&amp;lt;td colspan="3" bgcolor="silver"&amp;gt;TABLE: '.$table[0].'&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$fields = mysql_list_fields($database[0],$table[0]); &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for($i=0;$i&amp;lt;mysql_num_fields($fields);$i++) { &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td&amp;gt;'.mysql_field_name($fields,$i)."&amp;lt;/td&amp;gt;"; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td&amp;gt;'.mysql_field_len($fields,$i)."&amp;lt;/td&amp;gt;"; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td&amp;gt;'.mysql_field_type($fields,$i)."&amp;lt;/td&amp;gt;"; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;/tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;/table&amp;gt;&amp;lt;br&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;} &lt;br&gt;&lt;br /&gt;} &lt;br&gt;&lt;br /&gt;mysql_close; &lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;//show the nice structure of a particular database &lt;br&gt;&lt;br /&gt;$server_connection_1 = mysql_connect("localhost"); &lt;br&gt;&lt;br /&gt;$the_database = "cmphp"; &lt;br&gt;&lt;br /&gt;echo '&amp;lt;h2&amp;gt;DATABASE: '.$the_database.'&amp;lt;/h2&amp;gt;'; &lt;br&gt;&lt;br /&gt;$database_connection_1 = mysql_select_db($the_database); &lt;br&gt;&lt;br /&gt;$tables = mysql_query("SHOW TABLES"); &lt;br&gt;&lt;br /&gt;while($table = mysql_fetch_row($tables)){ &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;echo '&amp;lt;table border="1" cellpadding="5" width="600"&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;echo '&amp;lt;tr&amp;gt;&amp;lt;td colspan="4" bgcolor="silver"&amp;gt;&amp;lt;b&amp;gt;TABLE: '.$table[0].'&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;echo '&amp;lt;tr&amp;gt;&amp;lt;td  bgcolor="silver"&amp;gt;NAME&amp;lt;/td&amp;gt;&amp;lt;td  bgcolor="silver"&amp;gt;SIZE&amp;lt;/td&amp;gt;&amp;lt;td  bgcolor="silver"&amp;gt;TYPE&amp;lt;/td&amp;gt;&amp;lt;td  bgcolor="silver"&amp;gt;EXAMPLE&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;$fields = mysql_list_fields($the_database,$table[0]); &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;for($i=0;$i&amp;lt;mysql_num_fields($fields);$i++) { &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td&amp;gt;'.mysql_field_name($fields,$i)."&amp;lt;/td&amp;gt;"; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td&amp;gt;'.mysql_field_len($fields,$i)."&amp;lt;/td&amp;gt;"; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td&amp;gt;'.mysql_field_type($fields,$i)."&amp;lt;/td&amp;gt;"; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$rows = mysql_query("SELECT ".mysql_field_name($fields,$i)." FROM ".$table[0]." LIMIT 1"); &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$row = mysql_fetch_array($rows); &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;td bgcolor="eeeeee"&amp;gt;'.$row[0].'&amp;nbsp;&amp;lt;/td&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;echo '&amp;lt;/tr&amp;gt;'; &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;} &lt;br&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;echo '&amp;lt;/table&amp;gt;&amp;lt;br&amp;gt;'; &lt;br&gt;&lt;br /&gt;} &lt;br&gt;&lt;br /&gt;mysql_close; &lt;br&gt;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;This Article is taken from http://www.developerfusion.co.uk/show/3945/</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007</title><link>http://phpfunda.blogspot.com/2008/05/sams-red-hat-enterprise-linux-5.html</link><category>Ebook</category><category>Linux</category><category>Red Hat</category><author>noreply@blogger.com (Unknown)</author><pubDate>Fri, 16 May 2008 00:44:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-4642173729763774465</guid><description>&lt;object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="-630458988" name="-630458988" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%"&gt;  &lt;param name="movie" value="http://documents.scribd.com/ScribdViewer.swf?document_id=210558&amp;access_key=f74hljsrhd2ap&amp;page=&amp;version=1&amp;auto_size=true"&gt;   &lt;param name="quality" value="high"&gt;   &lt;param name="play" value="true"&gt;  &lt;param name="loop" value="true"&gt;   &lt;param name="scale" value="showall"&gt;  &lt;param name="wmode" value="opaque"&gt;   &lt;param name="devicefont" value="false"&gt;  &lt;param name="bgcolor" value="#ffffff"&gt;   &lt;param name="menu" value="true"&gt;  &lt;param name="allowFullScreen" value="true"&gt;   &lt;param name="allowScriptAccess" value="always"&gt;   &lt;param name="salign" value=""&gt;  &lt;embed src="http://documents.scribd.com/ScribdViewer.swf?document_id=210558&amp;access_key=f74hljsrhd2ap&amp;page=&amp;version=1&amp;auto_size=true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="-630458988_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" height="500" width="100%"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;div style="font-size:10px;text-align:center;width:100%"&gt;&lt;a href="http://www.scribd.com/doc/210558/Sams-Red-Hat-Enterprise-Linux-5-Administration-Unleashed-Apr-2007"&gt;Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007&lt;/a&gt; - &lt;a href="http://www.scribd.com/upload"&gt;Upload a doc&lt;/a&gt;&lt;/div&gt;&lt;div style="display:none"&gt; Read this doc on Scribd: &lt;a href="http://www.scribd.com/doc/210558/Sams-Red-Hat-Enterprise-Linux-5-Administration-Unleashed-Apr-2007"&gt;Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007&lt;/a&gt; &lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><enclosure length="216385" type="application/x-shockwave-flash" url="http://documents.scribd.com/ScribdViewer.swf?document_id=210558&amp;access_key=f74hljsrhd2ap&amp;page=&amp;version=1&amp;auto_size=true"/><itunes:explicit>no</itunes:explicit><itunes:subtitle>Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007 - Upload a doc Read this doc on Scribd: Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007</itunes:subtitle><itunes:author>noreply@blogger.com (Unknown)</itunes:author><itunes:summary>Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007 - Upload a doc Read this doc on Scribd: Sams Red Hat Enterprise Linux 5 Administration Unleashed Apr 2007</itunes:summary><itunes:keywords>php,code,free,tutorial,material,ebooks,download,software</itunes:keywords></item><item><title>Agile web-crawler : design and implementation</title><link>http://phpfunda.blogspot.com/2008/05/agile-web-crawler-design-and.html</link><category>Article</category><category>Ebook</category><category>Web crawler</category><author>noreply@blogger.com (Unknown)</author><pubDate>Thu, 15 May 2008 23:35:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-3419819533408168630</guid><description>&lt;object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="-628972138" name="-628972138" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%"&gt;  &lt;param name="movie" value="http://documents.scribd.com/ScribdViewer.swf?document_id=100903&amp;access_key=48rgf3a473xpf&amp;page=&amp;version=1&amp;auto_size=true"&gt;   &lt;param name="quality" value="high"&gt;   &lt;param name="play" value="true"&gt;  &lt;param name="loop" value="true"&gt;   &lt;param name="scale" value="showall"&gt;  &lt;param name="wmode" value="opaque"&gt;   &lt;param name="devicefont" value="false"&gt;  &lt;param name="bgcolor" value="#ffffff"&gt;   &lt;param name="menu" value="true"&gt;  &lt;param name="allowFullScreen" value="true"&gt;   &lt;param name="allowScriptAccess" value="always"&gt;   &lt;param name="salign" value=""&gt;  &lt;embed src="http://documents.scribd.com/ScribdViewer.swf?document_id=100903&amp;access_key=48rgf3a473xpf&amp;page=&amp;version=1&amp;auto_size=true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="-628972138_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" height="500" width="100%"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;div style="font-size:10px;text-align:center;width:100%"&gt;&lt;a href="http://www.scribd.com/doc/100903/Agile-webcrawler-design-and-implementation"&gt;Agile web-crawler : design and implementation&lt;/a&gt; - &lt;a href="http://www.scribd.com/upload"&gt;Upload a doc&lt;/a&gt;&lt;/div&gt;&lt;div style="display:none"&gt; Read this doc on Scribd: &lt;a href="http://www.scribd.com/doc/100903/Agile-webcrawler-design-and-implementation"&gt;Agile web-crawler : design and implementation&lt;/a&gt; &lt;/div&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><enclosure length="216385" type="application/x-shockwave-flash" url="http://documents.scribd.com/ScribdViewer.swf?document_id=100903&amp;access_key=48rgf3a473xpf&amp;page=&amp;version=1&amp;auto_size=true"/><itunes:explicit>no</itunes:explicit><itunes:subtitle>Agile web-crawler : design and implementation - Upload a doc Read this doc on Scribd: Agile web-crawler : design and implementation</itunes:subtitle><itunes:author>noreply@blogger.com (Unknown)</itunes:author><itunes:summary>Agile web-crawler : design and implementation - Upload a doc Read this doc on Scribd: Agile web-crawler : design and implementation</itunes:summary><itunes:keywords>php,code,free,tutorial,material,ebooks,download,software</itunes:keywords></item><item><title>Search Engine Optimization (SEO) Glossary</title><link>http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-glossary.html</link><category>Article</category><category>Ebook</category><category>Free Code</category><category>SEO</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 22 Apr 2008 05:29:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-6092978651726883155</guid><description>&lt;span style="font-weight:bold;"&gt;Search Engine Optimization (SEO) Glossary&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Definitions to the terms used to describe actions and event in the world of Search Engine Marketing. Search Terms&lt;br /&gt;The words or phrases used by people when performing searches in search engines. Also called keywords, query terms or query.&lt;br /&gt;&lt;br /&gt;Ad Pimp&lt;br /&gt;A website that has too many ads on it in an obvious attempt to monetize the site.&lt;br /&gt;&lt;br /&gt;Ad Rank&lt;br /&gt;Google AdWords multiplies Quality Score (QS) and the maximum CPC (Max CPC) to reach an Ad Rank for each ad.&lt;br /&gt;&lt;br /&gt;Added Value Affiliates&lt;br /&gt;Provide a value-added service to visitors in addition to affiliate links and affiliate content. &lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;AdSense Arbitrage&lt;br /&gt;The process of buying traffic with pay-per-click programs, sending traffic to highly optimized Adsense pages and collecting the difference.&lt;br /&gt;&lt;br /&gt;AdSense Link Clicking Bots&lt;br /&gt;Automated programs that try to spoof random IP addresses to click through AdWords displayed on a site.&lt;br /&gt;&lt;br /&gt;Adwords&lt;br /&gt;Google’s - Cost Per Click (CPC) based advertising system.&lt;br /&gt;&lt;br /&gt;Affiliate Sniper&lt;br /&gt;People who save money on purchases by switching your affiliate ID with their own.&lt;br /&gt;&lt;br /&gt;Agent Name&lt;br /&gt;An agent name is the name of the software accessing a web page.&lt;br /&gt;&lt;br /&gt;Aggregator&lt;br /&gt;Software that lets you automatically download content to your computer&lt;br /&gt;&lt;br /&gt;AIDA&lt;br /&gt;Attention, Interest, Desire, Action: A term used to describe a formula to increase conversions.&lt;br /&gt;&lt;br /&gt;Algorithm&lt;br /&gt;A mathematical formula used to determine the value of a page when compared against others.&lt;br /&gt;&lt;br /&gt;AlltheWeb&lt;br /&gt;Second Tier search engine.&lt;br /&gt;&lt;br /&gt;ALT Text&lt;br /&gt;The text that appears when you put your mouse on top of an image or a picture. &lt;br /&gt;&lt;br /&gt;AltaVista&lt;br /&gt;Used to be the #1 search engine until Google came along.&lt;br /&gt;&lt;br /&gt;Anchor Text&lt;br /&gt;Also known as Link Text, the clickable text of a hyperlink.&lt;br /&gt;&lt;br /&gt;AOL&lt;br /&gt;America On-Line - Great for novice users, uses Google as part of it's search results.&lt;br /&gt;&lt;br /&gt;API&lt;br /&gt;Application Programming Interface.&lt;br /&gt;&lt;br /&gt;ASCII&lt;br /&gt;American Standard Code for Information Interchange&lt;br /&gt;&lt;br /&gt;Ask&lt;br /&gt;Trying to be considered as one of the "Top Dogs" along with Yahoo and MSN, following Google.&lt;br /&gt;&lt;br /&gt;ASP&lt;br /&gt;Dual meanings: Microsoft Active Server Pages (filename.asp) or Application Service Provider (e.g. a provider of web based applications)&lt;br /&gt;&lt;br /&gt;Astroturfing&lt;br /&gt;The practice of faking, pushing or help to mold a “grass roots” movement.&lt;br /&gt;&lt;br /&gt;ATF (Above the Fold)&lt;br /&gt;This is the part of the user's screen that is always displayed.&lt;br /&gt;&lt;br /&gt;Audioblog&lt;br /&gt;An audio web log in MP3 format and available for download to an MP3 player or a computer.&lt;br /&gt;&lt;br /&gt;Authority Site&lt;br /&gt;A site that has many In-Bound links coming to it, and very little outbound links.&lt;br /&gt;&lt;br /&gt;Back link&lt;br /&gt;A text link to your website from another website.&lt;br /&gt;&lt;br /&gt;Banned&lt;br /&gt;A term that means a site has been removed from a search engine's index.&lt;br /&gt;&lt;br /&gt;Banner Blindness&lt;br /&gt;The act of web visitors to ignoring advertisements on the site whether it is a graphic or text ad.&lt;br /&gt;&lt;br /&gt;BAP (Blog and Ping)&lt;br /&gt;A method (ab)used to get the search engines to quickly index your blog's content.&lt;br /&gt;&lt;br /&gt;Black Hat SEO&lt;br /&gt;A term referring to the practice of “unethical” SEO. These techniques are used to gain an advantage over your competition.&lt;br /&gt;&lt;br /&gt;Blind Traffic&lt;br /&gt;This is traffic that is extremely low quality often by low relevance pages.&lt;br /&gt;&lt;br /&gt;Blog&lt;br /&gt;A "Web Log" that is updated frequently and is usually the opinion of one person. Also joking stands for Better Listing on Google.&lt;br /&gt;&lt;br /&gt;Blogged&lt;br /&gt;Term referring to have bookmarked a blog in your browser.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Blogola&lt;br /&gt;The emerging practice of giving free stuff (from tote bags to travel junkets) to bloggers, in return for a sympathetic review.&lt;br /&gt;&lt;br /&gt;Blook&lt;br /&gt;A book that is serialized on a blog site. Chapters are published one by one as blog posts.&lt;br /&gt;&lt;br /&gt;Bot&lt;br /&gt;Short for robot. Often used to refer to a search engine spider.&lt;br /&gt;&lt;br /&gt;Browser&lt;br /&gt;Software application used to browse the internet - Mozilla Firefox and Internet Explorer are the 2 most popular browsers.&lt;br /&gt;&lt;br /&gt;BTF (Below the Fold)&lt;br /&gt;This is the part of the user's screen that is hidden unless the user scrolls down on the page.&lt;br /&gt;&lt;br /&gt;C Class IP&lt;br /&gt;This is the third block of numbers found in an IP Address. &lt;br /&gt;&lt;br /&gt;Cache&lt;br /&gt;A copy of web pages stored within a search engine's database.&lt;br /&gt;&lt;br /&gt;CAPTCHA &lt;br /&gt;Stands for : Completely Automated Public Turing test to tell Computers and Humans Apart&lt;br /&gt;&lt;br /&gt;Catablog&lt;br /&gt;A blog that describes products for sale.&lt;br /&gt;&lt;br /&gt;Click Arbitrage&lt;br /&gt;Purchasing PPC ads and hoping that traffic leaves with a click on your ads.&lt;br /&gt;&lt;br /&gt;Click Distance&lt;br /&gt;The minimum number of clicks it takes a visitor to get from one page to another.&lt;br /&gt;&lt;br /&gt;Click Flipping&lt;br /&gt;The process of identifying and maximizing, multiple profit pathways, using PPC traffic and converting that traffic with Cost Per Action offers.&lt;br /&gt;&lt;br /&gt;Click Pirates&lt;br /&gt;Peuple who click on ads, knowingly and proudly, stealing from advertisers, as they encourage others to join with them in this quest.&lt;br /&gt;&lt;br /&gt;Click Poison&lt;br /&gt;The process of using blatant phrases such as "Cool New Idea" and "Click here for Travel Tips" to get a site buried on sites such as digg and netscape.&lt;br /&gt;&lt;br /&gt;Click Through&lt;br /&gt;The process of clicking through an online advertisement to the advertiser's destination.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Clickprint&lt;br /&gt;Derived from the amount of time a user spends on a Web site and the number of pages viewed, a clickprint is a unique online fingerprint that can help a vendor identify return visitors, curb fraud, and collect personal information for "customer service." aka invasive marketing&lt;br /&gt;&lt;br /&gt;Cloaking&lt;br /&gt;A technique that shows keyword stuffed apges to a search engine, but a real page to a human user.&lt;br /&gt;&lt;br /&gt;Clustering&lt;br /&gt;In search engine search results pages, clustering is limiting each represented website to one or two listings. &lt;br /&gt;&lt;br /&gt;Collabulary&lt;br /&gt;A collaborative vocabulary for tagging Web content. Like the folksonomies used on social bookmarking sites like del.icio.us, collabularies are generated by a community. But unlike folksonomies, they're automatically vetted for consistency, extracting the wisdom of the crowds from the cacophony.&lt;br /&gt;&lt;br /&gt;Content Networks&lt;br /&gt;A nicer way to say Link Farm.&lt;br /&gt;&lt;br /&gt;Content Repurposing&lt;br /&gt;A nicer way to say scraping a site for content.&lt;br /&gt;&lt;br /&gt;Contextual Link Inventory (CLI)&lt;br /&gt;Text links that are shown depending on the content that appears around them.&lt;br /&gt;&lt;br /&gt;Conversion Optimization&lt;br /&gt;Transforms your site into a selling tool - your site logically leads visitors through the sales cycle and closes sale.&lt;br /&gt;&lt;br /&gt;Conversion Rate&lt;br /&gt;The number of visitors to a website that end up performing a specific action that leads to a conversion. This could be a product purchase, newsletter sign up or anything where information is submitted.&lt;br /&gt;&lt;br /&gt;Converting Search Phrase&lt;br /&gt;A phrase that converts traffic into money.&lt;br /&gt;&lt;br /&gt;Cookie&lt;br /&gt;Information stored on a user's computer by a website.&lt;br /&gt;&lt;br /&gt;Copy&lt;br /&gt;Text found on a web page.&lt;br /&gt;&lt;br /&gt;Cost per Thousand&lt;br /&gt;The cost for each thousand impressions of your ad.&lt;br /&gt;&lt;br /&gt;CPA - (Cost Per Action)&lt;br /&gt;The price paid for each visitor's actions from a paid search.&lt;br /&gt;&lt;br /&gt;CPC (Cost Per Click)&lt;br /&gt;The amount it will cost each time a user selects your phrase or keyword.&lt;br /&gt;&lt;br /&gt;Crawler&lt;br /&gt;A bot from a search engine that reads the text found on a website in order to determine what the website is about.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Cross Linking&lt;br /&gt;Having multiple websites linking to each other.&lt;br /&gt;&lt;br /&gt;CSS (Cascading Style Sheets)&lt;br /&gt;Used to define the look and navigation of a website.&lt;br /&gt;&lt;br /&gt;CTR (Click Through Rate)&lt;br /&gt;The value associated to the amount of times a paid ad is viewed.&lt;br /&gt;&lt;br /&gt;Cybrarian&lt;br /&gt;A person who finds, collects, and manages information available on the Internet.&lt;br /&gt;&lt;br /&gt;Dangling Link&lt;br /&gt;This term is applied to a web page with no links to any other pages. Also known as an Orphan Page.&lt;br /&gt;&lt;br /&gt;Dead Link&lt;br /&gt;A hyperlink pointing to a non-existent URL.&lt;br /&gt;&lt;br /&gt;Deep Crawl&lt;br /&gt;Once a month, Googlebot will crawl all of the links it has listed in it's database on your site. This is known as the Deep Crawl.&lt;br /&gt;&lt;br /&gt;Deep Link&lt;br /&gt;A link on a website that is not reachable from the home page.&lt;br /&gt;&lt;br /&gt;Delisting&lt;br /&gt;When a site gets removed from the search index of a search engine.&lt;br /&gt;&lt;br /&gt;Deliverable&lt;br /&gt;In a contract, these are the expected results of the services provided.&lt;br /&gt;&lt;br /&gt;diggbait&lt;br /&gt;Purposely creating content to get traffic from digg.com&lt;br /&gt;&lt;br /&gt;Directory&lt;br /&gt;Usually human edited, a directory contains sites that are sorted by categories.&lt;br /&gt;&lt;br /&gt;DMCA (Digital Millennium Copyright Act)&lt;br /&gt;A declaration that protects digital works found online.&lt;br /&gt;&lt;br /&gt;DMOZ&lt;br /&gt;Also known as the Open Directory Project.&lt;br /&gt;&lt;br /&gt;DNO&lt;br /&gt;Domain Network Optimizers&lt;br /&gt;&lt;br /&gt;DNS (Domain Name System)&lt;br /&gt;A protocol that lets computers recognize each other through an IP Address, whereas the human sees a website URL.&lt;br /&gt;&lt;br /&gt;Dooced&lt;br /&gt;Fired for negative blogging about the company you work for.&lt;br /&gt;&lt;br /&gt;Doorway Page&lt;br /&gt;A web page designed to draw in Internet traffic from search engines, and then direct this traffic to another website. &lt;br /&gt;&lt;br /&gt;Dynamic Site&lt;br /&gt;A site that uses a database to store it's content and is delivered based on the variable passed to the page.&lt;br /&gt;&lt;br /&gt;EPC (Earnings Per Click)&lt;br /&gt;How much profit is made from each click from a paid ad.&lt;br /&gt;&lt;br /&gt;EPV (Earnings Per Visitor)&lt;br /&gt;The cost it takes to make profit from a site's total number of visitors.&lt;br /&gt;&lt;br /&gt;Error 404&lt;br /&gt;When a hyperlink is pointing to a location on the web that doesn't exist, it is called a 404 error.&lt;br /&gt;&lt;br /&gt;Everflux&lt;br /&gt;A term associated with the constant updating of Google's algorithm between the major updates.&lt;br /&gt;&lt;br /&gt;External Link&lt;br /&gt;A link that points to another website.&lt;br /&gt;&lt;br /&gt;FAQ (Frequently Asked Question)&lt;br /&gt;Commonly found on websites, FAQs answer questions that many users generally have about a product or service.&lt;br /&gt;&lt;br /&gt;FFA (Free For All)&lt;br /&gt;A site where anyone can list their link. Don't waste any time submitting your site to these places.&lt;br /&gt;&lt;br /&gt;Filter Words&lt;br /&gt;Words such as is, am, were, was, the, for, do, ETC, that search engines deem irrelevant for indexing purposes. Also known as Stop words. &lt;br /&gt;&lt;br /&gt;Flog&lt;br /&gt;A fake blog, a website pretending to be a blog but actually the creation of public relations firms, the mainstream media, or professional political operatives.&lt;br /&gt;&lt;br /&gt;Folksonomy&lt;br /&gt;The construction of open-ended organization systems that allow multiple internet users to sort web sites and their elements.&lt;br /&gt;&lt;br /&gt;Frankenbuild&lt;br /&gt;Pirated software cobbled together from beta versions and early releases.&lt;br /&gt;&lt;br /&gt;Fresh Crawl&lt;br /&gt;Utilizes FreshBot to review already indexed pages and any pages where the content has been updated.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;FreshBot&lt;br /&gt;A sister to GoogleBot, this spider crawls highly ranked sites on a very frequent basis.&lt;br /&gt;&lt;br /&gt;FTP (File Transfer Protocol)&lt;br /&gt;Technology that allows file transfers from a local machine to a remote host.&lt;br /&gt;&lt;br /&gt;Geo Targeting&lt;br /&gt;A very tactful way to employ cloaking.&lt;br /&gt;&lt;br /&gt;GFNR&lt;br /&gt;Google First Name Rank.&lt;br /&gt;&lt;br /&gt;Google&lt;br /&gt;Currently, the world's #1 search engine.&lt;br /&gt;&lt;br /&gt;Google AdWords&lt;br /&gt;Google's PPC program.&lt;br /&gt;&lt;br /&gt;Google Bombing&lt;br /&gt;A technique where using the same text anchor links, many people link to a certain page, usually of irrelevant content.&lt;br /&gt;&lt;br /&gt;GoogleBot&lt;br /&gt;The spider that performs a deep crawl of your site.&lt;br /&gt;&lt;br /&gt;Googlebowling&lt;br /&gt;To nudge a competitor from the serps.&lt;br /&gt;&lt;br /&gt;Googlephobia&lt;br /&gt;The fear of Google taking over everything.&lt;br /&gt;&lt;br /&gt;Googlewashing&lt;br /&gt;When your content is copied and inserted into someone else's site without permission or credit.&lt;br /&gt;&lt;br /&gt;GOOGOL&lt;br /&gt;This is the term that inspired the creators of Google to use this name - it means: 10100 = 1 followed by 100 zeros&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Heading Tag&lt;br /&gt;Tag that designates headlines in the text of a site.&lt;br /&gt;&lt;br /&gt;Hidden Text&lt;br /&gt;Text that can't be seen normally in a browser.&lt;br /&gt;&lt;br /&gt;Hit&lt;br /&gt;A single access request made to the server.&lt;br /&gt;&lt;br /&gt;Hoax Marketing&lt;br /&gt;The creation of false stories to drive traffic to a site.&lt;br /&gt;&lt;br /&gt;htaccess&lt;br /&gt;.htaccess is an Apache file that allows server configuration instructions.&lt;br /&gt;&lt;br /&gt;HTML&lt;br /&gt;HyperText Markup Language - the basics for all web coding.&lt;br /&gt;&lt;br /&gt;HTTP (Hypertext Transfer Protocol)&lt;br /&gt;It is a generic, stateless, protocol which can be used for many tasks.&lt;br /&gt;&lt;br /&gt;HTTPS (HyperText Transfer Protocol Secure)&lt;br /&gt;It is a generic, stateless, protocol which can be used for many tasks, but has security features enabled to protect sensitive data.&lt;br /&gt;&lt;br /&gt;Hub&lt;br /&gt;A site that has many outbound links, and few sites linking back.&lt;br /&gt;&lt;br /&gt;IBL (In-Bound Link)&lt;br /&gt;A link residing on another site that points to your site.&lt;br /&gt;&lt;br /&gt;ICRA (Internet Content Rating Association)&lt;br /&gt;The Internet Content Rating Association (ICRA) is an international, non-profit organization of internet leaders working to make the internet safer for children, while respecting the rights of content providers.&lt;br /&gt;&lt;br /&gt;IM (Instant Messaging)&lt;br /&gt;As the name implies, this protocol allows for extremely fast communication over the Internet&lt;br /&gt;&lt;br /&gt;Index&lt;br /&gt;A term used to describe the database that holds all the web pages crawled by the search engine for each website.&lt;br /&gt;&lt;br /&gt;Indexing Assistance&lt;br /&gt;An even more advanced form of cloaking.&lt;br /&gt;&lt;br /&gt;Information Architecture&lt;br /&gt;The gathering, organizing, and presenting information to serve a purpose. &lt;br /&gt;&lt;br /&gt;Informational Query&lt;br /&gt;A query about a topic where the user expects to be provided with information on the topic.&lt;br /&gt;&lt;br /&gt;Internal Link&lt;br /&gt;A link that points to another page within the same site. Most commonly used for navigation.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Internet&lt;br /&gt;An interconnected system of networks that connects computers around the world via the TCP/IP protocol.&lt;br /&gt;&lt;br /&gt;Internet Traffic Optimizer (ITO)&lt;br /&gt;A broader term for a person who optimizes not only for search engines but to get traffic from other sources such as blogs, RSS feeds and articles.&lt;br /&gt;&lt;br /&gt;Interstitials&lt;br /&gt;Loads a commercial in the background of a Web page. When the user exits the page, the user gets served a full-page, between-page advertisement in Flash, an animated gif or other rich media.&lt;br /&gt;&lt;br /&gt;Invisible Web&lt;br /&gt;Web Pages that are not reachable by search engines.&lt;br /&gt;&lt;br /&gt;IP (Internet Protocol)&lt;br /&gt;This protocol allows for machines to communicate to each other via the Internet.&lt;br /&gt;&lt;br /&gt;IP Address (Internet Protocol Address)&lt;br /&gt;how data finds its way back and forth from your computer to the internet.&lt;br /&gt;&lt;br /&gt;IP Spoofing&lt;br /&gt;A method of reporting an IP address other than your own when connecting to the internet.&lt;br /&gt;&lt;br /&gt;js (JavaScript)&lt;br /&gt;A scripting language that provides browser functionality.&lt;br /&gt;&lt;br /&gt;Keyword Density&lt;br /&gt;A ratio of the number of occurrences of a keyword or "keyword phrase" to the total number of words on a page.&lt;br /&gt;&lt;br /&gt;Keyword Effectiveness Index (KEI)&lt;br /&gt;The KEI compares the number of searches for a keyword with the number of search results to pinpoint which keywords should be the most effective for your campaign.&lt;br /&gt;&lt;br /&gt;Keyword Phrase&lt;br /&gt;A group of words that form a search query.&lt;br /&gt;&lt;br /&gt;Keyword Stuffing&lt;br /&gt;Using a keyword or "keyword phrase" excessively in a web page, perhaps in the text content or meta tags.&lt;br /&gt;&lt;br /&gt;Klog&lt;br /&gt;The term used when weblogs are used in knowledge management use cases.&lt;br /&gt;&lt;br /&gt;KW (Key Words)&lt;br /&gt;Used to define the terms a user might enter into a search engine to find information on their query.&lt;br /&gt;&lt;br /&gt;Landing Page&lt;br /&gt;Usually used in conjunction with a PPC campaign, they are call-to-action pages that prompt the user to engage the site.&lt;br /&gt;&lt;br /&gt;Link&lt;br /&gt;Also known as a hyperlink, it is the "clickable" area of text or image that allows for navigation on the Internet. Also the name of the main character og the Legend of Zelda video games.&lt;br /&gt;&lt;br /&gt;Link Bait (Linkbaiting)&lt;br /&gt;The process of getting users to link to your site.&lt;br /&gt;&lt;br /&gt;Link Farm&lt;br /&gt;A site that features links in no particular order which are totally unrelated to each other. &lt;br /&gt;&lt;br /&gt;Link Maximization&lt;br /&gt;The method of getting popular sites in your industry to link to your website.&lt;br /&gt;&lt;br /&gt;Link Partner&lt;br /&gt;A website who is willing to put a link to your site from their website. Quite often link partners engage in reciprocal linking.&lt;br /&gt;&lt;br /&gt;Link Popularity&lt;br /&gt;How many sites link to your website.&lt;br /&gt;&lt;br /&gt;Link Text&lt;br /&gt;The clickable part of a hyperlink. Also known as Anchor Text or Anchor Link.&lt;br /&gt;&lt;br /&gt;Linkerati&lt;br /&gt;People who are the target of linkbait - bloggers, forum users, social taggers, etc.&lt;br /&gt;&lt;br /&gt;Listings&lt;br /&gt;The results that a search engine returns for a particular search term.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Mashups&lt;br /&gt;Commonly thought of as a way of merging two different items, or scraping more than one source.&lt;br /&gt;&lt;br /&gt;Meta Description Tag&lt;br /&gt;Hold the description of the content found on the page.&lt;br /&gt;&lt;br /&gt;Meta Keywords Tag&lt;br /&gt;Holds the keywords that are found on the page.&lt;br /&gt;&lt;br /&gt;Meta Search Engine&lt;br /&gt;A search engine that relies on the meta data found in meta tags to determine relevancy.&lt;br /&gt;&lt;br /&gt;Meta Tag Masking&lt;br /&gt;An old trick that uses CGI codes to hide the Meta tags from browsers while allowing search engines to actually see the Meta tags.&lt;br /&gt;&lt;br /&gt;Meta Tags&lt;br /&gt;Header tags that provide information about the content of a site.&lt;br /&gt;&lt;br /&gt;Metadata&lt;br /&gt;META Tags or what are officially referred to as Metadata Elements, are found within the section of your web pages.&lt;br /&gt;&lt;br /&gt;Metajacking&lt;br /&gt;The use of copyrighted names and slogans in META tags.&lt;br /&gt;&lt;br /&gt;MFA (Made For AdSense)&lt;br /&gt;A term that describes websites that are created entirely for the purpose of gaming Google Adsense to make money.&lt;br /&gt;&lt;br /&gt;MFD&lt;br /&gt;Made For Digg - Similar to MFA (Made for AdSense) sites, these sites try to get traffic from digg by having entire sites full of funny images or postings.&lt;br /&gt;&lt;br /&gt;Microchunk&lt;br /&gt;To split up a product or service sold traditionally as a package, offering each piece to buyers a la carte.&lt;br /&gt;&lt;br /&gt;MicroFormats&lt;br /&gt;Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards. Instead of throwing away what works today, microformats intend to solve simpler problems first by adapting to current behaviors and usage patterns (e.g. XHTML, blogging). - taken from (http://microformats.org/about/)&lt;br /&gt;&lt;br /&gt;Mirror Sites&lt;br /&gt;A mirror site is a site that exacltly duplicates another site.&lt;br /&gt;&lt;br /&gt;Mobisode&lt;br /&gt;TV shows shot exclusively for mobile phones.&lt;br /&gt;&lt;br /&gt;MoBlog&lt;br /&gt;Short for "My Mobile Blog", a service from Blogger that when you send an email to go@blogger.com from your cellphone, it automatically creates a new blog.&lt;br /&gt;&lt;br /&gt;Mociology&lt;br /&gt;The study of how people adapt and use wireless technologies.&lt;br /&gt;&lt;br /&gt;Most Wanted Response (MWR)&lt;br /&gt;This is what you want your customer to do on your site.&lt;br /&gt;&lt;br /&gt;Mowser&lt;br /&gt;Short for Mobile Browser.&lt;br /&gt;&lt;br /&gt;MP3&lt;br /&gt;Stands for “MPEG Third Layer.” A standard for storing and transmitting music in digital format across the Internet.&lt;br /&gt;&lt;br /&gt;MSN (MicroSoft Network)&lt;br /&gt;Microsoft's search engine.&lt;br /&gt;&lt;br /&gt;Narrowcasting&lt;br /&gt;Creating a program aimed at a small and specific niche or group of people.&lt;br /&gt;&lt;br /&gt;Natural Listing&lt;br /&gt;A listing that appears below the sponsored ads, also known as Organic Listings.&lt;br /&gt;&lt;br /&gt;Navigational Query&lt;br /&gt;A query that normally has only one satisfactory result.&lt;br /&gt;&lt;br /&gt;NDA (Non-Disclosure Agreement)&lt;br /&gt;Usually required as part of a contract to protect the company engaging in services.&lt;br /&gt;&lt;br /&gt;Necroing&lt;br /&gt;The act of posting to old threads to bring them back up. Also known as "bumping".&lt;br /&gt;&lt;br /&gt;Niche&lt;br /&gt;A specialized segment of a market that is usually geared towards one specific purpose.&lt;br /&gt;&lt;br /&gt;Niche Aggregators&lt;br /&gt;Another way of saying Spam site.&lt;br /&gt;&lt;br /&gt;NOFOLLOW&lt;br /&gt;An attribute used in a hyperlink to instruct search engines not to follow the link. (And pass PageRank)&lt;br /&gt;&lt;br /&gt;Off-Page Factors&lt;br /&gt;Factors that alter search engine positions that occur externally from other website's. By having many links from other sites pointing to yours is an example of Off-Page Factors.&lt;br /&gt;&lt;br /&gt;On-Page Factors&lt;br /&gt;Factors that determine search engine positions that occur internally within a page of a website. This can include site copy, page titles, and navigational structure of the site.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;OOP (Over Optimization Penalty)&lt;br /&gt;A theory that applies if one targets only 1 keyword or phrase, and the search engines view the linking efforts to be spam.&lt;br /&gt;&lt;br /&gt;OpenRank (Open Source PageRank)&lt;br /&gt;A suggestion to make a web-wide ranking system as opposed to Google's Pagerank.&lt;br /&gt;&lt;br /&gt;Opt-In&lt;br /&gt;When a user willing joins a subscription to a newsletter or some other service.&lt;br /&gt;&lt;br /&gt;Organic Listing&lt;br /&gt;The natural results returned by a search engine.&lt;br /&gt;&lt;br /&gt;Orphan Page&lt;br /&gt;A page that has a link to it, but has no links to any other sites.&lt;br /&gt;&lt;br /&gt;Outbound Link&lt;br /&gt;A link from your site to any other site.&lt;br /&gt;&lt;br /&gt;Page View&lt;br /&gt;Anytime a user looks at any page on a website through their browser.&lt;br /&gt;&lt;br /&gt;PageMatch&lt;br /&gt;A cost-per-click advertising program that serves your site's ad on a page that contains related content.&lt;br /&gt;&lt;br /&gt;PageRank Drain&lt;br /&gt;When a page has no outbound links, it causes pagerank drain because it cannot pass any value to another web page.&lt;br /&gt;&lt;br /&gt;Paid Inclusion&lt;br /&gt;A submission service where you pay a fee to a search engine and the search engine guarantees that your website will be included in its index. Paid inclusion programs will also ensure that your website is indexed very fast and crawled on regular basis. It can also be used as a term to include fee based directory submission.&lt;br /&gt;&lt;br /&gt;Pay-Per-Click Management&lt;br /&gt;Strategy, Planning and Placement of targeted keywords in the paid search results.&lt;br /&gt;&lt;br /&gt;PFI (Pay For Inclusion)&lt;br /&gt;A system in which a site pays to get a guaranteed listing.&lt;br /&gt;&lt;br /&gt;PFP (Pay For Performance)&lt;br /&gt;A system in which payment for services is only made when a conversion takes place.&lt;br /&gt;&lt;br /&gt;Podcasting&lt;br /&gt;A Podcast is just an audio file that is syndicated via an RSS feed, that is downloaded and listened to with a computer or a portable device such as an iPod.&lt;br /&gt;&lt;br /&gt;Podcatching&lt;br /&gt;The process of subscribing to podcasts.&lt;br /&gt;&lt;br /&gt;PPC (Pay Per Click)&lt;br /&gt;A technique where placements are determined by how much id bid on a particular keyword or phrase. Can become very expensive.&lt;br /&gt;&lt;br /&gt;PR (Google's PageRank)&lt;br /&gt;Google's unique system of how it tries to predict the value of a pages rank.&lt;br /&gt;&lt;br /&gt;Pro Blogging&lt;br /&gt;A person who makes a living by blogging.&lt;br /&gt;&lt;br /&gt;Query&lt;br /&gt;An inquiry that is entered into a search engine in order to get results.&lt;br /&gt;&lt;br /&gt;Rank - Ranking&lt;br /&gt;The actual position of a website on a search engine results page for a certain search term or phrase.&lt;br /&gt;&lt;br /&gt;Reciprocal Link&lt;br /&gt;When two sites link to each other.&lt;br /&gt;&lt;br /&gt;Redirects&lt;br /&gt;Either server side or scripting language that tells the search engine to go to another URL automatically.&lt;br /&gt;&lt;br /&gt;Referral Spam&lt;br /&gt;Sending multiple requests to a website spoofing the header to make it look like real traffic is being sent to another site.&lt;br /&gt;&lt;br /&gt;Referrer&lt;br /&gt;A referrer is the URL of the page that the visitor came from when he entered a website.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Relevance Rank (RR)&lt;br /&gt;A system in which the search engine tries to determine the theme of a site that a link is coming from&lt;br /&gt;&lt;br /&gt;Relevancy&lt;br /&gt;Term used to describe how close the content of a page is in relation to the keyword phrase used to search.&lt;br /&gt;&lt;br /&gt;Results Page&lt;br /&gt;When a user conducts a search, the page that is displayed, is called the results page. Sometimes it may be called SERPs, which stands for "search engine results page."&lt;br /&gt;&lt;br /&gt;RFP (Request for Proposal)&lt;br /&gt;Used to send out to multiple companies in order to get a list of services to be delivered and at what cost.&lt;br /&gt;&lt;br /&gt;Rich Internet Applications (RIA)&lt;br /&gt;Applications such as Ajax and Flash that provide a better user experience by delivering content in an on-demand web environment.&lt;br /&gt;&lt;br /&gt;Robot&lt;br /&gt;Often used to refer to a search engine spider.&lt;br /&gt;&lt;br /&gt;ROC (Return on Customer)&lt;br /&gt;The value each customer brings.&lt;br /&gt;&lt;br /&gt;ROI (Return on Investment)&lt;br /&gt;The cost it takes to in order to see success on your marketing investment.&lt;br /&gt;&lt;br /&gt;RSS Feed (Rich Site Summary or Rich Site Syndication)&lt;br /&gt;RSS feeds use an XML document to publish information.&lt;br /&gt;&lt;br /&gt;Scope Creep &lt;br /&gt;When the contracted amount of work to be completed changes because of client changes or technology advances.&lt;br /&gt;&lt;br /&gt;SE (Search Engine)&lt;br /&gt;A web based information retrieval program.&lt;br /&gt;&lt;br /&gt;Search Engine&lt;br /&gt;Best described as a database of websites users can search using search terms. Every search engine has its own algorithm which defines how the results are displayed.&lt;br /&gt;&lt;br /&gt;Search Engine Marketing (SEM)&lt;br /&gt;The practice of getting a website found on the internet&lt;br /&gt;&lt;br /&gt;Search Engine Optimization (SEO)&lt;br /&gt;The act of altering code to a website to have optimum relevance to a search engine spider.&lt;br /&gt;&lt;br /&gt;Search Friendly Optimization (SFO)&lt;br /&gt;As the term implies, this is the process of making a website search engine friendly.&lt;br /&gt;&lt;br /&gt;Search Query&lt;br /&gt;The text entered into the search box on a search engine.&lt;br /&gt;&lt;br /&gt;SEOlebirty&lt;br /&gt;Famous people in the world of search.&lt;br /&gt;&lt;br /&gt;SERP (Search Engine Results Page)&lt;br /&gt;The results that are displayed after making a query into a search box.&lt;br /&gt;&lt;br /&gt;SFO&lt;br /&gt;Search Friendly Optimization.&lt;br /&gt;&lt;br /&gt;Sitemap (Site Map)&lt;br /&gt;A page that lists all of the critical navigation points of a website.&lt;br /&gt;&lt;br /&gt;Slurp&lt;br /&gt;The name of Yahoo's Search Engine Spider.&lt;br /&gt;&lt;br /&gt;Smishing&lt;br /&gt;Phishing via text message. Smishers bombard cell phones with SMS versions of standard phishing solicitations, directing victims to Web sites that install spyware on their computers.&lt;br /&gt;&lt;br /&gt;Snippet&lt;br /&gt;The text displayed from a search query.&lt;br /&gt;&lt;br /&gt;Social Media Poisoning&lt;br /&gt;A technique where unscrupulous marketers will try to sabotage a competitor's web site by engaging in social media communications and link seeding/spamming tactics that they hope will spark a rash of bad publicity, and maybe even trigger some sort of rankings and/or reputational search penalty against their competitor.&lt;br /&gt;&lt;br /&gt;SPAM&lt;br /&gt;Unwanted email or irrelevant content delivered. (or as some say, Site Placed Above Mine)&lt;br /&gt;&lt;br /&gt;Spam Cannon&lt;br /&gt;A term used in conjunction with sites that use email sign-ups for spamming purposes - the latimes.com is an example.&lt;br /&gt;&lt;br /&gt;Spamming&lt;br /&gt;The act of delivering unwanted messages to the masses.&lt;br /&gt;&lt;br /&gt;Spamouflage&lt;br /&gt;The method or result of concealing or disguising search engine spam to make it appear to be legitimate.&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;Spider&lt;br /&gt;The software that crawls your site to try and determine the content it finds.&lt;br /&gt;&lt;br /&gt;Spiderbaiting&lt;br /&gt;A technique that makes a search engine spider find your site.&lt;br /&gt;&lt;br /&gt;Splash Page&lt;br /&gt;A page displayed for viewing before reaching the main page.&lt;br /&gt;&lt;br /&gt;Stemming&lt;br /&gt;The main part of a word to which affixes are added.&lt;br /&gt;&lt;br /&gt;Stickiness&lt;br /&gt;How influential your site is in keeping a visitor on your page.&lt;br /&gt;&lt;br /&gt;Stop Word&lt;br /&gt;A stop word is a "common word" which is ignored in a query because the word makes no contribution to the relevancy of the query. &lt;br /&gt;&lt;br /&gt;Stop Word&lt;br /&gt;Stop words are very common words such as ‘a, the, and &amp; that’ and are filtered out of your search query. Search engines do this in order to try to serve the best results for a user query.&lt;br /&gt;&lt;br /&gt;Strategic Linking&lt;br /&gt;A thought out approach to getting websites to link to your site.&lt;br /&gt;&lt;br /&gt;Submission&lt;br /&gt;The process of submitting URL(s) to search engines or directories.&lt;br /&gt;&lt;br /&gt;SWOT&lt;br /&gt;A methodic way of identifying your Strengths and Weaknesses, and of examining the Opportunities and Threats you face.&lt;br /&gt;&lt;br /&gt;Syntax&lt;br /&gt;The proper use of language when coding a website.&lt;br /&gt;&lt;br /&gt;Tag Soup&lt;br /&gt;Tag soup is HTML code written without regard for the rules of HTML structure and semantics.&lt;br /&gt;&lt;br /&gt;The Deep Web&lt;br /&gt;The content in databases that rarely shows up in Web searches. It is estimated that there are 500 billion Web pages that could potentially be hidden.&lt;br /&gt;&lt;br /&gt;Theme&lt;br /&gt;What the site's main topic is about.&lt;br /&gt;&lt;br /&gt;Thin Affiliates&lt;br /&gt;Doorways that send visitors to affiliate programs, earning a commission for doing so, while providing little or no value-added content or service to the user.&lt;br /&gt;&lt;br /&gt;Title Tag&lt;br /&gt;It should be used to describe the web page using targeted keywords using no more that 60 characters, including spaces.&lt;br /&gt;&lt;br /&gt;TLD (Top Level Domain)&lt;br /&gt;Most commonly thought of as a ".com", also includes ".org" and ".edu"&lt;br /&gt;&lt;br /&gt;TOM (Tactical Online Marketing)&lt;br /&gt;The process of informing the customer of your services from various sources.&lt;br /&gt;&lt;br /&gt;TOS (Terms of Service)&lt;br /&gt;Usually found in a contract, also known as the contracts "deliverables".&lt;br /&gt;&lt;br /&gt;Tracking URL&lt;br /&gt;Usually used in PPC campaigns, it is a URL that has special code added to it so that results can be monitored.&lt;br /&gt;&lt;br /&gt;Traffic&lt;br /&gt;The number of visitors a website receives over a given period. Usually reported on a monthly basis.&lt;br /&gt;&lt;br /&gt;Transactional Query&lt;br /&gt;A query where the user expects to conduct a transaction.&lt;br /&gt;&lt;br /&gt;Trusted Feed&lt;br /&gt;A form of paid inclusion which uses bulk a XML feed to directly send website content to search engines for indexing. The feed can be optimized so that your website can take advantage better rankings and therefore more traffic&lt;br /&gt;&lt;br /&gt;TrustRank&lt;br /&gt;A method of using a combination of limited human site review in conjunction with a search engines algorithm.&lt;br /&gt;&lt;br /&gt;Typosquatting&lt;br /&gt;Relies on typographical errors by users to serve up websites that look like Google to launch viruses and trojans to unsuspecting users.&lt;br /&gt;&lt;br /&gt;Unique Visitor&lt;br /&gt;When a user visits a website, his/her IP address is logged so if he/she returns later on that day, the visit won’t be counted as a unique visit but as a page impression. &lt;br /&gt;&lt;br /&gt;Universal Search&lt;br /&gt;Launched on May 16, 2007, this is Google's attempt to deliver the best result from the web. This can include video, images, news, podcasts or any other form of digital content.&lt;br /&gt;&lt;br /&gt;URL (Uniform Resource Locator)&lt;br /&gt;Commonly referred to as the domain name, this is how humans navigate through the Internet, whereas computers use IP addresses.&lt;br /&gt;&lt;br /&gt;User Agent&lt;br /&gt;A User agent name is the name of the software accessing a web page. (Another term for Agent Name)&lt;br /&gt;&lt;br /&gt;USP (Unique Selling Proposition)&lt;br /&gt;Sometimes mistakenly defined as Unique Selling Point. The Unique Selling Proposition concept was first developed by Rosser Reeves of the Ted Bates Agency. Basically, it's what sets you apart from your competition.&lt;br /&gt;&lt;br /&gt;VEO&lt;br /&gt;Visitor Enhanced Optimization&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;VoIP (Voice Over Internet Protocol)&lt;br /&gt;VoIP converts the voice signal from your telephone into a digital signal that travels over the internet then converts it back at the other end so you can speak to anyone with a regular phone number.&lt;br /&gt;&lt;br /&gt;Web Saturation&lt;br /&gt;How many pages of your site are indexed by the search engines collectively.&lt;br /&gt;&lt;br /&gt;Webneck&lt;br /&gt;Slang term for a person who spends most of their time on the internet, most of their friends are netpals, and they are uncomfortable if they can't get online.&lt;br /&gt;&lt;br /&gt;White Hat SEO&lt;br /&gt;A term that refers to ethical practice of SEO methodologies that adhere to search engine Terms of Service. &lt;br /&gt;&lt;br /&gt;White Paper&lt;br /&gt;A White Paper is your statement about how a problem should be solved.&lt;br /&gt;&lt;br /&gt;Whois Data&lt;br /&gt;Registration data such as the company name, address and telephone number when registering a domain name.&lt;br /&gt;&lt;br /&gt;Whore Trains&lt;br /&gt;A list of people on MySpace that you add yourself to and keep reposting the list so that you can get a lot of people requesting to be your friends.&lt;br /&gt;&lt;br /&gt;Wi-Fi (certification mark)&lt;br /&gt;Used to certify the interoperability of wireless computer networking devices.&lt;br /&gt;&lt;br /&gt;WikiSoldiers&lt;br /&gt;Users who enjoy the process of building and defending wikipedia.&lt;br /&gt;&lt;br /&gt;Wilf&lt;br /&gt;What was I looking for?&lt;br /&gt;&lt;br /&gt;WWW (World Wide Web)&lt;br /&gt;Another term to describe the Internet.&lt;br /&gt;&lt;br /&gt;XML (Extensible Markup Language (filename.xml))&lt;br /&gt;A scripting language that allows the programmer to define the properties of the document. &lt;br /&gt;&lt;br /&gt;Yahoo!&lt;br /&gt;The #2 Search Engine in the world.&lt;br /&gt;&lt;br /&gt;Zeitgeist (Google Zeitgesit)&lt;br /&gt;A service provided that shows snippets of the emerging and declining trends of what people are searching for through the Google search engine.</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>Search Engine Optimization - SEO Workout</title><link>http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html</link><category>Article</category><category>Ebook</category><category>SEO</category><author>noreply@blogger.com (Unknown)</author><pubDate>Tue, 22 Apr 2008 05:24:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-2833651427414020978</guid><description>&lt;table cellspacing="0" cellpadding="0"&gt;  &lt;tr&gt;    &lt;td align="center"&gt;&lt;h1&gt;&lt;strong&gt;What is Search Engine Optimization? (SEO)&lt;/strong&gt;&lt;/h1&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td align="center"&gt;&lt;div align="center"&gt; Add to:&amp;nbsp; &lt;a href="http://www.technorati.com/faves?add=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Technorati&lt;/a&gt; | &lt;a href="http://digg.com/submit?phase=2&amp;amp;url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Digg&lt;/a&gt; | &lt;a href="http://del.icio.us/post?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;del.icio.us&lt;/a&gt; | &lt;a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=What%20is%20Search%20Engine%20Optimization&amp;amp;u=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Yahoo&lt;/a&gt; | &lt;a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;amp;Url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html;Title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;BlinkList&lt;/a&gt; | &lt;a href="http://www.spurl.net/spurl.php?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html&amp;amp;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;Spurl&lt;/a&gt; | &lt;a href="http://reddit.com/submit?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html&amp;amp;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;reddit&lt;/a&gt; | &lt;a href="http://www.furl.net/storeIt.jsp?t=What%20is%20Search%20Engine%20Optimization&amp;amp;u=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Furl&lt;/a&gt; &lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td&gt; Search Engine Optimization is the process of making changes to the  coding of a website in order to rank better in the search engine  results page. There are many steps involved in the process, many of  which include the following:&lt;br&gt;        &lt;ul&gt;          &lt;li&gt;W3C Validation&lt;/li&gt;          &lt;li&gt;Proper naming structure of files for search engines&lt;/li&gt;          &lt;li&gt;Proper phrasing of the page title&lt;/li&gt;          &lt;li&gt;Inclusion of a robots.txt file&lt;/li&gt;          &lt;li&gt;Creation of a sitemap&lt;/li&gt;          &lt;li&gt;404 error handling page&lt;/li&gt;          &lt;li&gt;Meta tags&lt;/li&gt;          &lt;li&gt;Relevant site copy to page title&lt;/li&gt;          &lt;li&gt;Site navigational structure&lt;/li&gt;        &lt;/ul&gt;      While this is a short list, there are many considerations that have to  accounted for when optimizing your website. A knowledgeable Search  Marketer should be able to determine what would be the best process to  get your site coded in a search engine friendly fashion.&lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;&lt;table cellspacing="0" cellpadding="0"&gt;  &lt;tr&gt;    &lt;td align="center"&gt;&lt;h1&gt;&lt;strong&gt;What is Search Engine Marketing? (SEM)&lt;/strong&gt;&lt;/h1&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td align="center"&gt;&lt;div align="center"&gt;Add to:&amp;nbsp; &lt;a href="http://www.technorati.com/faves?add=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Technorati&lt;/a&gt; | &lt;a href="http://digg.com/submit?phase=2&amp;amp;url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Digg&lt;/a&gt; | &lt;a href="http://del.icio.us/post?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;del.icio.us&lt;/a&gt; | &lt;a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=What%20is%20Search%20Engine%20Optimization&amp;amp;u=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Yahoo&lt;/a&gt; | &lt;a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;amp;Url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html;Title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;BlinkList&lt;/a&gt; | &lt;a href="http://www.spurl.net/spurl.php?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html&amp;amp;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;Spurl&lt;/a&gt; | &lt;a href="http://reddit.com/submit?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html&amp;amp;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;reddit&lt;/a&gt; | &lt;a href="http://www.furl.net/storeIt.jsp?t=What%20is%20Search%20Engine%20Optimization&amp;amp;u=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Furl&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td&gt; Search Engine Marketing is the process of getting targeted traffic to  your site by getting exposure of your site through various channels.  Here are some examples of getting exposure for your site:&lt;br&gt;        &lt;ul&gt;          &lt;li&gt;Press Releases&lt;/li&gt;          &lt;li&gt;Article Writing&lt;/li&gt;          &lt;li&gt;Blogs&lt;/li&gt;          &lt;li&gt;Engaging in a link campaign&lt;/li&gt;          &lt;li&gt;Directory Submission&lt;/li&gt;          &lt;li&gt;Purchasing Text Links&lt;/li&gt;          &lt;li&gt;PPC Campaigns&lt;/li&gt;          &lt;li&gt;Banner Advertising&lt;/li&gt;          &lt;li&gt;RSS/XML Feeds&lt;/li&gt;        &lt;/ul&gt;      A knowledgeable Search Marketer should be able to determine what would  be the best process to market your site and get the most of your  marketing budget.&lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;  &lt;tr&gt;    &lt;td colspan="2" align="center"&gt;&lt;h1&gt;&lt;strong&gt;Google Tricks&lt;/strong&gt;&lt;/h1&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td valign="top" width="600"&gt; Enter just the word &lt;a href="http://www.google.com/search?q=http&amp;amp;hl=en&amp;amp;lr=&amp;amp;c2coff=1&amp;amp;start=0&amp;amp;sa=N" target="_blank"&gt;http&lt;/a&gt; for your search to find the top 1000 PageRanked sites.&lt;br&gt;        &lt;br&gt;      Enter only &lt;a href="http://www.google.com/search?hl=en&amp;amp;lr=&amp;amp;c2coff=1&amp;amp;q=www&amp;amp;btnG=Search" target="_blank"&gt;www&lt;/a&gt; in your search to see how Google ranks the top 1,000 sites.&lt;br&gt;      &lt;br&gt;      Manually type the following prefixes and note their utility:&lt;br&gt;      &lt;br&gt;      &lt;li&gt;link:url Shows other pages with links to that url.&lt;/li&gt;      &lt;li&gt;related:url same as "what's related" on serps.&lt;/li&gt;      &lt;li&gt;site:domain restricts search results to the given domain.&lt;/li&gt;      &lt;li&gt;allinurl: shows only pages with all terms in the url.&lt;/li&gt;      &lt;li&gt;inurl: like allinurl, but only for the next query word.&lt;/li&gt;      &lt;li&gt;allintitle: shows only results with terms in title.&lt;/li&gt;      &lt;li&gt;intitle: similar to allintitle, but only for the next word.  "intitle:seoforgoogle google" finds only pages with seoforgoogle in the  title, and google anywhere on the page.&lt;/li&gt;      &lt;li&gt;cache:url will show the Google version of the passed url.&lt;/li&gt;      &lt;li&gt;info:url will show a page containing links to related searches,  backlinks, and pages containing the url. This is the same as typing the  url into the search box.&lt;/li&gt;      &lt;li&gt;spell: will spell check your query and search for it.&lt;/li&gt;      &lt;li&gt;stocks: will lookup the search query in a stock index.&lt;/li&gt;      &lt;li&gt;filetype: will restrict searches to that filetype. "-filetype:pdf" to remove Adobe PDF files.&lt;/li&gt;      &lt;li&gt;daterange: is supported in Julian date format only. 2452384 is an example of a Julian date.&lt;/li&gt;      &lt;li&gt;maps: If you enter a street address, a link to Yahoo Maps and to MapBlast will be presented.&lt;/li&gt;      &lt;li&gt;phone: enter anything that looks like a phone number to have a name  and address displayed. Same is true for something that looks like an  address (include a name and zip code)&lt;/li&gt;      &lt;li&gt;site:www.somesite.net "+www.somesite.+net" - (tells you how many pages of your site are indexed by google)&lt;/li&gt;      &lt;li&gt;allintext: searches only within text of pages, but not in the links or page title&lt;/li&gt;      &lt;li&gt;allinlinks: searches only within links, not text or title&lt;/li&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;  &lt;tr&gt;    &lt;td colspan="2" align="center"&gt;&lt;h1&gt;&lt;strong&gt;Search Engine Optimization (SEO) Resources&lt;/strong&gt;&lt;/h1&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan="2" align="center"&gt;&lt;div align="center"&gt;Add to:&amp;nbsp; &lt;a href="http://www.technorati.com/faves?add=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Technorati&lt;/a&gt; | &lt;a href="http://digg.com/submit?phase=2&amp;amp;url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Digg&lt;/a&gt; | &lt;a href="http://del.icio.us/post?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;del.icio.us&lt;/a&gt; | &lt;a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?t=What%20is%20Search%20Engine%20Optimization&amp;amp;u=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Yahoo&lt;/a&gt; | &lt;a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;amp;Url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html;Title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;BlinkList&lt;/a&gt; | &lt;a href="http://www.spurl.net/spurl.php?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html&amp;amp;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;Spurl&lt;/a&gt; | &lt;a href="http://reddit.com/submit?url=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html&amp;amp;title=What%20is%20Search%20Engine%20Optimization" target="_blank"&gt;reddit&lt;/a&gt; | &lt;a href="http://www.furl.net/storeIt.jsp?t=What%20is%20Search%20Engine%20Optimization&amp;amp;u=http://phpfunda.blogspot.com/2008/04/search-engine-optimization-seo-workout.html" target="_blank"&gt;Furl&lt;/a&gt;| &lt;a href="http://www.onlywire.com/submit?u=http://phpfunda.blogspot.com&amp;amp;t=index&amp;amp;tags=Google" target="_blank"&gt;OnlyWire&lt;/a&gt; &lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan="2" align="left" valign="top" width="650"&gt; A free listing of SEO Resources that will help you get your site ranked in the search engines.&lt;br&gt;      As always, if you know of a resource that you think should be on this  page, drop me a line, and if it's up to snuff, it will get listed. &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td colspan="2" align="center"&gt;&lt;a href="http://s4g31.1insider.hop.clickbank.net" target="_blank"&gt;Make Money From Google&lt;/a&gt;&lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;    &lt;td align="center" valign="top" width="325"&gt;&lt;table align="right" border="0" cellpadding="3" cellspacing="3"&gt;      &lt;tbody&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/seo-tools.cfm"&gt;SEO Tools&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/seo-forums.cfm"&gt;SEO Forums&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/free-ads.cfm"&gt;Free Ad Sites&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/fee-tools.cfm"&gt;Fee Based Tools&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;      &lt;/tbody&gt;    &lt;/table&gt;&lt;/td&gt;    &lt;td align="center" valign="top" width="325"&gt;&lt;table align="left" border="0" cellpadding="3" cellspacing="3"&gt;      &lt;tbody&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/press-releases.cfm"&gt;Press Release &amp;amp; Article Sites&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/press-release-tips.cfm"&gt;Press Release Tips&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/buy-text-links.cfm"&gt;Buy Text Links&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;          &lt;td&gt;&lt;a href="http://seoresources.seoforgoogle.com/traffic-generating-sites.cfm"&gt;Traffic Generating Sites&lt;/a&gt;&lt;/td&gt;        &lt;/tr&gt;      &lt;/tbody&gt;    &lt;/table&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Security Corner: SQL Injection</title><link>http://phpfunda.blogspot.com/2008/03/security-corner-sql-injection.html</link><author>noreply@blogger.com (Unknown)</author><pubDate>Mon, 17 Mar 2008 22:06:00 -0700</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-2957080163114867541</guid><description>&lt;p&gt;Welcome to another edition of Security Corner. This month's topic is &lt;em&gt;SQL injection&lt;/em&gt;, an attack vector that frequents the minds of PHP developers, but for which there is a shortage of good documentation.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Most web applications interact with a database, and the data stored  therein frequently originates from remote sources. Thus, when creating  an SQL statement, you often use input in its construction. A typical  SQL injection attack exploits this scenario by attempting to send  fragments of valid SQL queries as unexpected values of GET and POST  data. This is why an SQL injection vulnerability is often the fault of  poor filtering and escaping, and this fact cannot be stressed enough.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This article explains SQL injection by looking at a few example  attacks and then introducing some simple and effective safeguards. By  applying best practices, you can practically eliminate SQL injection  from your list of security concerns.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;SQL Injection&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;For a moment, place yourself in the role of an attacker. Your goal  is initially simple. You want to get any unexpected SQL statement  executed by the database. You're only looking to get something to work,  because that will reveal the fact that the application has a potential  vulnerability. You have as many chances as you want, and you have a lot  of information to work with. For example, consider the simple  authentication form shown in Figure 1.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Figure 1:&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;img src="http://shiflett.org/images/security_corner_apr2004_1.png"&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In order to get more information about this form, you view the source:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;form action="/login.php" method="POST"&amp;gt;  &amp;lt;p&amp;gt;Username: &amp;lt;input type="text" name="username" /&amp;gt;&amp;lt;/p&amp;gt;  &amp;lt;p&amp;gt;Password: &amp;lt;input type="text" name="password" /&amp;gt;&amp;lt;/p&amp;gt;  &amp;lt;p&amp;gt;&amp;lt;input type="submit" value="Log In" /&amp;gt;&amp;lt;/p&amp;gt;  &amp;lt;/form&amp;gt;  &lt;/pre&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;form action="/login.php" method="POST"&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;p&amp;gt;Username: &amp;lt;input type="text" name="username" /&amp;gt;&amp;lt;/p&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;p&amp;gt;Password: &amp;lt;input type="text" name="password" /&amp;gt;&amp;lt;/p&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;p&amp;gt;&amp;lt;input type="submit" value="Log In" /&amp;gt;&amp;lt;/p&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;/form&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;You can already make a very educated guess about the type of SQL  statement that this application might use to verify the access  credentials. It will most likely be a SELECT statement.  You can also make a guess about the naming convention used in the  database table, because it probably matches the simple names used in  the HTML form. (It's also possible that you can cause an error that  reveals this information to you.) Because this form is for  authentication, there is probably WHERE clause that uses $_POST['username'] and $_POST['password'].&lt;/p&gt;&lt;br /&gt;&lt;p&gt;From all of this, you might predict the following:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;?php  &amp;nbsp;  $sql = "SELECT count(*)          FROM   users          WHERE  username = '{$_POST['username']}'          AND    password = '...'";  &amp;nbsp;  ?&amp;gt;  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;?php&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;$sql = "SELECT count(*)&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; FROM   users&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; WHERE  username = '{$_POST['username']}'&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; AND    password = '...'";&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;?&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Assuming this guess is correct, what can you do to manipulate this query? Imagine sending the following username:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;chris' /*  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;chris' /*&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;The SQL statement becomes the following:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;SELECT count(*)  FROM   users  WHERE  username = 'chris' /*'  AND    password = '...'"; &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;SELECT count(*)&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;FROM   users&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;WHERE  username = 'chris' /*'&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;AND    password = '...'";&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;  &lt;p&gt;In this example, /* is used to begin  a multi-line comment, effectively terminating the query at that point.  This has been tested successfully with MySQL. A standard comment in SQL  begins with --, and it's trivial to try both.&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This query suggests a successful authentication attempt as long as the chris  account exists, regardless of the password. This particular attack is  frequently used to steal accounts. Of course, any username can be used (admin is a popular target). Thus, by sending a malformed username, you can manage to log in without having a valid account.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Keep in mind that creativity plays a large role in most attacks. In  the previous example, the attack is limited by the type of query (SELECT)  and in the way the username and password are used. In other words, as  an attacker, you are somewhat bound, and your attacks must try to  exploit the situation within these bounds. Other types of queries  present new opportunities, and the best practices mentioned in this  article apply to all SQL injection attacks.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;WHERE Hacking&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;The WHERE clause is used to restrict the records that a particular query matches. For a SELECT statement, it determines the records that are returned. For an UPDATE statement, it determines the records that are modified. For a DELETE statement, it determines the records that are deleted. If a user can manipulate the WHERE  clause, there are many opportunities to make drastic changes -  selecting, updating, and deleting arbitrary records in the database.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Imagine a SELECT statement intended to fetch all credit card numbers for the current user:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;?php  &amp;nbsp;  $sql = "SELECT card_num, card_name, card_expiry          FROM   credit_cards          WHERE  username = '{$_GET['username']}'";  &amp;nbsp;  ?&amp;gt;  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;?php&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;$sql = "SELECT card_num, card_name, card_expiry&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; FROM   credit_cards&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; WHERE  username = '{$_GET['username']}'";&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;?&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;In this particular case, the application might not even solicit the username but instead provide it in a link:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;a href="/account.php?username=shiflett"&amp;gt;  Credit Card Information  &amp;lt;/a&amp;gt;  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;a href="/account.php?username=shiflett"&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Credit Card Information&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;/a&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;If a user can have multiple cards, the application might loop  through the results of a database query, displaying the card number,  name on the card, and expiration date for each card.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Imagine a user who visits the following resource:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;/account.php?username=shiflett%27+OR+username+%3D+%27lerdorf  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;/account.php?username=shiflett%27+OR+username+%3D+%27lerdorf&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;This submits the following value for the username:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;shiflett' OR username = 'lerdorf  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;shiflett' OR username = 'lerdorf&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;If used in the previous SQL query, $sql has the following value:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;SELECT card_num, card_name, card_expiry  FROM   credit_cards  WHERE  username = 'shiflett' OR username = 'lerdorf'  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;SELECT card_num, card_name, card_expiry&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;FROM   credit_cards&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;WHERE  username = 'shiflett' OR username = 'lerdorf'&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Now the user sees a list of all credit cards belonging to either shiflett or lerdorf.  This is a pretty major security vulnerability. Of course, a larger  vulnerability exists in this particular example, because a user can  arbitrarily pass any username in the URL. In addition, a username that  causes the WHERE clause to match all records can potentially expose all records:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;shiflett' OR username = username  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;shiflett' OR username = username&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Imagine if this particular username is stored in the database (using  a separate SQL injection attack) as the attacker's own username. Every  query that is restricted by a WHERE clause in order to  only apply the user's own record can potentially apply to all records  instead. This is not only extremely dangerous, but it also makes  further attacks very convenient.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Input Filtering&lt;/h2&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;  &lt;p&gt;This article assumes magic_quotes_gpc is disabled. If it is enabled, you can disable it or use the &lt;a href="http://nyphp.org/phundamentals/storingretrieving.php"&gt;fix_magic_quotes() function&lt;/a&gt; to repair the input.&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;There are best practices that you should follow to prevent SQL  injection attacks, and these offer a very high level of protection. The  most important step is to filter all input (data that comes from a  remote source). This includes $_GET, $_POST, $_COOKIE, etc. To help clarify this, consider the following HTML form:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;form action="/receive.php" method="POST"&amp;gt;  &amp;lt;select name="color"&amp;gt;      &amp;lt;option value="red"&amp;gt;red&amp;lt;/option&amp;gt;      &amp;lt;option value="green"&amp;gt;green&amp;lt;/option&amp;gt;      &amp;lt;option value="blue"&amp;gt;blue&amp;lt;/option&amp;gt;  &amp;lt;/select&amp;gt;  &amp;lt;input type="submit"&amp;gt;  &amp;lt;/form&amp;gt;  &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin: AdBrite --&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;   var AdBrite_Title_Color = '0000FF';&lt;br /&gt;   var AdBrite_Text_Color = '000000';&lt;br /&gt;   var AdBrite_Background_Color = 'FFFFFF';&lt;br /&gt;   var AdBrite_Border_Color = 'CCCCCC';&lt;br /&gt;   var AdBrite_URL_Color = '008000';&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="white-space:nowrap;"&gt;&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=687213&amp;zs=3436385f3630" type="text/javascript"&gt;&lt;/script&gt;&lt;!--&lt;br /&gt;--&gt;&lt;a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=687213&amp;afsid=1"&gt;&lt;img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- End: AdBrite --&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;form action="/receive.php" method="POST"&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;select name="color"&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; &amp;lt;option value="red"&amp;gt;red&amp;lt;/option&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; &amp;lt;option value="green"&amp;gt;green&amp;lt;/option&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; &amp;lt;option value="blue"&amp;gt;blue&amp;lt;/option&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;/select&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;input type="submit"&amp;gt;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;/form&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Clearly, the expected values are red, green, and blue. So, the input filtering should verify this:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;?php  &amp;nbsp;  $clean = array();  &amp;nbsp;  switch ($_POST['color']) {      case 'red':      case 'green':      case 'blue':          $clean['color'] = $_POST['color'];          break;      default:          /* Error */          break;  }  &amp;nbsp;  ?&amp;gt;  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;?php&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;$clean = array();&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;switch ($_POST['color']) {&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; case 'red':&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; case 'green':&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; case 'blue':&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; $clean['color'] = $_POST['color'];&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; break;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; default:&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; /* Error */&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; break;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;}&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;?&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;This code uses a separate array ($clean) to store the  filtered data. It is a good idea to choose a naming convention that  will help you identify potentially tainted data. In this example, $clean['color'] can be trusted to contain a valid color, because it is first initialized and then only assigned the value of $_POST['color'] if that value passes the test.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The two most important points for input filtering are:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;Only accept valid data rather than trying to prevent invalid data.&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Choose a naming convention that helps you distinguish tainted data from filtered data.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Escaping Output&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;With properly filtered input, you're already pretty well protected  against malicious attacks. The only remaining step is to escape it such  that the format of the input doesn't accidentally interfere with the  format of the SQL statement. If you are using MySQL, this simply  requires you to pass all data through mysql_real_escape_string() prior to use:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;?php  &amp;nbsp;  $mysql = array();  &amp;nbsp;  $mysql['color'] = mysql_real_escape_string($clean['color']);  &amp;nbsp;  $sql = "SELECT username          FROM   users          WHERE  favorite_color = '{$mysql['color']}'";  &amp;nbsp;  ?&amp;gt;  &lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;&amp;lt;?php&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;$mysql = array();&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;$mysql['color'] = mysql_real_escape_string($clean['color']);&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;$sql = "SELECT username&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; FROM   users&lt;/li&gt;&lt;br /&gt;  &lt;li&gt; WHERE  favorite_color = '{$mysql['color']}'";&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&amp;nbsp;&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;?&amp;gt;&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;In this case, assuming $clean['color'] is created by the previous example, you can be sure that the color only contains alphabetic characters. (It's one of red, green, or blue.)  Thus, the escaping might seem superfluous, and it is. However, it is  still a good habit to always escape data. This practice will help you  avoid forgetting this crucial step, and it adheres to the principle of &lt;em&gt;defense in depth&lt;/em&gt;, which stresses the importance of redundant safeguards.&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;Until Next Time...&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Preventing SQL injection is easy, but it is one of the most common  web application vulnerabilities. Hopefully you will now always adhere  to the following guidelines:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;Filter input.&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Escape output.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;NYPHP has a &lt;a href="http://nyphp.org/phundamentals/storingretrieving.php"&gt;helpful resource&lt;/a&gt; that explains SQL escaping.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;I hope you can now safely protect your applications against SQL injection attacks. Until next month, be safe.&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><title>URL Rewriting</title><link>http://phpfunda.blogspot.com/2008/02/url-rewriting.html</link><author>noreply@blogger.com (Unknown)</author><pubDate>Wed, 6 Feb 2008 00:10:00 -0800</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-5669381327264139926.post-6001299765362833873</guid><description>&lt;p&gt;The Apache server&amp;rsquo;s mod_rewrite module  gives you the ability to transparently redirect one URL to another,  without the user&amp;rsquo;s knowledge. This opens up all sorts of possibilities,  from simply redirecting old URLs to new addresses, to cleaning up the &amp;lsquo;dirty&amp;rsquo; URLs coming from a poor publishing system &amp;mdash; giving you URLs that are friendlier to both readers and search engines.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;h2&gt;An Introduction to Rewriting&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Readable URLs are nice. A well designed website will have a logical  file system layout, with smart folder and file names, and as many  implementation details left out as possible. In the most well designed sites, readers can &lt;strong&gt;guess at filenames with a high level of success&lt;/strong&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;However, there are some cases when the best possible information design can&amp;rsquo;t stop your site&amp;rsquo;s URLs from being nigh-on impossible to use. For instance, you may be using a Content Management System that serves out URLs that look something like&lt;/p&gt;&lt;br /&gt;&lt;p&gt;http://www.example.com/viewcatalog.asp?category=hats&amp;amp;prodID=53&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This is a horrible URL, but it and its brethren are becoming increasingly prevalent in these days of dynamically-generated pages. There are a number of problems with an URL of this kind:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;&lt;br /&gt;    &lt;p&gt;It &lt;strong&gt;exposes the underlying technology&lt;/strong&gt; of the website (in this case &lt;acronym title="[ Active Server Page ] - Microsoft&amp;rsquo;s dynamic webpage technology"&gt;ASP&lt;/acronym&gt;). This can give potential hackers clues as to what type of data they should send along with the query string to perform a &amp;lsquo;front-door&amp;rsquo; attack on the site. Information like this shouldn&amp;rsquo;t be given away if you can help it.&lt;/p&gt;&lt;br /&gt;    &lt;p&gt;Even if you&amp;rsquo;re not overly concerned with the security of your site, &lt;strong&gt;the technology you&amp;rsquo;re using is at best irrelevant&lt;/strong&gt; &amp;mdash; and at worst a source of confusion &amp;mdash; to your readers, so it should be hidden from them if possible.&lt;/p&gt;&lt;br /&gt;    &lt;p&gt;Also, if at some point in the future you decide to change the language that your site is based on (to &lt;a href="http://php.net/"&gt;&amp;raquo; PHP&lt;/a&gt;, for instance); all your old URLs will stop working. This is a pretty serious problem, as anyone who has tackled a full-on site rewrite will attest.&lt;/p&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;  &lt;li&gt;&lt;strong&gt;The URL is littered with awkward punctuation&lt;/strong&gt;, like the question mark and ampersand. Those &amp;amp; characters, in particular, are problematic because if another webmaster links to this page using that URL, the un-escaped ampersands will mess up their &lt;a href="http://www.yourhtmlsource.com/accessibility/xhtmlexplained.html"&gt;XHTML&lt;/a&gt; conformance.&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;Some &lt;strong&gt;search engines won&amp;rsquo;t index pages which they think are generated dynamically&lt;/strong&gt;. They&amp;rsquo;ll see that question mark in the URL and just turn their asses around.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;Luckily, using rewriting, we can clean up this URL to something far more manageable. For example, we could map it to&lt;/p&gt;&lt;br /&gt;&lt;p&gt;http://www.example.com/catalog/hats/53/&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Much better. This URL is more logical, readable and memorable, and will be picked up by all search engines. The &lt;em lang="fr"&gt;faux&lt;/em&gt;-directories are short and descriptive. Importantly, it looks more &lt;em&gt;permanent&lt;/em&gt;.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;To use mod_rewrite, you supply it with the link  text you want the server to match, and the real URLs that these URLs  will be redirected to. The URLs to be matched can be straight file  addresses, which will match one file, or they can be &lt;em&gt;regular expressions&lt;/em&gt;, which will match many files.&lt;/p&gt;&lt;br /&gt;&lt;a name="basicrewriting"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;Basic Rewriting&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Some servers will not have &lt;a href="http://httpd.apache.org/docs/mod/mod_rewrite.html"&gt;&amp;raquo; mod_rewrite&lt;/a&gt; enabled by default. As long as the &lt;a href="http://modules.apache.org/"&gt;&amp;raquo; module&lt;/a&gt; is present in the installation, you can enable it simply by starting a .htaccess file with the command&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;RewriteEngine&lt;/strong&gt; on&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Put this .htaccess file in your root so that rewriting is enabled throughout your site. You only need to write this line once per .htaccess file.&lt;/p&gt;&lt;br /&gt;&lt;a name="basicredirects"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;Basic Redirects&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;We&amp;rsquo;ll start off with a straight redirect; as if you had moved a file to a new location and want all links to the old location to be forwarded to the new location. Though you shouldn&amp;rsquo;t really ever &lt;a href="http://www.w3.org/Provider/Style/URI.html" title="As Sir Tim says, &amp;lsquo;Cool URIs don&amp;rsquo;t change&amp;rsquo;"&gt;&amp;raquo; move a file&lt;/a&gt; once it has been placed on the web; at least when you &lt;em&gt;simply have to&lt;/em&gt;, you can do your best to stop any old links from breaking.&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteEngine&lt;/strong&gt; on&lt;br&gt;&lt;br /&gt;    &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;old\.html&lt;strong&gt;$&lt;/strong&gt; new.html &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Though this is the simplest example possible, it may throw a few  people off. The structure of the &amp;lsquo;old&amp;rsquo; URL is the only difficult part in this RewriteRule. There are three special characters in there.&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;  &lt;li&gt;The caret, ^, signifies the &lt;strong&gt;start of an URL&lt;/strong&gt;, under the current directory. This directory is whatever directory the .htaccess file is in. You&amp;rsquo;ll start almost all matches with a caret.&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;The dollar sign, $, signifies the &lt;strong&gt;end of the string to be matched&lt;/strong&gt;. You should add this in to stop your rules matching the first part of longer URLs.&lt;/li&gt;&lt;br /&gt;  &lt;li&gt;The period or dot before the file extension is a special character in regular expressions, and would mean something special if we didn&amp;rsquo;t &lt;strong&gt;escape it with the backslash&lt;/strong&gt;, which tells Apache to treat it as a normal character.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;So, this rule will make your server transparently redirect from old.html to the new.html page. Your reader will have no idea that it happened, and it&amp;rsquo;s pretty much instantaneous.&lt;/p&gt;&lt;br /&gt;&lt;a name="forcingnewrequests"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;Forcing New Requests&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Sometimes you &lt;em&gt;do&lt;/em&gt; want your readers to know a redirect has occurred, and can do this by forcing a new &lt;abbr title="[ HyperText Transfer Protocol ] - The protocol designed for the Internet, to send webpages"&gt;HTTP&lt;/abbr&gt; request for the new page. This will make the browser load up the new page as if it was the page originally requested, and the location bar will change to show the URL of the new page. All you need to do is turn on the [R] flag, by appending it to the rule:&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;old\.html&lt;strong&gt;$&lt;/strong&gt; new.html &lt;strong&gt;[R]&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;a name="usingregularexpressions"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;Using Regular Expressions&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Now we get on to the &lt;em&gt;really&lt;/em&gt; useful stuff. The power of mod_rewrite comes at the expense of complexity. If this is your first encounter with regular expressions, you may find them to be a tough nut to crack, but the options they afford you are well worth the slog. I&amp;rsquo;ll be providing plenty of examples to guide you through the basics here. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Using regular expressions you can have your rules matching a set of URLs at a time, and mass-redirect them to their actual pages. Take this rule;&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;products/([0-9][0-9])/&lt;strong&gt;$&lt;/strong&gt; /productinfo.php?prodID=$1 &lt;/p&gt;&lt;br /&gt;&lt;p&gt;This will match any URLs that start with &amp;lsquo;products/&amp;rsquo;, followed by  any two digits, followed by a forward slash. For example, this rule  will match an URL like products/12/ or products/99/, and redirect it to the PHP page.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The parts in square brackets are called &lt;em&gt;ranges&lt;/em&gt;. In this case we&amp;rsquo;re allowing anything in the range 0-9, which is any digit. Other ranges would be [A-Z], which is any uppercase letter; [a-z], any lowercase letter; and [A-Za-z], any letter in either case.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;We have &lt;strong&gt;encased the regular expression part of the URL in parentheses&lt;/strong&gt;, because we want to &lt;strong&gt;store whatever value was found here for later use&lt;/strong&gt;. In this case we&amp;rsquo;re sending this value to a PHP page as an argument. Once we have a value in parentheses we can use it through what&amp;rsquo;s called a &lt;em&gt;back-reference&lt;/em&gt;. &lt;strong&gt;Each of the parts you&amp;rsquo;ve placed in parentheses are given an index, starting with one&lt;/strong&gt;. So, the first back-reference is $1, the third is $3 etc.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Thus, once the redirect is done, the page loaded in the readers&amp;rsquo; browser will be something like productinfo.php?prodID=12 or something similar. Of course, we&amp;rsquo;re keeping this true URL secret from the reader, because it likely ain&amp;rsquo;t the prettiest thing they&amp;rsquo;ll see all day.&lt;/p&gt;&lt;br /&gt;&lt;a name="multipleredirects"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;Multiple Redirects&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;If your site visitor had entered something like products/12, the rule above won&amp;rsquo;t do a redirect, as the slash at the end is missing. To promote good URL writing, we&amp;rsquo;ll take care of this by doing a direct redirect to the same URL with the slash appended.&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;products/([0-9][0-9])&lt;strong&gt;$&lt;/strong&gt; /products/$1/ &lt;strong&gt;[R]&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Multiple redirects in the same .htaccess file can be applied in sequence&lt;/strong&gt;, which is what we&amp;rsquo;re doing here. This rule is added before the one we did above, like so:&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;products/([0-9][0-9])&lt;strong&gt;$&lt;/strong&gt; /products/$1/ &lt;strong&gt;[R]&lt;/strong&gt;&lt;br&gt;&lt;br /&gt;    &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;products/([0-9][0-9])/&lt;strong&gt;$&lt;/strong&gt; /productinfo.php?prodID=$1 &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Thus, if the user types in the URL products/12, our first rule kicks in, rewriting the URL to include the trailing slash, and doing a new request for products/12/ so the user can see that we likes our trailing slashes around here. Then the second rule has something to match, and transparently redirects this URL to productinfo.php?prodID=12. &lt;em&gt;Slick.&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;a name="matchmodifiers"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;Match Modifiers&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;You can expand your regular expression patterns by adding some modifier characters, which allow you to match URLs with an indefinite number of characters. In our examples above, we were only allowing two numbers after products. This isn&amp;rsquo;t the most expandable solution, as if the shop ever grew beyond these initial confines of 99 products and created the URL productinfo.php?prodID=100, our rules would cease to match this URL.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So, instead of hard-coding a set number of digits to look for, we&amp;rsquo;ll work in some room to grow by allowing any number of characters to be entered. The rule below does just that:&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;products/([0-9]&lt;strong&gt;+&lt;/strong&gt;)&lt;strong&gt;$&lt;/strong&gt; /products/$1/ &lt;strong&gt;[R]&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Note the plus sign (+) that has snuck in there. This modifier changes whatever comes directly before it, by saying &amp;lsquo;&lt;strong&gt;one or more of the preceding character or range&lt;/strong&gt;.&amp;rsquo; In  this case it means that the rule will match any URL that starts with  products/ and ends with at least one digit. So this&amp;rsquo;ll match both products/1 and products/1000.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Other match modifiers that can be used in the same way are the asterisk, *, which means &amp;lsquo;zero or more of the preceding character or range&amp;rsquo;, and the question mark, ?, which means &amp;lsquo;zero or only one of the preceding character or range.&amp;rsquo;&lt;/p&gt;&lt;br /&gt;&lt;a name="addingguessableurls"&gt;&lt;/a&gt;&lt;br /&gt;&lt;h3&gt;Adding Guessable URLs&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Using these simple commands you can set up a slew of &amp;lsquo;shortcut URLs&amp;rsquo; that you think visitors will likely try to enter to get to pages they know exist on your site. For example, I&amp;rsquo;d imagine a lot of visitors try jumping straight into our &lt;a href="http://www.yourhtmlsource.com/stylesheets/"&gt;stylesheets&lt;/a&gt; section by typing  the URL http://www.yourhtmlsource.com/css/. We can catch these cases,  and hopefully alert the reader to the correct address by updating their location bar once the redirect is done with these lines:&lt;/p&gt;&lt;br /&gt;&lt;p&gt; &lt;strong&gt;RewriteRule&lt;/strong&gt; &lt;strong&gt;^&lt;/strong&gt;css(/)?&lt;strong&gt;$&lt;/strong&gt; /stylesheets/ &lt;strong&gt;[R]&lt;/strong&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;The simple regular expression in this rule allows it to match the css URL with or without a trailing slash. The question mark means &amp;lsquo;zero or one of the preceding character or range&amp;rsquo; &amp;mdash; in other words either yourhtmlsource.com/css or yourhtmlsource.com/css/ will both be taken care of by this one rule.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;This approach means less confusing &lt;a href="http://www.yourhtmlsource.com/sitemanagement/custom404error.html" title="Even if you&amp;rsquo;ve set up your own, nobody likes to hit them"&gt;404 errors&lt;/a&gt; for your readers, and a site that seems to run a whole lot smoother all &amp;rsquo;round.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item></channel></rss>