<?php
/* davimage.php */
include_once("popoon/components/action.php");
/**
* http://bx.ppk.go/page/movie/page/movie/upimzip/bio/13462346/
* http://bx.ppk.go/page/movie/page/movie/upimzip/film/13462346/
*/
class popoon_components_actions_davcmszip extends popoon_components_action {
/**
* Constructor
*
*/
function Reset_Dir($dir) {
$dirfos = $dir;
if (is_dir($dirfos)) {
$d = dir($dirfos);
$mone=0;
while (false !== ($entry = $d->read())) {
if ($entry == "." or $entry =="..") {
continue;
}
if (is_dir($dirfos.$entry)) { /// is_dir bug???
continue;
}
if (is_file($dirfos.$entry)) {
@unlink($dirfos.$entry);
$mone++;
}
}
}
}
function Make_Dir($dir) {
if (eregi('data', $dir)) {
@shell_exec(escapeshellcmd('mkdir -p '.$dir)); ///PHP FastCGI from owner or www-data ///
if (!is_dir($dir)) {
print("<h1>ERROR Permission Denied! (Make_Dir ".$dir.")</h1> <p>".__FILE__."#".__LINE__."<p>");
exit;
} else {
return true;
}
} else {
print("<h1>ERROR Permission Denied! (Make_Dir ".$dir.")</h1> <p>".__FILE__."#".__LINE__."<p>");
return false;
}
return false;
}
function ResetCache() {
$dirfos = CACHEWEBS;
if (is_dir($dirfos)) {
$d = dir($dirfos);
$mone=0;
while (false !== ($entry = $d->read())) {
if ($entry == "." or $entry =="..") {
continue;
}
if (is_dir($dirfos.$entry)) { /// is_dir bug???
continue;
}
if (is_file($dirfos.$entry)) {
@unlink($dirfos.$entry);
$mone++;
}
}
return $mone;
} else {
return 0;
}
}
/* get zip stream and replace on dbs */
function TakeZipDB( $path , $uintid ) {
if (!@$fd = fopen($path, "rb")) {
return false;
}
$dbaccess = new DB_Service(DBASE_0);
$magic_quotes = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
$file_buffer = fread($fd, filesize($path));
$file_buffer = base64_encode($file_buffer);
$file_buffer .="|end_stream|"; /* help to find if longblob having more as 2.4 mb sql query size en come in or no.. */
fclose($fd);
set_magic_quotes_runtime($magic_quotes);
$sqlreplacezip = "REPLACE INTO PAGEFILE VALUES (".$uintid.", 'zip', 'attach' ,'".$file_buffer."',".date("U").")";
$kbgo = file_put_contents(CACHEWEBS."lastzibdb.dat",$sqlreplacezip);
return $dbaccess->Exec_SQL($sqlreplacezip);
if ($kbgo > 0) {
return true;
} else {
return false;
}
}
function action_davcmszip(&$sitemap) {
$this->action($sitemap);
}
function init() {
}
function act() {
$canno = ""; /* message action */
$openzipondir = "/root/"; /* on place wo not is permission to write! default ! */
$filewriter = ROOT_WWW_DIR."map/datazip.xml"; /* file mit retour info */
$code = $this->getParameterDefault("code"); /* file mit retour info */
$methodbrowser = strtolower($_SERVER['REQUEST_METHOD']);
$kb=0;
$errors="";
$canno="";
$teile = @explode("/", $code);
$filenr = $teile[0];
$methode = $teile[1];
$usefile = $teile[2];
$oneday_yahr = date('Y',$filenr);
$oneday_month = date('m',$filenr);
$oneday_tag = date('d',$filenr);
$userbasedir = "data/".$oneday_yahr."/".$oneday_month."/".$oneday_tag."/";
$basedir = ROOT_WWW_DIR."data/".$oneday_yahr."/".$oneday_month."/".$oneday_tag."/";
$basepagedir = $basedir.$filenr."/";
$imageedir = $basedir.$filenr."/album/";
$datadir = $basedir.$filenr."/data/";
$subjektfile = $basedir.$filenr.".zip";
if ($methodbrowser == "get" && $methode !="remove") {
$canno .="Test envoirment|";
$canno .="Usage filenr/data/zip/ to create page.|";
$canno .="Usage cache/remove/file/ to drop cache file.|";
}
if ($methodbrowser == "put" && $methode =="data") {
$canno .="Accept upload.|";
}
if (!isset($_COOKIE['Xserial'])) {
$errors .="You dont have a serial permission denied!|";
} else {
if (is_numeric($filenr) && $methode =="data") {
if ($_COOKIE['Xserial'] == QTSERIAL) {
$canno .="Your serial is correct.|";
if ($this->Make_Dir($basedir)) {
$canno .="Dir exist page|";
if ($methodbrowser == "put") {
$canno .="Reading input.|";
///////@unlink($subjektfile);
$content = file_get_contents("php://input");
$kb=file_put_contents($subjektfile,$content);
/* replace zip on db here */
$this->Reset_Dir($imageedir);
$this->Reset_Dir($datadir);
$this->Reset_Dir($basepagedir);
$zipreq = @exec(escapeshellcmd('unzip '.$subjektfile.' -d '.$basedir));
$this->ResetCache();
if ($this->TakeZipDB($subjektfile,$filenr)) {
$canno .="Zip ON DB OK|";
}
@unlink($subjektfile);
$canno .="Unzip MSG start.|";
$canno .=$zipreq.".|";
$canno .="Unzip MSG stop.|";
}
}
}
}
}
$dml = new XML('1.0', 'utf-8');
$root = $dml->createElement('dav_zip_upload');
$root->setAttribute('methode',$methode);
$root->setAttribute('httpm',$methodbrowser);
$root->setAttribute('filenr',$filenr);
$root->setAttribute('usefile',$userbasedir);
if (isset($_COOKIE['Xserial'])) {
if ($_COOKIE['Xserial'] == QTSERIAL) {
$root->setAttribute('youserial',"1");
} else {
$root->setAttribute('youserial',"NULL");
}
}
$root->setAttribute('buildindate',date("U"));
$root->setAttribute('hbuild',date("d.m.Y-G:i:s"));
$root->setAttribute('kb_in',$kb);
$dml->appendChild($root);
$nome = $dml->createElement("message",$canno);
$root->appendChild($nome);
$erno = $dml->createElement("erno",$errors);
$root->appendChild($erno);
$dxbio = $dml->saveXML();
@file_put_contents($filewriter,$dxbio);
return array("message" => "how take message");
}
}
?>
Bookmarks