Exemple #1
0
 public static function init($force = false)
 {
     $info = self::getVersion($force);
     if ($info->app == iPHP_APP && version_compare($info->version, iCMS_VER, '>=') && $info->release > iCMS_RELEASE) {
         self::$version = $info->version;
         self::$release = $info->release;
         self::$zipName = 'iCMS.' . self::$version . '.patch.' . self::$release . '.zip';
         return array(self::$version, self::$release, $info->update, $info->changelog);
     }
 }
Exemple #2
0
 function do_update()
 {
     $this->msg = iPatch::download();
     //下载文件包
     include iACP::view("patch");
 }
Exemple #3
0
 public static function update()
 {
     @set_time_limit(0);
     // Unzip uses a lot of memory
     @ini_set('memory_limit', '256M');
     require iPHP_CORE . '/pclzip.class.php';
     //加载zip操作类
     $zipFile = PATCH_DIR . '/' . self::$zipName;
     //临时文件
     $msg = '正在对 [' . self::$zipName . '] 更新包进行解压缩<iCMS>';
     $zip = new PclZip($zipFile);
     if (false == ($archive_files = $zip->extract(PCLZIP_OPT_EXTRACT_AS_STRING))) {
         exit("ZIP包错误");
     }
     if (0 == count($archive_files)) {
         exit("空的ZIP文件");
     }
     $msg .= '解压完成<iCMS>';
     $msg .= '开始测试目录权限<iCMS>';
     $bakDir = iPATH . self::$release . 'bak';
     $update = true;
     if (!self::checkDir(iPATH)) {
         $update = false;
         $msg .= iPATH . ' 目录无写权限<iCMS>';
     }
     //测试目录文件是否写
     foreach ($archive_files as $file) {
         $folder = $file['folder'] ? $file['filename'] : dirname($file['filename']);
         $dp = iPATH . $folder;
         if (!self::checkDir($dp) && iFS::ex($dp)) {
             $update = false;
             $msg .= $dp . ' 目录无写权限<iCMS>';
         }
         if (empty($file['folder'])) {
             $fp = iPATH . $file['filename'];
             if (file_exists($fp) && !@is_writable($fp)) {
                 $update = false;
                 $msg .= $fp . ' 文件无写权限<iCMS>';
             }
         }
     }
     if (!$update) {
         $msg .= '权限测试无法完成<iCMS>';
         $msg .= '请设置好上面提示的文件写权限<iCMS>';
         $msg .= '然后重新更新<iCMS>';
         iPatch::$next = false;
         return $msg;
     }
     //测试通过!
     iPatch::$next = true;
     iFS::mkdir($bakDir);
     $msg .= '权限测试通过<iCMS>';
     $msg .= '备份目录创建完成<iCMS>';
     $msg .= '开始更新程序<iCMS>';
     foreach ($archive_files as $file) {
         $folder = $file['folder'] ? $file['filename'] : dirname($file['filename']);
         $dp = iPATH . $folder;
         if (!iFS::ex($dp)) {
             $msg .= '创建 [' . $dp . '] 文件夹<iCMS>';
             iFS::mkdir($dp);
         }
         if (empty($file['folder'])) {
             $fp = iPATH . $file['filename'];
             $bfp = $bakDir . '/' . $file['filename'];
             iFS::mkdir(dirname($bfp));
             if (iFS::ex($fp)) {
                 $msg .= '备份 [' . $fp . '] 文件 到 [' . $bfp . ']<iCMS>';
                 @rename($fp, $bfp);
                 //备份旧文件
             }
             $msg .= '更新 [' . $fp . '] 文件<iCMS>';
             iFS::write($fp, $file['content']);
             $msg .= '[' . $fp . '] 更新完成!<iCMS>';
         }
     }
     $msg .= '清除临时文件!<iCMS>注:原文件备份在 [' . $bakDir . '] 目录<iCMS>如没有特殊用处请删除此目录!<iCMS>';
     iFS::rmdir(PATCH_DIR, true, 'version.txt');
     return $msg;
 }