国内流行的内容管理系统(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.

95 lines
4.0KB

  1. <?php
  2. /**
  3. * 附件添加
  4. *
  5. * @version $Id: media_add.php 2 15:25 2011-6-2 tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  8. * @copyright Copyright (c) 2020, DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license/v6
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(dirname(__FILE__) . "/config.php");
  13. //增加权限检查
  14. if (empty($dopost)) $dopost = "";
  15. //上传
  16. if ($dopost == "upload") {
  17. CheckCSRF();
  18. require_once(DEDEINC . "/image.func.php");
  19. $sparr_image = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/x-png", "image/wbmp");
  20. $sparr_flash = array("application/xshockwaveflash");
  21. $okdd = 0;
  22. $uptime = time();
  23. $adminid = $cuserLogin->getUserID();
  24. $width = $height = '';
  25. for ($i = 0; $i <= 40; $i++) {
  26. if (isset(${"upfile" . $i}) && is_uploaded_file(${"upfile" . $i})) {
  27. $filesize = ${"upfile" . $i . "_size"};
  28. $upfile_type = ${"upfile" . $i . "_type"};
  29. $upfile_name = ${"upfile" . $i . "_name"};
  30. $dpath = MyDate("ymd", $uptime);
  31. if (in_array($upfile_type, $sparr_image)) {
  32. $mediatype = 1;
  33. $savePath = $cfg_image_dir . "/" . $dpath;
  34. } else if (in_array($upfile_type, $sparr_flash)) {
  35. $mediatype = 2;
  36. $savePath = $cfg_other_medias . "/" . $dpath;
  37. }
  38. // 2011-6-2 修复附件无法上传的错误(by:tianya)
  39. else if (preg_match('#audio|media|video#i', $upfile_type) && preg_match("#\." . $cfg_mediatype . "$#i", $upfile_name)) {
  40. $mediatype = 3;
  41. $savePath = $cfg_other_medias . "/" . $dpath;
  42. } else if (preg_match("#\." . $cfg_softtype . "+\." . $cfg_softtype . "$#i", $upfile_name)) {
  43. $mediatype = 4;
  44. $savePath = $cfg_soft_dir . "/" . $dpath;
  45. } else {
  46. continue;
  47. }
  48. $filename = "{$adminid}_" . MyDate("His", $uptime) . mt_rand(100, 999) . $i;
  49. $fs = explode(".", ${"upfile" . $i . "_name"});
  50. $filename = $filename . "." . $fs[count($fs) - 1];
  51. $filename = $savePath . "/" . $filename;
  52. if (!is_dir($cfg_basedir . $savePath)) {
  53. MkdirAll($cfg_basedir . $savePath, 777);
  54. CloseFtp();
  55. }
  56. /*
  57. dedecms后台文件任意上传漏洞
  58. 漏洞描述:dedecms早期版本后台存在大量的富文本编辑器,该控件提供了一些文件上传接口,同时dedecms对上传文件的后缀类型未进行严格的限制,这导致了黑客可以上传WEBSHELL,获取网站后台权限。
  59. */
  60. if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml)[^a-zA-Z0-9]+$#i', trim($filename))) {
  61. ShowMsg("你指定的文件名被系统禁止!", "javascript:;");
  62. exit();
  63. }
  64. $fullfilename = $cfg_basedir . $filename;
  65. if ($mediatype == 1) {
  66. @move_uploaded_file(${"upfile" . $i}, $fullfilename);
  67. $info = '';
  68. $data = getImagesize($fullfilename, $info);
  69. $width = $data[0];
  70. $height = $data[1];
  71. if (in_array($upfile_type, $cfg_photo_typenames)) WaterImg($fullfilename, 'up');
  72. } else {
  73. @move_uploaded_file(${"upfile" . $i}, $fullfilename);
  74. }
  75. if ($i > 1) {
  76. $ntitle = $title . "_" . $i;
  77. } else {
  78. $ntitle = $title;
  79. }
  80. $inquery = "INSERT INTO `#@__uploads`(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
  81. VALUES ('$ntitle','$filename','$mediatype','$width','$height','$playtime','$filesize','$uptime','$adminid'); ";
  82. $okdd++;
  83. $dsql->ExecuteNoneQuery($inquery);
  84. }
  85. }
  86. ShowMsg("成功上传 {$okdd} 个文件!", "media_main.php");
  87. exit();
  88. }
  89. include DedeInclude('templets/media_add.htm');