当前位置: 首页>>代码示例>>PHP>>正文


PHP unzip_file函数代码示例

本文整理汇总了PHP中unzip_file函数的典型用法代码示例。如果您正苦于以下问题:PHP unzip_file函数的具体用法?PHP unzip_file怎么用?PHP unzip_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了unzip_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_widget

 function add_widget($fileName, $tempName)
 {
     $dest = wp_upload_dir();
     if ($fileName == null) {
         $name = $_SESSION['name'];
     }
     if ($_POST['file'] == null) {
         $zipDestination = $dest['basedir'] . $fileName;
         move_uploaded_file($tempName, $zipDestination);
         $zipDestination = str_replace('\\', '/', $zipDestination);
         //slash corection if nessary
         $_POST['file'] = $zipDestination;
         $_POST['name'] = $fileName;
         $form_fields = array('file', 'name');
     }
     if (self::connect_fs('', "POST", get_option('widgetdir'), $form_fields)) {
         $destination = get_option('widgetdir') . $fileName;
         $file = $_POST['file'];
         $unzip = unzip_file($file, $destination);
         if (is_wp_error($unzip)) {
             $_SESSION['errors'] = ' <div class="errorNotfi">' . $unzip->get_error_message() . '</div>';
         } else {
             $_SESSION['errors'] = NULL;
         }
         unlink($file);
         return TRUE;
     }
     $_SESSION['name'] = NULL;
 }
开发者ID:JasonDarkX2,项目名称:Wordpress-WidgetManager,代码行数:29,代码来源:widgetAdder.php

示例2: unpack_package_zip

 function unpack_package_zip($package, $delete_package = true)
 {
     global $wp_filesystem;
     $this->skin->feedback($this->strings['unpack_package'] . ' (' . basename($package) . ')');
     $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
     //Clean up contents of upgrade directory beforehand.
     $upgrade_files = $wp_filesystem->dirlist($upgrade_folder);
     if (!empty($upgrade_files)) {
         foreach ($upgrade_files as $file) {
             $wp_filesystem->delete($upgrade_folder . $file['name'], true);
         }
     }
     //We need a working directory
     #This is the only change from the WP core version - minimise path length
     #$working_dir = $upgrade_folder . basename($package, '.zip');
     $working_dir = $upgrade_folder . substr(md5($package), 0, 8);
     // Clean up working directory
     if ($wp_filesystem->is_dir($working_dir)) {
         $wp_filesystem->delete($working_dir, true);
     }
     // Unzip package to working directory
     $result = unzip_file($package, $working_dir);
     // Once extracted, delete the package if required.
     if ($delete_package) {
         unlink($package);
     }
     if (is_wp_error($result)) {
         $wp_filesystem->delete($working_dir, true);
         if ('incompatible_archive' == $result->get_error_code()) {
             return new WP_Error('incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data());
         }
         return $result;
     }
     return $working_dir;
 }
开发者ID:jeanpage,项目名称:ca_learn,代码行数:35,代码来源:restorer.php

示例3: get_zip_data

function get_zip_data($basename, $imgselect, $imgext, $getimage, $getdata, &$imgtempfile, &$imagename, &$data)
{
    $ret = 0;
    $zipname = IMGPATH . "/" . $basename . ".zip";
    if (file_exists($zipname)) {
        // make sure we keep the file around if people are using it actively
        touch($zipname);
        if ($getimage) {
            $imagename = "button_{$imgselect}.{$imgext}";
            $buf = unzip_file($zipname, $imagename);
            //      $buf = shell_exec("unzip -p ".$zipname." ".$imagename);
            $tmpfname = tempnam(IMGPATH, "");
            if ($file = fopen($tmpfname, "w+")) {
                fwrite($file, $buf);
                fclose($file);
                $imgtempfile = $tmpfname;
                $ret = filesize($tmpfname);
            }
        } elseif ($getdata) {
            $buf = unzip_file($zipname, READMENAME);
            //      $buf = shell_exec("unzip -p ".$zipname." ".READMENAME);
            // for each $readmetags, get the associated value and put in an array
            $data = array();
            $readmetags = array(TAGBT, TAGPC, TAGGC, TAGW, TAGH, TAGCR, TAGTH, TAGTC, TAGBC, TAGFN, TAGRPC, TAGRGC, TAGRTC, TAGQ, TAGURL, TAGIL, TAGIH, TAGIN, TAGIF, TAGIFC, TAGIT, TAGITC);
            foreach ($readmetags as $tag) {
                $tempstr = substr(strstr($buf, $tag . ": "), strlen($tag) + 2);
                $data[$tag] = substr($tempstr, 0, strpos($tempstr, "\n"));
            }
            $ret = 1;
        }
    }
    return $ret;
}
开发者ID:tiggerntatie,项目名称:Buttonmill-glassy-buttons,代码行数:33,代码来源:buttonincludes.php

示例4: _validate_form

 protected function _validate_form()
 {
     $url = wp_nonce_url('admin.php?page=vimeography-my-themes');
     if (false === ($creds = request_filesystem_credentials($url))) {
         // if we get here, then we don't have credentials yet,
         // but have just produced a form for the user to fill in,
         // so stop processing for now
         return true;
         // stop the normal page form from displaying
     }
     // now we have some credentials, try to get the wp_filesystem running
     if (!WP_Filesystem($creds)) {
         // our credentials were no good, ask the user for them again
         request_filesystem_credentials($url);
         return true;
     }
     if (empty($_FILES)) {
         return;
     }
     // if this fails, check_admin_referer() will automatically print a "failed" page and die.
     if (!empty($_FILES) && check_admin_referer('vimeography-install-theme', 'vimeography-theme-verification')) {
         $name = substr(wp_filter_nohtml_kses($_FILES['vimeography-theme']['name']), 0, -4);
         if ($_FILES['vimeography-theme']['type'] != 'application/zip') {
             $this->messages[] = array('type' => 'error', 'heading' => 'Ruh Roh.', 'message' => 'Make sure you are uploading the actual .zip file, not a subfolder or file.');
         } else {
             global $wp_filesystem;
             if (!unzip_file($_FILES['vimeography-theme']['tmp_name'], VIMEOGRAPHY_THEME_PATH)) {
                 $this->messages[] = array('type' => 'error', 'heading' => 'Ruh Roh.', 'message' => 'The theme could not be installed.');
             } else {
                 $this->messages[] = array('type' => 'success', 'heading' => 'Theme installed.', 'message' => 'You can now use the "' . $name . '" theme in your galleries.');
             }
         }
     }
 }
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:34,代码来源:list.php

示例5: extractFile

function extractFile($zip_file, $file_in_zip)
{
    global $base_tmp_upgrade_dir;
    $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
    unzip_file($zip_file, $file_in_zip, $my_zip_dir);
    return "{$my_zip_dir}/{$file_in_zip}";
}
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:7,代码来源:UpgradeWizardCommon.php

示例6: installFile

 public function installFile()
 {
     $hash = md5(uniqid());
     $tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_plugin_" . $hash;
     mkdir($tmp_folder);
     $file = $GLOBALS['TMP_PATH'] . "/temp_plugin_" . $hash . ".zip";
     if ($this['repository_download_url']) {
         file_put_contents($file, file_get_contents($this['repository_download_url']));
     } elseif ($_FILES['release_file']['tmp_name']) {
         move_uploaded_file($_FILES['release_file']['tmp_name'], $file);
     } else {
         return false;
     }
     unzip_file($file, $tmp_folder);
     $objects = scandir($tmp_folder);
     if (count($objects) === 3) {
         foreach ($objects as $object) {
             if ($object != "." && $object != "..") {
                 $plugin_dir = $tmp_folder . "/" . $object;
             }
         }
     } else {
         $plugin_dir = $tmp_folder;
     }
     $this->installFromDirectory($plugin_dir, $file);
     rmdirr($tmp_folder);
     unlink($file);
     $this['chdate'] = time();
     NotificationCenter::postNotification("PluginReleaseDidUpdateCode", $this);
 }
开发者ID:studip,项目名称:PluginMarket,代码行数:30,代码来源:MarketRelease.class.php

示例7: getDownloadUrl

 protected function getDownloadUrl()
 {
     global $wp_filesystem;
     $this->skin->feedback('download_envato');
     $package_filename = 'js_composer.zip';
     $res = $this->fs_connect(array(WP_CONTENT_DIR));
     if (!$res) {
         return new WP_Error('no_credentials', __("Error! Can't connect to filesystem", 'js_composer'));
     }
     $username = WPBakeryVisualComposerSettings::get('envato_username');
     $api_key = WPBakeryVisualComposerSettings::get('envato_api_key');
     $purchase_code = WPBakeryVisualComposerSettings::get('js_composer_purchase_code');
     if (empty($username) || empty($api_key) || empty($purchase_code)) {
         return new WP_Error('no_credentials', __('Error! Envato username, api key and your purchase code are required for downloading updates from Envato marketplace for the Visual Composer. Visit <a href="' . admin_url('options-general.php?page=wpb_vc_settings&tab=updater') . '' . '">Settings</a> to fix.', 'js_composer'));
     }
     $json = wp_remote_get($this->envatoDownloadPurchaseUrl($username, $api_key, $purchase_code));
     $result = json_decode($json['body'], true);
     if (!isset($result['download-purchase']['download_url'])) {
         return new WP_Error('no_credentials', __('Error! Envato API error' . (isset($result['error']) ? ': ' . $result['error'] : '.'), 'js_composer'));
     }
     $result['download-purchase']['download_url'];
     $download_file = download_url($result['download-purchase']['download_url']);
     if (is_wp_error($download_file)) {
         return $download_file;
     }
     $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade_tmp/js_composer_envato_package';
     if (is_dir($upgrade_folder)) {
         $wp_filesystem->delete($upgrade_folder);
     }
     $result = unzip_file($download_file, $upgrade_folder);
     if ($result && is_file($upgrade_folder . '/' . $package_filename)) {
         return $upgrade_folder . '/' . $package_filename;
     }
     return new WP_Error('no_credentials', __('Error on unzipping package', 'js_composer'));
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:35,代码来源:wpb_automatic_updater.php

示例8: synved_option_item_addon_install

 function synved_option_item_addon_install($id, $name, $item)
 {
     $return = null;
     $type = synved_option_item_type($item);
     $target = synved_option_item_property($item, 'target');
     $folder = synved_option_item_property($item, 'folder');
     $field_name = synved_option_name_default($id);
     $path = null;
     if (file_exists($target)) {
         $path = $target;
     }
     if ($type != 'addon' || $path == null) {
         return false;
     }
     $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
     if (substr($path, -1) != DIRECTORY_SEPARATOR) {
         $path .= DIRECTORY_SEPARATOR;
     }
     if (isset($_FILES[$field_name])) {
         foreach ($_FILES[$field_name]["error"] as $key => $error) {
             if ($key == $name && $error == UPLOAD_ERR_OK) {
                 $tmp_name = $_FILES[$field_name]["tmp_name"][$key];
                 $name = $_FILES[$field_name]["name"][$key];
                 $tmpfname = wp_tempnam($name . '.zip');
                 if (move_uploaded_file($tmp_name, $tmpfname)) {
                     global $wp_filesystem;
                     $unzip_path = realpath($path);
                     $dirs = glob($path . '*', GLOB_ONLYDIR);
                     if ($wp_filesystem != null) {
                         $unzip_path = $wp_filesystem->find_folder($unzip_path);
                     }
                     wp_mkdir_p(realpath($path));
                     $return = unzip_file($tmpfname, $unzip_path);
                     if ($wp_filesystem != null) {
                         $wp_filesystem->delete($tmpfname);
                     }
                     $dirs_new = glob($path . '*', GLOB_ONLYDIR);
                     $dirs_diff = array_values(array_diff($dirs_new, $dirs));
                     $addon_path = $path;
                     if ($dirs_diff != null) {
                         $folder_path = null;
                         foreach ($dirs_diff as $dir) {
                             if (basename($dir) == $folder) {
                                 $folder_path = $dir;
                             }
                         }
                         // XXX no correct path, was unzip successful?
                         if ($folder_path == null) {
                             $folder_path = $dirs_diff[0];
                         }
                         $addon_path = $folder_path;
                     }
                     synved_option_set($id, $name, $addon_path);
                 }
             }
         }
     }
     return $return;
 }
开发者ID:nihrain,项目名称:accelerate,代码行数:59,代码来源:option-type-addon.php

示例9: widget_output

    /**
     * This function will execute the widget frontend logic.
     * Everything you want in the widget should be output here.
     */
    private function widget_output($args, $instance)
    {
        extract($instance);
        $file_name = 'Losungen Free ' . date('Y') . '.xml';
        # determin/create content path
        $file_path = wp_upload_dir()['basedir'] . '/losung/';
        if (!is_dir($file_path)) {
            mkdir($file_path, 0777, true);
        }
        # download content if not existing
        if (!file_exists($file_path . $file_name)) {
            $archive_name = 'Losung_' . date('Y') . '_XML.zip';
            WP_Filesystem();
            file_put_contents($file_path . $archive_name, file_get_contents('http://www.brueder-unitaet.de/download/' . $archive_name));
            if (!unzip_file($file_path . $archive_name, $file_path)) {
                echo "Error, could not get Content.";
                exit;
            }
        }
        # parse xml -> get data
        $xml_data = simplexml_load_file($file_path . $file_name);
        # get day of the year
        $index = (int) date('z');
        $losung = $xml_data->Losungen[$index];
        ?>
            <p style="clear: right; padding-bottom: .8em">
                <?php 
        echo $losung->Losungstext;
        ?>
<br>
                <small style="float: right""><?php 
        echo $losung->Losungsvers;
        ?>
</small>
            </p>
            <p style="clear: right; padding-bottom: .8em;">
                <?php 
        echo $losung->Lehrtext;
        ?>
<br>
                <small style="float: right""><?php 
        echo $losung->Lehrtextvers;
        ?>
</small>
            </p>
            <p>
                <small>
                    <a href="http://herrnhuter.de" target="blank">
                        © Evangelische Brüder-Unität – Herrnhuter Brüdergemeine
                    </a>
                    Weitere Infos unter: <a target="blank" 
href="http://losung.de">www.losung.de</a>
                </small>
            </p>
        <?php 
    }
开发者ID:johannesreichard,项目名称:wordpress_die_losung,代码行数:60,代码来源:losung.php

示例10: extractFile

function extractFile($zip_file, $file_in_zip)
{
    global $base_tmp_upgrade_dir;
    if (empty($base_tmp_upgrade_dir)) {
        $base_tmp_upgrade_dir = $GLOBALS['sugar_config']['upload_dir'] . "upgrades/temp";
    }
    $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
    unzip_file($zip_file, $file_in_zip, $my_zip_dir);
    return "{$my_zip_dir}/{$file_in_zip}";
}
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:10,代码来源:UpgradeWizardCommon.php

示例11: extractFile

function extractFile($zip_file, $file_in_zip)
{
    global $base_tmp_upgrade_dir;
    if (empty($base_tmp_upgrade_dir)) {
        $base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
    }
    $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
    unzip_file($zip_file, $file_in_zip, $my_zip_dir);
    return "{$my_zip_dir}/{$file_in_zip}";
}
开发者ID:sunmo,项目名称:snowlotus,代码行数:10,代码来源:UpgradeWizardCommon.php

示例12: extractFile

 public static function extractFile($zip_file, $file_in_zip)
 {
     global $base_tmp_upgrade_dir;
     if (empty($base_tmp_upgrade_dir)) {
         $base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
     }
     $my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
     register_shutdown_function('rmdir_recursive', $my_zip_dir);
     unzip_file($zip_file, $file_in_zip, $my_zip_dir);
     return "{$my_zip_dir}/{$file_in_zip}";
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:11,代码来源:UpgradeWizardCommon.php

示例13: getDownloadUrl

 protected function getDownloadUrl()
 {
     require_once ABSPATH . '/wp-admin/includes/file.php';
     WP_Filesystem();
     global $wp_filesystem;
     $this->skin->feedback('download_envato');
     $package_filename = 'Ultimate_VC_Addons.zip';
     $res = $this->fs_connect(array(WP_CONTENT_DIR));
     if (!$res) {
         return new WP_Error('no_credentials', __("Error! Can't connect to filesystem", 'ultimate_vc'));
     }
     $ultimate_keys = get_option('ultimate_keys');
     $username = trim($ultimate_keys['envato_username']);
     $api_key = trim($ultimate_keys['envato_api_key']);
     $purchase_code = trim($ultimate_keys['ultimate_purchase_code']);
     if (empty($username) || empty($api_key) || empty($purchase_code)) {
         return new WP_Error('no_credentials', __('Error! Envato username, api key and your purchase code are required for downloading updates from Envato marketplace for the Visual Composer.', 'ultimate_vc') . ' ' . __('Visit', 'ultimate_vc') . ' <a href="' . admin_url('options-general.php?page=wpb_vc_settings&tab=updater') . '' . '">' . __('Settings', 'ultimate_vc') . '</a> ' . _('to fix.', 'ultimate_vc'));
     }
     $json = wp_remote_get($this->envatoDownloadPurchaseUrl($username, $api_key, $purchase_code));
     $result = json_decode($json['body'], true);
     if (!isset($result['wp-download']['url'])) {
         return new WP_Error('no_credentials', __('Error! Envato API error' . (isset($result['error']) ? ': ' . $result['error'] : '.'), 'ultimate_vc'));
     }
     $download_file = download_url($result['wp-download']['url']);
     if (is_wp_error($download_file)) {
         $download_file = file_get_contents($result['wp-download']['url']);
         if (is_wp_error($download_file)) {
             return $download_file;
         }
     }
     $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade_tmp/ultimate_envato_package';
     if (is_dir($upgrade_folder)) {
         $wp_filesystem->delete($upgrade_folder);
     } else {
         mkdir($upgrade_folder, 0755);
     }
     $is_unzip = unzip_file($download_file, $upgrade_folder);
     if ($is_unzip) {
         $result = copy($result['wp-download']['url'], $upgrade_folder . '/' . $package_filename);
         if ($result) {
             return $upgrade_folder . '/' . $package_filename;
         } else {
             if (file_exists($upgrade_folder . '/Ultimate_VC_Addons') && is_dir($upgrade_folder . '/Ultimate_VC_Addons')) {
                 $this->Ultimate_Zip($upgrade_folder . '/Ultimate_VC_Addons', $upgrade_folder . '/' . $package_filename);
                 if (is_file($upgrade_folder . '/' . $package_filename)) {
                     return $upgrade_folder . '/' . $package_filename;
                 }
                 return new WP_Error('no_credentials', __('Error while zipping plugin', 'ultimate_vc'));
             }
             return new WP_Error('no_credentials', __('Error while coping zip from Remote server, allow_url_fopen is disabled on your server.', 'ultimate_vc'));
         }
     }
     return new WP_Error('no_credentials', __('Error on unzipping package', 'ultimate_vc'));
 }
开发者ID:rinodung,项目名称:live-theme,代码行数:54,代码来源:auto-update.php

示例14: unzip

 function unzip($temp_file_addr, $to)
 {
     $filesystem = WP_Filesystem();
     $dounzip = unzip_file($temp_file_addr, $to);
     if (is_wp_error($dounzip)) {
         $error = $dounzip->get_error_code();
         $data = $dounzip->get_error_data($error);
         $this->error($dounzip->get_error_message());
         return false;
     }
     return true;
 }
开发者ID:fwelections,项目名称:fwelections,代码行数:12,代码来源:zip.php

示例15: edit_action

 public function edit_action($material_id = null)
 {
     $this->material = new LernmarktplatzMaterial($material_id);
     Pagelayout::setTitle($this->material->isNew() ? _("Neues Material hochladen") : _("Material bearbeiten"));
     if ($this->material['user_id'] && $this->material['user_id'] !== $GLOBALS['user']->id) {
         throw new AccessDeniedException();
     }
     if (Request::submitted("delete") && Request::isPost()) {
         $this->material->pushDataToIndexServers("delete");
         $this->material->delete();
         PageLayout::postMessage(MessageBox::success(_("Ihr Material wurde gelöscht.")));
         $this->redirect("market/overview");
     } elseif (Request::isPost()) {
         $was_new = $this->material->setData(Request::getArray("data"));
         $this->material['user_id'] = $GLOBALS['user']->id;
         $this->material['host_id'] = null;
         $this->material['license'] = "CC BY 4.0";
         if ($_FILES['file']['tmp_name']) {
             $this->material['content_type'] = $_FILES['file']['type'];
             if (in_array($this->material['content_type'], array("application/x-zip-compressed", "application/zip", "application/x-zip"))) {
                 $tmp_folder = $GLOBALS['TMP_PATH'] . "/temp_folder_" . md5(uniqid());
                 mkdir($tmp_folder);
                 unzip_file($_FILES['file']['tmp_name'], $tmp_folder);
                 $this->material['structure'] = $this->getFolderStructure($tmp_folder);
                 rmdirr($tmp_folder);
             } else {
                 $this->material['structure'] = null;
             }
             $this->material['filename'] = $_FILES['file']['name'];
             move_uploaded_file($_FILES['file']['tmp_name'], $this->material->getFilePath());
         }
         if ($_FILES['image']['tmp_name']) {
             $this->material['front_image_content_type'] = $_FILES['image']['type'];
             move_uploaded_file($_FILES['image']['tmp_name'], $this->material->getFrontImageFilePath());
         }
         if (Request::get("delete_front_image")) {
             $this->material['front_image_content_type'] = null;
         }
         $this->material->store();
         //Topics:
         $topics = Request::getArray("tags");
         foreach ($topics as $key => $topic) {
             if (!trim($topic)) {
                 unset($topics[$key]);
             }
         }
         $this->material->setTopics($topics);
         $this->material->pushDataToIndexServers();
         PageLayout::postMessage(MessageBox::success(_("Lernmaterial erfolgreich gespeichert.")));
         $this->redirect("market/details/" . $this->material->getId());
     }
 }
开发者ID:Krassmus,项目名称:LehrMarktplatz,代码行数:52,代码来源:mymaterial.php


注:本文中的unzip_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。