<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Autarchy of the Private Cave &#187; PHP</title> <atom:link href="https://bogdan.org.ua/categories/programming/php/feed" rel="self" type="application/rss+xml" /><link>https://bogdan.org.ua</link> <description>Tiny bits of bioinformatics, [web-]programming etc</description> <lastBuildDate>Wed, 28 Dec 2022 16:09:04 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>https://wordpress.org/?v=3.8.27</generator> <item><title>How to update a multisite Drupal 6/7 installation using Drush</title><link>https://bogdan.org.ua/2014/08/25/how-to-update-a-multisite-drupal-6-7-installation-using-drush.html</link> <comments>https://bogdan.org.ua/2014/08/25/how-to-update-a-multisite-drupal-6-7-installation-using-drush.html#comments</comments> <pubDate>Mon, 25 Aug 2014 15:35:27 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[Drupal]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[D6]]></category> <category><![CDATA[D7]]></category> <category><![CDATA[drupal]]></category> <category><![CDATA[drush]]></category> <category><![CDATA[update]]></category> <category><![CDATA[upgrade]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=2167</guid> <description><![CDATA[There are quite a lot of posts on how to do this, but my differs a tiny little bit, so I&#8217;m saving it for my own future reference, and also for the benefits of the wider audience. I am updating a multisite Drupal 6 installation. To the best of my knowledge, the only difference for [&#8230;]]]></description> <content:encoded><![CDATA[<p>There are quite a lot of posts on how to do this, but my differs a tiny little bit, so I&#8217;m saving it for my own future reference, and also for the benefits of the wider audience.</p><p>I am updating a multisite Drupal 6 installation. To the best of my knowledge, the only difference for Drupal 7 is that instead of the <strong>site_offline</strong> D6 variable the <strong>maintenance_mode</strong> variable is used in D7.</p><p>On Debian stable and later, you can <code>sudo aptitude install drush</code> and then just use it immediately after that.</p><p>Note: I recommend <code>su webuser</code> (or <code>sudo -s</code> followed by <code>sudo -s -u webuser</code>) before you run any non-testing <a
href="http://drush.ws/">drush</a> commands, where <em>webuser</em> is the user which owns your web-exposed files (e.g. Debian&#8217;s default is, I think, <strong>www-data</strong>). I&#8217;ve seen a lot of recommendations to run drush as a super-user, but that does not make sense, and may actually cause problems with file ownership.</p><p>One last thing before we start: if your <a
href="http://bogdan.org.ua/2014/08/25/drush-pm-update-fails-tar-hangs-when-extracting-tar-gz-module-archives-from-drupal-org.html">drush seems to work fine but hangs when untarring modules &#8211; check this solution</a>.</p><p><span
id="more-2167"></span></p><ol><li>Run some innocent command in drush to see if it produces any PHP warnings/errors you may want to fix before running actual update: <code>drush @sites core-status</code>. In my case, all the sites had the <a
href="https://www.drupal.org/project/cacherouter" class="broken_link" rel="nofollow">CacheRouter</a> module for in-RAM caching with a server daemon back-end, which was not initialized properly when drush bootstrapped Drupal from the command line. In my case, the only working solution was to edit <code>settings.php</code> files of every site to comment out the CacheRouter configuration for the period of update. If you get no warnings/errors, proceed to the next step. <em>Note: I was running drush from the Drupal&#8217;s root (directory which has top-level <code>index.php</code> and <code>.htaccess</code> files), but this should also work if you run from <code>sites/</code> or even <code>sites/sitename</code>.</em></li><li>Here would be several more steps &#8211; copying your production website(s) to a dev-server (if you do not have one already), performing an update on the dev-server first to see if anything breaks and needs fixes, then migrating updated website(s) from the dev-server to production server. Drush actually has tools to simplify all of these procedures. However, the websites I was updating were not critical, and short downtime was not a problem, so I was updating <strong>live</strong> websites. Modify these steps as you see fit to make the process more reliable.</li><li>Backup databases of all your sites. With drush: <code>drush @sites sql-dump --result-file --gzip</code>. This puts backups somewhere into the home directory of your <em>webuser</em>. Backups are named with a human-readable timestamp. Of course, you can also create a manual <a
href="https://www.drupal.org/project/backup_migrate" class="broken_link" rel="nofollow">Backup and Migrate</a> backup, or use phpMyAdmin, or just <code>mysqldump</code>.</li><li>Backup your site&#8217;s files. This step might be unnecessary, as drush seems to backup modules it is upgrading. I would still recommend making a backup, e.g. with <code>tar -acf multidrupal.tar.bz2 html</code>, where <em>html</em> is the directory containing your multisite Drupal&#8217;s root <code>index.php</code>.</li><li>Put the websites into maintenance mode and clear all caches; see the D7-specific note above: <code>drush @sites variable-set site_offline 1 ; drush @sites cache-clear all</code>.</li><li>The actual update! The easiest way would probably be to <code>drush @sites pm-update</code>, but I haven&#8217;t tested that and used a process which I understand better, and which seems more reliable to me (if anything goes wrong). If in your drupal root you have <strong>sites/site1</strong> and <strong>sites/site2</strong>, then run:<br
/> <code><br
/> drush site1 pm-updatecode<br
/> drush @sites updatedb<br
/> drush site2 pm-updatecode<br
/> drush @sites updatedb<br
/> </code><br
/> The <code>pm-updatecode</code> command only updates files, and does not run database update. So with these commands I am first updating modules from site1, then running database update on all sites, then update modules of site2, and run database update on all sites again. Running <code>drush @sites updatedb</code> multiple times, even when there are no updates, should be safe. Take note of any warnings/errors reported, you will want to fix them later, for example:</p><blockquote><p>WARNING:  Updating core will discard any modifications made to Drupal core files, most noteworthy among these are .htaccess and robots.txt.  If you have made any modifications to these files, please back them up before updating so that you can re-create your modifications in the updated version of the file.</p></blockquote></li><li>Disable maintenance mode. Cleaning the cache seems unnecessary, as <code>updatedb</code> command does that. <code>drush @sites variable-set site_offline 0</code>.</li><li>Finalize: re-enable anything disabled before the updates, fix warnings/errors you noted during the update.</li></ol><p>This worked well for me, and I hope it works well for you.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2014%2F08%2F25%2Fhow-to-update-a-multisite-drupal-6-7-installation-using-drush.html&amp;linkname=How%20to%20update%20a%20multisite%20Drupal%206%2F7%20installation%20using%20Drush" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2014%2F08%2F25%2Fhow-to-update-a-multisite-drupal-6-7-installation-using-drush.html&amp;linkname=How%20to%20update%20a%20multisite%20Drupal%206%2F7%20installation%20using%20Drush" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2014%2F08%2F25%2Fhow-to-update-a-multisite-drupal-6-7-installation-using-drush.html&amp;linkname=How%20to%20update%20a%20multisite%20Drupal%206%2F7%20installation%20using%20Drush" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2014%2F08%2F25%2Fhow-to-update-a-multisite-drupal-6-7-installation-using-drush.html&amp;linkname=How%20to%20update%20a%20multisite%20Drupal%206%2F7%20installation%20using%20Drush" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2014%2F08%2F25%2Fhow-to-update-a-multisite-drupal-6-7-installation-using-drush.html&amp;linkname=How%20to%20update%20a%20multisite%20Drupal%206%2F7%20installation%20using%20Drush" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2014%2F08%2F25%2Fhow-to-update-a-multisite-drupal-6-7-installation-using-drush.html&#038;title=How%20to%20update%20a%20multisite%20Drupal%206%2F7%20installation%20using%20Drush" data-a2a-url="https://bogdan.org.ua/2014/08/25/how-to-update-a-multisite-drupal-6-7-installation-using-drush.html" data-a2a-title="How to update a multisite Drupal 6/7 installation using Drush"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2014/08/25/how-to-update-a-multisite-drupal-6-7-installation-using-drush.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Configuring web-server: for production and for development</title><link>https://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html</link> <comments>https://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html#comments</comments> <pubDate>Sun, 25 Oct 2009 15:16:10 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[development]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[production]]></category> <category><![CDATA[web-server]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=680</guid> <description><![CDATA[Production: see http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch &#8211; it is for Debian Etch (which is old-stable), but many of the steps apply equally well to Debian Lenny (current-stable). Also, this is a very basic guide, as if you are going to host multiple sites from multiple clients, you most definitely will need some hosting control panel. Development: see http://www.ruzee.com/blog/2009/01/apache-virtual-hosts-a-clean-setup-for-php-developers. [&#8230;]]]></description> <content:encoded><![CDATA[<p><strong>Production</strong>: see <a
href="http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch">http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch</a> &#8211; it is for Debian Etch (which is old-stable), but many of the steps apply equally well to Debian Lenny (current-stable). Also, this is a very basic guide, as if you are going to host multiple sites from multiple clients, you most definitely will need some <a
href="http://bogdan.org.ua/2008/09/27/which-hosting-control-panel-to-use-for-a-debian-server.html">hosting control panel</a>.</p><p><strong>Development</strong>: see <a
href="http://www.ruzee.com/blog/2009/01/apache-virtual-hosts-a-clean-setup-for-php-developers">http://www.ruzee.com/blog/2009/01/apache-virtual-hosts-a-clean-setup-for-php-developers</a>. This setup works very well, unless you need to create several virtual hosts every day &#8211; in which case necessary actions could be partially scripted.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&amp;linkname=Configuring%20web-server%3A%20for%20production%20and%20for%20development" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&amp;linkname=Configuring%20web-server%3A%20for%20production%20and%20for%20development" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&amp;linkname=Configuring%20web-server%3A%20for%20production%20and%20for%20development" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&amp;linkname=Configuring%20web-server%3A%20for%20production%20and%20for%20development" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&amp;linkname=Configuring%20web-server%3A%20for%20production%20and%20for%20development" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&#038;title=Configuring%20web-server%3A%20for%20production%20and%20for%20development" data-a2a-url="https://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html" data-a2a-title="Configuring web-server: for production and for development"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Debugging PHP: Eclipse PDT + XDebug + XDebug helper</title><link>https://bogdan.org.ua/2009/06/08/debugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html</link> <comments>https://bogdan.org.ua/2009/06/08/debugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html#comments</comments> <pubDate>Sun, 07 Jun 2009 22:59:43 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[bug]]></category> <category><![CDATA[debugging]]></category> <category><![CDATA[development]]></category> <category><![CDATA[Eclipse]]></category> <category><![CDATA[FireFox]]></category> <category><![CDATA[PDT]]></category> <category><![CDATA[xdebug]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=735</guid> <description><![CDATA[Stimulated by a bug in a complex and unfamiliar web PHP application with heaps of custom tweaks by other programmers, I decided to try a more professional approach to PHP programming and debugging than the standard var_dump() and family. As a result, I&#8217;m now using Eclipse PDT with Xdebug and Xdebug Helper (Firefox extension). Now [&#8230;]]]></description> <content:encoded><![CDATA[<p>Stimulated by a bug in a complex and unfamiliar web PHP application with heaps of custom tweaks by other programmers, I decided to try a more professional approach to PHP programming and debugging than the standard var_dump() and family.</p><p>As a result, I&#8217;m now using Eclipse <abbr
title="PHP Development Tools">PDT</abbr> with <a
href="http://xdebug.org/">Xdebug</a> and <a
href="https://addons.mozilla.org/uk/firefox/addon/3960" class="broken_link" rel="nofollow">Xdebug Helper</a> (Firefox extension). Now I don&#8217;t understand how I used to debug my PHP programs before!</p><p>After proper configuration (I&#8217;m using local Apache, but it is also possible to debug remotely), my work flow is rather simple:</p><ul><li>use my web-app as usual, e.g. tweaking and testing here and there</li><li>if something server-side goes wrong: click the <a
href="https://addons.mozilla.org/uk/firefox/addon/3960" class="broken_link" rel="nofollow">XDebug helper</a> icon in Firefox, and perform some server-request action (e.g. load a page)</li><li>debugging is started in Eclipse PDT, where I can step through the code, set breakpoints, and examine all variables</li><li>as soon as the problem is fixed &#8211; click the XDebug helper icon again to continue using the site normally (w/o invoking the debugger)</li></ul><p>It takes some time to get used to, but then it&#8217;s a breeze.</p><p>Some advice:</p><ul><li>don&#8217;t use apt-get/aptitude to install Eclipse; it will be much easier both in the short and long run to use some all-in-one package from the <a
href="http://www.eclipse.org/pdt/downloads/">Eclipse PDT site</a>; all you need to do &#8211; download, extract, run!</li><li>before actually starting to do anything, tweak the eclipse.ini file by increasing heap size from 40 MiB (default) to some larger value (I used 128MiB). If you don&#8217;t do this, then at some point your debugging will become painfully sloooow, and then you&#8217;ll start getting tons of &#8220;out of heap memory&#8221; errors, each one suggesting that you quit Eclipse immediately</li><li>install <a
href="http://xdebug.org/">XDebug</a> with apt-get/aptitude &#8211; worked perfectly, and there&#8217;s /etc/php5/conf.d/xdebug.ini not to mess with php.ini</li><li>do <strong>read</strong> <a
href="http://www.eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf">XDebug guide for PDT 2.x</a> (I&#8217;m assuming you got the 2.x version); it should be the only document you will really need to configure everything</li></ul><p>I only wish Eclipse was faster &#8211; that is, written not in Java but e.g. C or C++.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fdebugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html&amp;linkname=Debugging%20PHP%3A%20Eclipse%20PDT%20%2B%20XDebug%20%2B%20XDebug%20helper" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fdebugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html&amp;linkname=Debugging%20PHP%3A%20Eclipse%20PDT%20%2B%20XDebug%20%2B%20XDebug%20helper" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fdebugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html&amp;linkname=Debugging%20PHP%3A%20Eclipse%20PDT%20%2B%20XDebug%20%2B%20XDebug%20helper" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fdebugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html&amp;linkname=Debugging%20PHP%3A%20Eclipse%20PDT%20%2B%20XDebug%20%2B%20XDebug%20helper" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fdebugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html&amp;linkname=Debugging%20PHP%3A%20Eclipse%20PDT%20%2B%20XDebug%20%2B%20XDebug%20helper" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fdebugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html&#038;title=Debugging%20PHP%3A%20Eclipse%20PDT%20%2B%20XDebug%20%2B%20XDebug%20helper" data-a2a-url="https://bogdan.org.ua/2009/06/08/debugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html" data-a2a-title="Debugging PHP: Eclipse PDT + XDebug + XDebug helper"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2009/06/08/debugging-php-like-a-pro-eclipse-pdt-xdebug-helper.html/feed</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>WordPress and Google Analytics external nofollow problem in comment links</title><link>https://bogdan.org.ua/2009/02/13/wordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html</link> <comments>https://bogdan.org.ua/2009/02/13/wordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html#comments</comments> <pubDate>Fri, 13 Feb 2009 19:41:55 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[CMS]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[comment]]></category> <category><![CDATA[fix]]></category> <category><![CDATA[link]]></category> <category><![CDATA[problem]]></category> <category><![CDATA[wordpress]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=594</guid> <description><![CDATA[Since some WP release, the comment author&#8217;s link in comments is broken &#8211; it has &#8216; external nofollow&#8217; attached straight to the href attribute (which breaks the link). I assume that the problem is caused by Google Analytics, namely the &#8220;track outgoing clicks&#8221; feature (as recalled, might be inaccurate feature name). &#8220;Track outgoing links&#8221; adds [&#8230;]]]></description> <content:encoded><![CDATA[<p>Since some WP release, the comment author&#8217;s link in comments is broken &#8211; it has &#8216; external nofollow&#8217; attached straight to the href attribute (which breaks the link).</p><p>I assume that the problem is caused by Google Analytics, namely the &#8220;track outgoing clicks&#8221; feature (as recalled, might be inaccurate feature name). &#8220;Track outgoing links&#8221; adds some JavaScript code to all outgoing links, and that script has tick characters like this one &#8216; which, incidentally, are also used for delimiting the values of comment anchor tags.</p><p>To fix:<br
/> <span
id="more-594"></span></p><ol><li>locate file <strong>wp-includes/comment-template.php</strong></li><li>in that file, find the <strong>get_comment_author_link</strong> function (lines 140-150 in WP 2.7.1)</li><li>replace the line<div
id="ig-sh-1" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$return = &quot;&lt;a href='$url' rel='external nofollow' class='url'&gt;$author&lt;/a&gt;&quot;;</div></li></ol></div></div><p>with</p><div
id="ig-sh-2" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$return = '&lt;a href=&quot;'.$url.'&quot; rel=&quot;external nofollow&quot; class=&quot;url&quot;&gt;'.$author.'&lt;/a&gt;';</div></li></ol></div></div></li></ol><p>This helped me and might help you.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F02%2F13%2Fwordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html&amp;linkname=WordPress%20and%20Google%20Analytics%20external%20nofollow%20problem%20in%20comment%20links" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F02%2F13%2Fwordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html&amp;linkname=WordPress%20and%20Google%20Analytics%20external%20nofollow%20problem%20in%20comment%20links" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F02%2F13%2Fwordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html&amp;linkname=WordPress%20and%20Google%20Analytics%20external%20nofollow%20problem%20in%20comment%20links" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F02%2F13%2Fwordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html&amp;linkname=WordPress%20and%20Google%20Analytics%20external%20nofollow%20problem%20in%20comment%20links" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F02%2F13%2Fwordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html&amp;linkname=WordPress%20and%20Google%20Analytics%20external%20nofollow%20problem%20in%20comment%20links" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2009%2F02%2F13%2Fwordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html&#038;title=WordPress%20and%20Google%20Analytics%20external%20nofollow%20problem%20in%20comment%20links" data-a2a-url="https://bogdan.org.ua/2009/02/13/wordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html" data-a2a-title="WordPress and Google Analytics external nofollow problem in comment links"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2009/02/13/wordpress-and-google-analytics-external-nofollow-problem-in-comment-links.html/feed</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>ExpressionEngine contact form (email module) spam vulnerability</title><link>https://bogdan.org.ua/2009/01/26/expressionengine-contact-form-email-module-spam-vulnerability.html</link> <comments>https://bogdan.org.ua/2009/01/26/expressionengine-contact-form-email-module-spam-vulnerability.html#comments</comments> <pubDate>Mon, 26 Jan 2009 09:50:05 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[CMS]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[EE]]></category> <category><![CDATA[ExpressionEngine]]></category> <category><![CDATA[spam]]></category> <category><![CDATA[vulnerability]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=575</guid> <description><![CDATA[Yesterday I had a look at mod.email.php &#8211; the Email module of ExpressionEngine CMS. It appears that it is very easy to use ExpressionEngine&#8217;s contact form (which uses Email module) to send emails to arbitrary addresses &#8211; simply put, send spam using someone&#8217;s EE. And here&#8217;s why: recipients hidden field is passed to the client; [&#8230;]]]></description> <content:encoded><![CDATA[<p>Yesterday I had a look at mod.email.php &#8211; the Email module of ExpressionEngine CMS.</p><p>It appears that it is very easy to use ExpressionEngine&#8217;s contact form (which uses Email module) to send emails to arbitrary addresses &#8211; simply put, send spam using someone&#8217;s EE.</p><p>And here&#8217;s why:</p><ul><li><em>recipients</em> hidden field is passed to the client; it is encrypted, but with access to the mod.email.php code, it is a matter of several minutes to write your own email-encoding function which will produce a completely valid <em>recipients</em> field</li><li>there&#8217;s also <em>XID</em> field, which seems to be unique for each page load</li></ul><p>Spamming algorithm is clear, so I won&#8217;t elaborate. (I could have missed some session variables, though &#8211; didn&#8217;t check them.)</p><p>This information is valid as of ExpressionEngine 1.6.6, but nothing in the change-logs indicates that this mechanism was modified in the newer versions of EE.</p><p><ins
datetime="2009-01-26T13:12:42+00:00">Update:</ins> I&#8217;ve tested, and this vulnerability does exist. The simplest prevention measure is to enable Captcha for Contact Form.</p><p>I&#8217;ve <a
href="http://expressionengine.com/archived_forums/viewthread/103537/" class="broken_link" rel="nofollow">notified</a> the developers.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F01%2F26%2Fexpressionengine-contact-form-email-module-spam-vulnerability.html&amp;linkname=ExpressionEngine%20contact%20form%20%28email%20module%29%20spam%20vulnerability" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F01%2F26%2Fexpressionengine-contact-form-email-module-spam-vulnerability.html&amp;linkname=ExpressionEngine%20contact%20form%20%28email%20module%29%20spam%20vulnerability" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F01%2F26%2Fexpressionengine-contact-form-email-module-spam-vulnerability.html&amp;linkname=ExpressionEngine%20contact%20form%20%28email%20module%29%20spam%20vulnerability" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F01%2F26%2Fexpressionengine-contact-form-email-module-spam-vulnerability.html&amp;linkname=ExpressionEngine%20contact%20form%20%28email%20module%29%20spam%20vulnerability" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2009%2F01%2F26%2Fexpressionengine-contact-form-email-module-spam-vulnerability.html&amp;linkname=ExpressionEngine%20contact%20form%20%28email%20module%29%20spam%20vulnerability" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2009%2F01%2F26%2Fexpressionengine-contact-form-email-module-spam-vulnerability.html&#038;title=ExpressionEngine%20contact%20form%20%28email%20module%29%20spam%20vulnerability" data-a2a-url="https://bogdan.org.ua/2009/01/26/expressionengine-contact-form-email-module-spam-vulnerability.html" data-a2a-title="ExpressionEngine contact form (email module) spam vulnerability"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2009/01/26/expressionengine-contact-form-email-module-spam-vulnerability.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Instructions on installing libmp3lame-enabled ffmpeg on shared linux hosting</title><link>https://bogdan.org.ua/2008/03/12/instructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html</link> <comments>https://bogdan.org.ua/2008/03/12/instructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html#comments</comments> <pubDate>Wed, 12 Mar 2008 06:25:54 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[ffmpeg]]></category> <category><![CDATA[install]]></category> <category><![CDATA[libmp3lame]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[shared hosting]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2008/03/12/instructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html</guid> <description><![CDATA[Note: this post is based on the comment by Simon, who generously shared his experience. Step-by-step: Download the compiled ffmpeg with libmp3lame support (direct download links: older version ffmpeg.with.lame and newer version ffmpeg.2007-10-28.with-libmp3lame-support). Rename the downloaded executable file to &#8220;ffmpeg&#8221; (no extension), upload it to the directory on your server (in this example /home/myusername/). Download [&#8230;]]]></description> <content:encoded><![CDATA[<p><em>Note:</em> this post is based on the <a
href="http://bogdan.org.ua/2007/10/25/using-libmp3lame-enabled-ffmpeg-on-shared-hosting.html#comment-59670">comment by Simon</a>, who generously shared his experience.</p><p>Step-by-step:</p><ul><li>Download the <a
title="this page will be irregularly updated with new compiled binaries of ffmpeg" href="http://bogdan.org.ua/2007/06/28/compiled-linux-ffmpeg-binary-for-gallery2-download.html">compiled ffmpeg with libmp3lame support</a> (direct download links: older version <a
href="http://bogdan.org.ua/wp-content/uploads/2007/06/ffmpeg.with.lame">ffmpeg.with.lame</a> and newer version <a
href="http://bogdan.org.ua/wp-content/uploads/2007/10/ffmpeg.2007-10-28.with-libmp3lame-support">ffmpeg.2007-10-28.with-libmp3lame-support</a>).</li><li>Rename the downloaded executable file to &#8220;ffmpeg&#8221; (no extension), upload it to the directory on your server (in this example /home/myusername/).</li><li>Download <a
href="http://bogdan.org.ua/wp-content/uploads/2008/03/libmp3lame.so.0">libmp3lame.so.0</a>.</li><li>Upload libmp3lame.so.0 to the same directory where you placed ffmpeg in.</li><li>Create a php file with the following code (remember to change the paths to your own, where you actually uploaded binaries in previous steps):<div
id="ig-sh-3" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #990000;">exec</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot;export LD_LIBRARY_PATH=/home/myusername/&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #b1b100;">echo</span> <span
style="color: #990000;">passthru</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot;/home/myusername/ffmpeg -formats&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div></li><li>If you access that PHP file with your browser, you should be able to see a list of formats which are supported by ffmpeg, and if you find &#8220;EA libmp3lame&#8221; somewhere in the output, then it means you now can Encode Audio in libmp3lame!</li><li>If that doesn&#8217;t work for you: LD_LIBRARY_PATH can be a protected variable in PHP (you can check for this by searching for the &#8220;safe_mode_protected_env_vars&#8221; value in phpinfo() output). The workaround here can be to write your commands to a file from php, then <strong>chmod</strong> that file with 0755 permissions (rwx-rx-rx), and run the file through <strong>exec()</strong>. In this way, PHP is not changing the LD_LIBRARY_PATH, but telling the server to run a file, which tells the server to change it. This method worked for the original author of these instructions.</li></ul><p>For passing arguments to the PHP wrapper script &#8211; check out PHP&#8217;s $argv variable (more on this <a
href="http://www.php.net/features.commandline">here</a>). If you decided to use shell-script as a wrapper for &#8220;export LD_LIBRARY_PATH&#8221;, then using $1, $2 etc will allow you to pass parameters to the shell script, e.g. in the example below</p><div
id="ig-sh-4" class="syntax_hilite"><div
class="code"><ol
class="code" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">#!/bin/bash</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">export LD_LIBRARY_PATH=/home/myusername/</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">/home/myusername/ffmpeg -i /home/myusername/$1 $2 /home/myusername/$3</div></li></ol></div></div><p>you could pass &#8220;input file&#8221; as first argument, &#8220;parameters&#8221; as second and &#8220;output file&#8221; as third to make such a wrapper script work.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F03%2F12%2Finstructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html&amp;linkname=Instructions%20on%20installing%20libmp3lame-enabled%20ffmpeg%20on%20shared%20linux%20hosting" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F03%2F12%2Finstructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html&amp;linkname=Instructions%20on%20installing%20libmp3lame-enabled%20ffmpeg%20on%20shared%20linux%20hosting" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F03%2F12%2Finstructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html&amp;linkname=Instructions%20on%20installing%20libmp3lame-enabled%20ffmpeg%20on%20shared%20linux%20hosting" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F03%2F12%2Finstructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html&amp;linkname=Instructions%20on%20installing%20libmp3lame-enabled%20ffmpeg%20on%20shared%20linux%20hosting" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F03%2F12%2Finstructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html&amp;linkname=Instructions%20on%20installing%20libmp3lame-enabled%20ffmpeg%20on%20shared%20linux%20hosting" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2008%2F03%2F12%2Finstructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html&#038;title=Instructions%20on%20installing%20libmp3lame-enabled%20ffmpeg%20on%20shared%20linux%20hosting" data-a2a-url="https://bogdan.org.ua/2008/03/12/instructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html" data-a2a-title="Instructions on installing libmp3lame-enabled ffmpeg on shared linux hosting"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2008/03/12/instructions-on-installing-libmp3lame-enabled-ffmpeg-on-shared-linux-hosting.html/feed</wfw:commentRss> <slash:comments>19</slash:comments> </item> <item><title>Convert MySQL database from one encoding/collation into another</title><link>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html</link> <comments>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html#comments</comments> <pubDate>Fri, 08 Feb 2008 19:17:45 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[collation]]></category> <category><![CDATA[convert]]></category> <category><![CDATA[database]]></category> <category><![CDATA[encoding]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[latin1]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[script]]></category> <category><![CDATA[utf8]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html</guid> <description><![CDATA[Most frequent use: convert database from latin1_swedish to utf8_general_ci. Original script found at: MySQL and UTF-8. Update: the original script had an error, it would generate queries likes this one (note the bold part): ALTER TABLE `links` CHANGE `link_rel` `link_rel` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT NULL; This is clearly wrong syntax [&#8230;]]]></description> <content:encoded><![CDATA[<p>Most frequent use: <a
title="self-link" href="http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html">convert database from latin1_swedish to utf8_general_ci</a>.<br
/> Original script found at: <a
href="http://www.phpwact.org/php/i18n/utf-8/mysql" class="broken_link" rel="nofollow">MySQL and UTF-8</a>.</p><p><ins
datetime="2008-02-22T21:50:28+00:00">Update:</ins> the original script <u>had an error</u>, it would generate queries likes this one (note the bold part):</p><blockquote><p>ALTER TABLE `links` CHANGE `link_rel` `link_rel` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci <strong>NOT NULL  DEFAULT NULL</strong>;</p></blockquote><p>This is clearly wrong syntax (and logic). I fixed this by making comparison to NULL strict (with three equal signs instead of two):</p><blockquote><p> // Does the field default to null, a string, or nothing?<br
/> if ($row['Default'] === NULL)</p></blockquote><p><ins
datetime="2008-06-27T07:23:50+00:00">Update 2:</ins> based on comment by <em>banesto</em>, I modified the script; now it does not require specifying the from_collation, it&#8217;s sufficient to specify to_collation (which will be used for all the fields and tables). The modified code is:</p><blockquote><p>if ($row['Collation'] == &#8221; || $row['Collation'] == $convert_to)<br
/> continue;</p></blockquote><p><ins
datetime="2010-06-28T11:58:11+00:00">Update 3:</ins> the long-lasting, re-appearing NOT NULL DEFAULT NULL problem is finally fixed.</p><p><ins
datetime="2010-06-28T12:11:38+00:00">Update 4:</ins> incorporated Russ&#8217;s fix to skip numeric fields (in order to leave autoincrement values intact).</p><p>Here&#8217;s the script itself: (to copy-paste: first click the &#8220;Plain text&#8221; header)<br
/> <span
id="more-255"></span></p><div
id="ig-sh-5" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// Original script (v1.0) by/from: http://www.phpwact.org/php/i18n/utf-8/mysql</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// Improved/modified (v1.05) by Bogdan http://bogdan.org.ua/</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// Last updated: 2010-06-28</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// this script will output all queries needed to change all fields/tables to a different collation</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// it is HIGHLY suggested you make a MySQL backup prior to running any of the generated queries</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// this code is provided AS IS and without any warranty</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// add text/plain header when used not as a CLI script; PHP CLI SAPI shouldn't output headers</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #990000;">header</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot;Content-Type: text/plain&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// precaution</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #990000;">die</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot;Make a backup of your MySQL database, then remove this line from the code!&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #990000;">set_time_limit</span><span
style="color: #009900;">&#40;</span><span
style="color: #cc66cc;">0</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// collation you want to change to:</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$convert_to</span> &nbsp; <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'utf8_general_ci'</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// character set of new collation:</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$character_set</span><span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'utf8'</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// DB login information - *modify before use*</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$username</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'user'</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$password</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'pass'</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$database</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'database_name'</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$host</span> &nbsp; &nbsp; <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">'localhost'</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">//-- usually, there is nothing to modify below this line --//</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// show TABLE alteration queries?</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$show_alter_table</span> <span
style="color: #339933;">=</span> <span
style="color: #009900; font-weight: bold;">true</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #666666; font-style: italic;">// show FIELD alteration queries?</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$show_alter_field</span> <span
style="color: #339933;">=</span> <span
style="color: #009900; font-weight: bold;">true</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #990000;">mysql_connect</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$host</span><span
style="color: #339933;">,</span> <span
style="color: #000088;">$username</span><span
style="color: #339933;">,</span> <span
style="color: #000088;">$password</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #990000;">mysql_select_db</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$database</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000088;">$rs_tables</span> <span
style="color: #339933;">=</span> <span
style="color: #990000;">mysql_query</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot; SHOW TABLES &quot;</span><span
style="color: #009900;">&#41;</span> or <span
style="color: #990000;">die</span><span
style="color: #009900;">&#40;</span><span
style="color: #990000;">mysql_error</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #b1b100;">while</span> <span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$row_tables</span> <span
style="color: #339933;">=</span> <span
style="color: #990000;">mysql_fetch_row</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$rs_tables</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span> <span
style="color: #009900;">&#123;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #000088;">$table</span> <span
style="color: #339933;">=</span> <span
style="color: #990000;">mysql_real_escape_string</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$row_tables</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;0&amp;#93;);</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// Alter table collation</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// ALTER TABLE `account` DEFAULT CHARACTER SET utf8</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$show_alter_table</span><span
style="color: #009900;">&#41;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">echo</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot;ALTER TABLE `<span
style="color: #006699; font-weight: bold;">$table</span>` DEFAULT CHARACTER SET <span
style="color: #006699; font-weight: bold;">$character_set</span>;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #000088;">$rs</span> <span
style="color: #339933;">=</span> <span
style="color: #990000;">mysql_query</span><span
style="color: #009900;">&#40;</span><span
style="color: #0000ff;">&quot; SHOW FULL FIELDS FROM `<span
style="color: #006699; font-weight: bold;">$table</span>` &quot;</span><span
style="color: #009900;">&#41;</span> or <span
style="color: #990000;">die</span><span
style="color: #009900;">&#40;</span><span
style="color: #990000;">mysql_error</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #b1b100;">while</span> <span
style="color: #009900;">&#40;</span> <span
style="color: #000088;">$row</span> <span
style="color: #339933;">=</span> <span
style="color: #990000;">mysql_fetch_assoc</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$rs</span><span
style="color: #009900;">&#41;</span> <span
style="color: #009900;">&#41;</span> <span
style="color: #009900;">&#123;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span> <span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Collation'&amp;#93; == '' || $row&amp;#91;'Collation'&amp;#93; == $convert_to )</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #b1b100;">continue</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// Is the field allowed to be null?</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span> <span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Null'&amp;#93; == 'YES' )</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #000088;">$nullable</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">' NULL '</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">else</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$nullable</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">' NOT NULL '</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// Does the field default to null, a string, or nothing?</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span> <span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Default'&amp;#93; === NULL &amp;&amp; $row&amp;#91;'Null'&amp;#93; == 'YES' )</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #000088;">$default</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">&quot; DEFAULT NULL &quot;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">elseif</span> <span
style="color: #009900;">&#40;</span> <span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Default'&amp;#93; != '' )</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #000088;">$default</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">&quot; DEFAULT '&quot;</span><span
style="color: #339933;">.</span><span
style="color: #990000;">mysql_real_escape_string</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Default'&amp;#93;).&quot;'&quot;;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #b1b100;">else</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$default</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">''</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// sanity check and fix:</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$nullable</span> <span
style="color: #339933;">==</span> <span
style="color: #0000ff;">' NOT NULL '</span> <span
style="color: #339933;">&amp;&amp;</span> <span
style="color: #000088;">$default</span> <span
style="color: #339933;">==</span> <span
style="color: #0000ff;">' DEFAULT NULL '</span><span
style="color: #009900;">&#41;</span> <span
style="color: #009900;">&#123;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$default</span> <span
style="color: #339933;">=</span> <span
style="color: #0000ff;">''</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">echo</span> <span
style="color: #0000ff;">&quot;/* Warning: wrong combination of 'default value' and 'NULL-flag' detected - and fixed! */<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">echo</span> <span
style="color: #0000ff;">&quot;/* Diagnostics: row&amp;#91;Null&amp;#93; = '<span
style="color: #006699; font-weight: bold;">$row</span>&amp;#91;Null&amp;#93;', row&amp;#91;Default&amp;#93; = &quot;</span> <span
style="color: #339933;">.</span> <span
style="color: #990000;">mysql_real_escape_string</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Default'&amp;#93;) . &quot;, MySQL version: &quot; . mysql_get_server_info() . &quot; */\n&quot;;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #009900;">&#125;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// Don't alter INT columns: no collations, and altering them drops autoincrement values</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #990000;">strpos</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Type'&amp;#93;, 'int') !== false) {</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #000088;">$show_alter_field</span> <span
style="color: #339933;">=</span> <span
style="color: #009900; font-weight: bold;">False</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">else</span> <span
style="color: #009900;">&#123;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$show_alter_field</span> <span
style="color: #339933;">=</span> <span
style="color: #009900; font-weight: bold;">True</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// Alter field collation:</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #666666; font-style: italic;">// ALTER TABLE `tab` CHANGE `field` `field` CHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #b1b100;">if</span> <span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$show_alter_field</span><span
style="color: #009900;">&#41;</span> <span
style="color: #009900;">&#123;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #000088;">$field</span> <span
style="color: #339933;">=</span> <span
style="color: #990000;">mysql_real_escape_string</span><span
style="color: #009900;">&#40;</span><span
style="color: #000088;">$row</span><span
style="color: #339933;">&amp;</span><span
style="color: #666666; font-style: italic;">#91;'Field'&amp;#93;);</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span
style="color: #b1b100;">echo</span> <span
style="color: #0000ff;">&quot;ALTER TABLE `<span
style="color: #006699; font-weight: bold;">$table</span>` CHANGE `<span
style="color: #006699; font-weight: bold;">$field</span>` `<span
style="color: #006699; font-weight: bold;">$field</span>` <span
style="color: #006699; font-weight: bold;">$row</span>&amp;#91;Type&amp;#93; CHARACTER SET <span
style="color: #006699; font-weight: bold;">$character_set</span> COLLATE <span
style="color: #006699; font-weight: bold;">$convert_to</span> <span
style="color: #006699; font-weight: bold;">$nullable</span> <span
style="color: #006699; font-weight: bold;">$default</span>;<span
style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color: #009900;">&#125;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; <span
style="color: #009900;">&#125;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #009900;">&#125;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F02%2F08%2Fconvert-mysql-database-from-one-encodingcollation-into-another.html&amp;linkname=Convert%20MySQL%20database%20from%20one%20encoding%2Fcollation%20into%20another" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F02%2F08%2Fconvert-mysql-database-from-one-encodingcollation-into-another.html&amp;linkname=Convert%20MySQL%20database%20from%20one%20encoding%2Fcollation%20into%20another" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F02%2F08%2Fconvert-mysql-database-from-one-encodingcollation-into-another.html&amp;linkname=Convert%20MySQL%20database%20from%20one%20encoding%2Fcollation%20into%20another" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F02%2F08%2Fconvert-mysql-database-from-one-encodingcollation-into-another.html&amp;linkname=Convert%20MySQL%20database%20from%20one%20encoding%2Fcollation%20into%20another" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2008%2F02%2F08%2Fconvert-mysql-database-from-one-encodingcollation-into-another.html&amp;linkname=Convert%20MySQL%20database%20from%20one%20encoding%2Fcollation%20into%20another" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2008%2F02%2F08%2Fconvert-mysql-database-from-one-encodingcollation-into-another.html&#038;title=Convert%20MySQL%20database%20from%20one%20encoding%2Fcollation%20into%20another" data-a2a-url="https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html" data-a2a-title="Convert MySQL database from one encoding/collation into another"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html/feed</wfw:commentRss> <slash:comments>60</slash:comments> </item> <item><title>PHP proxy</title><link>https://bogdan.org.ua/2007/09/19/php-proxy.html</link> <comments>https://bogdan.org.ua/2007/09/19/php-proxy.html#comments</comments> <pubDate>Wed, 19 Sep 2007 16:41:35 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2007/09/19/php-proxy.html</guid> <description><![CDATA[PHP proxy is simple but good. I converted it into a proxy-function for one of my projects. Do pay attention to the comments, especially these two: I had issues with this script (and others) returning 0 for the bytesTotal in flash. Basically, the Content-Length header was absent from the response. By simply adding header(&#8220;Content-length: &#8220;.strlen($response)) [&#8230;]]]></description> <content:encoded><![CDATA[<p><a
href="http://www.abdulqabiz.com/blog/archives/2007/05/31/php-proxy-script-for-cross-domain-requests/">PHP proxy</a> is simple but good. I converted it into a proxy-function for one of my projects.</p><p>Do pay attention to the comments, especially these two:</p><blockquote><p> I had issues with this script (and others) returning 0 for the bytesTotal in flash. Basically, the Content-Length header was absent from the response. By simply adding<br
/> header(&#8220;Content-length: &#8220;.strlen($response)) before the echo, it resolved the issue. I don&#8217;t know if there is a more appropriate fix to account for character encoding, etc, but it seems to work.</p></blockquote><blockquote><p> @Schimmi: Well, if you can add some checks there (like who is referring your script) and allow the access to whitelisted clients (served from your domain)&#8230; I think, you can totally make it used applications from same-domain&#8230;.So it would not be open to world. Yeah above script doesn&#8217;t have those things.</p></blockquote><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F09%2F19%2Fphp-proxy.html&amp;linkname=PHP%20proxy" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F09%2F19%2Fphp-proxy.html&amp;linkname=PHP%20proxy" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F09%2F19%2Fphp-proxy.html&amp;linkname=PHP%20proxy" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F09%2F19%2Fphp-proxy.html&amp;linkname=PHP%20proxy" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F09%2F19%2Fphp-proxy.html&amp;linkname=PHP%20proxy" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F09%2F19%2Fphp-proxy.html&#038;title=PHP%20proxy" data-a2a-url="https://bogdan.org.ua/2007/09/19/php-proxy.html" data-a2a-title="PHP proxy"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/09/19/php-proxy.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to convert between utf8 and cp-1251 without iconv or mbstring</title><link>https://bogdan.org.ua/2007/07/08/how-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html</link> <comments>https://bogdan.org.ua/2007/07/08/how-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html#comments</comments> <pubDate>Sun, 08 Jul 2007 14:32:57 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2007/07/08/how-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html</guid> <description><![CDATA[This helped me, maybe it will help you: How to convert between utf8 and cp1251 without iconv In case the original disappears, here&#8217;s a &#8220;backup&#8221;: function cp1251_to_utf8($s){ &#160; &#160; $c209 = chr(209); $c208 = chr(208); $c129 = chr(129); &#160; &#160; for($i=0; $i&#60;strlen($s); $i++) &#160; &#160;{ &#160; &#160; &#160; &#160; $c=ord($s&#38;#91;$i&#38;#93;); &#160; &#160; &#160; &#160; if [&#8230;]]]></description> <content:encoded><![CDATA[<p>This helped me, maybe it will help you: <a
href="http://www.ustrem.org/en/articles/how-to-convert-between-utf8-cp1251-without-iconv-en/">How to convert between utf8 and cp1251 without iconv</a><br
/> <span
id="more-195"></span></p><p>In case the original disappears, here&#8217;s a &#8220;backup&#8221;:</p><div
id="ig-sh-6" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function cp1251_to_utf8($s){</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $c209 = chr(209); $c208 = chr(208); $c129 = chr(129);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; for($i=0; $i&lt;strlen($s); $i++) &nbsp; &nbsp;{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; $c=ord($s&amp;#91;$i&amp;#93;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; if ($c&gt;=192 and $c&lt;=239) $t.=$c208.chr($c-48);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; elseif ($c&gt;239) $t.=$c209.chr($c-112);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; elseif ($c==184) $t.=$c209.$c209;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; elseif ($c==168) &nbsp; &nbsp;$t.=$c208.$c129;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; else $t.=$s[$i];</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; return $t;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function utf8_to_cp1251($s)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; for ($c=0;$c&lt;strlen($s);$c++)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp;$i=ord($s&amp;#91;$c&amp;#93;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp;if ($i&lt;=127) $out.=$s&amp;#91;$c&amp;#93;;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ($byte2){</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$new_c2=($c1&amp;3)*64+($i&amp;63);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$new_c1=($c1&gt;&gt;2)&amp;5;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$new_i=$new_c1*256+$new_c2;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ($new_i==1025){</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$out_i=168;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ($new_i==1105){</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$out_i=184;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$out_i=$new_i-848;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$out.=chr($out_i);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$byte2=false;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp;if (($i&gt;&gt;5)==6) {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$c1=$i;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$byte2=true;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp;}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; return $out;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li></ol></div></div><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F07%2F08%2Fhow-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html&amp;linkname=How%20to%20convert%20between%20utf8%20and%20cp-1251%20without%20iconv%20or%20mbstring" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F07%2F08%2Fhow-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html&amp;linkname=How%20to%20convert%20between%20utf8%20and%20cp-1251%20without%20iconv%20or%20mbstring" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F07%2F08%2Fhow-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html&amp;linkname=How%20to%20convert%20between%20utf8%20and%20cp-1251%20without%20iconv%20or%20mbstring" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F07%2F08%2Fhow-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html&amp;linkname=How%20to%20convert%20between%20utf8%20and%20cp-1251%20without%20iconv%20or%20mbstring" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F07%2F08%2Fhow-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html&amp;linkname=How%20to%20convert%20between%20utf8%20and%20cp-1251%20without%20iconv%20or%20mbstring" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F07%2F08%2Fhow-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html&#038;title=How%20to%20convert%20between%20utf8%20and%20cp-1251%20without%20iconv%20or%20mbstring" data-a2a-url="https://bogdan.org.ua/2007/07/08/how-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html" data-a2a-title="How to convert between utf8 and cp-1251 without iconv or mbstring"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/07/08/how-to-convert-between-utf8-and-cp-1251-without-iconv-or-mbstring.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to make PEAR work from behind an HTTP proxy (Windows and Linux)</title><link>https://bogdan.org.ua/2007/05/31/how-to-make-pear-work-from-behind-an-http-proxy.html</link> <comments>https://bogdan.org.ua/2007/05/31/how-to-make-pear-work-from-behind-an-http-proxy.html#comments</comments> <pubDate>Thu, 31 May 2007 10:35:04 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Misc]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2007/05/31/how-to-make-pear-work-from-behind-an-http-proxy.html</guid> <description><![CDATA[Earlier in one of my posts (Using PEAR HTTP_Client or HTTP_Request with HTTP proxy) I gave an example of using PEAR HTTP_Client and/or HTTP_Request from behind an http proxy. However, I didn&#8217;t tell how to make PEAR itself work properly from behind an HTTP proxy (e.g., for online operations like &#8220;pear upgrade-all&#8221;). So here&#8217;s that [&#8230;]]]></description> <content:encoded><![CDATA[<p>Earlier in one of my posts (<a
href="http://bogdan.org.ua/2006/09/06/using-pear-http_client-or-http_request-with-http-proxy-example.html">Using PEAR HTTP_Client or HTTP_Request with HTTP proxy</a>) I gave an example of using PEAR HTTP_Client and/or HTTP_Request from behind an http proxy. However, I didn&#8217;t tell how to make PEAR itself work properly from behind an HTTP proxy (e.g., for online operations like &#8220;pear upgrade-all&#8221;).</p><p>So here&#8217;s that tiny missing bit of information.</p><p><strong>Windows:</strong><br
/> Launch <strong>regedit</strong>, navigate to <strong>HKEY_CURRENT_USER\Environment</strong>, and create a string value called <strong>PHP_PEAR_HTTP_PROXY</strong>. Modify that new value to hold the string like: <strong>http://proxy_username:proxy_password@proxy_server_address:proxy_port</strong>.</p><p><strong>Linux:</strong><br
/> In the Terminal/Konsole, execute (for a system-wide pear configuration)</p><blockquote><p>sudo pear config-set http_proxy http://proxy_username:proxy_password@proxy_server_address:proxy_port</p></blockquote><p>If your proxy password has symbols, special for the shell (e.g. question or exclamation mark) &#8211; enclose full proxy specifications with single-quotes, e.g.</p><blockquote><p>sudo pear config-set http_proxy &#8216;http://proxy_username:proxy_password@proxy_server_address:proxy_port&#8217;</p></blockquote><p>If your HTTP proxy server does not require authentication, then use <strong>http://proxy_server_address:proxy_port</strong> instead.</p><p>I think the strings are completely self-explanatory; however, here&#8217;s an example of proxy (with authentication) specification: http://john.smith:CrAzYP433WoRd@192.168.0.1:3128.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F31%2Fhow-to-make-pear-work-from-behind-an-http-proxy.html&amp;linkname=How%20to%20make%20PEAR%20work%20from%20behind%20an%20HTTP%20proxy%20%28Windows%20and%20Linux%29" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F31%2Fhow-to-make-pear-work-from-behind-an-http-proxy.html&amp;linkname=How%20to%20make%20PEAR%20work%20from%20behind%20an%20HTTP%20proxy%20%28Windows%20and%20Linux%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F31%2Fhow-to-make-pear-work-from-behind-an-http-proxy.html&amp;linkname=How%20to%20make%20PEAR%20work%20from%20behind%20an%20HTTP%20proxy%20%28Windows%20and%20Linux%29" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F31%2Fhow-to-make-pear-work-from-behind-an-http-proxy.html&amp;linkname=How%20to%20make%20PEAR%20work%20from%20behind%20an%20HTTP%20proxy%20%28Windows%20and%20Linux%29" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F31%2Fhow-to-make-pear-work-from-behind-an-http-proxy.html&amp;linkname=How%20to%20make%20PEAR%20work%20from%20behind%20an%20HTTP%20proxy%20%28Windows%20and%20Linux%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F31%2Fhow-to-make-pear-work-from-behind-an-http-proxy.html&#038;title=How%20to%20make%20PEAR%20work%20from%20behind%20an%20HTTP%20proxy%20%28Windows%20and%20Linux%29" data-a2a-url="https://bogdan.org.ua/2007/05/31/how-to-make-pear-work-from-behind-an-http-proxy.html" data-a2a-title="How to make PEAR work from behind an HTTP proxy (Windows and Linux)"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/05/31/how-to-make-pear-work-from-behind-an-http-proxy.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Directory-based random image rotation PHP script</title><link>https://bogdan.org.ua/2007/05/23/directory-based-random-image-rotation-php-script.html</link> <comments>https://bogdan.org.ua/2007/05/23/directory-based-random-image-rotation-php-script.html#comments</comments> <pubDate>Wed, 23 May 2007 15:23:15 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2007/05/23/directory-based-random-image-rotation-php-script.html</guid> <description><![CDATA[Yesterday I needed to put together a rather simple PHP script: it would read the contents of a single pre-configured directory, and randomly select up to a pre-configured number of files. These files were images, and were just dumped as IMG tags into the webpage. I came up with a solution, shown below. The script [&#8230;]]]></description> <content:encoded><![CDATA[<p>Yesterday I needed to put together a rather simple PHP script: it would read the contents of a single pre-configured directory, and randomly select up to a pre-configured number of files. These files were images, and were just dumped as IMG tags into the webpage. I came up with a solution, shown below.</p><p>The script is simple, but still it&#8217;s easier to use the ready solution than to write your own :).<br
/> It is heavily commented, and should be easy to understand.<br
/> <span
id="more-184"></span><br
/> <em>To copy-paste, first click the &#8220;PLAIN TEXT&#8221; box header.</em></p><div
id="ig-sh-7" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// configuration</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// total number of images we want to display; can be 1 as well</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$to_display = 10;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// type of files to use eg. .jpg or .gif or .png</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$file_types = array(&quot;.jpg&quot;, &quot;.gif&quot;, &quot;.png&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// the location of the folder containing the images</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$image_folder = &quot;/usr/local/vhosts/sitename/htdocs/images&quot;;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// URL prefix for all images' SRC attribute;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// can be just &quot;/&quot;, or full URL</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$URL_prefix = &quot;http://some-site.kiev.ua/images/&quot;;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// no configuration below this comment!</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$Images = array();</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// check if $image_folder is really a directory</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">if (is_dir($image_folder))</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;$handle = opendir($image_folder);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;// read *all* files from the $image_folder</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;while (false !== ($img = readdir($handle)))</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; // skip two &quot;special files&quot;,</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; // current and upper directories</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; if ($img != &quot;.&quot; &amp;&amp; $img != &quot;..&quot;)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;// extract file's extension and test if it</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;// is present in the $file_types array;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;// if yes - add file to the Images array</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;$typetest = strtolower(substr($img,-4));</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp;if ( in_array($typetest, $file_types) )</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $Images[] = $img;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;closedir($handle);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// if there are less images than $to_display,</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// decrease the number to actual</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">if ( count($Images) &lt; $to_display)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;$to_display = count($Images);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// randomly select $to_display images</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$rand_keys = array_rand($Images, $to_display);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// output IMG tags with random images</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">foreach($rand_keys as $rand_key)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;echo '&lt;img src=&quot;'.$URL_prefix.$Images&amp;#91;$rand_key&amp;#93;.'&quot; alt=&quot;&quot; /&gt;';</div></li></ol></div></div><p>How to use: insert this code into your PHP file where you need to output the list of images. Do not forget to apply some pretty CSS styling to IMG tags! <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p><p>The major drawback of this solution is inefficiency: reading the complete directory of image files on every page display is not good at all. However, I inserted this code snippet into the CMS&#8217;s PHP-enabled template, which allows to turn on caching. This actually solves efficiency problem, as directory will be read (and images randomized&#8230;) only as often as long your configured cache is.</p><p>Another option is to add in some <a
href="http://bogdan.org.ua/2006/12/09/http-caching-universal-approach-and-sample-code.html">caching options</a>. It might be reasonable as well to use MySQL HEAP-table (in-memory table) to store the directory-reading result and refresh it only once in an hour; this way images would be randomized on each page display, but the directory would be re-read less than once in an hour.</p><p>But all of the above-described enhancements are optional, and can be left as an exercise to the reader <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley" /></p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fdirectory-based-random-image-rotation-php-script.html&amp;linkname=Directory-based%20random%20image%20rotation%20PHP%20script" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fdirectory-based-random-image-rotation-php-script.html&amp;linkname=Directory-based%20random%20image%20rotation%20PHP%20script" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fdirectory-based-random-image-rotation-php-script.html&amp;linkname=Directory-based%20random%20image%20rotation%20PHP%20script" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fdirectory-based-random-image-rotation-php-script.html&amp;linkname=Directory-based%20random%20image%20rotation%20PHP%20script" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fdirectory-based-random-image-rotation-php-script.html&amp;linkname=Directory-based%20random%20image%20rotation%20PHP%20script" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fdirectory-based-random-image-rotation-php-script.html&#038;title=Directory-based%20random%20image%20rotation%20PHP%20script" data-a2a-url="https://bogdan.org.ua/2007/05/23/directory-based-random-image-rotation-php-script.html" data-a2a-title="Directory-based random image rotation PHP script"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/05/23/directory-based-random-image-rotation-php-script.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Executing and checking background shell process from PHP</title><link>https://bogdan.org.ua/2007/05/23/executing-and-checking-background-shell-process-from-php.html</link> <comments>https://bogdan.org.ua/2007/05/23/executing-and-checking-background-shell-process-from-php.html#comments</comments> <pubDate>Wed, 23 May 2007 14:53:33 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2007/05/23/executing-and-checking-background-shell-process-from-php.html</guid> <description><![CDATA[Found a nicely illustrated method for running a background shell command from PHP and continuously checking if the process is still running. Here&#8217;s sample code without explanations: function run_in_background($Command, $Priority = 0) { &#160;if($Priority) &#160; $PID = shell_exec(&#34;nohup nice -n $Priority $Command 2&#62; /dev/null &#38; echo $!&#34;); &#160;else &#160; $PID = shell_exec(&#34;nohup $Command 2&#62; /dev/null [&#8230;]]]></description> <content:encoded><![CDATA[<p>Found a nicely illustrated method for <a
href="http://nsaunders.wordpress.com/2007/01/12/running-a-background-process-in-php/" target="_blank">running a background shell command from PHP and continuously checking if the process is still running</a>.</p><p>Here&#8217;s sample code without explanations:</p><div
id="ig-sh-8" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function run_in_background($Command, $Priority = 0)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;if($Priority)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; $PID = shell_exec(&quot;nohup nice -n $Priority $Command 2&gt; /dev/null &amp; echo $!&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;else</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; $PID = shell_exec(&quot;nohup $Command 2&gt; /dev/null &amp; echo $!&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;return($PID);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function is_process_running($PID)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;exec(&quot;ps $PID&quot;, $ProcessState);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;return(count($ProcessState) &gt;= 2);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li></ol></div></div><blockquote><p>To run something like hmmsearch from the HMMER package, youâ€™d do this:</p></blockquote><div
id="ig-sh-9" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">echo(&quot;Running hmmsearch. . .&quot;)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$ps = run_in_background(&quot;hmmsearch $hmmfile $fastafile &gt; $outfile&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">while(is_process_running($ps))</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;echo(&quot; . &quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;ob_flush();flush();</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;sleep(1);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li></ol></div></div><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fexecuting-and-checking-background-shell-process-from-php.html&amp;linkname=Executing%20and%20checking%20background%20shell%20process%20from%20PHP" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fexecuting-and-checking-background-shell-process-from-php.html&amp;linkname=Executing%20and%20checking%20background%20shell%20process%20from%20PHP" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fexecuting-and-checking-background-shell-process-from-php.html&amp;linkname=Executing%20and%20checking%20background%20shell%20process%20from%20PHP" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fexecuting-and-checking-background-shell-process-from-php.html&amp;linkname=Executing%20and%20checking%20background%20shell%20process%20from%20PHP" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fexecuting-and-checking-background-shell-process-from-php.html&amp;linkname=Executing%20and%20checking%20background%20shell%20process%20from%20PHP" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F05%2F23%2Fexecuting-and-checking-background-shell-process-from-php.html&#038;title=Executing%20and%20checking%20background%20shell%20process%20from%20PHP" data-a2a-url="https://bogdan.org.ua/2007/05/23/executing-and-checking-background-shell-process-from-php.html" data-a2a-title="Executing and checking background shell process from PHP"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/05/23/executing-and-checking-background-shell-process-from-php.html/feed</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>How to find absolute path on a web-server (using PHP)</title><link>https://bogdan.org.ua/2007/04/30/how-to-find-absolute-path-on-a-web-server-using-php.html</link> <comments>https://bogdan.org.ua/2007/04/30/how-to-find-absolute-path-on-a-web-server-using-php.html#comments</comments> <pubDate>Mon, 30 Apr 2007 11:53:51 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Notepad]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/2007/04/30/how-to-find-absolute-path-on-a-web-server.html</guid> <description><![CDATA[When using PHP, the simplest way to find the absolute path of your files/folders on the server is by creating a simple path.php file with the following contents (click on the &#8220;Plain text&#8221; box header for copy-pasting): &#60;?php echo realpath&#40;dirname&#40;__FILE__&#41;&#41;; ?&#62; Put the new file anywhere in the web-accessible folder on your server, then just [&#8230;]]]></description> <content:encoded><![CDATA[<p>When using PHP, the simplest way to find the absolute path of your files/folders on the server is by creating a simple path.php file with the following contents (click on the &#8220;Plain text&#8221; box header for copy-pasting):</p><div
id="ig-sh-10" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #b1b100;">echo</span> <span
style="color: #990000;">realpath</span><span
style="color: #009900;">&#40;</span><span
style="color: #990000;">dirname</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900; font-weight: bold;">__FILE__</span><span
style="color: #009900;">&#41;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div><p>Put the new file anywhere in the web-accessible folder on your server,<br
/> then just access that file from your favourite web-browser &#8211; and you&#8217;ll have the absolute path shown to you.</p><p>Alternatively, you may use the following code:</p><div
id="ig-sh-11" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">&lt;?php</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #b1b100;">echo</span> <span
style="color: #990000;">getcwd</span><span
style="color: #009900;">&#40;</span><span
style="color: #009900;">&#41;</span><span
style="color: #339933;">;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #000000; font-weight: bold;">?&gt;</span></div></li></ol></div></div><p>This also should display the absolute path on your server.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F04%2F30%2Fhow-to-find-absolute-path-on-a-web-server-using-php.html&amp;linkname=How%20to%20find%20absolute%20path%20on%20a%20web-server%20%28using%20PHP%29" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F04%2F30%2Fhow-to-find-absolute-path-on-a-web-server-using-php.html&amp;linkname=How%20to%20find%20absolute%20path%20on%20a%20web-server%20%28using%20PHP%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F04%2F30%2Fhow-to-find-absolute-path-on-a-web-server-using-php.html&amp;linkname=How%20to%20find%20absolute%20path%20on%20a%20web-server%20%28using%20PHP%29" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F04%2F30%2Fhow-to-find-absolute-path-on-a-web-server-using-php.html&amp;linkname=How%20to%20find%20absolute%20path%20on%20a%20web-server%20%28using%20PHP%29" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F04%2F30%2Fhow-to-find-absolute-path-on-a-web-server-using-php.html&amp;linkname=How%20to%20find%20absolute%20path%20on%20a%20web-server%20%28using%20PHP%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F04%2F30%2Fhow-to-find-absolute-path-on-a-web-server-using-php.html&#038;title=How%20to%20find%20absolute%20path%20on%20a%20web-server%20%28using%20PHP%29" data-a2a-url="https://bogdan.org.ua/2007/04/30/how-to-find-absolute-path-on-a-web-server-using-php.html" data-a2a-title="How to find absolute path on a web-server (using PHP)"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/04/30/how-to-find-absolute-path-on-a-web-server-using-php.html/feed</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>Drupal internationalization (i18n) and localization (l10n)</title><link>https://bogdan.org.ua/2007/03/10/drupal-internationalization-i18n-and-localization-l10n.html</link> <comments>https://bogdan.org.ua/2007/03/10/drupal-internationalization-i18n-and-localization-l10n.html#comments</comments> <pubDate>Sat, 10 Mar 2007 13:48:32 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[CMS]]></category> <category><![CDATA[Drupal]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[i18n]]></category> <category><![CDATA[l10n]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2007/03/10/drupal-internationalization-i18n-and-localization-l10n.html</guid> <description><![CDATA[This is a collection of links related to the multiple-language content in Drupal CMS. i18n module i18n: Getting the whole thing to work : http://drupal.org/node/81094 Patch: Translations of menu titles and descriptions: http://drupal.org/node/70919 Translated links: http://drupal.org/node/67814 i18n: menu not expanding with URL-Alias: http://drupal.org/node/80820 There was an alternative module to i18n, but I cannot find it [&#8230;]]]></description> <content:encoded><![CDATA[<p>This is a collection of links related to the multiple-language content in Drupal CMS.</p><p><a
href="https://drupal.org/project/i18n" class="broken_link" rel="nofollow">i18n module</a><br
/> i18n: Getting the whole thing to work : <a
href="https://drupal.org/node/81094" class="broken_link" rel="nofollow">http://drupal.org/node/81094</a><br
/> Patch: Translations of menu titles and descriptions: <a
href="https://drupal.org/node/70919" class="broken_link" rel="nofollow">http://drupal.org/node/70919</a><br
/> Translated links: <a
href="https://drupal.org/node/67814" class="broken_link" rel="nofollow">http://drupal.org/node/67814</a><br
/> i18n: menu not expanding with URL-Alias: <a
href="https://drupal.org/node/80820" class="broken_link" rel="nofollow">http://drupal.org/node/80820</a></p><p>There was an alternative module to i18n, but I cannot find it at the moment.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F03%2F10%2Fdrupal-internationalization-i18n-and-localization-l10n.html&amp;linkname=Drupal%20internationalization%20%28i18n%29%20and%20localization%20%28l10n%29" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F03%2F10%2Fdrupal-internationalization-i18n-and-localization-l10n.html&amp;linkname=Drupal%20internationalization%20%28i18n%29%20and%20localization%20%28l10n%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F03%2F10%2Fdrupal-internationalization-i18n-and-localization-l10n.html&amp;linkname=Drupal%20internationalization%20%28i18n%29%20and%20localization%20%28l10n%29" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F03%2F10%2Fdrupal-internationalization-i18n-and-localization-l10n.html&amp;linkname=Drupal%20internationalization%20%28i18n%29%20and%20localization%20%28l10n%29" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F03%2F10%2Fdrupal-internationalization-i18n-and-localization-l10n.html&amp;linkname=Drupal%20internationalization%20%28i18n%29%20and%20localization%20%28l10n%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F03%2F10%2Fdrupal-internationalization-i18n-and-localization-l10n.html&#038;title=Drupal%20internationalization%20%28i18n%29%20and%20localization%20%28l10n%29" data-a2a-url="https://bogdan.org.ua/2007/03/10/drupal-internationalization-i18n-and-localization-l10n.html" data-a2a-title="Drupal internationalization (i18n) and localization (l10n)"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/03/10/drupal-internationalization-i18n-and-localization-l10n.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>dotProject 2.0.4/2.1.2/2.1.3 on shared hosting</title><link>https://bogdan.org.ua/2007/01/22/dotproject-204-on-godaddy-shared-hosting.html</link> <comments>https://bogdan.org.ua/2007/01/22/dotproject-204-on-godaddy-shared-hosting.html#comments</comments> <pubDate>Mon, 22 Jan 2007 18:04:28 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[dotProject]]></category> <category><![CDATA[fix]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[project management]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2007/01/22/dotproject-on-godaddycom-shared-hosting.html</guid> <description><![CDATA[Update: the same solution seems to still apply to dotProject 2.1.2; the post instructions have been modified for dP 2.1.2. Update 2: fsmullin suggested a method to fix a similar error in index_table.php, the files_count_max cannot be found error when you click the FILES tab/menu item. His suggestion is now incorporated into the post. Update [&#8230;]]]></description> <content:encoded><![CDATA[<p><ins
datetime="2009-01-17T22:40:24+00:00">Update:</ins> the same solution seems to still apply to dotProject 2.1.2; the post instructions have been modified for dP 2.1.2.</p><p><ins
datetime="2009-01-30T19:21:41+00:00">Update 2:</ins> fsmullin <a
href="http://bogdan.org.ua/2007/01/22/dotproject-204-on-godaddy-shared-hosting.html#comment-97643">suggested</a> a method to fix a similar error in index_table.php, the <strong>files_count_max cannot be found error</strong> when you click the <strong>FILES</strong> tab/menu item. His suggestion is now incorporated into the post.</p><p><ins
datetime="2010-06-21T12:43:39+00:00">Update 3:</ins> this post is still relevant for dotProject 2.1.3.</p><p>In one of my recent posts about <a
href="http://bogdan.org.ua/2007/01/21/project-management-software.html">project management software</a> I stated the desire to extensively test dotProject 2.0.4. However, many shared hosting providers appear incompatible with dotProject: the right to CREATE TEMPORARY TABLES in MySQL is not granted, but is needed by dotProject.</p><p>Here&#8217;s sample error (2.0.4):</p><blockquote><p>query failed(CREATE TEMPORARY TABLE tasks_sum SELECT task_project, COUNT(distinct task_id) AS total_tasks,<br
/> SUM(task_duration * task_percent_complete * IF(task_duration_type = 24, 8.0, task_duration_type))/<br
/> SUM(task_duration * IF(task_duration_type = 24, 8.0, task_duration_type)) AS project_percent_complete FROM `tasks` GROUP BY task_project)</p></blockquote><p>For 2.1.2, sample error would be:</p><blockquote><p>Table &#8216;tasks_total&#8217; doesn&#8217;t exist</p></blockquote><p>I tried looking for solutions, and here&#8217;s what I found&#8230;<br
/> <span
id="more-106"></span><br
/> First of all, I tried issuing the &#8220;grant&#8221; command to try enabling temporary tables:</p><blockquote><p>GRANT CREATE TEMPORARY TABLES ON dot_projects.* to dot_projects@x.myserver.com;</p></blockquote><p>Expectedly, this didn&#8217;t work: &#8220;access denied for user &#8230;.&#8221;.</p><p>Then I tried looking for a ready-to-apply solution. Here are the links relevant to the topic, if you happen to prefer &#8220;the source&#8221;, and not the retelling: <a
href="http://www.dotproject.net/vbulletin/archive/index.php/t-29.html">link 1</a>, <a
href="http://www.dotproject.net/vbulletin/showthread.php?t=2749&#038;highlight=temporary">link 2</a>, <a
href="http://www.dotproject.net/vbulletin/archive/index.php/t-2753.html">link 3</a>, and <a
href="http://www.dotproject.net/vbulletin/showthread.php?t=4261">link 4</a>.</p><p>However, none of the solutions described behind the links worked for me.</p><p><strong>Here&#8217;s my solution (error fix).</strong></p><p>To fix, instead of creating temporary tables each time they are needed (what is impossible on many shared hostings), we need to create the necessary tables once. Then, instead of dropping temporary tables, we just truncate our &#8220;static&#8221; tables.</p><p>Here&#8217;s how we proceed.</p><ol><li>Issue once the following MySQL statements (using, e.g., phpMyAdmin):<div
id="ig-sh-12" class="syntax_hilite"><div
class="code"><ol
class="sql" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_problems`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span> <span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_log_problem`</span> TINYINT<span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">1</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_critical`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span> <span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`critical_task`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span> <span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`project_actual_end_date`</span> DATETIME <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_sum`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span> <span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`total_tasks`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">6</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span> <span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`project_percent_complete`</span> <span
style="color: #993333; font-weight: bold;">VARCHAR</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`project_duration`</span> <span
style="color: #993333; font-weight: bold;">VARCHAR</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_summy`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`my_tasks`</span> <span
style="color: #993333; font-weight: bold;">varchar</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">10</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_users`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`user_id`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_total`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">11</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">DEFAULT</span> <span
style="color: #993333; font-weight: bold;">NULL</span> <span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`total_tasks`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span> <span
style="color: #cc66cc;">6</span> <span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">DEFAULT</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`files_count_max`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`file_versions`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #cc66cc;">0</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`file_lastversion`</span> <span
style="color: #993333; font-weight: bold;">float</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #ff0000;">'0'</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`file_version_id`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #cc66cc;">0</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #ff0000;">`file_project`</span> <span
style="color: #993333; font-weight: bold;">INT</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #cc66cc;">0</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li></ol></div></div><p>This will create all the necessary tables.<br
/> <em>Note:</em> <strong>tasks_total</strong> and <strong>files_count_max</strong> tables are 2.1.2-specific.<br
/> <em>Another note</em>: for 2.1.2, the <strong>tasks_sum</strong> table is one field shorter:<div
id="ig-sh-13" class="syntax_hilite"><div
class="code"><ol
class="sql" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">CREATE</span> <span
style="color: #993333; font-weight: bold;">TABLE</span> <span
style="color: #993333; font-weight: bold;">IF</span> <span
style="color: #993333; font-weight: bold;">NOT</span> <span
style="color: #993333; font-weight: bold;">EXISTS</span> <span
style="color: #ff0000;">`tasks_sum`</span> <span
style="color: #66cc66;">&#40;</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; <span
style="color: #ff0000;">`task_project`</span> <span
style="color: #993333; font-weight: bold;">int</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; <span
style="color: #ff0000;">`project_percent_complete`</span> <span
style="color: #993333; font-weight: bold;">varchar</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span><span
style="color: #66cc66;">,</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; <span
style="color: #ff0000;">`project_duration`</span> <span
style="color: #993333; font-weight: bold;">varchar</span><span
style="color: #66cc66;">&#40;</span><span
style="color: #cc66cc;">11</span><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">default</span> <span
style="color: #993333; font-weight: bold;">NULL</span></div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #66cc66;">&#41;</span> <span
style="color: #993333; font-weight: bold;">TYPE</span><span
style="color: #66cc66;">=</span>MyISAM;</div></li></ol></div></div></li><li><a
href="http://www.dotproject.net/vbulletin/showthread.php?t=2753">Now</a>, in <strong>classes/query.class.php</strong> at line 393 (for dotProject 2.0.4; just search for the matching line in 2.1.2) <strong>replace</strong> this line:<div
id="ig-sh-14" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q = 'CREATE TEMPORARY TABLE ' . $this-&gt;_table_prefix . $this-&gt;create_table;</div></li></ol></div></div><p>with these:</p><div
id="ig-sh-15" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//$q = 'CREATE TEMPORARY TABLE ' . $this-&gt;_table_prefix . $this-&gt;create_table;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q = 'INSERT INTO ' . $this-&gt;_table_prefix . $this-&gt;create_table;</div></li></ol></div></div><p>Now we won&#8217;t get any errors about the tables which fail to be created.</li><li>Next, <strong>replace</strong> the following text in <strong>modules/projects/projects.class.php</strong> (lines 388-392 for 2.0.4):<div
id="ig-sh-16" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// Let's delete temporary tables</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q &nbsp;= new DBQuery;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q-&gt;dropTemp('tasks_sum, tasks_summy, tasks_critical, tasks_problems, tasks_users');</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q-&gt;exec();</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q-&gt;clear();</div></li></ol></div></div><p>with this code:</p><div
id="ig-sh-17" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// Let's delete temporary tables</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE tasks_sum&quot;; db_exec($sql);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE tasks_summy&quot;; db_exec($sql);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE tasks_critical&quot;; db_exec($sql);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE tasks_problems&quot;; db_exec($sql);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE tasks_users&quot;; db_exec($sql);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE tasks_total&quot;; db_exec($sql);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$q &nbsp;= new DBQuery;</div></li></ol></div></div><p>Note: <strong>$sql = &#8220;TRUNCATE TABLE tasks_sum&#8221;; db_exec($sql);</strong> line is 2.1.2-specific.<br
/> At this point, you will no longer receive error messages while on the &#8220;projects&#8221; tab.</li><li><em>(this point applies to 2.1.2 only)</em> <strong>Replace</strong> lines 222 and 223 in <strong>modules/files/index_table.php</strong><div
id="ig-sh-18" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$r-&gt;dropTemp('files_count_max');</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$r-&gt;exec();</div></li></ol></div></div><p>with:</p><div
id="ig-sh-19" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//$r-&gt;dropTemp('files_count_max');</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">//$r-&gt;exec();</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$sql = &quot;TRUNCATE TABLE files_count_max&quot;; db_exec($sql);</div></li></ol></div></div></li><li><strong>Optionally</strong>, if you want to improve the performance of dotProject specifically for these tables, change the &#8216;engine&#8217; for the above-mentioned tables to &#8216;memory&#8217;. To do that, execute the following SQL statements:<div
id="ig-sh-20" class="syntax_hilite"><div
class="code"><ol
class="sql" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> tasks_problems engine<span
style="color: #66cc66;">=</span>memory;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> tasks_critical engine<span
style="color: #66cc66;">=</span>memory;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> tasks_sum engine<span
style="color: #66cc66;">=</span>memory;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> tasks_summy engine<span
style="color: #66cc66;">=</span>memory;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> tasks_users engine<span
style="color: #66cc66;">=</span>memory;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> tasks_total engine<span
style="color: #66cc66;">=</span>memory;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span
style="color: #993333; font-weight: bold;">alter</span> <span
style="color: #993333; font-weight: bold;">table</span> files_count_max engine<span
style="color: #66cc66;">=</span>memory;</div></li></ol></div></div><p>This change will make MySQL keep these tables in RAM. As they are used as temporary tables, this decreases disk I/O a lot while working with dotProject. Of course, YMMV &#8211; to apply this change or not depends on where is your bottleneck.</li><p>Comments and further improvements are welcome.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F01%2F22%2Fdotproject-204-on-godaddy-shared-hosting.html&amp;linkname=dotProject%202.0.4%2F2.1.2%2F2.1.3%20on%20shared%20hosting" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F01%2F22%2Fdotproject-204-on-godaddy-shared-hosting.html&amp;linkname=dotProject%202.0.4%2F2.1.2%2F2.1.3%20on%20shared%20hosting" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F01%2F22%2Fdotproject-204-on-godaddy-shared-hosting.html&amp;linkname=dotProject%202.0.4%2F2.1.2%2F2.1.3%20on%20shared%20hosting" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F01%2F22%2Fdotproject-204-on-godaddy-shared-hosting.html&amp;linkname=dotProject%202.0.4%2F2.1.2%2F2.1.3%20on%20shared%20hosting" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2007%2F01%2F22%2Fdotproject-204-on-godaddy-shared-hosting.html&amp;linkname=dotProject%202.0.4%2F2.1.2%2F2.1.3%20on%20shared%20hosting" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2007%2F01%2F22%2Fdotproject-204-on-godaddy-shared-hosting.html&#038;title=dotProject%202.0.4%2F2.1.2%2F2.1.3%20on%20shared%20hosting" data-a2a-url="https://bogdan.org.ua/2007/01/22/dotproject-204-on-godaddy-shared-hosting.html" data-a2a-title="dotProject 2.0.4/2.1.2/2.1.3 on shared hosting"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2007/01/22/dotproject-204-on-godaddy-shared-hosting.html/feed</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>HTTP caching: universal approach and sample code</title><link>https://bogdan.org.ua/2006/12/09/http-caching-universal-approach-and-sample-code.html</link> <comments>https://bogdan.org.ua/2006/12/09/http-caching-universal-approach-and-sample-code.html#comments</comments> <pubDate>Sat, 09 Dec 2006 09:16:53 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[caching]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[http]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2006/12/09/http-caching-universal-approach-and-sample-code.html</guid> <description><![CDATA[As described in my previous post, there are some rather simple mechanisms to enable visitor&#8217;s browser to cache content, and avoid unnecessary load on your servers. In this post I&#8217;ll take a look at some parts of the practical implementation of the caching mechanism on the server, using PHP. I think of caching as a [&#8230;]]]></description> <content:encoded><![CDATA[<p>As described in my <a
href="http://bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html" title="HTTP caching: request and response headers">previous post</a>, there are some rather simple mechanisms to enable visitor&#8217;s browser to cache content, and avoid unnecessary load on your servers. In this post I&#8217;ll take a look at some parts of the practical implementation of the caching mechanism on the server, using PHP.<br
/> <span
id="more-50"></span><br
/> I think of caching as a set of relatively independent procedures:</p><ol><li>Process browser&#8217;s request &#8211; find out, if the browser is asking for content for the first time, or is looking for an updated version. If the browser&#8217;s content is fresh, just reply that it&#8217;s fresh. Otherwise, proceed to step 2. Also proceed to step 2, if this is a first-time request.</li><li>If this is a first-time request, check if we have a fresh locally cached content, and send it in response, to bypass <em>de novo</em> contet generation. If local cache is stale, proceed to step 3.</li><li>Generate new (fresh) content cache item, and send it to browser, together with cache-enabling headers.</li></ol><p>I decided to put all the header-related processing into one function, and all the cache-creation and sending &#8211; into another. If you prefer, you can make an object with two or more methods, but I see no need in doing so.</p><p>Here&#8217;s the headers part:</p><div
id="ig-sh-21" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">function HTTP_caching($timestamp)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">{</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; /*</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;* HTTP_caching(v0.3)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;* checks headers for eTag or Modified request,</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;* and replies with HTTP 304 Not Modified</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;* if $timestamp is equal to the requested time/tag</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;* returns TRUE if 304, FALSE otherwise</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp;* produces Last-Modified and ETag headers from $timestamp</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; */</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $latest = gmdate('D, d M Y H:i:s', $timestamp) . ' GMT';</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $etag = md5($latest);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; $not = false;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; if ( $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $latest )</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header(&quot;HTTP/1.1 304 Not Modified&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header(&quot;Status: 304 Not Modified&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $not = true;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; elseif ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) )</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; if ( $_SERVER['HTTP_IF_NONE_MATCH'] == $etag )</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header(&quot;HTTP/1.1 304 Not Modified&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header(&quot;Status: 304 Not Modified&quot;);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $not = true;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; if (!$not)</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; {</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; header(&quot;Last-Modified: &quot; . $latest );</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; &nbsp; &nbsp; header(&quot;ETag: &quot; . $etag);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; }</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp; &nbsp; return $not;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">}</div></li></ol></div></div><p>This function checks two caching-related request headers: If-None-Match and If-Modified-Since. Use of two headers is redundant, but this was done with an idea to provide different caching methods for different content types in the future. Timestamp-based approach should be sufficient in most cases, but having ETag as well does not hurt.</p><p>The parameter this function takes &#8211; $timestamp &#8211; is the date of the locally cached content item. We should check if the cached item exists before calling HTTP_caching; and if cached item does not exist, we should create it and then call HTTP_caching with the timestamp of the newly generated cached content item.</p><p>Function is utterly simple, but needs some explaining comments:</p><ul><li>There is a convenient function &#8220;apache_request_headers&#8221;, but as its name implies, it works only under apache. Thus I had to use global PHP variables for fetching specific request headers. However, this approach also doesn&#8217;t work on all hosting providers &#8211; you just do not get those headers, though they are sent by the browser. But you still benefit from local caching, and the only drawback of being unable to process request headers is that you waste traffic sending data which could have been unsent.</li><li>I&#8217;m also sending two equal headers &#8211; standard HTTP/1.1, and outdated Status header. This is redundant (sending Status might be removed), but depending on how your PHP is installed (as apache-httpd module or CGI) you may want to leave both in place, or experiment and leave the one which actually works.</li></ul><p>Now, let&#8217;s move on to actual caching. The simplest and quite reliable method of identifying any object within your cache is md5(url) &#8211; that is, the hash of the request URL. Note, that you might want to hash not the complete URL (starting with http://), but only the part after the TLD&#8217;s slash, e.g. for complete URL http://bogdan.org.ua/2006/10/27/xnameorg-down-largest-ddos-they-ever-had.html you would hash only the &#8220;xnameorg-down-largest-ddos-they-ever-had.html&#8221; part (or &#8220;2006/10/27/xnameorg-down-largest-ddos-they-ever-had.html&#8221;, if the filename part of the path might be non-unique). Evidently, this will save you from generating cache both for &#8220;http://www.bogdan.org.ua/2006/10/27/xnameorg-down-largest-ddos-they-ever-had.html&#8221; and for &#8220;http://bogdan.org.ua/2006/10/27/xnameorg-down-largest-ddos-they-ever-had.html&#8221; (differing only in &#8220;www.&#8221; part).</p><p>Here&#8217;s what we need to do (some evident micro-tunings dropped for clarity):</p><ol><li>Hash the request URL.</li><li>Check if that cache item exists. If yes &#8211; go to step 4. If not &#8211; step 3.</li><li>Create cache item (cache file), set the file name to the hash of the request URL, and store the file in your cache directory (e.g. &#8216;/cache&#8217;).</li><li>Read cache file modification timestamp.</li><li>Call HTTP_caching with that timestamp. If it returns true &#8211; do nothing. Else &#8211; continue to step 6.</li><li>Read cache file and send it to browser.</li></ol><p>To make this part of caching system wrapped in a single universally applicable function, you will need to define some &#8220;content-generating&#8221; handler function, which will be called when local cache file must be regenerated. &#8220;Content-generation&#8221; might be as simple as just reading some file from the disk; or you could wrap your index.php file in cache-checking block, so that page call and generation occur only if there is no readily available cached page.</p><p>function caching($handler_function)<br
/> {<br
/> // first, check if we have existing cache<br
/> // of currently requested resource in the &#8216;cache&#8217; directory<br
/> $cachedfile = &#8216;cache/&#8217; . md5($_SERVER['REQUEST_URI']);<br
/> if (file_exists($cachedfile) &#038;&#038; is_file($cachedfile))<br
/> { // cache exists. now check if it is up-to-date<br
/> $filetime = filemtime($cachedfile);<br
/> $modif = time() &#8211; $filetime;<br
/> // CACHE_PERIOD is a constant defined somewhere else,<br
/> // e.g. define(&#8216;CACHE_PERIOD&#8217;,300)<br
/> if ($modif <= (int)CACHE_PERIOD)
{
if ( HTTP_caching($filetime) === false )
{ // we need to send cached content to browser - no
// if-modified-since or if-none-match request headers
$expires = gmdate('D, d M Y H:i:s', ($filetime + CACHE_PERIOD) ) . ' GMT';
send_cached_file($cachedfile, CACHE_PERIOD, $expires)
}
// if HTTP_caching returned 'true' - we are done with '304' header.
// finally, ensure nothing else happens after sending contents...
exit();
}
// if cache is old - just call $handler_function,
// assuming that it returns all the content
$new_cache = $handler_function();
// if instead of using $handler_function you wrap some code:
// ob_start();
// include "page_generation.php";
// $new_cache = ob_get_contents();
// ob_end_clean();
$fp = fopen ($cachedfile, "w");
fwrite ($fp, $new_cache);
fclose ($fp);
$filetime = filemtime($cachedfile);
$expires = gmdate('D, d M Y H:i:s', ($filetime + CACHE_PERIOD) ) . ' GMT';
send_cached_file($cachedfile, CACHE_PERIOD, $expires);
}
}
[/php]
Below is a function which sends cached files to the browser. Note, that it lacks content-type parameter (or content-type detection code).
[php]
function send_cached_file($cachedfile, $cache, $expires)
{
// I omitted Content-Length and Content-Type for simplicity,
// though it's better to send them
header("HTTP/1.1 200 OK");
header("Status: 200 OK");
header("Pragma: cache");
header("Cache-Control: max-age=".$cache.", min-fresh=".$cache.", no-transform");
// Content-Type needs adjustment on a per-content-item basis
header("Content-Type: text/html");
header("Content-Length: " . filesize($cachedfile));
header("Expires: $expires");
readfile($cachedfile);
}
[/php]
(Note: function 'caching' was not tested; if you find any errors, or if it just doesn't work for you - let me know via the <a
href="http://bogdan.org.ua/contact">contact form</a>, I&#8217;ll try to fix my error.)</p><p>For the explanation of what headers mean, refer to <a
href="http://bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html" title="HTTP caching: request and response headers">my previous post</a>.</p><p>This is it for now. Coming next might be some useful information on differences in HTTP headers handling between PHP installed as a module and PHP as CGI.</p><p>As always, comments/suggestions are welcome.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F12%2F09%2Fhttp-caching-universal-approach-and-sample-code.html&amp;linkname=HTTP%20caching%3A%20universal%20approach%20and%20sample%20code" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F12%2F09%2Fhttp-caching-universal-approach-and-sample-code.html&amp;linkname=HTTP%20caching%3A%20universal%20approach%20and%20sample%20code" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F12%2F09%2Fhttp-caching-universal-approach-and-sample-code.html&amp;linkname=HTTP%20caching%3A%20universal%20approach%20and%20sample%20code" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F12%2F09%2Fhttp-caching-universal-approach-and-sample-code.html&amp;linkname=HTTP%20caching%3A%20universal%20approach%20and%20sample%20code" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F12%2F09%2Fhttp-caching-universal-approach-and-sample-code.html&amp;linkname=HTTP%20caching%3A%20universal%20approach%20and%20sample%20code" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2006%2F12%2F09%2Fhttp-caching-universal-approach-and-sample-code.html&#038;title=HTTP%20caching%3A%20universal%20approach%20and%20sample%20code" data-a2a-url="https://bogdan.org.ua/2006/12/09/http-caching-universal-approach-and-sample-code.html" data-a2a-title="HTTP caching: universal approach and sample code"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2006/12/09/http-caching-universal-approach-and-sample-code.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>HTTP caching: request and response headers</title><link>https://bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html</link> <comments>https://bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html#comments</comments> <pubDate>Wed, 18 Oct 2006 15:22:25 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html</guid> <description><![CDATA[In this post: some caching-related HTTP request and response headers discussed. Modern websites are &#8220;dynamic&#8221; by nature &#8211; content you get depends on a number of variables and conditions. The simplest example &#8211; being a &#8220;guest&#8221; or a &#8220;registered&#8221; user of some forum; in both cases you get content generated by the same script/program, but [&#8230;]]]></description> <content:encoded><![CDATA[<p><em>In this post: some caching-related HTTP request and response headers discussed.</em></p><p>Modern websites are &#8220;dynamic&#8221; by nature &#8211; content you get depends on a number of variables and conditions. The simplest example &#8211; being a &#8220;guest&#8221; or a &#8220;registered&#8221; user of some forum; in both cases you get content generated by the same script/program, but it differs because of your &#8220;registered&#8221; state.</p><p>Another example &#8211; web-photogallery. By design, it is wise to always keep the original photo (the largest and presumably of the highest quality). When gallery visitor&#8217;s browser requests any smaller version of the photo &#8211; we can dynamically resize (often downsize) the original and feed the resulting photo to the browser. This scheme works OK until your gallery gets more and more visitors &#8211; CPU load climbs up and increases wait time when accessing your gallery. Evidently, caching is needed.<br
/> <span
id="more-48"></span><br
/> Caching is a process of storing some integral (independent, atomic) piece of data in order to quickly retrieve it later, when asked for, in cases, when creating/accessing that piece of data without storing would require more time. Caching provides means to bypass calculation-intensive steps of content creation, and thus decreases server load, and allows your server to generate content faster, and deliver it to more visitors.</p><p>Probably the most important parameter of caching is &#8220;cache period&#8221; &#8211; time, during which cached piece of data is considered &#8220;fresh&#8221; and is read of the cache; if the cached piece of data exists more than &#8220;cache period&#8221; &#8211; it is considered &#8220;stale&#8221;, and should be replaced with newly recreated piece of data.</p><p>When web-server sends some content to the browser, there are three main &#8220;RFC-compliant&#8221; headers it may use to instruct the browser how to cache that content. These headers are Last-Modified, ETag, and Cache-Control. Two of these &#8211; Last-Modified and ETag &#8211; force the compliant browser to generate specific request tags: If-Modified-Since and If-None-Match. The Cache-Control header instructs the browser&#8217;s cache on how to handle data. For complete technical description, please refer to <a
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">RFC2616</a>.</p><p><strong>Last-Modified</strong> informs the browser about the date when the document (or image) was last updated (modified). Correct Last-Modified header must be issued using GMT time, and might look like this example:</p><div
id="ig-sh-22" class="syntax_hilite"><div
class="code"><ol
class="code" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">Last-Modified: Wed, 10 May 2006 08:24:39 GMT</div></li></ol></div></div><p>Sending this response header makes the browser to add corresponding <strong>If-Modified-Since</strong> request header next time it needs to load the resource. Following our example, browser&#8217;s request would include:</p><div
id="ig-sh-23" class="syntax_hilite"><div
class="code"><ol
class="code" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">If-Modified-Since: Wed, 10 May 2006 08:24:39 GMT</div></li></ol></div></div><p>Note: browsers are recommended to send back time exactly as it was sent by the server, without modifications. At the moment, I do not know whether and which browsers follow this recommendation. In any case, if you do send time as GMT, you are more likely to get the desired caching effect, than if you send any unique string in the Last-Modified header.</p><p>If a web-server receives If-Modified-Since header, it might reply either with a <em>HTTP/1.1 200 OK</em> (followed by resource data) or <em>HTTP/1.1 304 Not Modified</em> (header itself, no data following). Server response depends on the &#8220;fresh&#8221; or &#8220;stale&#8221; status of the resource, as described above.</p><p>Time is not always a good measure of resource &#8220;freshness&#8221;, especially in the case of dynamic sites, which send and process headers themselves, &#8220;bypassing&#8221; server behaviours. In order to identify some resource, an <strong>ETag</strong> response header can be used:</p><div
id="ig-sh-24" class="syntax_hilite"><div
class="code"><ol
class="code" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">ETag: &quot;some-double-quoted-string&quot;</div></li></ol></div></div><p>ETag is used as a unique resource identifier, which is expected to change if the resource changes. (Here, cyclic redundancy checks come to memory &#8211; and that is correct, hashing algorithms like CRC32 and md5 can be used on resource content to generate it&#8217;s ETag.) When a browser receives ETag header, then on next request it should send &#8220;If-None-Match&#8221; header:</p><div
id="ig-sh-25" class="syntax_hilite"><div
class="code"><ol
class="code" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">If-None-Match: &quot;some-double-quoted-string&quot;</div></li></ol></div></div><p>Obviously, string sent by the browser must be equal to one received from the server. Server behaviour in this case is determined by the equality or non-equality of local (server) and received (from browser in If-None-Match) tags: equality hints sending the 304 Not Modified header only, non-equality requires sending 200 OK with content following.</p><p>ETag header value also has weak/strong modifiers, and If-None-Match request header is not the only one for handling ETag, but I will not cover those topics here. Please refer to <a
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">RFC2616</a> for more.</p><p>Finally, <strong>Cache-Control</strong> response header is used to tell the browser how to cache (and if to cache at all) the resource being sent. Cache-Control has a number of possible values (comma-separated if there are more than one), but I will review only some of the values.<br
/> no-cache: forces resource re-validation on each request.<br
/> no-store: (applies to both request and response) forces the resource not to be stored at all; this is usually important for sensitive data.<br
/> max-age: (in seconds) informs about the time period when resource stays &#8220;fresh&#8221;.<br
/> must-revalidate: as the name implies, effect is similar to no-cache.<br
/> no-transform: forbids any resource transformations by proxies/servers in the chain to the end user (don&#8217;t think it&#8217;s still relevant, though).</p><p>That is it. Next post will continue the caching topic with the discussion of the universal approach to caching for web-sites.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F10%2F18%2Fhttp-caching-request-and-response-headers.html&amp;linkname=HTTP%20caching%3A%20request%20and%20response%20headers" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F10%2F18%2Fhttp-caching-request-and-response-headers.html&amp;linkname=HTTP%20caching%3A%20request%20and%20response%20headers" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F10%2F18%2Fhttp-caching-request-and-response-headers.html&amp;linkname=HTTP%20caching%3A%20request%20and%20response%20headers" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F10%2F18%2Fhttp-caching-request-and-response-headers.html&amp;linkname=HTTP%20caching%3A%20request%20and%20response%20headers" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F10%2F18%2Fhttp-caching-request-and-response-headers.html&amp;linkname=HTTP%20caching%3A%20request%20and%20response%20headers" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2006%2F10%2F18%2Fhttp-caching-request-and-response-headers.html&#038;title=HTTP%20caching%3A%20request%20and%20response%20headers" data-a2a-url="https://bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html" data-a2a-title="HTTP caching: request and response headers"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2006/10/18/http-caching-request-and-response-headers.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>PHP-Nuke 6.0/6.5 to Drupal 4.7.x/5.x migration (conversion)</title><link>https://bogdan.org.ua/2006/09/08/php-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html</link> <comments>https://bogdan.org.ua/2006/09/08/php-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html#comments</comments> <pubDate>Fri, 08 Sep 2006 15:29:56 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[CMS]]></category> <category><![CDATA[Drupal]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[conversion]]></category> <category><![CDATA[drupal]]></category> <category><![CDATA[import]]></category> <category><![CDATA[migration]]></category> <category><![CDATA[module]]></category> <category><![CDATA[php-nuke]]></category> <category><![CDATA[phpnuke]]></category> <category><![CDATA[utf8]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2006/09/08/php-nuke-60-to-drupal-473-migration-conversion.html</guid> <description><![CDATA[Post last updated: April 18, 2010. Now there is a Drupal 6.x module available. It is in no way related to the migrate script(s) below. The newest script version migrates from PHP-Nuke 6.5 to Drupal 5.x. Download the latest version of the migration script. In 2002 I set up a PHPNuke-6.0 &#8211; based portal. Eventually [&#8230;]]]></description> <content:encoded><![CDATA[<p><em>Post last updated: April 18, 2010.</em></p><p><ins
datetime="2010-04-18T17:54:34+00:00">Now</ins> there is a <a
href="https://drupal.org/project/phpnuke2drupal" class="broken_link" rel="nofollow">Drupal 6.x module available</a>. It is in no way related to the migrate script(s) below.</p><p><ins
datetime="2008-02-19T03:34:21+00:00" title="Note: other version combinations might work as well with no or little modifications. It is known (via bxtra.net) that the script also works for PHPNuke 7.8 to Drupal 5.7 migration - though it isn't known if any modifications were necessary.">The newest script version migrates from PHP-Nuke 6.5 to Drupal 5.x</ins>.<br
/> <a
href="#latest">Download the latest version of the migration script</a>.</p><p>In 2002 I set up a PHPNuke-6.0 &#8211; based portal. Eventually it died due to the lack of time investments and support from collaborators. Now, when time came to revive the project, I made a search and decided to use Drupal as a base CMS for the portal.<br
/> In order to migrate userbase from an old portal to the new Drupal-powered one, and following the <a
href="https://drupal.org/node/498" title="Migrating from PHPNuke" class="broken_link" rel="nofollow">topic</a> at drupal.org, I found a <a
href="http://quillem.com/nuke2drupal" title="original nuke_7.0 to drupal_4.6 script">script</a> and its modification.<br
/> I used it to migrate only users, and made some cosmetic changes:</p><ul><li>added options for custom phpnuke table prefixes</li><li>default user name is now = uname (login), not &#8216;temp_name&#8217;, as before</li><li>I replaced hard-coded links to &#8216;migrate.php&#8217; with links to $_SERVER['PHP_SELF'], so that if you rename the script you don&#8217;t have any problems with that <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></li><li>now forum topics should not be promoted to the main page (changed 1 to 0 as hinted by Alexis)</li></ul><p>Finally, I would like to thank both <a
href="http://quillem.com/">Karthik Kumar</a> for the original script and Alexis Bellido for the 6.0_to_4.7 modification.<br
/> <span
id="more-24"></span></p><p><ins
datetime="2007-02-25T08:46:18+00:00">Update:</ins> Waldo updated the migration script.<br
/> Here are the changes:</p><ul><li>imports from (a security-patched) Nuke 6.5 -> Drupal 5.1</li><li>imports story categories into Drupal taxonomy</li><li>incorporates phpnuke &#8220;Contributor writes&#8230;&#8221; into story</li><li>incorporates phpnuke admin story &#8220;note&#8221;</li><li>imports polls (does not import record of who already voted.  You can easily &#8220;close&#8221; old phpnuke polls via Admin page.  I left them open.)</li><li>imports poll comments</li><li>imports *anonymous* comments for stories, fora, &#038; polls</li><li>imports anonymous forum posts</li><li>filters BBCode to make semi-compatible with Drupal BBCode module</li><li>uses Drupal 5.0 API, and must be run from drupal root directory (/drupal-5/, for example)</li></ul><p>Thanks to Waldo for his work!</p><p><ins
datetime="2007-08-19T15:55:21+00:00"><strong>Latest update:</strong></ins> Waldo sent the newest, improved version of the PHP-Nuke-2-Drupal conversion script. Here is Waldo&#8217;s description:</p><blockquote><p> New Fixes:</p><ul><li>retain original user registration date &#038; last visit   4/22/07</li><li>fixed user migration bug which could result in screwed max_uid in session table   4/22/07</li><li>store anonymous forum posts names in the log for future compatibility w/Drupal 6   7/16/07</li><li>uses the &#8220;tidy&#8221; extension (if installed) in php 5.x to clean up the HTML of postings &#038; stories  7/30/07</li><li>bug fixes (possibly) related to drupal 5.2 where the fora had the wrong &#8220;changed&#8221; date resulting in misordered node lists. 7/30/07</li><li>polls properly remember date of last comment 7/30/07</li></ul><p>If you have the &#8220;tidy&#8221; PHP extension, it should close all open HTML tags and stuff in stories.</p></blockquote><p><ins
datetime="2008-02-19T15:23:55+00:00">update:</ins> I added to the script some more debug messages in case something goes wrong (as <a
href="http://bogdan.org.ua/2006/09/08/php-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html#comment-39615">recommended by me</a>) &#8211; that pushed the version up to 0.03.</p><p>Also, now MySQL connection collation is set to utf8 before doing anything &#8211; this <em>should</em> fix the problems with non-English characters in the imported texts (especially accented/umlauted/etc characters). Thus I upped the version to 0.04. For reference and in case 0.04 doesn&#8217;t work for you, I keep the older versions as well.</p><p><a
name="latest"> </a><br
/> Download the <a
href="http://bogdan.org.ua/wp-content/uploads/2008/02/phpnuke2drupal-5.x-0.04-w.zip" title="PHP-Nuke 6.0/6.5 to Drupal 4.7.x/5.x migration (conversion)">latest phpnuke2drupal-5.x-0.04-W.zip</a> or the <a
href="http://bogdan.org.ua/wp-content/uploads/2008/02/phpnuke2drupal-5.x-0.04-w.tar.gz" title="PHP-Nuke 6.0/6.5 to Drupal 4.7.x/5.x migration (conversion)">latest tar-gzipped version of the phpnuke2drupal migration script</a>.</p><p><ins
datetime="2010-01-03T21:35:38+00:00">update:</ins> to import Reviews and WebLinks from PHPNuke to Drupal, have a look at <a
href="https://drupal.org/node/202528#comment-724422" class="broken_link" rel="nofollow">this</a> and <a
href="https://drupal.org/node/202528#comment-689245" class="broken_link" rel="nofollow">this</a> comments; you will need CCK, and might need CCK Link Field to import reviews/weblinks.</p><p><u>Previous (older) versions</u>:<br
/> <a
href="http://bogdan.org.ua/wp-content/uploads/2008/01/phpnuke2drupal-5.x-0.03-W.zip">phpnuke2drupal-5.x-0.03-W.zip</a><br
/> <a
href="http://bogdan.org.ua/wp-content/uploads/2008/01/phpnuke2drupal-5.x-0.03-W.tar.gz">phpnuke2drupal-5.x-0.03-W.tar.gz</a><br
/> <a
href="http://bogdan.org.ua/wp-content/uploads/2007/08/phpnuke2drupal-5.x-0.02-w.zip">phpnuke2drupal-5.x-0.02-w.zip</a><br
/> <a
href="http://bogdan.org.ua/wp-content/uploads/2007/08/phpnuke2drupal-5.x-0.02-w.tar.gz">phpnuke2drupal-5.x-0.02-w.tar.gz</a><br
/> <a
href="http://bogdan.org.ua/wp-content/uploads/2007/02/phpnuke2drupal-5.x-0.01-W.rar">phpnuke2drupal-5.x-0.01 (VValdo&#8217;s huge improvements first appear here)</a><br
/> <a
href="http://bogdan.org.ua/wp-content/uploads/2006/09/migrate_phpnuke_60_to_drupal_47.txt" title="download">first version with my minor modifications</a></p><p><strong>IMPORTANT:</strong> for migration to work you will need MySQL version to be >= 4.1.1. Earlier versions do not support the STR_TO_DATE() function, used in the migration script.</p><p><strong>IMPORTANT:</strong> if you want to migrate forum entries from PHPNuke to Drupal, be sure to setup forum in your Drupal installation first &#8211; otherwise migration of forum entries will fail. See comments 13-17 below for user experiences.</p><p>If you do not get any help here, there is also a drupal.org <a
href="https://drupal.org/node/498" title="Migrating from PHPNuke" class="broken_link" rel="nofollow">migration thread</a>. I will keep this page updated for as long as I get new information about the migration script.</p><p>If you encounter any problems during migration &#8211; just search/scan the comments, your problem might have been already solved by someone else.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F08%2Fphp-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html&amp;linkname=PHP-Nuke%206.0%2F6.5%20to%20Drupal%204.7.x%2F5.x%20migration%20%28conversion%29" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F08%2Fphp-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html&amp;linkname=PHP-Nuke%206.0%2F6.5%20to%20Drupal%204.7.x%2F5.x%20migration%20%28conversion%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F08%2Fphp-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html&amp;linkname=PHP-Nuke%206.0%2F6.5%20to%20Drupal%204.7.x%2F5.x%20migration%20%28conversion%29" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F08%2Fphp-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html&amp;linkname=PHP-Nuke%206.0%2F6.5%20to%20Drupal%204.7.x%2F5.x%20migration%20%28conversion%29" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F08%2Fphp-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html&amp;linkname=PHP-Nuke%206.0%2F6.5%20to%20Drupal%204.7.x%2F5.x%20migration%20%28conversion%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F08%2Fphp-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html&#038;title=PHP-Nuke%206.0%2F6.5%20to%20Drupal%204.7.x%2F5.x%20migration%20%28conversion%29" data-a2a-url="https://bogdan.org.ua/2006/09/08/php-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html" data-a2a-title="PHP-Nuke 6.0/6.5 to Drupal 4.7.x/5.x migration (conversion)"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2006/09/08/php-nuke-6-06-5-to-drupal-4-7-x5-x-migration-conversion.html/feed</wfw:commentRss> <slash:comments>77</slash:comments> </item> <item><title>Allow posting duplicate form-name entries with different values</title><link>https://bogdan.org.ua/2006/09/06/allow-posting-duplicate-form-name-entries-with-different-values.html</link> <comments>https://bogdan.org.ua/2006/09/06/allow-posting-duplicate-form-name-entries-with-different-values.html#comments</comments> <pubDate>Wed, 06 Sep 2006 09:04:41 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Bioinformatics]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Science]]></category> <category><![CDATA[http]]></category> <category><![CDATA[HTTP_Client]]></category> <category><![CDATA[HTTP_Request]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2006/09/06/allow-posting-duplicate-form-name-entries-with-different-values.html</guid> <description><![CDATA[Sometimes, writing automatic HTML forms processors, you need to post several values with the same name of the form field, e.g.: collection_gene = str_chrom_name collection_gene = gene_stable_id This is against the RFC on form fields design and submitting, but this approach is used &#8211; for example, by Ensembl. I spent some time to figure out [&#8230;]]]></description> <content:encoded><![CDATA[<p>Sometimes, writing automatic HTML forms processors, you need to post several values with the same name of the form field, e.g.:<br
/> collection_gene = str_chrom_name<br
/> collection_gene = gene_stable_id</p><p>This is against the RFC on form fields design and submitting, but this approach is used &#8211; for example, by <a
href="http://www.ensembl.org/index.html" title="Ensembl genome automatic annotation database" target="_blank">Ensembl</a>. I spent some time to figure out how to make HTTP_Client and HTTP_Request submit multiple &#8216;name-value&#8217; pairs instead of one (the latest defined, which overrides the previous). The solution is extremely simple:<br
/> <span
id="more-23"></span></p><div
id="ig-sh-26" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">/*</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;allow posting duplicate form-name</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;entries with different values</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">*/</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$params['useBrackets'] = false;</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$req = &amp;new HTTP_Client($params, $headers);</div></li></ol></div></div><p>After setting &#8216;useBrackets&#8217; parameter to &#8216;false&#8217;, HTTP_Client/HTTP_Request do post multiple lines as you would want it.</p><p>Hope this saves you some time.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Fallow-posting-duplicate-form-name-entries-with-different-values.html&amp;linkname=Allow%20posting%20duplicate%20form-name%20entries%20with%20different%20values" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Fallow-posting-duplicate-form-name-entries-with-different-values.html&amp;linkname=Allow%20posting%20duplicate%20form-name%20entries%20with%20different%20values" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Fallow-posting-duplicate-form-name-entries-with-different-values.html&amp;linkname=Allow%20posting%20duplicate%20form-name%20entries%20with%20different%20values" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Fallow-posting-duplicate-form-name-entries-with-different-values.html&amp;linkname=Allow%20posting%20duplicate%20form-name%20entries%20with%20different%20values" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Fallow-posting-duplicate-form-name-entries-with-different-values.html&amp;linkname=Allow%20posting%20duplicate%20form-name%20entries%20with%20different%20values" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Fallow-posting-duplicate-form-name-entries-with-different-values.html&#038;title=Allow%20posting%20duplicate%20form-name%20entries%20with%20different%20values" data-a2a-url="https://bogdan.org.ua/2006/09/06/allow-posting-duplicate-form-name-entries-with-different-values.html" data-a2a-title="Allow posting duplicate form-name entries with different values"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2006/09/06/allow-posting-duplicate-form-name-entries-with-different-values.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Avoiding out of memory fatal error when using HTTP_Client or HTTP_Request</title><link>https://bogdan.org.ua/2006/09/06/avoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html</link> <comments>https://bogdan.org.ua/2006/09/06/avoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html#comments</comments> <pubDate>Wed, 06 Sep 2006 08:58:29 +0000</pubDate> <dc:creator><![CDATA[Bogdan]]></dc:creator> <category><![CDATA[Bioinformatics]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Science]]></category> <category><![CDATA[http]]></category> <category><![CDATA[HTTP_Client]]></category> <category><![CDATA[HTTP_Request]]></category> <category><![CDATA[memory]]></category> <guid
isPermaLink="false">http://www.bogdan.org.ua/2006/09/06/avoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html</guid> <description><![CDATA[If you fetch large amounts of data (e.g. over 2MB per request) using HTTP_Client (or HTTP_request), you may get &#8220;out of memory&#8221; fatal errors, especially if: memory_limit is set to default 8M, and you process multiple pages using single non-reset instance of HTTP_Client object. This problem can manifest itself by producing fatal error after a [&#8230;]]]></description> <content:encoded><![CDATA[<p>If you fetch large amounts of data (e.g. over 2MB per request) using HTTP_Client (or HTTP_request), you may get &#8220;out of memory&#8221; fatal errors, especially if:</p><ol><li>memory_limit is set to default 8M, and</li><li>you process multiple pages using single non-reset instance of HTTP_Client object.</li></ol><p>This problem can manifest itself by producing fatal error after a couple of cycles of successful page retrieval &#8211; but always, if run with the same parameters, after some constant or only slightly variable number of cycles.</p><p>In my case the problem was that HTTP_Request (a dependancy of HTTP_Client) was holding in memory all the previously fetched pages of the current session (the &#8216;history&#8217; feature). To force HTTP_Request to hold only the most recent page, you need to &#8216;disable&#8217; history after creating the HTTP_Client or HTTP_Request object instance:</p><div
id="ig-sh-27" class="syntax_hilite"><div
class="code"><ol
class="php" style="font-family:monospace;"><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$req = &amp;new HTTP_Client($params, $headers);</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">// disable history to save memory</div></li><li
style="font-weight: normal; vertical-align:top;"><div
style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$req-&gt;enableHistory(false);</div></li></ol></div></div><p>Hope this helps you.</p><p><a
class="a2a_button_citeulike" href="https://www.addtoany.com/add_to/citeulike?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Favoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html&amp;linkname=Avoiding%20out%20of%20memory%20fatal%20error%20when%20using%20HTTP_Client%20or%20HTTP_Request" title="CiteULike" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Favoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html&amp;linkname=Avoiding%20out%20of%20memory%20fatal%20error%20when%20using%20HTTP_Client%20or%20HTTP_Request" title="Pocket" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_kindle_it" href="https://www.addtoany.com/add_to/kindle_it?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Favoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html&amp;linkname=Avoiding%20out%20of%20memory%20fatal%20error%20when%20using%20HTTP_Client%20or%20HTTP_Request" title="Kindle It" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_evernote" href="https://www.addtoany.com/add_to/evernote?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Favoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html&amp;linkname=Avoiding%20out%20of%20memory%20fatal%20error%20when%20using%20HTTP_Client%20or%20HTTP_Request" title="Evernote" rel="nofollow noopener" target="_blank"></a><a
class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Favoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html&amp;linkname=Avoiding%20out%20of%20memory%20fatal%20error%20when%20using%20HTTP_Client%20or%20HTTP_Request" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a
class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fbogdan.org.ua%2F2006%2F09%2F06%2Favoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html&#038;title=Avoiding%20out%20of%20memory%20fatal%20error%20when%20using%20HTTP_Client%20or%20HTTP_Request" data-a2a-url="https://bogdan.org.ua/2006/09/06/avoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html" data-a2a-title="Avoiding out of memory fatal error when using HTTP_Client or HTTP_Request"><img
src="https://static.addtoany.com/buttons/share_save_120_16.png" alt="Share"></a></p>]]></content:encoded> <wfw:commentRss>https://bogdan.org.ua/2006/09/06/avoiding-out-of-memory-fatal-error-when-using-http_client-or-http_request.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>