Static compile and install of apache + mod_ssl + php on FC4
Tue, 05/22/2007 - 15:24 — sandipLatest Compile with pdo drivers for mysql along with mod_security.
NOTE:
Remove the MySQL-shared rpm else openssl will not work.
# rpm -e MySQL-shared-5.0.20a-0.glibc23
Load your PHP pages faster with GZip compression
Sat, 12/23/2006 - 00:57 — sandipIf you have heavy pages with lots of images and text, you can greatly improve its' performance by dynamically compressing the page with php.
Put the below code in the header of each php page.
<? ob_start("ob_gzhandler&qu ot;); ?>
It automatically gzips the page for browsers that support it.
This could also be set in the php.ini file instead, so all php pages are automatically compressed without having to add the above code in each and every php page.
In php.ini add the below code:
output_handler = ob_gzhandler
- sandip's blog
- Login or register to post comments
- Read more
How to fix _Can't open file: 'sessions.MYI'_ in Drupal
Fri, 03/10/2006 - 23:57 — sandipThis seems to occur if mysql crashes for some reason and corrupts the sessions table for Drupal.
Here is a quick way to resolve this and I have used it in the past...
mysql> REPAIR TABLE sessions QUICK;
You can also use phpmyadmin to repair the table.
Related Reading: MySQL Database Repair
- sandip's blog
- Login or register to post comments
Compiling support for XSLT in PHP
Fri, 02/24/2006 - 22:49 — sandipXSLT, Extensible Stylesheet Language (XSL) Transformations is a language for transforming XML documents into other XML documents. It is a standard defined by The World Wide Web Consortium (W3C). Information about XSLT and related technologies can be found at http://www.w3.org/TR/xslt.
PHP XSLT extension only supports the Sablotron library from the Ginger Alliance. The extension does not come standard with Redhat Enterprise... and the compilation was a bit tricky. So if you are having difficulty, theses notes may help you some...
Listing image files in folders and subfolders with PHP
Wed, 01/11/2006 - 11:09 — sandipHere's a quick way to create a listing of images uploaded to a folder with php:
<?php // file name: list_pics.php global $startDir; /** * List Directories function, which transverses sub-folders * listing out the image files that exists within it. */ function listDir( $path ) { global $startDir; $handle = opendir( $path ); while (false !== ($file = readdir($handle))) { if( substr( $file, 0, 1 ) != '.' ) { if( is_dir( $path.'/'.$file ) ) { listDir( $path.'/'.$file ); } else { if( @getimagesize( $path.'/'.$file ) ) { /* // Uncomment if using with the below "pic.php" script to // encode the filename and protect from direct linking. $url = 'http://domain.tld/images/pic.php?pic=' .urlencode( str_rot13( substr( $path, strlen( $startDir )+1 ).'/'.$file ) ); */ $url='http://domain.tld/images /'. substr( $path, strlen( $startDir )+1 ).'/'.$file; // You can customize the output to use img tag instead. echo "<a href='".$url."'>".$url."</a ><br>"; } } } } closedir( $handle ); } // End listDir function $startDir = '.'; listDir( $startDir ); ?>
- sandip's blog
- Login or register to post comments
- Read more
Generate a dynamic playlist of mp3 files in a folder with PHP
Thu, 12/22/2005 - 23:42 — sandipBelow is a simple php script to generate a playlist of the mp3 files placed in a folder. I have tested it to work with XMMS media player on FC4 and should work with others too. Substitute the path and the url of the music folder.
<?php // music_playlist.php $folder_path = './music_folder'; $folder_url = 'http://domain.tld/music_folde r/'; if ($handle = opendir($folder_path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $song_list .= $folder_url.$file."\n"; } } closedir($handle); } else { echo "Music folder does not exist!"; exit; } // send header of audio/x-mpegurl content type header('Content-type: audio/x-mpegurl'); if (preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) { header("Content-Disposition: filename=\"my_playlist.m3u\"") ; } else { header("Content-Disposition: inline; filename=\"my_playlist.m3u\"") ; } echo "$song_list"; ?>
Related Reading: Listen to mp3 songs using XMMS in Redhat/Fedora
- sandip's blog
- Login or register to post comments
Sending form data to email via php
Sat, 05/21/2005 - 21:09 — sandipThe below is a simple script that handles sending form data to email using php:
<?php // checks to see if the page that called this script was sent from the same host if ($_SERVER['REQUEST_METHOD']=="POST"){ if (strpos($_SERVER['HTTP_REFERER '], $_SERVER['HTTP_HOST'])>7 || !strpos($_SERVER['HTTP_REFERER '], $_SERVER['HTTP_HOST'])) die("Bad referer"); // begin building the message body $msg="Values submitted by the user:\n"; foreach($_POST as $key => $val){ if (is_array($val)){ $msg.="Item: $key\n"; foreach($val as $v){
- sandip's blog
- Login or register to post comments
- Read more
PHP Accelerator
Fri, 01/28/2005 - 21:43 — sandipPHP Accelerator is an easily installed PHP Zend engine extension that provides a PHP cache, and is capable of delivering a substantial acceleration of PHP scripts without requiring any script changes, loss of dynamic content, or other application compromises.
-
Installation:
-
Download PHPAccelerator.
Unpackage it and move contents to "/usr/local/phpaccelerator".
Include the below line to php.ini under dynamic extension section:
zend_extension="/usr/local/phpaccelerator/php_accelerator_1. 3.3r2.so"
- sandip's blog
- Login or register to post comments
- Read more
Get PHPwiki up and running with mysql
Thu, 12/16/2004 - 16:02 — sandipRan into some difficulty installing the wiki with mysql backend as the documentation wasn't upto-date.
Below are some notes and customization done during the process:- Download the latest tarball from SourceForge
- Extract all files.
- Copy 'config/config-dist.ini' to 'config/config.ini' and edit the settings.
- Make sure to set the value of 'DEBUG' to either 1 or 0 and do not comment it out. The install process complains if the DEBUG value is not found.
- Upload the "passencrypt.php" to the web-server and access it via browser to encrypt password.
- sandip's blog
- Login or register to post comments
- Read more
Top 10 ways to crash PHP
Sun, 08/15/2004 - 07:02 — himanshuProgramming errors are of many kinds but the consequences can range from harmless to downright dangerous.
Top 10 ways to crash PHP is an interesting article that deals with such a topic for PHP.
- himanshu's blog
- Login or register to post comments