Pure PHP - PHP
https://www.pure-php.de/taxonomy/term/6/0
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.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.deinclude_once Wrapper Class
https://www.pure-php.de/node/19
<p>There hase been some discussion in the recend days about the performance of include_once. Inlude_once is really slower than include. For the inclusion of the classes you can use<br />
class_exists('PEAR') or require_once 'PEAR.php' (<a href="http://www.akbkhome.com/blog.php/View/76/require_once%2C+one+optimization+too+many%3F.html">www.akbkhome.com/blog...</a>); </p>
<p>You can also use this wrapper class for include_once and require_once, it is faster.</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 /> private 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(!</span><span style="color: #0000CC">in_array</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">,</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</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">;<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(!</span><span style="color: #0000CC">in_array</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">,</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</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">;<br /> }<br /> }<br />}<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">"Class1.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">requireOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"Class1.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">"Class2.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">?></span>
</span>
</code></div></p>
https://www.pure-php.de/node/19#commentPHPFri, 18 Mar 2005 00:17:28 +0100pure-php19 at https://www.pure-php.dePHP Command Line rocks
https://www.pure-php.de/node/16
<p>Recently I wrote a PHP Command line app, I was amazed, how easy it was, to write command line app in PHP, and it really rocks.</p>
<p>Here is very simple Command Line handler class, it may be usefull for your apps.<br />
<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">CliHandler</span><span style="color: #006600">{<br /> private </span><span style="color: #0000CC">$in</span><span style="color: #006600">;<br /> private </span><span style="color: #0000CC">$out</span><span style="color: #006600">;<br /> private </span><span style="color: #0000CC">$handler</span><span style="color: #006600">;<br /> public function </span><span style="color: #0000CC">CliHandler</span><span style="color: #006600">(</span><span style="color: #0000CC">$handler</span><span style="color: #006600">){<br /> </span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">in </span><span style="color: #006600">= </span><span style="color: #0000CC">fopen</span><span style="color: #006600">(</span><span style="color: #CC0000">"php://stdin"</span><span style="color: #006600">,</span><span style="color: #CC0000">"r"</span><span style="color: #006600">);<br /> </span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">out </span><span style="color: #006600">= </span><span style="color: #0000CC">fopen</span><span style="color: #006600">(</span><span style="color: #CC0000">"php://stdout"</span><span style="color: #006600">, </span><span style="color: #CC0000">"w"</span><span style="color: #006600">);<br /> if(</span><span style="color: #0000CC">is_object</span><span style="color: #006600">(</span><span style="color: #0000CC">$handler</span><span style="color: #006600">)){<br /> </span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">handler </span><span style="color: #006600">= </span><span style="color: #0000CC">$handler</span><span style="color: #006600">;<br /> }<br /> } <br /> public function </span><span style="color: #0000CC">run</span><span style="color: #006600">(){<br /> </span><span style="color: #0000CC">$str </span><span style="color: #006600">= </span><span style="color: #CC0000">"Try these commands:\n"<br /> </span><span style="color: #006600">.</span><span style="color: #0000CC">implode</span><span style="color: #006600">(</span><span style="color: #CC0000">"\n"</span><span style="color: #006600">,</span><span style="color: #0000CC">get_class_methods</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">handler</span><span style="color: #006600">));<br /> </span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">out</span><span style="color: #006600">(</span><span style="color: #0000CC">$str</span><span style="color: #006600">);<br /> while(</span><span style="color: #0000CC">$line </span><span style="color: #006600">= </span><span style="color: #0000CC">rtrim</span><span style="color: #006600">(</span><span style="color: #0000CC">fgets</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">in</span><span style="color: #006600">, </span><span style="color: #0000CC">1024</span><span style="color: #006600">))){<br /> if(</span><span style="color: #0000CC">method_exists</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">handler</span><span style="color: #006600">,</span><span style="color: #0000CC">$line</span><span style="color: #006600">)){<br /> </span><span style="color: #0000CC">$out </span><span style="color: #006600">= </span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">handler</span><span style="color: #006600">-></span><span style="color: #0000CC">$line</span><span style="color: #006600">();<br /> if(</span><span style="color: #0000CC">$out</span><span style="color: #006600">){<br /> </span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">out</span><span style="color: #006600">(</span><span style="color: #0000CC">$out</span><span style="color: #006600">);<br /> }<br /> }<br /> }<br /> }<br /> public function </span><span style="color: #0000CC">out</span><span style="color: #006600">(</span><span style="color: #0000CC">$str</span><span style="color: #006600">){<br /> </span><span style="color: #0000CC">fwrite</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-></span><span style="color: #0000CC">out</span><span style="color: #006600">,</span><span style="color: #0000CC">$str</span><span style="color: #006600">.</span><span style="color: #CC0000">"\n"</span><span style="color: #006600">);<br /> }<br />}<br />class </span><span style="color: #0000CC">AnyClass</span><span style="color: #006600">{<br /> public function </span><span style="color: #0000CC">start</span><span style="color: #006600">(){<br /> return </span><span style="color: #CC0000">"started"</span><span style="color: #006600">;<br /> }<br /> public function </span><span style="color: #0000CC">stop</span><span style="color: #006600">(){<br /> return </span><span style="color: #CC0000">"stoppded"</span><span style="color: #006600">;<br /> }<br />}<br /></span><span style="color: #0000CC">$cli </span><span style="color: #006600">= new </span><span style="color: #0000CC">CliHandler</span><span style="color: #006600">(new </span><span style="color: #0000CC">AnyClass</span><span style="color: #006600">());<br /></span><span style="color: #0000CC">$cli</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></p>
<p>CliHandler accepts any class als argument.<br />
Try this.</p>
<p>/usr/local/php/PHP5 CliHandler.class.php<br />
output: Try these command:<br />
start<br />
stop<br />
enter "start"<br />
output: started</p>
https://www.pure-php.de/node/16#commentPHPSun, 13 Mar 2005 16:19:29 +0100pure-php16 at https://www.pure-php.dePHP must free itself from Apache Server
https://www.pure-php.de/node/10
<p>There has been a lot of Discussions about Enterprise PHP, specially after the release of PHP 5. PHP has a much better Object Model now, butt PHP is still NOT enterprise ready.</p>
<p>The first step toward enterprise is PHP's emancipation from Apache Web server. Since 4.1.0 Version, PHP supports sockets. Therefore PHP itself can serve HTTP Requests. Although PHP sockets are experimental, but it really rocks. I have written a simple IRC Sever in PHP using PHP sockets and it is up since about 70 days.</p>
<p><a href="https://www.pure-php.de/node/10">read more</a></p>https://www.pure-php.de/node/10#commentPHPWed, 02 Mar 2005 21:24:07 +0100pure-php10 at https://www.pure-php.dePure-PHP goes online
https://www.pure-php.de/node/8
<p>Pure-PHP goes online</p>
https://www.pure-php.de/node/8#commentPHPWed, 02 Mar 2005 20:30:46 +0100pure-php8 at https://www.pure-php.de Datenschutz | Impressum