Example #1
0
 if ($TimeStamp - $CurUserInfo['LastPostTime'] <= 5) {
     //发帖至少要间隔5秒
     AlertMsg($Lang['Posting_Too_Often'], $Lang['Posting_Too_Often']);
 }
 $Title = Request('Post', 'Title');
 $Content = Request('Post', 'Content');
 $TagsArray = $_POST['Tag'];
 if ($Title) {
     if (strlen($Title) <= $Config['MaxTitleChars'] || strlen($Content) <= $Config['MaxPostChars']) {
         if (!empty($TagsArray) && !in_array('', $TagsArray) && count($TagsArray) <= $Config["MaxTagsNum"]) {
             //获取已存在的标签
             $TagsExistArray = $DB->query("SELECT ID,Name FROM `" . $Prefix . "tags` WHERE `Name` in (?)", $TagsArray);
             $TagsExist = ArrayColumn($TagsExistArray, 'Name');
             $TagsID = ArrayColumn($TagsExistArray, 'ID');
             //var_dump($TagsExist);
             $NewTags = TagsDiff($TagsArray, $TagsExist);
             //新建不存在的标签
             if ($NewTags) {
                 foreach ($NewTags as $Name) {
                     $DB->query("INSERT INTO `" . $Prefix . "tags` \r\n\t\t\t\t\t\t\t(`ID`, `Name`,`Followers`,`Icon`,`Description`, `IsEnabled`, `TotalPosts`, `MostRecentPostTime`, `DateCreated`) \r\n\t\t\t\t\t\t\tVALUES (?,?,?,?,?,?,?,?,?)", array(null, htmlspecialchars(trim($Name)), 0, 0, null, 1, 1, $TimeStamp, $TimeStamp));
                     $TagsID[] = $DB->lastInsertId();
                 }
                 //更新全站统计数据
                 $NewConfig = array("NumTags" => $Config["NumTags"] + count($NewTags));
                 //var_dump($NewTags);
             }
             $TagsArray = array_merge($TagsExist, $NewTags);
             //往Topics表插入数据
             $TopicData = array("ID" => null, "Topic" => htmlspecialchars($Title), "Tags" => implode("|", $TagsArray), "UserID" => $CurUserID, "UserName" => $CurUserName, "LastName" => "", "PostTime" => $TimeStamp, "LastTime" => $TimeStamp, "IsGood" => 0, "IsTop" => 0, "IsLocked" => 0, "IsDel" => 0, "IsVote" => 0, "Views" => 0, "Replies" => 0, "Favorites" => 0, "RatingSum" => 0, "TotalRatings" => 0, "LastViewedTime" => 0, "PostsTableName" => null, "ThreadStyle" => "", "Lists" => "", "ListsTime" => $TimeStamp, "Log" => "");
             $NewTopicResult = $DB->query("INSERT INTO `" . $Prefix . "topics` \r\n\t\t\t\t\t(\r\n\t\t\t\t\t\t`ID`, \r\n\t\t\t\t\t\t`Topic`, \r\n\t\t\t\t\t\t`Tags`, \r\n\t\t\t\t\t\t`UserID`, \r\n\t\t\t\t\t\t`UserName`, \r\n\t\t\t\t\t\t`LastName`, \r\n\t\t\t\t\t\t`PostTime`, \r\n\t\t\t\t\t\t`LastTime`, \r\n\t\t\t\t\t\t`IsGood`, \r\n\t\t\t\t\t\t`IsTop`, \r\n\t\t\t\t\t\t`IsLocked`, \r\n\t\t\t\t\t\t`IsDel`, \r\n\t\t\t\t\t\t`IsVote`, \r\n\t\t\t\t\t\t`Views`, \r\n\t\t\t\t\t\t`Replies`, \r\n\t\t\t\t\t\t`Favorites`, \r\n\t\t\t\t\t\t`RatingSum`, \r\n\t\t\t\t\t\t`TotalRatings`, \r\n\t\t\t\t\t\t`LastViewedTime`, \r\n\t\t\t\t\t\t`PostsTableName`, \r\n\t\t\t\t\t\t`ThreadStyle`, \r\n\t\t\t\t\t\t`Lists`, \r\n\t\t\t\t\t\t`ListsTime`, \r\n\t\t\t\t\t\t`Log`\r\n\t\t\t\t\t) \r\n\t\t\t\t\tVALUES \r\n\t\t\t\t\t(\r\n\t\t\t\t\t\t:ID,\r\n\t\t\t\t\t\t:Topic,\r\n\t\t\t\t\t\t:Tags,\r\n\t\t\t\t\t\t:UserID,\r\n\t\t\t\t\t\t:UserName,\r\n\t\t\t\t\t\t:LastName,\r\n\t\t\t\t\t\t:PostTime,\r\n\t\t\t\t\t\t:LastTime,\r\n\t\t\t\t\t\t:IsGood,\r\n\t\t\t\t\t\t:IsTop,\r\n\t\t\t\t\t\t:IsLocked,\r\n\t\t\t\t\t\t:IsDel,\r\n\t\t\t\t\t\t:IsVote,\r\n\t\t\t\t\t\t:Views,\r\n\t\t\t\t\t\t:Replies,\r\n\t\t\t\t\t\t:Favorites,\r\n\t\t\t\t\t\t:RatingSum,\r\n\t\t\t\t\t\t:TotalRatings,\r\n\t\t\t\t\t\t:LastViewedTime,\r\n\t\t\t\t\t\t:PostsTableName,\r\n\t\t\t\t\t\t:ThreadStyle,\r\n\t\t\t\t\t\t:Lists,\r\n\t\t\t\t\t\t:ListsTime,\r\n\t\t\t\t\t\t:Log\r\n\t\t\t\t\t)", $TopicData);
             $TopicID = $DB->lastInsertId();
Example #2
0
     $TagName = Request('Post', 'TagName');
     if (count(explode('|', $TopicInfo['Tags'])) - 1 >= 1 && $DB->query("DELETE FROM `" . $Prefix . "posttags` \r\n\t\t\t\t\tWHERE TopicID = ? AND TagID = (SELECT ID FROM `" . $Prefix . "tags` WHERE Name = ?)", array($ID, $TagName))) {
         // 更新标签统计数据
         $DB->query("UPDATE `" . $Prefix . "tags` SET TotalPosts=TotalPosts-1 WHERE `Name`=?", array($TagName));
         // 更新Topics表里的Tags缓存
         $DB->query("UPDATE `" . $Prefix . "topics` SET Tags=? WHERE `ID`=?", array(implode('|', TagsDiff(explode('|', $TopicInfo['Tags']), array($TagName))), $ID));
         $Message = 'Success';
     } else {
         AlertMsg('Bad Request', 'Bad Request');
     }
     break;
     //添加标签
 //添加标签
 case 'AddTag':
     Auth(4, $TopicInfo['UserID'], true);
     $TagName = TagsDiff(array(Request('Post', 'TagName')), array());
     if ($TagName && !in_array($TagName[0], explode('|', $TopicInfo['Tags'])) && count(explode('|', $TopicInfo['Tags'])) + 1 <= $Config["MaxTagsNum"]) {
         $TagName = $TagName[0];
         $TagsExist = $DB->row("SELECT ID,Name FROM `" . $Prefix . "tags` WHERE `Name` = ?", array($TagName));
         if (!$TagsExist) {
             $DB->query("INSERT INTO `" . $Prefix . "tags` \r\n\t\t\t\t\t\t\t(`ID`, `Name`,`Followers`,`Icon`,`Description`, `IsEnabled`, `TotalPosts`, `MostRecentPostTime`, `DateCreated`) \r\n\t\t\t\t\t\t\tVALUES (?,?,?,?,?,?,?,?,?)", array(null, htmlspecialchars(trim($TagName)), 0, 0, null, 1, 1, $TimeStamp, $TimeStamp));
             $TagID = $DB->lastInsertId();
             if ($TagID) {
                 $DB->query("INSERT INTO `" . $Prefix . "posttags` \r\n\t\t\t\t\t\t\t\t(`TagID`, `TopicID`, `PostID`) \r\n\t\t\t\t\t\t\t\tVALUES (" . $TagID . ", " . $ID . ", (SELECT ID FROM `" . $Prefix . "posts` WHERE TopicID = " . $ID . " AND IsTopic = 1 LIMIT 1))");
                 //更新全站统计数据
                 $NewConfig = array("NumTags" => $Config["NumTags"] + 1);
                 UpdateConfig($NewConfig);
             }
         } else {
             if ($DB->query("INSERT INTO `" . $Prefix . "posttags` \r\n\t\t\t\t\t\t\t(`TagID`, `TopicID`, `PostID`) \r\n\t\t\t\t\t\t\tVALUES (" . $TagsExist['ID'] . ", " . $ID . ", (SELECT ID FROM `" . $Prefix . "posts` WHERE TopicID = " . $ID . " AND IsTopic = 1 LIMIT 1))")) {
                 // 更新标签统计数据
Example #3
0
 function dotag()
 {
     empty($_POST['id']) && javascript::alert("请选择文章");
     empty($_POST['pattern']) && javascript::alert("请选择操作方式");
     $forum = new forum();
     foreach ($_POST['id'] as $id) {
         $art = iCMS_DB::getRow("SELECT tags,fid FROM `#iCMS@__article` WHERE `id`='{$id}'");
         if ($_POST['pattern'] == 'replace') {
             $tags = dhtmlspecialchars($_POST['tag']);
         } elseif ($_POST['pattern'] == 'addto') {
             $tags = $art->tags ? $art->tags . ',' . dhtmlspecialchars($_POST['tag']) : dhtmlspecialchars($_POST['tag']);
         }
         TagsDiff($tags, $art->tags, $id, $forum->rootid($art->fid));
         $tagsArray = explode(',', $tags);
         $tagsArray = array_unique($tagsArray);
         iCMS_DB::query("UPDATE `#iCMS@__article` SET `tags` = '{$tags}' WHERE `id`='{$id}'");
     }
     javascript::dialog('文章标签更改完成!', "url:1");
 }
Example #4
0
     //insert_db_remote($body,$aid);
     addtags($tags);
     tags_cache();
     if ($isexamine) {
         alert("此栏目文章需要管理员审核,请稍候..", 'url:' . __SELF__ . "?do=article&operation=manage");
     } else {
         if ($iCMS->config['ishtm'] && $visible) {
             include_once iPATH . "include/function/template.php";
             MakeArticleHtm($aid);
         }
         $iCMS->db->query("UPDATE `#iCMS@__catalog` SET `count` = count+1 WHERE `id` ='{$cid}' LIMIT 1 ");
         alert("文章添加完成!", 'url:' . __SELF__ . "?do=article&operation=manage");
     }
 } else {
     $art = $iCMS->db->getRow("SELECT `cid`,`tags` FROM `#iCMS@__article` where `id` ='{$aid}'");
     TagsDiff($tags, $art->tags);
     tags_cache();
     $iCMS->db->update('article', compact('cid', 'title', 'stitle', 'customlink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'pic', 'pubdate', 'type', 'vlink', 'top', 'visible'), array('id' => $aid));
     if ($iCMS->db->getValue("SELECT `id` FROM `#iCMS@__articledata` where `aid` ='{$aid}'")) {
         $iCMS->db->update('articledata', compact('tpl', 'subtitle', 'body'), compact('aid'));
     } else {
         $iCMS->db->insert('articledata', compact('aid', 'subtitle', 'tpl', 'body'));
     }
     //			insert_db_remote($body,$aid);
     if ($isexamine) {
         alert("此栏目文章需要管理员审核,请稍候..", 'url:' . __SELF__ . "?do=article&operation=manage");
     } else {
         if ($iCMS->config['ishtm'] && $visible) {
             include_once iPATH . "include/function/template.php";
             MakeArticleHtm($aid);
         }
Example #5
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) {
             //缺少的字段 填默认空值
             $F = $FArray[$field];
             $content[$field] = '';
             if ($F['type'] == 'number' || $F['type'] == 'calendar') {
                 $content[$field] = 0;
             }
         }
     }
     $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=content&do=manage' : $_POST['REFERER']);
     $forum = new forum();
     empty($content['userid']) && ($content['userid'] = member::$uId);
     $content['postype'] = "0";
     $content['status'] = $forum->forum[$fid]['isexamine'] ? '0' : '1';
     //审核投稿
     if (empty($id)) {
         $content['hits'] = $content['good'] = $content['bad'] = $content['comments'] = 0;
         if ($this->iCMS->config['repeatitle']) {
             iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `title` = '{$title}'") && alert('该标题内容已经存在!请检查是否重复');
         }
         iCMS_DB::insert($table, $content);
         $id = iCMS_DB::$insert_id;
         model::upload($table, $id, $title);
         addtags($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);
         }
         if ($content['status']) {
             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=" . $_POST['table'] . "&mid=" . $mid);
         } else {
             javascript::dialog('您的投稿' . $model['name'] . '发布成功!<br />该版块内容需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . __SELF__ . "?mo=content&do=manage&table=" . $table . "&mid=" . $mid);
         }
     } else {
         $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__{$table}` where `id` ='{$id}'");
         TagsDiff($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 ($content['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('您的' . $model['name'] . '编辑完成!<br />该版块内容需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10);
         }
     }
 }