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

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