Pure PHP - PHP unconventional
https://www.pure-php.de
enLightweight, but Powerful PHP5 XML-RPC Server
https://www.pure-php.de/node/31
<p>I have written a XML-Server in PHP5.<br />
It is very easy to use. Just include the file and run the server.<br />
It has some restrictions, it accepts only functions and static methods. you don't have to to change your code if your methods return a php type. (string, array, integer)<br />
Example<br />
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000CC"><?php<br />$ws </span><span style="color: #006600">= new </span><span style="color: #0000CC">XML_RPC_Server</span><span style="color: #006600">();<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-></span><span style="color: #0000CC">registerFunction</span><span style="color: #006600">(</span><span style="color: #CC0000">'getTime'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-></span><span style="color: #0000CC">registerMethod</span><span style="color: #006600">(</span><span style="color: #CC0000">'Product::getPrice'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-></span><span style="color: #0000CC">registerMethod</span><span style="color: #006600">(</span><span style="color: #CC0000">'Product::getDetail'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-></span><span style="color: #0000CC">registerMethod</span><span style="color: #006600">(</span><span style="color: #CC0000">'Product::getBinaryPicture'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-></span><span style="color: #0000CC">run</span><span style="color: #006600">();<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div><br />
Example Source,<br />
http://www.pure-php.com/php/service.source.php<br />
The Server<br />
http://www.pure-php.com/php/xmlrpc.php.txt</p>
<p><a href="https://www.pure-php.de/node/31">read more</a></p>https://www.pure-php.de/node/31#commentPHPThu, 09 Mar 2006 22:59:47 +0100pure-php31 at https://www.pure-php.dePHP Style Cookie and Get Parameters in JavaScript
https://www.pure-php.de/node/30
<p>For lazy phpers, with this function you can read cookies and get parameters in javascript in php style.<br />
(I use php tags to highlight the code)<br />
Example<br />
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000CC"><?php<br />populateRequest</span><span style="color: #006600">();<br />if( </span><span style="color: #0000CC">$_COOKIE</span><span style="color: #006600">[</span><span style="color: #CC0000">'sid'</span><span style="color: #006600">] ) {<br /></span><span style="color: #FF9900">// do something<br /></span><span style="color: #006600">}<br />if( </span><span style="color: #0000CC">$_GET</span><span style="color: #006600">[</span><span style="color: #CC0000">'cmd'</span><span style="color: #006600">] == </span><span style="color: #CC0000">'login' </span><span style="color: #006600">) {<br /></span><span style="color: #FF9900">// do something<br /></span><span style="color: #006600">}<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div></p>
<p><a href="https://www.pure-php.de/node/30">read more</a></p>https://www.pure-php.de/node/30#commentJavaScript / AjaxThu, 23 Feb 2006 09:56:08 +0100pure-php30 at https://www.pure-php.deJava Class Search with Ajax, powered by PHP
https://www.pure-php.de/node/28
<p><a href="http://www.pure-java.com/">Pure-java.com</a> search for java classes with use of ajax. The site is powered by PHP5</p>
https://www.pure-php.de/node/28#commentSun, 12 Feb 2006 22:40:00 +0100pure-php28 at https://www.pure-php.deThe easist way to avoid double clicks in submit buttons
https://www.pure-php.de/node/27
<p>Most of the sites have this problem, for example, when user want to create an account. The fill in the registration from, and submit the form. If the site is too slow at that moment. they would click again, and you have double entries.</p>
<p>With this JavaScript class, you deactivate this. Just put that and end of your site.<br />
<code><br />
function ClickObServer(){<br />
this.deactivateDoubleClicks = function() {<br />
this.checkClicks(document.getElementsByTagName("a"));<br />
this.checkClicks(document.getElementsByTagName("input"));<br />
}<br />
this.checkClicks = function ( el ){<br />
for (var i = 0; i < el.length; i++) {</p>
<p><a href="https://www.pure-php.de/node/27">read more</a></p>https://www.pure-php.de/node/27#commentJavaScript / AjaxFri, 25 Nov 2005 21:30:00 +0100pure-php27 at https://www.pure-php.dePure PHP up again
https://www.pure-php.de/node/26
<p>After several months pure-php is up agian, and I would try to post in the next days</p>
https://www.pure-php.de/node/26#commentTue, 22 Nov 2005 22:51:00 +0100pure-php26 at https://www.pure-php.dePHP-Magazine's security leak closed
https://www.pure-php.de/node/25
<p>PHP-Magazine has closed its security leak. Yesterday I received an email from PHP-Magazine. My posting form the last week is not up to date anymore. The company, which has written the Powerslave CMS has also been informed, and they would fix it. The security leak remains on many sites, with the Powerslave CMS. </p>
<p>The user of Powersalve can ask me for a quick solution. The can also ask the company behind Powerslave.</p>
https://www.pure-php.de/node/25#commentSecurityWed, 06 Apr 2005 09:28:00 +0200pure-php25 at https://www.pure-php.deSecurity matters, specially for PHP-Magazine, some source code publicly accessible!
https://www.pure-php.de/node/24
<p><strong><br />
PHP-Magazine has fixed this secutrity leak, it is not possible to read any source code. This posting ist not up to date anymore </strong> </p>
<p>------------------------------------------------------<br />
It is not an April joke! I read frequently PHP-Magazine (http://php-mag.net http://php-mag.de), Yesterday I discovered some interesting things, because I was able, to read some source code and they are still publicly available. I don’t want to write, how I could read the source code, because there are always some people out side, who want play with it. Very important, they have <strong>register_globals on</strong>. I hope, they fix it as soon as possible.</p>
<p><a href="https://www.pure-php.de/node/24">read more</a></p>https://www.pure-php.de/node/24#commentPHPFri, 01 Apr 2005 09:59:12 +0200pure-php24 at https://www.pure-php.deinclude_once / require_once Wrapper Class optimized
https://www.pure-php.de/node/22
<p>When I posted my Idea of building a wrapper class for include_once and require_once, I didn't think, that the many php developer would like it. But I was wrong, fortunately.</p>
<p>Thanks to <a href="https://www.pure-php.de/node/19#comment-8">Mathias Taylor</a> for benchmarking. Special thanks goes to <a href="https://www.pure-php.de/node/19#comment-15">Cristian Strian</a> for his suggestion to optimize the class, and make it faster. That is the optimized wrapper class. </p>
<p><strong>Usage:</strong><br />
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000CC"><?php<br /></span><span style="color: #006600">require(</span><span style="color: #CC0000">"includeWrapper.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"test.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"test.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"test.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">print_r</span><span style="color: #006600">(</span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">getPaths</span><span style="color: #006600">());<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div></p>
<p><strong>Output:</strong><br />
Array<br />
(<br />
[test.php] => 1<br />
)</p>
<p>The class itself.</p>
<p><div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000CC"><?php<br /></span><span style="color: #006600">class </span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">{<br /> public static </span><span style="color: #0000CC">$paths </span><span style="color: #006600">= array();<br /> public static function </span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">){<br /> if(!isset(</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">])){<br /> include(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">);<br /> </span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">] = </span><span style="color: #0000CC">true</span><span style="color: #006600">;<br /> }<br /> }<br /> public static function </span><span style="color: #0000CC">requireOnce</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">){<br /> if(!isset(</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">])){<br /> require(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">);<br /> </span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">] = </span><span style="color: #0000CC">true</span><span style="color: #006600">;<br /> }<br /> }<br /> </span><span style="color: #FF9900">// just for testing<br /> </span><span style="color: #006600">public static function </span><span style="color: #0000CC">getPaths</span><span style="color: #006600">(){<br /> return </span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">;<br /> }<br />}<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div></p>
https://www.pure-php.de/node/22#commentPHPFri, 25 Mar 2005 23:38:00 +0100pure-php22 at https://www.pure-php.deFatal Error is the Fatal Error of PHP - How to avoid it
https://www.pure-php.de/node/21
<p>One of the disadvantages of PHP, and one of the things I don't like about the php, is the fatal error, because there isn't any way to avoid it. Well PHP is actually thought to be used in web environment, therefor it is not so important, if your script causes a fatal error, then only the execution of the script for a single request would be terminated.</p>
<p>In PHP command line apps, it is really fatal, if your app causes a fatal error, because you have to restart your app. Well you can avoid this, if you write your app very carefully. You should always use <strong>if(function_exists("a_func")) and if(method_exists("a_method"))</strong>. Now you can be pretty sure, that the script won't cause any fatal error.<br />
If you dynamically load third party modules in your app, you have a real problem, because the included module could cause a fatal error, your app would be terminated. There is on way to avoid it. Use <strong>call_user_func</strong>. You can replace in third party modules every function call and method call with call_user_func. For example.<br />
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000CC"><?php<br /></span><span style="color: #006600">function </span><span style="color: #0000CC">add</span><span style="color: #006600">(</span><span style="color: #0000CC">$a</span><span style="color: #006600">,</span><span style="color: #0000CC">$b</span><span style="color: #006600">){<br /> echo </span><span style="color: #0000CC">$a</span><span style="color: #006600">+</span><span style="color: #0000CC">$b</span><span style="color: #006600">;<br />}<br /></span><span style="color: #FF9900">// call the function with a small mistake<br /></span><span style="color: #0000CC">ad</span><span style="color: #006600">(</span><span style="color: #0000CC">2</span><span style="color: #006600">,</span><span style="color: #0000CC">3</span><span style="color: #006600">); </span><span style="color: #FF9900">// causes a fatal error<br />//replace it with<br /></span><span style="color: #0000CC">call_user_func</span><span style="color: #006600">(</span><span style="color: #CC0000">"ad"</span><span style="color: #006600">,</span><span style="color: #0000CC">2</span><span style="color: #006600">,</span><span style="color: #0000CC">3</span><span style="color: #006600">); </span><span style="color: #FF9900">// causes a warning<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div></p>
https://www.pure-php.de/node/21#commentPHPWed, 23 Mar 2005 14:42:00 +0100pure-php21 at https://www.pure-php.dePHP Command Line - Avoid several Instances of your App.
https://www.pure-php.de/node/20
<p>Since PHP 4, you can also write command line apps in php. If you have a critical app, and you want to avoid several, or mor than one instance of your app, to run, you can use the following class. It works only on unix and linux operating sytems.</p>
<p>Usage:<br />
<div class="codeblock"><code><span style="color: #000000">
<span style="color: #0000CC"><?php<br />inlude</span><span style="color: #006600">(</span><span style="color: #CC0000">"ProcessHandler.class.php"</span><span style="color: #006600">);<br />if(</span><span style="color: #0000CC">ProcessHandler</span><span style="color: #006600">::</span><span style="color: #0000CC">isActive</span><span style="color: #006600">()){<br /> die(</span><span style="color: #CC0000">"Already running!\n"</span><span style="color: #006600">);<br />}else{<br /> </span><span style="color: #0000CC">ProcessHandler</span><span style="color: #006600">::</span><span style="color: #0000CC">activate</span><span style="color: #006600">();<br /> </span><span style="color: #FF9900">//run my app<br /></span><span style="color: #006600">}<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div></p>
<p><a href="https://www.pure-php.de/node/20">read more</a></p>https://www.pure-php.de/node/20#commentPHPTue, 22 Mar 2005 00:39:01 +0100pure-php20 at https://www.pure-php.de