织梦使用kindeditor后批量上传图片无法加水印,解决方法是修改/include/dialog/kindeditor_post.php文件
用以下代码进行替换即可解决
具体代码如下:
FILE).\"/config.php\"); require_once(dirname(FILE).\"/../image.func.php\"); require_once(dirname(FILE).\"/../json.class.php\"); function alert($msg) { $json = new Services_JSON(); echo $json->encode(array(\'error\' => 1, \'message\' => $msg));
exit;
}
$ext_arr = array( \'image\' => array(\'gif\', \'jpg\', \'jpeg\', \'png\', \'bmp\'), \'flash\' => array(\'swf\', \'flv\'), \'media\' => array(\'swf\', \'flv\', \'mp3\', \'wav\', \'wma\', \'wmv\', \'mid\', \'avi\', \'mpg\', \'asf\', \'rm\', \'rmvb\'), \'file\' => array(\'doc\', \'docx\', \'xls\', \'xlsx\', \'ppt\', \'htm\', \'html\', \'txt\', \'zip\', \'rar\', \'gz\', \'bz2\', \'pdf\'), );
$media_type = array( \'image\' => 1, \'flash\' => 2, \'media\' => 3, \'file\' => 4, );
if(empty($activepath)) {
$activepath =\'\';
$activepath = str_replace(\'.\', \'\', $activepath);
$activepath = preg_replace(\"#/{1,}#\", \'/\', $activepath);
if(strlen($activepath) < strlen($cfg_image_dir)) { $activepath = $cfg_image_dir; } } $ismarkup = isset($_POST[\'iswater\'])? 1 : 0; $dir_name = empty($_GET[\'dir\']) ? \'image\' : trim($_GET[\'dir\']); if(empty($imgFile)) { $imgFile=\'\'; } if(!is_uploaded_file($imgFile)) { alert(gb2utf8(\"你没有选择上传的文件!\".$imgFile)); } $CKEditorFuncNum = (isset($CKEditorFuncNum))? $CKEditorFuncNum : 1; $imgfile_name = $_FILES[\'imgFile\'][\'name\']; $imgfile_name = trim(preg_replace(\"#[ rnt*%\\/?><|\":] {
1,
}
\", \'\', $imgfile_name)); //检查目录名 $dir_name = empty($_GET[\'dir\']) ? \'image\' : trim($_GET[\'dir\']); if (empty($ext_arr[$dir_name])) { alert(\"目录名不正确。\"); } //获得文件扩展名 $temp_arr = explode(\".\", $imgfile_name); $file_ext = array_pop($temp_arr); $file_ext = trim($file_ext); $file_ext = strtolower($file_ext); //检查扩展名 if (in_array($file_ext, $ext_arr[$dir_name]) === false) { alert(gb2utf8(\"上传文件扩展名是不允许的扩展名。n只允许\" . implode(\",\", $ext_arr[$dir_name]) . \"格式。\")); } $nowtme = time(); $imgfile_type = $_FILES[\'imgFile\'][\'type\']; $imgfile_type = strtolower(trim($imgfile_type)); $mdir = MyDate($cfg_addon_savetype, $nowtme); if(!is_dir($cfg_basedir.$activepath.\"/$mdir\")) { MkdirAll($cfg_basedir.$activepath.\"/$mdir\",$cfg_dir_purview); CloseFtp(); } $filename_name = $cuserLogin->getUserID().\'-\'.dd2char(MyDate(\"ymdHis\", $nowtme).mt_rand(100,999)); $filename = $mdir.\'/\'.$filename_name; $fs = explode(\'.\', $imgfile_name); $filename = $filename.\'.\'.$fs[count($fs)-1]; $filename_name = $filename_name.\'.\'.$fs[count($fs)-1]; $fullfilename = $cfg_basedir.$activepath.\"/\".$filename; move_uploaded_file($imgFile, $fullfilename) or die(\"上传文件到 $fullfilename 失败!\"); // 远程同步到附件服务器 if($cfg_multiserv[\'rmmedia\'] == 1) { if(!$ftp->_is_conn()) $ftp->connect($cfg_multiserv); //分析远程文件路径 $remotefile = str_replace(DEDEROOT, \'\', $fullfilename); $localfile = \'../..\'.$remotefile; //创建远程文件夹 $remotedir = preg_replace(\'/[^/]*.(jpg|gif|bmp|png)/\', \'\', $remotefile); $ftp->rmkdir($remotedir); $ftp->upload($localfile, $remotefile); } @unlink($imgfile); if(empty($resize)) { $resize = 0; } if($resize==1) { if(in_array($imgfile_type, $cfg_photo_typenames)) { ImageResize($fullfilename, $iwidth, $iheight); } } else { if(in_array($imgfile_type, $cfg_photo_typenames)) { if($ismarkup==1) WaterImg($fullfilename, \'up\'); } } $info = \'\'; $sizes[0] = 0; $sizes[1] = 0; if($dir_name == \'image\') { $sizes = getimagesize($fullfilename, $info); } $imgwidthValue = $sizes[0]; $imgheightValue = $sizes[1]; $imgsize = filesize($fullfilename); $media_type = $media_type[$dir_name]; //批量上传水印 if($photo_markup==1) WaterImg($fullfilename, \'up\'); //WaterImg($fullfilename, \'up\'); $inquery = \"INSERT INTO dede_uploads
(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid) VALUES (\'0\',\'$filename\',\'\".$activepath.\"/\".$filename.\"\',\'{$media_type}\',\'$imgwidthValue\',\'$imgheightValue\', \'0\',\'{$imgsize}\',\'{$nowtme}\',\'\".$cuserLogin->getUserID().\"\');
\"; $dsql->ExecuteNoneQuery($inquery); $fid = $dsql->GetLastID(); AddMyAddon($fid, $activepath.\'/\'.$filename); $CKUpload = isset($CKUpload)? $CKUpload : FALSE; $json = new Services_JSON(); echo $json->encode(array(\'error\' => 0, \'url\' => $activepath.\"/$mdir/\".$filename_name)); exit();
© 版权声明
1. 资源都是经过站长或作者收集测试修改后发布分享。如若转载请在文内以超链形式注明狐狸库文章出处,谢谢合作!
2. 本站除原创内容,其余所有内容均收集自互联网,仅限用于学习和研究目的,本站不对其内容的合法性承担任何责任。如有版权内容,请通知我们或作者删除,其版权均归原作者所有,本站虽力求保存原有版权信息,但因众多资源经多次转载,已无法确定其真实来源,或已将原有信息丢失,所以敬请原作者谅解!
3. 本站用户所发布的一切资源内容不代表本站立场,并不代表本站赞同其观点和对其真实性负责,若您对本站所载资源作品版权归属存有异议,请留言附说明联系邮箱,我们将在第一时间予以处理 ,同时向您表示歉意!为尊重作者版权,请购买原版作品,支持您喜欢的作者,谢谢!
4. 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客如有发现请立即向站长举报;本站资源文件大多存储在云盘,如发现链接或图片失效,请联系作者或站长及时更新。
THE END
请登录后查看评论内容