太阳成游戏网站CMS框架是一款PHP8高性能·简单易用的CMS开源开发框架,基于MIT开源许可协议发布,免费且不限制商业使用,是免费开源的产品,以万端互联为设计理念,支持的微信公众号、小程序、APP客户端、移动端网站、PC网站等多终端式管理系统。
联系官方销售客服
QQ1835022299
028-61286886
后台新闻修改新闻时候,默认编辑器是勾选自动提取描述。希望: 如果已经存在描述,则不在自动提取,若没有描述则自动提取,怎么修改
use_xss = 1; // 强制xss验证 $this->fieldtype = ['MEDIUMTEXT' => '']; $this->defaulttype = 'MEDIUMTEXT'; $this->rid = md5(FC_NOW_URL.\Phpcmf\Service::L('input')->get_user_agent().\Phpcmf\Service::L('input')->ip_address().\Phpcmf\Service::C()->uid); } /** * 字段相关属性参数 * * @param array $value 值 * @return string */ public function option($option) { $option['mode'] = isset($option['mode']) ? $option['mode'] : 1; $option['page'] = isset($option['page']) ? $option['page'] : 0; $option['tool'] = isset($option['tool']) ? $option['tool'] : '\'bold\', \'italic\', \'underline\''; $option['mode2'] = isset($option['mode2']) ? $option['mode2'] : $option['mode']; $option['tool2'] = isset($option['tool2']) ? $option['tool2'] : $option['tool']; $option['mode3'] = isset($option['mode3']) ? $option['mode3'] : $option['mode']; $option['tool3'] = isset($option['tool3']) ? $option['tool3'] : $option['tool']; $option['value'] = isset($option['value']) ? $option['value'] : ''; $option['width'] = isset($option['width']) ? $option['width'] : '100%'; $option['height'] = isset($option['height']) ? $option['height'] : 300; $option['fieldtype'] = isset($option['fieldtype']) ? $option['fieldtype'] : ''; $option['autofloat'] = isset($option['autofloat']) ? $option['autofloat'] : 0; $option['autoheight'] = isset($option['autoheight']) ? $option['autoheight'] : 0; $option['fieldlength'] = isset($option['fieldlength']) ? $option['fieldlength'] : ''; $option['simpleupload'] = isset($option['simpleupload']) ? $option['simpleupload'] : 0; $option['watermark'] = isset($option['watermark']) ? $option['watermark'] : ''; $option['enter'] = isset($option['enter']) ? $option['enter'] : ''; $option['show_bottom_boot'] = isset($option['show_bottom_boot']) ? $option['show_bottom_boot'] : ''; $wm = \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') ? ' '.dr_lang('图片水印').' '.dr_lang('系统强制开启水印').' ' : ' '.dr_lang('图片水印').' '.dr_lang('开启').' '.dr_lang('关闭').' '.dr_lang('上传的图片会加上水印图').' '; return [$this->_search_field().' '.dr_lang('回车换行符号').' '.dr_lang('br标签').' '.dr_lang('p标签').' '.dr_lang('选择回车换行的符号,默认是p标签换行').' '.dr_lang('下载远程图片').' '.dr_lang('自动').' '.dr_lang('手动').' '.dr_lang('自动模式下每一次编辑内容时都会下载图片;手动模式可以在编辑器下放工具栏中控制“是否下载”').' '.$wm. ' '.dr_lang('底部工具栏').' '.dr_lang('开启').' '.dr_lang('关闭').' '.dr_lang('编辑器底部工具栏,有截取字符选择、提取缩略图、下载远程图等控制按钮').' '.dr_lang("提取描述").' '.dr_lang("提取缩略图").' '.dr_lang("下载远程图").' '.dr_lang("去除站外链接").' '.dr_lang('固定编辑器图标栏').' '.dr_lang('开启').' '.dr_lang('关闭').' '.dr_lang('当开启时,在完整模式下,编辑器图标栏会固定在页面,不会随浏览器滚动').' '.dr_lang('过滤style属性').' '.dr_lang('全部过滤').' '.dr_lang('后台过滤').' '.dr_lang('前端过滤').' '.dr_lang('过滤编辑器里面的多余的style属性参数').' '.dr_lang('将div标签转换为p标签').' '.dr_lang('开启').' '.dr_lang('关闭').' '.dr_lang('将编辑器的div标签强制转换为p标签').' '.dr_lang('自动伸长高度').' '.dr_lang('开启').' '.dr_lang('关闭').' '.dr_lang('编辑器会自动增加高度').' '.dr_lang('分页标签').' '.dr_lang('开启').' '.dr_lang('关闭').' '.dr_lang('文章内容的分页功能').' '.dr_lang('后台编辑器模式').' '.dr_lang('完整').' '.dr_lang('精简').' '.dr_lang('自定义').' '.dr_lang('工具栏').' '.$option['tool'].' '.dr_lang('必须严格按照Ueditor工具栏格式\'source\', \'|\', \'undo\', \'redo\'').' '.dr_lang('前台编辑器模式').' '.dr_lang('完整').' '.dr_lang('精简').' '.dr_lang('自定义').' '.dr_lang('工具栏').' '.$option['tool2'].' '.dr_lang('必须严格按照Ueditor工具栏格式\'source\', \'|\', \'undo\', \'redo\'').' '.dr_lang('移动端编辑器模式').' '.dr_lang('完整').' '.dr_lang('精简').' '.dr_lang('自定义').' '.dr_lang('工具栏').' '.$option['tool3'].' '.dr_lang('必须严格按照Ueditor工具栏格式\'source\', \'|\', \'undo\', \'redo\'').' '.$this->attachment($option, 0).' '.dr_lang('图片补加后缀字符').' '.dr_lang('上传图片后自动为图片补加指定的后缀字符串').' '.dr_lang('默认存储值').' '.$option['value'].' '.$this->member_field_select().' '.dr_lang('用于字段为空时显示该填充值,并不会去主动变更数据库中的实际值;可以设置会员表字段,表示用当前登录会员信息来填充这个值').' '.$this->field_type($option['fieldtype'], $option['fieldlength']), ' '.dr_lang('控件宽度').' '.dr_lang('[整数]表示固定宽度;[整数%]表示百分比').' '.dr_lang('控件高度').' px ' ]; } /** * 字段入库值 */ public function insert_value($field) { //$table = []; $value = (string)\Phpcmf\Service::L('Field')->post[$field['fieldname']]; // 第一张作为缩略图 $slt = isset($_POST['data']['thumb']) && isset($_POST['is_auto_thumb_'.$field['fieldname']]) && !$_POST['data']['thumb'] && $_POST['is_auto_thumb_'.$field['fieldname']]; // 是否下载图片 $yct = $field['setting']['option']['down_img'] || (isset($_POST['is_auto_down_img_'.$field['fieldname']]) && $_POST['is_auto_down_img_'.$field['fieldname']]); // 下载远程图片 if ($yct || $slt) { $temp = preg_replace('//siU', '', $value); $temp = preg_replace('//siU', '', $temp); if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+)\\2/i", $temp, $imgs)) { $reps = array_unique($imgs[3]); usort($reps, function ($a, $b) { return dr_strlen($b) - dr_strlen($a); }); foreach ($reps as $img) { if (strpos($img, '/api/ueditor/') !== false) { continue; } $ext = $this->_get_image_ext($img); if (!$ext) { continue; } // 下载图片 if ($yct && strpos($img, 'http') === 0) { if (dr_is_app('mfile') && \Phpcmf\Service::M('mfile', 'mfile')->check_upload(\Phpcmf\Service::C()->uid)) { //用户存储空间已满 } else { // 正常下载 // 判断域名白名单 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $sites = \Phpcmf\Service::R(WRITEPATH.'config/domain_site.php'); if (isset($sites[$domain])) { // 过滤站点域名 } elseif (strpos(SYS_UPLOAD_URL, $domain) !== false) { // 过滤附件白名单 } else { $zj = 0; $remote = \Phpcmf\Service::C()->get_cache('attachment'); if ($remote) { foreach ($remote as $t) { if (strpos($t['url'], $domain) !== false) { $zj = 1; break; } } } if ($zj == 0) { // 可以下载文件 // 下载远程文件 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => html_entity_decode((string)$img), 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$this->rid); if ($att['code']) { // 归档成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 标记附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($this->rid, $att['code']); } } } } } } } // 缩略图 if ($img && $slt) { $_field = \Phpcmf\Service::L('form')->fields; if (isset($_field['thumb']) && $_field['thumb']['fieldtype'] == 'File' && !\Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb']) { if (!is_numeric($img)) { // 下载缩略图 // 判断域名白名单 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $file = dr_catcher_data($img, 8); if (!$file) { CI_DEBUG && log_message('debug', '服务器无法下载图片:'.$img); } else { // 尝试找一找附件库 $att = \Phpcmf\Service::M()->table('attachment')->like('related', 'ueditor')->where('filemd5', md5($file))->getRow(); if ($att) { $img = $att['id']; } else { // 下载归档 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => html_entity_decode((string)$img), 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, 'file_content' => $file, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$this->rid); if ($att['code']) { // 归档成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 标记附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($this->rid, $att['code']); } } } } } } \Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb'] = $_POST['data']['thumb'] = $img; } } } } } // 去除站外链接 if (isset($_POST['is_remove_a_'.$field['fieldname']]) && $_POST['is_remove_a_'.$field['fieldname']] && preg_match_all("/(.*)<\/a>/Ui", $value, $arrs)) { $sites = \Phpcmf\Service::R(WRITEPATH.'config/domain_site.php'); foreach ($arrs[2] as $i => $a) { if (strpos($a, ' ') !== false) { list($a) = explode(' ', $a); } $a = trim($a, '"'); $a = trim($a, '\''); $arr = parse_url($a); if ($arr && $arr['host'] && !isset($sites[$arr['host']])) { // 去除a标签 $value = str_replace($arrs[0][$i], $arrs[3][$i], $value); } } } /* // 默认过滤style标签 if (!isset($field['setting']['option']['remove_style']) || !$field['setting']['option']['remove_style'] || (IS_ADMIN && $field['setting']['option']['remove_style'] == 1) || (IS_MEMBER && $field['setting']['option']['remove_style'] == 2) ) { $value = preg_replace('/', '') */ // 提取描述信息 if (!$_POST['data']['description'] && isset($_POST['is_auto_description_'.$field['fieldname']]) && $_POST['is_auto_description_'.$field['fieldname']]) { \Phpcmf\Service::L('Field')->data[1]['description'] = $_POST['data']['description'] = dr_get_description($value); } // 替换分页 $value = str_replace('_ueditor_page_break_tag_', '', $value); $value = str_replace(' style=""', '', $value); // 入库操作 if (isset($_GET['is_verify_iframe']) && $_GET['is_verify_iframe']) { // 来自批量审核内容 \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = ($value); } else { \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = htmlspecialchars($value); } } // 获取远程附件扩展名 protected function _get_image_ext($url) { if (strlen($url) > 300) { return ''; } $arr = ['gif', 'jpg', 'jpeg', 'png', 'webp']; $ext = str_replace('.', '', trim(strtolower(strrchr($url, '.')), '.')); if ($ext && in_array($ext, $arr)) { return $ext; // 满足扩展名 } elseif ($ext && strlen($ext) < 4) { //CI_DEBUG && log_message('error', '此路径不是远程图片:'.$url); return ''; // 表示不是图片扩展名了 } foreach ($arr as $t) { if (stripos($url, $t) !== false) { return $t; } } $rt = getimagesize($url); if ($rt && $rt['mime']) { foreach ($arr as $t) { if (stripos($rt['mime'], $t) !== false) { return $t; } } } CI_DEBUG && log_message('debug', '服务器无法获取远程图片的扩展名:'.dr_safe_replace($url)); return ''; } /** * 获取附件id */ public function get_attach_id($value) { return \Phpcmf\Service::M('Attachment')->get_ueditor_aid($this->rid); } /** * 附件处理 */ public function attach($data, $_data) { return [\Phpcmf\Service::M('Attachment')->get_ueditor_aid($this->rid, true), NULL]; } /** * 字段输出 * * @param array $value 数据库值 * @return string */ public function output($value) { return dr_ueditor_html($value, isset(\Phpcmf\Service::L('Field')->data['title']) ? \Phpcmf\Service::L('Field')->data['title'] : ''); } /** * 字段显示 * * @return string */ public function show($field, $value = null) { $html = ' '.htmlspecialchars_decode((string)$value).' '; return $this->input_format($field['fieldname'], $field['name'], $html); } /** * 字段表单输入 * */ public function input($field, $value = '') { // 字段禁止修改时就返回显示字符串 if ($this->_not_edit($field, $value)) { return $this->show($field, $value); } // 字段存储名称 $name = $field['fieldname']; // 字段显示名称 $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']); if (isset($_GET['is_verify_iframe']) && $_GET['is_verify_iframe']) { // 来自批量审核内容 $str = ''.htmlspecialchars($value).''; return $this->input_format($field['fieldname'], $text, $str); } // 表单宽度设置 $width = \Phpcmf\Service::IS_MOBILE_USER() ? '100%' : ($field['setting']['option']['width'] ? $field['setting']['option']['width'] : '100%'); // 表单高度设置 $height = $field['setting']['option']['height'] ? $field['setting']['option']['height'] : '300'; // 字段提示信息 $tips = $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].'' : ''; // 字段默认值 $value = htmlspecialchars_decode((string)(dr_strlen($value) ? $value : $this->get_default_value($field['setting']['option']['value']))); // 输出 $str = ''; // 防止重复加载JS if (!$this->is_load_js($field['fieldtype'])) { $str.= ' '; $this->set_load_js($field['fieldtype'], 1); } $tool = IS_ADMIN ? "'fullscreen', 'source', '|', " : ''; // 后台引用时显示html工具栏 // 编辑器模式 if (\Phpcmf\Service::IS_MOBILE_USER()) { $mode = $field['setting']['option']['mode3'] ? $field['setting']['option']['mode3'] : $field['setting']['option']['mode']; $field['setting']['option']['tool'] = $field['setting']['option']['tool3'] ? $field['setting']['option']['tool3'] : $field['setting']['option']['tool']; } elseif (IS_ADMIN) { $mode = $field['setting']['option']['mode']; } else { $mode = $field['setting']['option']['mode2'] ? $field['setting']['option']['mode2'] : $field['setting']['option']['mode']; $field['setting']['option']['tool'] = $field['setting']['option']['tool2'] ? $field['setting']['option']['tool2'] : $field['setting']['option']['tool']; } // 编辑器工具 $pagebreak = (int)$field['setting']['option']['page'] ? ', \'pagebreak\'' : ''; switch ($mode) { case 3: // 自定义 $tool.= trim($field['setting']['option']['tool'], ',').$pagebreak; break; case 2: // 精简 $tool.= "'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough','|', 'pasteplain', 'forecolor', 'fontfamily', 'fontsize','|', 'link', 'insertimage'$pagebreak"; break; default: // 完整模式 $tool_code = \Phpcmf\Service::R(ROOTPATH.'api/ueditor/php/tool.php'); if (!$tool_code) { $tool.= "'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|', 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|', 'directionalityltr', 'directionalityrtl', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|', 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'attachment', 'map', 'insertframe', 'insertcode', 'template', 'background', '|', 'horizontal', 'date', 'time', 'spechars', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|', 'print', 'preview', 'searchreplace', 'drafts'"; } else { $tool.= str_replace([PHP_EOL, chr(13), chr(10)], ' ', $tool_code); } $tool.= "$pagebreak"; break; } $tool = str_replace(['"simpleupload",', ',"simpleupload"',"'simpleupload',", ",'simpleupload'"], '', $tool); if (!$field['setting']['option']['image_endstr']) { $field['setting']['option']['image_endstr'] = ''; } $str.= ""; $js = \Phpcmf\Service::L('js_packer'); $str.= $js->pack(" ", 0); if (isset($field['setting']['option']['show_bottom_boot']) && $field['setting']['option']['show_bottom_boot']) { $str.= ''; $str.= ' '.dr_lang('提取第一个图片为缩略图').' '; $str.= ' '.dr_lang('提取内容作为描述信息').' '; if (!$field['setting']['option']['down_img']) { $str.= ' '.dr_lang('下载远程图片').' '; } $str.= ' '.dr_lang('去除站外链接').' '; $str.= ''; } return $this->input_format($name, $text, $str.$tips); } } 满意答案
'.$this->member_field_select().' '.dr_lang('用于字段为空时显示该填充值,并不会去主动变更数据库中的实际值;可以设置会员表字段,表示用当前登录会员信息来填充这个值').'
/siU', '', $value); $temp = preg_replace('//siU', '', $temp); if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+)\\2/i", $temp, $imgs)) { $reps = array_unique($imgs[3]); usort($reps, function ($a, $b) { return dr_strlen($b) - dr_strlen($a); }); foreach ($reps as $img) { if (strpos($img, '/api/ueditor/') !== false) { continue; } $ext = $this->_get_image_ext($img); if (!$ext) { continue; } // 下载图片 if ($yct && strpos($img, 'http') === 0) { if (dr_is_app('mfile') && \Phpcmf\Service::M('mfile', 'mfile')->check_upload(\Phpcmf\Service::C()->uid)) { //用户存储空间已满 } else { // 正常下载 // 判断域名白名单 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $sites = \Phpcmf\Service::R(WRITEPATH.'config/domain_site.php'); if (isset($sites[$domain])) { // 过滤站点域名 } elseif (strpos(SYS_UPLOAD_URL, $domain) !== false) { // 过滤附件白名单 } else { $zj = 0; $remote = \Phpcmf\Service::C()->get_cache('attachment'); if ($remote) { foreach ($remote as $t) { if (strpos($t['url'], $domain) !== false) { $zj = 1; break; } } } if ($zj == 0) { // 可以下载文件 // 下载远程文件 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => html_entity_decode((string)$img), 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$this->rid); if ($att['code']) { // 归档成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 标记附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($this->rid, $att['code']); } } } } } } } // 缩略图 if ($img && $slt) { $_field = \Phpcmf\Service::L('form')->fields; if (isset($_field['thumb']) && $_field['thumb']['fieldtype'] == 'File' && !\Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb']) { if (!is_numeric($img)) { // 下载缩略图 // 判断域名白名单 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $file = dr_catcher_data($img, 8); if (!$file) { CI_DEBUG && log_message('debug', '服务器无法下载图片:'.$img); } else { // 尝试找一找附件库 $att = \Phpcmf\Service::M()->table('attachment')->like('related', 'ueditor')->where('filemd5', md5($file))->getRow(); if ($att) { $img = $att['id']; } else { // 下载归档 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => html_entity_decode((string)$img), 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, 'file_content' => $file, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$this->rid); if ($att['code']) { // 归档成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 标记附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($this->rid, $att['code']); } } } } } } \Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb'] = $_POST['data']['thumb'] = $img; } } } } } // 去除站外链接 if (isset($_POST['is_remove_a_'.$field['fieldname']]) && $_POST['is_remove_a_'.$field['fieldname']] && preg_match_all("/(.*)<\/a>/Ui", $value, $arrs)) { $sites = \Phpcmf\Service::R(WRITEPATH.'config/domain_site.php'); foreach ($arrs[2] as $i => $a) { if (strpos($a, ' ') !== false) { list($a) = explode(' ', $a); } $a = trim($a, '"'); $a = trim($a, '\''); $arr = parse_url($a); if ($arr && $arr['host'] && !isset($sites[$arr['host']])) { // 去除a标签 $value = str_replace($arrs[0][$i], $arrs[3][$i], $value); } } } /* // 默认过滤style标签 if (!isset($field['setting']['option']['remove_style']) || !$field['setting']['option']['remove_style'] || (IS_ADMIN && $field['setting']['option']['remove_style'] == 1) || (IS_MEMBER && $field['setting']['option']['remove_style'] == 2) ) { $value = preg_replace('/', '') */ // 提取描述信息 if (!$_POST['data']['description'] && isset($_POST['is_auto_description_'.$field['fieldname']]) && $_POST['is_auto_description_'.$field['fieldname']]) { \Phpcmf\Service::L('Field')->data[1]['description'] = $_POST['data']['description'] = dr_get_description($value); } // 替换分页 $value = str_replace('_ueditor_page_break_tag_', '', $value); $value = str_replace(' style=""', '', $value); // 入库操作 if (isset($_GET['is_verify_iframe']) && $_GET['is_verify_iframe']) { // 来自批量审核内容 \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = ($value); } else { \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = htmlspecialchars($value); } } // 获取远程附件扩展名 protected function _get_image_ext($url) { if (strlen($url) > 300) { return ''; } $arr = ['gif', 'jpg', 'jpeg', 'png', 'webp']; $ext = str_replace('.', '', trim(strtolower(strrchr($url, '.')), '.')); if ($ext && in_array($ext, $arr)) { return $ext; // 满足扩展名 } elseif ($ext && strlen($ext) < 4) { //CI_DEBUG && log_message('error', '此路径不是远程图片:'.$url); return ''; // 表示不是图片扩展名了 } foreach ($arr as $t) { if (stripos($url, $t) !== false) { return $t; } } $rt = getimagesize($url); if ($rt && $rt['mime']) { foreach ($arr as $t) { if (stripos($rt['mime'], $t) !== false) { return $t; } } } CI_DEBUG && log_message('debug', '服务器无法获取远程图片的扩展名:'.dr_safe_replace($url)); return ''; } /** * 获取附件id */ public function get_attach_id($value) { return \Phpcmf\Service::M('Attachment')->get_ueditor_aid($this->rid); } /** * 附件处理 */ public function attach($data, $_data) { return [\Phpcmf\Service::M('Attachment')->get_ueditor_aid($this->rid, true), NULL]; } /** * 字段输出 * * @param array $value 数据库值 * @return string */ public function output($value) { return dr_ueditor_html($value, isset(\Phpcmf\Service::L('Field')->data['title']) ? \Phpcmf\Service::L('Field')->data['title'] : ''); } /** * 字段显示 * * @return string */ public function show($field, $value = null) { $html = ' '.htmlspecialchars_decode((string)$value).' '; return $this->input_format($field['fieldname'], $field['name'], $html); } /** * 字段表单输入 * */ public function input($field, $value = '') { // 字段禁止修改时就返回显示字符串 if ($this->_not_edit($field, $value)) { return $this->show($field, $value); } // 字段存储名称 $name = $field['fieldname']; // 字段显示名称 $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']); if (isset($_GET['is_verify_iframe']) && $_GET['is_verify_iframe']) { // 来自批量审核内容 $str = ''.htmlspecialchars($value).''; return $this->input_format($field['fieldname'], $text, $str); } // 表单宽度设置 $width = \Phpcmf\Service::IS_MOBILE_USER() ? '100%' : ($field['setting']['option']['width'] ? $field['setting']['option']['width'] : '100%'); // 表单高度设置 $height = $field['setting']['option']['height'] ? $field['setting']['option']['height'] : '300'; // 字段提示信息 $tips = $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].'' : ''; // 字段默认值 $value = htmlspecialchars_decode((string)(dr_strlen($value) ? $value : $this->get_default_value($field['setting']['option']['value']))); // 输出 $str = ''; // 防止重复加载JS if (!$this->is_load_js($field['fieldtype'])) { $str.= ' '; $this->set_load_js($field['fieldtype'], 1); } $tool = IS_ADMIN ? "'fullscreen', 'source', '|', " : ''; // 后台引用时显示html工具栏 // 编辑器模式 if (\Phpcmf\Service::IS_MOBILE_USER()) { $mode = $field['setting']['option']['mode3'] ? $field['setting']['option']['mode3'] : $field['setting']['option']['mode']; $field['setting']['option']['tool'] = $field['setting']['option']['tool3'] ? $field['setting']['option']['tool3'] : $field['setting']['option']['tool']; } elseif (IS_ADMIN) { $mode = $field['setting']['option']['mode']; } else { $mode = $field['setting']['option']['mode2'] ? $field['setting']['option']['mode2'] : $field['setting']['option']['mode']; $field['setting']['option']['tool'] = $field['setting']['option']['tool2'] ? $field['setting']['option']['tool2'] : $field['setting']['option']['tool']; } // 编辑器工具 $pagebreak = (int)$field['setting']['option']['page'] ? ', \'pagebreak\'' : ''; switch ($mode) { case 3: // 自定义 $tool.= trim($field['setting']['option']['tool'], ',').$pagebreak; break; case 2: // 精简 $tool.= "'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough','|', 'pasteplain', 'forecolor', 'fontfamily', 'fontsize','|', 'link', 'insertimage'$pagebreak"; break; default: // 完整模式 $tool_code = \Phpcmf\Service::R(ROOTPATH.'api/ueditor/php/tool.php'); if (!$tool_code) { $tool.= "'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|', 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|', 'directionalityltr', 'directionalityrtl', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|', 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'attachment', 'map', 'insertframe', 'insertcode', 'template', 'background', '|', 'horizontal', 'date', 'time', 'spechars', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|', 'print', 'preview', 'searchreplace', 'drafts'"; } else { $tool.= str_replace([PHP_EOL, chr(13), chr(10)], ' ', $tool_code); } $tool.= "$pagebreak"; break; } $tool = str_replace(['"simpleupload",', ',"simpleupload"',"'simpleupload',", ",'simpleupload'"], '', $tool); if (!$field['setting']['option']['image_endstr']) { $field['setting']['option']['image_endstr'] = ''; } $str.= ""; $js = \Phpcmf\Service::L('js_packer'); $str.= $js->pack(" ", 0); if (isset($field['setting']['option']['show_bottom_boot']) && $field['setting']['option']['show_bottom_boot']) { $str.= ''; $str.= ' '.dr_lang('提取第一个图片为缩略图').' '; $str.= ' '.dr_lang('提取内容作为描述信息').' '; if (!$field['setting']['option']['down_img']) { $str.= ' '.dr_lang('下载远程图片').' '; } $str.= ' '.dr_lang('去除站外链接').' '; $str.= ''; } return $this->input_format($name, $text, $str.$tips); } } 满意答案
/siU', '', $temp); if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+)\\2/i", $temp, $imgs)) { $reps = array_unique($imgs[3]); usort($reps, function ($a, $b) { return dr_strlen($b) - dr_strlen($a); }); foreach ($reps as $img) { if (strpos($img, '/api/ueditor/') !== false) { continue; } $ext = $this->_get_image_ext($img); if (!$ext) { continue; } // 下载图片 if ($yct && strpos($img, 'http') === 0) { if (dr_is_app('mfile') && \Phpcmf\Service::M('mfile', 'mfile')->check_upload(\Phpcmf\Service::C()->uid)) { //用户存储空间已满 } else { // 正常下载 // 判断域名白名单 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $sites = \Phpcmf\Service::R(WRITEPATH.'config/domain_site.php'); if (isset($sites[$domain])) { // 过滤站点域名 } elseif (strpos(SYS_UPLOAD_URL, $domain) !== false) { // 过滤附件白名单 } else { $zj = 0; $remote = \Phpcmf\Service::C()->get_cache('attachment'); if ($remote) { foreach ($remote as $t) { if (strpos($t['url'], $domain) !== false) { $zj = 1; break; } } } if ($zj == 0) { // 可以下载文件 // 下载远程文件 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => html_entity_decode((string)$img), 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$this->rid); if ($att['code']) { // 归档成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 标记附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($this->rid, $att['code']); } } } } } } } // 缩略图 if ($img && $slt) { $_field = \Phpcmf\Service::L('form')->fields; if (isset($_field['thumb']) && $_field['thumb']['fieldtype'] == 'File' && !\Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb']) { if (!is_numeric($img)) { // 下载缩略图 // 判断域名白名单 $arr = parse_url($img); $domain = $arr['host']; if ($domain) { $file = dr_catcher_data($img, 8); if (!$file) { CI_DEBUG && log_message('debug', '服务器无法下载图片:'.$img); } else { // 尝试找一找附件库 $att = \Phpcmf\Service::M()->table('attachment')->like('related', 'ueditor')->where('filemd5', md5($file))->getRow(); if ($att) { $img = $att['id']; } else { // 下载归档 $rt = \Phpcmf\Service::L('upload')->down_file([ 'url' => html_entity_decode((string)$img), 'timeout' => 5, 'watermark' => \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark', 'ueditor') || $field['setting']['option']['watermark'] ? 1 : 0, 'attachment' => \Phpcmf\Service::M('Attachment')->get_attach_info(intval($field['setting']['option']['attachment']), $field['setting']['option']['image_reduce']), 'file_ext' => $ext, 'file_content' => $file, ]); if ($rt['code']) { $att = \Phpcmf\Service::M('Attachment')->save_data($rt['data'], 'ueditor:'.$this->rid); if ($att['code']) { // 归档成功 $value = str_replace($img, $rt['data']['url'], $value); $img = $att['code']; // 标记附件 \Phpcmf\Service::M('Attachment')->save_ueditor_aid($this->rid, $att['code']); } } } } } } \Phpcmf\Service::L('Field')->data[$_field['thumb']['ismain']]['thumb'] = $_POST['data']['thumb'] = $img; } } } } } // 去除站外链接 if (isset($_POST['is_remove_a_'.$field['fieldname']]) && $_POST['is_remove_a_'.$field['fieldname']] && preg_match_all("/(.*)<\/a>/Ui", $value, $arrs)) { $sites = \Phpcmf\Service::R(WRITEPATH.'config/domain_site.php'); foreach ($arrs[2] as $i => $a) { if (strpos($a, ' ') !== false) { list($a) = explode(' ', $a); } $a = trim($a, '"'); $a = trim($a, '\''); $arr = parse_url($a); if ($arr && $arr['host'] && !isset($sites[$arr['host']])) { // 去除a标签 $value = str_replace($arrs[0][$i], $arrs[3][$i], $value); } } } /* // 默认过滤style标签 if (!isset($field['setting']['option']['remove_style']) || !$field['setting']['option']['remove_style'] || (IS_ADMIN && $field['setting']['option']['remove_style'] == 1) || (IS_MEMBER && $field['setting']['option']['remove_style'] == 2) ) { $value = preg_replace('/', '') */ // 提取描述信息 if (!$_POST['data']['description'] && isset($_POST['is_auto_description_'.$field['fieldname']]) && $_POST['is_auto_description_'.$field['fieldname']]) { \Phpcmf\Service::L('Field')->data[1]['description'] = $_POST['data']['description'] = dr_get_description($value); } // 替换分页 $value = str_replace('_ueditor_page_break_tag_', '', $value); $value = str_replace(' style=""', '', $value); // 入库操作 if (isset($_GET['is_verify_iframe']) && $_GET['is_verify_iframe']) { // 来自批量审核内容 \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = ($value); } else { \Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = htmlspecialchars($value); } } // 获取远程附件扩展名 protected function _get_image_ext($url) { if (strlen($url) > 300) { return ''; } $arr = ['gif', 'jpg', 'jpeg', 'png', 'webp']; $ext = str_replace('.', '', trim(strtolower(strrchr($url, '.')), '.')); if ($ext && in_array($ext, $arr)) { return $ext; // 满足扩展名 } elseif ($ext && strlen($ext) < 4) { //CI_DEBUG && log_message('error', '此路径不是远程图片:'.$url); return ''; // 表示不是图片扩展名了 } foreach ($arr as $t) { if (stripos($url, $t) !== false) { return $t; } } $rt = getimagesize($url); if ($rt && $rt['mime']) { foreach ($arr as $t) { if (stripos($rt['mime'], $t) !== false) { return $t; } } } CI_DEBUG && log_message('debug', '服务器无法获取远程图片的扩展名:'.dr_safe_replace($url)); return ''; } /** * 获取附件id */ public function get_attach_id($value) { return \Phpcmf\Service::M('Attachment')->get_ueditor_aid($this->rid); } /** * 附件处理 */ public function attach($data, $_data) { return [\Phpcmf\Service::M('Attachment')->get_ueditor_aid($this->rid, true), NULL]; } /** * 字段输出 * * @param array $value 数据库值 * @return string */ public function output($value) { return dr_ueditor_html($value, isset(\Phpcmf\Service::L('Field')->data['title']) ? \Phpcmf\Service::L('Field')->data['title'] : ''); } /** * 字段显示 * * @return string */ public function show($field, $value = null) { $html = ' '.htmlspecialchars_decode((string)$value).' '; return $this->input_format($field['fieldname'], $field['name'], $html); } /** * 字段表单输入 * */ public function input($field, $value = '') { // 字段禁止修改时就返回显示字符串 if ($this->_not_edit($field, $value)) { return $this->show($field, $value); } // 字段存储名称 $name = $field['fieldname']; // 字段显示名称 $text = ($field['setting']['validate']['required'] ? ' * ' : '').dr_lang($field['name']); if (isset($_GET['is_verify_iframe']) && $_GET['is_verify_iframe']) { // 来自批量审核内容 $str = ''.htmlspecialchars($value).''; return $this->input_format($field['fieldname'], $text, $str); } // 表单宽度设置 $width = \Phpcmf\Service::IS_MOBILE_USER() ? '100%' : ($field['setting']['option']['width'] ? $field['setting']['option']['width'] : '100%'); // 表单高度设置 $height = $field['setting']['option']['height'] ? $field['setting']['option']['height'] : '300'; // 字段提示信息 $tips = $field['setting']['validate']['tips'] ? ''.$field['setting']['validate']['tips'].'' : ''; // 字段默认值 $value = htmlspecialchars_decode((string)(dr_strlen($value) ? $value : $this->get_default_value($field['setting']['option']['value']))); // 输出 $str = ''; // 防止重复加载JS if (!$this->is_load_js($field['fieldtype'])) { $str.= ' '; $this->set_load_js($field['fieldtype'], 1); } $tool = IS_ADMIN ? "'fullscreen', 'source', '|', " : ''; // 后台引用时显示html工具栏 // 编辑器模式 if (\Phpcmf\Service::IS_MOBILE_USER()) { $mode = $field['setting']['option']['mode3'] ? $field['setting']['option']['mode3'] : $field['setting']['option']['mode']; $field['setting']['option']['tool'] = $field['setting']['option']['tool3'] ? $field['setting']['option']['tool3'] : $field['setting']['option']['tool']; } elseif (IS_ADMIN) { $mode = $field['setting']['option']['mode']; } else { $mode = $field['setting']['option']['mode2'] ? $field['setting']['option']['mode2'] : $field['setting']['option']['mode']; $field['setting']['option']['tool'] = $field['setting']['option']['tool2'] ? $field['setting']['option']['tool2'] : $field['setting']['option']['tool']; } // 编辑器工具 $pagebreak = (int)$field['setting']['option']['page'] ? ', \'pagebreak\'' : ''; switch ($mode) { case 3: // 自定义 $tool.= trim($field['setting']['option']['tool'], ',').$pagebreak; break; case 2: // 精简 $tool.= "'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough','|', 'pasteplain', 'forecolor', 'fontfamily', 'fontsize','|', 'link', 'insertimage'$pagebreak"; break; default: // 完整模式 $tool_code = \Phpcmf\Service::R(ROOTPATH.'api/ueditor/php/tool.php'); if (!$tool_code) { $tool.= "'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|', 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|', 'directionalityltr', 'directionalityrtl', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|', 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'attachment', 'map', 'insertframe', 'insertcode', 'template', 'background', '|', 'horizontal', 'date', 'time', 'spechars', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|', 'print', 'preview', 'searchreplace', 'drafts'"; } else { $tool.= str_replace([PHP_EOL, chr(13), chr(10)], ' ', $tool_code); } $tool.= "$pagebreak"; break; } $tool = str_replace(['"simpleupload",', ',"simpleupload"',"'simpleupload',", ",'simpleupload'"], '', $tool); if (!$field['setting']['option']['image_endstr']) { $field['setting']['option']['image_endstr'] = ''; } $str.= ""; $js = \Phpcmf\Service::L('js_packer'); $str.= $js->pack(" ", 0); if (isset($field['setting']['option']['show_bottom_boot']) && $field['setting']['option']['show_bottom_boot']) { $str.= ''; $str.= ' '.dr_lang('提取第一个图片为缩略图').' '; $str.= ' '.dr_lang('提取内容作为描述信息').' '; if (!$field['setting']['option']['down_img']) { $str.= ' '.dr_lang('下载远程图片').' '; } $str.= ' '.dr_lang('去除站外链接').' '; $str.= ''; } return $this->input_format($name, $text, $str.$tips); } } 满意答案