예제 #1
0
파일: model.php 프로젝트: fanscky/HTPMS
 /**
  * Restore File 
  * 
  * @param  string    $backupFile 
  * @access public
  * @return object
  */
 public function restoreFile($backupFile)
 {
     $return = new stdclass();
     $return->result = true;
     $return->error = '';
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($backupFile);
     if ($zip->extract(PCLZIP_OPT_PATH, $this->app->getAppRoot() . 'www/data/') == 0) {
         $return->result = false;
         $return->error = $zip->errorInfo();
     }
     return $return;
 }
예제 #2
0
 /**
  * Extract zip.
  * 
  * @param  string    $zipFile 
  * @access public
  * @return string
  */
 public function extractZip($zipFile)
 {
     $classFile = $this->app->loadClass('zfile');
     $parentPath = $this->app->getCacheRoot() . 'uploadimages/';
     if (!is_dir($parentPath)) {
         mkdir($parentPath, 0777, true);
     }
     $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
     if (is_dir($filePath)) {
         $classFile->removeDir($filePath);
     }
     mkdir($filePath);
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($zipFile);
     $files = $zip->listContent();
     foreach ($files as $i => $uploadFile) {
         $extension = strtolower(substr(strrchr($uploadFile['filename'], '.'), 1));
         if (empty($extension) or !in_array($extension, $this->config->file->imageExtensions)) {
             return false;
         }
     }
     $extractedFiles = array();
     foreach ($files as $i => $uploadFile) {
         $fileName = mb_convert_encoding($uploadFile['filename'], 'UTF-8', 'gb2312');
         $file = array();
         $file['extension'] = $this->getExtension($fileName);
         $file['pathname'] = $this->setPathName($i, $file['extension']);
         $file['title'] = str_replace(".{$file['extension']}", '', $fileName);
         $file['size'] = $uploadFile['size'];
         $fileName = basename($file['pathname']);
         $file['realpath'] = $filePath . $fileName;
         $list = $zip->extract(PCLZIP_OPT_BY_NAME, $uploadFile['filename'], PCLZIP_OPT_EXTRACT_AS_STRING);
         if ($list) {
             file_put_contents($file['realpath'], $list[0]['content']);
             $extractedFiles[$fileName] = $file;
         }
     }
     return $extractedFiles;
 }
예제 #3
0
 /**
  * Extract zip.
  * 
  * @param  string    $zipFile 
  * @access public
  * @return string
  */
 public function extractZip($zipFile)
 {
     $classFile = $this->app->loadClass('zfile');
     $parentPath = $this->app->getCacheRoot() . 'uploadimages/';
     if (!is_dir($parentPath)) {
         mkdir($parentPath, 0777, true);
     }
     $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
     if (is_dir($filePath)) {
         $classFile->removeDir($filePath);
     }
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($zipFile);
     $files = $zip->listContent();
     if ($zip->extract(PCLZIP_OPT_PATH, $filePath) == 0) {
         return false;
     }
     return $filePath;
 }
예제 #4
0
파일: model.php 프로젝트: iamazhi/zentaopms
 /**
  * Extract an extension.
  * 
  * @param  string    $extension 
  * @access public
  * @return object
  */
 public function extractPackage($extension)
 {
     $return = new stdclass();
     $return->result = 'ok';
     $return->error = '';
     /* try remove pre extracted files. */
     $extensionPath = "ext/{$extension}";
     if (is_dir($extensionPath)) {
         $this->classFile->removeDir($extensionPath);
     }
     /* Extract files. */
     $packageFile = $this->getPackageFile($extension);
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($packageFile);
     $files = $zip->listContent();
     $removePath = $files[0]['filename'];
     if ($zip->extract(PCLZIP_OPT_PATH, $extensionPath, PCLZIP_OPT_REMOVE_PATH, $removePath) == 0) {
         $return->result = 'fail';
         $return->error = $zip->errorInfo(true);
     }
     return $return;
 }
예제 #5
0
파일: unpk.php 프로젝트: sembrono/1
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 读取失败!';
    } else {
        $fp = preg_replace("/(.*?)(\\.bz2)\$/i", "\\1", $_POST['dirpath'] . '/' . basename(_decode($_GET['path'])));
        $fp = fopen($fp, "a+");
        fwrite($fp, $data);
        while (!feof($bz2)) {
            fwrite($fp, gzread($bz2, 1024));
        }
        fclose($fp);
        bzclose($bz2);
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压成功!';
    }
} elseif ($_POST['ftype'] == 'zip') {
    require 'pclzip.lib.php';
    $pk = new pclzip(_decode($_GET['path']));
    if (($count = $pk->extract(PCLZIP_OPT_PATH, $_POST['dirpath'])) == false) {
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压失败!';
    } else {
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压成功!';
        echo '<div class="big_board"><div class="board_title"></div></div>-&gt;&gt;Hello,共解出档案 ' . count($count) . ' 个哦!';
    }
} elseif ($_POST['ftype'] == 'tar') {
    require 'tar.php';
    $tar = new Archive_Tar(_decode($_GET['path']));
    if (($count = $tar->extract($_POST['dirpath'])) == false) {
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压失败!';
    } else {
        echo 'Hello,压缩包 ' . basename(_decode($_GET['path'])) . ' 解压成功!';
    }
} elseif ($_POST['ftype'] == 'rar') {
    if (function_exists('rar_open')) {
예제 #6
0
 public function add()
 {
     if (isset($_POST['dosubmit']) || isset($_POST['dosubmit_continue'])) {
         define('INDEX_HTML', true);
         $catid = $_POST['info']['catid'] = intval($_POST['info']['catid']);
         if (trim($_POST['info']['title']) == '') {
             showmessage(L('title_is_empty'));
         }
         $category = $this->categorys[$catid];
         if ($category['type'] == 0) {
             $modelid = $this->categorys[$catid]['modelid'];
             $this->db->set_model($modelid);
             //如果该栏目设置了工作流,那么必须走工作流设定
             $setting = string2array($category['setting']);
             $workflowid = $setting['workflowid'];
             if ($workflowid && $_POST['status'] != 99) {
                 //如果用户是超级管理员,那么则根据自己的设置来发布
                 $_POST['info']['status'] = $_SESSION['roleid'] == 1 ? intval($_POST['status']) : 1;
             } else {
                 $_POST['info']['status'] = 99;
             }
             $id = $this->db->add_content($_POST['info']);
             $r = $this->db->get_one(array('id' => $id));
             if (isset($r['down_url'])) {
                 $down_url = string2array($r['down_url']);
                 require_once 'phpcms/libs/classes/pclzip.lib.php';
                 $pclzip = new pclzip(dirname(dirname(dirname(dirname(__FILE__)))) . strstr($down_url[0]['fileurl'], '/uploadfile'));
                 $rs = $pclzip->extract(PCLZIP_OPT_PATH, 'demo/' . $down_url[0]['filename'] . '_' . $id);
                 $this->db->update(array('demo_url' => 'demo/' . $down_url[0]['filename'] . '_' . $id), array('id' => $id));
             }
             if (isset($_POST['dosubmit'])) {
                 showmessage(L('add_success') . L('2s_close'), 'blank', '', '', 'function set_time() {$("#secondid").html(1);}setTimeout("set_time()", 500);setTimeout("window.close()", 1200);');
             } else {
                 showmessage(L('add_success'), HTTP_REFERER);
             }
         } else {
             //单网页
             $this->page_db = pc_base::load_model('page_model');
             $style_font_weight = $_POST['style_font_weight'] ? 'font-weight:' . strip_tags($_POST['style_font_weight']) : '';
             $_POST['info']['style'] = strip_tags($_POST['style_color']) . ';' . $style_font_weight;
             if ($_POST['edit']) {
                 $this->page_db->update($_POST['info'], array('catid' => $catid));
             } else {
                 $catid = $this->page_db->insert($_POST['info'], 1);
             }
             $this->page_db->create_html($catid, $_POST['info']);
             $forward = HTTP_REFERER;
         }
         showmessage(L('add_success'), $forward);
     } else {
         $show_header = $show_dialog = $show_validator = '';
         //设置cookie 在附件添加处调用
         param::set_cookie('module', 'content');
         if (isset($_GET['catid']) && $_GET['catid']) {
             $catid = $_GET['catid'] = intval($_GET['catid']);
             param::set_cookie('catid', $catid);
             $category = $this->categorys[$catid];
             if ($category['type'] == 0) {
                 $modelid = $category['modelid'];
                 //取模型ID,依模型ID来生成对应的表单
                 require CACHE_MODEL_PATH . 'content_form.class.php';
                 $content_form = new content_form($modelid, $catid, $this->categorys);
                 $forminfos = $content_form->get();
                 $formValidator = $content_form->formValidator;
                 $setting = string2array($category['setting']);
                 $workflowid = $setting['workflowid'];
                 $workflows = getcache('workflow_' . $this->siteid, 'commons');
                 $workflows = $workflows[$workflowid];
                 $workflows_setting = string2array($workflows['setting']);
                 $nocheck_users = $workflows_setting['nocheck_users'];
                 $admin_username = param::get_cookie('admin_username');
                 if (!empty($nocheck_users) && in_array($admin_username, $nocheck_users)) {
                     $priv_status = true;
                 } else {
                     $priv_status = false;
                 }
                 include $this->admin_tpl('content_add');
             } else {
                 //单网页
                 $this->page_db = pc_base::load_model('page_model');
                 $r = $this->page_db->get_one(array('catid' => $catid));
                 if ($r) {
                     extract($r);
                     $style_arr = explode(';', $style);
                     $style_color = $style_arr[0];
                     $style_font_weight = $style_arr[1] ? substr($style_arr[1], 12) : '';
                 }
                 include $this->admin_tpl('content_page');
             }
         } else {
             include $this->admin_tpl('content_add');
         }
         header("Cache-control: private");
     }
 }
예제 #7
0
 /**
  * Down notify.
  * 
  * @access public
  * @return void
  */
 public function downNotify()
 {
     $notifyDir = $this->app->getBasePath() . 'www/data/notify/';
     $packageFile = $notifyDir . 'notify.zip';
     $tmpDir = $notifyDir . 'notify';
     $loginFile = $tmpDir . '/notify/logininfo';
     $this->app->loadClass('pclzip', true);
     $sourceZip = new pclzip($packageFile);
     $files = $sourceZip->extract(PCLZIP_OPT_PATH, $notifyDir);
     if ($files == 0) {
         die("Error : " . $sourceZip->errorInfo(true));
     }
     $loginInfo = new stdclass();
     $loginInfo->account = $this->app->user->account;
     $loginInfo->password = $this->app->user->password;
     $loginInfo->zentaoRoot = common::getSysURL() . $this->config->webRoot;
     $loginInfo = json_encode($loginInfo);
     file_put_contents($loginFile, $loginInfo);
     unlink($packageFile);
     $newZip = new pclzip($packageFile);
     if ($newZip->create($tmpDir, PCLZIP_OPT_REMOVE_PATH, $notifyDir)) {
         $this->zfile = $this->app->loadClass('zfile');
         $this->zfile->removeDir($tmpDir);
     }
     $this->fetch('file', 'sendDownHeader', array('fileName' => 'notify.zip', 'zip', file_get_contents($packageFile)));
 }
예제 #8
0
파일: model.php 프로젝트: caiwenhao/zentao
 /**
  * Extract zip.
  * 
  * @param  string    $zipFile 
  * @access public
  * @return string
  */
 public function extractZip($zipFile)
 {
     $classFile = $this->app->loadClass('zfile');
     $parentPath = $this->app->getCacheRoot() . 'uploadimages/';
     if (!is_dir($parentPath)) {
         mkdir($parentPath, 0777, true);
     }
     $filePath = $parentPath . str_replace('.zip', '', basename($zipFile)) . '/';
     if (is_dir($filePath)) {
         $classFile->removeDir($filePath);
     }
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($zipFile);
     $files = $zip->listContent();
     foreach ($files as $uploadFile) {
         $extension = strtolower(substr(strrchr($uploadFile['filename'], '.'), 1));
         if (empty($extension) or !in_array($extension, $this->config->file->imageExtensions)) {
             return false;
         }
     }
     if ($zip->extract(PCLZIP_OPT_PATH, $filePath) == 0) {
         return false;
     }
     return $filePath;
 }
예제 #9
0
파일: unpack.php 프로젝트: liuguogen/weixin
                     fwrite($fp, bzread($bz2, 4096));
                 }
                 bzclose($bz2);
                 fclose($fp);
                 echo "压缩文件已经解压完成!";
             }
         }
     }
     break;
 case "zip":
     if (!file_exists("pclzip.php")) {
         echo "暂时无法进行解压操作!";
     } else {
         require "pclzip.php";
         $pk = new pclzip($path);
         if (($zip = $pk->extract(PCLZIP_OPT_PATH, $unpackdir)) == false) {
             echo "无法成功解压您的文件!";
         } else {
             echo "成功解压出&nbsp;" . count($zip) . "&nbsp;个档案!";
         }
     }
     break;
 case "tar":
     if (!file_exists("tarcls.php")) {
         echo "暂时无法进行解压操作!";
     } else {
         require "tarcls.php";
         $pk = new Archive_Tar($path);
         if ($pk->extract($unpackdir) == false) {
             echo "无法成功解压您的文件!";
         } else {
예제 #10
0
파일: unzip.php 프로젝트: liuguogen/weixin
    echo "</div>\n";
    echo "<div class=\"love\">\n";
    echo "此文件暂时不能被系统操作!";
    echo "</div>\n";
    xhtml_footer();
    exit;
}
xhtml_head("ZIP工具");
if (isset($_POST['z']) && is_array($_POST['z']) && isset($_POST['undir']) && is_dir(trim($_POST['undir']))) {
    echo "<div class=\"like\">\n";
    echo "<a href=\"./dlym.php?path=" . urlencode(dirname($path)) . "\"]>返回目录</a>解压结果\n";
    echo "</div>\n";
    $pk = new pclzip($path);
    $dir = trim($_POST['undir']);
    $arr = array_map('urldecode', $_POST['z']);
    if (($zip = $pk->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_BY_NAME, $arr)) == false) {
        echo "<div class=\"love\">\n";
        echo "无法成功解压您的文件!";
        echo "\n</div>\n";
    } else {
        echo "<div class=\"love\">\n";
        echo "本次共操作&nbsp;" . count($zip) . "&nbsp;个档案!";
        echo "\n</div>\n";
        foreach ($zip as $zf) {
            echo "<div class=\"love\">\n";
            if ($zf['folder']) {
                echo "[目录]";
            } else {
                echo "[文件]";
            }
            echo ___convert($zf['filename'], "UTF-8") . "(" . $zf['status'] . ")\n<br />\n";
예제 #11
0
 /**
  * Extract template package.
  * 
  * @param  string    $package 
  * @access public
  * @return void
  */
 public function extractPackage($package)
 {
     $packageFile = $this->app->getDataRoot() . "template/{$package}.zip";
     $this->app->loadClass('pclzip', true);
     $zip = new pclzip($packageFile);
     $files = $zip->listContent();
     $tempPath = $this->app->getDataRoot() . 'template/' . $package . DS;
     if (is_dir($tempPath)) {
         $fileClass = $this->app->loadClass('zfile');
         $fileClass->removeDir($tempPath);
     }
     $return = new stdclass();
     $removePath = $files[0]['filename'];
     if ($zip->extract(PCLZIP_OPT_PATH, $tempPath, PCLZIP_OPT_REMOVE_PATH, $removePath) == 0) {
         $return->result = 'fail';
         $return->error = $zip->errorInfo(true);
     }
     return true;
 }
예제 #12
0
            # Check if gedcom directory is writable
            if (!is_writable(GEDCOM_DIR)) {
                $smarty->assign('UPLOAD_ERROR', 'The gedcom directory is not writable. Check your server configuration.');
                break;
            }
            # Check if file already exists
            if (file_exists($uploadfile)) {
                $smarty->assign('UPLOAD_ERROR', 'A file with the same name already exists.');
                break;
            }
            # Move the file
            if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
                $smarty->assign('UPLOAD_ERROR', 'Error moving file to the gedcom directory.  Check your server configuration.');
                break;
            }
            # Extract gedcoms from zip files and cleanup
            if (strtolower($extension) == 'zip') {
                # load the pclzip library
                require_once LIB_PATH . 'pcl/pclzip.lib.php';
                $zip = new pclzip($uploadfile);
                # extract only .ged files (case insensitive)
                $zip->extract(PCLZIP_OPT_PATH, GEDCOM_DIR, PCLZIP_OPT_BY_PREG, '/ged$/i');
                # remove the zip file
                unlink($uploadfile);
            }
            # Success
            $smarty->assign('UPLOAD_SUCCESS', '1');
            $smarty->assign('REDIRECT', $_SERVER['PHP_SELF'] . '?m=gedcom');
            break;
    }
}
예제 #13
0
} elseif ($_FILES["uploadedfile"]["size"] == 0 && $_FILES["uploadedfile"]["tmp_name"] == "") {
    $msg = "Please indicate a file. This error may also happen if the file was too big.";
    $tpl->SetVariable("PROCESS_DURATION", "0");
} else {
    $tmp = explode('.', $_FILES["uploadedfile"]["name"]);
    $ext = $tmp[count($tmp) - 1];
    $startTimeStr = microtime();
    switch ($ext) {
        case "zip":
            if (!CanUploadZip()) {
                die(GetNotAllowedPage("You are not allowed to upload zip files"));
            }
            $directory = GetTmpPath();
            //dirname($_FILES["uploadedfile"]["tmp_name"]);
            $zip = new pclzip($_FILES["uploadedfile"]["tmp_name"]);
            $extractResult = $zip->extract(PCLZIP_OPT_PATH, $directory);
            if ($extractResult == 0) {
                $msg = "Error extracting zip file";
            } else {
                $msg = ProcessFiles($extractResult, $projectId, $tpl);
                /*$msg = "";
                  foreach($extractResult as $file)
                  {
                    $msg .= ProcessDtx($file["filename"], $_POST["project"])."<br>";
                  }*/
            }
            break;
        case "dtx":
            $filename = dirname($_FILES["uploadedfile"]["tmp_name"]) . '/' . basename($_FILES["uploadedfile"]["name"]);
            move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $filename);
            $msg = ProcessDtx($filename, $projectId);