コード例 #1
0
/**
 * Minimalistic creator of OASIS OpenDocument
 *
 * @param string $mime desired MIME type
 * @param string $data document content
 *
 * @return string  OASIS OpenDocument data
 *
 * @access  public
 */
function PMA_createOpenDocument($mime, $data)
{
    $zipfile = new ZipFile();
    $zipfile->addFile($mime, 'mimetype');
    $zipfile->addFile($data, 'content.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<office:document-meta ' . 'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' . 'xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" ' . 'office:version="1.0">' . '<office:meta>' . '<meta:generator>phpMyAdmin ' . PMA_VERSION . '</meta:generator>' . '<meta:initial-creator>phpMyAdmin ' . PMA_VERSION . '</meta:initial-creator>' . '<meta:creation-date>' . strftime('%Y-%m-%dT%H:%M:%S') . '</meta:creation-date>' . '</office:meta>' . '</office:document-meta>', 'meta.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<office:document-styles ' . $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">' . '<office:font-face-decls>' . '<style:font-face style:name="Arial Unicode MS"' . ' svg:font-family="\'Arial Unicode MS\'" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Sans1"' . ' svg:font-family="\'DejaVu Sans\'" style:font-pitch="variable"/>' . '<style:font-face style:name="HG Mincho Light J"' . ' svg:font-family="\'HG Mincho Light J\'" style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Serif"' . ' svg:font-family="\'DejaVu Serif\'" style:font-family-generic="roman"' . ' style:font-pitch="variable"/>' . '<style:font-face style:name="Thorndale"' . ' svg:font-family="Thorndale" style:font-family-generic="roman"' . ' style:font-pitch="variable"/>' . '<style:font-face style:name="DejaVu Sans"' . ' svg:font-family="\'DejaVu Sans\'" style:font-family-generic="swiss"' . ' style:font-pitch="variable"/>' . '</office:font-face-decls>' . '<office:styles>' . '<style:default-style style:family="paragraph">' . '<style:paragraph-properties fo:hyphenation-ladder-count="no-limit"' . ' style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging"' . ' style:line-break="strict" style:tab-stop-distance="0.4925in"' . ' style:writing-mode="page"/>' . '<style:text-properties style:use-window-font-color="true"' . ' style:font-name="DejaVu Serif" fo:font-size="12pt" fo:language="en"' . ' fo:country="US" style:font-name-asian="DejaVu Sans1"' . ' style:font-size-asian="12pt" style:language-asian="none"' . ' style:country-asian="none" style:font-name-complex="DejaVu Sans1"' . ' style:font-size-complex="12pt" style:language-complex="none"' . ' style:country-complex="none" fo:hyphenate="false"' . ' fo:hyphenation-remain-char-count="2"' . ' fo:hyphenation-push-char-count="2"/>' . '</style:default-style>' . '<style:style style:name="Standard" style:family="paragraph"' . ' style:class="text"/>' . '<style:style style:name="Text_body" style:display-name="Text body"' . ' style:family="paragraph" style:parent-style-name="Standard"' . ' style:class="text">' . '<style:paragraph-properties fo:margin-top="0in"' . ' fo:margin-bottom="0.0835in"/>' . '</style:style>' . '<style:style style:name="Heading" style:family="paragraph"' . ' style:parent-style-name="Standard" style:next-style-name="Text_body"' . ' style:class="text">' . '<style:paragraph-properties fo:margin-top="0.1665in"' . ' fo:margin-bottom="0.0835in" fo:keep-with-next="always"/>' . '<style:text-properties style:font-name="DejaVu Sans" fo:font-size="14pt"' . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="14pt"' . ' style:font-name-complex="DejaVu Sans1" style:font-size-complex="14pt"/>' . '</style:style>' . '<style:style style:name="Heading_1" style:display-name="Heading 1"' . ' style:family="paragraph" style:parent-style-name="Heading"' . ' style:next-style-name="Text_body" style:class="text"' . ' style:default-outline-level="1">' . '<style:text-properties style:font-name="Thorndale" fo:font-size="24pt"' . ' fo:font-weight="bold" style:font-name-asian="HG Mincho Light J"' . ' style:font-size-asian="24pt" style:font-weight-asian="bold"' . ' style:font-name-complex="Arial Unicode MS"' . ' style:font-size-complex="24pt" style:font-weight-complex="bold"/>' . '</style:style>' . '<style:style style:name="Heading_2" style:display-name="Heading 2"' . ' style:family="paragraph" style:parent-style-name="Heading"' . ' style:next-style-name="Text_body" style:class="text"' . ' style:default-outline-level="2">' . '<style:text-properties style:font-name="DejaVu Serif"' . ' fo:font-size="18pt" fo:font-weight="bold"' . ' style:font-name-asian="DejaVu Sans1" style:font-size-asian="18pt"' . ' style:font-weight-asian="bold" style:font-name-complex="DejaVu Sans1"' . ' style:font-size-complex="18pt" style:font-weight-complex="bold"/>' . '</style:style>' . '</office:styles>' . '<office:automatic-styles>' . '<style:page-layout style:name="pm1">' . '<style:page-layout-properties fo:page-width="8.2673in"' . ' fo:page-height="11.6925in" style:num-format="1"' . ' style:print-orientation="portrait" fo:margin-top="1in"' . ' fo:margin-bottom="1in" fo:margin-left="1.25in"' . ' fo:margin-right="1.25in" style:writing-mode="lr-tb"' . ' style:footnote-max-height="0in">' . '<style:footnote-sep style:width="0.0071in"' . ' style:distance-before-sep="0.0398in"' . ' style:distance-after-sep="0.0398in" style:adjustment="left"' . ' style:rel-width="25%" style:color="#000000"/>' . '</style:page-layout-properties>' . '<style:header-style/>' . '<style:footer-style/>' . '</style:page-layout>' . '</office:automatic-styles>' . '<office:master-styles>' . '<style:master-page style:name="Standard" style:page-layout-name="pm1"/>' . '</office:master-styles>' . '</office:document-styles>', 'styles.xml');
    $zipfile->addFile('<?xml version="1.0" encoding="UTF-8"?' . '>' . '<manifest:manifest' . ' xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">' . '<manifest:file-entry manifest:media-type="' . $mime . '" manifest:full-path="/"/>' . '<manifest:file-entry manifest:media-type="text/xml"' . ' manifest:full-path="content.xml"/>' . '<manifest:file-entry manifest:media-type="text/xml"' . ' manifest:full-path="meta.xml"/>' . '<manifest:file-entry manifest:media-type="text/xml"' . ' manifest:full-path="styles.xml"/>' . '</manifest:manifest>', 'META-INF/manifest.xml');
    return $zipfile->file();
}
コード例 #2
0
ファイル: export.lib.php プロジェクト: scriptpazar/phpmyadmin
/**
 * Compress the export buffer
 *
 * @param string $dump_buffer the current dump buffer
 * @param string $compression the compression mode
 * @param string $filename    the filename
 *
 * @return object $message a message object (or empty string)
 */
function PMA_compressExport($dump_buffer, $compression, $filename)
{
    if ($compression == 'zip' && @function_exists('gzcompress')) {
        $filename = substr($filename, 0, -4);
        // remove extension (.zip)
        $zipfile = new ZipFile();
        if (is_array($dump_buffer)) {
            foreach ($dump_buffer as $table => $dump) {
                $ext_pos = strpos($filename, '.');
                $extension = substr($filename, $ext_pos);
                $zipfile->addFile($dump, str_replace($extension, '_' . $table . $extension, $filename));
            }
        } else {
            $zipfile->addFile($dump_buffer, $filename);
        }
        $dump_buffer = $zipfile->file();
    } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
        // without the optional parameter level because it bugs
        $dump_buffer = gzencode($dump_buffer);
    }
    return $dump_buffer;
}
コード例 #3
0
ファイル: Admin.php プロジェクト: eadz/chyrp
 /**
  * Function: export
  * Export posts, pages, etc.
  */
 public function export()
 {
     if (!Visitor::current()->group->can("add_post")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to export content."));
     }
     if (empty($_POST)) {
         return $this->display("export");
     }
     $config = Config::current();
     $trigger = Trigger::current();
     $route = Route::current();
     $exports = array();
     if (isset($_POST['posts'])) {
         list($where, $params) = keywords($_POST['filter_posts'], "post_attributes.value LIKE :query OR url LIKE :query", "post_attributes");
         if (!empty($_GET['month'])) {
             $where["created_at like"] = $_GET['month'] . "-%";
         }
         $visitor = Visitor::current();
         if (!$visitor->group->can("view_draft", "edit_draft", "edit_post", "delete_draft", "delete_post")) {
             $where["user_id"] = $visitor->id;
         }
         $results = Post::find(array("placeholders" => true, "drafts" => true, "where" => $where, "params" => $params));
         $ids = array();
         foreach ($results[0] as $result) {
             $ids[] = $result["id"];
         }
         if (!empty($ids)) {
             $posts = Post::find(array("drafts" => true, "where" => array("id" => $ids), "order" => "id ASC"), array("filter" => false));
         } else {
             $posts = new Paginator(array());
         }
         $latest_timestamp = 0;
         foreach ($posts as $post) {
             if (strtotime($post->created_at) > $latest_timestamp) {
                 $latest_timestamp = strtotime($post->created_at);
             }
         }
         $id = substr(strstr($config->url, "//"), 2);
         $id = str_replace("#", "/", $id);
         $id = preg_replace("/(" . preg_quote(parse_url($config->url, PHP_URL_HOST)) . ")/", "\\1," . date("Y", $latest_timestamp) . ":", $id, 1);
         $posts_atom = '<?xml version="1.0" encoding="utf-8"?>' . "\r";
         $posts_atom .= '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:chyrp="http://chyrp.net/export/1.0/">' . "\r";
         $posts_atom .= '    <title>' . fix($config->name) . ' Posts</title>' . "\r";
         $posts_atom .= '    <subtitle>' . fix($config->description) . '</subtitle>' . "\r";
         $posts_atom .= '    <id>tag:' . parse_url($config->url, PHP_URL_HOST) . ',' . date("Y", $latest_timestamp) . ':Chyrp</id>' . "\r";
         $posts_atom .= '    <updated>' . date("c", $latest_timestamp) . '</updated>' . "\r";
         $posts_atom .= '    <link href="' . $config->url . '" rel="self" type="application/atom+xml" />' . "\r";
         $posts_atom .= '    <generator uri="http://chyrp.net/" version="' . CHYRP_VERSION . '">Chyrp</generator>' . "\r";
         foreach ($posts as $post) {
             $title = fix($post->title(), false);
             fallback($title, ucfirst($post->feather) . " Post #" . $post->id);
             $updated = $post->updated ? $post->updated_at : $post->created_at;
             $tagged = substr(strstr(url("id/" . $post->id), "//"), 2);
             $tagged = str_replace("#", "/", $tagged);
             $tagged = preg_replace("/(" . preg_quote(parse_url($post->url(), PHP_URL_HOST)) . ")/", "\\1," . when("Y-m-d", $updated) . ":", $tagged, 1);
             $url = $post->url();
             $posts_atom .= '    <entry xml:base="' . fix($url) . '">' . "\r";
             $posts_atom .= '        <title type="html">' . $title . '</title>' . "\r";
             $posts_atom .= '        <id>tag:' . $tagged . '</id>' . "\r";
             $posts_atom .= '        <updated>' . when("c", $updated) . '</updated>' . "\r";
             $posts_atom .= '        <published>' . when("c", $post->created_at) . '</published>' . "\r";
             $posts_atom .= '        <link href="' . fix($trigger->filter($url, "post_export_url", $post)) . '" />' . "\r";
             $posts_atom .= '        <author chyrp:user_id="' . $post->user_id . '">' . "\r";
             $posts_atom .= '            <name>' . fix(oneof($post->user->full_name, $post->user->login)) . '</name>' . "\r";
             if (!empty($post->user->website)) {
                 $posts_atom .= '            <uri>' . fix($post->user->website) . '</uri>' . "\r";
             }
             $posts_atom .= '            <chyrp:login>' . fix($post->user->login) . '</chyrp:login>' . "\r";
             $posts_atom .= '        </author>' . "\r";
             $posts_atom .= '        <content>' . "\r";
             foreach ($post->attributes as $key => $val) {
                 $posts_atom .= '            <' . $key . '>' . fix($val) . '</' . $key . '>' . "\r";
             }
             $posts_atom .= '        </content>' . "\r";
             foreach (array("feather", "clean", "url", "pinned", "status") as $attr) {
                 $posts_atom .= '        <chyrp:' . $attr . '>' . fix($post->{$attr}) . '</chyrp:' . $attr . '>' . "\r";
             }
             $trigger->filter($posts_atom, "posts_export", $post);
             $posts_atom .= '    </entry>' . "\r";
         }
         $posts_atom .= '</feed>' . "\r";
         $exports["posts.atom"] = $posts_atom;
     }
     if (isset($_POST['pages'])) {
         list($where, $params) = keywords($_POST['filter_pages'], "title LIKE :query OR body LIKE :query", "pages");
         $pages = Page::find(array("where" => $where, "params" => $params, "order" => "id ASC"), array("filter" => false));
         $latest_timestamp = 0;
         foreach ($pages as $page) {
             if (strtotime($page->created_at) > $latest_timestamp) {
                 $latest_timestamp = strtotime($page->created_at);
             }
         }
         $pages_atom = '<?xml version="1.0" encoding="utf-8"?>' . "\r";
         $pages_atom .= '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:chyrp="http://chyrp.net/export/1.0/">' . "\r";
         $pages_atom .= '    <title>' . fix($config->name) . ' Pages</title>' . "\r";
         $pages_atom .= '    <subtitle>' . fix($config->description) . '</subtitle>' . "\r";
         $pages_atom .= '    <id>tag:' . parse_url($config->url, PHP_URL_HOST) . ',' . date("Y", $latest_timestamp) . ':Chyrp</id>' . "\r";
         $pages_atom .= '    <updated>' . date("c", $latest_timestamp) . '</updated>' . "\r";
         $pages_atom .= '    <link href="' . $config->url . '" rel="self" type="application/atom+xml" />' . "\r";
         $pages_atom .= '    <generator uri="http://chyrp.net/" version="' . CHYRP_VERSION . '">Chyrp</generator>' . "\r";
         foreach ($pages as $page) {
             $updated = $page->updated ? $page->updated_at : $page->created_at;
             $tagged = substr(strstr($page->url(), "//"), 2);
             $tagged = str_replace("#", "/", $tagged);
             $tagged = preg_replace("/(" . preg_quote(parse_url($page->url(), PHP_URL_HOST)) . ")/", "\\1," . when("Y-m-d", $updated) . ":", $tagged, 1);
             $url = $page->url();
             $pages_atom .= '    <entry xml:base="' . fix($url) . '" chyrp:parent_id="' . $page->parent_id . '">' . "\r";
             $pages_atom .= '        <title type="html">' . fix($page->title) . '</title>' . "\r";
             $pages_atom .= '        <id>tag:' . $tagged . '</id>' . "\r";
             $pages_atom .= '        <updated>' . when("c", $updated) . '</updated>' . "\r";
             $pages_atom .= '        <published>' . when("c", $page->created_at) . '</published>' . "\r";
             $pages_atom .= '        <link href="' . fix($trigger->filter($url, "page_export_url", $page)) . '" />' . "\r";
             $pages_atom .= '        <author chyrp:user_id="' . fix($page->user_id) . '">' . "\r";
             $pages_atom .= '            <name>' . fix(oneof($page->user->full_name, $page->user->login)) . '</name>' . "\r";
             if (!empty($page->user->website)) {
                 $pages_atom .= '            <uri>' . fix($page->user->website) . '</uri>' . "\r";
             }
             $pages_atom .= '            <chyrp:login>' . fix($page->user->login) . '</chyrp:login>' . "\r";
             $pages_atom .= '        </author>' . "\r";
             $pages_atom .= '        <content type="html">' . fix($page->body) . '</content>' . "\r";
             foreach (array("show_in_list", "list_order", "clean", "url") as $attr) {
                 $pages_atom .= '        <chyrp:' . $attr . '>' . fix($page->{$attr}) . '</chyrp:' . $attr . '>' . "\r";
             }
             $trigger->filter($pages_atom, "pages_export", $page);
             $pages_atom .= '    </entry>' . "\r";
         }
         $pages_atom .= '</feed>' . "\r";
         $exports["pages.atom"] = $pages_atom;
     }
     if (isset($_POST['groups'])) {
         list($where, $params) = keywords($_POST['filter_groups'], "name LIKE :query", "groups");
         $groups = Group::find(array("where" => $where, "params" => $params, "order" => "id ASC"));
         $groups_yaml = array("groups" => array(), "permissions" => array());
         foreach (SQL::current()->select("permissions", "*", array("group_id" => 0))->fetchAll() as $permission) {
             $groups_yaml["permissions"][$permission["id"]] = $permission["name"];
         }
         foreach ($groups as $index => $group) {
             $groups_yaml["groups"][$group->name] = $group->permissions;
         }
         $exports["groups.yaml"] = YAML::dump($groups_yaml);
     }
     if (isset($_POST['users'])) {
         list($where, $params) = keywords($_POST['filter_users'], "login LIKE :query OR full_name LIKE :query OR email LIKE :query OR website LIKE :query", "users");
         $users = User::find(array("where" => $where, "params" => $params, "order" => "id ASC"));
         $users_yaml = array();
         foreach ($users as $user) {
             $users_yaml[$user->login] = array();
             foreach ($user as $name => $attr) {
                 if (!in_array($name, array("no_results", "group_id", "group", "id", "login", "belongs_to", "has_many", "has_one", "queryString"))) {
                     $users_yaml[$user->login][$name] = $attr;
                 } elseif ($name == "group_id") {
                     $users_yaml[$user->login]["group"] = $user->group->name;
                 }
             }
         }
         $exports["users.yaml"] = YAML::dump($users_yaml);
     }
     $trigger->filter($exports, "export");
     require INCLUDES_DIR . "/lib/zip.php";
     $zip = new ZipFile();
     foreach ($exports as $filename => $content) {
         $zip->addFile($content, $filename);
     }
     $zip_contents = $zip->file();
     $filename = sanitize(camelize($config->name), false, true) . "_Export_" . date("Y-m-d");
     header("Content-type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"" . $filename . ".zip\"");
     header("Content-length: " . strlen($zip_contents) . "\n\n");
     echo $zip_contents;
 }
コード例 #4
0
function makeZip($images_pack)
{
    require_once 'zip.lib.php';
    $zipGenerator = new ZipFile();
    for ($i = 0; $i < $images_pack['count']; $i++) {
        $image_str = $images_pack['images'][$i];
        $filename = $images_pack['fileNames'][$i];
        $zipGenerator->addFile($image_str, $filename);
    }
    return $zipGenerator->file();
}
コード例 #5
0
 /**
  *	Export Skin XML
  *	Export the skin files in XML
  *
  *	@param	string	XML File name
  *	@param	array	Skin key
  *	@param	array	Skin set
  *	@param	boolean	Download file
  *	@param	string	File compress (default -> gzip)
  *	@param	array	Force codekey
  *	@return	string	XML content
  */
 public function ExportXML($xml_file, $skin_key, $skin_set, $download = FALSE, $compress = "gzip", $force_codekey = array())
 {
     set_time_limit(0);
     ini_set("memory_limit", 128000000);
     $set_files = array();
     $css_files = array();
     $img_files = array();
     $rsc_files = array();
     $count_set = 0;
     $count_css = 0;
     $count_img = 0;
     $count_rsc = 0;
     parent::Lib('Sources')->OpenDatabase();
     parent::Lib('Sources')->GetSkin($skin_key, $skin_info);
     parent::Lib('Sources')->CloseDatabase();
     foreach ($skin_set as $key) {
         $all_files = array();
         parent::Lib('Database')->OpenDatabase($skin_key, $key);
         parent::Lib('Database')->GetAllFiles($all_files);
         parent::Lib('Database')->CloseDatabase();
         $_files = array();
         $_count = 0;
         foreach ($all_files as $name => $content) {
             $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
             $_files['template#:' . $_count++] = array("a:hash" => md5($content), "filename" => $name, "content" => "<![CDATA[" . str_replace(array("<![CDATA[", "]]>"), array("<!#^#|CDATA|", "|#^#]>"), $content) . "]]>");
         }
         $set_files['skin_set#:' . $count_set++] = array("name" => $key, "files" => $_files);
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_css/" . $skin_key)) {
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_css/" . $skin_key)) > 0) {
             $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                     if ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $css_files['css_file#:' . $count_css++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_images/" . $skin_key)) {
         $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_images/" . $skin_key)) > 0) {
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false) {
                     if ($fileinfo->isDir() == true) {
                         $my_array = $this->loadExporterSetDirectory("images_folder", "image_file", $fileinfo->getPathname());
                         $key_array = array("a:name" => $fileinfo->getFilename());
                         $img_files['images_folder#:' . $count_img++] = array_merge($key_array, $my_array);
                     } elseif ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $img_files['image_file#:' . $count_img++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     if (file_exists(CTM_PUBLIC_PATH . "style_resources/" . $skin_key)) {
         $spaces = chr(9) . chr(9) . chr(9) . chr(9) . chr(9);
         if (count($iterator = new DirectoryIterator(CTM_PUBLIC_PATH . "style_resources/" . $skin_key)) > 0) {
             foreach ($iterator as $fileinfo) {
                 if ($fileinfo->isDot() == false) {
                     if ($fileinfo->isDir() == true) {
                         $my_array = $this->loadExporterSetDirectory("resources_folder", "resource_file", $fileinfo->getPathname(), 1);
                         $key_array = array("a:name" => $fileinfo->getFilename());
                         $rsc_files['resources_folder#:' . $count_rsc++] = array_merge($key_array, $my_array);
                     } elseif ($fileinfo->isFile() == true || $fileinfo->isLink() == true) {
                         $file_name = $fileinfo->getFilename();
                         $file_data = file_get_contents($fileinfo->getPathname());
                         $rsc_files['resource_file#:' . $count_rsc++] = array("a:checksum" => md5_file($fileinfo->getPathname()), "name" => $file_name, "content" => "\r\n" . $spaces . rtrim(chunk_split(base64_encode($file_data), 80, "\r\n" . $spaces), "\r\n" . $spaces) . "\r\n" . substr($spaces, 1));
                     }
                 }
             }
         }
     }
     $_xml_inf = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_info" => array("skin_name" => $skin_info['Name'], "skin_key" => $skin_key, "skin_codekey" => $this->loadGenerateCodeKey($skin_key, $skin_info['Name'], $skin_info['CodeKey'], $force_codekey), "skin_author" => array("name" => $skin_info['Author']['Name'], "site" => $skin_info['Author']['Site']))));
     $_xml_set = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_templates" => $set_files));
     $_xml_css = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_css" => $css_files));
     $_xml_img = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_images" => $img_files));
     $_xml_rsc = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("style_resources" => $rsc_files));
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_inf, false, $xml_inf);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_set, false, $xml_set);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_css, false, $xml_css);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_img, false, $xml_img);
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $_xml_rsc, false, $xml_rsc);
     $spaces = chr(9) . chr(9);
     $skin_info = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_inf, "skin_info"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_templates = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_set, "skin_set"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_css = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_css, "skin_css"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_images = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_img, "skin_images"), 80, "\n" . $spaces), "\n" . $spaces);
     $skin_resources = $spaces . rtrim(chunk_split($this->loadXMLEncode($xml_rsc, "skin_resources"), 80, "\n" . $spaces), "\n" . $spaces);
     $xml = array("Header" => array("1.0", "UTF-8"), "Attributes" => array("creator" => "(CTM) Cetemaster Services", "system" => $this->settings['SystemName'], "version" => $this->settings['Version']), "Elements" => array("skin_info" => "\n" . $skin_info . "\n" . substr($spaces, 1), "skin_templates" => "\n" . $skin_templates . "\n" . substr($spaces, 1), "skin_css" => "\n" . $skin_css . "\n" . substr($spaces, 1), "skin_images" => "\n" . $skin_images . "\n" . substr($spaces, 1), "skin_resources" => "\n" . $skin_resources . "\n" . substr($spaces, 1)));
     CTM_FileManage::Lib('XML')->CreateXML("skin_xml", $xml, false, $xml_source);
     if ($download == true) {
         if ($compress == "gzip" && function_exists("gzencode")) {
             $down_source = gzencode($xml_source, 9);
             $down_suffix = ".gz";
         } elseif ($compress == "zip" && (class_exists("ZipArchive") || class_exists("ZipFile"))) {
             if (!class_exists("ZipArchive")) {
                 $zip = new ZipArchive();
                 $zip->open($filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "template__kernel::" . time() . "__zip") . ".tmp", ZipArchive::CREATE);
                 $zip->addFromString(self::TEMPLATE_ENGINE_EXPORT_FILE, $xml_source);
                 $zip->close();
                 $down_source = file_get_contents($filepath);
                 unlink($filepath);
             } else {
                 $zip = new ZipFile();
                 $zip->addFile($xml_source, self::TEMPLATE_ENGINE_EXPORT_FILE);
                 $down_source = $zip->file();
             }
             $down_suffix = ".zip";
         } else {
             $down_source = $xml_source;
             $down_suffix = NULL;
         }
         $length = strlen($down_source) + 3;
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: public");
         header("Content-Description: File Transfer");
         header("Content-type: application/octet-stream");
         header("Content-Disposition: attachment; filename=\"" . $xml_file . ".xml" . $down_suffix . "\"");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $length);
         ob_end_flush();
         ob_end_clean();
         exit($down_source);
     }
     return $xml_source;
 }
コード例 #6
0
ファイル: Releases.php プロジェクト: sebst3r/nZEDb
 /**
  * @param $guids
  *
  * @return string
  */
 public function getZipped($guids)
 {
     $nzb = new NZB($this->pdo);
     $zipFile = new \ZipFile();
     foreach ($guids as $guid) {
         $nzbPath = $nzb->NZBPath($guid);
         if ($nzbPath) {
             $nzbContents = Utility::unzipGzipFile($nzbPath);
             if ($nzbContents) {
                 $filename = $guid;
                 $r = $this->getByGuid($guid);
                 if ($r) {
                     $filename = $r['searchname'];
                 }
                 $zipFile->addFile($nzbContents, $filename . '.nzb');
             }
         }
     }
     return $zipFile->file();
 }
コード例 #7
0
ファイル: export.lib.php プロジェクト: pombredanne/ArcherSys
/**
 * Compress the export buffer
 *
 * @param string $dump_buffer the current dump buffer
 * @param string $compression the compression mode
 * @param string $filename    the filename
 *
 * @return object $message a message object (or empty string)
 */
function PMA_compressExport($dump_buffer, $compression, $filename)
{
    if ($compression == 'zip' && @function_exists('gzcompress')) {
        $zipfile = new ZipFile();
        $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
        $dump_buffer = $zipfile->file();
    } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
        // without the optional parameter level because it bugs
        $dump_buffer = gzencode($dump_buffer);
    }
    return $dump_buffer;
}
コード例 #8
0
ファイル: webapp.php プロジェクト: mindfeederllc/openemr
/**
 * @ignore
 */
define('PMA_MINIMUM_COMMON', true);
/**
 * Gets core libraries and defines some variables
 */
require './libraries/common.inc.php';
/**
 * ZIP file handler.
 */
require './libraries/zip.lib.php';
// ini file
$parameters = array('id' => 'phpMyAdmin@' . $_SERVER['HTTP_HOST'], 'uri' => $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'), 'status' => 'yes', 'location' => 'no', 'sidebar' => 'no', 'navigation' => 'no', 'icon' => 'phpMyAdmin');
// dom sript file
// none need yet
// icon
$icon = 'favicon.ico';
// name
$name = 'phpMyAdmin.webapp';
$ini_file = "[Parameters]\n";
foreach ($parameters as $key => $value) {
    $ini_file .= $key . '=' . $value . "\n";
}
PMA_downloadHeader($name, 'application/webapp', 0, false);
$zip = new ZipFile();
$zip->setDoWrite();
$zip->addFile($ini_file, 'webapp.ini');
$zip->addFile(file_get_contents($icon), 'phpMyAdmin.ico');
$zip->file();
コード例 #9
0
ファイル: fetch.php プロジェクト: syaofox/tumblr-images
/**
 * generate zip file stream
 * @param $arrImageStrings
 * @param $arrImageUrls
 * @return string
 */
function makeZipPack($arrImageStrings, $arrImageUrls)
{
    require_once 'zip.lib.php';
    $zipGenerator = new ZipFile();
    for ($i = 0, $length = sizeof($arrImageStrings); $i < $length; $i++) {
        $strImageString = $arrImageStrings[$i];
        $strImageUrl = $arrImageUrls[$i];
        $zipGenerator->addFile($strImageString, basename($strImageUrl));
    }
    return $zipGenerator->file();
}
コード例 #10
0
ファイル: export.php プロジェクト: GDantas05/WorkSeries
}
/**
 * Send the dump as a file...
 */
if (!empty($asfile)) {
    // Convert the charset if required.
    if ($output_charset_conversion) {
        $dump_buffer = PMA_convert_string('utf-8', $GLOBALS['charset_of_file'], $dump_buffer);
    }
    // Do the compression
    // 1. as a zipped file
    if ($compression == 'zip') {
        if (@function_exists('gzcompress')) {
            $zipfile = new ZipFile();
            $zipfile->addFile($dump_buffer, substr($filename, 0, -4));
            $dump_buffer = $zipfile->file();
        }
    } elseif ($compression == 'bzip2') {
        // 2. as a bzipped file
        if (@function_exists('bzcompress')) {
            $dump_buffer = bzcompress($dump_buffer);
        }
    } elseif ($compression == 'gzip' && PMA_gzencodeNeeded()) {
        // 3. as a gzipped file
        // without the optional parameter level because it bugs
        $dump_buffer = gzencode($dump_buffer);
    }
    /* If we saved on server, we have to close file now */
    if ($save_on_server) {
        $write_result = @fwrite($file_handle, $dump_buffer);
        fclose($file_handle);
コード例 #11
0
 public static function getImagesZipPack(&$images)
 {
     require_once 'zip.lib.php';
     $zip = new ZipFile(true);
     foreach ($images as $url => &$image) {
         if ($image) {
             $fileName = basename($url);
             $zip->addFile($image, $fileName);
         }
     }
     return $zip->file();
 }
コード例 #12
0
ファイル: analysis.php プロジェクト: ADMTec/effectweb-project
 /**
  *	Private: System Logs
  *	View and manage the system's logs
  *
  *	@return	void
  */
 private function loadSystemLogs()
 {
     if (!empty($_GET['load_file']) && !empty($_GET['folder'])) {
         if (array_key_exists($_GET['folder'], $this->logs_folders)) {
             $folder = $this->logs_folders[$_GET['folder']][0];
             $file = $folder . "-(" . str_replace(EW_LOG_EXT, NULL, $_GET['load_file']) . ")" . EW_LOG_EXT;
             $_GET['load_file'] = urldecode($_GET['load_file']);
             $GLOBALS['file_exists'] = file_exists(EW_LOG_PATH . $folder . "/" . $_GET['load_file']);
             if ($GLOBALS['file_exists'] == true) {
                 $GLOBALS['log_file_content'] = file_get_contents(EW_LOG_PATH . $folder . "/" . $_GET['load_file']);
             }
             if ($_GET['do'] == "download") {
                 if ($GLOBALS['file_exists'] == true) {
                     if (CTM_ACP_USE_ZIP == "gzip") {
                         showFileDownload($file . ".gz", gzencode($GLOBALS['log_file_content'], 9));
                     } elseif (CTM_ACP_USE_ZIP == "zip") {
                         if (class_exists("ZipArchive")) {
                             $zip = new ZipArchive();
                             $zip->open($filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp", ZipArchive::CREATE);
                             $zip->addFile(EW_LOG_PATH . $folder . "/" . $_GET['load_file'], $_GET['load_file']);
                             $zip->close();
                             $content = file_get_contents($filepath);
                             unlink($filepath);
                         } else {
                             $zip = new ZipFile();
                             $zip->addFile($GLOBALS['log_file_content'], $_GET['load_file'], filemtime(EW_LOG_PATH . $log . "/" . $filename));
                             $content = $zip->file();
                         }
                         showFileDownload($file . ".zip", $content);
                     } else {
                         showFileDownload($file, $GLOBALS['log_file_content']);
                     }
                 }
             } elseif ($_GET['do'] == "delete") {
                 if ($GLOBALS['file_exists'] == true) {
                     if (!unlink(EW_LOG_PATH . $folder . "/" . $_GET['load_file'])) {
                         $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['ShowLogs']['Messages']['DeleteError'];
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 2);
                     } else {
                         $url = "?app=core&module=system&section=analysis&index=logs&load_folder=" . $_GET['folder'] . "&message=file_deleted";
                         header("Location: " . CTM_URLEngine::URLBase() . $url);
                         exit;
                     }
                 }
             }
             $this->lang->setArguments("System,Analysis,SystemLogs,ShowLogs,Title", $_GET['load_file']);
             return $this->output->setContent("analysis_logsShowFile");
         } else {
             header("Location: " . CTM_URLEngine::URLBase() . "?app=core&module=system&section=analysis&index=logs");
         }
     } elseif (!empty($_GET['load_folder'])) {
         if (array_key_exists($_GET['load_folder'], $this->logs_folders)) {
             $log = $this->logs_folders[$_GET['load_folder']][0];
             if (!file_exists(EW_LOG_PATH . $log)) {
                 mkdir(EW_LOG_PATH . $log);
                 $GLOBALS['logs_files'] = array();
             } else {
                 if ($_GET['do'] == true) {
                     if ($_POST['DoCommand'] == "deleteFiles") {
                         $count = 0;
                         if (count($_POST) > 0) {
                             foreach ($_POST as $key => $value) {
                                 if (substr($key, 0, 6) == "file__" && $value == 1) {
                                     $file = substr($key, 6);
                                     $file = str_replace("_" . substr(EW_LOG_EXT, 1), EW_LOG_EXT, $file);
                                     if (file_exists(EW_LOG_PATH . $log . "/" . $file)) {
                                         unlink(EW_LOG_PATH . $log . "/" . $file);
                                         $count++;
                                     }
                                 }
                             }
                         }
                         $GLOBALS['result_command'] = sprintf($this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['FilesDeleted'], $count);
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                     } elseif ($_POST['DoCommand'] == "downloadFiles") {
                         $files_to_download = array();
                         if (count($_POST) > 0) {
                             foreach ($_POST as $key => $value) {
                                 if (substr($key, 0, 6) == "file__" && $value == 1) {
                                     $file = substr($key, 6);
                                     $file = str_replace("_" . substr(EW_LOG_EXT, 1), EW_LOG_EXT, $file);
                                     if (file_exists(EW_LOG_PATH . $log . "/" . $file)) {
                                         $files_to_download[] = $file;
                                     }
                                 }
                             }
                         }
                         if (count($files_to_download) == 0) {
                             $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['SelectFiles'];
                             $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                         } else {
                             if (class_exists("ZipArchive")) {
                                 $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp";
                                 $zip = new ZipArchive();
                                 $zip->open($filepath, ZipArchive::CREATE);
                             } else {
                                 $zip = new ZipFile();
                             }
                             foreach ($files_to_download as $filename) {
                                 if (class_exists("ZipArchive")) {
                                     $zip->addFile(EW_LOG_PATH . $log . "/" . $filename, $filename);
                                 } else {
                                     $content = file_get_contents(EW_LOG_PATH . $log . "/" . $filename);
                                     $time = filemtime(EW_LOG_PATH . $log . "/" . $filename);
                                     $zip->addFile($content, $filename, $time);
                                 }
                             }
                             if (class_exists("ZipArchive")) {
                                 $zip->close();
                                 $content = file_get_contents($filepath);
                                 unlink($filepath);
                             } else {
                                 $content = $zip->file();
                             }
                             showFileDownload($log . "_Logs.zip", $content);
                         }
                     } else {
                         $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['CategoryLogs']['Messages']['SelectAction'];
                         $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                     }
                 }
                 $GLOBALS['logs_files'] = array();
                 if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $log)) > 0) {
                     foreach ($iterator as $fileinfo) {
                         if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                             $extension = strrpos($fileinfo->getFilename(), ".");
                             $extension = substr($fileinfo->getFilename(), $extension);
                             if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) {
                                 $GLOBALS['logs_files'][$fileinfo->getFilename()] = array("change_data" => date("d/m/Y - H:i:s", $fileinfo->getMTime()), "file_size" => realFormatBytes($fileinfo->getSize()));
                             }
                         }
                     }
                 }
             }
             $this->lang->setArguments("System,Analysis,SystemLogs,CategoryLogs,Title", $this->logs_folders[$_GET['load_folder']][1]);
             return $this->output->setContent("analysis_logsFiles");
         } else {
             header("Location: " . CTM_URLEngine::URLBase() . "?app=core&module=system&section=analysis&index=logs");
         }
     } else {
         if ($_GET['do_folder'] == true) {
             if ($_POST['DoCommand'] != "clearFolders" && $_POST['DoCommand'] != "downloadFolders") {
                 $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectAction'];
                 $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
             } elseif ($_POST['DoCommand'] == "clearFolders") {
                 $folders_count = 0;
                 $files_count = 0;
                 $select_count = 0;
                 foreach ($_POST as $key => $value) {
                     if (substr($key, 0, 8) == "folder__" && $value == 1) {
                         $folder = substr($key, 8);
                         $tmp_count = 0;
                         $select_count++;
                         if (array_key_exists($folder, $this->logs_folders)) {
                             $folder = $this->logs_folders[substr($key, 8)][0];
                             if (!file_exists(EW_LOG_PATH . $folder)) {
                                 mkdir(EW_LOG_PATH . $folder);
                             }
                             if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $folder)) > 0) {
                                 foreach ($iterator as $fileinfo) {
                                     if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                                         $extension = strrpos($fileinfo->getFilename(), ".");
                                         $extension = substr($fileinfo->getFilename(), $extension);
                                         if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) {
                                             unlink(EW_LOG_PATH . $folder . "/" . $fileinfo->getFilename());
                                             $files_count++;
                                             $tmp_count++;
                                         }
                                     }
                                 }
                             }
                             if ($tmp_count > 0) {
                                 $folders_count++;
                             }
                         }
                     }
                 }
                 if ($select_count == 0) {
                     $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectFolders'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                 } else {
                     $this->lang->setTags("System,Analysis,SystemLogs,DoCommand,Messages,FoldersCleaned", $files_count, $folders_count);
                     $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['FoldersCleaned'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 3);
                 }
             } elseif ($_POST['DoCommand'] == "downloadFolders") {
                 $folders_to_download = array();
                 $select_count = 0;
                 foreach ($_POST as $key => $value) {
                     if (substr($key, 0, 8) == "folder__" && $value == 1) {
                         $folder = substr($key, 8);
                         $select_count++;
                         if (array_key_exists($folder, $this->logs_folders)) {
                             $folder = $this->logs_folders[substr($key, 8)][0];
                             $folders_to_download[$folder] = array();
                             if (!file_exists(EW_LOG_PATH . $folder)) {
                                 mkdir(EW_LOG_PATH . $folder);
                             }
                             if (count($iterator = new DirectoryIterator(EW_LOG_PATH . $folder)) > 0) {
                                 foreach ($iterator as $fileinfo) {
                                     if ($fileinfo->isDot() == false && $fileinfo->isDir() == false) {
                                         $extension = strrpos($fileinfo->getFilename(), ".");
                                         $extension = substr($fileinfo->getFilename(), $extension);
                                         if (($fileinfo->isFile() == true || $fileinfo->isLink() == true) && $extension == EW_LOG_EXT) {
                                             $folders_to_download[$folder][$fileinfo->getFilename()] = $fileinfo->getMTime();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if ($select_count == 0) {
                     $GLOBALS['result_command'] = $this->lang->words['System']['Analysis']['SystemLogs']['DoCommand']['Messages']['SelectFolders'];
                     $GLOBALS['result_command'] = adminShowMessage($GLOBALS['result_command'], 1);
                 } else {
                     if (class_exists("ZipArchive")) {
                         $filepath = CTM_CACHE_PATH . "temp_cache/" . md5(mt_rand() . "log__::" . time() . "__zip") . ".tmp";
                         $zip = new ZipArchive();
                         $zip->open($filepath, ZipArchive::CREATE);
                     } else {
                         $zip = new ZipFile();
                     }
                     foreach ($folders_to_download as $folder => $files) {
                         if (class_exists("ZipArchive")) {
                             $zip->addEmptyDir($folder);
                         } else {
                             $zip->addFile(NULL, $folder . "/");
                         }
                         if (count($files) > 0) {
                             foreach ($files as $filename => $filetime) {
                                 if (class_exists("ZipArchive")) {
                                     $zip->addFile(EW_LOG_PATH . $folder . "/" . $filename, $folder . "/" . $filename);
                                 } else {
                                     $content = file_get_contents(EW_LOG_PATH . $folder . "/" . $filename);
                                     $zip->addFile($content, $folder . "/" . $filename, $filetime);
                                 }
                             }
                         }
                     }
                     if (class_exists("ZipArchive")) {
                         $zip->close();
                         $content = file_get_contents($filepath);
                         unlink($filepath);
                     } else {
                         $content = $zip->file();
                     }
                     showFileDownload(sprintf($this->logs_zip_file['name'], date($this->logs_zip_file['date'])) . ".zip", $content);
                 }
             }
         }
         foreach ($this->logs_folders as $key => $value) {
             $GLOBALS['logs_folders'][$key] = array("name" => $value[1], "count_files" => number_format(intval(count(glob(EW_LOG_PATH . $value[0] . "/*" . EW_LOG_EXT))), 0, false, "."));
         }
         $this->output->setContent("analysis_logs");
         if (loadIsAjax() == true) {
             $this->output->setVariable("no_set_tmp", true);
         }
     }
 }
コード例 #13
0
function make_zip(&$imgs_and_urls)
{
    require_once 'zip.lib.php';
    $zip = new ZipFile();
    foreach ($imgs_and_urls['valid_images'] as $url => $img) {
        $zip->addFile($img, basename($url));
    }
    if ($imgs_and_urls['invalid_image_urls']) {
        $msg = "images list below cannot be found: \r\n";
        $msg .= implode("\r\n", $imgs_and_urls['invalid_image_urls']);
        $zip->addFile($msg, 'failed_list.txt');
    }
    return $zip->file();
}
コード例 #14
0
 public function getCode($arr)
 {
     $ModelPHPCode = "";
     $ControllerPHPCode = "";
     $zipfile = new ZipFile();
     foreach ($arr as $k => $v) {
         ## MODEL Class
         $ModelPHPCode = "";
         $ModelPHPCode .= "<" . "?php\r\n";
         $ModelPHPCode .= "/*\r\n\t@PHPClassCreator [Doctrine + CodeIgniter]\r\n\t@Autor: Esteban Fuentealba\r\n\t@Email:\tmi [dot] warezx [at] gmail [dot] com\r\n*/\r\n";
         $ModelPHPCode .= "// models/" . $v['class']['name'] . ".php\r\n";
         $ModelPHPCode .= "class " . $v['class']['name'] . " extends Doctrine_Record {\r\n";
         ## setTableDefinition
         $ModelPHPCode .= "\tpublic function setTableDefinition() {\r\n";
         foreach ($v['class']['method']['setTableDefinition'] as $index => $valor) {
             $ModelPHPCode .= "\t\t" . $valor . "\r\n";
         }
         $ModelPHPCode .= "\t}\r\n";
         ## setUp
         $ModelPHPCode .= "\tpublic function setUp() {\r\n";
         foreach ($v['class']['method']['setUp'] as $index => $valor) {
             foreach ($valor as $key => $val) {
                 $ModelPHPCode .= "\t\t" . $val . "\r\n";
             }
         }
         $ModelPHPCode .= "\t}\r\n";
         $ModelPHPCode .= "}\r\n";
         if ($this->debug) {
             echo $ModelPHPCode;
         } else {
             $zipfile->add_file($ModelPHPCode, "system/application/models/" . $v['class']['name'] . ".php");
         }
         ## FIN CLASS MODEL
         ## CONTROLLER MODEL
         $ControllerPHPCode = "";
         $ControllerPHPCode .= "<" . "?php\r\n";
         $ControllerPHPCode .= "/*\r\n\t@PHPClassCreator [Doctrine + CodeIgniter]\r\n\t@Autor: Esteban Fuentealba\r\n\t@Email:\tmi [dot] warezx [at] gmail [dot] com\r\n*/\r\n";
         $ControllerPHPCode .= "// system/application/controllers/" . $v['class']['name'] . "Controller.php\r\n";
         $ControllerPHPCode .= "require_once(dirname(__FILE__) .'/KoalaController.class.php');\r\n";
         $ControllerPHPCode .= "class " . $v['class']['name'] . "Controller extends KoalaController {\r\n";
         ## CONSTRUCTOR
         $ControllerPHPCode .= "\tpublic function __construct() {\r\n";
         $ControllerPHPCode .= "\t\tparent::Controller();\r\n";
         $ControllerPHPCode .= "\t\tparse_str(\$" . "_SERVER['QUERY_STRING'],\$" . "_GET);\r\n";
         $ControllerPHPCode .= "\t}\r\n";
         ## METHOD INSERT
         $ControllerPHPCode .= "\tpublic function Insert() {\r\n";
         $ControllerPHPCode .= "\t\t\$" . "clean = \$" . "this->input->xss_clean(\$" . "_GET);\r\n";
         $ControllerPHPCode .= "\t\t\$" . "c = new " . $v['class']['name'] . "();\r\n";
         $ControllerPHPCode .= "\t\ttry {\r\n";
         $ControllerPHPCode .= "\t\t\tforeach(\$" . "clean as \$" . "param => \$" . "value) {\r\n";
         $ControllerPHPCode .= "\t\t\t\t\$" . "c->\$" . "param = isset(\$" . "value) ? \$" . "value : null;\r\n";
         $ControllerPHPCode .= "\t\t\t}\r\n";
         $ControllerPHPCode .= "\t\t} catch(Doctrine_Record_UnknownPropertyException \$" . "e) {\r\n";
         $ControllerPHPCode .= "\t\t\t//xD\r\n";
         $ControllerPHPCode .= "\t\t}\r\n";
         $ControllerPHPCode .= "\t\ttry {\r\n";
         $ControllerPHPCode .= "\t\t\tforeach(\$" . "clean as \$" . "param => \$" . "value) {\r\n";
         $ControllerPHPCode .= "\t\t\t\t\$" . "c->\$" . "param = isset(\$" . "value) ? \$" . "value : null;\r\n";
         $ControllerPHPCode .= "\t\t\t}\r\n";
         $ControllerPHPCode .= "\t\t} catch(Doctrine_Record_UnknownPropertyException \$" . "e) {\r\n";
         $ControllerPHPCode .= "\t\t\t//xD\r\n";
         $ControllerPHPCode .= "\t\t}\r\n";
         $ControllerPHPCode .= "\t}\r\n";
         $ControllerPHPCode .= "}\r\n";
         ## FIN CONTROLLER MODEL
         if ($this->debug) {
             echo $ControllerPHPCode;
         } else {
             $zipfile->add_file($ControllerPHPCode, "system/application/models/" . $v['class']['name'] . "Controller.php");
         }
     }
     if (!$this->debug) {
         header("Content-type: application/octet-stream");
         header("Content-disposition: attachment; filename=PHPClassCreator-" . time() . ".zip");
         echo $zipfile->file();
     }
 }
コード例 #15
0
/**
 * Download images, pack into a zip, return as zip string.
 * @param Array $imageSources
 * @return Array
 */
function getImageZipAndValidSrc($imageSources)
{
    require_once 'zip.lib.php';
    $zip = new ZipFile();
    $validSrc = array();
    foreach ($imageSources as $source) {
        $image = file_get_contents($source);
        if (in_array(parseHeaders($http_response_header, 'status'), array(200, 301, 304))) {
            $zip->addFile($image, basename($source));
            $validSrc[] = $source;
        }
    }
    return array('zipFile' => $zip->file(), 'validSrc' => $validSrc);
}