Home php教程 php手册 功能控制完备的PHP上载程序(1)

功能控制完备的PHP上载程序(1)

Jun 21, 2016 am 09:02 AM
echo gt lt return

 

主控程序 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")){



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Detailed explanation of the usage of return in C language Detailed explanation of the usage of return in C language Oct 07, 2023 am 10:58 AM

The usage of return in C language is: 1. For functions whose return value type is void, you can use the return statement to end the execution of the function early; 2. For functions whose return value type is not void, the function of the return statement is to end the execution of the function. The result is returned to the caller; 3. End the execution of the function early. Inside the function, we can use the return statement to end the execution of the function early, even if the function does not return a value.

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

What is the execution order of return and finally statements in Java? What is the execution order of return and finally statements in Java? Apr 25, 2023 pm 07:55 PM

Source code: publicclassReturnFinallyDemo{publicstaticvoidmain(String[]args){System.out.println(case1());}publicstaticintcase1(){intx;try{x=1;returnx;}finally{x=3;}}}#Output The output of the above code can simply conclude: return is executed before finally. Let's take a look at what happens at the bytecode level. The following intercepts part of the bytecode of the case1 method, and compares the source code to annotate the meaning of each instruction in

Five selected Go language open source projects to take you to explore the technology world Five selected Go language open source projects to take you to explore the technology world Jan 30, 2024 am 09:08 AM

In today's era of rapid technological development, programming languages ​​are springing up like mushrooms after a rain. One of the languages ​​that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Go language development essentials: 5 popular framework recommendations Go language development essentials: 5 popular framework recommendations Mar 24, 2024 pm 01:15 PM

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

Implementing distributed task scheduling using Golang's web framework Echo framework Implementing distributed task scheduling using Golang's web framework Echo framework Jun 24, 2023 am 11:49 AM

With the development of the Internet and the advancement of information technology, the era of big data has arrived, and fields such as data analysis and machine learning have also been widely used. In these fields, task scheduling is an inevitable problem. How to achieve efficient task scheduling is crucial to improving efficiency. In this article, we will introduce how to use Golang's web framework Echo framework to implement distributed task scheduling. 1. Introduction to the Echo framework Echo is a high-performance, scalable, lightweight GoWeb framework. It is based on HTTP

See all articles