■主控程序 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 "<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")){xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器