<?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>rarecore development &#187; PHP</title>
	<atom:link href="http://blog.rarecore.eu/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.rarecore.eu</link>
	<description>the blog that matters...</description>
	<lastBuildDate>Tue, 27 Dec 2011 10:15:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>XAJAX Autocompleter V2</title>
		<link>http://blog.rarecore.eu/xajax-autocompleter-v2.html</link>
		<comments>http://blog.rarecore.eu/xajax-autocompleter-v2.html#comments</comments>
		<pubDate>Fri, 11 Sep 2009 14:11:32 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[technobase]]></category>
		<category><![CDATA[we are one]]></category>
		<category><![CDATA[xajax]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[autocompleter]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=372</guid>
		<description><![CDATA[It is often helpful to use an autocompleter on your website. Perhaps in search dialogs? An example is google on an extra search page. I tested some free tools, but I had always the problem that there was no possibility to use two or more autocompleter on one page and to organize the dependency. E.g. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/demo/xajax_autocompleter_v2/" target="_blank"><img class="alignleft" title="rarecore autocompleter" src="/wp-content/uploads/2009/02/autocompleter.png" alt="rarecore autocompleter" width="285" height="111" /></a>It is often helpful to use an autocompleter on your website. Perhaps in search dialogs? An example is google on an extra search page.</p>
<p>I tested some free tools, but I had always the problem that there was no possibility to use two or more autocompleter on one page and to organize the dependency. E.g. insert a name of a country in the first textbox and in the second textbox insert a name of a city. On the city textbox you only want to see cities belonging to the inserted country – no other cities.</p>
<p>This problem was the reason why I developed my own autocompleter using xajax. This framework allows me to respond on the key events and select the values from the database. I could write my own functions and use any parameters.</p>
<p>I generated a textbox with a hidden div below which is calling a function on the onkeyup event by using xajax. In this test I mark the searched string with a span and on CSS I colored it blue. Additional I added a mouseover using CSS.</p>
<p><strong>Here you could download the second version of my autocompleter.</strong></p>
<p>Changes:<br />
 &#8211; Using the arrow keys to choose the correct value<br />
 &#8211; Performance Tuning</p>
<p><a href="/demo/xajax_autocompleter_v2/">Demo</a><br />
<span style="display:block; border: 1px solid #CCC; margin-left:4px; margin-right:4px; width:500px; height:60px">
<span style="display:block;float:left;margin-left:5px;margin-top:5px"><img src="http://blog.rarecore.eu/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://blog.rarecore.eu/wp-content/plugins/downloads-manager/img/icons/default.gif" /></span >
<span style="display:block;float:left;margin-left:5px;margin-top:5px">
   <b>download:</b> <a href="http://blog.rarecore.eu/?file_id=2">Autocompleter v2</a> <small>(119.55KB)</small><br />
  <b>added:</b> 08/11/2009 <br />
  <b>clicks:</b> 2553 
</span >
</span >
<br style="clear:left" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/xajax-autocompleter-v2.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP 5 memcache extension on Debian Etch as session handler</title>
		<link>http://blog.rarecore.eu/php_5_memcache_extension_on_debian_etch_as_session_handler.html</link>
		<comments>http://blog.rarecore.eu/php_5_memcache_extension_on_debian_etch_as_session_handler.html#comments</comments>
		<pubDate>Wed, 13 May 2009 17:45:46 +0000</pubDate>
		<dc:creator>Remolus</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[etch]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[session_handler]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=326</guid>
		<description><![CDATA[Have you ever thought about a method of saving sessions without getting a lot of session files or using a selfmade session handler? The answer for this question is memcache. A module giving you the ability to store variables in memory for a defined time. You can install the module on a Linux and a [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever thought about a method of saving sessions without getting a lot of session files or using a selfmade session handler?<br />
The answer for this question is <strong>memcache</strong>. A module giving you the ability to store variables in memory for a defined time. You can install the module on a Linux and a Windows Server. I only want to explain you how to set it up on <strong>Linux Debian Etch</strong>.</p>
<p>At first you have to do is to install the server module.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">apt<span style="color: #339933;">-</span>get install memcached</pre></div></div>

<p>If the application is already started, we have to kill the process to setup what we want.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">memcached <span style="color: #339933;">-</span>d <span style="color: #339933;">-</span>u www<span style="color: #339933;">-</span>data <span style="color: #339933;">-</span>m <span style="color: #CC0000;">2048</span> <span style="color: #339933;">-</span>l 127.0.0.1 <span style="color: #339933;">-</span>p <span style="color: #CC0000;">11211</span></pre></div></div>

<p><span style="text-decoration: underline;">Explain this command:</span><br />
<strong>memcached</strong> (command)<br />
<strong>-d</strong> (the parameter to run it in background)<strong><br />
</strong><strong>-u</strong> www-data (to run it under the standard apache2 user www-data)<br />
<strong>-m</strong> (Sets the space of the memcached server (in Mega Byte) (in this example 2048 MB (Mega Byte))<br />
<strong>-l</strong> (Sets the IP the memcached server listens to)<br />
<strong>-p</strong> (Sets the Port the memcached server listens to)</p>
<p>Now the memcache server runs as www-data with a space of 2024 MB RAM which is listen to localhost:11211. The next step is to involve PHP. For that we have to enable the module memcache.</p>
<p>You could get the latest version <a title="memcache PECL Module" href="http://pecl.php.net/package/memcache" target="_blank">here</a>. Please use the wget command to download the file. <em>(Note: replace X.X.X. with the current version)</em></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">cd <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>src
wget http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//pecl.php.net/get/memcache-X.X.X.tgz</span>
tar zxvf memcache<span style="color: #339933;">-</span>X.<span style="color: #660066;">X</span>.<span style="color: #660066;">X</span>.<span style="color: #660066;">tgz</span>
cd memcache<span style="color: #339933;">-</span>X.<span style="color: #660066;">X</span>.<span style="color: #660066;">X</span>
apt<span style="color: #339933;">-</span>get install php5<span style="color: #339933;">-</span>dev
phpize
.<span style="color: #339933;">/</span>configure
make <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> make install</pre></div></div>

<p>Okay we have compiled the files. Now you have to move the memcache.so to your extension folder of PHP5. In my case I found the memcache.so in <em>/usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so</em>, but maybe your location is different.</p>
<p>Now copy the file to <em>/usr/lib/php5/20060613+lfs</em></p>
<p>The next step is to get the latest version of the memcache php5 extension in our extension directory. All we have to do now is to configure the php.ini by adding the following line.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">extension<span style="color: #339933;">=</span>memcache.<span style="color: #660066;">so</span></pre></div></div>

<p>Before you could restart the apache2 server you need to set up the memcache that it will be used as session handler. The standard will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">session.<span style="color: #660066;">save_handler</span> <span style="color: #339933;">=</span> files
session.<span style="color: #660066;">save_path</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;N;MODE;/path&quot;</span>
session.<span style="color: #660066;">gc_probability</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span></pre></div></div>

<p>You have to change it to:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">session.<span style="color: #660066;">save_handler</span> <span style="color: #339933;">=</span> memcache
session.<span style="color: #660066;">save_path</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;tcp://127.0.0.1:11211?persistent=1&amp;amp;weight=1&amp;amp;timeout=1&amp;amp;retry_interval=15&quot;</span>
session.<span style="color: #660066;">gc_probability</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span></pre></div></div>

<p>Save the ini file and restart your apache2 server.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>init.<span style="color: #660066;">d</span><span style="color: #339933;">/</span>apache2 restart</pre></div></div>

<p>When you take now a look into your phpinfo it should look like this:</p>
<p style="text-align: center;">
<img class="aligncenter" title="phpinfo" src="/wp-content/uploads/2009/05/memcache.png" alt="" width="384" height="653" /></p>
<p>(the white spaces are private settings)<br />
<strong>Congratulations! If you create now a session it will be stored into the memory instead of creating a file.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/php_5_memcache_extension_on_debian_etch_as_session_handler.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fiddler2 &#8211; The Web Debugging Proxy</title>
		<link>http://blog.rarecore.eu/fiddler2-the-web-debugging-proxy.html</link>
		<comments>http://blog.rarecore.eu/fiddler2-the-web-debugging-proxy.html#comments</comments>
		<pubDate>Wed, 08 Apr 2009 11:29:47 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[technobase]]></category>
		<category><![CDATA[we are one]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[fiddler2]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=308</guid>
		<description><![CDATA[A friend told me something about a tool called fiddler2. It is a web debugging proxy. You only have to start this program and surf in the internet. You can see which pages / files are opened by each application, you can check the status (HTTP Status) and the used protocol, too. It helps a [...]]]></description>
			<content:encoded><![CDATA[<p>A friend told me something about a tool called <a href="http://www.fiddler2.com" target="_blank">fiddler2</a>. It is a web debugging proxy. You only have to start this program and surf in the internet. You can see which pages / files are opened by each application, you can check the status (HTTP Status) and the used protocol, too.</p>
<p>It helps a lot by searching for errors!</p>
<p><a href="http://blog.rarecore.eu/wp-content/uploads/2009/04/fiddler2.png" target="_blank"><img class="alignnone" title="Fiddler2" src="http://blog.rarecore.eu/wp-content/uploads/2009/04/fiddler2.png" alt="" width="713" height="566" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/fiddler2-the-web-debugging-proxy.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>News updated</title>
		<link>http://blog.rarecore.eu/news-updated.html</link>
		<comments>http://blog.rarecore.eu/news-updated.html#comments</comments>
		<pubDate>Thu, 12 Mar 2009 11:45:59 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[technobase]]></category>
		<category><![CDATA[we are one]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=295</guid>
		<description><![CDATA[It is just a small update for us, but a big for SEO. Now on the We aRe oNe Pages the news have a new link and the page title changed, too. For exampe the new release of Phunkless is linked on http://www.technobase.fm/news/9029-phunkless-i-wont-let-you-down. Enjoy it!]]></description>
			<content:encoded><![CDATA[<p>It is just a small update for us, but a big for SEO.</p>
<p>Now on the <a href="http://www.housetime.fm">We aRe oNe Pages</a> the news have a new link and the page title changed, too. For exampe the new release of <a href="http://www.phunkless.de/">Phunkless</a> is linked on <a href="http://www.technobase.fm/news/9029-phunkless-quot-i-wont-let-you-down-quot">http://www.technobase.fm/news/9029-phunkless-i-wont-let-you-down</a>.</p>
<p>Enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/news-updated.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autocompleter using XAJAX</title>
		<link>http://blog.rarecore.eu/autocompleter-using-xajax.html</link>
		<comments>http://blog.rarecore.eu/autocompleter-using-xajax.html#comments</comments>
		<pubDate>Fri, 06 Feb 2009 12:12:20 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[technobase]]></category>
		<category><![CDATA[we are one]]></category>
		<category><![CDATA[xajax]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[autocompleter]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=238</guid>
		<description><![CDATA[It is often helpful to use an autocompleter on your website. Perhaps in search dialogs? An example is google on an extra search page. I tested some free tools, but I had always the problem that there was no possibility to use two or more autocompleter on one page and to organize the dependency. E.g. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.rarecore.eu/demo/xajax_autocompleter" target="_blank"><img class="alignleft" title="rarecore autocompleter" src="/wp-content/uploads/2009/02/autocompleter.png" alt="rarecore autocompleter" width="285" height="111" /></a> It is often helpful to use an autocompleter on your website. Perhaps in search dialogs? An example is <a href="http://www.google.com/webhp?complete=1" target="_blank">google</a> on an extra search page.</p>
<p>I tested some free tools, but I had always the problem that there was no possibility to use two or more autocompleter on one page and to organize the dependency. E.g. insert a name of a country in the first textbox and in the second textbox insert a name of a city. On the city textbox you only want to see cities belonging to the inserted country &#8211; no other cities.</p>
<p>This problem was the reason why I developed my own autocompleter using <a href="http://xajaxproject.org/" target="_blank">xajax</a>. This framework allows me to respond on the key events and select the values from the database. I could write my own functions and use any parameters.</p>
<p>I generated a textbox with a hidden div below which is calling a function on the onkeyup event by using xajax. In this test I mark the searched string with a span and on CSS I colored it blue. Additional I added a mouseover using CSS.</p>
<p><a href="http://blog.rarecore.eu/demo/xajax_autocompleter/" target="_blank"><del datetime="2009-09-11T17:48:06+00:00">Demo</del></a> <a href="/xajax-autocompleter-v2.html">*** NEW VERSION ***</a></p>
<div><span style="display:block; border: 1px solid #CCC; margin-left:4px; margin-right:4px; width:500px; height:60px">
<span style="display:block;float:left;margin-left:5px;margin-top:5px"><img src="http://blog.rarecore.eu/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://blog.rarecore.eu/wp-content/plugins/downloads-manager/img/icons/default.gif" /></span >
<span style="display:block;float:left;margin-left:5px;margin-top:5px">
   <b>download:</b> <a href="http://blog.rarecore.eu/?file_id=2">Autocompleter v2</a> <small>(119.55KB)</small><br />
  <b>added:</b> 08/11/2009 <br />
  <b>clicks:</b> 2553 
</span >
</span >
<br style="clear:left" /></div>
<p>That&#8217;s all!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/autocompleter-using-xajax.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Blog Ping Server List *Update*</title>
		<link>http://blog.rarecore.eu/blog-ping-server-list.html</link>
		<comments>http://blog.rarecore.eu/blog-ping-server-list.html#comments</comments>
		<pubDate>Wed, 28 Jan 2009 09:12:23 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[blog ping server]]></category>
		<category><![CDATA[blog ping server list]]></category>
		<category><![CDATA[ping blogs]]></category>
		<category><![CDATA[ping server]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=221</guid>
		<description><![CDATA[I&#8217;ve found a blog ping server list. Now, we are pinging: *Update* Thx to Ak.Tronic (see comments) http://blogsearch.google.com/ping/RPC2 http://1470.net/api/ping http://api.feedster.com/ping http://api.feedster.com/ping.php http://api.moreover.com/ping http://api.moreover.com/RPC2 http://api.my.yahoo.com/RPC2 http://api.my.yahoo.com/rss/ping http://bblog.com/ping.php http://bitacoras.net/ping http://blogdb.jp/xmlrpc http://blog.goo.ne.jp/XMLRPC http://blogmatcher.com/u.php http://bulkfeeds.net/rpc http://coreblog.org/ping/ http://mod-pubsub.org/kn_apps/blogchatt https://phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast http://ping.amagle.com/ http://ping.bitacoras.com http://ping.bloggers.jp/rpc/ http://ping.blogmura.jp/rpc/ http://ping.blo.gs/ http://ping.cocolog-nifty.com/xmlrpc http://pinger.blogflux.com/rpc/ http://ping.exblog.jp/xmlrpc http://ping.feedburner.com http://ping.myblog.jp http://pingoat.com/goat/RPC2 http://pingqueue.com/rpc/ http://ping.blogg.de/ http://ping.rootblog.com/rpc.php http://ping.syndic8.com/xmlrpc.php http://ping.weblogalot.com/rpc.php http://ping.weblogs.se/ http://rcs.datashed.net/RPC2/ http://rpc.blogbuzzmachine.com/RPC2 http://rpc.blogrolling.com/pinger/ http://rpc.britblog.com/ [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found a <a href="http://blog.taragana.com/index.php/archive/blog-ping-server-list/">blog ping server list</a>.<br />
Now, we are pinging:</p>
<p><strong>*Update*</strong><br />
Thx to <a href="http://www.hd-area.org" target="_blank">Ak.Tronic</a> (see comments)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//blogsearch.google.com/ping/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//1470.net/api/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//api.feedster.com/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//api.feedster.com/ping.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//api.moreover.com/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//api.moreover.com/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//api.my.yahoo.com/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//api.my.yahoo.com/rss/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//bblog.com/ping.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//bitacoras.net/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//blogdb.jp/xmlrpc</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//blog.goo.ne.jp/XMLRPC</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//blogmatcher.com/u.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//bulkfeeds.net/rpc</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//coreblog.org/ping/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//mod-pubsub.org/kn_apps/blogchatt</span>
https<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//phobos.apple.com/WebObjects/MZFinance.woa/wa/pingPodcast</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.amagle.com/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.bitacoras.com</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.bloggers.jp/rpc/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.blogmura.jp/rpc/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.blo.gs/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.cocolog-nifty.com/xmlrpc</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//pinger.blogflux.com/rpc/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.exblog.jp/xmlrpc</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.feedburner.com</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.myblog.jp</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//pingoat.com/goat/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//pingqueue.com/rpc/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.blogg.de/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.rootblog.com/rpc.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.syndic8.com/xmlrpc.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.weblogalot.com/rpc.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.weblogs.se/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rcs.datashed.net/RPC2/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.blogbuzzmachine.com/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.blogrolling.com/pinger/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.britblog.com/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.icerocket.com:10080/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.newsgator.com/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.pingomatic.com/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.tailrank.com/feedburner/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.technorati.com/rpc/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.weblogs.com/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//rpc.wpkeys.com/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//services.newsgator.com/ngws/xmlrpcping.aspx</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//signup.alerts.msn.com/alerts-PREP/submitPingExtended.doz</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//topicexchange.com/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//trackback.bakeinu.jp/bakeping.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.a2b.cc/setloc/bp.a2b</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.bitacoles.net/ping.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogdigger.com/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogoole.com/ping/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogoon.net/ping/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogpeople.net/servlet/weblogUpdates</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogroots.com/tb_populi.blog?id=1</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogshares.com/rpc.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogsnow.com/ping</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.blogstreet.com/xrbin/xmlrpc.cgi</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.lasermemory.com/lsrpc/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.imblogs.net/ping/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.mod-pubsub.org/kn_apps/blogchatter/ping.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.newsisfree.com/RPCCloud</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.newsisfree.com/xmlrpctest.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.popdex.com/addsite.php</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.rssfwd.com/xmlrpc/api</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.snipsnap.org/RPC2</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.weblogues.com/RPC/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//xmlrpc.blogg.de</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//xping.pubsub.com/ping/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//www.wasalive.com/ping/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//blogping.unidatum.com/RPC2/</span>
http<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//ping.wordblog.de/</span></pre></div></div>

<p>Does anybody know other ping server?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/blog-ping-server-list.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The unsupported TinyMCE BB Code Bug&#8230;</title>
		<link>http://blog.rarecore.eu/the_unsupported_tinymce_bbcode_bug.html</link>
		<comments>http://blog.rarecore.eu/the_unsupported_tinymce_bbcode_bug.html#comments</comments>
		<pubDate>Fri, 05 Dec 2008 14:07:46 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[TinyMCE]]></category>
		<category><![CDATA[we are one]]></category>
		<category><![CDATA[tinymce bbcode]]></category>
		<category><![CDATA[tinymce bbcode bug]]></category>
		<category><![CDATA[tinymce bug]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=144</guid>
		<description><![CDATA[TinyMCE is a nice WYSIWYG Editor for a Webapplication. In my application I’m very interested in allowing the users to use BB Code to optimize the visualisation of the texts (guestbooks, news comments, …). Before I released the TinyMCE Editor on my Webradio website, I did some tests. 1. At first, I entered the following text [...]]]></description>
			<content:encoded><![CDATA[<p>TinyMCE is a nice WYSIWYG Editor for a Webapplication. In my application I’m very interested in allowing the users to use BB Code to optimize the visualisation of the texts (guestbooks, news comments, …). Before I released the TinyMCE Editor on my <a href="http://www.technobase.fm" target="_blank">Webradio </a>website, I did some tests.</p>
<p><strong>1. At first, I entered the following text into my textarea:</strong><br />
<img class="alignnone" title="Step 1" src="http://blog.rarecore.eu/wp-content/uploads/2008/12/step1.png" alt="" width="351" height="194" /></p>
<p><strong>2. After submit the form, I get this text displayed:</strong><br />
<img class="alignnone" title="Step 2" src="http://blog.rarecore.eu/wp-content/uploads/2008/12/step2.png" alt="" width="350" height="296" /></p>
<p>Now you can see that the text which is between the &lt;strong&gt; tag is now displayed as bold. But, it shouldn’t be! If I choose the BB code plugin I think the html tag should be disabled…</p>
<p><strong>3. After submit the form again, I get this text displayed:</strong><br />
<img class="alignnone" title="Step 3" src="http://blog.rarecore.eu/wp-content/uploads/2008/12/step3.png" alt="" width="351" height="294" /><br />
Well, now my HTML Tag is rendered as a bb code tag. That’s wrong. I want to display the html tag and not a formatted bb code text.</p>
<p>I searched for support, but nobody on the TinyMCE board helps me…<br />
After some tests, I think, I fixed the bug.</p>
<p>Please change the _tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin.js file and add the following lines to line 47 (before replacing the old tags).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">rep<span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&amp;amp;lt;/gi</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&amp;amp;amp;lt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
rep<span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&amp;amp;gt;/gi</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&amp;amp;amp;gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a title="TinyMCE BBCode Bugfix" href="http://blog.rarecore.eu/wp-content/uploads/2008/12/tinymce_bbcode_bugfix.zip">Download bugfix</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/the_unsupported_tinymce_bbcode_bug.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NFS, the slow performance Network File System</title>
		<link>http://blog.rarecore.eu/nfs-the-slow-performance-network-file-system.html</link>
		<comments>http://blog.rarecore.eu/nfs-the-slow-performance-network-file-system.html#comments</comments>
		<pubDate>Mon, 29 Sep 2008 17:48:09 +0000</pubDate>
		<dc:creator>Exi</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[NFS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rarecore]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Smarty]]></category>
		<category><![CDATA[cache_handler_func]]></category>
		<category><![CDATA[hardbase]]></category>
		<category><![CDATA[housetime]]></category>
		<category><![CDATA[network file system]]></category>
		<category><![CDATA[session_set_save_handler]]></category>
		<category><![CDATA[technobase]]></category>
		<category><![CDATA[trancebase]]></category>
		<category><![CDATA[weareone]]></category>

		<guid isPermaLink="false">http://blog.rarecore.eu/?p=22</guid>
		<description><![CDATA[As described, we are using 2 web servers and 1 application server. What’s the background? It’s easy to explain. Every good designed and developed website needs a template engine for visualization. Our template engine is smarty. Smarty has the caching feature and I like it to minimize the database connections and optimize the performance. I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.rarecore.eu/wp-content/uploads/2008/09/smarty.png"></a><a title="Serverfarm" href="http://blog.rarecore.eu/wp-content/uploads/2008/09/tb-11.png" target="_blank"><img class="alignleft" style="border: 0px;" title="Serverfarm" src="http://blog.rarecore.eu/wp-content/uploads/2008/09/tb-11.png" alt="" width="300" height="172" /></a> As <a href="http://blog.rarecore.eu/technobasefm-and-the-technical-story.html" target="_blank">described</a>, we are using 2 web servers and 1 application server. What’s the background? It’s easy to explain. Every good designed and developed website needs a template engine for visualization. Our template engine is <a href="http://www.smarty.net" target="_blank">smarty</a>. Smarty has the caching feature and I like it to minimize the database connections and optimize the performance. I cache some pages (profile, news) until the next update (e.g. new comment) was done.</p>
<p><span style="color: #000000;">The problem is if the PHP script has deleted the cache file on the first web server (tbweb01), the cache file on the second web server (tbweb02) isn’t deleted. To avoid any delay times, we stored our source code on the application server and we are using NFS to share the files. Normally it works fine, but on some peak times the NFS is too slow. </span></p>
<p><span style="color: #000000;">Information like &#8220;logged in user&#8221; and so on are saved on the session. Usually the user opens the website and the browser always uses the same ip address. It does not matter which server it is. If the user uses a proxy, the proxy chooses one of the round robin ip addresses by each click. So on one server the user has a correct session with the information, on the other server he hasn&#8217;t. If we store the sessions on the NFS we make sure that every server uses the same session. But the performance&#8230;</span></p>
<p><span style="color: #000000;"><strong>Now we have to search for a good solution!<br />
</strong></span><span style="color: #000000;">I found two interesting articles. One about a <a href="http://www.mt-soft.com.ar/2007/12/21/using-a-mysql-database-to-store-session-data/" target="_blank">session_set_save_handler</a> and the other about a <a href="http://www.phpinsider.com/smarty-forum/viewtopic.php?t=4835&amp;highlight=memcached" target="_blank">cache_handler_func</a>. And a new idea was born. Use NFS only to read the files and store the information in the database.</span></p>
<p><span style="color: #000000;"><strong>session_set_save_handler:</strong><br />
This default PHP function allows you to use your own way for the session handling. I think it’s really better to store everything in a mysql table and avoid the NFS storage. On the article they didn’t open and close a database connection. That’s bad… Normally your page is already using a connection, but sometimes you don’t have to open one.</span></p>
<p><span style="color: #000000;">It’s a little bit tricky, but not a problem for experienced developer. I wrote a class to handle my database connection(s). It was very important to use one class for more connections, but it was much more important that the class doesn’t connect with the same user and the same selected database twice times and make sure that the class closes every connection correct. I called my class &#8220;classDataBase&#8221; and overloaded the most used mysql functions. To make sure that the handling works, we’ve to use a static array for the connection and remember the used index in an attribute. Also we remember the count of objects for each connection. On calling the close function, we don’t want to close always the database connection. If more than one object uses this connection, we only decrease the count variable. To be sure that the PHP script closes all opened connections correctly, the class registers automatically on the initializing of the first object a static DBCloseAll() function for shutdown. </span></p>
<p><strong>classDataBase.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/******************************************
 * class created by Exi (http://www.technobase.fm/member/1)
 * please find some information about on
 * http://blog.rarecore.eu/nfs-the-unperformed-file-system.html
 ******************************************/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> classDataBase <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000088;">$connections</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$connection</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$Idx</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$DBName</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// error handling</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$errNum</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// error number</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$errTxt</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// error message</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// constructor - set default values</span>
    <span style="color: #000000; font-weight: bold;">function</span> classDataBase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span>classDataBase<span style="color: #339933;">::</span><span style="color: #000088;">$connections</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            classDataBase<span style="color: #339933;">::</span><span style="color: #000088;">$connections</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">register_shutdown_function</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'classDataBase'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'DBCloseAll'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errNum <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errTxt <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connectionID <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> Init<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cDBName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBHost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBPass</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>DBClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$iconnection</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        classDataBase<span style="color: #339933;">::</span><span style="color: #000088;">$connections</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
                        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Idx <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$found</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$found</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>DBConnecting<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cDBName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBHost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBPass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$retVal</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//Lost connection to MySQL server at 'reading authorization packet', system error: 0</span>
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errNum <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">2013</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$mail</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error on connect to the Databasen&quot;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$mail</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Error Text: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errTxt<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #339933;">;</span>
                    <span style="color: #000088;">$mail</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Error Number: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errNum<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #339933;">;</span>
&nbsp;
                    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>ErrorMail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;strong&gt;Error on connect to the Database&lt;/strong&gt;&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>    
&nbsp;
            <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dbname'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cDBName</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dbhost'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cDBHost</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dbuser'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cDBUser</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'connection'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #339933;">;</span>
            <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">array_push</span><span style="color: #009900;">&#40;</span>classDataBase<span style="color: #339933;">::</span><span style="color: #000088;">$connections</span><span style="color: #339933;">,</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>DBName <span style="color: #339933;">=</span> <span style="color: #000088;">$cDBName</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$retVal</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> DBConnecting<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cDBName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBHost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBPass</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// connect to database</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cDBHost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cDBPass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// throw error if connection failed ...</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errNum <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_errno</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errTxt <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!@</span><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cDBName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errNum <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_errno</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errTxt <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$retVal</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//function to execute statements</span>
    <span style="color: #000000; font-weight: bold;">function</span> execSQL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$XSQL</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$XSQL</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">// Check for error</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$XSQL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errNum <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_errno</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>errTxt <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
&nbsp;
                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>LogDBError<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$XSQL</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>execSQL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> queryCatch<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>execSQL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> insertId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> affectedRows<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">mysql_affected_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//function to fetch the query</span>
    <span style="color: #000000; font-weight: bold;">function</span> fetchArray<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$XSQL</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$XSQL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$XSQL</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> numRows<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$XSQL</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_num_rows</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQLQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$XSQL</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$XSQL</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//function to send a mail on error to the programer</span>
    <span style="color: #000000; font-weight: bold;">function</span> ErrorMail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$Content</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// send an email to the programmer?</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;strong&gt;change the ErrorMail function!!!&lt;/strong&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$Content</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> LogDBError<span style="color: #009900;">&#40;</span><span style="color: #000088;">$Statement</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*
        // log the database errors?!?
        $qry = 'INSERT INTO dberror
                        SET dberr_number = ''.$this-&amp;gt;errNum.'',
                            dberr_text = ''.mysql_escape_string($this-&amp;gt;errTxt).'',
                            dberr_statement = ''.mysql_escape_string($Statement).'',
                            dberr_site = ''.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'',
                            dberr_ip = ''.$_SERVER['REMOTE_ADDR'].'',
                            dberr_time = ''.time().'',
                            dberr_sent = 0';
&nbsp;
        @mysql_db_query($this-&amp;gt;DBName, $qry, $this-&amp;gt;connection);*/</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #990000;">nl2br</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'
              dberr_number = '</span><span style="color: #0000ff;">'.$this-&amp;gt;errNum.'</span><span style="color: #0000ff;">',
              dberr_text = '</span><span style="color: #0000ff;">'.$this-&amp;gt;errTxt.'</span><span style="color: #0000ff;">''</span>
             <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;strong&gt;change the LogDBError function!!!'</span><span style="color: #339933;">&lt;/</span>strong<span style="color: #339933;">&gt;.</span><span style="color: #000088;">$Statement</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> ListTables<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_list_tables</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>DBName<span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$table_names</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>numRows<span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$table_names</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_tablename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #339933;">,</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$table_names</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> DBClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>classDataBase<span style="color: #339933;">::</span><span style="color: #000088;">$connections</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Idx<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #339933;">@</span><span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>          
&nbsp;
            classDataBase<span style="color: #339933;">::</span><span style="color: #000088;">$connections</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Idx<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">--;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>connection <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> DBCloseAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql_session_handler'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #990000;">session_write_close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span>
&nbsp;
After creating our database <span style="color: #000000; font-weight: bold;">class</span> we want to write our own session handling<span style="color: #339933;">.</span> At first we<span style="color: #0000ff;">'ve to create a simple MySQL Table. I called my table cache_session. I want to prefix my example tables with cache_.</span></pre></div></div>

<pre><span style="color: #ff6600;"><span style="color: #993300;">CREATE TABLE `cache_sessions` (
  `session_id` varchar(100) NOT NULL default '',
  `session_data` text NOT NULL,
  `session_expires` int(11) NOT NULL default '0',
  PRIMARY KEY  (`session_id`)
) TYPE=innodb;
</span></span></pre>
<p>What is my session handler class doing? It&#8217;s a static class to overwrite the session handling. On construct I get the maxfiletime from the php configuration, I register my methods to read, write and destroy the session and create a database connection.</p>
<p>On read / write the session, the class use MySQL to store the information.</p>
<p><strong>mysql_session_handler.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/******************************************
 * class created by Exi (http://www.technobase.fm/member/1)
 * please find some information about on
 * http://blog.rarecore.eu/nfs-the-unperformed-network-file-system
 ******************************************/</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'classDataBase.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql_session_handler'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">class</span> mysql_session_handler <span style="color: #009900;">&#123;</span>
        static <span style="color: #000088;">$life_time</span><span style="color: #339933;">;</span>
        static <span style="color: #000088;">$mysql</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// construct</span>
        <span style="color: #000000; font-weight: bold;">function</span> mysql_session_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// read the maxlifetime setting from PHP</span>
            mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$life_time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">get_cfg_var</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session.gc_maxlifetime'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
&nbsp;
            <span style="color: #666666; font-style: italic;">// register this object as the session handler</span>
            <span style="color: #990000;">session_set_save_handler</span><span style="color: #009900;">&#40;</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'open'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'close'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'read'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'write'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'destroy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'gc'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// create a new database connection or use the already opened</span>
                mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> classDataBase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Init<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ip'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// open session -&amp;gt; just to have. no action</span>
        <span style="color: #000000; font-weight: bold;">function</span> open<span style="color: #009900;">&#40;</span><span style="color: #000088;">$save_path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$session_name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$sess_save_path</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$sess_save_path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$save_path</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// read session data</span>
        <span style="color: #000000; font-weight: bold;">function</span> read<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000088;">$qry</span> <span style="color: #339933;">=</span> mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select session_data
                                                           from cache_sessions
                                                          where session_id = '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">mysql_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'
                                                            and session_expires &amp;gt;= &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fetch</span> <span style="color: #339933;">=</span> mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>fetchArray<span style="color: #009900;">&#40;</span><span style="color: #000088;">$qry</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$fetch</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// insert / update session information</span>
        <span style="color: #000000; font-weight: bold;">function</span> write<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;replace into cache_sessions
                                                              (session_id,
                                                               session_data,
                                                               session_expires)
                                                       values ('&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">mysql_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;',
                                                               '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">mysql_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;',
                                                                &quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$life_time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// destroy a session</span>
        <span style="color: #000000; font-weight: bold;">function</span> destroy<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            mysql_session_handler<span style="color: #339933;">::</span><span style="color: #000088;">$mysql</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;delete from cache_sessions where session_id = '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">mysql_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// clean old session</span>
        <span style="color: #000000; font-weight: bold;">function</span> gc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// do not clean by an page call, use a cronjob to delete all expired entries every minute!</span>
            <span style="color: #666666; font-style: italic;">/*mysql_session_handler::$mysql-&amp;gt;query('delete from cache_sessions where session_expires &amp;lt; '.time());*/</span>
&nbsp;
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// close session</span>
        <span style="color: #000000; font-weight: bold;">function</span> close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000088;">$SessionHandler</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysql_session_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, I want to do some tests&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'mysql_session_handler.php'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'session &quot;a&quot; not set!'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">session_destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'session destroyed'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'session &quot;a&quot; set!'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><img class="alignnone size-full wp-image-103" title="cache_session1" src="http://blog.rarecore.eu/wp-content/uploads/2008/09/cache_session1.png" alt="" width="505" height="73" /><br />
<strong>looks good &#8211; works!</strong></p>
<p>The next step is to store the smarty cache in the database. I always write my own classes to overwrite existing open source projects. So I could implement features / settings and software updates doesn&#8217;t touch me&#8230; I created a classSmarty and opened a database connection using the classDataBase class.</p>
<p><strong>classSmarty.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/******************************************
 * class created by Exi (http://www.technobase.fm/member/1)
 * please find some information about on
 * http://blog.rarecore.eu/nfs-the-unperformed-file-system.html
 ******************************************/</span>
&nbsp;
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'Smarty.class.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'classDataBase.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'mysql_cache_handler.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> classSmarty <span style="color: #000000; font-weight: bold;">extends</span> Smarty <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$mysql</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> classSmarty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">Smarty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>template_dir  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_smarty/templates'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>compile_dir   <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_smarty/templates_c'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>cache_dir     <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_smarty/cache'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>config_dir    <span style="color: #339933;">=</span> <span style="color: #0000ff;">'_smarty/config'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>compile_check <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>debugging     <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>caching       <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> classDataBase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Init<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'host'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>cache_handler_func <span style="color: #339933;">=</span> <span style="color: #0000ff;">'mysql_cache_handler'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As descripted in the smarty forum I created a function to handle the caching by mysql.</p>
<pre><span style="color: #993300;">CREATE TABLE `cache_smarty` (
  `smarty_cacheId` varchar(32) NOT NULL,
  `smarty_template` varchar(255) NOT NULL,
  `smarty_group` varchar(255) NOT NULL,
  `smarty_content` mediumtext NOT NULL,
  `smarty_expire` int(11) NOT NULL,
  PRIMARY KEY  (`smarty_cacheId`),
  KEY `smarty_template` (`smarty_template`),
  KEY `smarty_expire` (`smarty_expire`)
) ENGINE=InnoDB ;</span></pre>
<p><strong>mysql_cache_handler.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/******************************************
 * class created by Exi (http://www.technobase.fm/member/1)
 * please find some information about on
 * http://blog.rarecore.eu/nfs-the-unperformed-file-system.html
 ******************************************/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mysql_cache_handler<span style="color: #009900;">&#40;</span><span style="color: #000088;">$action</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span><span style="color: #000088;">$cache_content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tpl_file</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cache_group</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$compile_id</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exp_time</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$db_table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'cache_smarty'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// create unique cache id</span>
    <span style="color: #000088;">$cache_id</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl_file</span><span style="color: #339933;">.</span><span style="color: #000088;">$cache_group</span><span style="color: #339933;">.</span><span style="color: #000088;">$compile_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
    <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$action</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'read'</span><span style="color: #339933;">:</span>
            <span style="color: #666666; font-style: italic;">// read cache from database</span>
            <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;select smarty_content from <span style="color: #006699; font-weight: bold;">$db_table</span> where smarty_cacheId = '<span style="color: #006699; font-weight: bold;">$cache_id</span>' and smarty_expire &amp;gt; &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>_trigger_error_msg<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache_handler: query failed.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> 
&nbsp;
            <span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>fetchArray<span style="color: #009900;">&#40;</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$cache_content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
&nbsp;
            <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> 
&nbsp;
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'write'</span><span style="color: #339933;">:</span>
            <span style="color: #666666; font-style: italic;">// save cache to database</span>
            <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;replace into <span style="color: #006699; font-weight: bold;">$db_table</span> (
                                                           smarty_cacheId,
                                                           smarty_template,
                                                           smarty_group,
                                                           smarty_content,
                                                           smarty_expire
                                                         ) values (
                                                           '<span style="color: #006699; font-weight: bold;">$cache_id</span>',
                                                           '<span style="color: #006699; font-weight: bold;">$tpl_file</span>',
                                                           '<span style="color: #006699; font-weight: bold;">$cache_group</span>',
                                                           '&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">addslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;',
                                                           '&quot;</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$exp_time</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> ? <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">3600</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$exp_time</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' )&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// no expire =&amp;gt; expire next hour</span>
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>_trigger_error_msg<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache_handler: query failed.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> 
&nbsp;
            <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> 
&nbsp;
        <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'clear'</span><span style="color: #339933;">:</span>
            <span style="color: #666666; font-style: italic;">// clear cache info</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache_group</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$compile_id</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;delete from <span style="color: #006699; font-weight: bold;">$db_table</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">/*
                if(!$smarty_obj-&amp;gt;mysql-&amp;gt;query(&quot;delete from $db_table where smarty_expire &amp;lt; &quot;.time())) {
                    $smarty_obj-&amp;gt;_trigger_error_msg('cache_handler: clear expired entries query failed.');
                }
                */</span>
&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;">$cache_group</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'|'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tpl_file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                      <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;delete from <span style="color: #006699; font-weight: bold;">$db_table</span> where smarty_template = '<span style="color: #006699; font-weight: bold;">$tpl_file</span>' AND smarty_group LIKE '<span style="color: #006699; font-weight: bold;">$cache_group</span>%'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                      <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;delete from <span style="color: #006699; font-weight: bold;">$db_table</span> where smarty_group LIKE '<span style="color: #006699; font-weight: bold;">$cache_group</span>%'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                   <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                   <span style="color: #000088;">$results</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>mysql<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;delete from <span style="color: #006699; font-weight: bold;">$db_table</span> where smarty_cacheId = '<span style="color: #006699; font-weight: bold;">$cache_id</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> 
&nbsp;
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$results</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>_trigger_error_msg<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache_handler: query failed.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> 
&nbsp;
            <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$results</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> 
&nbsp;
        <span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
            <span style="color: #666666; font-style: italic;">// error, unknown action</span>
            <span style="color: #000088;">$smarty_obj</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>_trigger_error_msg<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;cache_handler: unknown action &quot;</span><span style="color: #000088;">$action</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, I want to do some tests again&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'classSmarty.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$smarty</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> classSmarty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>caching <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>cache_lifetime <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$template</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'smarty.html'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cache_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'smarty|1337'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>is_cached<span style="color: #009900;">&#40;</span><span style="color: #000088;">$template</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cache_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>assign<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'time'</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'H:i:s'</span><span style="color: #339933;">,</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>assign<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9999</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>assign<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'b'</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9999</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>assign<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'c'</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9999</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$smarty</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>display<span style="color: #009900;">&#40;</span><span style="color: #000088;">$template</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cache_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://blog.rarecore.eu/wp-content/uploads/2008/10/smarty.png"><img class="alignnone size-full wp-image-138" title="smarty" src="http://blog.rarecore.eu/wp-content/uploads/2008/10/smarty.png" alt="" width="601" height="43" /></a><a href="http://blog.rarecore.eu/wp-content/uploads/2008/09/smarty1.png"></a></p>
<p><strong>and works again!</strong></p>
<p>And last but not least we want to delete all expired entries. Create a cronjob which is running every minute to do this.</p>
<p>I hope the blog helps you!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rarecore.eu/nfs-the-slow-performance-network-file-system.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

