TruePathfileFun.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. //上传固定目录文件
  3. function TranTruePathFile($level,$path,$file,$file_name,$file_type,$file_size,$add,$userid,$username){
  4. global $empire,$dbtbpre,$public_r;
  5. if(!$file_name)
  6. {
  7. printerror("EmptyTranFile","history.go(-1)");
  8. }
  9. $r['filetype']=GetFiletype($file_name);//取得文件类型
  10. //如果是.php文件
  11. if(CheckSaveTranFiletype($r['filetype']))
  12. {
  13. printerror("TranPHP","history.go(-1)");
  14. }
  15. $type_r=explode("|".$r['filetype']."|",$public_r['filetype']);
  16. if(count($type_r)<2)
  17. {
  18. printerror("TranFiletypeFail","history.go(-1)");
  19. }
  20. if($file_size>$public_r['filesize']*1024)
  21. {
  22. printerror("TranFilesizeFail","history.go(-1)");
  23. }
  24. //文件名
  25. $r['insertfile']=ReturnDoTranFilename($file_name,$classid);
  26. $r['filename']=$r['insertfile'].$r['filetype'];
  27. $r['name']=ECMS_PATH.$path.'/'.$r['filename'];
  28. $r['tran']=1;
  29. //上传文件
  30. $cp=@move_uploaded_file($file,$r['name']);
  31. if(empty($cp))
  32. {
  33. $r['tran']=0;
  34. printerror('TranFail','');
  35. }
  36. DoChmodFile($r['name']);
  37. //操作日志
  38. insert_dolog("path=$path<br>filename=".$r['filename']);
  39. echo'<meta http-equiv="refresh" content="0;url='.EcmsGetReturnUrl().'">';
  40. db_close();
  41. $empire=null;
  42. }
  43. //删除固定目录文件
  44. function DelTruePathFile($level,$path,$filename,$userid,$username){
  45. global $empire,$dbtbpre,$public_r;
  46. $count=count($filename);
  47. if(empty($count))
  48. {
  49. printerror("NotFileid","history.go(-1)");
  50. }
  51. //基目录
  52. $basepath=ECMS_PATH.$path;
  53. for($i=0;$i<$count;$i++)
  54. {
  55. if(!$filename[$i]||!eReturnCkCFile($filename[$i]))
  56. {
  57. continue;
  58. }
  59. DelFiletext($basepath."/".$filename[$i]);
  60. }
  61. //操作日志
  62. insert_dolog("path=$path");
  63. printerror("DelFileSuccess",EcmsGetReturnUrl());
  64. }
  65. ?>