123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497 |
- <?php
- //新用户投稿验证
- function qCheckNewMemberAddInfo($registertime){
- global $public_r;
- if(empty($public_r['newaddinfotime']))
- {
- return '';
- }
- $registertime=eReturnMemberIntRegtime($registertime);
- if(time()-$registertime<=$public_r['newaddinfotime']*60)
- {
- printerror('NewMemberAddInfoError','',1);
- }
- }
- //验证同一IP发信息数
- function eCheckIpAddInfoNum($ip,$tbname,$mid,$checked=1){
- global $empire,$dbtbpre,$public_r,$emod_r;
- if(!$public_r['ipaddinfonum']||!$public_r['ipaddinfotime'])
- {
- return '';
- }
- //是否有IP字段
- $qenterf=$emod_r[$mid]['qenter'];
- if(!strstr($qenterf,',infoip,'))
- {
- return '';
- }
- $infotb=ReturnInfoMainTbname($tbname,$checked);
- //时间
- $cktime=time()-$public_r['ipaddinfotime']*3600;
- $num=$empire->gettotal("select count(*) as total from ".$infotb." where newstime>$cktime and infoip='$ip'");
- if($num+1>$public_r['ipaddinfonum'])
- {
- printerror('IpMaxAddInfo','history.go(-1)',1);
- }
- }
- //一个会员单信息
- function qCheckMemberOneInfo($tbname,$mid,$classid,$userid){
- global $empire,$dbtbpre,$class_r;
- $classid=(int)$classid;
- $userid=(int)$userid;
- if(empty($class_r[$classid]['oneinfo']))
- {
- return '';
- }
- $GLOBALS['classqoneinfo']=$class_r[$classid]['oneinfo'];
- //表
- $num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$tbname." where userid='$userid' and ismember=1 and classid='$classid'");
- if($num>=$class_r[$classid]['oneinfo'])
- {
- printerror('OneInfoAddInfo','history.go(-1)',1);
- }
- //审核表
- $cknum=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$tbname."_check where userid='$userid' and ismember=1 and classid='$classid'");
- $allnum=$num+$cknum;
- if($allnum>=$class_r[$classid]['oneinfo'])
- {
- printerror('OneInfoAddInfo','history.go(-1)',1);
- }
- }
- //屏蔽字符
- function qCheckInfoCloseWord($mid,$add,$closewordsf,$closewords){
- if(empty($closewordsf)||$closewordsf=='|'||empty($closewords)||$closewords=='|')
- {
- return '';
- }
- $fr=explode('|',$closewordsf);
- $count=count($fr);
- $r=explode('|',$closewords);
- $countr=count($r);
- for($i=0;$i<$count;$i++)
- {
- if(empty($fr[$i]))
- {
- continue;
- }
- for($j=0;$j<$countr;$j++)
- {
- if($r[$j])
- {
- if(stristr($r[$j],'##'))//多字
- {
- $morer=explode('##',$r[$j]);
- if(stristr($add[$fr[$i]],$morer[0])&&stristr($add[$fr[$i]],$morer[1]))
- {
- printerror("HaveCloseWords","history.go(-1)",1);
- }
- }
- else
- {
- if(stristr($add[$fr[$i]],$r[$j]))
- {
- printerror("HaveCloseWords","history.go(-1)",1);
- }
- }
- }
- }
- }
- }
- //提交字段值的处理
- function DoqValue($mid,$f,$val){
- global $public_r,$emod_r;
- $val=RepPhpAspJspcodeText($val);
- if(strstr($emod_r[$mid]['editorf'],','.$f.','))//编辑器
- {
- $val=ClearNewsBadCode($val);
- }
- else
- {
- $val=doehtmlstr($val);//替换html
- if(!strstr($emod_r[$mid]['tobrf'],','.$f.',')&&strstr($emod_r[$mid]['dohtmlf'],','.$f.','))//加回车
- {
- $val=doebrstr($val);
- }
- }
- return $val;
- }
- //返回字段值的处理
- function DoReqValue($mid,$f,$val){
- global $public_r,$emod_r;
- if($emod_r[$mid]['savetxtf']&&$emod_r[$mid]['savetxtf']==$f)//存文本
- {
- $val=stripSlashes(GetTxtFieldText($val));
- }
- if(strstr($emod_r[$mid]['editorf'],','.$f.','))//编辑器
- {
- return $val;
- }
- $val=dorehtmlstr($val);//替换html
- if(!strstr($emod_r[$mid]['tobrf'],','.$f.',')&&strstr($emod_r[$mid]['dohtmlf'],','.$f.','))//加回车
- {
- $val=dorebrstr($val);
- }
- return $val;
- }
- //替换html代码
- function doehtmlstr($str){
- $str=ehtmlspecialchars($str,ENT_QUOTES);
- return $str;
- }
- //还原html代码
- function dorehtmlstr($str){
- return $str;
- }
- //替换回车
- function doebrstr($str){
- $str=str_replace("\n","<br />",$str);
- return $str;
- }
- //还原回车
- function dorebrstr($str){
- $str=str_replace("<br />","\n",$str);
- $str=str_replace("<br>","\n",$str);
- return $str;
- }
- //投稿生成内容页面
- function qAddGetHtml($classid,$id){
- $titleurl=DoGetHtml($classid,$id);
- return $titleurl;
- }
- //投稿生成页面
- function qAddListHtml($classid,$mid,$qaddlist,$listdt){
- global $class_r;
- if($qaddlist==0)//不生成
- {
- return "";
- }
- elseif($qaddlist==1)//生成当前栏目
- {
- if(!$listdt)
- {
- $sonclass="|".$classid."|";
- QReClassHtml($sonclass);
- }
- }
- elseif($qaddlist==2)//生成首页
- {
- QReIndex();
- }
- elseif($qaddlist==3)//生成父栏目
- {
- $featherclass=$class_r[$classid]['featherclass'];
- if($featherclass&&$featherclass!="|")
- {
- QReClassHtml($featherclass);
- }
- }
- elseif($qaddlist==4)//生成当前栏目与父栏目
- {
- $featherclass=$class_r[$classid]['featherclass'];
- if(empty($featherclass))
- {
- $featherclass="|";
- }
- if(!$listdt)
- {
- $featherclass.=$classid."|";
- }
- QReClassHtml($featherclass);
- }
- elseif($qaddlist==5)//生成父栏目与首页
- {
- QReIndex();
- $featherclass=$class_r[$classid]['featherclass'];
- if($featherclass&&$featherclass!="|")
- {
- QReClassHtml($featherclass);
- }
- }
- elseif($qaddlist==6)//生成当前栏目、父栏目与首页
- {
- QReIndex();
- $featherclass=$class_r[$classid]['featherclass'];
- if(empty($featherclass))
- {
- $featherclass="|";
- }
- if(!$listdt)
- {
- $featherclass.=$classid."|";
- }
- QReClassHtml($featherclass);
- }
- }
- //投稿生成栏目
- function QReClassHtml($sonclass){
- global $empire,$dbtbpre,$class_r;
- $r=explode("|",$sonclass);
- $count=count($r);
- for($i=1;$i<$count-1;$i++)
- {
- //终极栏目
- if($class_r[$r[$i]]['islast'])
- {
- if(!$class_r[$r[$i]]['listdt'])
- {
- ListHtml($r[$i],'',0,$userlistr);
- }
- }
- elseif($class_r[$r[$i]]['islist']==1)//列表式父栏目
- {
- if(!$class_r[$r[$i]]['listdt'])
- {
- ListHtml($r[$i],'',3);
- }
- }
- elseif($class_r[$r[$i]]['islist']==3)//栏目绑定信息式
- {
- ReClassBdInfo($r[$i]);
- }
- else//父栏目
- {
- $cr=$empire->fetch1("select classtempid from {$dbtbpre}enewsclass where classid='$r[$i]'");
- $classtemp=$class_r[$r[$i]]['islist']==2?GetClassText($r[$i]):GetClassTemp($cr['classtempid']);
- NewsBq($r[$i],$classtemp,0,0);
- }
- }
- }
- //投稿生成首页
- function QReIndex(){
- $indextemp=GetIndextemp();
- NewsBq($classid,$indextemp,1,0);
- }
- //验证权限
- function CheckQdoinfo($classid,$id,$userid,$tbname,$adminqinfo,$ecms=0){
- global $empire,$dbtbpre,$emod_r,$class_r;
- //索引表
- $index_r=$empire->fetch1("select id,classid,checked from {$dbtbpre}ecms_".$tbname."_index where id='$id' limit 1");
- if(!$index_r['id']||$index_r['classid']!=$classid)
- {
- printerror("HaveNotLevelQInfo","history.go(-1)",1);
- }
- //返回表
- $infotb=ReturnInfoMainTbname($tbname,$index_r['checked']);
- $r=$empire->fetch1("select * from ".$infotb." where id='$id' and classid='$classid' and ismember=1 and userid='$userid' limit 1");
- if(!$r['id'])
- {
- printerror("HaveNotLevelQInfo","history.go(-1)",1);
- }
- $r['checked']=$index_r['checked'];
- if($adminqinfo==1)//管理未审核信息
- {
- if($index_r['checked'])
- {
- printerror("ClassSetNotAdminQCInfo","history.go(-1)",1);
- }
- }
- elseif($adminqinfo==2)//只可编辑未审核信息
- {
- if($index_r['checked']||$ecms!=1)
- {
- printerror("ClassSetNotEditQCInfo","history.go(-1)",1);
- }
- }
- elseif($adminqinfo==3)//只可删除未审核信息
- {
- if($index_r['checked']||$ecms!=2)
- {
- printerror("ClassSetNotDelQCInfo","history.go(-1)",1);
- }
- }
- elseif($adminqinfo==4)//管理所有信息
- {}
- elseif($adminqinfo==5)//只可编辑所有信息
- {
- if($ecms!=1)
- {
- printerror("ClassSetNotEditQInfo","history.go(-1)",1);
- }
- }
- elseif($adminqinfo==6)//只可删除所有信息
- {
- if($ecms!=2)
- {
- printerror("ClassSetNotDelQInfo","history.go(-1)",1);
- }
- }
- else//不能管理投稿
- {
- printerror("ClassSetNotAdminQInfo","history.go(-1)",1);
- }
- //返回表信息
- $infotbr=ReturnInfoTbname($tbname,$index_r['checked'],$r['stb']);
- //副表
- $mid=$class_r[$classid]['modid'];
- $finfor=$empire->fetch1("select ".ReturnSqlFtextF($mid)." from ".$infotbr['datatbname']." where id='$r[id]' limit 1");
- $r=array_merge($r,$finfor);
- return $r;
- }
- //组合下载/影视
- function DoqReturnDownPath($path,$ecms=0){
- global $fun_r;
- $downqz="";
- $fen=0;
- $fuser=0;
- $f_exp="::::::";
- $r_exp="\r\n";
- $returnstr="";
- $path=str_replace($f_exp,"",$path);
- $path=str_replace($r_exp,"",$path);
- if($ecms==0)
- {
- $name=$fun_r['DownPath']."1";
- }
- else
- {
- $name="1";
- }
- if($path)
- {
- $returnstr=$name.$f_exp.$path.$f_exp.$fuser.$f_exp.$fen.$f_exp.$downqz.$r_exp;
- }
- //去掉最后的字符
- $returnstr=substr($returnstr,0,strlen($returnstr)-2);
- return $returnstr;
- }
- //返回下载/影视地址
- function DoReqDownPath($downpath){
- if(empty($downpath))
- {
- return "";
- }
- $f_exp="::::::";
- $r_exp="\r\n";
- $r=explode($r_exp,$downpath);
- $r1=explode($f_exp,$r[0]);
- $r1[1]=addslashes(RepPostStr($r1[1]));
- return $r1[1];
- }
- //特殊字段处理
- function DoqSpecialValue($mid,$f,$value,$add,$infor,$ecms=0){
- global $public_r,$loginin,$emod_r;
- if($f=="morepic")//图片集
- {
- $add['msavepic']=0;
- $value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],$ecms,0,($ecms==1?$infor['fstb']:$public_r['filedeftb']));
- $value=doehtmlstr($value);
- }
- elseif($f=="downpath")//下载地址
- {
- $value=DoqReturnDownPath($value,0);
- $value=doehtmlstr($value);
- }
- elseif($f=="onlinepath")//在线地址
- {
- $value=DoqReturnDownPath($value,1);
- $value=doehtmlstr($value);
- }
- elseif($f=="newstext")//内容
- {
- //远程保存
- //$value=addslashes(CopyImg(stripSlashes($value),$add[copyimg],$add[copyflash],$add[classid],$add[qz_url],$loginin,$add['id'],$add['filepass'],$add['mark'],($ecms==1?$infor['fstb']:$public_r['filedeftb'])));
- }
- //存文本
- if($emod_r[$mid]['savetxtf']&&$f==$emod_r[$mid]['savetxtf'])
- {
- if($ecms==1)
- {
- //建立目录
- $newstexttxt_r=explode("/",$infor[$f]);
- $thetxtfile=$newstexttxt_r[2];
- $truevalue=MkDirTxtFile($newstexttxt_r[0]."/".$newstexttxt_r[1],$thetxtfile);
- }
- else
- {
- //建立目录
- $thetxtfile=GetFileMd5();
- $truevalue=MkDirTxtFile(date("Y/md"),$thetxtfile);
- }
- //写放文件
- EditTxtFieldText($truevalue,$value);
- $value=$truevalue;
- }
- return $value;
- }
- //检测点数是否足够
- function MCheckEnoughFen($userfen,$userdate,$fen){
- if(!($userdate-time()>0))
- {
- if($userfen+$fen<0)
- {
- printerror("HaveNotFenAQinfo","history.go(-1)",1);
- }
- }
- }
- //返回字段
- function ReturnQAddinfoF($mid,$add,$infor,$classid,$filepass,$userid,$username,$ecms=0){
- global $empire,$dbtbpre,$public_r,$emod_r,$ecms_config;
- $ret_r=array();
- $pr=$empire->fetch1("select qaddtran,qaddtransize,qaddtranimgtype,qaddtranfile,qaddtranfilesize,qaddtranfiletype,closewords,closewordsf from {$dbtbpre}enewspublic limit 1");
- $isadd=$ecms==0?1:0;
- qCheckInfoCloseWord($mid,$add,$pr['closewordsf'],$pr['closewords']);//屏蔽字符验证
- //检测必填字段
- $pagef=$emod_r[$mid]['pagef'];
- $mustr=explode(",",$emod_r[$mid]['mustqenterf']);
- $mustcount=count($mustr)-1;
- for($i=1;$i<$mustcount;$i++)
- {
- $mf=$mustr[$i];
- if(strstr($emod_r[$mid]['filef'],','.$mf.',')||strstr($emod_r[$mid]['imgf'],','.$mf.',')||strstr($emod_r[$mid]['flashf'],','.$mf.',')||$mf=='downpath'||$mf=='onlinepath')//附件
- {
- $mfilef=$mf."file";
- //上传文件
- if($_FILES[$mfilef]['name'])
- {
- if(strstr($emod_r[$mid]['imgf'],','.$mf.','))//图片
- {
- if(!$pr['qaddtran'])
- {
- printerror("CloseQTranPic","",1);
- }
- }
- else//附件
- {
- if(!$pr['qaddtranfile'])
- {
- printerror("CloseQTranFile","",1);
- }
- }
- }
- elseif(!trim($add[$mf])&&!$infor[$mf])
- {
- printerror("EmptyQMustF","",1);
- }
- }
- else
- {
- $chmustval=ReturnCheckboxAddF($add[$mf],$mid,$mf);//复选框
- $chmustval=ReturnMoreValueAddF($add,$chmustval,$mid,$mf,$ecms);//多值
- if(!trim($chmustval))
- {
- printerror("EmptyQMustF","",1);
- }
- }
- }
- //字段处理
- $dh="";
- $tranf="";
- $fr=explode(',',$emod_r[$mid]['qenter']);
- $count=count($fr)-1;
- for($i=1;$i<$count;$i++)
- {
- $f=$fr[$i];
- if($f=='special.field'||($ecms==0&&!strstr($emod_r[$mid]['canaddf'],','.$f.','))||($ecms==1&&!strstr($emod_r[$mid]['caneditf'],','.$f.',')))
- {continue;}
- //附件
- $add[$f]=str_replace('[!#@-','ecms',$add[$f]);
- if(strstr($emod_r[$mid]['filef'],','.$f.',')||strstr($emod_r[$mid]['imgf'],','.$f.',')||strstr($emod_r[$mid]['flashf'],','.$f.',')||$f=='downpath'||$f=='onlinepath')
- {
- //上传附件
- $filetf=$f."file";
- if($_FILES[$filetf]['name'])
- {
- $filetype=GetFiletype($_FILES[$filetf]['name']);//取得文件类型
- if(CheckSaveTranFiletype($filetype))
- {
- printerror("NotQTranFiletype","",1);
- }
- if(strstr($emod_r[$mid]['imgf'],','.$f.','))//图片
- {
- if(!$pr['qaddtran'])
- {
- printerror("CloseQTranPic","",1);
- }
- if(!strstr($pr['qaddtranimgtype'],"|".$filetype."|"))
- {
- printerror("NotQTranFiletype","",1);
- }
- if($_FILES[$filetf]['size']>$pr['qaddtransize']*1024)
- {
- printerror("TooBigQTranFile","",1);
- }
- if(!strstr($ecms_config['sets']['tranpicturetype'],','.$filetype.','))
- {
- printerror("NotQTranFiletype","",1);
- }
- }
- else//附件
- {
- if(!$pr['qaddtranfile'])
- {
- printerror("CloseQTranFile","",1);
- }
- if(!strstr($pr['qaddtranfiletype'],"|".$filetype."|"))
- {
- printerror("NotQTranFiletype","",1);
- }
- if($_FILES[$filetf]['size']>$pr['qaddtranfilesize']*1024)
- {
- printerror("TooBigQTranFile","",1);
- }
- if(strstr($emod_r[$mid]['flashf'],','.$f.','))//flash
- {
- if(!strstr($ecms_config['sets']['tranflashtype'],",".$filetype.","))
- {printerror("NotQTranFiletype","",1);}
- }
- if($f=="onlinepath")//视频
- {
- if(strstr($wmv_type,",".$filetype.","))
- {}
- }
- }
- $tranf.=$dh.$f;
- $dh=",";
- $fval="[!#@-".$f."-@!]";
- }
- else
- {
- if($public_r['modinfoedittran']==1)
- {
- $fval=$add[$f];
- if($ecms==1&&$infor[$f]&&!trim($fval))
- {
- $fval=$infor[$f];
- //特殊字段
- if($f=="downpath"||$f=="onlinepath")
- {
- $fval=DoReqDownPath($fval);
- }
- }
- }
- else
- {
- $fval='';
- if($ecms==1)
- {
- $fval=$infor[$f];
- //特殊字段
- if($f=="downpath"||$f=="onlinepath")
- {
- $fval=DoReqDownPath($fval);
- }
- }
- }
- }
- }
- elseif($f=='newstime')//时间
- {
- if($add[$f])
- {
- $fval=to_time($add[$f]);
- }
- else
- {
- $fval=time();
- }
- }
- elseif($f=='newstext')//内容
- {
- if($ecms==0)
- {
- $fval=DoReplaceKeyAndWord($add[$f],1,$classid);//替换关键字和字符
- }
- else
- {
- $fval=$add[$f];
- }
- }
- elseif($f=='infoip') //ip
- {
- $fval=egetip();
- }
- elseif($f=='infoipport') //ip端口
- {
- $fval=egetipport();
- }
- elseif($f=='infozm') //字母
- {
- $fval=$add[$f]?$add[$f]:GetInfoZm($add[title]);
- }
- else
- {
- $add[$f]=ReturnCheckboxAddF($add[$f],$mid,$f);//复选框
- $add[$f]=ReturnMoreValueAddF($add,$add[$f],$mid,$f,$ecms);//多值
- $fval=$add[$f];
- }
- $fval=eDoInfoTbfToQj($emod_r[$mid]['tbname'],$f,$fval,$public_r['qtoqjf']);
- $fval=DoFFun($mid,$f,$fval,$isadd,1);//执行函数
- $modispagef=$pagef==$f?1:0;
- $fval=RepTempvarPostStrT($fval,$modispagef);
- if($pagef!=$f)
- {
- $fval=RepTempvarPostStr($fval);
- }
- ChIsOnlyAddF($mid,$infor[id],$f,$fval,1);//唯一值
- $fval=DoqValue($mid,$f,$fval);
- $fval=DoqSpecialValue($mid,$f,$fval,$add,$infor,$ecms);
- $fval=RepPostStr2($fval);
- if($ecms==1)
- {
- SameDataAddF($info[id],$classid,$mid,$f,$fval);
- }
- $fval=addslashes($fval);
- if($ecms==0)//添加
- {
- if(strstr($emod_r[$mid]['tbdataf'],','.$f.','))//副表
- {
- $ret_r[2].=",".$f;
- $ret_r[3].=",'".$fval."'";
- }
- else
- {
- $ret_r[0].=",".$f;
- $ret_r[1].=",'".$fval."'";
- }
- }
- else//编辑
- {
- if($f=='infoip'||$f=='infoipport') //ip
- {
- continue;
- }
- if(strstr($emod_r[$mid]['tbdataf'],','.$f.','))//副表
- {
- $ret_r[3].=",".$f."='".$fval."'";
- }
- else
- {
- $ret_r[0].=",".$f."='".$fval."'";
- }
- }
- }
- //上传附件
- if($tranf)
- {
- if($ecms==0)
- {
- $infoid=0;
- }
- else
- {
- $infoid=$infor['id'];
- $filepass=0;
- }
- $tranr=explode(",",$tranf);
- $count=count($tranr);
- for($i=0;$i<$count;$i++)
- {
- $tf=$tranr[$i];
- $tffile=$tf."file";
- $tfr=DoTranFile($_FILES[$tffile]['tmp_name'],$_FILES[$tffile]['name'],$_FILES[$tffile]['type'],$_FILES[$tffile]['size'],$classid);
- if($tfr['tran'])
- {
- //文件类型
- $mvf=$tf."mtfile";
- if(strstr($emod_r[$mid]['imgf'],','.$tf.','))//图片
- {
- $type=1;
- }
- elseif(strstr($emod_r[$mid]['flashf'],','.$tf.','))//flash
- {
- $type=2;
- }
- elseif($add[$mvf]==1)//多媒体
- {
- $type=3;
- }
- else//附件
- {
- $type=0;
- }
- //写入数据库
- $filetime=time();
- $filesize=(int)$_FILES[$tffile]['size'];
- $classid=(int)$classid;
- eInsertFileTable($tfr[filename],$filesize,$tfr[filepath],'[Member]'.$username,$classid,'['.$tf.']'.addslashes(RepPostStr($add[title])),$type,$infoid,$filepass,$public_r[fpath],0,0,($ecms==1?$infor['fstb']:$public_r['filedeftb']));
- //删除旧文件
- if($ecms==1&&$infor[$tf])
- {
- DelYQTranFile($classid,$infor['id'],$infor[$tf],$tf,$infor['fstb']);
- }
- $repfval=$tfr['url'];
- }
- else
- {
- $repfval=$infor[$tf];
- //特殊字段
- if($tf=="downpath"||$tf=="onlinepath")
- {
- $repfval=DoReqDownPath($repfval);
- }
- }
- if($ecms==0)//添加
- {
- $ret_r[1]=str_replace("[!#@-".$tf."-@!]",$repfval,$ret_r[1]);
- $ret_r[3]=str_replace("[!#@-".$tf."-@!]",$repfval,$ret_r[3]);
- }
- else//编辑
- {
- $ret_r[0]=str_replace("[!#@-".$tf."-@!]",$repfval,$ret_r[0]);
- $ret_r[3]=str_replace("[!#@-".$tf."-@!]",$repfval,$ret_r[3]);
- }
- }
- }
- $ret_r[4]=$emod_r[$mid]['deftb'];
- return $ret_r;
- }
- //删除原附件
- function DelYQTranFile($classid,$id,$file,$tf,$fstb='1'){
- global $empire,$dbtbpre;
- //特殊字段
- if($tf=="downpath"||$tf=="onlinepath")
- {
- $file=DoReqDownPath($file);
- }
- if(empty($file))
- {
- return "";
- }
- $r=explode("/",$file);
- $count=count($r);
- $filename=$r[$count-1];
- $filename=addslashes(RepPostStr($filename));
- $fr=$empire->fetch1("select filename,path,fileid,fpath,classid from {$dbtbpre}enewsfile_{$fstb} where classid='$classid' and id='$id' and filename='$filename' limit 1");
- if($fr['fileid'])
- {
- $sql=$empire->query("delete from {$dbtbpre}enewsfile_{$fstb} where fileid='$fr[fileid]'");
- DoDelFile($fr);
- }
- }
- //信息投稿
- function DodoInfo($add,$ecms=0){
- global $empire,$public_r,$emod_r,$level_r,$class_r,$dbtbpre,$fun_r;
- //验证来源
- if($ecms==0||$ecms==1)
- {
- CheckCanPostUrl();
- }
- //开启投稿
- if($public_r['addnews_ok'])
- {
- printerror("CloseQAdd","",1);
- }
- //验证本时间允许操作
- eCheckTimeCloseDo('info');
- $classid=(int)$add['classid'];
- $mid=(int)$class_r[$classid]['modid'];
- if(!$mid||!$classid)
- {
- printerror("EmptyQinfoCid","",1);
- }
- $tbname=$emod_r[$mid]['tbname'];
- $qenter=$emod_r[$mid]['qenter'];
- if(!$tbname||!$qenter||$qenter==',')
- {
- printerror("ErrorUrl","history.go(-1)",1);
- }
- $muserid=(int)getcvar('mluserid');
- $musername=RepPostVar(getcvar('mlusername'));
- $mrnd=RepPostVar(getcvar('mlrnd'));
- //取得栏目信息
- $isadd=0;
- if($ecms==0)
- {
- $isadd=1;
- }
- $setuserday='';
- $cr=DoQCheckAddLevel($classid,$muserid,$musername,$mrnd,$ecms,$isadd);
- $setuserday=$cr['checkaddnumquery'];
- $filepass=(int)$add['filepass'];
- $id=(int)$add['id'];
- $infor=array();
- //组合标题属性
- $titlecolor=addslashes(RepPostStr(RepPhpAspJspcodeText($add[titlecolor])));
- $titlefont=dgdb_tosave(TitleFont($add[titlefont],$titlecolor));
- $titlecolor="";
- $titlefont="";
- $ttid=(int)$add['ttid'];
- $keyboard=addslashes(RepPostStr(trim(DoReplaceQjDh($add[keyboard]))));
- $keyid='';
- //返回关键字组合
- if($keyboard&&strstr($qenter,',special.field,'))
- {
- $keyboard=str_replace('[!--f--!]','ecms',$keyboard);
- $keyid=GetKeyid($keyboard,$classid,$id,$class_r[$classid][link_num]);
- $keyid=dgdb_tosave($keyid);
- }
- else
- {
- $keyboard='';
- $keyid='';
- }
- //验证码
- $keyvname='checkinfokey';
- //moreport
- if(Moreport_ReturnMustDt())
- {
- define('ECMS_SELFPATH',eReturnEcmsMainPortPath());
- Moreport_ResetMainTempGid();
- }
- $epreid=0;
- //-----------------增加
- if($ecms==0)
- {
- //时间
- $lasttime=getcvar('lastaddinfotime');
- if($lasttime)
- {
- if(time()-$lasttime<$public_r['readdinfotime'])
- {
- printerror("QAddInfoOutTime","",1);
- }
- }
- //验证码
- if($cr['qaddshowkey'])
- {
- ecmsCheckShowKey($keyvname,$add['key'],1);
- }
- //IP发布数限制
- $check_ip=egetip();
- $check_checked=$cr['wfid']?0:$cr['checkqadd'];
- eCheckIpAddInfoNum($check_ip,$tbname,$mid,$check_checked);
- //验证单信息
- qCheckMemberOneInfo($tbname,$mid,$classid,$muserid);
- //返回字段
- $ret_r=ReturnQAddinfoF($mid,$add,$infor,$classid,$filepass,$muserid,$musername,0);
- $checked=$cr['checkqadd'];
- $havehtml=0;
- $newspath=date($cr['newspath']);
- $truetime=time();
- $newstime=$truetime;
- $newstempid=$cr['newstempid'];
- $haveaddfen=0;
- //强制签发
- $isqf=0;
- if($cr['wfid'])
- {
- $checked=0;
- $isqf=1;
- }
- //增扣点
- if($muserid)
- {
- if($checked)
- {
- AddInfoFen($cr['addinfofen'],$muserid);
- $haveaddfen=1;
- }
- else
- {
- if($cr['addinfofen']<0&&!$public_r['qinfoaddfen'])
- {
- AddInfoFen($cr['addinfofen'],$muserid);
- $haveaddfen=1;
- }
- }
- }
- if(empty($muserid))
- {
- $musername=$fun_r['guest'];
- }
- //会员投稿数更新
- if($setuserday)
- {
- $empire->query($setuserday);
- }
- //发布时间
- if(!strstr($qenter,',newstime,'))
- {
- $ret_r[0]=",newstime".$ret_r[0];
- $ret_r[1]=",'$newstime'".$ret_r[1];
- }
- else
- {
- if($add['newstime'])
- {
- $newstime=to_time($add['newstime']);
- $newstime=intval($newstime);
- }
- }
- //附加链接参数
- $addecmscheck=empty($checked)?'&ecmscheck=1':'';
- //索引表
- $indexsql=$empire->query("insert into {$dbtbpre}ecms_".$tbname."_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('$classid','$checked','$newstime','$truetime','$truetime','$havehtml');");
- $id=$empire->lastid();
- //返回表信息
- $infotbr=ReturnInfoTbname($tbname,$checked,$ret_r[4]);
- //主表
- $sql=$empire->query("insert into ".$infotbr['tbname']."(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard".$ret_r[0].") values('$id','$classid','$ttid',0,0,0,'$newspath','','".$muserid."','".addslashes($musername)."',0,0,0,'$isqf',1,0,'$truetime','$truetime','$havehtml',0,0,'$titlefont','','$ret_r[4]','$public_r[filedeftb]','$public_r[pldeftb]','$keyboard'".$ret_r[1].");");
- //副表
- $fsql=$empire->query("insert into ".$infotbr['datatbname']."(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags".$ret_r[2].") values('$id','$classid','$keyid',1,'$newstempid',0,'$haveaddfen',''".$ret_r[3].");");
- //扣点记录
- if($haveaddfen)
- {
- if($cr['addinfofen']<0)
- {
- BakDown($classid,$id,0,$muserid,$musername,addslashes(RepPostStr($add[title])),abs($cr['addinfofen']),3);
- }
- }
- //签发
- if($isqf==1)
- {
- InfoInsertToWorkflow($id,$classid,$cr['wfid'],$muserid,addslashes($musername));
- }
- //文件命名
- $filename=ReturnInfoFilename($classid,$id,'');
- //信息地址
- $infourl=GotoGetTitleUrl($classid,$id,$newspath,$filename,0,0,'');
- $usql=$empire->query("update ".$infotbr['tbname']." set filename='$filename',titleurl='$infourl' where id='$id'");
- //修改ispic
- UpdateTheIspic($classid,$id,$checked);
- //修改附件
- if($filepass)
- {
- UpdateTheFile($id,$filepass,$classid,$public_r['filedeftb']);
- }
- //更新栏目信息数
- AddClassInfos($classid,'+1','+1',$checked);
- //更新新信息数
- DoUpdateAddDataNum('info',$class_r[$classid]['tid'],1);
- //处理函数
- DoMFun($class_r[$classid]['modid'],$classid,$id,1,1);
- //清除验证码
- ecmsEmptyShowKey($keyvname);
- esetcookie("qeditinfo","",0);
- //生成页面
- if($checked&&!$cr['showdt'])
- {
- $titleurl=qAddGetHtml($classid,$id);
- }
- //生成列表
- $epreid=0;
- if($checked)
- {
- qAddListHtml($classid,$mid,$cr['qaddlist'],$cr['listdt']);
- //生成上一篇
- if($cr['repreinfo'])
- {
- $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id<$id and classid='$classid' order by id desc limit 1");
- $epreid=$prer['id'];
- GetHtml($prer['classid'],$prer['id'],$prer,1);
- }
- }
- //更新动态缓存
- if($public_r['ctimeopen']&&$checked)
- {
- eUpCacheInfo(0,$classid,0,$epreid,$ttid,'','',0,0);
- }
- if($sql)
- {
- $reurl=DoingReturnUrl("AddInfo.php?classid=$classid&mid=$mid".$addecmscheck,$add['ecmsfrom']);
- if($add['gotoinfourl']&&$checked)//返回内容页
- {
- if($cr['showdt']==1)
- {
- $reurl=$public_r[newsurl]."e/action/ShowInfo/?classid=$classid&id=$id";
- }
- elseif($cr['showdt']==2)
- {
- $rewriter=eReturnRewriteInfoUrl($classid,$id,1);
- $reurl=$rewriter['pageurl'];
- }
- else
- {
- $reurl=$titleurl;
- }
- }
- esetcookie("lastaddinfotime",time(),time()+3600*24);//设置最后发表时间
- printerror("AddQinfoSuccess",$reurl,1);
- }
- else
- {printerror("DbError","history.go(-1)",1);}
- }
- //---------------修改
- elseif($ecms==1)
- {
- if(!$id)
- {
- printerror("ErrorUrl","history.go(-1)",1);
- }
- //检测权限
- $infor=CheckQdoinfo($classid,$id,$muserid,$tbname,$cr['adminqinfo'],1);
- //检测时间
- if($public_r['qeditinfotime'])
- {
- if(time()-$infor['truetime']>$public_r['qeditinfotime']*60)
- {
- printerror("QEditInfoOutTime","history.go(-1)",1);
- }
- }
- //签发信息
- if($infor['isqf'])
- {
- $qck_qfr=$empire->fetch1("select wfid,checktno from {$dbtbpre}enewswfinfo where id='$infor[id]' and classid='$infor[classid]' limit 1");
- if($qck_qfr['checktno']<100)
- {
- $qck_qfwfr=$empire->fetch1("select wfid,canedit from {$dbtbpre}enewsworkflow where wfid='$qck_qfr[wfid]' limit 1");
- if($qck_qfwfr['wfid']&&!$qck_qfwfr['canedit'])
- {
- printerror("qWorkflowCanNotEditInfo","history.go(-1)",1);
- }
- }
- }
- $iaddfield='';
- $addfield='';
- $faddfield='';
- //返回字段
- $ret_r=ReturnQAddinfoF($mid,$add,$infor,$classid,$filepass,$muserid,$musername,1);
- if($keyboard)
- {
- $addfield=",keyboard='$keyboard'";
- $faddfield=",keyid='$keyid'";
- }
- //时间
- if(strstr($qenter,',newstime,'))
- {
- if($add['newstime'])
- {
- $newstime=to_time($add['newstime']);
- $newstime=intval($newstime);
- $iaddfield.=",newstime='$newstime'";
- }
- }
- //修改是否需要审核
- $ychecked=$infor['checked'];
- if($cr['qeditchecked'])
- {
- $infor['checked']=0;
- $iaddfield.=",checked=0";
- $relist=1;
- //删除原页面
- DelNewsFile($infor[filename],$infor[newspath],$infor[classid],$infor[newstext],$infor[groupid]);
- }
- //会员投稿数更新
- if($setuserday)
- {
- //$empire->query($setuserday);
- }
- $lastdotime=time();
- //附加链接参数
- $addecmscheck=empty($infor['checked'])?'&ecmscheck=1':'';
- //索引表
- $indexsql=$empire->query("update {$dbtbpre}ecms_".$tbname."_index set lastdotime=$lastdotime,havehtml=0".$iaddfield." where id='$id'");
- //返回表信息
- $infotbr=ReturnInfoTbname($tbname,$ychecked,$infor['stb']);
- //主表
- $sql=$empire->query("update ".$infotbr['tbname']." set lastdotime=$lastdotime,havehtml=0,ttid='$ttid'".$addfield.$ret_r[0]." where id=$id and classid=$classid and userid='$muserid' and ismember=1");
- //副表
- $fsql=$empire->query("update ".$infotbr['datatbname']." set classid='$classid'".$faddfield.$ret_r[3]." where id='$id'");
- //修改ispic
- UpdateTheIspic($classid,$id,$ychecked);
- //更新附件
- UpdateTheFileEdit($classid,$id,$infor['fstb']);
- //未审核信息互转
- if($ychecked!=$infor['checked'])
- {
- MoveCheckInfoData($tbname,$ychecked,$infor['stb'],"id='$id'");
- //更新栏目信息数
- if($infor['checked'])
- {
- AddClassInfos($classid,'','+1');
- }
- else
- {
- AddClassInfos($classid,'','-1');
- }
- }
- //处理函数
- DoMFun($class_r[$classid]['modid'],$classid,$id,0,1);
- esetcookie("qeditinfo","",0);
- //生成页面
- if($infor['checked']&&!$cr['showdt'])
- {
- $titleurl=qAddGetHtml($classid,$id);
- }
- //生成列表
- if($infor['checked']||$relist==1)
- {
- qAddListHtml($classid,$mid,$cr['qaddlist'],$cr['listdt']);
- }
- //生成上一篇
- $epreid=0;
- if($cr['repreinfo']&&$infor['checked'])
- {
- $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id<$id and classid='$classid' order by id desc limit 1");
- $epreid=$prer['id'];
- GetHtml($prer['classid'],$prer['id'],$prer,1);
- }
- //更新动态缓存
- if($public_r['ctimeopen']&&$infor['checked'])
- {
- eUpCacheInfo(0,$classid,0,$epreid,$ttid,'','',0,0);
- }
- if($sql)
- {
- $reurl=DoingReturnUrl("ListInfo.php?mid=$mid".$addecmscheck,$add['ecmsfrom']);
- if($add['editgotoinfourl']&&$infor['checked'])//返回内容页
- {
- if($cr['showdt']==1)
- {
- $reurl=$public_r[newsurl]."e/action/ShowInfo/?classid=$classid&id=$id";
- }
- elseif($cr['showdt']==2)
- {
- $rewriter=eReturnRewriteInfoUrl($classid,$id,1);
- $reurl=$rewriter['pageurl'];
- }
- else
- {
- $reurl=$titleurl;
- }
- }
- printerror("EditQinfoSuccess",$reurl,1);
- }
- else
- {printerror("DbError","history.go(-1)",1);}
- }
- //---------------删除
- elseif($ecms==2)
- {
- if(!$id)
- {
- printerror("ErrorUrl","history.go(-1)",1);
- }
- //检测权限
- $r=CheckQdoinfo($classid,$id,$muserid,$tbname,$cr['adminqinfo'],2);
- //附加链接参数
- $addecmscheck=empty($r['checked'])?'&ecmscheck=1':'';
- //返回表信息
- $infotbr=ReturnInfoTbname($tbname,$r['checked'],$r['stb']);
- $stf=$emod_r[$mid]['savetxtf'];
- $pf=$emod_r[$mid]['pagef'];
- //分页字段
- if($pf)
- {
- if(strstr($emod_r[$mid]['tbdataf'],','.$pf.','))
- {
- $finfor=$empire->fetch1("select ".$pf." from ".$infotbr['datatbname']." where id='$id' limit 1");
- $r[$pf]=$finfor[$pf];
- }
- }
- //存文本
- if($stf)
- {
- $newstextfile=$r[$stf];
- $r[$stf]=GetTxtFieldText($r[$stf]);
- //删除文件
- DelTxtFieldText($newstextfile);
- }
- //删除信息文件
- DelNewsFile($r[filename],$r[newspath],$classid,$r[$pf],$r[groupid]);
- $indexsql=$empire->query("delete from {$dbtbpre}ecms_".$tbname."_index where id='$id'");
- $sql=$empire->query("delete from ".$infotbr['tbname']." where id=$id and classid=$classid and userid='$muserid' and ismember=1");
- $fsql=$empire->query("delete from ".$infotbr['datatbname']." where id=$id");
- esetcookie("qdelinfo","",0);
- //更新栏目信息数
- AddClassInfos($classid,'-1','-1',$r['checked']);
- //删除其它表记录和附件
- DelSingleInfoOtherData($classid,$id,$r,0,0);
- //生成列表
- $epreid=0;
- $enextid=0;
- if($r['checked'])
- {
- qAddListHtml($classid,$mid,$cr['qaddlist'],$cr['listdt']);
- //生成上一篇
- if($cr['repreinfo'])
- {
- $prer=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id<$id and classid='$classid' order by id desc limit 1");
- $epreid=$prer['id'];
- GetHtml($prer['classid'],$prer['id'],$prer,1);
- //下一篇
- $nextr=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id>$id and classid='$classid' order by id limit 1");
- if($nextr['id'])
- {
- $enextid=$nextr['id'];
- GetHtml($nextr['classid'],$nextr['id'],$nextr,1);
- }
- }
- }
- //更新动态缓存
- if($public_r['ctimeopen']&&$r['checked'])
- {
- eUpCacheInfo(0,$classid,$enextid,$epreid,$r['ttid'],'','',0,0);
- }
- if($sql)
- {
- $reurl=DoingReturnUrl("ListInfo.php?mid=$mid",$add['ecmsfrom']);
- printerror("DelQinfoSuccess",$reurl,1);
- }
- else
- {printerror("DbError","history.go(-1)",1);}
- }
- else
- {
- printerror("ErrorUrl","",1);
- }
- }
- //投稿权限检测
- function DoQCheckAddLevel($classid,$userid,$username,$rnd,$ecms=0,$isadd=0){
- global $empire,$dbtbpre,$level_r,$public_r;
- $classid=(int)$classid;
- $user=array();
- $r=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$classid'");
- if(!$r['classid']||$r[wburl])
- {
- printerror("EmptyQinfoCid","",1);
- }
- if(!$r['islast'])
- {
- printerror("MustLast","",1);
- }
- if($r['openadd'])
- {
- printerror("NotOpenCQInfo","",1);
- }
- //是否登陆
- if($ecms==1||$ecms==2||($r['qaddgroupid']&&$r['qaddgroupid']<>','))
- {
- $user=islogin($userid,$username,$rnd);
- //验证新会员投稿
- if($isadd==1&&$public_r['newaddinfotime'])
- {
- qCheckNewMemberAddInfo($user[registertime]);
- }
- }
- //会员组
- if($r['qaddgroupid']&&$r['qaddgroupid']<>',')
- {
- if(!strstr($r['qaddgroupid'],','.$user[groupid].','))
- {
- printerror("HaveNotLevelAQinfo","history.go(-1)",1);
- }
- }
- if($isadd==1)
- {
- //检测是否足够点数
- if($r['addinfofen']<0&&$user['userid'])
- {
- MCheckEnoughFen($user['userfen'],$user['userdate'],$r['addinfofen']);
- }
- //检测投稿数
- if($r['qaddgroupid']&&$r['qaddgroupid']<>','&&$level_r[$user[groupid]]['dayaddinfo'])
- {
- $r['checkaddnumquery']=DoQCheckAddNum($user['userid'],$user['groupid']);
- }
- }
- //审核
- if(($ecms==0||$ecms==1)&&$userid)
- {
- if(!$user[groupid])
- {
- $user=islogin($userid,$username,$rnd);
- }
- if($level_r[$user[groupid]]['infochecked'])
- {
- $r['checkqadd']=1;
- $r['qeditchecked']=0;
- }
- }
- //实名验证
- eCheckHaveTruename('info',$user['userid'],$user['username'],$user['isern'],$user['checked'],0);
- return $r;
- }
- //检查投稿数
- function DoQCheckAddNum($userid,$groupid){
- global $empire,$dbtbpre,$level_r,$public_r;
- $userid=(int)$userid;
- $ur=$empire->fetch1("select userid,todayinfodate,todayaddinfo from {$dbtbpre}enewsmemberpub where userid='$userid' limit 1");
- $thetoday=date("Y-m-d");
- if($ur['userid'])
- {
- if($thetoday!=$ur['todayinfodate'])
- {
- $query="update {$dbtbpre}enewsmemberpub set todayinfodate='$thetoday',todayaddinfo=1 where userid='$userid'";
- }
- else
- {
- if($ur['todayaddinfo']>=$level_r[$groupid]['dayaddinfo'])
- {
- printerror("CrossDayInfo",$public_r['newsurl'],1);
- }
- $query="update {$dbtbpre}enewsmemberpub set todayaddinfo=todayaddinfo+1 where userid='$userid'";
- }
- }
- else
- {
- $query="replace into {$dbtbpre}enewsmemberpub(userid,todayinfodate,todayaddinfo) values('$userid','$thetoday',1);";
- }
- return $query;
- }
- //上传附件
- function DoQTranFile($add,$file,$file_name,$file_type,$file_size,$userid,$username,$rnd,$ecms=0){
- global $empire,$dbtbpre,$class_r,$public_r,$ecms_config;
- if($public_r['addnews_ok'])//关闭投稿
- {
- $ecms!=1?printerror("NotOpenCQInfo","",9):ECMS_QEditorPrintError(1,'','','NotOpenCQInfo','','');
- }
- $filepass=(int)$add['filepass'];
- $classid=(int)$add['classid'];
- $infoid=(int)$add['infoid'];
- if(!$file_name||!$filepass||!$classid||!$class_r[$classid][tbname])
- {
- $ecms!=1?printerror("EmptyQTranFile","",9):ECMS_QEditorPrintError(1,'','','EmptyQTranFile','','');
- }
- //信息
- if($infoid)
- {
- $index_r=$empire->fetch1("select classid,checked from {$dbtbpre}ecms_".$class_r[$classid][tbname]."_index where id='$infoid'");
- if(!$index_r['classid']||$classid!=$index_r['classid'])
- {
- $ecms!=1?printerror("EmptyQTranFile","",9):ECMS_QEditorPrintError(1,'','','EmptyQTranFile','','');
- }
- $infotb=ReturnInfoMainTbname($class_r[$classid][tbname],$index_r['checked']);
- $infor=$empire->fetch1("select classid,fstb from ".$infotb." where id='$infoid'");
- if(!$infor['fstb']||$classid!=$infor['classid'])
- {
- $ecms!=1?printerror("EmptyQTranFile","",9):ECMS_QEditorPrintError(1,'','','EmptyQTranFile','','');
- }
- $fstb=$infor['fstb'];
- }
- else
- {
- $fstb=$public_r['filedeftb'];
- }
- //验证权限
- $userid=(int)$userid;
- $username=RepPostVar($username);
- $rnd=RepPostVar($rnd);
- DoQCheckAddLevel($classid,$userid,$username,$rnd,0,0);
- $filetype=GetFiletype($file_name);//取得文件类型
- if(CheckSaveTranFiletype($filetype))
- {
- $ecms!=1?printerror("NotQTranFiletype","",9):ECMS_QEditorPrintError(1,'','','NotQTranFiletype','','');
- }
- $type=(int)$add['type'];
- $pr=$empire->fetch1("select qaddtran,qaddtransize,qaddtranimgtype,qaddtranfile,qaddtranfilesize,qaddtranfiletype from {$dbtbpre}enewspublic limit 1");
- if($type==1)//图片
- {
- if(!$pr['qaddtran'])
- {
- $ecms!=1?printerror("CloseQTranPic","",9):ECMS_QEditorPrintError(1,'','','CloseQTranPic','','');
- }
- if(!strstr($pr['qaddtranimgtype'],"|".$filetype."|"))
- {
- $ecms!=1?printerror("NotQTranFiletype","",9):ECMS_QEditorPrintError(1,'','','NotQTranFiletype','','');
- }
- if($file_size>$pr['qaddtransize']*1024)
- {
- $ecms!=1?printerror("TooBigQTranFile","",9):ECMS_QEditorPrintError(1,'','','TooBigQTranFile','','');
- }
- if(!strstr($ecms_config['sets']['tranpicturetype'],','.$filetype.','))
- {
- $ecms!=1?printerror("NotQTranFiletype","",9):ECMS_QEditorPrintError(1,'','','NotQTranFiletype','','');
- }
- }
- elseif($type==2)//flash
- {
- if(!$pr['qaddtranfile'])
- {
- $ecms!=1?printerror("CloseQTranFile","",9):ECMS_QEditorPrintError(1,'','','CloseQTranFile','','');
- }
- if(!strstr($pr['qaddtranfiletype'],"|".$filetype."|"))
- {
- $ecms!=1?printerror("NotQTranFiletype","",9):ECMS_QEditorPrintError(1,'','','NotQTranFiletype','','');
- }
- if($file_size>$pr['qaddtranfilesize']*1024)
- {
- $ecms!=1?printerror("TooBigQTranFile","",9):ECMS_QEditorPrintError(1,'','','TooBigQTranFile','','');
- }
- if(!strstr($ecms_config['sets']['tranflashtype'],','.$filetype.','))
- {
- $ecms!=1?printerror("NotQTranFiletype","",9):ECMS_QEditorPrintError(1,'','','NotQTranFiletype','','');
- }
- }
- else//附件
- {
- if(!$pr['qaddtranfile'])
- {
- $ecms!=1?printerror("CloseQTranFile","",9):ECMS_QEditorPrintError(1,'','','CloseQTranFile','','');
- }
- if(!strstr($pr['qaddtranfiletype'],"|".$filetype."|"))
- {
- $ecms!=1?printerror("NotQTranFiletype","",9):ECMS_QEditorPrintError(1,'','','NotQTranFiletype','','');
- }
- if($file_size>$pr['qaddtranfilesize']*1024)
- {
- $ecms!=1?printerror("TooBigQTranFile","",9):ECMS_QEditorPrintError(1,'','','TooBigQTranFile','','');
- }
- }
- $r=DoTranFile($file,$file_name,$file_type,$file_size,$classid);
- if(empty($r[tran]))
- {
- $ecms!=1?printerror("TranFail","",9):ECMS_QEditorPrintError(1,'','','TranFail','','');
- }
- //写入数据库
- $filetime=time();
- $r[filesize]=(int)$r[filesize];
- $classid=(int)$classid;
- eInsertFileTable($r[filename],$r[filesize],$r[filepath],'[Member]'.$username,$classid,$r[filename],$type,$filepass,$filepass,$public_r[fpath],0,0,$fstb);
- //编辑器
- if($ecms==1)
- {
- ECMS_QEditorPrintError(0,$r[url],$r[filename],'',$r[filename],$r[filesize]);
- }
- else
- {
- eCheckStrType(4,$add['field'],1);
- echo"<script>opener.document.add.".$add['field'].".value='".$r['url']."';window.close();</script>";
- }
- db_close();
- $empire=null;
- exit();
- }
- //----------- 编辑器 --------------
- //提示信息
- function ECMS_QEditorPrintError($errorNumber,$fileUrl,$fileName,$customMsg,$fileno,$filesize){
- if(empty($errorNumber))
- {
- $errorNumber=0;
- $filesize=ChTheFilesize($filesize);
- }
- else
- {
- @include LoadLang("pub/q_message.php");
- $customMsg=$qmessage_r[$customMsg];
- }
- $errorNumber=(int)$errorNumber;
- $typer=ECMS_EditorReturnType('');
- $type=$typer['ftype'];
- //附件
- if($type==0)
- {
- $fileUrl=$fileUrl.'##'.$fileno.'##'.$filesize;
- }
- ECMS_PTEditorShowError($type,addslashes($customMsg),addslashes($fileUrl),$add,0);
- db_close();
- exit();
- }
- ?>
|