e/class/filefun.php

26
'请选择要删除的文件',*/
	if(!$fileid)
	{printerror("NotFileid","history.go(-1)");}
	//操作权限
	CheckLevel($userid,$username,$classid,"file");

	//获得此文件数据信息 提供给②③操作内容
	$r=$empire->fetch1("select filename,path,classid,fpath from {$dbtbpre}enewsfile where fileid='$fileid' limit 1");

	//①删除数据库中对于此文件的记录
	$sql=$empire->query("delete from {$dbtbpre}enewsfile where fileid='$fileid'");

	//②DoDelFi() 自定义函数用于删除文件 /e/class/connect.php
	DoDelFile($r);
	if($sql)
	{
		//③操作日志 插入管理员操作记录 e/class/functions.php
		insert_dolog("fileid=".$fileid."filename=".$r[filename]);

		//打印信息 'DelFileSuccess'=>'删除文件成功',  $_SERVER['HTTP_REFERER']; 地址来源
		printerror("DelFileSuccess",$_SERVER['HTTP_REFERER']);
    }
	else //SQL执行返回FLASE 'DbError'=>'数据库出错',
	{
		printerror("DbError","history.go(-1)");
    }
}

//批量删除文件
function DelFile_all($fileid,$userid,$username){
	global $empire,$dbtbpre,$class_r;
	//操作权限

	//如果 POST方式提交 表单中enews值为TDelFile_all 执行{}
	if($_POST['enews']=='TDelFile_all')
	{
		$userid=(int)$userid;

		//获得用户文件操作权限
		$ur=$empire->fetch1("select groupid,adminclass,filelevel from {$dbtbpre}enewsuser where userid='$userid' limit 1");

		/*
		  如取得栏目应用于附件权限为真 也就是值为1 执行{}
		  具体参考数据表参考手册 phome_enewsuser

http://bbs.phome.net/showthread-42-109320-0.html

		  此if{}内容为权限验证暂标记为①
		*/
		if($ur['filelevel'])
		{
			//取得此用户所在组dofile字段内容
			$gr=$empire->fetch1("select dofile from {$dbtbpre}enewsgroup where groupid='$ur[groupid]'");

			/*
			取得dofile不为假/0的情况下执行{}
			具体参考数据表参考手册 phome_enewsgroup

http://bbs.phome.net/showthread-42-109320-0.html

			*/
			if(!$gr['dofile'])
			{
				$classid=(int)$_POST['classid'];
				$searchclassid=(int)$_POST['searchclassid'];

				/*
				三目运算
				$searchclassid为空/假/0的时候 $classid=$classid
				其他情况$classid=$searchclassid
				*/
				$classid=$searchclassid?$searchclassid:$classid;
				if(!$class_r[$classid]['classid'])
				{
					printerror("NotLevel","history.go(-1)");
				}
				/*
				phome_enewsuser adminclass记录用户栏目操作权限
				具体参考手册:http://bbs.phome.net/showthread-42-109320-0.html
				strstr() PHP自带函数 检查参数2在参数1中出现位置 ,这里是利用此函数返回真假判断是否有权限
				*/
				if(!strstr($ur['adminclass'],'|'.$classid.'|'))
				{
					printerror("NotLevel","history.go(-1)");
				}
			}
		}/*到此①结束 没有环节的printerror()中 exit(); 作用不会将没有权限的操作执行到这里*/
		else
		{
			CheckLevel($userid,$username,$classid,"file");
		}
	}
	else
	{
		CheckLevel($userid,$username,$classid,"file");
	}
	/*以上权限验证都结束了 CheckLevel()中也同样有printerror() 提示信息和终止向下执行 一下是删除文件及其记录日志*/

	/*此处count()检查数组中元素个数,对于数组返回元素个数,其他值返回1*/
	$count=count($fileid);

	//如检测到0个 'NotFileid'=>'请选择要删除的文件',
	if(!$count)
	{printerror("NotFileid","history.go(-1)");}

	//使用FOR循环删除附件
	for($i=0;$ifetch1("select filename,path,classid,fpath from {$dbtbpre}enewsfile where fileid='$fileid[$i]' limit 1");
		$sql=$empire->query("delete from {$dbtbpre}enewsfile where fileid='$fileid[$i]'");
		DoDelFile($r);
    }
	if($sql)
	{
		//操作日志 {$doing="---";} 具体看操作/e/class/functions.php
		insert_dolog("");
		printerror("DelFileAllSuccess",$_SERVER['HTTP_REFERER']);
    }
	else
	{
		printerror("DbError","history.go(-1)");
    }
}

//删除多余附件 参考上边的内容
function DelFreeFile($userid,$username){
	global $empire,$dbtbpre;
	//操作权限
	CheckLevel($userid,$username,$classid,"file");
	$sql=$empire->query("select filename,path,classid,fpath from {$dbtbpre}enewsfile where cjid<>0 and (id=0 or cjid=id)");
	while($r=$empire->fetch($sql))
	{
       DoDelFile($r);
    }
	$delsql=$empire->query("delete from {$dbtbpre}enewsfile where cjid<>0 and (id=0 or cjid=id)");
	if($sql)
	{
		//操作日志
		insert_dolog("");
		printerror("DelFreeFileSuccess",$_SERVER['HTTP_REFERER']);
    }
	else
	{
		printerror("DbError","history.go(-1)");
    }
}

//删除目录文件
function DelPathFile($filename,$userid,$username){
	global $empire,$dbtbpre;
	//操作权限
	CheckLevel($userid,$username,$classid,"file");
	$count=count($filename);
	if(empty($count))
	{
		printerror("NotFileid","history.go(-1)");
	}
	//基目录
	$basepath="../../d/file";
	for($i=0;$i<$count;$i++)
	{
		if(strstr($filename[$i],".."))
		{
			continue;
	    }
		DelFiletext($basepath."/".$filename[$i]);
		$dfile=ReturnPathFile($filename[$i]);
		$sql=$empire->query("delete from {$dbtbpre}enewsfile where filename='$dfile'");
    }
	//操作日志
	insert_dolog("");
	printerror("DelFileSuccess",$_SERVER['HTTP_REFERER']);
}

//批量加水印/缩略图
function DoMarkSmallPic($add,$userid,$username){
	global $empire,$class_r,$dbtbpre;
	//导入gd处理文件
	if($add['getsmall']||$add['getmark'])
	{
		@include(ECMS_PATH."e/class/gd.php");
	}
	else
	{
		printerror("EmptyDopicFileid","history.go(-1)");
	}
	$fileid=$add['fileid'];
	$count=count($fileid);
	if($count==0)
	{
		printerror("EmptyDopicFileid","history.go(-1)");
	}
	for($i=0;$i<$count;$i++)
	{
		$fileid[$i]=intval($fileid[$i]);
		$r=$empire->fetch1("select classid,filename,path,no,fpath from {$dbtbpre}enewsfile where fileid='$fileid[$i]'");
		$rpath=$r['path']?$r['path'].'/':$r['path'];
		$fspath=ReturnFileSavePath($r[classid],$r[fpath]);
		$path="../../".$fspath['filepath'].$rpath;
		$yname=$path.$r[filename];
		//缩略图
		if($add['getsmall'])
		{
			$filetype=GetFiletype($r[filename]);
			$insertfile=substr($r[filename],0,strlen($r[filename])-strlen($filetype));
			$name=$path."small".$insertfile;
			GetMySmallImg($add['classid'],$r[no],$insertfile,$r[path],$yname,$add[width],$add[height],$name,$add['filepass'],$add['filepass'],$userid,$username);
		}
		//水印
		if($add['getmark'])
		{
			GetMyMarkImg($yname);
		}
	}
	printerror("DoMarkSmallPicSuccess",$_SERVER['HTTP_REFERER']);
}

//上传多附件
function TranMoreFile($file,$file_name,$file_type,$file_size,$no,$type,$userid,$username){
	global $empire,$public_r,$dbtbpre;
	$count=count($file_name);
	if(empty($count))
	{
		printerror("MustChangeTranOneFile","history.go(-1)");
    }
	//操作权限
	CheckLevel($userid,$username,$classid,"file");
	$type=(int)$type;

	/*

	*/
	for($i=0;$i<$count;$i++)
	{
		if(empty($file_name[$i]))
		{
			continue;
		}
		//取得文件类型
		$filetype=GetFiletype($file_name[$i]);
		//如果是.php文件
		if(CheckSaveTranFiletype($filetype))
		{continue;}
	    $type_r=explode("|".$filetype."|",$public_r['filetype']);
	    if(count($type_r)<2)
		{continue;}
		if($file_size[$i]>$public_r['filesize']*1024)
		{continue;}
		//上传 DTranFile() /e/class/connect.php
		$r=DoTranFile($file[$i],$file_name[$i],$file_type[$i],$file_size[$i],$classid);
		//写入数据库
		$r[filesize]=(int)$r[filesize];
		$classid=(int)$classid;
		$filetime=date("Y-m-d H:i:s");

		//没附件编号就是用附件名称作为附件编号
		if(empty($no[$i]))
		{$no[$i]=$r[filename];}

		//附件信息写入数据库
		//数据库手册参考 phome_enewsfile 附件管理数据记录表
		//http://bbs.phome.net/showthread-42-109320-0.html
		$sql=$empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,onclick,id,cjid,fpath) values('$r[filename]',$r[filesize],'$username','$r[filepath]','$filetime',$classid,'$no[$i]',$type,0,0,0,'$public_r[fpath]');");
	}
	insert_dolog("");//操作日志
	printerror("TranMoreFileSuccess","file/TranMoreFile.php");
}
?>

密码保护:【不同会员组不同购买价格说明文档 trylife@20091024】

24 要查看留言请输入您的密码。

这是一篇受密码保护的文章。您需要提供访问密码:


e/class/copypath.php 用于创建和复制目录

24
wm_chief_createpath($n_path);
                }

                $i=0;
                while($file=@readdir($hand)){
                        $i++;
                        if ($file!="."&&$file!=".."){

                                //目录
                                if(is_dir($o_path."/".$file)){
                                        $o_s_path=$o_path."/".$file;
                                        $n_s_path=$n_path."/".$file;
                                        $this->wm_chief_copypath($o_s_path,$n_s_path);
                                }
                                else{
                                        $o_file=$o_path."/".$file;
                                        $n_file=$n_path."/".$file;
                                        $this->wm_chief_copyfile($o_file,$n_file);
                                }
                        }
                }

                @closedir($hand);
                return  true;
        }

        /*copy() PHP自带函数用于拷贝文件*/
        function  wm_chief_copyfile($o_file,$n_file){
                @copy($o_file,$n_file);
        }
        /*
        mkdir() PHP自带函数用于创建目录
        chmod() PHP自带函数用于改改读写权限 貌似是mkdir()创建完目录权限不一定落实 所以补了个chmod()
        */
        function  wm_chief_createpath($n_path){
                @mkdir($n_path,0777);
                @chmod($n_path,0777);
        }
}
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
?>

/e/class/CheckClassLevel.php 栏目前台查看权限检测文件

24

下面是正常HTML网页代码内容
---------------------------------------------------------------------------------------

*/

/*
1.defined() 函数检查某常量是否存在;
2.exit();执行后下面的代码将不再执行
3.引用此文件的动态页面不能被其他程序所引用
*/
if(!defined('empirecms'))
{
        exit();
}
//扣点
require_once($check_path."e/class/connect.php");

/*同上defined*/
if(!defined('InEmpireCMS'))
{
        exit();
}
require_once(ECMS_PATH."e/class/db_sql.php");
require_once(ECMS_PATH."e/class/user.php");
require_once(ECMS_PATH.'e/data/dbcache/MemberLevel.php');

/*
所要看的栏目ID
需要的最低用户组ID
设置需要权限的动态页面直接传参得到
*/
$check_classid=(int)$check_classid;
$check_groupid=(int)$check_groupid;

/*
1.返回页面地址
2.$_SERVER['PHP_SELF'] 得到当前执行脚本的绝路径文件名
3.例如:http://www.phome.net/some/text.php 会得到/some/text.php
*/
$toreturnurl=$_SERVER['PHP_SELF'];        

/*
$eloginurl 登陆地址
/e/class/user.php
*/
$gotourl=$eloginurl?$eloginurl:$public_r['newsurl']."e/member/login/";        //登陆地址

/*
1.getcvar() 自定义函数用于取得登陆信息
2.定义:e/class/connect.php
3.getcvar('mluserid')登陆ID
4.getcvar('mlgroupid')登陆用户组ID
*/
$loginuserid=(int)getcvar('mluserid');
$logingroupid=(int)getcvar('mlgroupid'); 

/*
1.printerror2()函数定义在/e/class/connect.php
2.用于直接打印提示信息
3.如果登录ID为FLASE 也就是说用户没有登录
3.$level_r 读取缓存文件中数组/e/data/dbcache/MemberLevel.php

*/
if(!$loginuserid)
{
        printerror2("本栏目需要 ".$level_r[$check_groupid][groupname]." 会员级别以上才能查看","");
}
if($level_r[$logingroupid][level]<$level_r[$check_groupid][level])
{
        printerror2("本栏目需要 ".$level_r[$check_groupid][groupname]." 会员级别以上才能查看","");
}
?>

/e/class/delpath.php

24

用于删除文件目录
应该是老大很早以前写的类了 版权上下都有
用于删除目录和文件
包含一个类3个方法
wm_chief_delpath()
wm_chief_file()
wm_chief_path()

如果目录中有目录就返回重新读新发现的目录 目录中的文件 然后删除目录,如此循环 目录和文件全删了

wm_chief_delpath($del_s_path);
                                }

                                /*其他情况 也就是不是目录的情况即为文件的情况 执行大括号中内容*/
                                else{
                                        $del_file=$del_path."/".$file;

                                        /* 使用本类中 wm_chief_file处理$del_file*/
                                        $this->wm_chief_file($del_file);
                                }
                        }
                }//while循环结束

                /*关闭*/
                @closedir($hand);

                /*使用本类中的 wm_chief_path函数处理*/
                $this->wm_chief_path($del_path);

                /**/
                return  true;
        }

        // unlink() PHP自由函数,用于删除文件:若成功,则返回 true,失败则返回 false。
        function  wm_chief_file($del_file){
                @unlink($del_file);
        }

        //删除目录 rmdir() 函数删除空的目录。若成功,则该函数返回 true。若失败,则返回 false。
        function  wm_chief_path($del_path){
                @rmdir($del_path);
        }
}

//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
?>