Fungsi dibawah ini bisa dugunakan untuk membuat file zip secara otomatis. /* creates a compressed zip file */ function create_zip($files = array(),$destination = ”,$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in… if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; }

Read More

function list_files($dir) {     if(is_dir($dir))     {         if($handle = opendir($dir))         {             while(($file = readdir($handle)) !== false)             {                 if($file != “.” && $file != “..” && $file != “Thumbs.db”)                 {                     echo ‘<a target=”_blank” href=”‘.$dir.$file.’”>’.$file.'</a><br>’.”\n”;                 }             }             closedir($handle);         }     } }

Read More

function readable_random_string($length = 6){     $conso=array(“b”,”c”,”d”,”f”,”g”,”h”,”j”,”k”,”l”,     “m”,”n”,”p”,”r”,”s”,”t”,”v”,”w”,”x”,”y”,”z”);     $vocal=array(“a”,”e”,”i”,”o”,”u”);     $password=””;     srand ((double)microtime()*1000000);     $max = $length/2;     for($i=1; $i<=$max; $i++)     {     $password.=$conso[rand(0,19)];     $password.=$vocal[rand(0,4)];     }     return $password; }

Read More

Cara membuat halaman download ditunggu 3 detik <?php // if name via get equals ‘download”, show the downloading message. if($_GET[‘name’] == “download”){ echo “Downloading … “; } else { // set refresh to 3 seconds, make the variable name be ‘download’ via the get method; header(“Refresh: 3: url=http://maque.kodingen.com/index.php?name=download”); // show this message echo “You can download in 3 seconds.”; } ?>

Read More

Fungsi untuk unzip file menggunakan php = <?php function unzip($location,$newLocation){ if(exec(“unzip $location”,$arr)){ mkdir($newLocation); for($i = 1;$i< count($arr);$i++){ $file = trim(preg_replace(“~inflating: ~”,””,$arr[$i])); copy($location.’/’.$file,$newLocation.’/’.$file); unlink($location.’/’.$file); } return TRUE; }else{ return FALSE; } } include ‘functions.php’; if(unzip(‘zipedfiles/test.zip’,’unziped/myNewZip’)) echo ‘Success!’; else

Read More
WhatsApp chat