/** * 提取关键字 */ function getKw($data) { $data = fn_geturl('http://keyword.discuz.com/related_kw.html?ics=utf-8&ocs=utf-8&title=' . rawurlencode($data) . '&content=' . rawurlencode($data)); if ($data) { $parser = xml_parser_create(); $kws = array(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $values, $index); xml_parser_free($parser); foreach ($values as $valuearray) { $kw = trim($valuearray['value']); if (strlen($kw) > 5 && ($valuearray['tag'] == 'kw' || $valuearray['tag'] == 'ekw')) { $kws[] = $kw; } } return implode(',', $kws); } }
/** * 下载远程图片 */ private function download_images($imgs, $uid = 0, $size = 0) { $imgs = array_unique($imgs); //去除重复图片 $regex = $replace = array(); $path = $uid ? 'uploadfiles/member/' . $uid . '/image/' . date('Ym') . '/' : 'uploadfiles/image/' . date('Ym') . '/'; $this->mkdirs($path); //水印 $config = App::get_config(); if ($config['SITE_WATERMARK']) { $image = Controller::instance('image_lib'); } foreach ($imgs as $img) { if ($uid && $size && count_member_size($uid) > $size * 1024 * 1024) { continue; } if (strpos($img, SITE_URL) !== false || substr($img, 0, 7) != 'http://') { continue; } //下载图片 $fileext = strtolower(trim(substr(strrchr($img, '.'), 1, 10))); //扩展名 $name = $path . md5($img . time()) . '.' . $fileext; $content = fn_geturl($img); if (empty($content)) { continue; } if (file_put_contents($name, $content)) { if ($config['SITE_WATERMARK']) { $image = Controller::instance('image_lib'); if ($config['SITE_WATERMARK'] == 1) { $image->set_watermark_alpha($config['SITE_WATERMARK_ALPHA']); $image->make_image_watermark($name, $config['SITE_WATERMARK_POS'], $config['SITE_WATERMARK_IMAGE']); } else { $image->set_text_content($config['SITE_WATERMARK_TEXT']); $image->make_text_watermark($name, $config['SITE_WATERMARK_POS'], $config['SITE_WATERMARK_SIZE']); } } $regex[] = $img; $replace[] = $name; } } return count($regex) > 0 ? array('regex' => $regex, 'replace' => $replace) : null; }
/** * 下载插件 */ public function downAction() { if (!@is_writable(PLUGIN_DIR)) { $this->adminMsg(lang('a-plu-22', array('1' => $this->site['PLUGIN_DIR']))); } $down = urldecode($this->get('url')); $dir = $this->get('dir'); $mark = $this->get('mark'); $install = $this->get('install'); if (empty($down) || empty($dir)) { $this->adminMsg(lang('a-plu-23')); } if ($result = fn_check_url()) { $this->adminMsg($result . '<br><br> <a href="http://bbs.finecms.net/forum.php?mod=viewthread&tid=100&extra=" target="_blank" style="font-size:14px">' . lang('a-plu-24') . '</a>'); exit; } if (empty($install) && is_dir(PLUGIN_DIR . $dir)) { $this->adminMsg(lang('a-plu-25', array('1' => $dir))); } if ($install) { //升级信息检测 $data = $this->plugin->getOne('dir=?', $dir); if (empty($data)) { $this->adminMsg(lang('a-plu-26', array('1' => $dir))); } if ($data['markid'] != $mark) { $this->adminMsg(lang('a-plu-27', array('1' => $dir))); } } $path = APP_ROOT . 'cache' . DIRECTORY_SEPARATOR . 'down' . DIRECTORY_SEPARATOR; if (!is_dir($path)) { //创建下载文件临时目录 mkdir($path, 0777); } //保存到本地地址 $zip_path = $path . $dir . '.zip'; //测试目录 $testzip_path = $path . $dir; //下载压缩包 @file_put_contents($zip_path, fn_geturl($down)); if (filesize($zip_path) == 0) { $this->adminMsg(lang('a-plu-28')); } //解压缩 $zip = $this->instance('pclzip'); $zip->PclFile($zip_path); if ($zip->extract(PCLZIP_OPT_PATH, $testzip_path, PCLZIP_OPT_REPLACE_NEWER) == 0) { @unlink($zip_path); $this->delDir($testzip_path); $this->adminMsg('Error : ' . $zip->errorInfo(true)); } else { if (!file_exists($testzip_path . DIRECTORY_SEPARATOR . 'config.php')) { @unlink($zip_path); $this->delDir($testzip_path); $this->adminMsg(lang('a-plu-29')); } //配置文件验证 if (filesize($testzip_path . DIRECTORY_SEPARATOR . 'config.php') == 0) { @unlink($zip_path); $this->delDir($testzip_path); $this->adminMsg(lang('a-plu-30')); } //md5文件校验 $md5_file = $testzip_path . 'md5.php'; if (file_exists($md5_file)) { if (filesize($md5_file) == 0) { @unlink($zip_path); $this->delDir($testzip_path); $this->adminMsg(lang('a-plu-31')); } $md5s = (require $md5_file); if (is_array($md5s)) { foreach ($md5s as $md5 => $file) { if (file_exists($testzip_path . $file)) { if (strtolower(md5(file_get_contents($testzip_path . $file))) != $md5) { @unlink($zip_path); $this->delDir($testzip_path); $this->adminMsg(lang('a-plu-31')); } } } } else { @unlink($zip_path); $this->delDir($testzip_path); $this->adminMsg(lang('a-plu-31')); } } $this->delDir($testzip_path); } //解压升级包 if ($zip->extract(PCLZIP_OPT_PATH, PLUGIN_DIR . $dir, PCLZIP_OPT_REPLACE_NEWER) == 0) { @unlink($zip_path); $this->adminMsg('Error : ' . $zip->errorInfo(true) . '<br>' . lang('a-plu-32')); } if (empty($install)) { @unlink($zip_path); if (is_dir(PLUGIN_DIR . $dir) && is_file(PLUGIN_DIR . $dir . DIRECTORY_SEPARATOR . 'config.php')) { $this->adminMsg(lang('a-plu-33'), url('admin/plugin/'), 3, 1, 1); } else { $this->adminMsg(lang('a-plu-34')); } } //升级插件 if (!@is_writable($this->dir . $dir . DIRECTORY_SEPARATOR . 'config.php')) { $this->adminMsg(lang('a-plu-35')); } $config = (require $this->dir . $dir . DIRECTORY_SEPARATOR . 'config.php'); $update = array('author' => $config['author'], 'version' => $config['version'], 'description' => $config['description']); $this->plugin->update($update, 'pluginid=' . $data['pluginid']); $this->adminMsg(lang('a-plu-36'), url('admin/plugin/'), 3, 1, 1); }
function ueditor_editor($name, $content = '', $field = '') { $setting = isset($field['setting']) ? string2array($field['setting']) : $field; //配置 $content = is_null($content[0]) && isset($setting['default']) ? get_content_value($setting['default']) : $content[0]; $w = isset($setting['width']) && $setting['width'] ? $setting['width'] : '98'; $h = isset($setting['height']) && $setting['height'] ? $setting['height'] : '400'; $id = $name; $type = isset($setting['type']) && $setting['type'] ? 1 : (!isset($setting['type']) ? 1 : 0); $str = ''; $page = isset($setting['pagebreak']) || !isset($setting['system']) && $name == 'content' ? ",'snapscreen','pagebreak'" : ''; $source = strpos($_SERVER['QUERY_STRING'], 's=' . ADMIN_NAMESPACE) === false || strpos($_SERVER['QUERY_STRING'], 's=' . ADMIN_NAMESPACE) === false ? '' : "'source', '|',"; $appkey = file_exists(EXTENSION_DIR . 'ueditor/appkey.txt') ? fn_geturl(EXTENSION_DIR . 'ueditor/appkey.txt') : ''; if (!defined('FINECMS_EDITOR_LD')) { //加载相关js $str .= ' <script type="text/javascript">var ueditor_url="' . EXT_PATH . 'ueditor/";</script> <script type="text/javascript" charset="utf-8" src="' . EXT_PATH . 'ueditor/editor_config.js"></script> <script type="text/javascript" charset="utf-8" src="' . EXT_PATH . 'ueditor/editor_all.js"></script> '; define('FINECMS_EDITOR_LD', 1); //防止重复加载JS } if ($type) { //完整模式 $str .= "\n\t\t<script type=\"text/plain\" id=\"fc_" . $id . "\" name=\"data[" . $id . "]\" style=\"width:" . $w . "%\">" . htmlspecialchars_decode($content) . "</script>\n\t\t<script type=\"text/javascript\">\n\t\t\tvar editorOption = {\n\t\t\t UEDITOR_HOME_URL: ueditor_url,\n\t\t\t\ttoolbars:[[\n\t\t\t\t" . $source . " 'undo', 'redo', '|',\n 'bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch','autotypeset', '|',\n 'blockquote', '|', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist','selectall', 'cleardoc', '|', 'customstyle',\n 'paragraph', '|','rowspacingtop', 'rowspacingbottom','lineheight', '|','fontfamily', 'fontsize', '|',\n 'directionalityltr', 'directionalityrtl', '|', '', 'indent', '|',\n 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','touppercase','tolowercase','|',\n 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright',\n 'imagecenter', '|', 'insertimage', 'emotion', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe','highlightcode','webapp','template','background', '|',\n 'horizontal', 'date', 'time', 'spechars','|',\n 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',\n 'print', 'preview', 'searchreplace'," . $page . ",'help'\n\t\t\t\t]],\n\t\t\t\tlang: \"" . SYS_LANGUAGE . "\",\n\t\t\t\tinitialContent:'',\n\t\t\t\tautoClearinitialContent:false,\n\t\t\t\tminFrameHeight:" . $h . ",\n\t\t\t\tinitialFrameHeight: " . $h . ",\n\t\t\t\tinitialFrameWidth: '" . $w . "%',\n\t\t\t\tscaleEnabled:false,\n\t\t\t\tallHtmlEnabled:false,\n\t\t\t\tautoFloatEnabled:false,\n\t\t\t\tautoHeightEnabled:false,\n\t\t\t\tpageBreakTag: \"{-page-}\",\n\t\t\t\tinitialStyle:'body{font-size:14px;line-height:20px;}',\n\t\t\t\timageUrl:\"" . url('attachment/ueditor_upload') . "&dir=image&document=\"+finecms_admin_document,\n imagePath:\"" . SITE_PATH . "\",\n\t\t\t\timageManagerUrl:\"" . url('attachment/ueditor_manager', array('dir' => 'image')) . "\",\n imageManagerPath:\"" . SITE_PATH . "\",\n\t\t\t\tfileUrl:\"" . url('attachment/ueditor_upload') . "&dir=file&document=\"+finecms_admin_document,\n\t\t\t\tfilePath:\"" . SITE_PATH . "\",\n\t\t\t\twebAppKey:\"" . $appkey . "\",\n\t\t\t\twordCount:false,\n\t\t\t\tmaximumWords:9999999,\n\t\t\t\tgetMovieUrl:ueditor_url+\"getMovie.php\",\n\t\t\t\tcatchRemoteImageEnable:false\n\t\t\t};\n\t\t\tvar editor_a = new baidu.editor.ui.Editor(editorOption);\n\t\t\teditor_a.render( 'fc_" . $id . "' );\n\t\t</script>\n\t\t"; } else { //精简模式 $str .= "\n\t\t<script type=\"text/plain\" id=\"fc_" . $id . "\" name=\"data[" . $id . "]\" style=\"width:" . $w . "%\">" . htmlspecialchars_decode($content) . "</script>\n\t\t<script type=\"text/javascript\">\n\t\t\tvar editorOption = {\n\t\t\t UEDITOR_HOME_URL: ueditor_url,\n\t\t\t\ttoolbars:[[\n\t\t\t\t" . $source . "'bold', 'italic', 'underline', 'removeformat','|', 'forecolor', 'backcolor', '|', 'insertimage', 'emotion','map', 'gmap'" . $page . "\n\t\t\t\t]],\n\t\t\t\tlang: \"" . SYS_LANGUAGE . "\",\n\t\t\t\tinitialContent:'',\n\t\t\t\tautoClearinitialContent:false,\n\t\t\t\tminFrameHeight:" . $h . ",\n\t\t\t\tinitialFrameHeight: " . $h . ",\n\t\t\t\tinitialFrameWidth: '" . $w . "%',\n\t\t\t\tallHtmlEnabled:false,\n\t\t\t\tautoHeightEnabled:false,\n\t\t\t\tpageBreakTag: \"{-page-}\",\n\t\t\t\tinitialStyle:'body{font-size:14px;line-height:20px;}',\n\t\t\t\timageUrl:\"" . url('attachment/ueditor_upload', array('dir' => 'image')) . "\",\n imagePath:\"" . SITE_PATH . "\",\n\t\t\t\timageManagerUrl:\"" . url('attachment/ueditor_manager', array('dir' => 'image')) . "\",\n imageManagerPath:\"" . SITE_PATH . "\",\n\t\t\t\twordCount:false,\n\t\t\t\telementPathEnabled:false,\n\t\t\t\tautoFloatEnabled:false,\n\t\t\t\tcatchRemoteImageEnable:false\n\t\t\t};\n\t\t\tvar editor_a = new baidu.editor.ui.Editor(editorOption);\n\t\t\teditor_a.render( 'fc_" . $id . "' );\n\t\t</script>\n\t\t"; } if (!isset($setting['system']) && $name == 'content') { //是否显示编辑器底部截取内容,缩略图,远程下载等提示信息 $str .= '<div style="padding-top:8px;"><input type="checkbox" checked="" value="1" name="data[fn_add_introduce]"> ' . lang('a-mod-115') . '<input type="text" size="3" value="200" name="data[fn_introcude_length]" class="input-text">' . lang('a-mod-116') . '<input type="checkbox" checked="" value="1" name="data[fn_auto_thumb]"> ' . lang('a-mod-117') . ' <input type="checkbox" checked="" value="1" name="data[fn_down_image]"> ' . lang('a-mod-136') . '</div>'; } return $str; }