Main control Program 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
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
return false;
};
if (Strstr ($fileType, $fileExtent) ' $fileType = ' * ') return true;
echo
return false;
}
# #文件类型验证函数结束
# #上传站点验证函数
function Checkfromsiteerr ($siteFrom, $limitSite) {
Gets the IP address of the site domain name; http://202.108.240.75 www.yyy.com
Echo $siteFrom;
$step 1=substr ($siteFrom, 7);//echo "<br> $step 1";
$step 2=strpos ($step 1, "/");//echo "<br> $step 2";
$step 3=substr ($step 1,0, $step 2);//echo "<br> $step 3";
if (eregi ("^[0-9]+.[ 0-9]+. [0-9]+. [0-9]+$, $step 3)) {;} else{
$referIP =gethostbyname ($step 3);//echo "<br>ip: $referIP <br>";
//}
Here, $referIP is already the IP address of a previous page.
Match the relevant content.
if (Strpos ($limitSite, ",", 1)) {
Description is a set of values
$pieces = Explode (",", $limitSite);
while (the list ($key, $value) = each ($pieces)) {
$limit =gethostbyname ($value);
if ($starPos =strpos ($limit, "*")) {
IP with * number
$tempLimit =substr ($limit, 0, $starPos);
$tempFromIP =substr ($referIP, 0, $starPos);
if ($tempLimit = = $tempFromIP) {
return false;
}else{
Continue
};
}else{
With no * number of IP
if ($limit = = $referIP) {
return false;
}else{
Continue
};
};
}
echo "
return true;
}else{
Indicates that there is only one limit
$limit =gethostbyname ($limitSite);
if ($starPos =strpos ($limit, "*")) {
IP with * number
$tempLimit =substr ($limit, 0, $starPos);
$tempFromIP =substr ($referIP, 0, $starPos);
if ($tempLimit = = $tempFromIP) {
return false;
}else{
echo "
return true;
};
}else{
With no * number of IP
if ($limit = = $referIP) {
return false;
}else{
echo "
return true;
};
};
}
};
# #上传站点验证函数结束
# #日志记录函数
function Putlog ($actionID, $message, $flag = "a") {
if (!file_exists ("./log")) {
echo "The current directory does not have an attribute of 0777 log directory, is trying to establish ...";
if (@mkdir ("./log", 0777)) {ECHO builds successfully!!! ";} Else{echo "Failure!" Insufficient permissions, please manually establish./log. <br> log has not been recorded ... "; 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 profile name, $actionID action ID, $actionType action type
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") {
If it's an uploaded file,
while (the list ($key, $value) = each ($fileArray)) {
$value =trim ($value);
Determine the parameter area and restrict the parameter extraction to the upload file Settings area
$Zone _temp=substr ($value, 0, 1);
if ($Zone _temp== "[") {//start a parameter area
if (Strstr ($value, "up")) { -->