|
发表于 2005 年 3 月 21 日 10:51:07
|
显示全部楼层
phpwind\require\postupload.php- <?php
- !function_exists('readover') && exit('Forbidden');
- $ifopload=0;
- $windupload='';$attt=$timestamp;
- $oldattachdb=explode("|",$winddb['attach']);
- $attachs=array();
- for($i=1;$i<=$db_attachnum+1;$i++){
- if(is_array(${'atc_attachment'.$i})){
- $atc_attachment=${'atc_attachment'.$i}['tmp_name'];
- $atc_attachment_name=${'atc_attachment'.$i}['name'];
- $atc_attachment_size=${'atc_attachment'.$i}['size'];
- }else{
- $atc_attachment=${'atc_attachment'.$i};
- $atc_attachment_name=${'atc_attachment'.$i.'_name'};
- $atc_attachment_size=${'atc_attachment'.$i.'_size'};
- }
- $needrvrc=${'atc_downrvrc'.$i};
- !is_numeric($needrvrc) && $needrvrc=0;
- if(!$atc_attachment || $atc_attachment== 'none'){
- continue;
- } elseif(function_exists('is_uploaded_file') && !is_uploaded_file($atc_attachment)){
- continue;
- } elseif(!($atc_attachment && $atc_attachment['error']!=4)){
- continue;
- }
- /*
- * 附件上传功能开关
- */
- if(!$db_allowupload){
- showmsg('upload_close');
- }
- /**
- *版块权限判断
- */
- if(($atc_attachment1||$atc_attachment2||$atc_attachment3||$atc_attachment4) && $foruminfo['allowupload'] && strpos($foruminfo['allowupload'],','.$groupid.',')===false && $windid!=$manager){
- Showmsg('upload_forum_right');
- }
- /**
- *用户组权限判断
- */
- if(($atc_attachment1||$atc_attachment2||$atc_attachment3||$atc_attachment4) && !$foruminfo['allowupload'] && $gp_allowupload==0){
- Showmsg('upload_group_right');
- }
- if ($atc_attachment_size>$db_uploadmaxsize && $windid!=$manager){
- Showmsg('upload_size_error');
- }
- $available_type = explode(' ',trim($db_uploadfiletype));
- $attach_ext = substr(strrchr($atc_attachment_name,'.'),1);
- $attach_ext=strtolower($attach_ext);
- if($attach_ext == 'php' || empty($attach_ext) || !@in_array($attach_ext,$available_type)){
- Showmsg('upload_type_error');
- }
-
- if($oldattachdb[0]<$tdtime){
- $oldattachdb[0]=$tdtime;
- $oldattachdb[1]=1;
- } else{
- if($oldattachdb[1]>=$gp_allownum){
- Showmsg('upload_num_error');
- } else{
- $oldattachdb[0]=$timestamp;
- $oldattachdb[1]++;
- }
- }
- $db->update("INSERT INTO pw_attachs(fid,hits) VALUES('$fid',0)");
- $aid=$db->insert_id();
- $fileuplodeurl=$fid.'_'.$aid.'.'.$attach_ext;//写入帖子的附件名称 为动态附件做准备[:windupload]为判断是否有附件 为下载附件次数做准备
- if($db_attachdir) {
- switch($db_attachdir) {
- case 1: $savedir = 'Fid_'.$fid; break;
- case 2: $savedir = 'Type_'.$attach_ext; break;
- case 3: $savedir = 'Mon_'.date('ym'); break;
- case 4: $savedir = 'Day_'.date('ymd'); break;
- }
- $attachdir = $attachpath.'/'.$savedir;
- if(!is_dir($attachdir)) {
- @mkdir($attachdir, 0777);
- @fclose(@fopen($attachdir.'/index.html', 'w'));
- }
- $fileuplodeurl= $savedir.'/'.$fileuplodeurl;
- }
- $source=$attachpath.'/'.$fileuplodeurl;//版块id_文件名_时间.类型
- if(function_exists("move_uploaded_file") && @move_uploaded_file($atc_attachment, $source)){
- chmod($source,0777);
- $attach_saved = TRUE;
- }elseif(@copy($atc_attachment, $source)){
- chmod($source,0777);
- $attach_saved = TRUE;
- }elseif(is_readable($atc_attachment) && $attcontent=readover($atc_attachment)){
- $attach_saved = TRUE;
- writeover($source,$attcontent);
- chmod($source,0777);
- }
- if(empty($attach_saved)){
- $db->update("DELETE FROM pw_attachs WHERE aid='$aid'");
- Showmsg('upload_error');
- }
- if (eregi("\.(gif|jpg|png|bmp|swf)$",$atc_attachment_name) && function_exists('getimagesize') && !getimagesize($source)){
- @unlink($source);
- $db->update("DELETE FROM pw_attachs WHERE aid='$aid'");
- Showmsg('upload_content_error');
- }
- if (eregi("\.(gif|jpg|jpeg|png|bmp|swf)$",$atc_attachment_name)){
- $ifupload=1;
- if(eregi("\.swf$",$atc_attachment_name)){
- $type='zip';
- }else{
- $type='img';
- }
- } elseif(eregi("\.(zip|rar)$",$atc_attachment_name)){
- $ifupload=3;
- $type='zip';
- } elseif(eregi("\.txt$",$atc_attachment_name)){
- $safecheckdb=readover($source);
- if (strpos($safecheckdb,"onload")!==false && strpos($safecheckdb,"submit")!==false && strpos($safecheckdb,"post")!==false && strpos($safecheckdb,"form")!==false){
- @unlink($source);
- $db->update("DELETE FROM pw_attachs WHERE aid='$aid'");
- Showmsg('upload_content_error');
- } else{
- $ifupload=2;
- $type='txt';
- }
- } else{
- $ifupload=3;
- $type='zip';
- }
-
- $size=ceil(filesize("$attachpath/$fileuplodeurl")/1024);
- $attachs[$aid]=array('aid'=>$aid,'name'=>stripslashes($atc_attachment_name),'type'=>$type,'attachurl'=>$fileuplodeurl,'needrvrc'=>$needrvrc,'size'=>$size,'hits'=>0);
- $atc_attachment_name=addslashes($atc_attachment_name);
- $db->update("UPDATE pw_attachs SET name='$atc_attachment_name',type='$type',size='$size',attachurl='$fileuplodeurl',needrvrc='$needrvrc' WHERE aid='$aid'");
- }
- $winddb['attach']=$oldattachdb[0]."|".$oldattachdb[1];
- $attachs=$attachs ? addslashes(serialize($attachs)):'';
- ?>
复制代码 |
|