示例#1
0
 function doTag()
 {
     include_once iPATH . 'include/tag.class.php';
     $rs = iTAG::data(0, 10);
     $ul = '<ul style="margin:0; padding:0;">';
     foreach ((array) $rs as $key => $tag) {
         $ul .= '<li><input onclick="inTag(\'' . $tag['name'] . '\',' . $tag['id'] . ')" id="gt_' . $tag['id'] . '" name="gt_' . $tag['id'] . '" class="checkbox" type="checkbox" value="' . $tag['name'] . '" /> <label for="gt_' . $tag['id'] . '">' . $tag['name'] . '</label></li>';
     }
     $ul .= "</ul>";
     echo $ul;
 }
示例#2
0
 function doUpdate()
 {
     if ($_POST['forum']) {
         $forum = new forum();
         $forum->cache();
     }
     if ($_POST['adm']) {
         include_once iPATH . 'admin/advertise.mo.php';
         $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__advertise`", OBJECT);
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             adm($rs[$i]);
         }
     }
     $_POST['tpl'] && $this->iCMS->clear_compiled_tpl();
     $_POST['iCMS_list'] && FS::rmdir(iPATH . 'cache/list');
     $_POST['iCMS_forum'] && FS::rmdir(iPATH . 'cache/forum');
     $_POST['iCMS_tag'] && FS::rmdir(iPATH . 'cache/tags');
     if ($_POST['iCMS_ALL']) {
         FS::rmdir(iPATH . 'cache/list');
         FS::rmdir(iPATH . 'cache/forum');
         FS::rmdir(iPATH . 'cache/tags');
     }
     $_POST['keywords'] && keywords_cache();
     $_POST['tags'] && iTAG::cache();
     if ($_POST['model']) {
         include_once iPATH . 'include/model.class.php';
         model::cache();
     }
     $_POST['config'] && CreateConfigFile();
     if ($_POST['Re-Article-Count']) {
         $rs = iCMS_DB::getArray("SELECT fid FROM `#iCMS@__forum`");
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article where `fid`='" . $rs[$i]['fid'] . "' LIMIT 1 ");
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` ='{$c}' WHERE `fid` ='" . $rs[$i]['fid'] . "' LIMIT 1 ");
         }
     }
     if ($_POST['Re-Tag-Count']) {
         $rs = iCMS_DB::getArray("SELECT id FROM `#iCMS@__tags`");
         $_count = count($rs);
         for ($i = 0; $i < $_count; $i++) {
             $_count = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__taglist` WHERE `tid`='" . $rs[$i]['id'] . "'");
             iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count` = '{$_count}'  WHERE `id` ='" . $rs[$i]['id'] . "'");
             iTAG::cache($rs[$i]['id']);
         }
     }
     javascript::dialog("执行完毕!", 'url:1');
 }
示例#3
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);
     }
 }
示例#4
0
function delArticle($id, $uid = '0', $postype = '1')
{
    global $iCMS;
    $uid && ($sql = "and `userid`='{$uid}' and `postype`='{$postype}'");
    $id = (int) $id;
    $art = iCMS_DB::getRow("SELECT * FROM `#iCMS@__article` WHERE id='{$id}' {$sql} Limit 1");
    if ($art->pic) {
        $usePic = iCMS_DB::getValue("SELECT id FROM `#iCMS@__article` WHERE `pic`='{$art->pic}' and `id`<>'{$id}'");
        if (empty($usePic)) {
            $msg .= delpic($art->pic);
        } else {
            $msg .= $art->pic . '文件 其它文章正在使用,请到文件管理删除…<span style=\'color:green;\'>×</span><br />';
        }
    }
    $forum = $iCMS->getCache('system/forum.cache', $art->fid);
    $body = iCMS_DB::getValue("SELECT `body` FROM `#iCMS@__article_data` WHERE aid='{$id}' Limit 1");
    if ($forum['mode'] && strstr($forum['contentRule'], '{PHP}') === false && empty($art->url)) {
        $bArray = explode('<!--iCMS.PageBreak-->', $body);
        $total = count($bArray);
        for ($i = 1; $i <= $total; $i++) {
            $iurl = $iCMS->iurl('show', array((array) $art, $forum), $i);
            FS::del($iurl->path);
            $msg .= $iurl->path . ' 静态文件删除…<span style=\'color:green;\'>√</span><br />';
        }
    }
    $frs = iCMS_DB::getArray("SELECT `filename`,`path`,`ext` FROM `#iCMS@__file` WHERE `aid`='{$id}'");
    for ($i = 0; $i < count($frs); $i++) {
        if (!empty($frs[$i])) {
            $path = $frs[$i]['path'] . '/' . $frs[$i]['filename'] . '.' . $frs[$i]['ext'];
            FS::del(FS::fp($frs[$i]['path'], '+iPATH'));
            $msg .= $path . ' 文件删除…<span style=\'color:green;\'>√</span><br />';
        }
    }
    if ($art->tags) {
        include_once iPATH . 'include/tag.class.php';
        $msg .= iTAG::del($art->tags);
    }
    iCMS_DB::query("DELETE FROM `#iCMS@__file` WHERE `aid`='{$id}'");
    $msg .= '相关文件数据删除…<span style=\'color:green;\'>√</span><br />';
    iCMS_DB::query("DELETE FROM `#iCMS@__comment` WHERE indexId='{$id}' and mid='0'");
    $msg .= '评论数据删除…<span style=\'color:green;\'>√</span><br />';
    iCMS_DB::query("DELETE FROM `#iCMS@__article` WHERE id='{$id}'");
    iCMS_DB::query("DELETE FROM `#iCMS@__article_data` WHERE `id`='{$id}'");
    iCMS_DB::query("DELETE FROM `#iCMS@__vlink` WHERE indexId='{$id}' AND modelId='0'");
    $msg .= '文章数据删除…<span style=\'color:green;\'>√</span><br />';
    iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1");
    $msg .= '栏目数据更新…<span style=\'color:green;\'>√</span><br />';
    $msg .= '删除完成…<span style=\'color:green;\'>√</span><hr />';
    return $msg;
}
示例#5
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);
         }
     }
 }
示例#6
0
 function dotag()
 {
     include_once iPATH . 'include/tag.class.php';
     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']);
         }
         iTAG::diff($tags, $art->tags, member::$uId, $id, $forum->rootid($art->fid));
         $tags = iTAG::split($tags, true);
         iCMS_DB::query("UPDATE `#iCMS@__article` SET `tags` = '{$tags}' WHERE `id`='{$id}'");
     }
     javascript::dialog('文章标签更改完成!', "url:1");
 }