Esempio n. 1
0
 /**
  * Opens xlsx file
  *
  * @param $file
  *
  * @return $this
  *
  * @throws \Exception
  */
 public function open($file)
 {
     if (!is_file($file)) {
         throw new \Exception("File {$file} not found");
     }
     $dir = $this->getTempDir();
     $this->zip->extract($file, $dir);
     return $this;
 }
Esempio n. 2
0
 /**
  * Импорт и экспорт
  */
 public function tools_action()
 {
     $this->hookSiteSettingsMenu();
     template('Admin/templates/tools')->show();
     $form = new Form('Admin/forms/import');
     if ($result = $form->result()) {
         if ($file = $result->file) {
             $zip = new Zip(array('file' => $file->path, 'check' => array('type' => 'config')));
             if ($zip->extract(ROOT)) {
                 success(t('<b>Архив успешно распакован!</b> Новый файл конфигурации установлен.'));
             }
             $zip->close();
             unlink($file->path);
         }
     }
     $form->show();
 }
Esempio n. 3
0
function singleBakinData($index, $pre)
{
    global $bakupDir;
    if (!$index) {
        return false;
    }
    $sql = array();
    $tmpname = $bakupDir . $pre . '/';
    $extend = file_exists($tmpname . 'table.zip') ? 'zip' : 'sql';
    $data = explode(',', $index);
    $filename = $tmpname . $data[0];
    if ($extend == 'zip') {
        L::loadClass('zip', 'utility', false);
        $zipService = new Zip();
        $filename = str_replace(substr($filename, strpos($filename, '.')), '.zip', $filename);
        list($tmpData) = $zipService->extract($filename);
        $tmpSql = explode("\n", $tmpData['data']);
    } else {
        $tmpData = pwCache::readover($filename);
        $tmpSql = explode("\n", $tmpData);
    }
    $sql = $data[2] == -1 ? array_slice($tmpSql, $data[1]) : array_slice($tmpSql, $data[1], $data[2] - $data[1]);
    return doBackIn($sql);
}
Esempio n. 4
0
 /**
  *
  */
 public function index_action($action = 'import')
 {
     $this->hookAdminMenu(1);
     $this->hookAdminMenu(3);
     switch ($action) {
         case 'import':
             $form = new Form('Lang/forms/import');
             if ($result = $form->result()) {
                 if ($file = $result->file) {
                     $zip = new Zip(array('file' => $file->path, 'check' => array('type' => 'lang')));
                     if ($zip->extract(LANG)) {
                         $info = $zip->info();
                         $langs = $this->getLangs(array($info['lang']));
                         success(t('<b>Архив успешно распакован!</b> Индекс для языка <b>«%s»</b> установлен.', implode($langs)), '', 'content');
                     }
                     $zip->close();
                     unlink($file->path);
                 }
             }
             $form->show();
             break;
         case 'export':
             template('Lang/templates/download')->show();
             break;
         case 'download':
             $file = ROOT . $this->prepareFilePath();
             $archive = TEMP . DS . pathinfo($file, PATHINFO_FILENAME) . '.zip';
             $zip = new Zip(array('file' => $archive, 'create' => TRUE));
             $zip->add($file);
             $zip->info(array('type' => 'lang', 'lang' => config('lang.lang')));
             $zip->close();
             File::download($archive, basename($archive), TRUE);
             break;
     }
 }
Esempio n. 5
0
 public function download()
 {
     if (IS_POST) {
         $module = q('get.module');
         $app = Curl::get(c('api.cloud') . '?a=site/GetLastAppInfo&t=web&siteid=1&m=store&type=addons&module=' . $module);
         $app = json_decode($app, TRUE);
         if ($app) {
             $package = Curl::post(c('api.cloud') . '?a=site/download&t=web&siteid=1&m=store&type=addons', ['file' => $app['data']['package']]);
             file_put_contents('tmp.zip', $package);
             //释放压缩包
             Zip::PclZip('tmp.zip');
             //设置压缩文件名
             Zip::extract(".");
             //解压缩
             file_put_contents('addons/' . $module . '/cloud.hd', json_encode($app['data'], JSON_UNESCAPED_UNICODE));
             message('模块下载成功,准备安装', '', 'success');
         }
         message('应用商店不存在模块', '', 'error');
     }
     View::make();
 }
Esempio n. 6
0
 /**
  * Загрузка тем
  */
 public function upload_action()
 {
     $this->hookAdminMenu();
     $this->hookAdminMenu(2);
     $form = new Form('Gears/forms/add');
     if ($result = $form->result()) {
         if ($file = $result->file ? $result->file : $result->url) {
             $zip = new Zip(array('file' => UPLOADS . $file, 'check' => array('type' => 'gears')));
             if ($zip->extract(GEARS)) {
                 $info = $zip->info();
                 success(t('<b>Архив успешно распакован!</b> <p>Он содержал в себе следующие шестерёнки: <ul><li>%s</li></ul>', implode('</li><li>', $info['gears'])), '', 'content');
             }
             $zip->close();
             unlink(UPLOADS . $file);
         }
     }
     $form->show();
 }