Ejemplo n.º 1
0
 function doTag()
 {
     require_once iPATH . 'include/cn.class.php';
     require_once iPATH . 'include/snoopy.class.php';
     $title = urlencode(CN::u2g($_POST['title']));
     $Snoopy = new Snoopy();
     $Snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5";
     $Snoopy->accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
     $baidu = 'http://www.baidu.com/s?wd=' . $title;
     $Snoopy->fetch($baidu);
     preg_match_all("/<td\\s*nowrap\\s*class=\"f14\"><a\\s*href=\".*?\">(.*?)<\\/a><\\/td>/is", CN::g2u($Snoopy->results), $match);
     $baiduTag = (array) array_unique($match[1]);
     $google = 'http://www.google.com.hk/search?hl=zh-CN&source=hp&q=' . $title . '&aq=f&aqi=&aql=&oq=&gs_rfai=';
     $Snoopy->fetch($google);
     preg_match_all("/<p><a\\s*href=\".*?\">(.*?)<\\/a><\\/p>/is", $Snoopy->results, $match);
     $googleTag = (array) array_unique($match[1]);
     $tagArray = array_merge($baiduTag, $googleTag);
     $tagArray = array_unique($tagArray);
     $ul = '<ul style="margin:0; padding:0;">';
     foreach ((array) $tagArray as $key => $tag) {
         $ul .= "<li><input onclick=\"inTag('{$tag}',{$key})\" id=\"gt_{$key}\" class='checkbox' type=\"checkbox\" value=\"{$tag}\" />{$tag}</li>\n";
     }
     $ul .= "</ul>";
     echo $ul;
 }
Ejemplo n.º 2
0
 function doSave()
 {
     $id = (int) $_POST['id'];
     $name = dhtmlspecialchars($_POST['name']);
     $table = dhtmlspecialchars($_POST['table']);
     $description = dhtmlspecialchars($_POST['desc']);
     $position2 = $_POST['pos'];
     $position = $_POST['position'];
     $binding = isset($_POST['binding']) ? 1 : 0;
     empty($name) && javascript::alert('模块名称不能为空!');
     empty($table) && $binding && javascript::alert('模块名不能为空!');
     if (!$binding && empty($id)) {
         if (empty($table)) {
             include iPATH . 'include/cn.class.php';
             $table = CN::pinyin($name);
         }
         $table = $table . '_content';
     }
     if ($id) {
         iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}' and `id`!='{$id}'") && javascript::alert('该模块已经存在!请检查是否重复');
         iCMS_DB::query("UPDATE `#iCMS@__model` SET `name` = '{$name}', `table` = '{$table}', `binding` = '{$binding}', `description` = '{$description}', `position` = '{$position}', `position2` = '{$position2}' WHERE `id` = '{$id}';");
     } else {
         iCMS_DB::query("INSERT INTO `#iCMS@__model`(`name`, `table`, `binding`, `description`, `position`,`position2`, `addtime`)VALUES ('{$name}', '{$table}', '{$binding}', '{$description}', '{$position}','{$position2}', '" . time() . "');");
         $id = iCMS_DB::$insert_id;
     }
     model::cache();
     $moreaction = array(array("text" => "下一步添加字段", "url" => __SELF__ . "?mo=models&do=addfield&id=<?php echo {$id};?>"), array("text" => "返回模块列表", "url" => __SELF__ . "?mo=models&do=manage"));
     javascript::dialog('模块添加完成!<br />10秒后返回模块列表', "url:" . __SELF__ . "?mo=models&do=manage", $moreaction, 10);
 }
Ejemplo n.º 3
0
 function update($tag, $uId = "0", $indexId = "0", $sortid = '0', $modelId = '0')
 {
     global $iCMS;
     if (empty($tag)) {
         return;
     }
     $tid = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__tags` WHERE `name`='{$tag}'");
     if (empty($tid) && $tag != "") {
         include_once iPATH . 'include/cn.class.php';
         $link = CN::pinyin($tag, $iCMS->config['CLsplit']);
         iCMS_DB::query("INSERT INTO `#iCMS@__tags`(`uid`,`sortid`,`name`,`type`,`keywords`,`seotitle`,`subtitle`,`description`,`link`,`count`,`weight`,`ordernum`,`tpl`,`updatetime`,`status`)VALUES ('{$uId}','{$sortid}','{$tag}','0','','','','','{$link}','1',0,0,'','" . time() . "','1')");
         $tid = iCMS_DB::$insert_id;
         self::cache($tid);
         iCMS_DB::query("INSERT INTO `#iCMS@__taglist` (`indexId`, `tid`, `modelId`) VALUES ('{$indexId}', '{$tid}', '{$modelId}')");
     } else {
         $taglist = iCMS_DB::getValue("SELECT * FROM `#iCMS@__taglist` WHERE `indexId`='{$indexId}' and `tid`='{$tid}' and `modelId`='{$modelId}'");
         if (empty($taglist)) {
             iCMS_DB::query("INSERT INTO `#iCMS@__taglist` (`indexId`, `tid`, `modelId`) VALUES ('{$indexId}', '{$tid}', '{$modelId}')");
             iCMS_DB::query("UPDATE `#iCMS@__tags` SET  `count`=count+1,`updatetime`='" . time() . "'  WHERE `id`='{$tid}'");
         }
     }
 }
Ejemplo n.º 4
0
 function dosave()
 {
     include_once iPATH . 'include/tag.class.php';
     $id = $_POST['id'];
     $mid = $_POST['mid'];
     $FArray = model::field($mid);
     $model = model::data($mid);
     $content = array();
     if ($_POST['content']) {
         foreach ($_POST['content'] as $field => $value) {
             if (model::isDefField($field)) {
                 switch ($field) {
                     case "userid":
                         $value = intval($value);
                         break;
                     case "fid":
                         $value = $fid = intval($value);
                         empty($value) && javascript::alert('请选择所属栏目');
                         break;
                     case "orderNum":
                         $value = _int($value);
                         break;
                     case "top":
                         $value = _int($value);
                         break;
                     case "title":
                         $value = dhtmlspecialchars($value);
                         empty($value) && javascript::alert('标题不能为空!');
                         break;
                     case "editor":
                         $value = dhtmlspecialchars($value);
                         break;
                     case "tags":
                         $value = iTAG::split(dhtmlspecialchars($value), true);
                         break;
                     case "type":
                         $value = intval($value);
                         break;
                     case "vlink":
                         $value = implode(',', $value);
                         break;
                     case "postype":
                         $value = empty($value) ? intval($value) : "1";
                         break;
                     case "pubdate":
                         $value = _strtotime($value);
                         break;
                     case "clink":
                         $value = dhtmlspecialchars($value);
                         if ($value) {
                             $clinklen = strlen($value);
                             for ($i = 0; $i < $clinklen; $i++) {
                                 !preg_match("/[a-zA-Z0-9_\\-~" . preg_quote($this->iCMS->config['CLsplit'], '/') . "]/", $value[$i]) && javascript::alert('自定链接只能由英文字母、数字或_-~组成(不支持中文)');
                             }
                         }
                         break;
                 }
             } elseif ($F = $FArray[$field]) {
                 switch ($F['type']) {
                     case "number":
                         $value = intval($value);
                         break;
                     case "calendar":
                         $value = _strtotime($value);
                         break;
                     case in_array($F['type'], array('text', 'textarea', 'radio', 'select', 'email', 'url', 'image', 'upload')):
                         $value = dhtmlspecialchars($value);
                         break;
                     case in_array($F['type'], array('checkbox', 'multiple')):
                         $value = implode(',', $value);
                         break;
                     case 'editor':
                         $this->iCMS->config['autoformat'] && ($value = autoformat($value));
                         break;
                     default:
                         $value = dhtmlspecialchars($value);
                 }
             }
             WordFilter($value) && javascript::alert($field . '字段包含被系统屏蔽的字符,请返回重新填写。');
             $content[$field] = $value;
             $PF[] = $field;
         }
     }
     if (empty($content['clink'])) {
         include iPATH . 'include/cn.class.php';
         $content['clink'] = CN::pinyin($content['title'], $this->iCMS->config['CLsplit']);
     }
     $table = model::tbn($_POST['table']);
     $MF = explode(',', $model['field']);
     $diff = array_diff_values($PF, $MF);
     if ($diff['-']) {
         foreach ($diff['-'] as $field) {
             $content[$field] = '';
         }
     }
     //缺少的字段 填认空值
     $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=content&do=manage' : $_POST['REFERER']);
     $forum = new forum();
     if (empty($id)) {
         empty($content['userid']) && ($content['userid'] = member::$uId);
         $content['hits'] = $content['good'] = $content['bad'] = $content['comments'] = 0;
         $content['status'] = "1";
         $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `clink` ='" . $content['clink'] . "'");
         if ($this->iCMS->config['repeatitle']) {
             iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `title` = '{$title}'") && alert('该标题内容已经存在!请检查是否重复');
             $checkCL && javascript::alert('该自定链接已经存在!请另选一个');
         } else {
             $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1));
         }
         iCMS_DB::insert($table, $content);
         $id = iCMS_DB::$insert_id;
         model::upload($table, $id, $title);
         iTAG::add($content['tags'], $content['userid'], $id, $forum->rootid($fid), $mid);
         $vlink = empty($content['vlink']) ? $fid : $content['vlink'] . ',' . $fid;
         vlinkDiff($vlink, '', $id, $mid);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $content['status']) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::content($id, $mid, $table);
             iHtml::forum($fid, 1, 0, 1);
         }
         iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
         //			$moreaction=array(
         //				array("text"=>"编辑该内容","url"=>__SELF__."?do=content&operation=add&table=".$table."&mid=".$mid."&id=".$id),
         //				array("text"=>"继续添加内容","url"=>__SELF__."?do=content&operation=add&table=".$table."&mid=".$mid."&cid=".$cid),
         //				array("text"=>"查看该内容","url"=>$iCMS->iurl('content',array('mId'=>$mid,'id'=>$id,'link'=>$clink,'pubdate'=>$pubdate,'cid'=>$cid,'dir'=>$catalog->catalog[$cid]['dir'],'domain'=>$catalog->catalog[$cid]['domain'],'htmlext'=>$catalog->catalog[$cid]['htmlext']))->href,"o"=>'target="_blank"'),
         //				array("text"=>"查看网站首页","url"=>"../index.php","o"=>'target="_blank"')
         //			);
         javascript::dialog("添加完成!", 'url:' . __SELF__ . "?mo=content&do=manage&table=" . $table . "&mid=" . $mid);
     } else {
         $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `clink` ='{$clink}' AND `id` !='{$id}'");
         if ($this->iCMS->config['repeatitle']) {
             $checkCL && alert('该自定链接已经存在!请另选一个');
         } else {
             $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1));
         }
         $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__{$table}` where `id` ='{$id}'");
         iTAG::diff($content['tags'], member::$uId, $art->tags, $id, $forum->rootid($fid));
         iCMS_DB::update($table, $content, array('id' => $id));
         model::upload($table, $id, $title);
         $vlink = empty($content['vlink']) ? $fid : $content['vlink'] . ',' . $fid;
         vlinkDiff($vlink, $art->vlink, $id);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::content($id, $mid, $table);
             iHtml::forum($fid, 1, 0, 1);
         }
         if ($art->fid != $fid) {
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 ");
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
         }
         javascript::dialog('编辑完成!<br />3秒后返回项目列表', 'url:' . $SELFURL);
     }
 }
Ejemplo n.º 5
0
 function dosave()
 {
     $id = (int) $_POST['id'];
     $name = dhtmlspecialchars($_POST['name']);
     $sortid = (int) $_POST['sortid'];
     $type = (int) $_POST['type'];
     $link = dhtmlspecialchars($_POST['link']);
     $keywords = dhtmlspecialchars($_POST['keywords']);
     $seotitle = dhtmlspecialchars($_POST['seotitle']);
     $subtitle = dhtmlspecialchars($_POST['subtitle']);
     $description = dhtmlspecialchars($_POST['description']);
     $count = (int) $_POST['count'];
     $weight = _int($_POST['weight']);
     $ordernum = _int($_POST['ordernum']);
     $tpl = $_POST['tpl'];
     $status = (int) $_POST['status'];
     if (empty($link)) {
         include iPATH . 'include/cn.class.php';
         $link = CN::pinyin($name, $this->iCMS->config['CLsplit']);
     }
     if (empty($id)) {
         iCMS_DB::query("INSERT INTO `#iCMS@__tags`(`sortid`, `uid`, `name`,`type`,`keywords`,`seotitle`,`subtitle`,`description`, `link`, `count`, `weight`,`ordernum`, `tpl`,`updatetime`,`status`) VALUES ('{$sortid}', '" . Admin::$uId . "', '{$name}','{$type}','{$keywords}','{$seotitle}','{$subtitle}','{$description}', '{$link}', '{$count}', '{$weight}','{$ordernum}','{$tpl}','" . time() . "' '{$status}');");
     } else {
         iCMS_DB::query("UPDATE `#iCMS@__tags` SET `sortid` = '{$sortid}',`name` = '{$name}',`type` = '{$type}',`keywords` = '{$keywords}',`seotitle` = '{$seotitle}',`subtitle` = '{$subtitle}',`description` = '{$description}', `link` = '{$link}', `count` = '{$count}', `weight` = '{$weight}',`ordernum` = '{$ordernum}',`tpl` = '{$tpl}',`updatetime`='" . time() . "', `status` = '{$status}' WHERE `id` = '{$id}'");
     }
     tags_cache($id);
     javascript::dialog('TAG更新完成!', 'url:' . __SELF__ . '?mo=tag&do=manage');
 }
Ejemplo n.º 6
0
 function doSave()
 {
     //    	print_r($_POST);
     //    	exit;
     set_time_limit(0);
     $aid = (int) $_POST['aid'];
     $fid = (int) $_POST['fid'];
     $userid = (int) $_POST['userid'];
     $type = (int) $_POST['type'];
     $orderNum = (int) $_POST['orderNum'];
     $title = dhtmlspecialchars($_POST['title']);
     $subtitle = dhtmlspecialchars($_POST['subtitle']);
     $stitle = dhtmlspecialchars($_POST['stitle']);
     $pic = dhtmlspecialchars($_POST['pic']);
     $source = dhtmlspecialchars($_POST['source']);
     $author = dhtmlspecialchars($_POST['author']);
     $editor = dhtmlspecialchars($_POST['editor']);
     $description = dhtmlspecialchars($_POST['description']);
     $keywords = dhtmlspecialchars($_POST['keywords']);
     $tags = dhtmlspecialchars($_POST['tags']);
     $clink = dhtmlspecialchars($_POST['clink']);
     $url = dhtmlspecialchars($_POST['url']);
     $tpl = dhtmlspecialchars($_POST['template']);
     $top = _int($_POST['top']);
     $vlink = empty($_POST['vlink']) ? "" : implode(',', $_POST['vlink']);
     $related = empty($_POST['related']) ? "" : implode(',', $_POST['related']);
     $pubdate = _strtotime($_POST['pubdate']);
     $remote = isset($_POST['remote']) ? true : false;
     $dellink = isset($_POST['dellink']) ? true : false;
     $this->autopic = isset($_POST['autopic']) ? true : false;
     $status = isset($_POST['draft']) ? "0" : "1";
     $postype = $_POST['postype'] ? $_POST['postype'] : "1";
     $body = implode('<!--iCMS.PageBreak-->', $_POST['body']);
     $body = str_replace(array("\n", "\r", "\t", '<p>&nbsp;</p><p>&nbsp;</p>', '<p>&nbsp;</p><p>&nbsp;</p>', '<p>&nbsp;</p><p>&nbsp;</p>'), "", $body);
     $body = preg_replace(array('/<script.+?<\\/script>/is', '/<form.+?<\\/form>/is', '/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is'), array('', '', '<!--iCMS.PageBreak-->'), $body);
     //$body       = strip_tags($body,'<div><br><p><img><a><embed><span><b><strong><u><em>');
     empty($title) && javascript::alert('标题不能为空!');
     empty($fid) && javascript::alert('请选择所属栏目');
     empty($body) && empty($url) && javascript::alert('文章内容不能为空!');
     WordFilter($title) && javascript::alert('标题包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($body) && javascript::alert('文章内容包含被系统屏蔽的字符,请返回重新填写。');
     if ($clink) {
         for ($i = 0; $i < strlen($clink); $i++) {
             !preg_match("/[a-zA-Z0-9_\\-~" . preg_quote($this->iCMS->config['CLsplit'], '/') . "]/", $clink[$i]) && javascript::alert('自定链接只能由英文字母、数字或_-~组成(不支持中文)');
         }
     }
     isset($_POST['keywordToTag']) && empty($tags) && ($tags = $keywords);
     $tags = implode(',', (array) tag_split($tags));
     if ($this->iCMS->config['autodesc'] == "1" && !empty($this->iCMS->config['descLen']) && empty($description) && empty($url)) {
         $description = csubstr(HtmToText($body), $this->iCMS->config['descLen']);
     }
     $remote && FS::remotepic($body, $title);
     !$remote && $this->autopic && FS::remotepic($body, $title, true);
     if (empty($clink)) {
         include iPATH . 'include/cn.class.php';
         $clink = CN::pinyin($title, $this->iCMS->config['CLsplit']);
     }
     $isPic = empty($pic) ? 0 : 1;
     $dellink && ($body = preg_replace("/<a[^>].*?>(.*?)<\\/a>/si", "\\1", $body));
     $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=article&do=manage' : $_POST['REFERER']);
     $forum = new forum();
     if (empty($aid)) {
         empty($userid) && ($userid = Admin::$uId);
         $hits = $good = $bad = $comments = 0;
         $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__article` where `clink` ='{$clink}'");
         if ($this->iCMS->config['repeatitle']) {
             iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__article` where `title` = '{$title}'") && javascript::alert('该标题的文章已经存在!请检查是否重复');
             $checkCL && javascript::alert('该自定链接已经存在!请另选一个');
         } else {
             $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1));
         }
         iCMS_DB::insert('article', compact('fid', 'title', 'stitle', 'clink', 'orderNum', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'isPic', 'pic', 'pubdate', 'hits', 'good', 'bad', 'comments', 'type', 'vlink', 'top', 'status'));
         $aid = iCMS_DB::$insert_id;
         if (empty($url)) {
             //            	$body	= addslashes($body);
             iCMS_DB::insert('article_data', compact('aid', 'subtitle', 'tpl', 'body'));
             $this->insert_db_remote($body, $aid);
             //$iCMS->setCache('system/search',$res,0);
         }
         addtags($tags, $aid, $forum->rootid($fid));
         $vlink = empty($vlink) ? $fid : $vlink . ',' . $fid;
         vlinkDiff($vlink, '', $aid);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::Article($aid);
             iHtml::forum($fid, 1, 0, 1);
         }
         iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
         $moreaction = array(array("text" => "查看该文章", "url" => $this->iCMS->iurl('show', array(array('id' => $aid, 'link' => $clink, 'url' => $url, 'fid' => $fid, 'pubdate' => $pubdate), $forum->forum[$fid]))->href, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => __SELF__ . "?mo=article&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => __SELF__ . "?mo=article&do=add&fid=" . $fid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => "../index.php", "o" => 'target="_blank"'));
         javascript::dialog('文章添加完成!<br />10秒后返回文章列表', 'url:' . $SELFURL, $moreaction, 10);
     } else {
         $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__article` where `clink` ='{$clink}' AND `id` !='{$aid}'");
         if ($this->iCMS->config['repeatitle']) {
             $checkCL && javascript::alert('该自定链接已经存在!请另选一个');
         } else {
             $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1));
         }
         $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__article` where `id` ='{$aid}'");
         TagsDiff($tags, $art->tags, $aid, $forum->rootid($fid));
         iCMS_DB::update('article', compact('fid', 'title', 'stitle', 'orderNum', 'clink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'isPic', 'pic', 'pubdate', 'type', 'vlink', 'top', 'status'), array('id' => $aid));
         $vlink = empty($vlink) ? $fid : $vlink . ',' . $fid;
         vlinkDiff($vlink, $art->vlink, $aid);
         if (empty($url)) {
             //            	$body	= addslashes($body);
             if (iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__article_data` where `aid` ='{$aid}'")) {
                 iCMS_DB::update('article_data', compact('tpl', 'subtitle', 'body'), compact('aid'));
             } else {
                 iCMS_DB::insert('article_data', compact('aid', 'subtitle', 'tpl', 'body'));
             }
             $this->insert_db_remote($body, $aid);
         }
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::Article($aid);
             iHtml::forum($fid, 1, 0, 1);
         }
         if ($art->fid != $fid) {
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 ");
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
         }
         javascript::dialog('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL);
     }
 }
Ejemplo n.º 7
0
 function doSave()
 {
     $id = (int) $_POST['id'];
     $name = dhtmlspecialchars($_POST['name']);
     $table = dhtmlspecialchars($_POST['table']);
     $description = dhtmlspecialchars($_POST['desc']);
     $show = (int) $_POST['show'];
     $position = $_POST['position'];
     $position2 = $_POST['pos'];
     $form = dhtmlspecialchars($_POST['form']);
     $binding = isset($_POST['binding']) ? 1 : 0;
     empty($name) && javascript::alert('模块名称不能为空!');
     empty($table) && $binding && javascript::alert('模块名不能为空!');
     if (!$binding && empty($id)) {
         if (empty($table)) {
             include iPATH . 'include/cn.class.php';
             $table = CN::pinyin($name);
         }
     }
     !preg_match("/[a-zA-Z]/", $table[0]) && javascript::alert('模型表名只能以英文字母开头');
     !preg_match("/[a-zA-Z0-9_\\-~]/", $table) && javascript::alert('模型表名只能由英文字母或数字组成');
     //model::isSysTable($table) && javascript::alert('您所填写的模块表名是系统表!请重新填写.');
     if ($id) {
         iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}' and `id`!='{$id}'") && javascript::alert('该模块已经存在!请检查是否重复');
         iCMS_DB::query("UPDATE `#iCMS@__model` SET `name` = '{$name}', `table` = '{$table}', `binding` = '{$binding}', `description` = '{$description}', `show` = '{$show}', `position` = '{$position}', `position2` = '{$position2}', `form` = '{$form}' WHERE `id` = '{$id}';");
         if (!$binding) {
             $oTable = iCMS_DB::getValue("SELECT `table` FROM `#iCMS@__model` where `id` ='{$id}'");
             if ($oTable != $table) {
                 iCMS_DB::query("RENAME TABLE `#iCMS@__" . model::tbn($oTable) . "` TO `#iCMS@__" . model::tbn($table) . "`");
             }
         }
     } else {
         iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}'") && javascript::alert('该模块已经存在!请检查是否重复');
         $field = $binding ? '' : model::$defaultField;
         iCMS_DB::query("INSERT INTO `#iCMS@__model`(`name`, `table`, `field`, `binding`, `description`,`show`, `position`,`position2`,`form`, `addtime`)VALUES ('{$name}', '{$table}','{$field}', '{$binding}', '{$description}','{$show}', '{$position}','{$position2}','{$form}', '" . time() . "');");
         $id = iCMS_DB::$insert_id;
         if (!$binding) {
             //创建模块基础表
             $tableSQL = "CREATE TABLE `#iCMS@__" . model::tbn($table) . "` (\n\t\t\t\t\t   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t   `fid` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `orderNum` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t   `title` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `clink` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `editor` varchar(200) NOT NULL DEFAULT '',\n\t\t\t\t\t   `userid` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `tags` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `pubdate` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `hits` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `comments` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `good` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `bad` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `vlink` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t   `type` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t   `top` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t   `postype` tinyint(1) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t   `status` tinyint(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\t\t   PRIMARY KEY (`id`),\n\t\t\t\t\t   KEY `pubdate` (`pubdate`),\n\t\t\t\t\t   KEY `comment` (`comments`),\n\t\t\t\t\t   KEY `hit` (`hits`),\n\t\t\t\t\t   KEY `order` (`orderNum`),\n\t\t\t\t\t   KEY `sortid` (`fid`,`id`),\n\t\t\t\t\t   KEY `topord` (`top`,`orderNum`),\n\t\t\t\t\t   KEY `userid` (`userid`),\n\t\t\t\t\t   KEY `postype` (`postype`,`id`),\n\t\t\t\t\t   KEY `status` (`status`,`postype`,`id`)\n\t\t\t\t\t ) ENGINE=MyISAM  DEFAULT CHARSET=" . DB_CHARSET;
             iCMS_DB::query($tableSQL);
         }
     }
     model::cache();
     $moreaction = array(array("text" => "下一步添加字段", "url" => __SELF__ . "?mo=models&do=addfield&id=" . $id), array("text" => "返回模块列表", "url" => __SELF__ . "?mo=models&do=manage"));
     javascript::dialog('模块' . ($id ? '编辑' : '添加') . '完成!<br />模块基础建表完成...<br />10秒后返回模块列表', "url:" . __SELF__ . "?mo=models&do=manage", $moreaction, 10);
 }
Ejemplo n.º 8
0
 function doSave()
 {
     $fid = (int) $_POST['fid'];
     $rootid = (int) $_POST['rootid'];
     $modelid = (int) $_POST['modelid'];
     $status = (int) $_POST['status'];
     $issend = (int) $_POST['issend'];
     $isexamine = (int) $_POST['isexamine'];
     $orderNum = (int) $_POST['orderNum'];
     $mode = (int) $_POST['mode'];
     $name = dhtmlspecialchars($_POST['name']);
     $subname = dhtmlspecialchars($_POST['subname']);
     $domain = dhtmlspecialchars($_POST['domain']);
     $htmlext = dhtmlspecialchars($_POST['htmlext']);
     $url = dhtmlspecialchars($_POST['url']);
     $password = dhtmlspecialchars($_POST['password']);
     $pic = dhtmlspecialchars($_POST['pic']);
     $dir = dhtmlspecialchars($_POST['dir']);
     $title = dhtmlspecialchars($_POST['title']);
     $keywords = dhtmlspecialchars($_POST['keywords']);
     $description = dhtmlspecialchars($_POST['description']);
     $attr = dhtmlspecialchars($_POST['attr']);
     $forumRule = dhtmlspecialchars($_POST['forumRule']);
     $contentRule = dhtmlspecialchars($_POST['contentRule']);
     $indexTPL = dhtmlspecialchars($_POST['indexTPL']);
     $listTPL = dhtmlspecialchars($_POST['listTPL']);
     $contentTPL = dhtmlspecialchars($_POST['contentTPL']);
     $fid && $fid == $rootid && javascript::dialog('不能以自身做为上级栏目');
     empty($name) && javascript::dialog('栏目名称不能为空!');
     if (empty($dir) && empty($url)) {
         include iPATH . 'include/cn.class.php';
         $dir = strtolower(CN::pinyin($name));
     }
     if ($mode == "2") {
         if (strpos($forumRule, '{FDIR}') === FALSE && strpos($forumRule, '{FID}') === FALSE) {
             javascript::dialog('伪静态模式下版块URL规则<br />必需要有<br />{FDIR}版块目录<br />或者<br />{FID}版块ID', 'js:', 'ok', 10);
         }
         if (strpos($contentRule, '{AID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) {
             javascript::dialog('伪静态模式下内容URL规则<br />必需要有<br />{AID}文章ID <br />或者<br />{0xID}文章ID补零<br />或者<br />{LINK}文章自定义链接', 'js:', 'ok', 10);
         }
         global $iCMS;
         $htaFile = iPATH . "/.htaccess";
         //        	if(file_exists($htaFile)){
         //        		$RewriteRule=FS::read($htaFile);
         //        	}
         //        	if(empty($RewriteRule)){
         $RewriteBase = $iCMS->config['dir'] == "/" ? '' : $iCMS->config['dir'];
         $RewriteRule = "RewriteEngine On\nRewriteBase /" . $RewriteBase . "\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\n\n";
         //        	}
         //内容
         $contentRR = RewriteRule($contentRule, "show", $htmlext, $iCMS->config['htmldir']);
         $cmd5 = md5($contentRR);
         if (strstr($RewriteRule, $cmd5) === false) {
             $RewriteRule .= "#{$cmd5}\n" . $contentRR . "#{$cmd5}\n\n\n";
         }
         //版块
         $forumRR = RewriteRule($forumRule, "forum", $htmlext, $iCMS->config['htmldir']);
         $fmd5 = md5($forumRR);
         if (strstr($RewriteRule, $fmd5) === false) {
             $RewriteRule .= "#{$fmd5}\n" . $forumRR . "#{$fmd5}\n\n\n";
         }
         FS::write($htaFile, $RewriteRule);
     }
     if (empty($fid)) {
         iCMS_DB::getValue("SELECT `dir` FROM `#iCMS@__forum` where `dir` ='{$dir}'") && empty($url) && javascript::dialog('该栏目别名/目录已经存在!请另选一个');
         iCMS_DB::query("INSERT INTO `#iCMS@__forum` (`rootid`,`modelid`,`orderNum`,`name`,`subname`,`password`,`title`,`keywords`,`description`,`dir`,`mode`,`domain`,`url`,`pic`,`htmlext`,`forumRule`,`contentRule`,`indexTPL`,`listTPL`,`contentTPL`,`attr`,`isexamine`,`issend`,`status`)\n    \t\tVALUES ('{$rootid}','{$modelid}', '{$orderNum}', '{$name}','{$subname}','{$password}','{$title}','{$keywords}', '{$description}', '{$dir}','{$mode}','{$domain}', '{$url}','{$pic}','{$htmlext}','{$forumRule}', '{$contentRule}','{$indexTPL}', '{$listTPL}', '{$contentTPL}', '{$attr}','{$isexamine}','{$issend}','{$status}')");
         $forum = new forum();
         $forum->cache();
         $msg = "栏目添加完成!";
     } else {
         Admin::CP($fid, 'Permission_Denied', __SELF__ . '?mo=forums');
         $rootid != $forum->forum[$fid]['rootid'] && Admin::CP($rootid, 'Permission_Denied', __SELF__ . '?mo=forums');
         iCMS_DB::getValue("SELECT `dir` FROM `#iCMS@__forum` where `dir` ='{$dir}' AND `fid` !='{$fid}'") && empty($url) && javascript::alert('该栏目别名/目录已经存在!请另选一个');
         iCMS_DB::query("UPDATE `#iCMS@__forum` SET `rootid` = '{$rootid}',`modelid` = '{$modelid}',`orderNum` = '{$orderNum}',`name` = '{$name}',`subname` = '{$subname}',`password`='{$password}',`title` = '{$title}',`keywords` = '{$keywords}',`description` = '{$description}',`dir` = '{$dir}',`url` = '{$url}',`mode` = '{$mode}',`domain` = '{$domain}',`pic`='{$pic}',`htmlext`='{$htmlext}',`forumRule`='{$forumRule}',`contentRule`='{$contentRule}',`indexTPL` = '{$indexTPL}',`listTPL` = '{$listTPL}',`contentTPL` = '{$contentTPL}',`attr` = '{$attr}',`isexamine`='{$isexamine}',`status`='{$status}',`issend`='{$issend}' WHERE `fid` ='{$fid}' ");
         $forum = new forum();
         $forum->cache();
         $msg = "栏目编辑完成!";
     }
     javascript::dialog($msg, 'url:' . __SELF__ . '?mo=forums');
 }
Ejemplo n.º 9
0
 function doSave()
 {
     include_once iPATH . 'include/tag.class.php';
     //    	print_r($_POST);
     //    	exit;
     set_time_limit(0);
     $aid = (int) $_POST['aid'];
     $fid = (int) $_POST['fid'];
     $title = dhtmlspecialchars($_POST['title']);
     $source = dhtmlspecialchars($_POST['source']);
     $author = dhtmlspecialchars($_POST['author']);
     $description = dhtmlspecialchars($_POST['description']);
     $keywords = dhtmlspecialchars($_POST['keywords']);
     $tags = dhtmlspecialchars($_POST['tags']);
     $pic = dhtmlspecialchars($_POST['pic']);
     $metadata = dhtmlspecialchars($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     $userid = member::$uId;
     $pubdate = _strtotime();
     $type = 0;
     $orderNum = 0;
     $subtitle = '';
     $stitle = '';
     $editor = '';
     $clink = '';
     $url = '';
     $tpl = '';
     $top = 0;
     $vlink = "";
     $related = "";
     $postype = 0;
     $body = str_replace(array("\n", "\r", "\t"), "", $_POST['body']);
     empty($title) && javascript::alert('标题不能为空!');
     empty($fid) && javascript::alert('请选择所属栏目');
     empty($body) && javascript::alert('文章内容不能为空!');
     WordFilter($title) && javascript::alert('标题包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($source) && javascript::alert('出处包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($author) && javascript::alert('作者包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($description) && javascript::alert('摘要包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($keywords) && javascript::alert('关键字包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($tags) && javascript::alert('标签包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($metadata) && javascript::alert('自定义内容包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($body) && javascript::alert('文章内容包含被系统屏蔽的字符,请返回重新填写。');
     if ($this->iCMS->config['AutoPage']) {
         if ($this->iCMS->config['AutoPageLen'] && !preg_match('/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is', $body)) {
             $html = autoformat($body, false);
             AutoPageBreak::page($html, $this->iCMS->config['AutoPageLen']);
             $body = implode('<!--iCMS.PageBreak-->', AutoPageBreak::$Rs);
             AutoPageBreak::$Rs = '';
             unset($html);
             $this->iCMS->config['autoformat'] = false;
         }
     }
     $body = preg_replace(array('/<script.+?<\\/script>/is', '/<form.+?<\\/form>/is', '/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is'), array('', '', '<!--iCMS.PageBreak-->'), $body);
     $this->iCMS->config['autoformat'] && ($body = autoformat($body));
     if ($this->iCMS->config['autodesc'] == "1" && !empty($this->iCMS->config['descLen']) && empty($description)) {
         $_body = preg_replace(array('/<p[^>]*>/is', '/<[\\/\\!]*?[^<>]*?>/is', "/\n+/", "/ +/", "/^\n/"), array("\n\n", '', "\n", '', ''), $this->iCMS->config['autoformat'] ? $body : autoformat($body));
         $description = csubstr($_body, $this->iCMS->config['descLen']);
     }
     $tags = iTAG::split($tags, true);
     include iPATH . 'include/cn.class.php';
     $clink = CN::pinyin($title, $this->iCMS->config['CLsplit']);
     $isPic = empty($pic) ? 0 : 1;
     $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=article&do=manage' : $_POST['REFERER']);
     $forum = new forum();
     $status = $forum->forum[$fid]['isexamine'] ? '0' : '1';
     //审核投稿
     if (empty($aid)) {
         $hits = $good = $bad = $comments = 0;
         iCMS_DB::insert('article', compact('fid', 'title', 'stitle', 'clink', 'orderNum', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'metadata', 'isPic', 'pic', 'pubdate', 'hits', 'good', 'bad', 'comments', 'type', 'vlink', 'top', 'status'));
         $aid = iCMS_DB::$insert_id;
         iCMS_DB::insert('article_data', compact('aid', 'subtitle', 'tpl', 'body'));
         if ($_FILES['picfile']) {
             require_once iPATH . 'include/upload.class.php';
             $F = iUpload::FILES("picfile", $aid, $title);
             iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '" . $F["FilePath"] . "' WHERE `id` = '{$aid}'");
         }
         //$this->insert_db_remote($body,$aid);
         iTAG::add($tags, $userid, $aid, $forum->rootid($fid));
         vlinkDiff($fid, '', $aid);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::Article($aid);
             iHtml::forum($fid, 1, 0, 1);
         }
         if ($status) {
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
             $moreaction = array(array("text" => "查看该文章", "url" => $this->iCMS->iurl('show', array(array('id' => $aid, 'link' => $clink, 'url' => $url, 'fid' => $fid, 'pubdate' => $pubdate), $forum->forum[$fid]))->href, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => __SELF__ . "?mo=article&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => __SELF__ . "?mo=article&do=add&fid=" . $fid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => "../index.php", "o" => 'target="_blank"'));
             javascript::dialog('文章发布成功!<br />10秒后返回文章列表', 'url:' . $SELFURL, $moreaction, 10);
         } else {
             javascript::dialog('您的投稿文章发布成功!<br />该版块文章需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10);
         }
     } else {
         $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__article` where `id` ='{$aid}'");
         iTAG::diff($tags, $art->tags, member::$uId, $aid, $forum->rootid($fid));
         iCMS_DB::update('article', compact('fid', 'title', 'stitle', 'orderNum', 'clink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'metadata', 'isPic', 'pic', 'pubdate', 'type', 'vlink', 'top', 'status'), array('id' => $aid));
         vlinkDiff($fid, $art->vlink, $aid);
         iCMS_DB::update('article_data', compact('tpl', 'subtitle', 'body'), compact('aid'));
         if ($_FILES['picfile']) {
             require_once iPATH . 'include/upload.class.php';
             $F = iUpload::FILES("picfile", $aid, $title);
             iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '" . $F["FilePath"] . "' WHERE `id` = '{$aid}'");
         }
         //$this->insert_db_remote($body,$aid);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::Article($aid);
             iHtml::forum($fid, 1, 0, 1);
         }
         if ($status) {
             if ($art->fid != $fid) {
                 iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 ");
                 iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
             }
             javascript::dialog('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL);
         } else {
             javascript::dialog('您的文章编辑完成!<br />该版块文章需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10);
         }
     }
 }