Jump to content
php.lv forumi

Automātiskā kompresācija


lazda144

Recommended Posts

man ir saadas skripts:

<?
  function zipcompressfile($source,$destination,$filename,$level=false)
  {
   $dest=$destination.$filename.'.zip';
   $mode='wb'.$level;
   $error=false;
	   echo $source.$filename.' -> '.$dest.'<br>';
   if($fp_out=gzopen($dest,$mode))
  {
	   if($fp_in=fopen($source.$filename,'rb'))
	   {
		  while(!feof($fp_in))
		   {
			   gzwrite($fp_out,fread($fp_in,1024*512));
		   }
		   fclose($fp_in);
	  }
	  else
	  {
		  $error=true;
					}
	   gzclose($fp_out);
   }
   else $error=true;
   if($error) return false;
   else return $dest;
  }

  $demo_dir = 'r:/AppServ/www/recorded_demos/'; // Folder with .dem files
 $dl_dir = 'r:/AppServ/www/compressed_demos/'; // Folder, where to put compressed files

  $handle = opendir($demo_dir);  
  if ($handle)
  {
   while (false !== ($fails = readdir($handle)))
   {
	   if ( preg_match("/(.*).dem/", $fails, $demo) )
	   {
		   zipcompressfile($demo_dir, $dl_dir, $fails);
	 }  
  }
  closedir($handle);  
  }
?>

 

kaa uzlikt lai vins pats automaatiski kompresee failus?

Link to comment
Share on other sites

Vienkāršāks veids izveidot linku ar onclick eventu, kas kaut kādam noslēptam ifreimam src atribūtu nomaina uz to hltv.php un pēc tam returno false (lai nenotiktu pārlāde).

 

Var arī ar xmlhttprequest objektu (ajax). Atkal links ar onclick eventu, kas fonā veic ajax pieprasījumu uz noteiktu skriptu.

Link to comment
Share on other sites

×
×
  • Create New...