Zend - The PHP Company




Utilities

Add Code


Zend Encoder - whole webserver directory  

Type: code fragment
Added by: med
Entered: 23/07/2001
Last modified: 07/12/2000
Rating: - (fewer than 3 votes)
Views: 5510
My small contribution for your marvellous encoder ;-) this script asks for a webserver directory and encodes every file in it. (keeps source as file.src). Includes function to not reeocnde already encoded file. This code is kissware.


<?
// by mederic@oxymum.com - enjoy gaining time ;-)

if ($dir && ereg("/$",$dir)) $dir=substr($dir,0,strlen($dir)-1);
if (
$dir) {setcookie("dirc",$dir,time()+3600*24*365);$dirc=$dir;};
?>
<form>Please encode every file in dir:<input type=text name=dir value="<?echo $dirc;?>">
<?
if ($dir) {
if (!
ereg("~/",$dir) && !ereg("~.:",$dir)) $dir=dirname(getenv("PATH_TRANSLATED"))."/".$dir;
echo 
"<br>".$dir."<br><br>";
chdir($dir);
$attdir=opendir($dir); 
while (
$att=readdir($attdir))
 if (
strlen($att)>&& ereg(".php$|.php3$|.phps$|.phtml$",$att)) 
   {
    echo(
"<br><br><b>".$dir."/".$att."</b><br>");
    
$fp=fopen($dir."/".$att,"r");
    
$beg=substr(fgets($fp,5),0,4);
    
fclose($fp);
    if (
$beg=="Zend")
          echo 
"Already encoded.";
     else 
system ("zendenc --rename-source src ".$dir."/".$att." ".$dir."/".$att);
   };
// 

};
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories