file() public méthode

public file ( )
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;
    }
}
/**
 * Minimalistic creator of OASIS OpenDocument
 *
 * @param   string      desired MIME type
 * @param   string      document content
 *
 * @return  string      OASIS OpenDocument data
 *
 * @access  public
 */
function PMA_createOpenDocument($mime, $data)
{
    $zipfile = new zipfile();
    $zipfile->addFile($mime, 'mimetype');
    $zipfile->addFile($data, 'content.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<office:document-meta ' . 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' . 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" ' . 'office:version="1.0">' . '<office:meta>' . '<meta:generator>phpMyAdmin ' . PMA_VERSION . '</meta:generator>' . '<meta:initial-creator>phpMyAdmin ' . PMA_VERSION . '</meta:initial-creator>' . '<meta:creation-date>' . strftime('%Y-%m-%dT%H:%M:%S') . '</meta:creation-date>' . '</office:meta>' . '</office:document-meta>', 'meta.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<office:document-styles ' . $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">' . '<office:font-face-decls>' . '<style:font-face style:name="Arial Unicode MS" svg:font-family="\'Arial Unicode MS\'" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Sans1" svg:font-family="\'DejaVu Sans\'" style:font-pitch="variable"/>' . '<style:font-face style:name="HG Mincho Light J" svg:font-family="\'HG Mincho Light J\'" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Serif" svg:font-family="\'DejaVu Serif\'" style:font-family-generic="roman" style:font-pitch="variable"/>' . '<style:font-face style:name="Thorndale" svg:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Sans" svg:font-family="\'DejaVu Sans\'" style:font-family-generic="swiss" style:font-pitch="variable"/>' . '</office:font-face-decls>' . '<office:styles>' . '<style:default-style style:family="paragraph">' . '<style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="0.4925in" style:writing-mode="page"/>' . '<style:text-properties style:use-window-font-color="true" style:font-name="DejaVu Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:font-name-asian="DejaVu Sans1" style:font-size-asian="12pt" style:language-asian="none" style:country-asian="none" style:font-name-complex="DejaVu Sans1" style:font-size-complex="12pt" style:language-complex="none" style:country-complex="none" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>' . '</style:default-style>' . '<style:style style:name="Standard" style:family="paragraph" style:class="text"/>' . '<style:style style:name="Text_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">' . '<style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0.0835in"/>' . '</style:style>' . '<style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_body" style:class="text">' . '<style:paragraph-properties fo:margin-top="0.1665in" fo:margin-bottom="0.0835in" fo:keep-with-next="always"/>' . '<style:text-properties style:font-name="DejaVu Sans" fo:font-size="14pt" style:font-name-asian="DejaVu Sans1" style:font-size-asian="14pt" style:font-name-complex="DejaVu Sans1" style:font-size-complex="14pt"/>' . '</style:style>' . '<style:style style:name="Heading_1" style:display-name="Heading 1" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_body" style:class="text" style:default-outline-level="1">' . '<style:text-properties style:font-name="Thorndale" fo:font-size="24pt" fo:font-weight="bold" style:font-name-asian="HG Mincho Light J" style:font-size-asian="24pt" style:font-weight-asian="bold" style:font-name-complex="Arial Unicode MS" style:font-size-complex="24pt" style:font-weight-complex="bold"/>' . '</style:style>' . '<style:style style:name="Heading_2" style:display-name="Heading 2" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_body" style:class="text" style:default-outline-level="2">' . '<style:text-properties style:font-name="DejaVu Serif" fo:font-size="18pt" fo:font-weight="bold" style:font-name-asian="DejaVu Sans1" style:font-size-asian="18pt" style:font-weight-asian="bold" style:font-name-complex="DejaVu Sans1" style:font-size-complex="18pt" style:font-weight-complex="bold"/>' . '</style:style>' . '</office:styles>' . '<office:automatic-styles>' . '<style:page-layout style:name="pm1">' . '<style:page-layout-properties fo:page-width="8.2673in" fo:page-height="11.6925in" style:num-format="1" style:print-orientation="portrait" fo:margin-top="1in" fo:margin-bottom="1in" fo:margin-left="1.25in" fo:margin-right="1.25in" style:writing-mode="lr-tb" style:footnote-max-height="0in">' . '<style:footnote-sep style:width="0.0071in" style:distance-before-sep="0.0398in" style:distance-after-sep="0.0398in" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>' . '</style:page-layout-properties>' . '<style:header-style/>' . '<style:footer-style/>' . '</style:page-layout>' . '</office:automatic-styles>' . '<office:master-styles>' . '<style:master-page style:name="Standard" style:page-layout-name="pm1"/>' . '</office:master-styles>' . '</office:document-styles>', 'styles.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">' . '<manifest:file-entry manifest:media-type="' . $mime . '" manifest:full-path="/"/>' . '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>' . '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="meta.xml"/>' . '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/>' . '</manifest:manifest>', 'META-INF/manifest.xml');
    return $zipfile->file();
}
Exemple #3
0
 function zipFiles($zipname, $files)
 {
     $zipfile = new zipfile();
     //	        $zipfile->add_dir("files/");
     for ($f = 0; $f < count($files); $f++) {
         $filename = $files[$f][0];
         $filedata = $files[$f][1];
         $zipfile->add_file($filedata, $filename);
     }
     File::throwFile($zipname, $zipfile->file());
 }
/**
 * Implementation of hook_page.
 * Zip current file/folder 
 */
function ft_zip_page($act)
{
    global $ft;
    if ($act == 'zip') {
        $_REQUEST['file'] = trim(ft_stripslashes($_REQUEST['file']));
        // nom de fichier/repertoire
        $zip = new zipfile();
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            $zip->setOutFile($ft["plugins"]["zip"]["filebuffer"]);
        }
        $substr_base = strlen(ft_get_dir()) + 1;
        foreach (ft_zip_getfiles(ft_get_dir() . '/' . $_REQUEST['file']) as $file) {
            $filename = substr($file, $substr_base);
            $filesize = filesize($file);
            if ($filesize > 0) {
                $fp = fopen($file, 'r');
                $content = fread($fp, $filesize);
                fclose($fp);
            } else {
                $content = '';
            }
            $zip->addfile($content, $filename);
        }
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            $zip->finish();
            $filesize = filesize($ft["plugins"]["zip"]["filebuffer"]);
        } else {
            $archive = $zip->file();
            $filesize = strlen($archive);
        }
        header('Content-Type: application/x-zip');
        header('Content-Disposition: inline; filename="' . $_REQUEST['file'] . '.zip"');
        header('Content-Length: ' . $filesize);
        if ($ft["plugins"]["zip"]["filebuffer"]) {
            readfile($ft["plugins"]["zip"]["filebuffer"]);
            unlink($ft["plugins"]["zip"]["filebuffer"]);
        } else {
            echo $archive;
        }
        exit;
    }
}
 function process_backup($user)
 {
     include_once "class_zip.php";
     if ($_REQUEST['choice'] == 'yes') {
         //CREATE A UNIX TIMESTAMP
         $stamp = time();
         $date1 = gmdate("m-d-y", $stamp);
         $date = gmdate("Y-m-d H:i:s", $stamp);
         $title = "bu_" . $date . "_" . $user->user_name . ".zip";
         //CREATE THE BACKUP OF OUR DATABASE
         $filename = "../" . $this->config->file_dir . "/tmp_{$date1}.sql";
         passthru("mysqldump --opt -h" . $this->config->db_host . " -u" . $this->config->db_user . " -p" . $this->config->db_pass . " " . $this->config->db_name . " >{$filename}");
         //
         $zipfile = new zipfile();
         //READ THE CURRENT DIRECTORY WE ARE IN
         $dir_list = $this->read_dir("../");
         for ($i = 0; $i < count($dir_list); $i++) {
             if ($dir_list[$i]['type'] == "dir") {
                 //echo $dir_list[$i]['name']."<br/>";
                 $zipfile->add_dir($dir_list[$i]['name']);
             } else {
                 if ($dir_list[$i]['type'] == "file") {
                     //echo $dir_list[$i]['name']."<br/>";
                     $zipfile->add_file(file_get_contents($dir_list[$i]['loc'], false), $dir_list[$i]['name']);
                 }
             }
         }
         //REMOVE OUR TEMP SQL FILE
         unlink($filename);
         //CREATE THE SYSTEM NAME
         $sql = "SELECT id FROM " . $this->config->db_prefix . "_files ORDER BY id DESC";
         $results = $this->db->DB_Q_C($sql);
         $total_files = mysql_fetch_array($results);
         $total_files[0]++;
         $sys_name = "file_" . $total_files[0] . ".zip";
         //CREATE THE ZIP FILE
         $fileName = "../" . $this->config->file_dir . "/backup/{$sys_name}";
         $fd = fopen($fileName, "w");
         $out = fwrite($fd, $zipfile->file());
         fclose($fd);
         //
         $sql = "INSERT INTO `" . $this->config->db_prefix . "_files` VALUES ('', '{$title}', '{$sys_name}', '../" . $this->config->file_dir . "/backup/', 'zip', 'A backup of your site.')";
         $results = $this->db->DB_Q_C($sql);
         $lastid = mysql_insert_id();
         //LOG THE ACTION
         $sql = "INSERT INTO " . $this->config->db_prefix . "_object(create_date, create_who) \r\r\n          \t\t\t   VALUES('{$date}', '{$user->user_id}')";
         $results = $this->db->DB_Q_C($sql);
         $lastobjectid = mysql_insert_id();
         $sql = "INSERT INTO " . $this->config->db_prefix . "_logs(object_id, user_id, module_id, sub_module_id, record_id, action)\r\r\n                  VALUES({$lastobjectid}, '" . $user->user_id . "', '" . $this->id . "', 1, {$lastid}, 1)";
         $results = $this->db->DB_Q_C($sql);
         //
         $ret_code = array(1, $lastid);
     } else {
         $ret_code = array(-1, 0);
     }
     return $ret_code;
 }
Exemple #6
0
//Respaldar_Instancias recibe como params un array
if (strlen($result) > 0) {
    die("<html><head><meta HTTP-EQUIV='REFRESH' content='3; url=instancias.bd.php'><title>Error al descargar, perimisos</title></head><body><h1><center>" . $result . "</center></h1></body></html>");
}
$f = new zipfile();
for ($i = 0; $i < sizeof($ids); $i++) {
    //$f->add_file(file_get_contents($files[$i]), $file_id[$i] . ".sql");
    $final_path = str_replace("server", "static_content/db_backups", POS_PATH_TO_SERVER_ROOT);
    $dbs_instance = trim(shell_exec("ls -lat -m1 " . $final_path . "| grep " . $ids[$i] . ".sql"));
    Logger::log("Respaldos encontrados: " . $dbs_instance);
    /*dbs_instance almacena una cadena con un listado donde se encuentran archivos que tengan la teminacion
    	con el id de la instancia y .sql, ademas de que la lista viene ordenada de mas reciente a antiguo
    	la lista seria como lo siguiente:
    	1353617611_pos_instance_82.sql 1353608687_pos_instance_82.sql 1353608206_pos_instance_82.sql 1353608191_pos_instance_82.sql
    	en found se coloca un array y en cada posicion el nombre de cada respaldo
    	*/
    $found = preg_split("/[\\s,]+/", $dbs_instance, -1, PREG_SPLIT_NO_EMPTY);
    //Logger::log("No archivos: ".count($found));
    if (count($found) < 1) {
        Logger::log("Error al restaurar la instancias " . $ids[$i] . ", no hay un respaldo existente");
        continue;
    }
    $contenido = file_get_contents($final_path . "/" . $found[0]);
    $f->add_file($contenido, $found[0]);
}
$folder_name = sizeof($ids) > 1 ? "instances_backup_" . date("d-m-Y H:i:s") : "instance_" . $ids[0] . "_backup_" . date("d-m-Y H:i:s");
Logger::log(":::::::ENVIANDO ARCHIVO A DESCARGAR");
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename={$folder_name}.zip");
echo $f->file();
Exemple #7
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);
}
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");
}
Exemple #9
0
 /**
  * Writes a zip file of an array of release guids directly to the stream
  */
 public function getZipped($guids)
 {
     $s = new Settings();
     $this->nzb = new NZB();
     $zipfile = new zipfile();
     foreach ($guids as $guid) {
         $nzbpath = $this->nzb->getNZBPath($guid, $s->getSetting('nzbpath'));
         if (file_exists($nzbpath)) {
             ob_start();
             @readgzfile($nzbpath);
             $nzbfile = ob_get_contents();
             ob_end_clean();
             $filename = $guid;
             $r = $this->getByGuid($guid);
             if ($r) {
                 $filename = $r["searchname"];
             }
             $zipfile->addFile($nzbfile, $filename . ".nzb");
         }
     }
     return $zipfile->file();
 }
Exemple #10
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);
 }
Exemple #11
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();
}
 /**
  * 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 #13
0
			$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');
					$filename = $backupfilename.'.sql';
					cpmsg('database_export_succeed');
Exemple #14
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();
}
Exemple #15
0
        }
        echo "\n";
        $values = mysql_query('SELECT * FROM ' . $table . $clause_where);
        while ($rowr = mysql_fetch_row($values)) {
            for ($j = 0; $j < $l; $j++) {
                $d = str_replace('"', '""', $rowr[$j]);
                echo '"' . str_replace('
', '\\n', $d) . '";';
            }
            echo "\n";
        }
        $zip->addfile(utf8_decode(ob_get_contents()), $nom_fichier);
        //on ajoute le fichier
        ob_end_clean();
        //on vide le cache
    }
}
$archive = $zip->file();
// on associe l'archive
// on enregistre l'archive dans un fichier
$open = fopen('exports/' . $filename . '.zip', "wb");
fwrite($open, $archive);
fclose($open);
// code à insérer à la place des 3lignes ( fopen, fwrite, fclose )
header('Content-Type: application/x-zip');
//on détermine les en-tête
header('Content-Disposition: inline; filename=' . $filename . '.zip');
echo $archive;
?>

 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 #17
0
    'uri'       => $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'),
    'status'    => 'yes',
    'location'  => 'no',
    'sidebar'   => 'no',
    'navigation' => 'no',
    'icon'      => 'phpMyAdmin',
);

// dom sript file
// none need yet

// icon
$icon = 'favicon.ico';

// name
$name = 'phpMyAdmin.webapp';

$ini_file = "[Parameters]\n";
foreach ($parameters as $key => $value) {
    $ini_file .= $key . '=' . $value . "\n";
}

PMA_download_header($name, 'application/webapp', 0, false);

$zip = new zipfile;
$zip->setDoWrite();
$zip->addFile($ini_file, 'webapp.ini');
$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico');
$zip->file();
?>
$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 {
                    unlink($dir . "/" . $object);
                }
            }
Exemple #19
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 #20
0
}
/**
 * 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);
        fclose($file_handle);
Exemple #21
0
                 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.';
     }
 } else {
     if (isset($_REQUEST['do_active'])) {
         if ($standard_active || $froogle_active || $hardwareschotte_active || $kelkoo_active || $pangora_active || $shopping_active || $webde_active || $amazon_active) {
             #echo '<script type="text/javascript">alert("Produktdateien werden generiert. Bitte OK druecken und warten...");</script>';
Exemple #22
0
    require_once 'inc/zip.class.php';
    $zipfile = new zipfile();
    $timestamp = date('Y-m-d-Hi');
    ini_set("memory_limit", "600M");
    // paths and files to backup
    $paths = array($relative . 'data', $relative . 'theme');
    //no trailing slash
    $files = array($relative . '.htaccess', $relative . 'index.php', $relative . 'gsconfig.php');
    $zipfile->add_dir('getsimple');
    // cycle thru each path and file and add to zip file
    foreach ($paths as $path) {
        $dir_handle = @opendir($path) or die("Unable to open {$path}");
        ListDir($dir_handle, $path);
    }
    foreach ($files as $fl) {
        $filedata = file_get_contents($fl);
        $zipfile->add_file($filedata, substr_replace($fl, 'getsimple', 0, 2));
    }
    // $listing is the list of all files and folders that were added to the backup
    //echo $listing;
    // create the final zip file
    $file = $relative . 'backups/zip/' . $timestamp . '_archive.zip';
    $fh = fopen($file, 'w') or die('Could not open file for writing!');
    fwrite($fh, $zipfile->file()) or die('Could not write to file');
    fclose($fh);
    // redirect back to archive page with a success
    header('Location: archive.php?done');
} else {
    die('You do not have permission to execute this page');
}
exit;
/**
 * 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();
<?php

require "../includes/verifica_logado_controle.inc.php";
require "../includes/funcoes.php";
require "../includes/global.inc.php";
require "../includes/zip/zip.php";
pt_register('GET', 'id');
$anexoDAO = new AnexoDAO();
$anexo = $anexoDAO->selectPorId($id);
if (is_null($anexo) or $controle_id_empresa != 1) {
    echo 'Download bloqueado pelo servidor. Contate o administrador';
    exit;
}
$zipfile = new zipfile($controle_id_usuario . '_' . date("d-m-Y") . ".zip");
$arquivo = '../anexos_franquia/' . $anexo->anexo;
$zipfile->addFileAndRead($arquivo);
echo $zipfile->file();
 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;
 }
    $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;
}
Exemple #27
0
function compress(&$filename, &$filedump, $compress)
{
    global $content_encoding;
    global $mime_type;
    if ($compress == 'bzip' && @function_exists('bzcompress')) {
        $filename .= '.bz2';
        $mime_type = 'application/x-bzip2';
        $filedump = bzcompress($filedump);
    } else {
        if ($compress == 'gzip' && @function_exists('gzencode')) {
            $filename .= '.gz';
            $content_encoding = 'x-gzip';
            $mime_type = 'application/x-gzip';
            $filedump = gzencode($filedump);
        } else {
            if ($compress == 'zip' && @function_exists('gzcompress')) {
                $filename .= '.zip';
                $mime_type = 'application/zip';
                $zipfile = new zipfile();
                $zipfile->addFile($filedump, substr($filename, 0, -4));
                $filedump = $zipfile->file();
            } else {
                $mime_type = 'application/octet-stream';
            }
        }
    }
}
Exemple #28
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;
}
        if (count($myProfessionalReferenceFileArray) > 0) {
            $zipfile->add_dir($dir_company_name . "/");
            for ($i_loop = 0; $i_loop < count($myProfessionalReferenceFileArray); $i_loop++) {
                $filedata = func_read_file("../gateway/" . $_SESSION['gw_folder'] . "UserDocuments/Professional_Reference/" . $myProfessionalReferenceFileArray[$i_loop]);
                $zipfile->add_file($filedata, $dir_company_name . "/Professional_Reference_" . $myProfessionalReferenceFileArray[$i_loop]);
            }
        }
    }
}
if ($zipfile->get_file_size() > 0) {
    //$arr_result = func_send_documents($zipfile, $str_company_name, $other_email, $str_failure_companies, //$i_max_file_size_MB, $error_msg);
    //$zip_file_name = func_replace_invalid_literals($str_company_name);
    $zip_file_name = "Documents";
    $filename = "csv/" . $zip_file_name . ".zip";
    $fd = fopen($filename, "wb");
    $out = fwrite($fd, $zipfile->file());
    fclose($fd);
    $mail_response = "<a href='csv/Documents.zip' target='_blank'>Click here to Download the documents</a>";
} else {
    $mail_response = "No Documents to Download";
}
function getDirList($dirName, $i_company)
{
    $d = dir($dirName);
    $filename = "";
    while ($entry = $d->read()) {
        //echo strpos($entry,$i_company);
        if ($entry != "." && $entry != "..") {
            if (strpos($entry, $i_company) >= 0) {
                //echo $dirName."\\".$entry."\n";
                $filename = $entry;
Exemple #30
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;
    }
}