国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

media_edit.php 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * 附件编辑
  4. *
  5. * @version $Id: media_edit.php 1 11:17 2010年7月19日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2021, 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. CheckPurview('sys_Upload,sys_MyUpload');
  14. if (empty($dopost)) $dopost = "";
  15. $backurl = isset($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : "javascript:history.go(-1);";
  16. /*---------------------------
  17. function __del_file() //删除附件
  18. -----------------------------*/
  19. if ($dopost == 'del') {
  20. CheckPurview('sys_DelUpload');
  21. if (empty($ids)) {
  22. $ids = "";
  23. }
  24. if ($ids == "") {
  25. $myrow = $dsql->GetOne("SELECT url FROM `#@__uploads` WHERE aid='" . $aid . "'");
  26. $truefile = $cfg_basedir . $myrow['url'];
  27. $rs = 0;
  28. if (!file_exists($truefile) || $myrow['url'] == "") {
  29. $rs = 1;
  30. } else {
  31. $rs = @unlink($truefile);
  32. }
  33. if ($rs == 1) {
  34. $msg = "成功删除一个附件!";
  35. $dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads` WHERE aid='" . $aid . "'");
  36. }
  37. ShowMsg($msg, $backurl);
  38. exit();
  39. } else {
  40. $ids = explode(',', $ids);
  41. $idquery = "";
  42. foreach ($ids as $aid) {
  43. if ($idquery == "") {
  44. $idquery .= " WHERE aid='$aid' ";
  45. } else {
  46. $idquery .= " OR aid='$aid' ";
  47. }
  48. }
  49. $dsql->SetQuery("SELECT aid,url FROM `#@__uploads` $idquery ");
  50. $dsql->Execute();
  51. while ($myrow = $dsql->GetArray()) {
  52. $truefile = $cfg_basedir . $myrow['url'];
  53. $rs = 0;
  54. if (!file_exists($truefile) || $myrow['url'] == "") {
  55. $rs = 1;
  56. } else {
  57. $rs = @unlink($truefile);
  58. }
  59. if ($rs == 1) {
  60. $dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads` WHERE aid='" . $myrow['aid'] . "'");
  61. }
  62. }
  63. ShowMsg('成功删除选定的文件!', $backurl);
  64. exit();
  65. }
  66. }
  67. /*--------------------------------
  68. function __save_edit() //保存更改
  69. -----------------------------------*/ else if ($dopost == 'save') {
  70. if ($aid == "") exit();
  71. CheckCSRF();
  72. //检查是否有修改权限
  73. $myrow = $dsql->GetOne("SELECT * FROM `#@__uploads` WHERE aid='" . $aid . "'");
  74. if ($myrow['mid'] != $cuserLogin->getUserID()) {
  75. CheckPurview('sys_Upload');
  76. }
  77. //检测文件类型
  78. $addquery = "";
  79. if (is_uploaded_file($upfile)) {
  80. if ($mediatype == 1) {
  81. $sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
  82. if (!in_array($upfile_type, $sparr)) {
  83. ShowMsg("你上传的不是图片类型的文件!", "javascript:history.go(-1);");
  84. exit();
  85. }
  86. } else if ($mediatype == 2) {
  87. $sparr = array("application/x-shockwave-flash");
  88. if (!in_array($upfile_type, $sparr)) {
  89. ShowMsg("你上传的不是Flash类型的文件!", "javascript:history.go(-1);");
  90. exit();
  91. }
  92. } else if ($mediatype == 3) {
  93. if (!preg_match('#audio|media|video#i', $upfile_type)) {
  94. ShowMsg("你上传的为不正确类型的影音文件!", "javascript:history.go(-1);");
  95. exit();
  96. }
  97. if (!preg_match("#\." . $cfg_mediatype . "#", $upfile_name)) {
  98. ShowMsg("你上传的影音文件扩展名无法被识别,请更改系统配置的参数!", "javascript:history.go(-1);");
  99. exit();
  100. }
  101. } else {
  102. if (!preg_match("#\." . $cfg_softtype . "#", $upfile_name)) {
  103. ShowMsg("你上传的附件扩展名无法被识别,请更改系统配置的参数!", "javascript:history.go(-1);");
  104. exit();
  105. }
  106. }
  107. //保存文件
  108. $nowtime = time();
  109. $oldfile = $myrow['url'];
  110. $oldfiles = explode('/', $oldfile);
  111. $fullfilename = $cfg_basedir . $oldfile;
  112. $oldfile_path = preg_replace("#" . $oldfiles[count($oldfiles) - 1] . "$#", "", $oldfile);
  113. if (!is_dir($cfg_basedir . $oldfile_path)) {
  114. MkdirAll($cfg_basedir . $oldfile_path, 777);
  115. CloseFtp();
  116. }
  117. @move_uploaded_file($upfile, $fullfilename);
  118. if ($mediatype == 1) {
  119. require_once(DEDEINC . "/image.func.php");
  120. if (in_array($upfile_type, $cfg_photo_typenames)) {
  121. WaterImg($fullfilename, 'up');
  122. }
  123. }
  124. $filesize = $upfile_size;
  125. $imgw = 0;
  126. $imgh = 0;
  127. if ($mediatype == 1) {
  128. $info = "";
  129. $sizes[0] = 0;
  130. $sizes[1] = 0;
  131. $sizes = @getimagesize($fullfilename, $info);
  132. $imgw = $sizes[0];
  133. $imgh = $sizes[1];
  134. }
  135. if ($imgw > 0) {
  136. $addquery = ",width='$imgw',height='$imgh',filesize='$filesize' ";
  137. } else {
  138. $addquery = ",filesize='$filesize' ";
  139. }
  140. } else {
  141. $fileurl = $filename;
  142. }
  143. //写入数据库
  144. $query = " UPDATE #@__uploads SET title='$title',mediatype='$mediatype',playtime='$playtime'";
  145. $query .= "$addquery WHERE aid='$aid' ";
  146. $dsql->ExecuteNoneQuery($query);
  147. ShowMsg('成功更改一则附件数据!', 'media_edit.php?aid=' . $aid);
  148. exit();
  149. }
  150. //读取档案信息
  151. $myrow = $dsql->GetOne("SELECT * FROM #@__uploads WHERE aid='" . $aid . "'");
  152. if (!is_array($myrow)) {
  153. ShowMsg('错误,找不到此编号的档案!', 'javascript:;');
  154. exit();
  155. }
  156. include DedeInclude('templets/media_edit.htm');