View file admin/backup/arch.php

File size: 5.26Kb
<?php

include("../config.php");
include("../templates/head.php");
echo"<div class=\"a\">";
echo"Админка";
echo"</div>";
echo"<p>";
echo"<div class=\"c\">";
echo"Настройка<p>";
if($_SERVER['QUERY_STRING'] == "login=$admin&pass=$pass")
{
$admin = $_POST['admin'];
$password = $_POST['pass'];
$email = $_POST['email'];
$title = $_POST['title'];
$index = $_POST['index'];
$skin = $_POST['skin'];
$mpass = md5($password);

print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"><html><head>";
echo "<link href=\"motorusa.css\" rel=\"stylesheet\" type=\"text/css\">";
echo "<title>MOTORUSA-ARCHIVER</title><body>
<p align=\"center\"><div align=\"center\" class=\"d\">
<hr/>";

error_reporting(7);
include "tmp.php";
class zipfile
{

    var $datasec = array(); 
    var $ctrl_dir = array(); 
    var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; 
    var $old_offset = 0;

    function add_dir($name)

    {
        $name = str_replace("\\", "/", $name);

        $fr = "\x50\x4b\x03\x04";
        $fr .= "\x0a\x00";   
        $fr .= "\x00\x00";   
        $fr .= "\x00\x00";   
        $fr .= "\x00\x00\x00\x00"; 
        $fr .= pack("V",0); 
        $fr .= pack("V",0); 
        $fr .= pack("V",0); 
        $fr .= pack("v", strlen($name) ); 
        $fr .= pack("v", 0 ); 
        $fr .= $name;
        $fr .= pack("V",$crc); 
        $fr .= pack("V",$c_len); 
        $fr .= pack("V",$unc_len); 
        $this -> datasec[] = $fr;
        $new_offset = strlen(implode("", $this->datasec));
        $cdrec = "\x50\x4b\x01\x02";
        $cdrec .="\x00\x00";    
        $cdrec .="\x0a\x00";    
        $cdrec .="\x00\x00";    
        $cdrec .="\x00\x00";   
        $cdrec .="\x00\x00\x00\x00"; 
        $cdrec .= pack("V",0); 
        $cdrec .= pack("V",0); 
        $cdrec .= pack("V",0); 
        $cdrec .= pack("v", strlen($name) ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("v", 0 ); 
        $ext = "\x00\x00\x10\x00";
        $ext = "\xff\xff\xff\xff";
        $cdrec .= pack("V", 16 ); 
        $cdrec .= pack("V", $this -> old_offset ); 
        $this -> old_offset = $new_offset;
        $cdrec .= $name;
        $this -> ctrl_dir[] = $cdrec;
    }


    function add_file($data, $name)
    { $name = str_replace("\\", "/", $name);
$fr = "\x50\x4b\x03\x04";
        $fr .= "\x14\x00";    
        $fr .= "\x00\x00";    
        $fr .= "\x08\x00";    
        $fr .= "\x00\x00\x00\x00"; 

        $unc_len = strlen($data);
        $crc = crc32($data);
        $zdata = gzcompress($data);
        $zdata = substr( substr($zdata, 0, strlen($zdata) - 4), 2); 
        $c_len = strlen($zdata);
        $fr .= pack("V",$crc); 
        $fr .= pack("V",$c_len); 
        $fr .= pack("V",$unc_len); 
        $fr .= pack("v", strlen($name) ); 
        $fr .= pack("v", 0 ); 
        $fr .= $name;
        $fr .= $zdata;
        $fr .= pack("V",$crc); 
        $fr .= pack("V",$c_len); 
        $fr .= pack("V",$unc_len); 
        $this -> datasec[] = $fr;
        $new_offset = strlen(implode("", $this->datasec));
        $cdrec = "\x50\x4b\x01\x02";
        $cdrec .="\x00\x00";    
        $cdrec .="\x14\x00";  
        $cdrec .="\x00\x00";   
        $cdrec .="\x08\x00";   
        $cdrec .="\x00\x00\x00\x00"; 
        $cdrec .= pack("V",$crc); 
        $cdrec .= pack("V",$c_len); 
        $cdrec .= pack("V",$unc_len);
        $cdrec .= pack("v", strlen($name) ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("v", 0 ); 
        $cdrec .= pack("V", 32 ); 

        $cdrec .= pack("V", $this -> old_offset ); 
        $this -> old_offset = $new_offset;

        $cdrec .= $name;
        $this -> ctrl_dir[] = $cdrec;
    }

    function file() { 
        $data = implode("", $this -> datasec);
        $ctrldir = implode("", $this -> ctrl_dir);
        return
            $data.
            $ctrldir.
            $this -> eof_ctrl_dir.
            pack("v", sizeof($this -> ctrl_dir)).    
            pack("v", sizeof($this -> ctrl_dir)). 
            pack("V", strlen($ctrldir)).   
            pack("V", strlen($data)).    
            "\x00\x00"; }}
$abort = ignore_user_abort(1);
$zipfile = new zipfile();
$fdir = opendir($dir);
while($file = readdir($fdir)){
if ($file != '.' and $file != '..'){
if (is_file($dir.$file)){$zipfile->add_file(file_get_contents($dir.$file),$file);}
if (is_dir($dir.$file)){
$sdir = opendir($dir.$file);
while($sfile = readdir($sdir)){
if ($sfile != '.' and $sfile != '..'){
if (is_file($dir.$file.'/'.$sfile)){$zipfile->add_file(file_get_contents($dir.$file.'/'.$sfile), $file.'/'.$sfile);}}}}}}
 $fil = fopen ("$zipdir/$zipp","r+");
   $str = $zipfile->file();
  if ( !$fil )
  {
    echo("Не получилось!:(");
  }
  else
  {
    fputs ( $fil, $str);
  }
  fclose ($fil);
  echo "Ураа!Получилось!<a href=\"index.php\">Создать Еще!</a>";
echo '<div class="c">
<a href="http://motorusa.net.ru"><font size="3" color="#ffff99" face="Zapf Chancery, Comic Sans MS, cursive"><var>© MOTORUSA</var></font></div></a>';
echo'</body></html>';

?>