コード例 #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
ファイル: system.php プロジェクト: liuguogen/weixin
function ___ziplist()
{
    $zip = trim(func_get_arg(0));
    if (!is_readable('pclzip.php') || !___getmime($zip, 'zip')) {
        return false;
    }
    require 'pclzip.php';
    $pclzip = new pclzip($zip);
    if (!($getlist = $pclzip->listContent())) {
        return false;
    }
    if (!is_array($getlist) || count($getlist) < 1) {
        return false;
    }
    return $getlist;
}
コード例 #3
0
ファイル: model.php プロジェクト: mustafakarali/b2c-1
 /**
  * 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;
 }
コード例 #4
0
ファイル: pkzip.php プロジェクト: simplesky/course
<?php

require "config.php";
if (!isset($_GET['gopath']) || !isset($_SESSION['flist']) || !file_exists("pclzip.php")) {
    header("Location: ./404.php");
    exit;
}
if (!isset($_GET['getcwd'])) {
    $getcwd = OPEN;
} else {
    $getcwd = ___realpath(trim($_GET['getcwd']));
}
xhtml_head("文件压缩");
if (count($_SESSION['flist']) < 1) {
    echo "<div class=\"error\">\n";
    echo "[<a href=\"./index.php?path=" . urlencode($getcwd) . "\">返回</a>]抱歉,文件清单为空!\n";
    echo "</div>\n";
} else {
    require "pclzip.php";
    $pkzip = new pclzip($gopath = trim($_GET['gopath']));
    echo "[<a href=\"./index.php?path=" . urlencode($getcwd) . "\">目录</a>]\n";
    if ($pkzip->create($_SESSION['flist'], PCLZIP_OPT_REMOVE_PATH, dirname($gopath))) {
        echo "文件&nbsp;" . ___basename($gopath) . "&nbsp;创建成功!";
    } else {
        echo "文件&nbsp;" . ___basename($gopath) . "&nbsp;无法建立!";
    }
}
xhtml_footer();
コード例 #5
0
ファイル: model.php プロジェクト: JameTheSmart/zentaopms
 /**
  * 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;
 }
コード例 #6
0
ファイル: backup.php プロジェクト: huokedu/zentaowamp
/* Backup database. */
$dbRawFile = "db." . date('Ymd') . ".sql";
$password = $config->db->password ? "-p{$config->db->password}" : ' ';
$command = "\"{$mysqldump}\" -u{$config->db->user} {$password} -P {$config->db->port} {$config->db->name} > {$dbRawFile}";
echo "Backup command: " . $command . "\n";
echo "Backuping database,";
system($command, $return);
if ($return == 0) {
    $dbZipFile = $destDir . "/" . str_replace("sql", "zip", $dbRawFile);
    $archive = new pclzip($dbZipFile);
    if ($archive->create($dbRawFile)) {
        unlink($dbRawFile);
        echo " successfully saved to {$dbZipFile}\n";
    } else {
        die("Error : " . $archive->errorInfo(true));
    }
} else {
    echo "Failed to backup database!\n";
}
/* Backup the attachments. */
chdir(dirname(dirname(dirname(__FILE__))) . "/www");
if (!is_dir('data/upload')) {
    die(" No files needed backup.\n");
}
echo "Backuping files,";
$attachFile = $destDir . "/" . "file." . date('Ymd', time()) . ".zip";
$archive = new pclzip($attachFile);
if ($archive->create("data/upload", PCLZIP_OPT_REMOVE_PATH, "data")) {
    die(" successfully saved to {$attachFile}\n");
}
die("Error : " . $archive->errorInfo(true));
コード例 #7
0
ファイル: content.php プロジェクト: hw18708118867/htmlmoban
 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");
     }
 }
コード例 #8
0
ファイル: unpk.php プロジェクト: sembrono/1
    } elseif (($data = bzread($bz2, 1024)) == false) {
        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') {
コード例 #9
0
ファイル: addfile.php プロジェクト: amjadtbssm/website
    $tpl->SetVariable("PROCESS_DURATION", round($duration, 4));
} 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);
コード例 #10
0
ファイル: model.php プロジェクト: jsyinwenjun/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);
     }
     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;
 }
コード例 #11
0
ファイル: control.php プロジェクト: laiello/zentaoms
 /**
  * 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)));
 }
コード例 #12
0
ファイル: pkzip.php プロジェクト: sembrono/1
<body>
<div class="big_board"><div class="board_title">爱特文管-路径信息</div></div>
HTML;
echo '<a href="index.php?path=' . $_GET['path'] . '">' . _decode($_GET['path']) . '</a>';
if (count($_SESSION['path']) <= 0) {
    echo <<<HTML
<div class="big_board"><div class="board_title">爱特文管-系统警告</div></div>
Hello,待处理文件为空!
HTML;
} elseif (preg_match('/^([a-zA-Z0-9_\\-\\.\\x{4e00}-\\x{9fa5}]+)([zip])$/iu', $_REQUEST['pkname']) == false) {
    echo '<div class="big_board"><div class="board_title">爱特文管-系统警告</div></div>Hello,存档名称不规范喔!';
} else {
    $i = 0;
    while ($i < count($_SESSION['path'])) {
        $_SESSION['path']['decode'][] = _decode($_SESSION['path'][$i]);
        $i++;
    }
    $pk = new pclzip(_decode($_GET['path']) . '/' . $_REQUEST['pkname']);
    echo <<<HTML
<div class="big_board"><div class="board_title">压缩数据-压缩结果</div></div>
HTML;
    if ($pk->create($_SESSION['path']['decode'], PCLZIP_OPT_REMOVE_PATH, _decode($_GET['path'])) == true) {
        echo 'Hello,压缩包 ' . $_REQUEST['pkname'] . ' 生成成功!';
    } else {
        echo 'Hello,压缩包 ' . $_REQUEST['pkname'] . ' 生成失败!';
    }
}
echo <<<HTML
<div class="big_board"><div class="board_title">By:Admin@Aite.Me</div></div>
HTML;
unset($_SESSION['path']);
コード例 #13
0
ファイル: unpack.php プロジェクト: liuguogen/weixin
                 while (!feof($bz2)) {
                     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 "无法成功解压您的文件!";
コード例 #14
0
ファイル: genfile.php プロジェクト: amjadtbssm/website
         $tpl->parseCurrentBlock("auto_refresher");
         $filename = tempnam("", "jh_");
         setcookie(DTX_COOKIE_NAME, $filename);
         $file = fopen($filename, "w");
         foreach ($unitIDs as $unitID) {
             fwrite($file, trim($unitID) . "\n");
         }
         fclose($file);
         $tpl->show();
     }
 } elseif (array_key_exists(DTX_COOKIE_NAME . "_project", $_COOKIE)) {
     // Step 3: The last cookie is the project Id cookie, so we know
     // that we can create the zip file from the dtx files.
     // create zip
     $zipname = tempnam("", "jh_");
     $zip = new pclzip($zipname);
     $addResult = $zip->add($outDirName . "/", PCLZIP_OPT_REMOVE_ALL_PATH);
     if ($addResult == 0) {
         $msg = "Error creating zip file:" . $zip->errorInfo(true);
         $tpl->SetVariable("MESSAGE", $msg);
         $tpl->Show();
     } else {
         $projectInfos = GetProjectInfos($_COOKIE[DTX_COOKIE_NAME . "_project"]);
         $filename = $projectInfos["Name"] . ".zip";
         // we have the zip, send it
         header("Content-Type: archive/zip");
         // replace by text/plain for debug
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         // don't use file_get_contents, it might be too recent
         //        echo file_get_contents($zipname);
         $file = fopen($zipname, "rb");
コード例 #15
0
ファイル: unzip.php プロジェクト: liuguogen/weixin
    xhtml_head("ZIP工具");
    echo "<div class=\"like\">\n";
    echo "<a href=\"./dlym.php?path=" . urlencode(dirname($path)) . "\"]>返回目录</a>错误提示\n";
    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 {
コード例 #16
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;
    }
}
コード例 #17
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;
 }
コード例 #18
0
ファイル: control.php プロジェクト: XMGmen/zentao
 /**
  * Down notify.
  * 
  * @access public
  * @return void
  */
 public function downNotify()
 {
     $notifyDir = $this->app->getBasePath() . 'www/data/notify/';
     $packageFile = $notifyDir . 'notify.zip';
     $loginFile = $notifyDir . 'config.json';
     /* write login info into tmp file. */
     $loginInfo = new stdclass();
     $userInfo = new stdclass();
     $userInfo->Account = $this->app->user->account;
     $userInfo->Url = common::getSysURL() . $this->config->webRoot;
     $userInfo->PassMd5 = '';
     $userInfo->Role = $this->app->user->role;
     $userInfo->AutoSignIn = true;
     $userInfo->Lang = $this->cookie->lang;
     $loginInfo->User = $userInfo;
     $loginInfo->LastLoginTime = time() / 86400 + 25569;
     $loginInfo = json_encode($loginInfo);
     file_put_contents($loginFile, $loginInfo);
     define('PCLZIP_TEMPORARY_DIR', $notifyDir);
     $this->app->loadClass('pclzip', true);
     /* remove the old config.json, add a new one. */
     $archive = new pclzip($packageFile);
     $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'config.json');
     if ($result == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH);
     if ($result == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     unlink($loginFile);
     $this->fetch('file', 'sendDownHeader', array('fileName' => 'notify.zip', 'zip', file_get_contents($packageFile)));
     $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'config.json');
     if ($result == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
 }
コード例 #19
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;
 }
コード例 #20
0
ファイル: export2excel.class.php プロジェクト: leowh/colla
 /**
  * Export data to Excel. This is main function.
  *
  * @param  object $data 
  * @param  string $savePath , define the path to save xlsx file
  * @access public
  * @return void
  */
 public function export($data, $savePath = '')
 {
     $this->init($data);
     $this->setDocProps();
     $this->excelKey = array();
     for ($i = 0; $i < count($this->fieldsKey); $i++) {
         $field = $this->fieldsKey[$i];
         $this->excelKey[$field] = $this->setExcelField($i);
         if (in_array($field, $this->config->excel->centerFields)) {
             $this->styleSetting['center'][$this->excelKey[$field]] = 1;
         }
         if (strpos($field, 'Date') !== false || in_array($field, $this->config->excel->dateField)) {
             $this->styleSetting['date'][$this->excelKey[$field]] = 1;
         }
     }
     /* Show header data. */
     $this->sheet1SheetData = '<row r="1" spans="1:%colspan%" ht="20" customHeight="1">';
     foreach ($this->fields as $key => $field) {
         $this->sheet1SheetData .= $this->setCellValue($this->excelKey[$key], '1', $field, !isset($this->rawExcelData->nocolor));
     }
     $this->sheet1SheetData .= '</row>';
     /* Write system data in excel.*/
     $this->writeSysData();
     $i = 1;
     $excelData = array();
     foreach ($this->rows as $num => $row) {
         $i++;
         $columnData = array();
         $this->sheet1SheetData .= '<row r="' . $i . '" spans="1:%colspan%" ht="20" customHeight="1">';
         foreach ($this->excelKey as $key => $letter) {
             $value = isset($row[$key]) ? $row[$key] : '';
             /* Merge Cells.*/
             if (isset($this->rawExcelData->rowspan[$num]) and strpos($this->rawExcelData->rowspan[$num]['rows'], ",{$key},") !== false) {
                 $this->mergeCells($letter . $i, $letter . ($i + $this->rawExcelData->rowspan[$num]['num'] - 1));
             }
             if (isset($this->rawExcelData->colspan[$num]) and strpos($this->rawExcelData->colspan[$num]['cols'], ",{$key},") !== false) {
                 $this->mergeCells($letter . $i, chr(ord($letter) + $this->rawExcelData->colspan[$num]['num'] - 1) . $i);
             }
             /* Wipe off html tags. Use to export html message like company->selfDesc via js::kindeditor */
             if (isset($this->config->excel->editor[$this->rawExcelData->kind]) and in_array($key, $this->config->excel->editor[$this->rawExcelData->kind])) {
                 $value = $this->file->excludeHtml($value);
             }
             if (isset($value[1])) {
                 $value = $value[1] == ':' ? $substr($value, 2) : $value;
             }
             $this->sheet1SheetData .= $this->setCellValue($letter, $i, $value, !isset($this->rawExcelData->nocolor));
             /* Build excel list.*/
             if (isset($this->rawExcelData->listStyle) and in_array($key, $this->rawExcelData->listStyle)) {
                 $this->buildList($key, $i);
             }
         }
         $this->sheet1SheetData .= '</row>';
     }
     $this->sheet1Params['colspan'] = count($this->excelKey) - 1;
     $this->setStyle($i);
     if (!empty($this->sheet1Params['cols'])) {
         $this->sheet1Params['cols'] = '<cols>' . $this->sheet1Params['cols'] . '</cols>';
     }
     if (!empty($this->sheet1Params['mergeCells'])) {
         $this->sheet1Params['mergeCells'] = '<mergeCells count="' . $this->counts['mergeCells'] . '">' . $this->sheet1Params['mergeCells'] . '</mergeCells>';
     }
     if (!empty($this->sheet1Params['dataValidations'])) {
         $this->sheet1Params['dataValidations'] = '<dataValidations count="' . $this->counts['dataValidations'] . '">' . $this->sheet1Params['dataValidations'] . '</dataValidations>';
     }
     if (!empty($this->sheet1Params['hyperlinks'])) {
         $this->sheet1Params['hyperlinks'] = '<hyperlinks>' . $this->sheet1Params['hyperlinks'] . '</hyperlinks>';
     }
     /* Save sheet1*/
     $sheet1 = file_get_contents($this->exportPath . 'xl/worksheets/sheet1.xml');
     $sheet1 = str_replace(array('%area%', '%xSplit%', '%topLeftCell%', '%cols%', '%sheetData%', '%mergeCells%', '%dataValidations%', '%hyperlinks%', '%colspan%'), array($this->sheet1Params['area'], $this->sheet1Params['xSplit'], $this->sheet1Params['topLeftCell'], $this->sheet1Params['cols'], $this->sheet1SheetData, $this->sheet1Params['mergeCells'], $this->sheet1Params['dataValidations'], $this->sheet1Params['hyperlinks'], $this->sheet1Params['colspan']), $sheet1);
     file_put_contents($this->exportPath . 'xl/worksheets/sheet1.xml', $sheet1);
     /* Save sharedStrings file. */
     $this->sharedStrings .= '</sst>';
     $this->sharedStrings = str_replace('%count%', $this->record, $this->sharedStrings);
     file_put_contents($this->exportPath . 'xl/sharedStrings.xml', $this->sharedStrings);
     /* Save link message. */
     if ($this->rels) {
         $this->rels = '<?xml version="1.0" encoding="UTF-8" standalone="yes"? ><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">' . $this->rels . '</Relationships>';
         if (!is_dir($this->exportPath . 'xl/worksheets/_rels/')) {
             mkdir($this->exportPath . 'xl/worksheets/_rels/');
         }
         file_put_contents($this->exportPath . 'xl/worksheets/_rels/sheet1.xml.rels', $this->rels);
     }
     /* urlencode the filename for ie. */
     $fileName = $this->rawExcelData->fileName . '.xlsx';
     /* Zip to xlsx. */
     helper::cd($this->exportPath);
     $files = array('[Content_Types].xml', '_rels', 'docProps', 'xl');
     $zip = new pclzip($fileName);
     $zip->create($files);
     $fileData = file_get_contents($this->exportPath . $fileName);
     $this->zfile->removeDir($this->exportPath);
     if ($savePath == '') {
         $this->sendDownHeader($fileName, 'xlsx', $fileData);
     } else {
         file_put_contents($savePath, $fileData);
     }
 }