■主控程序 upfile.php
<?
####################################################################
#project name: test
#author : lanf
#home page: http://lanf.yeah.net
#e-mail:[email protected]
#time: 2001 . 9
####################################################################
##驗證身份函數
function getuserright($username,$user){
if($username==$user' '$user=="*") return true;
echo "<html>您沒有這個操作id的權限。<a href=javascript:window.history.back()>點這里返回修改</a></html>";
return false;
}
##驗證身份函數結束
##文件類型驗證函數
function getfiletype($filename,$filetype){
$fileextent=strrchr($filename, ".");$fileextent=substr($fileextent,1);
$fileextent=strtolower($fileextent);$filetype=strtolower($filetype);
if(strstr($filetype,"jpg")|| strstr($filetype,"gif")' 'strstr($filetype,"png") ){
if(!getimagesize($imgfile)) {
echo "<html>這個操作id不允許上傳此種類型文件。<a href=javascript:window.history.back()>點這里返回修改</a></html>";
return false;};
};
if(strstr($filetype,$fileextent )' '$filetype="*") return true;
echo "<html>這個操作id不允許上傳此種類型文件。<a href=javascript:window.history.back()>點這里返回修改</a></html>";
return false;
}
##文件類型驗證函數結束
##上傳站點驗證函數
function checkfromsiteerr($sitefrom,$limitsite){
//取得站點域名的ip地址;http://202.108.240.75 www.yyy.com
//echo $sitefrom;
$step1=substr($sitefrom,7);//echo "<br>$step1";
$step2=strpos($step1, "/");//echo "<br>$step2";
$step3=substr($step1,0,$step2);//echo "<br>$step3";
//if(eregi("^[0-9]+.[0-9]+.[0-9]+.[0-9]+$",$step3)){;}else{
$referip=gethostbyname($step3);//echo "<br>ip:$referip<br>";
//}
//到這里,$referip已經是一個上一個頁面的ip地址。
//匹配相關的內容。
if(strpos($limitsite,",",1)){
//說明是一組值
$pieces = explode(",",$limitsite);
while(list($key,$value) = each($pieces)){
$limit=gethostbyname($value);
if($starpos=strpos($limit,"*")){
//帶*號的ip
$templimit=substr($limit,0,$starpos);
$tempfromip=substr($referip,0,$starpos);
if($templimit==$tempfromip){
return false;
}else{
continue;
};
}else{
//不帶*號的ip
if($limit==$referip){
return false;
}else{
continue;
};
};
}
echo "<html>錯誤的上傳站點#16。<a href=javascript:window.close()>點這里關閉窗口</a></html>";
return true;
}else{
//說明只有一個限制
$limit=gethostbyname($limitsite);
if($starpos=strpos($limit,"*")){
//帶*號的ip
$templimit=substr($limit,0,$starpos);
$tempfromip=substr($referip,0,$starpos);
if($templimit==$tempfromip){
return false;
}else{
echo "<html>錯誤的上傳站點。<a href=javascript:window.close()>點這里關閉窗口</a></html>";
return true;
};
}else{
//不帶*號的ip
if($limit==$referip){
return false;
}else{
echo "<html>錯誤的上傳站點。<a href=javascript:window.close()>點這里關閉窗口</a></html>";
return true;
};
};
}
};
##上傳站點驗證函數結束
##日志記錄函數
function putlog($actionid,$message,$flag="a"){
if(!file_exists("./log")){
echo "當前目錄沒有建立屬性為0777的log目錄,正在嘗試建立……";
if(@mkdir("./log",0777)){echo "建立成功!??!";}else{echo "失??!權限不足,請手動建立 ./log 。<br> 日志沒有被記錄……"; return false;}
}
$logfile="./log/".$actionid.$flag.".log";
$cmdstr="echo "".$message."" >> ".$logfile;
if (!file_exists($logfile)) {passthru("touch ".$logfile); chmod($logfile,0777);}
passthru($cmdstr);
return true;
};
##日志記錄函數
##取配置文件參數函數
function get_config($conf,$actionid="",$actiontype=""){
//$conf 配置文件名,$actionid 操作id ,$actiontype 操作類型
global $targetdir,$user,$maxlength,$filetype,$checkfile,$limitsite,$callback;
$actionid=trim($actionid);
if($actionid=="") return false;
$keylength=strlen($actionid);
$filearray=file($conf);
$canshuzoneid=0;
if($actiontype=="upload"){
//假如是上傳文件的話
while (list($key,$value) = each($filearray)) {
$value=trim($value);
//判斷參數區域,將參數提取限制在上傳文件設置區
$zone_temp=substr($value,0,1);
if($zone_temp=="["){//開始一個參數區域
if(strstr($value, "up")){
新聞熱點
疑難解答