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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
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)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
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

Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Laravel development: How to implement WebSockets communication using Laravel Echo and Pusher? Jun 13, 2023 pm 05:01 PM

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets

What are the most popular golang frameworks on the market? What are the most popular golang frameworks on the market? Jun 01, 2024 pm 08:05 PM

The most popular Go frameworks at present are: Gin: lightweight, high-performance web framework, simple and easy to use. Echo: A fast, highly customizable web framework that provides high-performance routing and middleware. GorillaMux: A fast and flexible multiplexer that provides advanced routing configuration options. Fiber: A performance-optimized, high-performance web framework that handles high concurrent requests. Martini: A modular web framework with object-oriented design that provides a rich feature set.

Detailed explanation of the role and usage of the echo keyword in PHP Detailed explanation of the role and usage of the echo keyword in PHP Jun 28, 2023 pm 08:12 PM

Detailed explanation of the role and usage of the echo keyword in PHP PHP is a widely used server-side scripting language, which is widely used in web development. The echo keyword is a method used to output content in PHP. This article will introduce in detail the function and use of the echo keyword. Function: The main function of the echo keyword is to output content to the browser. In web development, we need to dynamically present data to the front-end page. At this time, we can use the echo keyword to output the data to the page. e

See all articles