Skip to main content

unzip file with php

This is a little php script to unzip file using php


function unzip($file){
if(!$zip) {return("Unable to proccess file '{$file}'");}
while($zip_entry=zip_read($zip)) { $zdir=dirname(zip_entry_name($zip_entry)); $zname=zip_entry_name($zip_entry);
{$e.="Unable to proccess file '{$zname}'";continue;}
if(!is_dir($zdir)) mkdirr($zdir,0777);
#print "{$zdir} | {$zname} \n";
$zip_fs=zip_entry_filesize($zip_entry); if(empty($zip_fs)) continue;
$z=fopen($zname,"w"); fwrite($z,$zz); fclose($z); zip_entry_close($zip_entry);
return($e); }
function mkdirr($pn,$mode=null) {
if(is_dir($pn)||empty($pn)) return true; $pn=str_replace(array('/', ''),DIRECTORY_SEPARATOR,$pn);
if(is_file($pn)) {trigger_error('mkdirr() File exists', E_USER_WARNING);return false;}
$next_pathname=substr($pn,0,strrpos($pn,DIRECTORY_SEPARATOR)); if(mkdirr($next_pathname,$mode)) {if(!file_exists($pn))
{return mkdir($pn,$mode);} } return false; }



Popular posts from this blog

Image IP Logger

We will need : 
- image.php
- image.jpg
- .htaccess


$date = date("d-m-y / H:i:s");
$refer = $_SERVER["HTTP_REFERER"];
$BR = "<br>"; $HR = "<hr>";
$IPS = @fopen("log.html",'a');
$s = "<b>ip: </b> ".$ip. $BR . "<b>Date: </b>".$date. $BR ."<b>Refer: </b>". $refer. $BR ."<b>Agent: </b>". $agent. $BR . $HR;
fwrite($IPS, $s, strlen($s));
header('Content-Type: image/jpeg');
// Get image from file
$img = imagecreatefromjpeg($imgpath);
// Output the image
We could use an gif image then use imagecreatefromgif instead of imagecreatefromjpeg


RewriteEngine On RewriteRule ^coolimage.jpg image.php

coolimage.jpg would be the image in url:


Lighttpd PHP fastcgi configuration

FastCGI is a language independent, scalable, open extension to CGI that provides high performance without the limitations of server specific APIs. FastCGI provides better scalability and performance. Instead of creating a new process (the CGI program) for every request, FastCGI uses a single persistent process which handles many requests over its lifetime. (See wikipedia article for more information)
Make sure php support fastcgi Type any one of the following command to verify that php support fastcgi
$ php -v
PHP 5.0.4 (cli) (built: Nov 8 2005 08:27:12) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies OR
$ php-cgi -v
PHP 5.0.4 (cgi-fcgi) (built: Nov 8 2005 08:25:54) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies You must get string cgi-fcgi. Next find out full path to php-cgi or php binary:
$ which php-cgi
/usr/bin/php-cgi Open lighttpd configurati…