Файл: DarkAge/files/functions.php
Строк: 55
<?
function check($mess){
$mess=str_replace("|","",$mess);
$mess=str_replace("||","",$mess);
$mess=htmlspecialchars($mess);
$mess=str_replace("'","'",$mess);
$mess=str_replace(""",""",$mess);
$mess=str_replace("$","$",$mess);
$mess=str_replace("\","\", $mess);
$mess=str_replace("!","!", $mess);
$mess=str_replace("[","[", $mess);
$mess=str_replace("]","]", $mess);
$mess=str_replace("@","@", $mess);
$mess=stripslashes($mess);
return $mess; }
///////////////////////////////////////////// BACKUP ///////////////////////////
class zipfile
{
var $datasec = array();
var $ctrl_dir = array();
var $eof_ctrl_dir = "x50x4bx05x06x00x00x00x00";
var $old_offset = 0;
function add_dir($name)
{
$name = str_replace("\", "/", $name);
$fr = "x50x4bx03x04";
$fr .= "x0ax00";
$fr .= "x00x00";
$fr .= "x00x00";
$fr .= "x00x00x00x00";
$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 = "x50x4bx01x02";
$cdrec .="x00x00";
$cdrec .="x0ax00";
$cdrec .="x00x00";
$cdrec .="x00x00";
$cdrec .="x00x00x00x00";
$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 = "x00x00x10x00";
$ext = "xffxffxffxff";
$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 = "x50x4bx03x04";
$fr .= "x14x00";
$fr .= "x00x00";
$fr .= "x08x00";
$fr .= "x00x00x00x00";
$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 = "x50x4bx01x02";
$cdrec .="x00x00";
$cdrec .="x14x00";
$cdrec .="x00x00";
$cdrec .="x08x00";
$cdrec .="x00x00x00x00";
$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)).
"x00x00";
}
}
////////////////////////////////////////////////////////////////////
?>