コード例 #1
0
ファイル: fun_archive.php プロジェクト: Zhi2014/cogs
function zip_items($dir, $name)
{
    $cnt = count($GLOBALS['__POST']["selitems"]);
    $abs_dir = get_abs_dir($dir);
    $zipfile = new ZipFile();
    for ($i = 0; $i < $cnt; ++$i) {
        $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        if (!$zipfile->add($abs_dir, $selitem)) {
            show_error($selitem . ": Failed adding item.");
        }
    }
    if (!$zipfile->save(get_abs_item($dir, $name))) {
        show_error($name . ": Failed saving zipfile.");
    }
    header("Location: " . make_link("list", $dir, NULL));
}
コード例 #2
0
ファイル: Templates.class.php プロジェクト: habb0/mobbo
 public static function Download($url = 'http://bi0s.hostingsiteforfree.com/uploads/bi0s/mobbo.zip')
 {
     $path = TEMPLATES;
     $patan = explode('/', $url);
     $pates = $patan[5];
     $name = str_replace('.zip', '', $pates);
     $path = $path . $name . '/';
     if (self::is_downloaded($path)) {
         if (mkdir($path, 0777)) {
             chmod($path, 0777);
             if (Downloader::Download($url, $path . $pates)) {
                 if (ZipFile::processUnZip($path . $pates, $path)) {
                     if (unlink($path . $pates)) {
                         return 1;
                     } else {
                         echo ' Erro ao Deletar Pastas..';
                         return 0;
                     }
                 } else {
                     echo 'Erro a Extrair..';
                     return 0;
                 }
             } else {
                 echo 'Erro ao Baixar..';
                 return 0;
             }
         } else {
             echo 'Erro ao Criar Pasta';
             return 0;
         }
     } else {
         echo 'Ja existe?';
     }
     return 0;
 }
コード例 #3
0
/**
 * Minimalistic creator of OASIS OpenDocument
 *
 * @param string $mime desired MIME type
 * @param string $data document content
 *
 * @return string  OASIS OpenDocument data
 *
 * @access  public
 */
function PMA_createOpenDocument($mime, $data)
{
    $zipfile = new ZipFile();
    $zipfile->addFile($mime, 'mimetype');
    $zipfile->addFile($data, 'content.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<office:document-meta ' . 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' . 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" ' . 'office:version="1.0">' . '<office:meta>' . '<meta:generator>phpMyAdmin ' . PMA_VERSION . '</meta:generator>' . '<meta:initial-creator>phpMyAdmin ' . PMA_VERSION . '</meta:initial-creator>' . '<meta:creation-date>' . strftime('%Y-%m-%dT%H:%M:%S') . '</meta:creation-date>' . '</office:meta>' . '</office:document-meta>', 'meta.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<office:document-styles ' . $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">' . '<office:font-face-decls>' . '<style:font-face style:name="Arial Unicode MS"' . ' svg:font-family="\'Arial Unicode MS\'" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Sans1"' . ' svg:font-family="\'DejaVu Sans\'" style:font-pitch="variable"/>' . '<style:font-face style:name="HG Mincho Light J"' . ' svg:font-family="\'HG Mincho Light J\'" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Serif"' . ' svg:font-family="\'DejaVu Serif\'" style:font-family-generic="roman"' . ' style:font-pitch="variable"/>' . '<style:font-face style:name="Thorndale"' . ' svg:font-family="Thorndale" style:font-family-generic="roman"' . ' style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Sans"' . ' svg:font-family="\'DejaVu Sans\'" style:font-family-generic="swiss"' . ' style:font-pitch="variable"/>' . '</office:font-face-decls>' . '<office:styles>' . '<style:default-style style:family="paragraph">' . '<style:paragraph-properties fo:hyphenation-ladder-count="no-limit"' . ' style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging"' . ' style:line-break="strict" style:tab-stop-distance="0.4925in"' . ' style:writing-mode="page"/>' . '<style:text-properties style:use-window-font-color="true"' . ' style:font-name="DejaVu Serif" fo:font-size="12pt" fo:language="en"' . ' fo:country="US" style:font-name-asian="DejaVu Sans1"' . ' style:font-size-asian="12pt" style:language-asian="none"' . ' style:country-asian="none" style:font-name-complex="DejaVu Sans1"' . ' style:font-size-complex="12pt" style:language-complex="none"' . ' style:country-complex="none" fo:hyphenate="false"' . ' fo:hyphenation-remain-char-count="2"' . ' fo:hyphenation-push-char-count="2"/>' . '</style:default-style>' . '<style:style style:name="Standard" style:family="paragraph"' . ' style:class="text"/>' . '<style:style style:name="Text_body" style:display-name="Text body"' . ' style:family="paragraph" style:parent-style-name="Standard"' . ' style:class="text">' . '<style:paragraph-properties fo:margin-top="0in"' . ' fo:margin-bottom="0.0835in"/>' . '</style:style>' . '<style:style style:name="Heading" style:family="paragraph"' . ' style:parent-style-name="Standard" style:next-style-name="Text_body"' . ' style:class="text">' . '<style:paragraph-properties fo:margin-top="0.1665in"' . ' fo:margin-bottom="0.0835in" fo:keep-with-next="always"/>' . '<style:text-properties style:font-name="DejaVu Sans" fo:font-size="14pt"' . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="14pt"' . ' style:font-name-complex="DejaVu Sans1" style:font-size-complex="14pt"/>' . '</style:style>' . '<style:style style:name="Heading_1" style:display-name="Heading 1"' . ' style:family="paragraph" style:parent-style-name="Heading"' . ' style:next-style-name="Text_body" style:class="text"' . ' style:default-outline-level="1">' . '<style:text-properties style:font-name="Thorndale" fo:font-size="24pt"' . ' fo:font-weight="bold" style:font-name-asian="HG Mincho Light J"' . ' style:font-size-asian="24pt" style:font-weight-asian="bold"' . ' style:font-name-complex="Arial Unicode MS"' . ' style:font-size-complex="24pt" style:font-weight-complex="bold"/>' . '</style:style>' . '<style:style style:name="Heading_2" style:display-name="Heading 2"' . ' style:family="paragraph" style:parent-style-name="Heading"' . ' style:next-style-name="Text_body" style:class="text"' . ' style:default-outline-level="2">' . '<style:text-properties style:font-name="DejaVu Serif"' . ' fo:font-size="18pt" fo:font-weight="bold"' . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="18pt"' . ' style:font-weight-asian="bold" style:font-name-complex="DejaVu Sans1"' . ' style:font-size-complex="18pt" style:font-weight-complex="bold"/>' . '</style:style>' . '</office:styles>' . '<office:automatic-styles>' . '<style:page-layout style:name="pm1">' . '<style:page-layout-properties fo:page-width="8.2673in"' . ' fo:page-height="11.6925in" style:num-format="1"' . ' style:print-orientation="portrait" fo:margin-top="1in"' . ' fo:margin-bottom="1in" fo:margin-left="1.25in"' . ' fo:margin-right="1.25in" style:writing-mode="lr-tb"' . ' style:footnote-max-height="0in">' . '<style:footnote-sep style:width="0.0071in"' . ' style:distance-before-sep="0.0398in"' . ' style:distance-after-sep="0.0398in" style:adjustment="left"' . ' style:rel-width="25%" style:color="#000000"/>' . '</style:page-layout-properties>' . '<style:header-style/>' . '<style:footer-style/>' . '</style:page-layout>' . '</office:automatic-styles>' . '<office:master-styles>' . '<style:master-page style:name="Standard" style:page-layout-name="pm1"/>' . '</office:master-styles>' . '</office:document-styles>', 'styles.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<manifest:manifest' . ' xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">' . '<manifest:file-entry manifest:media-type="' . $mime . '" manifest:full-path="/"/>' . '<manifest:file-entry manifest:media-type="text/xml"' . ' manifest:full-path="content.xml"/>' . '<manifest:file-entry manifest:media-type="text/xml"' . ' manifest:full-path="meta.xml"/>' . '<manifest:file-entry manifest:media-type="text/xml"' . ' manifest:full-path="styles.xml"/>' . '</manifest:manifest>', 'META-INF/manifest.xml');
    return $zipfile->file();
}
コード例 #4
0
ファイル: export.php プロジェクト: GDantas05/WorkSeries
    }
    exit;
}
/**
 * Send the dump as a file...
 */
if (!empty($asfile)) {
    // Convert the charset if required.
    if ($output_charset_conversion) {
        $dump_buffer = PMA_convert_string('utf-8', $GLOBALS['charset_of_file'], $dump_buffer);
    }
    // Do the compression
    // 1. as a zipped file
    if ($compression == 'zip') {
        if (@function_exists('gzcompress')) {
            $zipfile = new ZipFile();
            $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
            $dump_buffer = $zipfile->file();
        }
    } elseif ($compression == 'bzip2') {
        // 2. as a bzipped file
        if (@function_exists('bzcompress')) {
            $dump_buffer = bzcompress($dump_buffer);
        }
    } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
        // 3. as a gzipped file
        // without the optional parameter level because it bugs
        $dump_buffer = gzencode($dump_buffer);
    }
    /* If we saved on server, we have to close file now */
    if ($save_on_server) {
コード例 #5
0
ファイル: export.lib.php プロジェクト: pombredanne/ArcherSys
/**
 * Compress the export buffer
 *
 * @param string $dump_buffer the current dump buffer
 * @param string $compression the compression mode
 * @param string $filename    the filename
 *
 * @return object $message a message object (or empty string)
 */
function PMA_compressExport($dump_buffer, $compression, $filename)
{
    if ($compression == 'zip' && @function_exists('gzcompress')) {
        $zipfile = new ZipFile();
        $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
        $dump_buffer = $zipfile->file();
    } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
        // without the optional parameter level because it bugs
        $dump_buffer = gzencode($dump_buffer);
    }
    return $dump_buffer;
}
コード例 #6
0
ファイル: filefolder.class.php プロジェクト: keverage/webftp
 /**
  * Créer un fichier zip
  *
  * @require class zip.class.php
  *
  * @param string $filename     -> Le nom du fichier zip
  * @param array  $files_struct -> La structure de l'archive zip
  * $files_struct = array(
  *                   'file.txt',
  *                   'folder' => array('file_in_folder.txt')
  *                 )
  */
 public static function createZip($filename, $files_struct, $sendHeaders = true)
 {
     // Si la class est instanciée
     if (class_exists('zipfile')) {
         // Si la structure des fichiers est bien un array
         if (is_array($files_struct)) {
             // Initialisation
             $zipfile = new ZipFile();
             // Création de la structure des fichiers/dossiers
             foreach ($files_struct as $folder => $file) {
                 if (is_string($folder)) {
                     $zipfile->createDir($folder);
                     foreach ($file as $file_array) {
                         $handle = fopen($file_array, 'rb');
                         $buffer = fread($handle, filesize($file_array));
                         fclose($handle);
                         $zipfile->createFile($buffer, $folder . '/' . basename($file_array));
                     }
                 } else {
                     $handle = fopen($file, 'rb');
                     $buffer = fread($handle, filesize($file));
                     fclose($handle);
                     $zipfile->createFile($buffer, basename($file));
                 }
             }
             // Création de l'archive
             $archive = $zipfile->zippedFile();
             $open = fopen($filename, 'wb');
             fwrite($open, $archive);
             fclose($open);
             // Si on envoi les headers pour le téléchargement direct
             if ($sendHeaders) {
                 self::sendDownloadHeaders($filename);
                 echo $archive;
             } else {
                 return $archive;
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #7
0
 function getSubClass($fileName, $diskFile)
 {
     //php4 can't list subclasses of class, so we need to add each one here
     require_once "AudioFile.php";
     require_once "ImageFile.php";
     require_once "VideoFile.php";
     require_once "ZipFile.php";
     if (preg_match('/\\.([^.]{2,4}$)/', $fileName, $m)) {
         $ext = strtolower($m[1]);
     } else {
         return "PlainFile";
     }
     if (ImageFile::validateExtension($ext)) {
         return "ImageFile";
     }
     if (ZipFile::validateExtension($ext)) {
         return "ZipFile";
     }
     $audioValid = AudioFile::validateExtension($ext);
     $videoValid = VideoFile::validateExtension($ext);
     if ($audioValid && $videoValid) {
         exec(escapeshellcmd("file " . $diskFile), $out, $ret_error);
         if (preg_match("/video/", $out[0]) || preg_match("/movie/", $out[0])) {
             return "VideoFile";
         } else {
             return "AudioFile";
         }
     }
     if ($audioValid) {
         return "AudioFile";
     }
     if ($videoValid) {
         return "VideoFile";
     }
     return "PlainFile";
 }
コード例 #8
0
 /**
  * Uncompresses a gzipped file
  *
  * @param 	string 		$gzipped
  * @param 	string 		$destination
  * @return 	boolean 	result
  */
 public static function uncompressFile($gzipped, $destination)
 {
     if (!@is_file($gzipped)) {
         return false;
     }
     $sourceFile = new ZipFile($gzipped, 'rb');
     $filesize = $sourceFile->getFileSize();
     $targetFile = new File($destination);
     while (!$sourceFile->eof()) {
         $targetFile->write($sourceFile->read(512), 512);
     }
     $targetFile->close();
     $sourceFile->close();
     @$targetFile->chmod(0777);
     if ($filesize != filesize($destination)) {
         @unlink($destination);
         return false;
     }
     return true;
 }
コード例 #9
0
ファイル: Releases.php プロジェクト: sebst3r/nZEDb
 /**
  * @param $guids
  *
  * @return string
  */
 public function getZipped($guids)
 {
     $nzb = new NZB($this->pdo);
     $zipFile = new \ZipFile();
     foreach ($guids as $guid) {
         $nzbPath = $nzb->NZBPath($guid);
         if ($nzbPath) {
             $nzbContents = Utility::unzipGzipFile($nzbPath);
             if ($nzbContents) {
                 $filename = $guid;
                 $r = $this->getByGuid($guid);
                 if ($r) {
                     $filename = $r['searchname'];
                 }
                 $zipFile->addFile($nzbContents, $filename . '.nzb');
             }
         }
     }
     return $zipFile->file();
 }
コード例 #10
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // test compression
     $file = new File($this->fileName, 'rb');
     if ($file->read(2) == "‹") {
         $this->isGzip = true;
         $zipFile = new ZipFile($this->fileName, 'rb');
         $this->fileSize = $zipFile->getFileSize();
     } else {
         $this->fileSize = filesize($this->fileName);
     }
     $file->close();
     $this->dbName = WCF::getDB()->getDatabaseName();
     // build session data array
     $sessionData = array();
     $sessionData['isGzip'] = $this->isGzip;
     $sessionData['extendedCommand'] = '';
     $sessionData['importFile'] = $this->fileName;
     $sessionData['isTmpFile'] = $this->isTmpFile;
     $sessionData['ignoreErrors'] = $this->ignoreErrors;
     $sessionData['offset'] = 0;
     $sessionData['errors'] = array('messages' => array(), 'errorDescriptions' => array());
     $sessionData['tableErrors'] = array();
     $sessionData['commandCount'] = 0;
     $sessionData['wcfCharset'] = WCF::getDB()->getCharset();
     $sessionData['importCharset'] = '';
     $sessionData['filesize'] = $this->fileSize;
     $sessionData['remain'] = $sessionData['count'] = $this->fileSize;
     WCF::getSession()->register('databaseImportData', $sessionData);
     $this->saved();
     WCF::getTPL()->assign(array('pageTitle' => WCF::getLanguage()->get('wcf.acp.db.import.pageHeadline'), 'url' => 'index.php?action=DatabaseImport&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED, 'progress' => 0));
     WCF::getTPL()->display('worker');
     exit;
 }
コード例 #11
0
 /**
  *	Export Skin XML
  *	Export the skin files in XML
  *
  *	@param	string	XML File name
  *	@param	array	Skin key
  *	@param	array	Skin set
  *	@param	boolean	Download file
  *	@param	string	File compress (default -> gzip)
  *	@param	array	Force codekey
  *	@return	string	XML content
  */
 public function ExportXML($xml_file, $skin_key, $skin_set, $download = FALSE, $compress = "gzip", $force_codekey = array())
 {
     set_time_limit(0);
     ini_set("memory_limit", 128000000);
     $set_files = array();
     $css_files = array();
     $img_files = array();
     $rsc_files = array();
     $count_set = 0;
     $count_css = 0;
     $count_img = 0;
     $count_rsc = 0;
     parent::Lib('Sources')->OpenDatabase();
     parent::Lib('Sources')->GetSkin($skin_key, $skin_info);
     parent::Lib('Sources')->CloseDatabase();
     foreach ($skin_set as $key) {
         $all_files = array();
         parent::Lib('Database')->OpenDatabase($skin_key, $key);
         parent::Lib('Database')->GetAllFiles($all_files);
         parent::Lib('Database')->CloseDatabase();
         $_files = array();
         $_count = 0;
         foreach ($all_files as $name => $content) {
             $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
             $_files['template#:' . $_count++] = array("a:hash" => md5($content), "filename" => $name, "content" => "<![CDATA[" . str_replace(array("<![CDATA[", "]]>"), array("<!#^#|CDATA|", "|#^#]>"), $content) . "]]>");
         }
         $set_files['skin_set#:' . $count_set++] = array("name" => $key, "files" => $_files);
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_css/" . $skin_key)) {
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_css/" . $skin_key)) > 0) {
             $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                     if ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $css_files['css_file#:' . $count_css++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_images/" . $skin_key)) {
         $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_images/" . $skin_key)) > 0) {
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false) {
                     if ($fileinfo->isDir() == true) {
                         $my_array = $this->loadExporterSetDirectory("images_folder", "image_file", $fileinfo->getPathname());
                         $key_array = array("a:name" => $fileinfo->getFilename());
                         $img_files['images_folder#:' . $count_img++] = array_merge($key_array, $my_array);
                     } elseif ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $img_files['image_file#:' . $count_img++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_resources/" . $skin_key)) {
         $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_resources/" . $skin_key)) > 0) {
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false) {
                     if ($fileinfo->isDir() == true) {
                         $my_array = $this->loadExporterSetDirectory("resources_folder", "resource_file", $fileinfo->getPathname(), 1);
                         $key_array = array("a:name" => $fileinfo->getFilename());
                         $rsc_files['resources_folder#:' . $count_rsc++] = array_merge($key_array, $my_array);
                     } elseif ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $rsc_files['resource_file#:' . $count_rsc++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     $_xml_inf = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_info" => array("skin_name" => $skin_info['Name'], "skin_key" => $skin_key, "skin_codekey" => $this->loadGenerateCodeKey($skin_key, $skin_info['Name'], $skin_info['CodeKey'], $force_codekey), "skin_author" => array("name" => $skin_info['Author']['Name'], "site" => $skin_info['Author']['Site']))));
     $_xml_set = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_templates" => $set_files));
     $_xml_css = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_css" => $css_files));
     $_xml_img = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_images" => $img_files));
     $_xml_rsc = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_resources" => $rsc_files));
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_inf, false, $xml_inf);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_set, false, $xml_set);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_css, false, $xml_css);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_img, false, $xml_img);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_rsc, false, $xml_rsc);
     $spaces = chr(9) . chr(9);
     $skin_info = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_inf, "skin_info"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_templates = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_set, "skin_set"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_css = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_css, "skin_css"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_images = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_img, "skin_images"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_resources = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_rsc, "skin_resources"), 80, "\n" . $spaces), "\n" . $spaces);
     $xml = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_info" => "\n" . $skin_info . "\n" . substr($spaces, 1), "skin_templates" => "\n" . $skin_templates . "\n" . substr($spaces, 1), "skin_css" => "\n" . $skin_css . "\n" . substr($spaces, 1), "skin_images" => "\n" . $skin_images . "\n" . substr($spaces, 1), "skin_resources" => "\n" . $skin_resources . "\n" . substr($spaces, 1)));
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $xml, false, $xml_source);
     if ($download == true) {
         if ($compress == "gzip" && function_exists("gzencode")) {
             $down_source = gzencode($xml_source, 9);
             $down_suffix = ".gz";
         } elseif ($compress == "zip" && (class_exists("ZipArchive") || class_exists("ZipFile"))) {
             if (!class_exists("ZipArchive")) {
                 $zip = new ZipArchive();
                 $zip->open($filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "template__kernel::" . time() . "__zip") . ".tmp", ZipArchive::CREATE);
                 $zip->addFromString(self::TEMPLATE_ENGINE_EXPORT_FILE, $xml_source);
                 $zip->close();
                 $down_source = file_get_contents($filepath);
                 unlink($filepath);
             } else {
                 $zip = new ZipFile();
                 $zip->addFile($xml_source, self::TEMPLATE_ENGINE_EXPORT_FILE);
                 $down_source = $zip->file();
             }
             $down_suffix = ".zip";
         } else {
             $down_source = $xml_source;
             $down_suffix = NULL;
         }
         $length = strlen($down_source) + 3;
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: public");
         header("Content-Description: File Transfer");
         header("Content-type: application/octet-stream");
         header("Content-Disposition: attachment; filename=\"" . $xml_file . ".xml" . $down_suffix . "\"");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $length);
         ob_end_flush();
         ob_end_clean();
         exit($down_source);
     }
     return $xml_source;
 }
コード例 #12
0
ファイル: analysis.php プロジェクト: ADMTec/effectweb-project
 /**
  *	Private: System Logs
  *	View and manage the system's logs
  *
  *	@return	void
  */
 private function loadSystemLogs()
 {
     if (!empty($_GET['load_file']) && !empty($_GET['folder'])) {
         if (array_key_exists($_GET['folder'], $this->logs_folders)) {
             $folder = $this->logs_folders[$_GET['folder']][0];
             $file = $folder . "-(" . str_replace(EW_LOG_EXT, NULL, $_GET['load_file']) . ")" . EW_LOG_EXT;
             $_GET['load_file'] = urldecode($_GET['load_file']);
             $GLOBALS['file_exists'] = file_exists(EW_LOG_PATH . $folder . "/" . $_GET['load_file']);
             if ($GLOBALS['file_exists'] == true) {
                 $GLOBALS['log_file_content'] = file_get_contents(EW_LOG_PATH . $folder . "/" . $_GET['load_file']);
             }
             if ($_GET['do'] == "download") {
                 if ($GLOBALS['file_exists'] == true) {
                     if (CTM_ACP_USE_ZIP == "gzip") {
                         showFileDownload($file . ".gz", gzencode($GLOBALS['log_file_content'], 9));
                     } elseif (CTM_ACP_USE_ZIP == "zip") {
                         if (class_exists("ZipArchive")) {
                             $zip = new ZipArchive();
                             $zip->open($filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp", ZipArchive::CREATE);
                             $zip->addFile(EW_LOG_PATH . $folder . "/" . $_GET['load_file'], $_GET['load_file']);
                             $zip->close();
                             $content = file_get_contents($filepath);
                             unlink($filepath);
                         } else {
                             $zip = new ZipFile();
                             $zip->addFile($GLOBALS['log_file_content'], $_GET['load_file'], filemtime(EW_LOG_PATH . $log . "/" . $filename));
                             $content = $zip->file();
                         }
                         showFileDownload($file . ".zip", $content);
                     } else {
                         showFileDownload($file, $GLOBALS['log_file_content']);
                     }
                 }
             } elseif ($_GET['do'] == "delete") {
                 if ($GLOBALS['file_exists'] == true) {
                     if (!unlink(EW_LOG_PATH . $folder . "/" . $_GET['load_file'])) {
                         $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['ShowLogs']['Messages']['DeleteError'];
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                     } else {
                         $url = "?app=core&module=system&section=analysis&index=logs&load_folder=" . $_GET['folder'] . "&message=file_deleted";
                         header("Location: " . CTM_URLEngine::URLBase() . $url);
                         exit;
                     }
                 }
             }
             $this->lang->setArguments("System,Analysis,SystemLogs,ShowLogs,Title", $_GET['load_file']);
             return $this->output->setContent("analysis_logsShowFile");
         } else {
             header("Location: " . CTM_URLEngine::URLBase() . "?app=core&module=system&section=analysis&index=logs");
         }
     } elseif (!empty($_GET['load_folder'])) {
         if (array_key_exists($_GET['load_folder'], $this->logs_folders)) {
             $log = $this->logs_folders[$_GET['load_folder']][0];
             if (!file_exists(EW_LOG_PATH . $log)) {
                 mkdir(EW_LOG_PATH . $log);
                 $GLOBALS['logs_files'] = array();
             } else {
                 if ($_GET['do'] == true) {
                     if ($_POST['DoCommand'] == "deleteFiles") {
                         $count = 0;
                         if (count($_POST) > 0) {
                             foreach ($_POST as $key => $value) {
                                 if (substr($key, 0, 6) == "file__" && $value == 1) {
                                     $file = substr($key, 6);
                                     $file = str_replace("_" . substr(EW_LOG_EXT, 1), EW_LOG_EXT, $file);
                                     if (file_exists(EW_LOG_PATH . $log . "/" . $file)) {
                                         unlink(EW_LOG_PATH . $log . "/" . $file);
                                         $count++;
                                     }
                                 }
                             }
                         }
                         $GLOBALS['result_command'] = sprintf($this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['FilesDeleted'], $count);
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                     } elseif ($_POST['DoCommand'] == "downloadFiles") {
                         $files_to_download = array();
                         if (count($_POST) > 0) {
                             foreach ($_POST as $key => $value) {
                                 if (substr($key, 0, 6) == "file__" && $value == 1) {
                                     $file = substr($key, 6);
                                     $file = str_replace("_" . substr(EW_LOG_EXT, 1), EW_LOG_EXT, $file);
                                     if (file_exists(EW_LOG_PATH . $log . "/" . $file)) {
                                         $files_to_download[] = $file;
                                     }
                                 }
                             }
                         }
                         if (count($files_to_download) == 0) {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['SelectFiles'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                         } else {
                             if (class_exists("ZipArchive")) {
                                 $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp";
                                 $zip = new ZipArchive();
                                 $zip->open($filepath, ZipArchive::CREATE);
                             } else {
                                 $zip = new ZipFile();
                             }
                             foreach ($files_to_download as $filename) {
                                 if (class_exists("ZipArchive")) {
                                     $zip->addFile(EW_LOG_PATH . $log . "/" . $filename, $filename);
                                 } else {
                                     $content = file_get_contents(EW_LOG_PATH . $log . "/" . $filename);
                                     $time = filemtime(EW_LOG_PATH . $log . "/" . $filename);
                                     $zip->addFile($content, $filename, $time);
                                 }
                             }
                             if (class_exists("ZipArchive")) {
                                 $zip->close();
                                 $content = file_get_contents($filepath);
                                 unlink($filepath);
                             } else {
                                 $content = $zip->file();
                             }
                             showFileDownload($log . "_Logs.zip", $content);
                         }
                     } else {
                         $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['SelectAction'];
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                     }
                 }
                 $GLOBALS['logs_files'] = array();
                 if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $log)) > 0) {
                     foreach ($iterator as $fileinfo) {
                         if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                             $extension = strrpos($fileinfo->getFilename(), ".");
                             $extension = substr($fileinfo->getFilename(), $extension);
                             if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) {
                                 $GLOBALS['logs_files'][$fileinfo->getFilename()] = array("change_data" => date("d/m/Y - H:i:s", $fileinfo->getMTime()), "file_size" => realFormatBytes($fileinfo->getSize()));
                             }
                         }
                     }
                 }
             }
             $this->lang->setArguments("System,Analysis,SystemLogs,CategoryLogs,Title", $this->logs_folders[$_GET['load_folder']][1]);
             return $this->output->setContent("analysis_logsFiles");
         } else {
             header("Location: " . CTM_URLEngine::URLBase() . "?app=core&module=system&section=analysis&index=logs");
         }
     } else {
         if ($_GET['do_folder'] == true) {
             if ($_POST['DoCommand'] != "clearFolders" && $_POST['DoCommand'] != "downloadFolders") {
                 $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectAction'];
                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
             } elseif ($_POST['DoCommand'] == "clearFolders") {
                 $folders_count = 0;
                 $files_count = 0;
                 $select_count = 0;
                 foreach ($_POST as $key => $value) {
                     if (substr($key, 0, 8) == "folder__" && $value == 1) {
                         $folder = substr($key, 8);
                         $tmp_count = 0;
                         $select_count++;
                         if (array_key_exists($folder, $this->logs_folders)) {
                             $folder = $this->logs_folders[substr($key, 8)][0];
                             if (!file_exists(EW_LOG_PATH . $folder)) {
                                 mkdir(EW_LOG_PATH . $folder);
                             }
                             if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $folder)) > 0) {
                                 foreach ($iterator as $fileinfo) {
                                     if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                                         $extension = strrpos($fileinfo->getFilename(), ".");
                                         $extension = substr($fileinfo->getFilename(), $extension);
                                         if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) {
                                             unlink(EW_LOG_PATH . $folder . "/" . $fileinfo->getFilename());
                                             $files_count++;
                                             $tmp_count++;
                                         }
                                     }
                                 }
                             }
                             if ($tmp_count > 0) {
                                 $folders_count++;
                             }
                         }
                     }
                 }
                 if ($select_count == 0) {
                     $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectFolders'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                 } else {
                     $this->lang->setTags("System,Analysis,SystemLogs,DoCommand,Messages,FoldersCleaned", $files_count, $folders_count);
                     $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['FoldersCleaned'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                 }
             } elseif ($_POST['DoCommand'] == "downloadFolders") {
                 $folders_to_download = array();
                 $select_count = 0;
                 foreach ($_POST as $key => $value) {
                     if (substr($key, 0, 8) == "folder__" && $value == 1) {
                         $folder = substr($key, 8);
                         $select_count++;
                         if (array_key_exists($folder, $this->logs_folders)) {
                             $folder = $this->logs_folders[substr($key, 8)][0];
                             $folders_to_download[$folder] = array();
                             if (!file_exists(EW_LOG_PATH . $folder)) {
                                 mkdir(EW_LOG_PATH . $folder);
                             }
                             if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $folder)) > 0) {
                                 foreach ($iterator as $fileinfo) {
                                     if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                                         $extension = strrpos($fileinfo->getFilename(), ".");
                                         $extension = substr($fileinfo->getFilename(), $extension);
                                         if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) {
                                             $folders_to_download[$folder][$fileinfo->getFilename()] = $fileinfo->getMTime();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($select_count == 0) {
                     $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectFolders'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                 } else {
                     if (class_exists("ZipArchive")) {
                         $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp";
                         $zip = new ZipArchive();
                         $zip->open($filepath, ZipArchive::CREATE);
                     } else {
                         $zip = new ZipFile();
                     }
                     foreach ($folders_to_download as $folder => $files) {
                         if (class_exists("ZipArchive")) {
                             $zip->addEmptyDir($folder);
                         } else {
                             $zip->addFile(NULL, $folder . "/");
                         }
                         if (count($files) > 0) {
                             foreach ($files as $filename => $filetime) {
                                 if (class_exists("ZipArchive")) {
                                     $zip->addFile(EW_LOG_PATH . $folder . "/" . $filename, $folder . "/" . $filename);
                                 } else {
                                     $content = file_get_contents(EW_LOG_PATH . $folder . "/" . $filename);
                                     $zip->addFile($content, $folder . "/" . $filename, $filetime);
                                 }
                             }
                         }
                     }
                     if (class_exists("ZipArchive")) {
                         $zip->close();
                         $content = file_get_contents($filepath);
                         unlink($filepath);
                     } else {
                         $content = $zip->file();
                     }
                     showFileDownload(sprintf($this->logs_zip_file['name'], date($this->logs_zip_file['date'])) . ".zip", $content);
                 }
             }
         }
         foreach ($this->logs_folders as $key => $value) {
             $GLOBALS['logs_folders'][$key] = array("name" => $value[1], "count_files" => number_format(intval(count(glob(EW_LOG_PATH . $value[0] . "/*" . EW_LOG_EXT))), 0, false, "."));
         }
         $this->output->setContent("analysis_logs");
         if (loadIsAjax() == true) {
             $this->output->setVariable("no_set_tmp", true);
         }
     }
 }
コード例 #13
0
 public static function getImagesZipPack(&$images)
 {
     require_once 'zip.lib.php';
     $zip = new ZipFile(true);
     foreach ($images as $url => &$image) {
         if ($image) {
             $fileName = basename($url);
             $zip->addFile($image, $fileName);
         }
     }
     return $zip->file();
 }
コード例 #14
0
function make_zip(&$imgs_and_urls)
{
    require_once 'zip.lib.php';
    $zip = new ZipFile();
    foreach ($imgs_and_urls['valid_images'] as $url => $img) {
        $zip->addFile($img, basename($url));
    }
    if ($imgs_and_urls['invalid_image_urls']) {
        $msg = "images list below cannot be found: \r\n";
        $msg .= implode("\r\n", $imgs_and_urls['invalid_image_urls']);
        $zip->addFile($msg, 'failed_list.txt');
    }
    return $zip->file();
}
コード例 #15
0
 /**
  * Download all media attached to specified object (not necessarily open for editing)
  * Includes all representation media attached to the specified object + any media attached to oter
  * objects in the same object hierarchy as the specified object. Used by the book viewer interfacce to 
  * initiate a download.
  */
 public function DownloadMedia($pa_options = null)
 {
     list($vn_subject_id, $t_subject) = $this->_initView();
     $pn_representation_id = $this->request->getParameter('representation_id', pInteger);
     $pn_value_id = $this->request->getParameter('value_id', pInteger);
     if ($pn_value_id) {
         //print_R($_REQUEST); die;
         return $this->DownloadAttributeMedia();
     }
     $ps_version = $this->request->getParameter('version', pString);
     if (!$vn_subject_id) {
         return;
     }
     $o_view = new View($this->request, $this->request->getViewsDirectoryPath() . '/bundles/');
     if (!$ps_version) {
         $ps_version = 'original';
     }
     $o_view->setVar('version', $ps_version);
     $va_ancestor_ids = $t_subject->isHierarchical() ? $t_subject->getHierarchyAncestors(null, array('idsOnly' => true, 'includeSelf' => true)) : array($vn_subject_id);
     if ($vn_parent_id = array_pop($va_ancestor_ids)) {
         $t_subject->load($vn_parent_id);
         array_unshift($va_ancestor_ids, $vn_parent_id);
     }
     $va_child_ids = $t_subject->isHierarchical() ? $t_subject->getHierarchyChildren(null, array('idsOnly' => true)) : array($vn_subject_id);
     foreach ($va_ancestor_ids as $vn_id) {
         array_unshift($va_child_ids, $vn_id);
     }
     $vn_c = 1;
     $va_file_names = array();
     $va_file_paths = array();
     foreach ($va_child_ids as $vn_child_id) {
         if (!$t_subject->load($vn_child_id)) {
             continue;
         }
         if ($t_subject->tableName() == 'ca_object_representations') {
             $va_reps = array($vn_child_id => array('representation_id' => $vn_child_id, 'info' => array($ps_version => $t_subject->getMediaInfo('media', $ps_version))));
         } else {
             $va_reps = $t_subject->getRepresentations(array($ps_version));
         }
         $vs_idno = $t_subject->get('idno');
         foreach ($va_reps as $vn_representation_id => $va_rep) {
             if ($pn_representation_id && $pn_representation_id != $vn_representation_id) {
                 continue;
             }
             $va_rep_info = $va_rep['info'][$ps_version];
             $vs_idno_proc = preg_replace('![^A-Za-z0-9_\\-]+!', '_', $vs_idno);
             switch ($this->request->user->getPreference('downloaded_file_naming')) {
                 case 'idno':
                     $vs_file_name = $vs_idno_proc . '_' . $vn_c . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'idno_and_version':
                     $vs_file_name = $vs_idno_proc . '_' . $ps_version . '_' . $vn_c . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'idno_and_rep_id_and_version':
                     $vs_file_name = $vs_idno_proc . '_representation_' . $vn_representation_id . '_' . $ps_version . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'original_name':
                 default:
                     if ($va_rep['info']['original_filename']) {
                         $va_tmp = explode('.', $va_rep['info']['original_filename']);
                         if (sizeof($va_tmp) > 1) {
                             if (strlen($vs_ext = array_pop($va_tmp)) < 3) {
                                 $va_tmp[] = $vs_ext;
                             }
                         }
                         $vs_file_name = join('_', $va_tmp);
                     } else {
                         $vs_file_name = $vs_idno_proc . '_representation_' . $vn_representation_id . '_' . $ps_version;
                     }
                     if (isset($va_file_names[$vs_file_name . '.' . $va_rep_info['EXTENSION']])) {
                         $vs_file_name .= "_{$vn_c}";
                     }
                     $vs_file_name .= '.' . $va_rep_info['EXTENSION'];
                     break;
             }
             $va_file_names[$vs_file_name] = true;
             $o_view->setVar('version_download_name', $vs_file_name);
             //
             // Perform metadata embedding
             $t_rep = new ca_object_representations($va_rep['representation_id']);
             if (!($vs_path = caEmbedMetadataIntoRepresentation($t_subject, $t_rep, $ps_version))) {
                 $vs_path = $t_rep->getMediaPath('media', $ps_version);
             }
             $va_file_paths[$vs_path] = $vs_file_name;
             $vn_c++;
         }
     }
     if (sizeof($va_file_paths) > 1) {
         if (!($vn_limit = ini_get('max_execution_time'))) {
             $vn_limit = 30;
         }
         set_time_limit($vn_limit * 2);
         $o_zip = new ZipFile();
         foreach ($va_file_paths as $vs_path => $vs_name) {
             $o_zip->addFile($vs_path, $vs_name, null, array('compression' => 0));
             // don't try to compress
         }
         $o_view->setVar('archive_path', $vs_path = $o_zip->output(ZIPFILE_FILEPATH));
         $o_view->setVar('archive_name', preg_replace('![^A-Za-z0-9\\.\\-]+!', '_', $t_subject->get('idno')) . '.zip');
         $this->response->addContent($o_view->render('download_media_binary.php'));
         if ($vs_path) {
             unlink($vs_path);
         }
     } else {
         foreach ($va_file_paths as $vs_path => $vs_name) {
             $o_view->setVar('archive_path', $vs_path);
             $o_view->setVar('archive_name', $vs_name);
         }
         $this->response->addContent($o_view->render('download_media_binary.php'));
     }
 }
コード例 #16
0
 public function getCode($arr)
 {
     $ModelPHPCode = "";
     $ControllerPHPCode = "";
     $zipfile = new ZipFile();
     foreach ($arr as $k => $v) {
         ## MODEL Class
         $ModelPHPCode = "";
         $ModelPHPCode .= "<" . "?php\r\n";
         $ModelPHPCode .= "/*\r\n\t@PHPClassCreator [Doctrine + CodeIgniter]\r\n\t@Autor: Esteban Fuentealba\r\n\t@Email:\tmi [dot] warezx [at] gmail [dot] com\r\n*/\r\n";
         $ModelPHPCode .= "// models/" . $v['class']['name'] . ".php\r\n";
         $ModelPHPCode .= "class " . $v['class']['name'] . " extends Doctrine_Record {\r\n";
         ## setTableDefinition
         $ModelPHPCode .= "\tpublic function setTableDefinition() {\r\n";
         foreach ($v['class']['method']['setTableDefinition'] as $index => $valor) {
             $ModelPHPCode .= "\t\t" . $valor . "\r\n";
         }
         $ModelPHPCode .= "\t}\r\n";
         ## setUp
         $ModelPHPCode .= "\tpublic function setUp() {\r\n";
         foreach ($v['class']['method']['setUp'] as $index => $valor) {
             foreach ($valor as $key => $val) {
                 $ModelPHPCode .= "\t\t" . $val . "\r\n";
             }
         }
         $ModelPHPCode .= "\t}\r\n";
         $ModelPHPCode .= "}\r\n";
         if ($this->debug) {
             echo $ModelPHPCode;
         } else {
             $zipfile->add_file($ModelPHPCode, "system/application/models/" . $v['class']['name'] . ".php");
         }
         ## FIN CLASS MODEL
         ## CONTROLLER MODEL
         $ControllerPHPCode = "";
         $ControllerPHPCode .= "<" . "?php\r\n";
         $ControllerPHPCode .= "/*\r\n\t@PHPClassCreator [Doctrine + CodeIgniter]\r\n\t@Autor: Esteban Fuentealba\r\n\t@Email:\tmi [dot] warezx [at] gmail [dot] com\r\n*/\r\n";
         $ControllerPHPCode .= "// system/application/controllers/" . $v['class']['name'] . "Controller.php\r\n";
         $ControllerPHPCode .= "require_once(dirname(__FILE__) .'/KoalaController.class.php');\r\n";
         $ControllerPHPCode .= "class " . $v['class']['name'] . "Controller extends KoalaController {\r\n";
         ## CONSTRUCTOR
         $ControllerPHPCode .= "\tpublic function __construct() {\r\n";
         $ControllerPHPCode .= "\t\tparent::Controller();\r\n";
         $ControllerPHPCode .= "\t\tparse_str(\$" . "_SERVER['QUERY_STRING'],\$" . "_GET);\r\n";
         $ControllerPHPCode .= "\t}\r\n";
         ## METHOD INSERT
         $ControllerPHPCode .= "\tpublic function Insert() {\r\n";
         $ControllerPHPCode .= "\t\t\$" . "clean = \$" . "this->input->xss_clean(\$" . "_GET);\r\n";
         $ControllerPHPCode .= "\t\t\$" . "c = new " . $v['class']['name'] . "();\r\n";
         $ControllerPHPCode .= "\t\ttry {\r\n";
         $ControllerPHPCode .= "\t\t\tforeach(\$" . "clean as \$" . "param => \$" . "value) {\r\n";
         $ControllerPHPCode .= "\t\t\t\t\$" . "c->\$" . "param = isset(\$" . "value) ? \$" . "value : null;\r\n";
         $ControllerPHPCode .= "\t\t\t}\r\n";
         $ControllerPHPCode .= "\t\t} catch(Doctrine_Record_UnknownPropertyException \$" . "e) {\r\n";
         $ControllerPHPCode .= "\t\t\t//xD\r\n";
         $ControllerPHPCode .= "\t\t}\r\n";
         $ControllerPHPCode .= "\t\ttry {\r\n";
         $ControllerPHPCode .= "\t\t\tforeach(\$" . "clean as \$" . "param => \$" . "value) {\r\n";
         $ControllerPHPCode .= "\t\t\t\t\$" . "c->\$" . "param = isset(\$" . "value) ? \$" . "value : null;\r\n";
         $ControllerPHPCode .= "\t\t\t}\r\n";
         $ControllerPHPCode .= "\t\t} catch(Doctrine_Record_UnknownPropertyException \$" . "e) {\r\n";
         $ControllerPHPCode .= "\t\t\t//xD\r\n";
         $ControllerPHPCode .= "\t\t}\r\n";
         $ControllerPHPCode .= "\t}\r\n";
         $ControllerPHPCode .= "}\r\n";
         ## FIN CONTROLLER MODEL
         if ($this->debug) {
             echo $ControllerPHPCode;
         } else {
             $zipfile->add_file($ControllerPHPCode, "system/application/models/" . $v['class']['name'] . "Controller.php");
         }
     }
     if (!$this->debug) {
         header("Content-type: application/octet-stream");
         header("Content-disposition: attachment; filename=PHPClassCreator-" . time() . ".zip");
         echo $zipfile->file();
     }
 }
コード例 #17
0
 /**
  * Download all media attached to specified object (not necessarily open for editing)
  * Includes all representation media attached to the specified object + any media attached to oter
  * objects in the same object hierarchy as the specified object. Used by the book viewer interfacce to 
  * initiate a download.
  */
 public function DownloadMedia()
 {
     if (!caObjectsDisplayDownloadLink($this->request)) {
         $this->postError(1100, _t('Cannot download media'), 'DetailController->DownloadMedia');
         return;
     }
     $pn_object_id = $this->request->getParameter('object_id', pInteger);
     $t_object = new ca_objects($pn_object_id);
     if (!($vn_object_id = $t_object->getPrimaryKey())) {
         return;
     }
     $ps_version = $this->request->getParameter('version', pString);
     if (!$ps_version) {
         $ps_version = 'original';
     }
     $this->view->setVar('version', $ps_version);
     $va_ancestor_ids = $t_object->getHierarchyAncestors(null, array('idsOnly' => true, 'includeSelf' => true));
     if ($vn_parent_id = array_pop($va_ancestor_ids)) {
         $t_object->load($vn_parent_id);
         array_unshift($va_ancestor_ids, $vn_parent_id);
     }
     $va_child_ids = $t_object->getHierarchyChildren(null, array('idsOnly' => true));
     foreach ($va_ancestor_ids as $vn_id) {
         array_unshift($va_child_ids, $vn_id);
     }
     $vn_c = 1;
     $va_file_names = array();
     $va_file_paths = array();
     foreach ($va_child_ids as $vn_object_id) {
         $t_object = new ca_objects($vn_object_id);
         if (!$t_object->getPrimaryKey()) {
             continue;
         }
         $va_reps = $t_object->getRepresentations(array($ps_version));
         $vs_idno = $t_object->get('idno');
         foreach ($va_reps as $vn_representation_id => $va_rep) {
             $va_rep_info = $va_rep['info'][$ps_version];
             $vs_idno_proc = preg_replace('![^A-Za-z0-9_\\-]+!', '_', $vs_idno);
             switch ($this->request->user->getPreference('downloaded_file_naming')) {
                 case 'idno':
                     $vs_file_name = $vs_idno_proc . '_' . $vn_c . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'idno_and_version':
                     $vs_file_name = $vs_idno_proc . '_' . $ps_version . '_' . $vn_c . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'idno_and_rep_id_and_version':
                     $vs_file_name = $vs_idno_proc . '_representation_' . $vn_representation_id . '_' . $ps_version . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'original_name':
                 default:
                     if ($va_rep['info']['original_filename']) {
                         $va_tmp = explode('.', $va_rep['info']['original_filename']);
                         if (sizeof($va_tmp) > 1) {
                             if (strlen($vs_ext = array_pop($va_tmp)) < 3) {
                                 $va_tmp[] = $vs_ext;
                             }
                         }
                         $vs_file_name = join('_', $va_tmp);
                     } else {
                         $vs_file_name = $vs_idno_proc . '_representation_' . $vn_representation_id . '_' . $ps_version;
                     }
                     if (isset($va_file_names[$vs_file_name . '.' . $va_rep_info['EXTENSION']])) {
                         $vs_file_name .= "_{$vn_c}";
                     }
                     $vs_file_name .= '.' . $va_rep_info['EXTENSION'];
                     break;
             }
             $va_file_names[$vs_file_name] = true;
             $this->view->setVar('version_download_name', $vs_file_name);
             //
             // Perform metadata embedding
             $t_rep = new ca_object_representations($va_rep['representation_id']);
             if (!($vs_path = caEmbedMetadataIntoRepresentation($t_object, $t_rep, $ps_version))) {
                 $vs_path = $t_rep->getMediaPath('media', $ps_version);
             }
             $va_file_paths[$vs_path] = $vs_file_name;
             $vn_c++;
         }
     }
     if (sizeof($va_file_paths) > 1) {
         if (!($vn_limit = ini_get('max_execution_time'))) {
             $vn_limit = 30;
         }
         set_time_limit($vn_limit * 2);
         $o_zip = new ZipFile();
         foreach ($va_file_paths as $vs_path => $vs_name) {
             $o_zip->addFile($vs_path, $vs_name, null, array('compression' => 0));
             // don't try to compress
         }
         $this->view->setVar('archive_path', $vs_path = $o_zip->output(ZIPFILE_FILEPATH));
         $this->view->setVar('archive_name', preg_replace('![^A-Za-z0-9\\.\\-]+!', '_', $t_object->get('idno')) . '.zip');
         $this->response->sendHeaders();
         $vn_rc = $this->render('Details/object_download_media_binary.php');
         $this->response->sendContent();
         if ($vs_path) {
             unlink($vs_path);
         }
     } else {
         foreach ($va_file_paths as $vs_path => $vs_name) {
             $this->view->setVar('archive_path', $vs_path);
             $this->view->setVar('archive_name', $vs_name);
         }
         $this->response->sendHeaders();
         $vn_rc = $this->render('Details/object_download_media_binary.php');
         $this->response->sendContent();
     }
     return $vn_rc;
 }
コード例 #18
0
 /**
  * ZIPアーカイブを解析し、ファイルの矯正を行います。
  * @param \SplFileInfo $file
  * @throws SyntaxException
  * @return \SplFileInfo
  */
 protected function parseArchive(\SplFileInfo $file) : \SplFileInfo
 {
     $archive = new ZipOutputFile(ZipFile::openFromFile($file instanceof \SplTempFileObject ? $this->generateTempFile($file) : $file->getRealPath()));
     $this->correctArchiveFilenamesEncoding($archive);
     $this->flattenArchive($archive);
     $this->filenames = $this->correctArchiveFilenames($archive);
     $tempDirectoryPath = (new GenericDictionaryParser())->generateTempDirectory();
     $archive->extractTo($tempDirectoryPath);
     $archive->close();
     $validator = new \esperecyan\dictionary_php\Validator();
     $validator->setLogger($this->logger);
     foreach (new \FilesystemIterator($tempDirectoryPath, \FilesystemIterator::KEY_AS_FILENAME) as $filename => $file) {
         if ($file->getExtension() === 'txt') {
             if (isset($quizFile)) {
                 throw new SyntaxException(_('拡張子が「.txt」のファイルが2つ以上含まれています。'));
             }
             if (!in_array((new Finfo(FILEINFO_MIME_TYPE))->file($file), ['text/plain', 'text/csv'])) {
                 throw new SyntaxException(sprintf(_('「%s」は通常のテキストファイルとして認識できません。'), $filename));
             }
             $quizFile = $file;
         }
     }
     if (empty($quizFile)) {
         throw new SyntaxException(_('拡張子が「.txt」のファイルが見つかりません。'));
     }
     return $quizFile;
 }
コード例 #19
0
ファイル: webapp.php プロジェクト: mindfeederllc/openemr
 */
/**
 * @ignore
 */
define('PMA_MINIMUM_COMMON', true);
/**
 * Gets core libraries and defines some variables
 */
require './libraries/common.inc.php';
/**
 * ZIP file handler.
 */
require './libraries/zip.lib.php';
// ini file
$parameters = array('id' => 'phpMyAdmin@' . $_SERVER['HTTP_HOST'], 'uri' => $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'), 'status' => 'yes', 'location' => 'no', 'sidebar' => 'no', 'navigation' => 'no', 'icon' => 'phpMyAdmin');
// dom sript file
// none need yet
// icon
$icon = 'favicon.ico';
// name
$name = 'phpMyAdmin.webapp';
$ini_file = "[Parameters]\n";
foreach ($parameters as $key => $value) {
    $ini_file .= $key . '=' . $value . "\n";
}
PMA_downloadHeader($name, 'application/webapp', 0, false);
$zip = new ZipFile();
$zip->setDoWrite();
$zip->addFile($ini_file, 'webapp.ini');
$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico');
$zip->file();
コード例 #20
0
ファイル: utilityHelpers.php プロジェクト: ffarago/pawtucket2
function caZipDirectory($ps_directory, $ps_name, $ps_output_file)
{
    $va_files_to_zip = caGetDirectoryContentsAsList($ps_directory);
    $o_zip = new ZipFile();
    foreach ($va_files_to_zip as $vs_file) {
        $vs_name = str_replace($ps_directory, $ps_name, $vs_file);
        $o_zip->addFile($vs_file, $vs_name);
    }
    $vs_new_file = $o_zip->output(ZIPFILE_FILEPATH);
    copy($vs_new_file, $ps_output_file);
    unlink($vs_new_file);
    return true;
}
コード例 #21
0
 /**
  * Returns an archive reader for a given zip file
  *
  * @param   string package
  * @param   string name
  * @return  io.archive.zip.ZipArchiveReader
  */
 protected function archiveReaderFor($package, $name)
 {
     return ZipFile::open($this->getClass()->getPackage()->getPackage($package)->getResourceAsStream($name . '.zip')->getInputStream());
 }
コード例 #22
0
 /**
  * 
  * 
  */
 public function DownloadRepresentations()
 {
     if ($t_subject = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true)) {
         $pa_ids = null;
         if ($vs_ids = trim($this->request->getParameter($t_subject->tableName(), pString))) {
             if ($vs_ids != 'all') {
                 $pa_ids = explode(';', $vs_ids);
                 foreach ($pa_ids as $vn_i => $vs_id) {
                     if (!trim($vs_id) || !(int) $vs_id) {
                         unset($pa_ids[$vn_i]);
                     }
                 }
             }
         }
         if (!is_array($pa_ids) || !sizeof($pa_ids)) {
             $pa_ids = $this->opo_result_context->getResultList();
         }
         $vn_file_count = 0;
         if (is_array($pa_ids) && sizeof($pa_ids)) {
             $ps_version = $this->request->getParameter('version', pString);
             if ($qr_res = $t_subject->makeSearchResult($t_subject->tableName(), $pa_ids, array('filterNonPrimaryRepresentations' => false))) {
                 $o_zip = new ZipFile();
                 if (!($vn_limit = ini_get('max_execution_time'))) {
                     $vn_limit = 30;
                 }
                 set_time_limit($vn_limit * 2);
                 while ($qr_res->nextHit()) {
                     if (!is_array($va_version_list = $qr_res->getMediaVersions('ca_object_representations.media')) || !in_array($ps_version, $va_version_list)) {
                         $vs_version = 'original';
                     } else {
                         $vs_version = $ps_version;
                     }
                     $va_paths = $qr_res->getMediaPaths('ca_object_representations.media', $vs_version);
                     $va_infos = $qr_res->getMediaInfos('ca_object_representations.media');
                     $va_representation_ids = $qr_res->get('ca_object_representations.representation_id', array('returnAsArray' => true));
                     foreach ($va_paths as $vn_i => $vs_path) {
                         $vs_ext = array_pop(explode(".", $vs_path));
                         $vs_idno_proc = preg_replace('![^A-Za-z0-9_\\-]+!', '_', $qr_res->get($t_subject->tableName() . '.idno'));
                         $vs_original_name = $va_infos[$vn_i]['ORIGINAL_FILENAME'];
                         $vn_index = sizeof($va_paths) > 1 ? "_" . ($vn_i + 1) : '';
                         $vn_representation_id = $va_representation_ids[$vn_i];
                         // make sure we don't download representations the user isn't allowed to read
                         if (!caCanRead($this->request->user->getPrimaryKey(), 'ca_object_representations', $vn_representation_id)) {
                             continue;
                         }
                         switch ($this->request->user->getPreference('downloaded_file_naming')) {
                             case 'idno':
                                 $vs_filename = "{$vs_idno_proc}{$vn_index}.{$vs_ext}";
                                 break;
                             case 'idno_and_version':
                                 $vs_filename = "{$vs_idno_proc}_{$vs_version}{$vn_index}.{$vs_ext}";
                                 break;
                             case 'idno_and_rep_id_and_version':
                                 $vs_filename = "{$vs_idno_proc}_representation_{$vn_representation_id}_{$vs_version}{$vn_index}.{$vs_ext}";
                                 break;
                             case 'original_name':
                             default:
                                 if ($vs_original_name) {
                                     $va_tmp = explode('.', $vs_original_name);
                                     if (sizeof($va_tmp) > 1) {
                                         if (strlen($vs_ext = array_pop($va_tmp)) < 3) {
                                             $va_tmp[] = $vs_ext;
                                         }
                                     }
                                     $vs_filename = join('_', $va_tmp) . "{$vn_index}.{$vs_ext}";
                                 } else {
                                     $vs_filename = "{$vs_idno_proc}_representation_{$vn_representation_id}_{$vs_version}{$vn_index}.{$vs_ext}";
                                 }
                                 break;
                         }
                         if ($vs_path_with_embedding = caEmbedMetadataIntoRepresentation(new ca_objects($qr_res->get('ca_objects.object_id')), new ca_object_representations($vn_representation_id), $vs_version)) {
                             $vs_path = $vs_path_with_embedding;
                         }
                         $o_zip->addFile($vs_path, $vs_filename, 0, array('compression' => 0));
                         $vn_file_count++;
                     }
                 }
                 $this->view->setVar('zip', $o_zip);
                 $this->view->setVar('download_name', 'media_for_' . mb_substr(preg_replace('![^A-Za-z0-9]+!u', '_', $this->getCriteriaForDisplay()), 0, 20) . '.zip');
                 set_time_limit($vn_limit);
             }
         }
         if ($vn_file_count > 0) {
             $this->render('Results/object_representation_download_binary.php');
         } else {
             $this->response->setHTTPResponseCode(204, _t('No files to download'));
         }
         return;
     }
     // post error
     $this->postError(3100, _t("Could not generate ZIP file for download"), "BaseEditorController->DownloadRepresentation()");
 }
コード例 #23
0
 /**
  * Creates a new \ZipFile, adds current file set to it, and yields it
  *
  * @return \ZipFile
  */
 function build_zip()
 {
     include_once EDW_INC . 'lib/zip.lib.php';
     $zip = new \ZipFile();
     foreach ($this->files as $file) {
         $zip->addFile($file->contents, $file->filename);
     }
     return $zip;
 }
コード例 #24
0
ファイル: export.lib.php プロジェクト: scriptpazar/phpmyadmin
/**
 * Compress the export buffer
 *
 * @param string $dump_buffer the current dump buffer
 * @param string $compression the compression mode
 * @param string $filename    the filename
 *
 * @return object $message a message object (or empty string)
 */
function PMA_compressExport($dump_buffer, $compression, $filename)
{
    if ($compression == 'zip' && @function_exists('gzcompress')) {
        $filename = substr($filename, 0, -4);
        // remove extension (.zip)
        $zipfile = new ZipFile();
        if (is_array($dump_buffer)) {
            foreach ($dump_buffer as $table => $dump) {
                $ext_pos = strpos($filename, '.');
                $extension = substr($filename, $ext_pos);
                $zipfile->addFile($dump, str_replace($extension, '_' . $table . $extension, $filename));
            }
        } else {
            $zipfile->addFile($dump_buffer, $filename);
        }
        $dump_buffer = $zipfile->file();
    } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
        // without the optional parameter level because it bugs
        $dump_buffer = gzencode($dump_buffer);
    }
    return $dump_buffer;
}
コード例 #25
0
ファイル: Admin.php プロジェクト: eadz/chyrp
 /**
  * Function: export
  * Export posts, pages, etc.
  */
 public function export()
 {
     if (!Visitor::current()->group->can("add_post")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to export content."));
     }
     if (empty($_POST)) {
         return $this->display("export");
     }
     $config = Config::current();
     $trigger = Trigger::current();
     $route = Route::current();
     $exports = array();
     if (isset($_POST['posts'])) {
         list($where, $params) = keywords($_POST['filter_posts'], "post_attributes.value LIKE :query OR url LIKE :query", "post_attributes");
         if (!empty($_GET['month'])) {
             $where["created_at like"] = $_GET['month'] . "-%";
         }
         $visitor = Visitor::current();
         if (!$visitor->group->can("view_draft", "edit_draft", "edit_post", "delete_draft", "delete_post")) {
             $where["user_id"] = $visitor->id;
         }
         $results = Post::find(array("placeholders" => true, "drafts" => true, "where" => $where, "params" => $params));
         $ids = array();
         foreach ($results[0] as $result) {
             $ids[] = $result["id"];
         }
         if (!empty($ids)) {
             $posts = Post::find(array("drafts" => true, "where" => array("id" => $ids), "order" => "id ASC"), array("filter" => false));
         } else {
             $posts = new Paginator(array());
         }
         $latest_timestamp = 0;
         foreach ($posts as $post) {
             if (strtotime($post->created_at) > $latest_timestamp) {
                 $latest_timestamp = strtotime($post->created_at);
             }
         }
         $id = substr(strstr($config->url, "//"), 2);
         $id = str_replace("#", "/", $id);
         $id = preg_replace("/(" . preg_quote(parse_url($config->url, PHP_URL_HOST)) . ")/", "\\1," . date("Y", $latest_timestamp) . ":", $id, 1);
         $posts_atom = '<?xml version="1.0" encoding="utf-8"?>' . "\r";
         $posts_atom .= '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:chyrp="http://chyrp.net/export/1.0/">' . "\r";
         $posts_atom .= '    <title>' . fix($config->name) . ' Posts</title>' . "\r";
         $posts_atom .= '    <subtitle>' . fix($config->description) . '</subtitle>' . "\r";
         $posts_atom .= '    <id>tag:' . parse_url($config->url, PHP_URL_HOST) . ',' . date("Y", $latest_timestamp) . ':Chyrp</id>' . "\r";
         $posts_atom .= '    <updated>' . date("c", $latest_timestamp) . '</updated>' . "\r";
         $posts_atom .= '    <link href="' . $config->url . '" rel="self" type="application/atom+xml" />' . "\r";
         $posts_atom .= '    <generator uri="http://chyrp.net/" version="' . CHYRP_VERSION . '">Chyrp</generator>' . "\r";
         foreach ($posts as $post) {
             $title = fix($post->title(), false);
             fallback($title, ucfirst($post->feather) . " Post #" . $post->id);
             $updated = $post->updated ? $post->updated_at : $post->created_at;
             $tagged = substr(strstr(url("id/" . $post->id), "//"), 2);
             $tagged = str_replace("#", "/", $tagged);
             $tagged = preg_replace("/(" . preg_quote(parse_url($post->url(), PHP_URL_HOST)) . ")/", "\\1," . when("Y-m-d", $updated) . ":", $tagged, 1);
             $url = $post->url();
             $posts_atom .= '    <entry xml:base="' . fix($url) . '">' . "\r";
             $posts_atom .= '        <title type="html">' . $title . '</title>' . "\r";
             $posts_atom .= '        <id>tag:' . $tagged . '</id>' . "\r";
             $posts_atom .= '        <updated>' . when("c", $updated) . '</updated>' . "\r";
             $posts_atom .= '        <published>' . when("c", $post->created_at) . '</published>' . "\r";
             $posts_atom .= '        <link href="' . fix($trigger->filter($url, "post_export_url", $post)) . '" />' . "\r";
             $posts_atom .= '        <author chyrp:user_id="' . $post->user_id . '">' . "\r";
             $posts_atom .= '            <name>' . fix(oneof($post->user->full_name, $post->user->login)) . '</name>' . "\r";
             if (!empty($post->user->website)) {
                 $posts_atom .= '            <uri>' . fix($post->user->website) . '</uri>' . "\r";
             }
             $posts_atom .= '            <chyrp:login>' . fix($post->user->login) . '</chyrp:login>' . "\r";
             $posts_atom .= '        </author>' . "\r";
             $posts_atom .= '        <content>' . "\r";
             foreach ($post->attributes as $key => $val) {
                 $posts_atom .= '            <' . $key . '>' . fix($val) . '</' . $key . '>' . "\r";
             }
             $posts_atom .= '        </content>' . "\r";
             foreach (array("feather", "clean", "url", "pinned", "status") as $attr) {
                 $posts_atom .= '        <chyrp:' . $attr . '>' . fix($post->{$attr}) . '</chyrp:' . $attr . '>' . "\r";
             }
             $trigger->filter($posts_atom, "posts_export", $post);
             $posts_atom .= '    </entry>' . "\r";
         }
         $posts_atom .= '</feed>' . "\r";
         $exports["posts.atom"] = $posts_atom;
     }
     if (isset($_POST['pages'])) {
         list($where, $params) = keywords($_POST['filter_pages'], "title LIKE :query OR body LIKE :query", "pages");
         $pages = Page::find(array("where" => $where, "params" => $params, "order" => "id ASC"), array("filter" => false));
         $latest_timestamp = 0;
         foreach ($pages as $page) {
             if (strtotime($page->created_at) > $latest_timestamp) {
                 $latest_timestamp = strtotime($page->created_at);
             }
         }
         $pages_atom = '<?xml version="1.0" encoding="utf-8"?>' . "\r";
         $pages_atom .= '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:chyrp="http://chyrp.net/export/1.0/">' . "\r";
         $pages_atom .= '    <title>' . fix($config->name) . ' Pages</title>' . "\r";
         $pages_atom .= '    <subtitle>' . fix($config->description) . '</subtitle>' . "\r";
         $pages_atom .= '    <id>tag:' . parse_url($config->url, PHP_URL_HOST) . ',' . date("Y", $latest_timestamp) . ':Chyrp</id>' . "\r";
         $pages_atom .= '    <updated>' . date("c", $latest_timestamp) . '</updated>' . "\r";
         $pages_atom .= '    <link href="' . $config->url . '" rel="self" type="application/atom+xml" />' . "\r";
         $pages_atom .= '    <generator uri="http://chyrp.net/" version="' . CHYRP_VERSION . '">Chyrp</generator>' . "\r";
         foreach ($pages as $page) {
             $updated = $page->updated ? $page->updated_at : $page->created_at;
             $tagged = substr(strstr($page->url(), "//"), 2);
             $tagged = str_replace("#", "/", $tagged);
             $tagged = preg_replace("/(" . preg_quote(parse_url($page->url(), PHP_URL_HOST)) . ")/", "\\1," . when("Y-m-d", $updated) . ":", $tagged, 1);
             $url = $page->url();
             $pages_atom .= '    <entry xml:base="' . fix($url) . '" chyrp:parent_id="' . $page->parent_id . '">' . "\r";
             $pages_atom .= '        <title type="html">' . fix($page->title) . '</title>' . "\r";
             $pages_atom .= '        <id>tag:' . $tagged . '</id>' . "\r";
             $pages_atom .= '        <updated>' . when("c", $updated) . '</updated>' . "\r";
             $pages_atom .= '        <published>' . when("c", $page->created_at) . '</published>' . "\r";
             $pages_atom .= '        <link href="' . fix($trigger->filter($url, "page_export_url", $page)) . '" />' . "\r";
             $pages_atom .= '        <author chyrp:user_id="' . fix($page->user_id) . '">' . "\r";
             $pages_atom .= '            <name>' . fix(oneof($page->user->full_name, $page->user->login)) . '</name>' . "\r";
             if (!empty($page->user->website)) {
                 $pages_atom .= '            <uri>' . fix($page->user->website) . '</uri>' . "\r";
             }
             $pages_atom .= '            <chyrp:login>' . fix($page->user->login) . '</chyrp:login>' . "\r";
             $pages_atom .= '        </author>' . "\r";
             $pages_atom .= '        <content type="html">' . fix($page->body) . '</content>' . "\r";
             foreach (array("show_in_list", "list_order", "clean", "url") as $attr) {
                 $pages_atom .= '        <chyrp:' . $attr . '>' . fix($page->{$attr}) . '</chyrp:' . $attr . '>' . "\r";
             }
             $trigger->filter($pages_atom, "pages_export", $page);
             $pages_atom .= '    </entry>' . "\r";
         }
         $pages_atom .= '</feed>' . "\r";
         $exports["pages.atom"] = $pages_atom;
     }
     if (isset($_POST['groups'])) {
         list($where, $params) = keywords($_POST['filter_groups'], "name LIKE :query", "groups");
         $groups = Group::find(array("where" => $where, "params" => $params, "order" => "id ASC"));
         $groups_yaml = array("groups" => array(), "permissions" => array());
         foreach (SQL::current()->select("permissions", "*", array("group_id" => 0))->fetchAll() as $permission) {
             $groups_yaml["permissions"][$permission["id"]] = $permission["name"];
         }
         foreach ($groups as $index => $group) {
             $groups_yaml["groups"][$group->name] = $group->permissions;
         }
         $exports["groups.yaml"] = YAML::dump($groups_yaml);
     }
     if (isset($_POST['users'])) {
         list($where, $params) = keywords($_POST['filter_users'], "login LIKE :query OR full_name LIKE :query OR email LIKE :query OR website LIKE :query", "users");
         $users = User::find(array("where" => $where, "params" => $params, "order" => "id ASC"));
         $users_yaml = array();
         foreach ($users as $user) {
             $users_yaml[$user->login] = array();
             foreach ($user as $name => $attr) {
                 if (!in_array($name, array("no_results", "group_id", "group", "id", "login", "belongs_to", "has_many", "has_one", "queryString"))) {
                     $users_yaml[$user->login][$name] = $attr;
                 } elseif ($name == "group_id") {
                     $users_yaml[$user->login]["group"] = $user->group->name;
                 }
             }
         }
         $exports["users.yaml"] = YAML::dump($users_yaml);
     }
     $trigger->filter($exports, "export");
     require INCLUDES_DIR . "/lib/zip.php";
     $zip = new ZipFile();
     foreach ($exports as $filename => $content) {
         $zip->addFile($content, $filename);
     }
     $zip_contents = $zip->file();
     $filename = sanitize(camelize($config->name), false, true) . "_Export_" . date("Y-m-d");
     header("Content-type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"" . $filename . ".zip\"");
     header("Content-length: " . strlen($zip_contents) . "\n\n");
     echo $zip_contents;
 }
コード例 #26
0
 /**
  *
  */
 public function Download()
 {
     $pn_item_id = $this->request->getParameter('item_id', pInteger);
     $t_item = new ca_commerce_order_items($pn_item_id);
     $t_order = new ca_commerce_orders($t_item->get('order_id'));
     $t_transaction = new ca_commerce_transactions($t_order->get('transaction_id'));
     $o_media = new Media();
     if ($t_item->getPrimaryKey() && $t_order->getPrimaryKey()) {
         // Is the order paid for...
         if (!in_array($t_order->get('order_status'), array('PROCESSED', 'PROCESSED_AWAITING_DIGITIZATION', 'COMPLETED'))) {
             $this->notification->addNotification(_t("This order must be processed before you can download items"), __NOTIFICATION_TYPE_ERROR__);
             $this->Index();
             return;
         }
         // ... and accessible by this user?
         if ($t_transaction->get('user_id') != $this->request->getUserID()) {
             $this->notification->addNotification(_t("You may not download this item"), __NOTIFICATION_TYPE_ERROR__);
             $this->Index();
             return;
         }
         // Is this item downloadable?
         if ($t_item->get('fullfillment_method') != 'DOWNLOAD') {
             $this->notification->addNotification(_t("This item cannot be downloaded"), __NOTIFICATION_TYPE_ERROR__);
             $this->Index();
             return;
         }
         // Which reps, and what versions?
         $t_object = new ca_objects($t_item->get('object_id'));
         $va_services_list = array();
         if (is_array($va_service_groups = $this->opo_client_services_config->getAssoc("service_groups"))) {
             foreach ($va_service_groups as $vs_group => $va_services_in_group) {
                 foreach ($va_services_in_group['services'] as $vs_service => $va_service_info) {
                     $va_services_list[$vs_service] = $va_service_info;
                 }
             }
         }
         if (!($vs_version = $va_services_list[$t_item->get('service')]['download_version'])) {
             $vs_version = 'small';
         }
         $va_reps = $t_object->getRepresentations(array($vs_version));
         $va_reps_to_download = $t_item->getRepresentationIDs();
         $o_zip = new ZipFile();
         $va_files = array();
         $vn_size = 0;
         foreach ($va_reps as $va_rep) {
             if (!isset($va_reps_to_download[$va_rep['representation_id']]) || !$va_reps_to_download[$va_rep['representation_id']]) {
                 continue;
             }
             $va_tmp = explode('.', $va_rep['paths'][$vs_version]);
             $vs_ext = array_pop($va_tmp);
             if ($va_rep['original_filename']) {
                 $va_tmp2 = explode(".", $va_rep['original_filename']);
                 if (sizeof($va_tmp2) > 1) {
                     array_pop($va_tmp2);
                 }
                 $vs_filename = join(".", $va_tmp2) . ".{$vs_ext}";
             } else {
                 $vs_filename = $t_object->get('idno') . "_" . $va_rep['representation_id'] . ".{$vs_ext}";
             }
             $vn_size += $va_files[$va_rep['paths'][$vs_version]] = filesize($va_rep['paths'][$vs_version]);
             $o_zip->addFile($va_rep['paths'][$vs_version], $vs_filename, 0, array('compression' => 0));
         }
         $this->view->setVar('zip', $o_zip);
         $this->view->setVar('version_download_name', date('dmY', $t_order->get('created_on', array('GET_DIRECT_DATE' => true))) . '-' . $t_order->getPrimaryKey());
         // Log fulfillment
         $t_item->logFulfillmentEvent('DOWNLOAD', array('ip_addr' => $_SERVER['REMOTE_ADDR'], 'user_id' => $this->request->getUserID(), 'datetime' => time(), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'files' => $va_files, 'size' => $vn_size, 'representation_ids' => $va_reps_to_download));
         return $this->render('Account/download_binary.php');
     }
     $this->notification->addNotification(_t("You may not download this"), __NOTIFICATION_TYPE_ERROR__);
     $this->Index();
     return;
 }
コード例 #27
0
function makeZip($images_pack)
{
    require_once 'zip.lib.php';
    $zipGenerator = new ZipFile();
    for ($i = 0; $i < $images_pack['count']; $i++) {
        $image_str = $images_pack['images'][$i];
        $filename = $images_pack['fileNames'][$i];
        $zipGenerator->addFile($image_str, $filename);
    }
    return $zipGenerator->file();
}
コード例 #28
0
ファイル: generate.php プロジェクト: saanina/sdeploy
*
* automatically generated file, copyrights (c) 2009
* settings come from here
*/

';
#index file content, to block the access to public files
$index_file = '';
$css_file = '';
if (isset($_POST['ft']['constant'])) {
    $info_codes .= file_get_contents('./resources/php/core/constant.php');
}
//require "zip.class.php"; // Get the zipfile class
require "ZipFile.php";
// Get the zipfile class
$zipfile = new ZipFile();
// Create an object
function tmpco($v)
{
    $tmpfname = tempnam(sys_get_temp_dir(), 'tmp');
    //	$temp = tmpfile();
    //	print $temp;
    file_put_contents($tmpfname, $v);
    return $tmpfname;
}
#create the folders
#$zipfile->create_dir("includes");
#$zipfile->create_dir("css");
#$zipfile->create_dir("images");
#$zipfile->create_dir("js");
#if(isset($_POST['ft']['easytemplate']))
コード例 #29
0
ファイル: fetch.php プロジェクト: syaofox/tumblr-images
/**
 * generate zip file stream
 * @param $arrImageStrings
 * @param $arrImageUrls
 * @return string
 */
function makeZipPack($arrImageStrings, $arrImageUrls)
{
    require_once 'zip.lib.php';
    $zipGenerator = new ZipFile();
    for ($i = 0, $length = sizeof($arrImageStrings); $i < $length; $i++) {
        $strImageString = $arrImageStrings[$i];
        $strImageUrl = $arrImageUrls[$i];
        $zipGenerator->addFile($strImageString, basename($strImageUrl));
    }
    return $zipGenerator->file();
}
コード例 #30
0
ファイル: users.php プロジェクト: ricain59/fortaff
 public function executecode()
 {
     //$this->load->helper(array('form', 'email','cookie','googledrive'));
     $this->load->helper('generate');
     //$zip =  new ZipFile();
     $destination_path = $_GET['destination'];
     $zip_name_with_path = $_GET['zipName'];
     echo $action = $_GET['action'];
     $obj = new ZipFile();
     if (!isset($destination_path) || !isset($zip_name_with_path) || !isset($action)) {
         echo "If you want to extract any file then pass destination path in query string with (destination) parameter <br/>If you want to delete directory then pass destination path in query string with (destination) parameter <br/>If you want to make zip file then pass destination path & zip file path with name in query string with (destination & zipName) parameter";
     } else {
         switch ($action) {
             case 'Delete':
                 $obj->deleteDirectory($destination_path);
                 break;
             case 'Extract':
                 $obj->ExtractZip($destination_path);
                 break;
             case 'Zip':
                 $zipName = $zip_name_with_path;
                 $obj->MakeZip($destination_path, $zipName);
                 break;
             default:
                 echo "Please pass action";
         }
     }
 }