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

45 lines
1.7KB

  1. <?php
  2. /**
  3. * 模板发送
  4. *
  5. * @version $Id: select_templets_post.php 1 9:43 2010年7月8日Z tianya $
  6. * @package DedeBIZ.Dialog
  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. $cfg_txttype = "htm|html|tpl|txt";
  13. if (empty($uploadfile)) {
  14. $uploadfile = "";
  15. }
  16. if (!is_uploaded_file($uploadfile)) {
  17. ShowMsg("你没有选择上传的文件!", "-1");
  18. exit();
  19. }
  20. if (!preg_match("#^text#", $uploadfile_type)) {
  21. ShowMsg("你上传的不是文本类型附件!", "-1");
  22. exit();
  23. }
  24. if (!preg_match("#\.(" . $cfg_txttype . ")#i", $uploadfile_name)) {
  25. ShowMsg("你所上传的模板文件类型不能被识别,只允许htm、html、tpl、txt扩展名!", "-1");
  26. exit();
  27. }
  28. if ($filename != '') {
  29. $filename = trim(preg_replace("#[ \r\n\t\*\%\\\/\?><\|\":]{1,}#", '', $filename));
  30. } else {
  31. $uploadfile_name = trim(preg_replace("#[ \r\n\t\*\%\\\/\?><\|\":]{1,}#", '', $uploadfile_name));
  32. $filename = $uploadfile_name;
  33. if ($filename == '' || !preg_match("#\.(" . $cfg_txttype . ")#i", $filename)) {
  34. ShowMsg("你所上传的文件存在问题,请检查文件类型是否适合!", "-1");
  35. exit();
  36. }
  37. }
  38. $fullfilename = $cfg_basedir . $activepath . "/" . $filename;
  39. move_uploaded_file($uploadfile, $fullfilename) or die("上传文件到 $fullfilename 失败!");
  40. @unlink($uploadfile);
  41. ShowMsg("成功上传文件!", "select_templets.php?comeback=" . urlencode($filename) . "&f=$f&activepath=" . urlencode($activepath) . "&d=" . time());
  42. exit();