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

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