Exemplo n.º 1
0
	[Destoon B2B System] Copyright (c) 2008-2015 www.destoon.com
	This is NOT a freeware, use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array(array('编辑助手', '?file=' . $file));
switch ($action) {
    case 'upload':
        $_FILES['uploadfile']['size'] or dalert('请选择zip文件');
        require DT_ROOT . '/include/upload.class.php';
        $name = date('YmdHis') . mt_rand(10, 99) . $_userid;
        $upload = new upload($_FILES, 'file/temp/', $name . '.zip', 'zip');
        $upload->adduserid = false;
        if ($upload->save()) {
            dir_create(DT_ROOT . '/file/temp/' . $name);
            require DT_ROOT . '/admin/unzip.class.php';
            $zip = new unzip();
            $zip->extract_zip(DT_ROOT . '/file/temp/' . $name . '.zip', DT_ROOT . '/file/temp/' . $name);
            file_del(DT_ROOT . '/file/temp/' . $name . '.zip');
            $F = get_file(DT_ROOT . '/file/temp/' . $name);
            if ($F) {
                $htm = '';
                $max = 0;
                foreach ($F as $f) {
                    $ext = file_ext($f);
                    if (in_array($ext, array('htm', 'html'))) {
                        $tmp = filesize($f);
                        if ($tmp > $max) {
                            $htm = str_replace(DT_ROOT . '/file/temp/', '', $f);
                        }
                        $max = $tmp;
                    } else {
Exemplo n.º 2
0
     } else {
         msg('无法连接官方服务器,请重试或稍后更新');
     }
     dir_create($release_dir);
     if (@copy($code, $release_dir . '/' . $release . '.zip')) {
         file_copy(DT_ROOT . '/file/index.html', $release_dir . '/index.html');
         dir_create($release_dir . '/source/');
         dir_create($release_dir . '/backup/');
         msg('更新下载成功,开始解压缩..', '?file=' . $file . '&action=unzip&release=' . $release);
     } else {
         msg('更新下载失败,请重试..');
     }
     break;
 case 'unzip':
     require DT_ROOT . '/admin/unzip.class.php';
     $zip = new unzip();
     $zip->extract_zip($release_dir . '/' . $release . '.zip', $release_dir . '/source/');
     if (is_file($release_dir . '/source/destoon/version.inc.php')) {
         msg('更新解压缩成功,开始更新文件..', '?file=' . $file . '&action=copy&release=' . $release);
     } else {
         msg('更新解压缩失败,请重试..');
     }
     break;
 case 'copy':
     if ($CFG['template'] != 'default' && is_dir($release_dir . '/source/destoon/template/default')) {
         @rename($release_dir . '/source/destoon/template/default', $release_dir . '/source/destoon/template/' . $CFG['template']);
     }
     if ($CFG['skin'] != 'default' && is_dir($release_dir . '/source/destoon/skin/default')) {
         @rename($release_dir . '/source/destoon/skin/default', $release_dir . '/source/destoon/skin/' . $CFG['skin']);
     }
     $files = file_list($release_dir . '/source/destoon');
Exemplo n.º 3
0
 function extract_files()
 {
     $pwd = getcwd();
     chdir($this->options['basedir']);
     $z = new unzip();
     $result = $z->Extract($this->options['name'], $this->options['basedir']);
     //print_r($result);
 }
Exemplo n.º 4
0
            $userid = $_SESSION["userid"];
            if (move_uploaded_file($srcfile, $destfile)) {
                $mysql->query("insert into attachment(title,size,type,path,time,unzip) values ('{$title}','{$size}','{$ext}','{$destfile}','{$time}','{$unzip}')");
                $attachmentId = $mysql->insert_id();
                $res = $mysql->query("select * from courseunitversion_rel_attachment where deleted=0 and courseunitid=" . $courseunitId);
                if ($mysql->num_rows($res) == 0) {
                    $mysql->query("insert into courseunitversion_rel_attachment (courseunitid,attachmentid,versionname,userid,time) values ('{$courseunitId}','{$attachmentId}','默认版本','{$userid}','{$time}')");
                } else {
                    if ($rewrite) {
                        $mysql->query("update courseunitversion_rel_attachment set attachmentid='{$attachmentId}',userid='{$userid}',lpid='0' where id=" . $_POST["versionid"]);
                    } else {
                        $mysql->query("insert into courseunitversion_rel_attachment (courseunitid,attachmentid,versionname,userid,time) values ('{$courseunitId}','{$attachmentId}','" . $versionname . "','{$userid}','{$time}')");
                    }
                }
                if ($unzip && $ext == "zip") {
                    $unzip = new unzip();
                    $unzip->extract_zip($destfile, $up_folder . "unzip/");
                }
                header("Location:courseUnitShow.php?id=" . $courseunitId);
            } else {
                die("上传文件时发生错误");
            }
        }
    }
} else {
    if ($packageType == 2) {
        // SCORM/AICC
        $userid = $_SESSION["userid"];
        include "scorm/lp_upload.php";
    }
}
Exemplo n.º 5
0
 $stopping_error = false;
 $time = date("Y-m-d H:i:s");
 $title = $_FILES['file']['name'];
 $srcfile = $_FILES['file']['tmp_name'];
 $size = round($_FILES['file']['size'] / 1000);
 //get name of the zip file without the extension
 $extension = file_ext($title);
 $filename = date("YmdHis-") . rand(1000, 9999) . "." . $extension;
 $file_base_name = str_replace('.' . $extension, '', $filename);
 //$file_base_name = replace_dangerous_char(trim($file_base_name),'strict');
 //move_uploaded_file($srcfile,$course_dir.iconv("GBK","UTF-8",$s));
 move_uploaded_file($srcfile, $course_dir . $filename);
 //die("insert into attachment(title,size,type,path,time,unzip) values ('$title','$size','$extension','".$course_dir.$filename."','$time','1')");
 $mysql->query("insert into attachment(title,size,type,path,time,unzip) values ('{$title}','{$size}','{$extension}','" . $course_dir . $filename . "','{$time}','1')");
 $attachmentId = $mysql->insert_id();
 $unzip = new unzip();
 $unzip->extract_zip($course_dir . $filename, $course_dir . $file_base_name . "/");
 $type = learnpath::get_package_type($course_dir . $filename, $filename);
 switch ($type) {
     case 'scorm':
         require_once 'scorm.class.php';
         //require_once api_get_path(LIBRARY_PATH).'searchengine.lib.php';
         $oScorm = new scorm();
         //$manifest = $oScorm->import_package($_FILES['file'],$current_dir);
         $manifest = $course_dir . $file_base_name . "/imsmanifest.xml";
         if (!empty($manifest)) {
             $oScorm->parse_manifest($manifest);
             $oScorm->import_manifest($parentDir);
         } else {
             //show error message stored in $oScrom->error_msg
             //logger("error: lp_upload->switch(scorm)->empty(manifest)");