background preloader

Php

Facebook Twitter

Mysql

Benchmark. Xdebug - Debugger and Profiler Tool for PHP. Apache PHP MySQL and Runaway Scripts | MySQL Performance Blog. May 20, 2008 by Peter Zaitsev20 Comments Sometimes due to programming error or due to very complex query you can get your PHP script running too long, well after user stopped waiting for the page to render and went browsing other sites. Looking at Server-Status I’ve seen scripts executing for hours sometimes which is obviously the problem – they take Apache Slot, MySQL Connection and other resources. I had discussion today who was thinking Apache would kill the script after “Timeout” specified in Apache configuration is reached – this was not my experience so I decided to run couple of tests to check it.

I wrote couple of very simple scripts which demonstrate different behavior for scripts running very long time. For simplicity I did not use MySQL, but other system call – sleep() which has similar behavior for sake of experiment: Script which simply runs in tight loop “forever” Script which is same as previous one but which also outputs some data in the loop: Results were a bit surprising: The html blog | 10 code snippets for PHP developers. I’ve compiled a small list of some useful code snippets which might help you when writing your PHP scripts… Email address check Checks for a valid email address using the php-email-address-validation class. Source and docs: 01.include('EmailAddressValidator.php'); 03. 04.if ($validator->check_email_address('test@example.org')) { 07.else { Random password generator PHP password generator is a complete, working random password generation function for PHP. 01.function generatePassword($length=9, $strength=0) { 02. 03. 04. if ($strength & 1) { 05. 07. if ($strength & 2) { 08. 10. if ($strength & 4) { 11. 13. if ($strength & 8) { 14. 17. 18. 19. for ($i = 0; $i < $length; $i++) { 20. if ($alt == 1) { 21. 22. 23. } else { 24. 25. 28. return $password; Get IP address Returns the real IP address of a visitor, even when connecting via a proxy. 01.function getRealIpAddr(){ 02. if (!

04. 06. elseif (! 08. 10. else{ 11. 13. return $ip; XSL transformation 01. 04. 05. 08. A Guide to Cryptography in PHP. N an ideal world, words like cryptography and security wouldn't even exist, but the real world is far from perfect, so software developers have to spend a good deal of time building security into applications. Cryptography is just one piece of the security puzzle, along with SSL/TLS, certificates, digital signatures, and so on. This article explains how to use PHP to implement the most common cryptographic algorithms. In addition to describing PHP's default encryption functions, you'll see how to use a wide variety of cryptographic libraries and packages. The code examples in this article use the contents of a short text file, textfile.txt, which contains the following plain-text content: For every difficult and complicated question there is an answer that is simple, easily understood, and wrong.

Default PHP Encryption Functions PHP ships with three built-in encryption functions: md5(), crypt(), and sha1(). String md5(string $str [, bool $raw_output ]) Table 1. Useful articles and tutorials. (Simple version)Matrix like animated dropping character effect i. Like most animated effects I will ever make, it needs GIFEncoder class . The basic idea: On a screen, when one pixel is activated, it lights up. Here, instead of a pixel, it is a character, so I just have to construct a character grid and light them when it is activated. include ( 'GIFEncoder.class.php' ) ; ob_start ( ) ; $msg = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!

@#$%^&*()-_=+`[]{};:? /., \\|"' ; $length = strlen ( $msg ) ; $max_x = 400 ; //image x size $max_y = 400 ; //image y size $font_file = 'cour.ttf' ; //font, best monospace $font_size = 10 ; //font site $grid = 10 ; //gridient of the fonts $measuer = imagettfbbox ( 10 , 0 , $font_file , '1' ) ; $space = 5 ; //space between letters $char_height = $measuer [ 1 ] - $measuer [ 7 ] + $space ; $char_width = $measuer [ 2 ] - $measuer [ 0 ] + $space ; $i = 1 ; $colorimage = imagecreatetruecolor ( 1 , 1 ) ; $color [ 1 ] = imagecolorallocate ( $colorimage , 255 , 255 , 255 ) ; while ( $i GetAnimation ( ) ;

The PHP coder&#039;s top 10 mistakes and problems @ SourceRally. Hundreds of PHP scripts, tutorials, and articles; One purple wal. Zack Bloom&#039;s Programs. Introducing PHP - Practical PHP Programming. PHP Manual. PHP Manual. PEAR :: Manual :: PEAR Manual. Output Buffering in PHP - PHP. Jaslabs: High performance php &amp; Top 25 PHP. Ymfony - open-source PHP5 web framework. PHP Manual. Dictionary. GeSHi - Generic Syntax Highlighter :: Home. Latest News GeSHi on GitHub You can find more details on this change in my blog. GeSHi Website available encrypted 2012/11/25 I recently decided to make the GeSHi website available via SSL as a related project requires use of SSL anyway.

Currently I'm not yet forcing SSL, but if you connected successfully via SSL once you'll use it automatically for the next six months due to HSTS. The reason I'm currently not enforcing is that as the used Certification Authority CAcert is not in the trusted store of Mozilla and Internet Explorer (although the second is not relevant to me) you'd probably get alot of confusing warnings. This change is available for qbnz.com and geshi.org. GeSHi 1.0.8.11 Released 2012/08/19 Again quite some time has passed but here it is: the new release of GeSHi with loads of new languages, some minor parser tweaks and fixes to existing language files.

More information on current GeSHi developement can be found in the GeSHi corner of my blog. BenBE. GeSHi 1.0.8.10 Released.