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