function getFilePackage($fileids, $returnContent = false) { $fileids = explode(",", $fileids); include_once "createZip.inc.php"; $createZip = new createZip(); $fileCount = 0; foreach ($fileids as $fileid) { if (file_exists($this->rootPath . $fileid)) { $createZip->addFile(file_get_contents($this->rootPath . $fileid), basename($fileid)); $fileCount++; } } if ($fileCount > 0) { if ($returnContent != true) { header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); #header("Content-length: ".strlen($zipped)); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip->getZippedfile(); } else { return $createZip->getZippedfile(); } } else { $this->error('no files zipped'); } }
/** * Connects to POG SOAP server defined in configuration.php and * generates new versions of all objects detected in /objects/ dir. * All upgraded objects are then zipped and presented to user. * * @param string $path */ function UpdateAllObjects($path) { $dir = opendir($path); $objects = array(); while (($file = readdir($dir)) !== false) { if (strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "configuration.php" && $file != "setup.php" && $file != "class.pog_base.php") { $objects[] = $file; } } closedir($dir); $i = 0; foreach ($objects as $object) { $content = file_get_contents($path . "/" . $object); $contentParts = split("<b>", $content); if (isset($contentParts[1])) { $contentParts2 = split("</b>", $contentParts[1]); } if (isset($contentParts2[0])) { $className = trim($contentParts2[0]); } if (isset($className)) { eval('include_once("../../objects/class.' . strtolower($className) . '.php");'); $instance = new $className(); if (!TestIsMapping($instance)) { $objectNameList[] = $className; $linkParts1 = split("\\*\\/", $contentParts[1]); $linkParts2 = split("\\@link", $linkParts1[0]); $link = $linkParts2[1]; $options = false; if ($GLOBALS['configuration']['proxy_host'] != false && $GLOBALS['configuration']['proxy_port'] != false && $GLOBALS['configuration']['proxy_username'] != false && $GLOBALS['configuration']['proxy_password'] != false) { $options = array('proxy_host' => $GLOBALS['configuration']['proxy_host'], 'proxy_port' => $GLOBALS['configuration']['proxy_port'], 'proxy_login' => $GLOBALS['configuration']['proxy_username'], 'proxy_password' => $GLOBALS['configuration']['proxy_password']); } $client = new SoapClient($GLOBALS['configuration']['soap'], $options); if ($i == 0) { $package = unserialize($client->GeneratePackageFromLink($link)); } else { $objectString = $client->GenerateObjectFromLink($link); $package["objects"]["class." . strtolower($className) . ".php"] = $objectString; } } } $i++; } //upgrade mapping classes if any foreach ($objectNameList as $objectName) { $instance = new $objectName(); foreach ($instance->pog_attribute_type as $key => $attribute_type) { if ($attribute_type['db_attributes'][1] == "JOIN") { $mappingString = $client->GenerateMapping($objectName, $key, isset($GLOBALS['configuration']['pdoDriver']) ? 'php5.1' : 'php5', isset($GLOBALS['configuration']['pdoDriver']) ? 'pdo' : 'pog', isset($GLOBALS['configuration']['pdoDriver']) ? 'mysql' : ''); $package["objects"]['class.' . strtolower(MappingName($objectName, $key)) . '.php'] = $mappingString; } } } $zipfile = new createZip(); $zipfile->addPOGPackage($package); $zipfile->forceDownload("pog." . time() . ".zip"); }
/** * Connects to POG SOAP server defined in configuration.php and * generates new versions of all objects detected in /objects/ dir. * All upgraded objects are then zipped and presented to user. * * @param string $path */ function UpdateAllObjects($path) { $dir = opendir($path); $objects = array(); while (($file = readdir($dir)) !== false) { if (strlen($file) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "configuration.php" && $file != "setup.php") { $objects[] = $file; } } closedir($dir); $i = 0; foreach ($objects as $object) { $content = file_get_contents($path . "/" . $object); $contentParts = split("<b>", $content); if (isset($contentParts[1])) { $contentParts2 = split("</b>", $contentParts[1]); } if (isset($contentParts2[0])) { $className = trim($contentParts2[0]); } if (isset($className)) { $objectNameList[] = $className; $linkParts1 = split("\\*\\/", $contentParts[1]); $linkParts2 = split("\\@link", $linkParts1[0]); $link = $linkParts2[1]; $client = new SoapClient($GLOBALS['configuration']['soap']); if ($i == 0) { $package = unserialize($client->GeneratePackageFromLink($link)); } else { $objectString = $client->GenerateObjectFromLink($link); $package["objects"]["class." . strtolower($className) . ".php"] = $objectString; } } $i++; } $zipfile = new createZip(); $zipfile->addPOGPackage($package); $zipfile->forceDownload("pog." . time() . ".zip"); }
function getFilePackage($paths, $returnContent = false) { // paths will look like: // "/filestore~kristinaRose.jpeg,/filestore/pics~harmonyRose.jpeg" logAction('getFilePackage', $paths); $paths = explode("\\\\,", $paths); $files = array(); $fileCount = 0; include_once "inc/createZip.inc.php"; $createZip = new createZip(); foreach ($paths as $path) { $i = preg_split("/\\~/", $path); $files[] = array("path" => $i[0], "filename" => $i[1]); } foreach ($files as $file) { $filePath = $file['path'] . '/' . $file['filename']; if (file_exists($filePath)) { $createZip->addFile(file_get_contents($filePath), $file['filename']); $fileCount++; } } if ($fileCount > 0) { if ($returnContent != true) { header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip->getZippedfile(); } else { return $createZip->getZippedfile(); } } else { error('No files zipped.'); } }
function tfu_zip_download($files, $enable_file_download) { global $zip_folder; // The folder is used to create the temp download files! if ($enable_file_download == 'false' && !isset($_GET['fullscreen'])) { echo 'This action is not enabled!'; exit(0); } $createZip = new createZip(); $nrfiles = count($files); for ($i = 0; $i < $nrfiles; $i++) { $createZip->addFile(file_get_contents($files[$i]), my_basename($files[$i])); } $fileName = $zip_folder . '/' . $_GET['zipname']; $fd = fopen($fileName, "wb"); $out = fwrite($fd, $createZip->getZippedfile()); fclose($fd); tfu_download($fileName, $enable_file_download); @unlink($fileName); }
if ($GLOBALS['configuration']['soapEngine'] == "nusoap") { $client = new soapclient($GLOBALS['configuration']['soap'], true); $attributeList = unserialize($_SESSION['attributeList']); $typeList = unserialize($_SESSION['typeList']); $params = array('objectName' => $_SESSION['objectName'], 'attributeList' => $attributeList, 'typeList' => $typeList, 'language' => $_SESSION['language'], 'wrapper' => $_SESSION['wrapper'], 'pdoDriver' => $_SESSION['pdoDriver'], 'db_encoding' => "0"); $package = unserialize($client->call('GeneratePackage', $params)); } else { if ($GLOBALS['configuration']['soapEngine'] == "phpsoap") { $client = new SoapClient('services/pog.wsdl', array('cache_wsdl' => 0)); $attributeList = unserialize($_SESSION['attributeList']); $typeList = unserialize($_SESSION['typeList']); $objectName = $_SESSION['objectName']; $language = $_SESSION['language']; $wrapper = $_SESSION['wrapper']; $pdoDriver = $_SESSION['pdoDriver']; $classList = unserialize($_SESSION['classList']); $dbEncoding = "0"; try { $package = unserialize($client->GeneratePackage($objectName, $attributeList, $typeList, $language, $wrapper, $pdoDriver, $dbEncoding, $classList)); } catch (SoapFault $e) { echo "Error: {$e->faultstring}"; } } } $zipfile = new createZip(); $zipfile->addPOGPackage($package); $zipfile->forceDownload("pog." . time() . ".zip"); $_POST = null; } else { header("Location:/"); }
$dbname = DB_DATABASE; // Configure the backup settings // Which directory/files to backup ( directory should have trailing slash ) $configBackup = array(''); // which directories to skip while backup $configSkip = array('../'); // Put backups in which directory $configBackupDir = '../backup/'; // Databses you wish to backup , can be many ( tables array if contains table names only those tables will be backed up ) $configBackupDB[] = array('server' => $dbhost, 'username' => $dbuser, 'password' => $dbpword, 'database' => $dbname); // Put in a email ID if you want the backup emailed $configEmail = ''; // Include backup functions file include 'includes/backup_functions.php'; $backupName = "backup-" . date('d-m-y') . '-' . date('H-i-s') . '.zip'; $createZip = new createZip(); if (isset($configBackup) && is_array($configBackup) && count($configBackup) > 0) { // Lets backup any files or folders if any foreach ($configBackup as $dir) { $basename = basename($dir); // dir basename if (is_file($dir)) { $fileContents = file_get_contents($dir); $createZip->addFile($fileContents, $basename); } else { $createZip->addDirectory($basename . "/"); $files = directoryToArray($dir, true); $files = array_reverse($files); foreach ($files as $file) { $zipPath = explode($dir, $file); $zipPath = $zipPath[1];
function getFilePackage($fileids, $returnContent = false) { global $database, $fileinfo, $filepath; $fileids = preg_split("/\\,/", $fileids); include_once "inc/createZip.inc.php"; $createZip = new createZip(); $fileCount = 0; logAction('getFilePackage', $fileids); foreach ($fileids as $fileid) { if (getFileInfo($fileid)) { if (getUserAuth('download', $fileinfo['virtualpath'])) { logAction('get', $fileid); $query = "update {$GLOBALS['tablePrefix']}filesystem set downloads=downloads+1 where id={$fileid}"; $result = mysql_query($query, $database); $createZip->addFile(file_get_contents($filepath), "{$fileinfo['filename']}"); $fileCount++; } else { // denied } } else { // denied } } if ($fileCount > 0) { if ($returnContent != true) { header("Content-Type: application/zip"); header("Content-Transfer-Encoding: Binary"); #header("Content-length: ".strlen($zipped)); header("Content-disposition: attachment; filename=\"package.zip\""); echo $createZip->getZippedfile(); } else { return $createZip->getZippedfile(); } } else { error('no files zipped'); } }
if ($show_form) { $base = md5(rand(0,99999) + time()); $s = new Scaffold($table); $s->download = true; /*file_put_contents( "temp/$base/{$table['list_page']}", $s->listtable() ); file_put_contents( "temp/$base/{$table['new_page']}", $s->newrow() ); file_put_contents( "temp/$base/{$table['edit_page']}", $s->editrow() ); file_put_contents( "temp/$base/{$table['delete_page']}", $s->deleterow() ); */ $createZip = new createZip; $createZip -> addFile($s->listtable(), $table['list_page'] ); $createZip -> addFile($s->newrow(), $table['new_page'] ); $createZip -> addFile($s->editrow(), $table['edit_page'] ); $createZip -> addFile($s->deleterow(), $table['delete_page'] ); $fileName = "temp/$base.zip"; $fd = fopen ($fileName, "wb"); $out = fwrite ($fd, $createZip -> getZippedfile() ); fclose ($fd); $createZip -> forceDownload($fileName); //@unlink($fileName); }
* the auth code, without which, the backup is not complete: the authcode is * required to ensure the MD5 hashes stored in the DB per user are still valid * when the backup is restored at an unfortunate moment later in time. */ $configBackup = array(array('tree' => 'content/'), array('tree' => 'lib/templates/'), array('file' => 'lib/config.inc.php'), array('tree' => 'media/albums/:/\\.txt$/i')); $backupName = date('Ymd_His') . '-data' . $current_user . '.zip'; $file_collection = array(); $fileName = BASE_PATH . '/' . BACKUP_DIRECTORY . $backupName; $listfile = $fileName . '.list'; $progressfile = BASE_PATH . '/' . BACKUP_DIRECTORY . 'progress-data' . $current_user . '.json'; log_current_backup_state($progressfile, $file_collection); $fd = @fopen($fileName, 'wb'); if (!$fd) { throw new FbX($ccms['lang']['system']['error_openfile'] . ": " . $fileName); } else { $createZip = new createZip($fd); if (isset($configBackup) && is_array($configBackup) && count($configBackup) > 0) { foreach ($configBackup as $elem) { foreach ($elem as $scantype => $spec) { $pathspec = explode(':', $spec, 2); $dir = $pathspec[0]; $regex_to_match = count($pathspec) > 1 ? $pathspec[1] : null; /* strip off the relative-path-to-root so we're left with the full, yet relative, path. Handy when restoring data: extract zip equals (almost) done. */ $basename = $dir; if (is_file(BASE_PATH . '/' . $dir)) { if ($scantype == 'file') { $file_collection[] = array('file' => $basename);
copy($styledir . 'images/sectionheader_small_gold_bg.jpg', 'offline/images/sectionheader_small_gold_bg.jpg'); /* Save archivetime */ //date_default_timezone_set('America/Los_Angeles'); $ob_file = fopen('include/archive.inc', 'w'); ob_start('ob_file_callback'); $d = date('Y-m-d'); echo "<?php\n"; echo '$archivetime="' . $d . '";'; echo "\n?>"; ob_end_flush(); /* Zip the offline doc */ if (!is_dir('archives')) { mkdir('archives'); copy('include/index.html', 'archives/index.html'); } $zip = new createZip(); $zip->addDirectory("images/"); if ($dh = opendir('offline')) { while (($file = readdir($dh)) !== false) { if (is_file('offline/' . $file)) { $fileContents = file_get_contents('offline/' . $file); $zip->addFile($fileContents, $file); } } closedir($dh); } if ($dh = opendir('offline/images')) { while (($file = readdir($dh)) !== false) { if (is_file('offline/images/' . $file)) { $fileContents = file_get_contents('offline/images/' . $file); $zip->addFile($fileContents, 'images/' . $file);
public function home() { $dim = array(900, 600); $dim = array(800, 533); $dim = array(600, 400); if (_button()) { $v = $this->__(array('start' => 0, 'folder' => '', 'width' => 0, 'height' => 0)); $images = $types = w(); $dim = array($v['width'], $v['height']); @set_time_limit(0); $original = PCK . $v['folder'] . '/'; $gallery = $original . 'gallery/'; if (!@file_exists($original)) { exit; } if (!@file_exists($gallery)) { @mkdir($gallery, 0777); @chmod($gallery, 0777); } require_once XFS . XCOR . 'upload.php'; require_once XFS . XCOR . 'zip.php'; if (!is_writable($original) || !is_writable($gallery)) { exit; } $upload = new upload(); $zip = new createZip(); $fp = @opendir(PCK . $v['folder']); while ($row = @readdir($fp)) { if (preg_match('#^(.*?)\\.(jpg|JPG)$#is', $row, $s) && @is_readable($original . $row)) { $images[] = $row; $type = preg_match('#^(\\d+)$#is', $s[1]) ? 'numeric' : 'string'; $types[$type] = true; } } @closedir($fp); if (!count($images)) { exit('No hay archivos para convertir.'); } $multisort = array(&$images, SORT_ASC); if (!isset($types['string'])) { $multisort[] = SORT_NUMERIC; } hook('array_multisort', $multisort); foreach ($images as $image) { $row = $upload->_row($gallery, $image); $xa = $upload->resize($row, $original, $gallery, $start, $dim, false, false, false, $original . $image); $start++; $zip->addFile(file_get_contents($gallery . $xa['filename']), $xa['filename']); } $zipfile = PCK . $folder . '.zip'; $fd = @fopen($zipfile, 'wb'); $out = @fwrite($fd, $zip->getZippedfile()); @fclose($fd); $zip->forceDownload($zipfile); @unlink($zipfile); exit; } $options = w(); $fp = @opendir(PCK); while ($file = @readdir($fp)) { if (substr($file, 0, 1) != '.' && is_dir(PCK . $file)) { $options[] = $file; } } @closedir($fp); foreach ($options as $row) { echo '<option value="' . $row . '">' . $row . '</option>'; } return; }
$dim = array($width, $height); @set_time_limit(0); $original = PCK . $folder . '/'; $gallery = PCK . $folder . '/gallery/'; if (!@file_exists($original)) { exit('No se encuentra > ' . $folder); } if (!@file_exists($gallery)) { @mkdir($gallery, 0777); @chmod($gallery, 0777); } if (!is_writable($original) || !is_writable($gallery)) { die('Error en permisos.'); } $upload = new upload(); $zip = new createZip(); // $fp = @opendir(PCK . $folder); while ($row = @readdir($fp)) { if (preg_match('#^(.*?)\\.(jpg|JPG)$#is', $row, $s) && @is_readable($original . $row)) { $images[] = $row; $type = preg_match('#^(\\d+)$#is', $s[1]) ? 'numeric' : 'string'; $types[$type] = true; } } @closedir($fp); if (!count($images)) { exit('No hay archivos para convertir.'); } $multisort = array(&$images, SORT_ASC); if (!isset($types['string'])) {