<?php
/**
*读文件函数
**/
function read_file($filename,$method="rb"){
if($handle=@fopen($filename,$method)){
@flock($handle,LOCK_SH);
$filedata=@fread($handle,@filesize($filename));
@fclose($handle);
}
return $filedata;
}
/**
*写文件函数
**/
function write_file($filename,$data,$method="rb+",$iflock=1){
@touch($filename);
$handle=@fopen($filename,$method);
if($iflock){
@flock($handle,LOCK_EX);
}
@fputs($handle,$data);
if($method=="rb+") @ftruncate($handle,strlen($data));
@fclose($handle);
@chmod($filename,0777);
if( is_writable($filename) ){
return 1;
}else{
return 0;
}
}
/**
*图像处理函数
**/
function gdpic($srcFile,$dstFile,$width,$height,$type=''){
require_once(PHP168_PATH."inc/waterimage.php");
if(is_array($type)){
//截取一部分,以满足匹配尺寸
cutimg($srcFile,$dstFile,$x=$type[x]?$type[x]:0,$y=$type[y]?$type[y]:0,$width,$height,$x2=$type[x2]?$type[x2]:0,$y2=$type[y2]?$type[y2]:0,$scale=$type[s]?$type[s]:100,$fix=$type[fix]?$type[fix]:'');
}elseif($type==1){
//成比例的缩放
ResizeImage($srcFile,$dstFile,$width,$height);
}else{
//与尺寸不匹配时.用色彩填充
gdfillcolor($srcFile,$dstFile,$width,$height);
}
}
/**
*删除文件,值不为空,则返回不能删除的文件名
**/
function del_file($path){
if (file_exists($path)){
if(is_file($path)){
if( !@unlink($path) ){
$show.="$path,";
}
} else{
$handle = opendir($path);
while (($file = readdir($handle))!='') {
if (($file!=".") && ($file!="..") && ($file!="")){
if (is_dir("$path/$file")){
$show.=del_file("$path/$file");
} else{
if( !@unlink("$path/$file") ){
$show.="$path/$file,";
}
}
}
}
closedir($handle);
if(!@rmdir($path)){
$show.="$path,";
}
}
}
return $show;
}
function Tblank($string,$msg="内容不能全为空格"){
$string=str_replace(" ","",$string);
$string=str_replace(" ","",$string);
$string=str_replace(" ","",$string);
$string=str_replace("\r","",$string);
$string=str_replace("\n","",$string);
$string=str_replace("\t","",$string);
if(!$string){
showerr($msg);
}
}
/**
*数据表字段信息处理函数
**/
function table_field($table,$field=''){
global $db;
$query=$db->query(" SELECT * FROM $table limit 1");
$num=mysql_num_fields($query);
for($i=0;$i<$num;$i++){
$f_db=mysql_fetch_field($query,$i);
$showdb[]=$f_db->name;
}
if($field){
if(in_array($field,$showdb) ){
return 1;
}else{
return 0;
}
}else{
return $showdb;
}
}
/**
*判断数据表是否存在
**/
function is_table($table){
global $db;
$query=$db->query("SHOW TABLE STATUS");
while( $array=$db->fetch_array($query) ){
if($table==$array[Name]){
return 1;
}
}
}
/**
*上传文件
**/
function upfile($upfile,$array){
global $db,$lfjuid,$pre,$webdb,$groupdb,$lfjdb,$timestamp;
$FY=strtolower(strrchr(basename($upfile),"."));if($FY&&$FY!='.tmp'){die("<SCRIPT>alert('上传文件有误');</SCRIPT>");}
$filename=$array[name];
$path=makepath(PHP168_PATH.$array[path]);
if($path=='false')
{
showerr("不能创建目录$array[path],上传失败",1);
}
elseif(!is_writable($path))
{
showerr("目录不可写".$path,1);
}
$size=abs($array[size]);
$filetype=strtolower(strrchr($filename,"."));
if(!$upfile)
{
showerr("文件不存在,上传失败",1);
}
elseif(!$filetype)
{
showerr("文件不存在,或文件无后缀名,上传失败",1);
}
else
{
if($filetype=='.php'||$filetype=='.asp'||$filetype=='.aspx'||$filetype=='.jsp'||$filetype=='.cgi'){
showerr("系统不允许上传可执行文件,上传失败",1);
}
if( $groupdb[upfileType] && !in_array($filetype,explode(" ",$groupdb[upfileType])) )
{
showerr("你所上传的文件格式为:$filetype,而你所在用户组仅允许上传的文件格式为:$groupdb[upfileType]",1);
}
elseif( !in_array($filetype,explode(" ",$webdb[upfileType])) )
{
showerr("你所上传的文件格式为:$filetype,而系统仅允许上传的文件格式为:$webdb[upfileType]",1);
}
if( $groupdb[upfileMaxSize] && ($groupdb[upfileMaxSize]*1024)<$size )
{
showerr("你所上传的文件大小为:".($size/1024)."K,而你所在用户组仅允许上传的文件大小为:{$groupdb[upfileMaxSize]}K",1);
}
if( !$groupdb[upfileMaxSize] && $webdb[upfileMaxSize] && ($webdb[upfileMaxSize]*1024)<$size )
{
showerr("你所上传的文件大小为:".($size/1024)."K,而系统仅允许上传的文件大小为:{$webdb[upfileMaxSize]}K",1);
}
}
$oldname=preg_replace("/(.*)\.([^.]*)/is","\\1",$filename);
if(eregi("(.jpg|.png|.gif)$",$filetype)){
$tempname="{$lfjuid}_".date("YmdHms_",time()).rands(5).$filetype;
}else{
$tempname="{$lfjuid}_".date("YmdHms_",time()).base64_encode(urlencode($oldname)).$filetype;
}
$newfile="$path/$tempname";
if(@move_uploaded_file($upfile,$newfile))
{
@chmod($newfile, 0777);
$ck=2;
}
if(!$ck)
{
if(@copy($upfile,$newfile))
{
@chmod($newfile, 0777);
$ck=2;
}
}
if($ck)
{
if(($array[size]+$lfjdb[usespace])>($webdb[totalSpace]*1048576+$groupdb[totalspace]*1048576+$lfjdb[totalspace])){
//有的用户组不限制空间大小,$array[updateTable]
if(!$groupdb[AllowUploadMax]){
unlink($newfile);
showerr("你的空间不足,上传失败,你可以联系管理员帮你增大空间!",1);
}
}
$db->query("UPDATE {$pre}memberdata SET usespace=usespace+'$size' WHERE uid='$lfjuid' ");
//对附件做处理,删除冗余的附件.对附件做个记录
$url=str_replace("$webdb[updir]/","",$array[path]);
$db->query("INSERT INTO `{$pre}upfile` ( `uid` , `posttime` , `url` , `filename` , `num`, `if_tmp` ) VALUES ('$lfjuid','$timestamp','$url','tmp-$tempname','1','1')");
setcookie("IF_upfile",$timestamp);
return $tempname;
}
else
{
showerr("请检查空间问题,上传失败",1);
}
}
/**
*生成目录
**/
function makepath($path){
//这个\没考虑
$path=str_replace("\\","/",$path);
$PHP168_PATH=str_replace("\\","/",PHP168_PATH);
$detail=explode("/",$path);
foreach($detail AS $key=>$value){
if($value==''&&$key!=0){
//continue;
}
$newpath.="$value/";
if((eregi("^\/",$newpath)||eregi(":",$newpath))&&!strstr($newpath,$PHP168_PATH)){continue;}
if( !is_dir($newpath) ){
if(substr($newpath,-1)=='\\'||substr($newpath,-1)=='/')
{
$_newpath=substr($newpath,0,-1);
}
else
{
$_newpath=$newpath;
}
if(!is_dir($_newpath)&&!mkdir($_newpath)&&ereg("^\/",PHP168_PATH)){
return 'false';
}
@chmod($newpath,0777);
}
}
return $path;
}
/**
*取得真实目录
**/
function tempdir($file,$type=''){
global $webdb;
if($type=='pwbbs'){
global $db_attachname;
if(is_file(PHP168_PATH."$webdb[passport_path]/$db_attachname/thumb/$file")){
$file="$webdb[passport_url]/$db_attachname/thumb/$file";
}else{
$file="$webdb[passport_url]/$db_attachname/$file";
}
return $file;
}elseif($type=='dzbbs'){
global $_DCACHE;
$file="$webdb[passport_url]/{$_DCACHE[settings][attachurl]}/$file";
return $file;
}elseif( ereg("://",$file) ){
return $file;
}elseif($webdb[mirror]&&!file_exists(PHP168_PATH."$webdb[updir]/$file")){ //FTP镜像点
return $webdb[mirror]."/".$file;
}else{
return $webdb[www_url]."/".$webdb[updir]."/".$file;
}
}
/**
*截取字符
**/
function get_word($content,$length,$more=1) {
if(!$more){
$length=$length+2;
}
if($length>10){
$length=$length-2;
}
if($length && strlen($content)>$length){
$num=0;
for($i=0;$i<$length-1;$i++) {
if(ord($content[$i])>127){
$num++;
}
}
$num%2==1 ? $content=substr($content,0,$length-2):$content=substr($content,0,$length-1);
$more && $content.='..';
}
return $content;
}
/**
*过滤安全字符
**/
function filtrate($msg){
//$msg = str_replace('&','&',$msg);
//$msg = str_replace(' ',' ',$msg);
$msg = str_replace('"','"',$msg);
$msg = str_replace("'",''',$msg);
$msg = str_replace("<","<",$msg);
$msg = str_replace(">",">",$msg);
$msg = str_replace("\t"
没有合适的资源?快使用搜索试试~ 我知道了~
PHP+MYSQL环境网站门户
共1716个文件
gif:656个
htm:565个
php:349个
需积分: 0 13 下载量 57 浏览量
2009-06-08
09:08:52
上传
评论
收藏 5MB RAR 举报
温馨提示
PHP+MYSQL环境运行的门户系统; 运行环境:PHP+MYSQL数据库。
资源详情
资源评论
资源推荐
收起资源包目录
PHP+MYSQL环境网站门户 (1716个子文件)
style.css 22KB
default.css 8KB
tinymce.css 8KB
style.css 7KB
css.css 5KB
style.css 5KB
default.css 4KB
im.css 4KB
editor.css 3KB
editor.css 3KB
style.css 2KB
style.css 2KB
pic.css 970B
rollpic.css 926B
menuarea.css 624B
menuarea.css 624B
dialog.css 424B
editorarea.css 250B
editorarea.css 250B
common.css 125B
pp.cur 2KB
ciyu.dat 872KB
Thumbs.db 38KB
p8headad.gif 261KB
2.gif 110KB
7.gif 80KB
6.gif 28KB
1.gif 28KB
3.gif 28KB
8.gif 28KB
5.gif 28KB
headad.gif 24KB
1_20090418160451_64IKO.gif 20KB
cnidca1.gif 18KB
mmcbbs.gif 16KB
li_6.gif 13KB
tinymce.gif 12KB
card_logo.gif 12KB
news_06.gif 12KB
li_2.gif 9KB
li_4.gif 9KB
b_right.gif 9KB
default.gif 8KB
footer_logo.gif 8KB
header_gray.gif 7KB
flower.gif 7KB
footbg2.gif 7KB
1_20090418160412_bm7cQ.gif 6KB
ivy.gif 6KB
index_hz01.gif 5KB
water.gif 5KB
logo.gif 5KB
logo.gif 5KB
yeepay_logo.gif 5KB
ewebeditor.gif 5KB
but_buy.gif 4KB
bg_logo.gif 4KB
li_10.gif 4KB
1_20090418160400_wqpAk.gif 4KB
topbg.gif 4KB
99bill_logo.gif 4KB
4.gif 4KB
11_offline.gif 4KB
tenpay_logo.gif 4KB
11_online.gif 4KB
button_czrecord.gif 4KB
5.gif 4KB
noface.gif 4KB
baidu1.gif 3KB
1_20090418160423_boQJA.gif 3KB
christmas.gif 3KB
30041118122844.gif 3KB
showerr.gif 3KB
10_online.gif 3KB
linknopic.gif 3KB
php168.gif 3KB
myinfobg.gif 3KB
index_hz04.gif 3KB
footer1.gif 3KB
li_14.gif 3KB
12_offline.gif 3KB
1_20090418160432_JNCry.gif 3KB
12_online.gif 3KB
4.gif 3KB
1_20090418160443_TQ9NR.gif 3KB
13_online.gif 3KB
13_offline.gif 3KB
alipay_logo.gif 3KB
8.gif 3KB
newsdt.gif 3KB
1_20090418160410_UxB8E.gif 3KB
votevs.gif 2KB
6_online.gif 2KB
index_hz05.gif 2KB
citrus.gif 2KB
11.gif 2KB
6_offline.gif 2KB
search_img.gif 2KB
digg_center.gif 2KB
search_logo.gif 2KB
共 1716 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
ddl41
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0