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


PHP Installer::unzip方法代码示例

本文整理汇总了PHP中Installer::unzip方法的典型用法代码示例。如果您正苦于以下问题:PHP Installer::unzip方法的具体用法?PHP Installer::unzip怎么用?PHP Installer::unzip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Installer的用法示例。


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

示例1: update

 public function update()
 {
     $version = $this->request->get['version'];
     $product_id = $this->request->get['product_id'];
     $data = $this->update->downloadUpdate($product_id, $version);
     $path = 'temp-' . md5(mt_rand());
     $file = DIR_UPLOAD . $path . '/upload.zip';
     if (!is_dir(DIR_UPLOAD . $path)) {
         $this->filesystem->mkdir(DIR_UPLOAD . $path);
     }
     $uploaded = is_int(file_put_contents($file, $data)) ? true : false;
     if (!$uploaded) {
         return false;
     }
     // Fire event
     $this->trigger->fire('pre.admin.update.update', $product_id);
     // Force enable maintenance mode
     $maintenance_mode = $this->config->get('maintenance_mode');
     $this->config->set('maintenance_mode', 1);
     $installer = new Installer($this->registry);
     if (!$installer->unzip($file)) {
         return false;
     }
     // Remove Zip
     $this->filesystem->remove($file);
     if ($product_id == 'core') {
         $temp_path = DIR_UPLOAD . $path;
         $install_path = $temp_path . '/install';
         // Load the update script, if available
         if (is_file($install_path . '/update.php')) {
             require_once $install_path . '/update.php';
         }
         // Don't copy the install folder
         $this->filesystem->remove($install_path);
         // Move all files/folders from temp path
         $this->filesystem->mirror($temp_path, DIR_ROOT, null, array('override' => true));
         // Delete the temp path
         $this->filesystem->remove($temp_path);
     } else {
         // Required for ftp & remove extension functions
         $this->request->post['path'] = $path;
         $ftp = $this->load->controller('extension/installer/ftp');
         $remove = $this->load->controller('extension/installer/remove');
         $this->db->query("UPDATE `" . DB_PREFIX . "addon` SET `product_version` = '" . $this->db->escape($version) . "' WHERE `product_id` = '" . (int) $product_id . "'");
     }
     // Restore maintenance mode
     $this->config->set('maintenance_mode', $maintenance_mode);
     // Fire event
     $this->trigger->fire('post.admin.update.update', $product_id);
     return true;
 }
开发者ID:sojimaxi,项目名称:arastta,代码行数:51,代码来源:update.php

示例2: downloadLanguage

 public function downloadLanguage($data)
 {
     $code = $data['lang_code'];
     if ($code == 'en-GB') {
         $this->session->data['lang_name'] = 'English';
         $this->session->data['lang_code'] = 'en';
         $this->session->data['lang_image'] = 'gb.png';
         $this->session->data['lang_directory'] = 'en-GB';
         // Workaround to mutual session ids
         $this->session->data['config_language'] = 'en';
         $this->session->data['config_admin_language'] = 'en';
         return $code;
     }
     $link = 'https://crowdin.com/download/project/arastta/' . $code . '.zip';
     $data = $this->utility->getRemoteData($link);
     if (empty($data)) {
         return false;
     }
     $path = 'temp-' . md5(mt_rand());
     $file = DIR_UPLOAD . $path . '/upload.zip';
     if (!is_dir(DIR_UPLOAD . $path)) {
         $this->filesystem->mkdir(DIR_UPLOAD . $path);
     }
     $uploaded = is_int(file_put_contents($file, $data)) ? true : false;
     if (!$uploaded) {
         return false;
     }
     $installer = new Installer($this->registry);
     if (!$installer->unzip($file)) {
         return false;
     }
     // Remove Zip
     $this->filesystem->remove($file);
     $temp_path = DIR_UPLOAD . $path;
     $json = json_decode(file_get_contents($temp_path . '/install.json'), true);
     $this->session->data['lang_name'] = $json['translation']['name'];
     $this->session->data['lang_code'] = $json['translation']['code'];
     $this->session->data['lang_image'] = $json['translation']['image'];
     $this->session->data['lang_directory'] = $json['translation']['directory'];
     // Workaround to mutual session ids
     $this->session->data['config_language'] = $json['translation']['code'];
     $this->session->data['config_admin_language'] = $json['translation']['code'];
     $lang_dir = $json['translation']['directory'];
     // Move all files/folders from temp path
     $this->filesystem->mirror($temp_path . '/admin', DIR_ADMIN . 'language/' . $lang_dir, null, array('override' => true));
     $this->filesystem->mirror($temp_path . '/catalog', DIR_CATALOG . 'language/' . $lang_dir, null, array('override' => true));
     $this->filesystem->mirror($temp_path . '/install', DIR_INSTALL . 'language/' . $lang_dir, null, array('override' => true));
     // Delete the temp path
     $this->filesystem->remove($temp_path);
     return $lang_dir;
 }
开发者ID:LinuxJedi,项目名称:arastta,代码行数:51,代码来源:language.php

示例3: unzip

 public function unzip()
 {
     $this->load->language('extension/installer');
     $json = array();
     if (!$this->user->hasPermission('modify', 'extension/installer')) {
         $json['error'] = $this->language->get('error_permission');
     }
     // Sanitize the filename
     $file = DIR_UPLOAD . str_replace(array('../', '..\\', '..'), '', $this->request->post['path']) . '/upload.zip';
     if (!file_exists($file)) {
         $json['error'] = $this->language->get('error_file');
     }
     if (!$json) {
         // Fire event
         $this->trigger->fire('pre.admin.extension.unzip', array(&$file));
         $installer = new Installer($this->registry);
         if (!$installer->unzip($file)) {
             $json['error'] = $this->language->get('error_unzip');
         }
         // Remove Zip
         unlink($file);
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
开发者ID:cdsalmons,项目名称:arastta,代码行数:25,代码来源:installer.php


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