国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
3.3KB

  1. <?php
  2. /**
  3. * 模块上传
  4. *
  5. * @version $id:module_upload.php 14:43 2010年7月20日 tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022 DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. if (DEDEBIZ_SAFE_MODE) {
  13. die(DedeAlert("系统已启用安全模式,无法使用当前功能",ALERT_DANGER));
  14. }
  15. CheckPurview('sys_module');
  16. require_once(DEDEINC."/dedemodule.class.php");
  17. require_once(DEDEINC."/libraries/oxwindow.class.php");
  18. if (empty($action)) $action = '';
  19. $mdir = DEDEDATA.'/module';
  20. if ($action == 'upload') {
  21. if (!is_uploaded_file($upfile)) {
  22. ShowMsg("您什么都没有上传", "javascript:;");
  23. exit();
  24. } else {
  25. include_once(DEDEINC."/libraries/zip.class.php");
  26. $tmpfilename = $mdir.'/'.ExecTime().mt_rand(10000, 50000).'.tmp';
  27. move_uploaded_file($upfile, $tmpfilename) or die("把上传的文件移动到<span class='text-primary'>{$tmpfilename}</span>时失败,请检查<span class='text-primary'>{$mdir}</span>目录是否有写入权限");
  28. $dm = new DedeModule($mdir);
  29. $infos = $dm->GetModuleInfo($tmpfilename, 'file');
  30. if (empty($infos['hash'])) {
  31. unlink($tmpfilename);
  32. $dm->Clear();
  33. ShowMsg("您上传的文件可能不是模块的标准格式文件,<a href='javascript:history.go(-1);'>重新上传</a>", "javascript:;");
  34. exit();
  35. }
  36. if (preg_match("#[^0-9a-zA-Z]#", $infos['hash'])) {
  37. exit("hash check failed!");
  38. }
  39. $okfile = $mdir.'/'.$infos['hash'].'.xml';
  40. if ($dm->HasModule($infos['hash']) && empty($delhas)) {
  41. unlink($tmpfilename);
  42. $dm->Clear();
  43. ShowMsg("您上传的模块已经存在,请删除原模块文件或强制删除同名模块上传,<a href='javascript:history.go(-1);'>重新上传</a>", "javascript:;");
  44. exit();
  45. }
  46. @unlink($okfile);
  47. copy($tmpfilename, $okfile);
  48. @unlink($tmpfilename);
  49. $dm->Clear();
  50. ShowMsg("成功上传一个新的模块", "module_main.php?action=view&hash={$infos['hash']}");
  51. exit();
  52. }
  53. } else {
  54. $win = new OxWindow();
  55. $win->Init("module_upload.php", "js/blank.js", "POST' enctype='multipart/form-data");
  56. $win->mainTitle = "模块管理";
  57. $wecome_info = "<a href='module_main.php'>模块管理</a> &gt; 上传模块";
  58. $win->AddTitle('请选择要上传的文件');
  59. $win->AddHidden("action", 'upload');
  60. $msg = "<table width='900' cellspacing='0' cellpadding='0'>
  61. <tr>
  62. <td width='260'>文件格式:</td>
  63. <td><label><input type='radio' name='filetype' value='0' checked='checked'> 正常的模块包</label></td>
  64. </tr>
  65. <tr>
  66. <td>已有模块:</td>
  67. <td><label><input type='checkbox' name='delhas' id='delhas' value='1'> 强制删除同名模块,这可能导致已经安装的模块无法卸载</label></td>
  68. </tr>
  69. <tr>
  70. <td>请选择文件:</td>
  71. <td><input name='upfile' type='file' id='upfile' class='admin-input-lg'></td>
  72. </tr>
  73. </table>";
  74. $win->AddMsgItem("$msg");
  75. $winform = $win->GetWindow('ok', '');
  76. $win->Display();
  77. exit();
  78. }//ClearAllLink();
  79. ?>