|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * 模块上传
- *
- * @version $id:module_upload.php 14:43 2010年7月20日 tianya $
- * @package DedeBIZ.Administrator
- * @copyright Copyright (c) 2022 DedeBIZ.COM
- * @license https://www.dedebiz.com/license
- * @link https://www.dedebiz.com
- */
- require_once(dirname(__FILE__)."/config.php");
- if (DEDEBIZ_SAFE_MODE) {
- die(DedeAlert("系统已启用安全模式,无法使用当前功能",ALERT_DANGER));
- }
- CheckPurview('sys_module');
- require_once(DEDEINC."/dedemodule.class.php");
- require_once(DEDEINC."/libraries/oxwindow.class.php");
- if (empty($action)) $action = '';
- $mdir = DEDEDATA.'/module';
- if ($action == 'upload') {
- if (!is_uploaded_file($upfile)) {
- ShowMsg("您什么都没有上传", "javascript:;");
- exit();
- } else {
- include_once(DEDEINC."/libraries/zip.class.php");
- $tmpfilename = $mdir.'/'.ExecTime().mt_rand(10000, 50000).'.tmp';
- move_uploaded_file($upfile, $tmpfilename) or die("把上传的文件移动到{$tmpfilename}时失败,请检查{$mdir}目录是否有写入权限");
- $dm = new DedeModule($mdir);
- $infos = $dm->GetModuleInfo($tmpfilename, 'file');
- if (empty($infos['hash'])) {
- unlink($tmpfilename);
- $dm->Clear();
- ShowMsg("对不起,您上传的文件可能不是模块的标准格式文件<br><a href='javascript:history.go(-1);'>重新上传</a>", "javascript:;");
- exit();
- }
- if (preg_match("#[^0-9a-zA-Z]#", $infos['hash'])) {
- exit("hash check failed!");
- }
- $okfile = $mdir.'/'.$infos['hash'].'.xml';
- if ($dm->HasModule($infos['hash']) && empty($delhas)) {
- unlink($tmpfilename);
- $dm->Clear();
- ShowMsg("对不起,您上传的模块已经存在<br>如果要覆盖请先删除原来版本或选择强制删除的选项<br><a href='javascript:history.go(-1);'>重新上传</a>", "javascript:;");
- exit();
- }
- @unlink($okfile);
- copy($tmpfilename, $okfile);
- @unlink($tmpfilename);
- $dm->Clear();
- ShowMsg("成功上传一个新的模块", "module_main.php?action=view&hash={$infos['hash']}");
- exit();
- }
- } else {
- $win = new OxWindow();
- $win->Init("module_upload.php", "js/blank.js", "POST' enctype='multipart/form-data");
- $win->mainTitle = "模块管理";
- $wecome_info = "<a href='module_main.php'>模块管理</a> > 上传模块";
- $win->AddTitle('请选择要上传的文件');
- $win->AddHidden("action", 'upload');
- $msg = "<table width='900' cellspacing='0' cellpadding='0'>
- <tr>
- <td width='260'>文件格式:</td>
- <td>
- <label><input type='radio' name='filetype' value='0' checked='checked'> 正常的模块包</label>
- </td>
- </tr>
- <tr>
- <td>已有模块:</td>
- <td><label><input type='checkbox' name='delhas' id='delhas' value='1'> 强制删除同名模块,这可能导致已经安装的模块无法卸载</label></td>
- </tr>
- <tr>
- <td>请选择文件:</td>
- <td><input name='upfile' type='file' id='upfile' class='admin-input-lg'></td>
- </tr>
- </table>";
- $win->AddMsgItem("$msg");
- $winform = $win->GetWindow('ok', '');
- $win->Display();
- exit();
- }//ClearAllLink();
- ?>
|