在e/class/userfun.php这个自定义函数文件中添加一个函数
折叠展开PHP 代码
- function user_TranImgAuto($mid,$f,$isadd,$isq,$value,$cs){
- global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$tranpicturetype,$musername;
-
- $filetf=$f.'file';
- if(!$_FILES[$filetf]['name'])
- {
- return '';
- }
- $classid=(int)$_POST['classid'];
- $id=(int)$_POST['id'];
- $filepass=(int)$_POST['filepass'];
- $filetype=GetFiletype($_FILES[$filetf]['name']);
- $pr=$empire->fetch1("select qaddtran,qaddtransize,qaddtranimgtype from {$dbtbpre}enewspublic limit 1");
- 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($tranpicturetype,','.$filetype.','))
- {
- printerror("NotQTranFiletype","",1);
- }
- $tfr=DoTranFile($_FILES[$filetf]['tmp_name'],$_FILES[$filetf]['name'],$_FILES[$filetf]['type'],$_FILES[$filetf]['size'],$classid);
- if($tfr['tran'])
- {
-
- $csr=explode(',',$cs);
- $maxwidth=$csr[0];
- $maxheight=$csr[1];
- $datu=$csr[2];
- $suiyi=$csr[3];
- include_once(ECMS_PATH.'e/class/gd.php');
- $yname=$tfr['yname'];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if($suiyi=="yes" and $datu=="yes"){
- imageWaterMark($tfr[yname],5,"../data/mark/maskdef.gif","",5,"#FF0000","../data/mark/cour.ttf",100,100);
- }
- $name=$tfr['name'];
-
- $filer=ResizeImage($yname,$name,$maxwidth,$maxheight,$public_r['spickill']);
-
- if($datu=="no"){
- DelFiletext($yname);
- }
-
-
- if($filer['file'])
- {
-
- $type=1;
- $filetime=date("Y-m-d H:i:s");
- $filesize=@filesize($filer['file']);
- $filename=GetFilename(str_replace(ECMS_PATH,'',$filer['file']));
- $adduser='[Member]'.$musername;
- $infoid=$isadd==1?0:$id;
-
- if($datu=="yes"){
- $empire->query("insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,fpath) values('$tfr[filename]','$filesize','$adduser','$tfr[filepath]','$filetime','$classid','".addslashes(RepPostStr($_POST[title]))."','$type','$infoid','$filepass','$public_r[fpath]');");
- }
- }
-
- $value=$tfr['url'];
- }
- else
- {
- $value='';
- }
- return $value;
- }
在titlepic中添加处理函数,如图所示:
具体字段处理函数添加说明如下:user_TranImgAuto##160,120,yes,yes
160 宽度
120 高度
no 代表删除大图保留缩图,同时下面第4个参数无效 yes 代表保留大图和小图
no 代表不加水印 yes 代表加水印