Tips for speeding up your PHP scripts

Jaslabs shares six key points on improving the speed of your dynamic PHP scripts including: object code caching, template system, distributed object caching system, turning off some global PHP variable settings, output compression and database query optimization.

Open source phpMyEdit

phpMyEdit:

generates PHP code for displaying/editing MySQL tables in HTML. All you need to do is to write a simple calling program (a utility to do this is included). It includes a huge set of table manipulation functions (record addition, change, view, copy, and removal), table sorting, filtering, table lookups, and more.

Download (gz).

Microsoft to work with Zend on Windows PHP runtime

Good news for PHP developers on the Windows front.

Technewsworld:

The collaboration should improve the experience of PHP-with-Windows users, according to Zend co-founder and CTO Andi Gutmans, who indicated that a majority of PHP developers work on Windows, though until now the solution has been tuned mainly for Linux.

Microsoft has embraced more open source solutions — including Xen virtualization technology, SugarCRM and now PHP — and seems to be seeking a peaceful co-existence of its proprietary platforms with open source software.

In the process, both users and developers are getting more choices, said Gardner.

Trying out Websnapr [blog news]

Blog news that is unrelated to PHP:

When you hover over some of the third party links starting with the last couple posts, I’m trying out Websnapr to deliver thumbnail previews. You can also hover over Websnapr link. I’m noticing several “thumbnail in queue” messages at the moment and remain curious how long this will take to deliver the thumbnails.

Update 2:38pm PST: Looks like updated thumb will appear within a couple hours.
10/23/06 8:43am PST: Wordpress Websnapr plugin

Update 2/8/07 8:26pm PST: The Websnapr service has been disabled on this blog.

How to change your PHP installation to accept larger than 2MB file transfers

where in php.ini to find upload_max_filesize

You can check your file upload limit by checking phpinfo() and the variable: upload_max_filesize.. A tutorial via Radlinks walks through the other settings relevant to handling larger than 2MB (default) file size transfers using PHP.

Zend/PHP conference

Where?
Doubletree Hotel San Jose, CA Oct 30 - November 2, 2006

Price:
$1,100 ($550 for early bird registration)Z

Random web page background colors

If you want to create a random background color

<?php $hex = dechex(rand(0,255)) . dechex(rand(0,255)) . dechex(rand(0,255)); ?>

and then you’d use the following in your body tag:

<body BGCOLOR=“#<?php echo($hex);?>”>

Related
How to change background color only on holidays

Free command line PHP to EXE converter for Windows

Bambalam PHP EXE Compiler/Embedder:

a free command line tool to convert PHP applications to standalone Windows .exe applications. The exe files produced are totally standalone, no need for php dlls etc. The php code is encoded using the Turck MMCache Encode library so it’s a perfect solution if you want to distribute your application while protecting your source code. The converter is also suitable for producing .exe files for windowed PHP applications (created using for example the WinBinder library, or with PHP-GTK

Usage:
bamcompile [-options] infile.php [outfile.exe]
bamcompile [-options] project_directory mainfile.php [outfile.exe]

Options:
-w Hide console window for windowed applications
-c Compress output exe (using UPX - must be available)
-d Do not encode PHP files

Colorized PHP ASCII art

Generate PHP ASCII art in color online.

How to fix reBlog 2.0b2 URL sanitizing bug

Behavior: Links in Reblog cannot be ‘archived’ or ‘published’
Problem: Reblog wasn’t sanitizing the ‘link’ field in the MySQL table properly, allowing injection of unescaped single quotes (’) from RSS feeds into the database. The query would fail and thus would never process properly.
File: Controller.class.php in /refeed/library/RF
Version: $Revision: 1.40 (reBlog version 2.0b2)
Status: Bug reported with code fix implemented below. I didn’t see a solution posted in the official Reblog help forum. I have posted about the issue there and linked here.

Example database call (http part is stripped so WP doesn’t make a link, error emphasized)
mysql> select link from items where link like ‘%\’%';

| businessweek.com/technology/content/jun2006/tc20060615_290127.htm?
chan=technology_technology+index+page_more+of+todays+top+stories |

1 row in set (1.81 sec)

Note: this link isn’t being sent properly by del.icio.us either. It should have been converted to a safe URL by them and then transported through the RSS feed. This leaves the problem to the aggregator to sanitize before entering the database — which should always be done anyway.

This URL bug ran through three places: businessweek RSS feed (source), delicious popular (tagged) and reblog (aggregator, and into the database).

The proper code to sanitize query strings from URLs like this:

$the_link = “?chan=technology_technology+index+page_more+of+today‘s+top+stories”;
print “before: $the_link

<hr />After: “ . urlencode($the_link);

If this step had been taken before transferring the URL to the source RSS feed (businessweek) or in the tagging (delicious popular) then it wouldn’t be needed in the RSS Aggregator (Reblog). Since that’s not the case, I decided to modify the Reblog code to deal with unsanitized URLs before they reach the database and render future database writes in Reblog disfunctional. Because Reblog can use multiple input sources it makes more sense to alter the point just before the save routine rather than alter the code of each input source (like magepieRSS).

Reblog
1. locate Controller.class.php in /refeed/library/RF
2. line to patch is in saveItem() function starting around line 1679 as follows:

Locate this:

function saveItem(&$item)
{
$dbhw =& $this->getWriteHandle();
$data = $item->columnNamesValues();

And CHANGE to this:

function saveItem(&$item)
{
$dbhw =& $this->getWriteHandle();
$data = $item->columnNamesValues();

// sanitize all links being saved with single quote
$data[‘link’] = str_replace(“‘”,“%27″,$data[‘link’]);

Notice this patch string replaces any instance of the single quote character in the link to the %27 sanitized version. A more comprehensive fix would be to urlencode the query string portion of the URL shown earlier in this post. My concern was fixing that specific character which kept causing problems.

You can test this issue in your version of Reblog with the broken del.icio.us feed cached here (not linked):
php-scripts.com/examples/popular-delicious_06172006.xml

« » Pages (999999) : 1 [2]3 4 ... Last »