本文整理汇总了PHP中zipfile::file方法的典型用法代码示例。如果您正苦于以下问题:PHP zipfile::file方法的具体用法?PHP zipfile::file怎么用?PHP zipfile::file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipfile
的用法示例。
在下文中一共展示了zipfile::file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makezip
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;
}
}
示例2: PMA_createOpenDocument
/**
* 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();
}
示例3: zipFiles
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());
}
示例4: ft_zip_page
/**
* 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;
}
}
示例5: time
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;
}
示例6: die
//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();
示例7: messages_mailAndDeleteMessages
/**
*
*/
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 = "noreply@uga-agga.de";
$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);
}
示例8: downloadTema2
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ão exista, que servirá de base para obtençã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ão existir, tenta inserir com base no mapfile existente no diretório temas
//o tema pode existir se a função estiver sendo chamada da árvore de temas de um mapa já 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ã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 {
//.........这里部分代码省略.........
示例9: getZipped
/**
* 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();
}
示例10: send
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 = "noreply@uga-agga.de";
$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);
}
示例11: get_projects_archive
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();
}
示例12: Generate
/**
* 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"];
//.........这里部分代码省略.........
示例13: addslashes
$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="'.$dbuser.'" --password="'.$dbpw.'" "'.$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');
示例14: generate_kmz_track
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();
}
示例15: while
}
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;
?>