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

94 lines
3.9KB

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