搜尋
首頁php教程php手册功能控制完备的PHP上载程序(1)

 

主控程序 upfile.php



####################################################################

#Project Name: Test

#Author : lanf

#Home Page: http://lanf.yeah.net

#E-mail:imbusy@263.net

#Time: 2001 . 9

####################################################################



##
验证身份函数

function getUserRight($username,$user){

if($username==$user' '$user=="*") return true;

echo "
您没有这个操作ID的权限。href=javascript:window.history.back()>点这里返回修改";

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 "
这个操作ID不允许上传此种类型文件。href=javascript:window.history.back()>点这里返回修改";

return false;};

};

if(strstr($fileType,$fileExtent )' '$fileType="*") return true;

echo "
这个操作ID不允许上传此种类型文件。href=javascript:window.history.back()>点这里返回修改";

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:$referIPbr>";

//}

//到这里,$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 "
错误的上传站点#16href=javascript:window.close()>点这里关闭窗口";

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 "
错误的上传站点。href=javascript:window.close()>点这里关闭窗口";

return true;

};

}else{

//
不带*号的IP

if($limit==$referIP){

return false;

}else{

echo "
错误的上传站点。href=javascript:window.close()>点这里关闭窗口";

return true;

};

};

}

};

##
上传站点验证函数结束



##
日志记录函数

function putLog($actionID,$message,$flag="a"){

if(!file_exists("./log")){

echo "
当前目录没有建立属性为0777log目录,正在尝试建立……";

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")){



陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。