Beispiel #1
0
"  name="pubdate" type="text" style="width:230px" <?php 
echo $readonly;
?>
/>
            </div>
            <div class="clearfloat mb10"></div>
            <div class="input-prepend"> <span class="add-on">排序</span>
              <input id="ordernum" class="span2" value="<?php 
echo _int($rs['ordernum']);
?>
" name="ordernum" type="text"/>
            </div>
            <div class="clearfloat mb10"></div>
            <div class="input-prepend"> <span class="add-on">权重</span>
              <input id="weight" class="span2" value="<?php 
echo _int($rs['weight']);
?>
" name="weight" type="text"/>
            </div>
            <div class="clearfloat mb10"></div>
            <div class="input-prepend input-append"> <span class="add-on">模板</span>
              <input type="text" name="tpl" class="span6" id="tpl" value="<?php 
echo $rs['tpl'];
?>
"/>
              <a href="<?php 
echo __ADMINCP__;
?>
=files&do=seltpl&from=modal&click=file&target=tpl" class="btn" data-toggle="modal" title="选择模板文件"><i class="fa fa-search"></i> 选择</a> </div>
            <div class="clearfloat mb10"></div>
            <div class="input-prepend"> <span class="add-on">自定链接</span>
Beispiel #2
0
 function do_save()
 {
     $id = (int) $_POST['id'];
     $cid = (int) $_POST['cid'];
     $_cid = (int) $_POST['_cid'];
     $userid = (int) $_POST['userid'];
     $pid = (int) $_POST['pid'];
     $editor = iS::escapeStr($_POST['editor']);
     $ordernum = _int($_POST['ordernum']);
     $addtime = iPHP::str2time($_POST['addtime']);
     $title = iS::escapeStr($_POST['title']);
     $pic = $this->getpic($_POST['pic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $title2 = iS::escapeStr($_POST['title2']);
     $pic2 = $this->getpic($_POST['pic2']);
     $description2 = iS::escapeStr($_POST['description2']);
     $url2 = iS::escapeStr($_POST['url2']);
     $title3 = iS::escapeStr($_POST['title3']);
     $pic3 = $this->getpic($_POST['pic3']);
     $description3 = iS::escapeStr($_POST['description3']);
     $url3 = iS::escapeStr($_POST['url3']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     empty($userid) && ($userid = iMember::$userid);
     empty($title) && iPHP::alert('1.标题必填');
     empty($cid) && iPHP::alert('请选择所属栏目');
     $haspic = empty($pic) ? 0 : 1;
     $status = 1;
     $fields = array('cid', 'rootid', 'pid', 'haspic', 'editor', 'userid', 'title', 'pic', 'url', 'description', 'title2', 'pic2', 'url2', 'description2', 'title3', 'pic3', 'url3', 'description3', 'ordernum', 'metadata', 'addtime', 'hits', 'status');
     $data = compact($fields);
     if (empty($id)) {
         iDB::insert('push', $data);
         iDB::query("UPDATE `#iCMS@__category` SET `count` = count+1 WHERE `cid` ='{$cid}' LIMIT 1 ");
         iPHP::success('推送完成', 'url:' . APP_URI);
     } else {
         iDB::update('push', $data, array('id' => $id));
         if ($_cid != $cid) {
             iDB::query("UPDATE `#iCMS@__category` SET `count` = count-1 WHERE `cid` ='{$_cid}' and `count`>0 LIMIT 1 ");
             iDB::query("UPDATE `#iCMS@__category` SET `count` = count+1 WHERE `cid` ='{$cid}' LIMIT 1 ");
         }
         iPHP::success('编辑完成!', 'url:' . APP_URI);
     }
 }
Beispiel #3
0
      <td><input type="checkbox" class="checkbox" name="id[]" value="<?php 
    echo $rs[$i]['id'];
    ?>
" /></td>
      <td><a href="<?php 
    echo $rs[$i]['url'];
    ?>
" target="_blank"><?php 
    echo $rs[$i]['id'];
    ?>
</a></td>
      <td><input type="text" class="txt" name="ordernum[<?php 
    echo $rs[$i]['id'];
    ?>
]" value="<?php 
    echo _int($rs[$i]['ordernum']);
    ?>
" style="width:40px;"/></td>
      <td><input type="text" class="txt" name="name[<?php 
    echo $rs[$i]['id'];
    ?>
]" value="<?php 
    echo $rs[$i]['name'];
    ?>
" style="width:240px;"/></td>
      <td><select name="sortid[<?php 
    echo $rs[$i]['id'];
    ?>
]" style="width:auto;">
          <option value="0"> == 暂无归类 == </option>
          <?php 
Beispiel #4
0
 * @author		Nazar Mokrynskyi <*****@*****.**>
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

$User = User::instance();
if ($User->guest()) {
    error_code(403);
    return;
}
$fields = ['id', 'login', 'username', 'language', 'timezone', 'avatar'];
$Page = Page::instance();
$Config = Config::instance();
if (isset($Config->route[1])) {
    $id = _int(explode(',', $Config->route[1]));
    $single = count($id) == 1;
    if (!$User->admin() && !($id = array_intersect($id, $User->get_contacts()))) {
        error_code(403);
        $Page->error('User is not in your contacts');
    }
    if ($single) {
        $Page->json($User->get($fields, $id));
    } else {
        $Page->json(array_map(function ($id) use($fields, $User) {
            return $User->get($fields, $id);
        }, $id));
    }
} else {
    error_code(400);
    $Page->error('Specified ids are expected');
Beispiel #5
0
function iCMS_contents($vars, &$iCMS)
{
    if (isset($vars['mid'])) {
        $mId = (int) $vars['mid'];
        $model = $iCMS->getCache('system/models.cache', $mId);
        $table = $model['tbn'];
    } elseif (isset($vars['name'])) {
        $model = $iCMS->getCache('system/models.table', $vars['name']);
        $mId = $model['id'];
        $table = $model['tbn'];
    } else {
        if (isset($iCMS->metadata)) {
            $mId = $iCMS->metadata->mid;
            $table = $iCMS->metadata->table;
            $model = $iCMS->getCache('system/models.cache', $mId);
        } else {
            echo $iCMS->language('error:model.empty');
            return;
        }
    }
    if (empty($model)) {
        echo $iCMS->language('error:model.exit');
        return;
    }
    //----------------------------
    $whereSQL = " status='1'";
    $_cache = $iCMS->getCache(array('system/forum.cache', 'system/forum.hidden'));
    $_cache['system/forum.hidden'] && ($whereSQL .= getSQL($_cache['system/forum.hidden'], 'fid', 'not'));
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
    isset($vars['userid']) && ($whereSQL .= " AND `userid`='{$vars['userid']}'");
    isset($vars['author']) && ($whereSQL .= " AND `author`='{$vars['author']}'");
    isset($vars['top']) && ($whereSQL .= " AND `top`='" . _int($vars['top']) . "'");
    $vars['call'] == 'user' && ($whereSQL .= " AND `postype`='0'");
    $vars['call'] == 'admin' && ($whereSQL .= " AND `postype`='1'");
    $forum = $_cache['system/forum.cache'];
    if (isset($vars['fid!'])) {
        $_Nfid = getfids($vars['fid!']);
        $_Nfid && ($Nfids[] = $_Nfid);
        $vars['sub'] == 'all' && ($Nfids[] = $vars['fid!']);
        $ids = $Nfids && $vars['sub'] == 'all' ? implode(',', $Nfids) : $vars['fid!'];
        $whereSQL .= getSQL($ids, 'fid', 'not');
    }
    if (isset($vars['fid'])) {
        $_fid = getfids($vars['fid']);
        $_fid && ($fids[] = $_fid);
        $vars['sub'] == 'all' && ($fids[] = $vars['fid']);
        $ids = $fids && $vars['sub'] == 'all' ? implode(',', $fids) : $vars['fid'];
        $whereSQL .= getSQL($ids, 'fid');
    }
    isset($vars['type']) && ($whereSQL .= " AND `type` ='{$vars['type']}'");
    $vars['id'] && ($whereSQL .= getSQL($vars['id'], 'id'));
    $vars['id!'] && ($whereSQL .= getSQL($vars['id!'], 'id', 'not'));
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $orderSQL = " ORDER BY `id` {$by}";
            break;
        case "hot":
            $orderSQL = " ORDER BY `hits` {$by}";
            break;
        case "comment":
            $orderSQL = " ORDER BY `comments` {$by}";
            break;
        case "pubdate":
            $orderSQL = " ORDER BY `pubdate` {$by}";
            break;
        case "disorder":
            $orderSQL = " ORDER BY `orderNum` {$by}";
            break;
            //        case "rand":    $orderSQL=" ORDER BY rand() $by";    break;
        //        case "rand":    $orderSQL=" ORDER BY rand() $by";    break;
        case "top":
            $orderSQL = " ORDER BY `top`,`orderNum` ASC";
            break;
        default:
            $orderSQL = " ORDER BY `id` DESC";
    }
    isset($vars['date']) && (list($iCMS->date['y'], $iCMS->date['m'], $iCMS->date['d']) = explode('-', $vars['date']));
    if ($iCMS->date) {
        $day = empty($iCMS->date['d']) ? '01' : $iCMS->date['d'];
        $start = strtotime($iCMS->date['y'] . $iCMS->date['m'] . $day);
        $end = empty($iCMS->date['d']) ? $start + 86400 * $iCMS->date['total'] : $start + 86400;
        $whereSQL .= " AND `pubdate`<='{$end}' AND `pubdate`>='{$start}'";
    } else {
        isset($vars['startdate']) && ($whereSQL .= " AND `pubdate`>='" . strtotime($vars['startdate']) . "'");
        isset($vars['enddate']) && ($whereSQL .= " AND `pubdate`<='" . strtotime($vars['enddate']) . "'");
    }
    isset($vars['where']) && ($whereSQL .= $vars['where']);
    if ($vars['action'] == 'search') {
        $whereSQL .= $iCMS->actionSQL;
    } elseif ($vars['action'] == 'tag') {
        if (empty($vars['tag'])) {
            return false;
        }
        if (is_array($vars['tag'])) {
            $_tCache = $vars['tag'];
        } else {
            $_tCache = $iCMS->getCache($iCMS->getTagKey($vars['tag']));
        }
        if ($_tCache['id']) {
            $tidSQL = 'AND `tid`=\'' . $_tCache['id'] . '\'';
        } else {
            if ($_tCache) {
                foreach ($_tCache as $_tag) {
                    if ($_tag) {
                        $_tids[] = $_tag['id'];
                    }
                }
            }
            if (empty($_tids)) {
                return false;
            }
            $tidSQL = 'AND `tid` in (' . implode(',', $_tids) . ')';
        }
        $countSQL = 'SELECT count(#iCMS@__' . $table . '.id) FROM `#iCMS@__' . $table . '`,`#iCMS@__taglist` WHERE #iCMS@__' . $table . '.id = `indexId` ' . $tidSQL . ' AND  #iCMS@__taglist.modelId=' . $mId . ' AND';
        $selectSQL = 'SELECT #iCMS@__' . $table . '.* FROM `#iCMS@__' . $table . '`,`#iCMS@__taglist` WHERE #iCMS@__' . $table . '.id = `indexId` ' . $tidSQL . ' AND #iCMS@__taglist.modelId=' . $mId . ' AND';
        $orderSQL = " ORDER BY #iCMS@__taglist.indexId {$by}";
        $vars['indexId!'] && ($whereSQL .= getSQL($vars['indexId!'], '#iCMS@__' . $table . '.id', 'not'));
    }
    $offset = 0;
    if ($vars['page']) {
        empty($countSQL) && ($countSQL = "SELECT count(*) FROM `#iCMS@__{$table}` WHERE");
        $total = iCMS_DB::getValue($countSQL . " {$whereSQL}");
        //        echo iCMS_DB::last_query;
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:list'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
        //        $GLOBALS['cpn'] && $iCMS->_vars['pagenav'].='<span><a class="page_more" href="more.php?fid='.$ids.'" target="_self">'.$iCMS->language('page:more').'</a></span>';
        //$iCMS->addto($pagenav,"----------------");
    }
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = array();
    } else {
        $cacheName = 'clist/' . md5($whereSQL . $orderSQL . $maxperpage);
        $rs = $iCMS->getCache($cacheName);
    }
    if (empty($rs)) {
        empty($selectSQL) && ($selectSQL = "SELECT * FROM `#iCMS@__{$table}` WHERE");
        $rs = iCMS_DB::getArray($selectSQL . " {$whereSQL} {$orderSQL} LIMIT {$offset} , {$maxperpage}");
        //echo iCMS_DB::$last_query;
        //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
        //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
        //print_r($explain);
        $_count = count($rs);
        for ($i = 0; $i < $_count; $i++) {
            $F = $forum[$rs[$i]['fid']];
            $rs[$i]['sort']['name'] = $F['name'];
            $rs[$i]['sort']['url'] = $iCMS->iurl('forum', $F)->href;
            $rs[$i]['sort']['link'] = "<a href='{$rs[$i]['sort']['url']}'>{$rs[$i]['sort']['name']}</a>";
            $rs[$i]['url'] = $iCMS->iurl('content', array($rs[$i], $F, $model))->href;
            $rs[$i]['commentUrl'] = $iCMS->config['publicURL'] . "/comment.php?indexId=" . $rs[$i]['id'] . "&mId=" . $mId . "&sortId=" . $rs[$i]['fid'];
            $rs[$i]['link'] = "<a href='{$rs[$i]['url']}'>{$rs[$i]['title']}</a>";
            if ($rs[$i]['tags'] && isset($vars['tag'])) {
                $tagarray = explode(',', $rs[$i]['tags']);
                foreach ($tagarray as $tk => $tag) {
                    $t = $iCMS->getTag($tag);
                    if ($t) {
                        $rs[$i]['tag'][$tk]['name'] = $tag;
                        $rs[$i]['tag'][$tk]['url'] = $t['url']->href;
                        $rs[$i]['taglink'] .= '<a href="' . $rs[$i]['tag'][$tk]['url'] . '" class="tag" target="_self">' . $tag . '</a> ';
                    }
                }
            }
            if ($fArray = explode(',', $model['field'])) {
                foreach ($fArray as $k => $field) {
                    if (!model::isDefField($field)) {
                        $FV = model::FieldValue($mId, $field, $rs[$i][$field]);
                        $FV !== Null && ($rs[$i][$field] = $FV);
                    }
                }
            }
        }
        $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
    }
    //	var_dump($rs);
    return $rs;
}
Beispiel #6
0
use cs\Cache\Prefix, cs\Index, cs\Language, cs\Page;
$Index = Index::instance();
$Page = Page::instance();
$Precincts = Precincts::instance();
if (isset($Index->route_ids[0])) {
    $Page->json($Precincts->get($Index->route_ids[0]));
    header('Cache-Control: max-age=60, public');
    header('Expires: access plus 1 minute');
} else {
    $Cache = new Prefix('precincts');
    $precincts = $Cache->get('all/ids_api/' . Language::instance()->clang, function () use($Precincts) {
        return $Precincts->get($Precincts->get_all());
    });
    if (isset($_GET['id'])) {
        $id = array_unique(_int(explode(',', $_GET['id'])));
        if ($id) {
            $precincts = array_filter($precincts, function ($precinct) use($id) {
                return in_array($precinct['id'], $id);
            });
            $precincts = array_values($precincts);
        }
    }
    if (isset($_GET['number'])) {
        if (isset($_GET['page'])) {
            $page = max((int) $_GET['page'], 1);
        } else {
            $page = 1;
        }
        $number = max((int) $_GET['number'], 1);
        $offset = $number * ($page - 1);
Beispiel #7
0
 function do_save($callback = false)
 {
     $aid = (int) $_POST['aid'];
     $cid = (int) $_POST['cid'];
     $userid = (int) $_POST['userid'];
     $scid = implode(',', (array) $_POST['scid']);
     $pid = implode(',', (array) $_POST['pid']);
     $status = (int) $_POST['status'];
     $chapter = (int) $_POST['chapter'];
     $ordernum = _int($_POST['ordernum']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $_scid = iS::escapeStr($_POST['_scid']);
     $_tags = iS::escapeStr($_POST['_tags']);
     $title = iS::escapeStr($_POST['title']);
     $stitle = iS::escapeStr($_POST['stitle']);
     $pic = iS::escapeStr($_POST['pic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $source = iS::escapeStr($_POST['source']);
     $author = iS::escapeStr($_POST['author']);
     $editor = iS::escapeStr($_POST['editor']);
     $description = iS::escapeStr($_POST['description']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $tags = str_replace(',', ',', iS::escapeStr($_POST['tags']));
     $clink = iS::escapeStr($_POST['clink']);
     $url = iS::escapeStr($_POST['url']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     $body = (array) $_POST['body'];
     $creative = (int) $_POST['creative'];
     iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert');
     empty($_POST['pubdate']) && ($_POST['pubdate'] = get_date(0, 'Y-m-d H:i:s'));
     $pubdate = iPHP::str2time($_POST['pubdate']);
     $weight = _int($_POST['weight']);
     $postype = $_POST['postype'] ? $_POST['postype'] : 0;
     $ischapter = isset($_POST['ischapter']) ? 1 : 0;
     isset($_POST['inbox']) && ($status = "0");
     $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags));
     empty($title) && iPHP::alert('标题不能为空!');
     empty($cid) && iPHP::alert('请选择所属栏目');
     empty($body) && empty($url) && iPHP::alert('文章内容不能为空!');
     $userid or $userid = iMember::$userid;
     iFS::$userid = $userid;
     if (empty($aid) && iCMS::$config['publish']['repeatitle']) {
         articleTable::check_title($title) && iPHP::alert('该标题的文章已经存在!请检查是否重复');
     }
     if (strstr($this->category[$cid]['contentRule'], '{LINK}') !== false) {
         empty($clink) && ($clink = strtolower(pinyin($title)));
         if (empty($aid) && $clink) {
             articleTable::check_clink($clink) && iPHP::alert('该文章自定义链接已经存在!请检查是否重复');
         }
     }
     if (empty($description) && empty($url)) {
         $description = $this->autodesc($body);
     }
     stripos($pic, 'http://') === false or $pic = iFS::http($pic);
     stripos($mpic, 'http://') === false or $mpic = iFS::http($mpic);
     stripos($spic, 'http://') === false or $spic = iFS::http($spic);
     $haspic = empty($pic) ? 0 : 1;
     $SELFURL = __SELF__ . $_POST['REFERER'];
     if (empty($_POST['REFERER']) || strstr($_POST['REFERER'], '=save')) {
         $SELFURL = __SELF__ . '?app=article&do=manage';
     }
     $editor or $editor = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname;
     // if($aid && $ischapter){
     //     $this->article_data($body,$aid);
     //     iDB::query("UPDATE `#iCMS@__article` SET `chapter`=chapter+1  WHERE `id` = '$aid'");
     //     iPHP::success('章节添加完成!','url:'.$SELFURL);
     // }
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $picdata = '';
     $ucid = 0;
     $fields = articleTable::fields($aid);
     if (empty($aid)) {
         $postime = $pubdate;
         $hits = 0;
         $good = $bad = $comments = 0;
         $ischapter && ($chapter = 1);
         $mobile = 0;
         $aid = articleTable::insert(compact($fields));
         if ($this->callback['primary']) {
             $PCB = $this->callback['primary'];
             $handler = $PCB[0];
             $params = (array) $PCB[1] + array('indexid' => $aid);
             if (is_callable($handler)) {
                 call_user_func_array($handler, $params);
             }
         }
         if ($tags) {
             iPHP::app('tag.class', 'static');
             tag::add($tags, $userid, $aid, $cid);
             //articleTable::update(compact('tags'),array('id'=>$aid));
         }
         map::init('prop', $this->appid);
         $pid && map::add($pid, $aid);
         map::init('category', $this->appid);
         map::add($cid, $aid);
         $scid && map::add($scid, $aid);
         $tagArray && tag::map_iid($tagArray, $aid);
         $url or $this->article_data($body, $aid, $haspic);
         $this->categoryApp->update_count_one($cid);
         $article_url = iURL::get('article', array(array('id' => $aid, 'url' => $url, 'cid' => $cid, 'pubdate' => $pubdate), $this->category[$cid]))->href;
         if ($status && iCMS::$config['api']['baidu']['sitemap']['sync']) {
             baidu_ping($article_url);
         }
         if ($callback) {
             return array("code" => $callback, 'indexid' => $aid);
         }
         $moreBtn = array(array("text" => "查看该文章", "target" => '_blank', "url" => $article_url, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => APP_URI . "&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => APP_URI . "&do=add&cid=" . $cid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => iCMS_URL, "target" => '_blank'));
         iPHP::$dialog['lock'] = true;
         iPHP::dialog('success:#:check:#:文章添加完成!<br />10秒后返回文章列表', 'url:' . $SELFURL, 10, $moreBtn);
     } else {
         if ($tags) {
             iPHP::app('tag.class', 'static');
             tag::diff($tags, $_tags, iMember::$userid, $aid, $cid);
         }
         $picdata = $this->picdata($pic, $mpic, $spic);
         articleTable::update(compact($fields), array('id' => $aid));
         if ($this->callback['primary']) {
             $PCB = $this->callback['primary'];
             $handler = $PCB[0];
             $params = (array) $PCB[1] + array('indexid' => $aid);
             if (is_callable($handler)) {
                 call_user_func_array($handler, $params);
             }
         }
         map::init('prop', $this->appid);
         map::diff($pid, $_pid, $aid);
         map::init('category', $this->appid);
         map::diff($cid, $_cid, $aid);
         map::diff($scid, $_scid, $aid);
         $url or $this->article_data($body, $aid, $haspic);
         //$ischapter && $this->chapter_count($aid);
         if ($_cid != $cid) {
             $this->categoryApp->update_count_one($_cid, '-');
             $this->categoryApp->update_count_one($cid);
         }
         if ($callback) {
             return array("code" => $callback, 'indexid' => $aid);
         }
         //       if(!strstr($this->category[$cid]['contentRule'],'{PHP}')&&!$this->category[$cid]['url']&&$this->category[$cid]['mode']=="1" && $status) {
         // 	$htmlApp = iACP::app('html');
         // 	$htmlApp->Article($aid);
         // }
         iPHP::success('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL);
     }
 }
Beispiel #8
0
 function do_batch()
 {
     $idArray = (array) $_POST['id'];
     $idArray or iPHP::alert("请选择要操作的标签");
     $ids = implode(',', $idArray);
     $batch = $_POST['batch'];
     switch ($batch) {
         case 'dels':
             iPHP::$break = false;
             foreach ($idArray as $id) {
                 $this->do_del($id, false);
             }
             iPHP::$break = true;
             iPHP::success('标签全部删除完成!', 'js:1');
             break;
         case 'move':
             $_POST['cid'] or iPHP::alert("请选择目标栏目!");
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $cid = (int) $_POST['cid'];
             foreach ($idArray as $id) {
                 $_cid = iDB::value("SELECT `cid` FROM `#iCMS@__tags` where `id` ='{$id}'");
                 iDB::update("tags", compact('cid'), compact('id'));
                 if ($_cid != $cid) {
                     map::diff($cid, $_cid, $id);
                     $this->categoryApp->update_count_one($_cid, '-');
                     $this->categoryApp->update_count_one($cid);
                 }
             }
             iPHP::success('成功移动到目标栏目!', 'js:1');
             break;
         case 'mvtcid':
             $_POST['tcid'] or iPHP::alert("请选择目标分类!");
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $tcid = (int) $_POST['tcid'];
             foreach ($idArray as $id) {
                 $_tcid = iDB::value("SELECT `tcid` FROM `#iCMS@__tags` where `id` ='{$id}'");
                 iDB::update("tags", compact('tcid'), compact('id'));
                 if ($_tcid != $tcid) {
                     map::diff($tcid, $_tcid, $id);
                     $this->categoryApp->update_count_one($_tcid, '-');
                     $this->categoryApp->update_count_one($tcid);
                 }
             }
             iPHP::success('成功移动到目标分类!', 'js:1');
             break;
         case 'prop':
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $pid = implode(',', (array) $_POST['pid']);
             foreach ((array) $_POST['id'] as $id) {
                 $_pid = iDB::value("SELECT pid FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                 iDB::update("tags", compact('pid'), compact('id'));
                 map::diff($pid, $_pid, $id);
             }
             iPHP::success('属性设置完成!', 'js:1');
             break;
         case 'weight':
             $weight = _int($_POST['mweight']);
             $sql = "`weight` = '{$weight}'";
             break;
         case 'tpl':
             $tpl = iS::escapeStr($_POST['mtpl']);
             $sql = "`tpl` = '{$tpl}'";
             break;
         case 'keyword':
             if ($_POST['pattern'] == 'replace') {
                 $sql = "`keywords` = '" . iS::escapeStr($_POST['mkeyword']) . "'";
             } elseif ($_POST['pattern'] == 'addto') {
                 foreach ($idArray as $id) {
                     $keywords = iDB::value("SELECT keywords FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                     $sql = "`keywords` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mkeyword']) : iS::escapeStr($_POST['mkeyword'])) . "'";
                     iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
                 }
                 iPHP::success('关键字更改完成!', 'js:1');
             }
             break;
         case 'tag':
             if ($_POST['pattern'] == 'replace') {
                 $sql = "`related` = '" . iS::escapeStr($_POST['mtag']) . "'";
             } elseif ($_POST['pattern'] == 'addto') {
                 foreach ($idArray as $id) {
                     $keywords = iDB::value("SELECT related FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                     $sql = "`related` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mtag']) : iS::escapeStr($_POST['mtag'])) . "'";
                     iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
                 }
                 iPHP::success('相关标签更改完成!', 'js:1');
             }
             break;
         default:
             if (strpos($batch, ':')) {
                 $data = iACP::fields($batch);
                 foreach ($idArray as $id) {
                     $data && iDB::update("tags", $data, array('id' => $id));
                 }
                 iPHP::success('操作成功!', 'js:1');
             } else {
                 iPHP::alert('请选择要操作项!', 'js:1');
             }
     }
     $sql && iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id` IN ({$ids})");
     iPHP::success('操作成功!', 'js:1');
 }
Beispiel #9
0
</td>
        <td><?php 
    if ($ourl) {
        ?>
          <img src="admin/images/olink.gif" align="absmiddle" alt="外部链接">
          <?php 
    } elseif ($fid && $fid != $rs[$i]['fid'] && empty($_GET['sub'])) {
        ?>
          虚
          <?php 
    } else {
        echo $rs[$i]['type'];
    }
    ?>
/<?php 
    echo _int($rs[$i]['top']);
    ?>
</td>
        <td><?php 
    echo get_date($rs[$i]['pubdate'], 'Y-m-d H:i');
    ?>
<br /><?php 
    if ($F['mode'] && strstr($F['contentRule'], '{PHP}') === false && $rs[$i]['status'] == "1" && empty($ourl)) {
        echo file_exists($htmlurl) ? "静态" : "无静态";
    } else {
        echo '动态';
    }
    ?>
</td>
      </tr>
      <?php 
Beispiel #10
0
} else {
    ?>
$('#vlink').val(<?php 
    echo (int) $rs['vlink'];
    ?>
);<?php 
}
?>
</script>
          <br />
          按住Ctrl可多选 </td>
      </tr>
      <tr>
        <td class="td40">置顶权重:</td>
        <td colspan="3"><input id="top" class="txt" value="<?php 
echo _int($rs['top']);
?>
" name="top" type="text"/></td>
      </tr>
      <tr>
        <td class="td40">发布时间:</td>
        <td colspan="3"><input id="pubdate" class="txt datepicker" value="<?php 
echo $rs['pubdate'];
?>
" name="pubdate" type="text" style="width:230px"/></td>
      </tr>
      <tr>
        <td class="td40">模板:</td>
        <td colspan="3"><input id="template" class="txt" value="<?php 
echo $rs['tpl'];
?>
Beispiel #11
0
            <input id="'editor" class="span3" value="<?php 
echo $rs['editor'];
?>
" name="editor" type="text"/>
          </div>
          <div class="clearfloat mb10"></div>
          <div class="input-prepend"> <span class="add-on">时间</span>
            <input id="addtime" class="ui-datepicker span3" value="<?php 
echo $rs['addtime'];
?>
"  name="addtime" type="text" />
          </div>
          <div class="clearfloat mb10"></div>
          <div class="input-prepend"> <span class="add-on">排序</span>
            <input id="ordernum" class="span3" value="<?php 
echo _int($rs['ordernum']);
?>
" name="ordernum" type="text"/>
          </div>
          <fieldset>
            <legend>1</legend>
            <div class="input-prepend"> <span class="add-on">标 题</span>
              <input type="text" name="title" class="span6" id="title" value="<?php 
echo $rs['title'];
?>
"/>
            </div>
            <span class="label label-important">必填</span>
            <div class="clearfloat mb10"></div>
            <div class="input-prepend input-append"> <span class="add-on">缩略图</span>
              <input type="text" name="pic" class="span6" id="pic" value="<?php 
Beispiel #12
0
 /**
  * Delete user's groups
  *
  * @param int|int[]		$group	Group id
  * @param bool|int		$user	If not specified - current user assumed
  *
  * @return bool
  */
 function del_groups($group, $user = false)
 {
     $user = (int) ($user ?: $this->id);
     if (!$user || $user == self::GUEST_ID) {
         return false;
     }
     $groups = array_diff($this->get_groups($user), (array) _int($group));
     return $this->set_groups($groups, $user);
 }
Beispiel #13
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);
         }
     }
 }
Beispiel #14
0
echo __ADMINCP__;
?>
=dialog&do=template&click=file&type=htm','tpl','选择模板');" hidefocus=true /></td>
    </tr>
    <tr>
      <td class="td80">权重:</td>
      <td class="rowform"><input name="weight" id="weight" value="<?php 
echo _int($rs->weight);
?>
" type="text" class="txt"  /></td>
      <td class="tips2">&nbsp;</td>
    </tr>
    <tr>
      <td class="td80">排序:</td>
      <td class="rowform"><input name="ordernum" id="ordernum" value="<?php 
echo _int($rs->ordernum);
?>
" type="text" class="txt"  /></td>
      <td class="tips2">&nbsp;</td>
    </tr>
    <tr>
      <td class="td80">状态:</td>
      <td class="rowform"><ul onmouseover="altStyle(this);">
          <li<?php 
if ($rs->status == '1') {
    echo ' class="checked"';
}
?>
>
            <input class="radio" type="radio" name="status" value="1" <?php 
if ($rs->status == '1') {
Beispiel #15
0
 function dotop()
 {
     empty($_POST['id']) && javascript::alert("请选择要设置置顶权重的文章");
     $top = _int($_POST['top']);
     $ids = implode(',', (array) $_POST['id']);
     iCMS_DB::query("UPDATE `#iCMS@__article` SET `top` = '{$top}' WHERE `id` IN ({$ids})");
     javascript::dialog('文章权重设置完成!', "url:1");
 }
Beispiel #16
0
function article_list($vars)
{
    if ($vars['loop'] === "rel" && empty($vars['id'])) {
        return false;
    }
    $resource = array();
    $map_where = array();
    $status = '1';
    isset($vars['status']) && ($status = (int) $vars['status']);
    $where_sql = "WHERE `status`='{$status}'";
    $vars['call'] == 'user' && ($where_sql .= " AND `postype`='0'");
    $vars['call'] == 'admin' && ($where_sql .= " AND `postype`='1'");
    $hidden = iCache::get('iCMS/category/hidden');
    $hidden && ($where_sql .= iPHP::where($hidden, 'cid', 'not'));
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    isset($vars['weight']) && ($where_sql .= " AND `weight`='" . _int($vars['weight']) . "'");
    if (isset($vars['ucid']) && $vars['ucid'] != '') {
        $where_sql .= " AND `ucid`='{$vars['ucid']}'";
    }
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if ($vars['cid'] && !isset($vars['cids'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    if (isset($vars['cids']) && !$vars['cid']) {
        $cids = explode(',', $vars['cids']);
        $vars['sub'] && ($cids += iCMS::get_category_ids($vars['cids'], true));
        if ($cids) {
            iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
            map::init('category', iCMS_APP_ARTICLE);
            $map_where += map::where($cids);
        }
    }
    if (isset($vars['pid']) && !isset($vars['pids'])) {
        $where_sql .= iPHP::where($vars['pid'], 'pid');
    }
    if (isset($vars['pids']) && !isset($vars['pid'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('prop', iCMS_APP_ARTICLE);
        $map_where += map::where($vars['pids']);
    }
    if (isset($vars['tids'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('tags', iCMS_APP_ARTICLE);
        $map_where += map::where($vars['tids']);
    }
    if (isset($vars['keywords'])) {
        //最好使用 iCMS:article:search
        if (empty($vars['keywords'])) {
            return;
        }
        if (strpos($vars['keywords'], ',') === false) {
            $vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
            $where_sql .= " AND CONCAT(title,keywords,description) like '%" . addslashes($vars['keywords']) . "%'";
        } else {
            $kws = explode(',', $vars['keywords']);
            foreach ($kws as $kwv) {
                $keywords .= addslashes($kwv) . "|";
            }
            $keywords = substr($keywords, 0, -1);
            $where_sql .= " AND CONCAT(title,keywords,description) REGEXP '{$keywords}' ";
        }
    }
    $vars['id'] && ($where_sql .= iPHP::where($vars['id'], 'id'));
    $vars['id!'] && ($where_sql .= iPHP::where($vars['id!'], 'id', 'not'));
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
    isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "hot":
            $order_sql = " ORDER BY `hits` {$by}";
            break;
        case "week":
            $order_sql = " ORDER BY `hits_week` {$by}";
            break;
        case "month":
            $order_sql = " ORDER BY `hits_month` {$by}";
            break;
        case "comment":
            $order_sql = " ORDER BY `comments` {$by}";
            break;
        case "pubdate":
            $order_sql = " ORDER BY `pubdate` {$by}";
            break;
        case "disorder":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
        case "rand":
            $order_sql = " ORDER BY rand() {$by}";
            break;
        case "weight":
            $order_sql = " ORDER BY `weight`,`ordernum` ASC";
            break;
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    isset($vars['startdate']) && ($where_sql .= " AND `pubdate`>='" . strtotime($vars['startdate']) . "'");
    isset($vars['enddate']) && ($where_sql .= " AND `pubdate`<='" . strtotime($vars['enddate']) . "'");
    isset($vars['where']) && ($where_sql .= $vars['where']);
    if ($map_where) {
        $map_sql = iCMS::map_sql($map_where, 'join');
        //join
        //empty($vars['cid']) && $map_order_sql = " ORDER BY map.`iid` $by";
        $map_table = 'map';
        $vars['map_order_table'] && ($map_table = $vars['map_order_table']);
        $map_order_sql = " ORDER BY {$map_table}.`iid` {$by}";
        //$map_order_sql = " ORDER BY `icms_article`.`id` $by";
        //
        $where_sql .= ' AND ' . $map_sql['where'];
        $where_sql = ",{$map_sql['from']} {$where_sql} AND `#iCMS@__article`.`id` = {$map_table}.`iid`";
        //derived
        // $where_sql = ",({$map_sql}) map {$where_sql} AND `id` = map.`iid`";
    }
    $offset = 0;
    $limit = "LIMIT {$maxperpage}";
    if ($vars['page']) {
        $total_type = $vars['total_cache'] ? $vars['total_cache'] : null;
        $total = iPHP::total('sql.md5', "SELECT count(*) FROM `#iCMS@__article` {$where_sql}", $total_type);
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $multi = iCMS::page(array('total_type' => $total_type, 'total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
        $limit = "LIMIT {$offset},{$maxperpage}";
        iPHP::assign("article_list_total", $total);
    }
    $hash = md5($where_sql . $order_sql . $limit);
    if ($offset) {
        if ($vars['cache']) {
            $map_cache_name = iPHP_DEVICE . '/article_page/' . $hash;
            $ids_array = iCache::get($map_cache_name);
        }
        if (empty($ids_array)) {
            $ids_order_sql = $map_order_sql ? $map_order_sql : $order_sql;
            $ids_array = iDB::all("SELECT `#iCMS@__article`.`id` FROM `#iCMS@__article` {$where_sql} {$ids_order_sql} {$limit}");
            iPHP_SQL_DEBUG && iDB::debug(1);
            $vars['cache'] && iCache::set($map_cache_name, $ids_array, $cache_time);
        }
        $ids = iCMS::get_ids($ids_array);
        $ids = $ids ? $ids : '0';
        $where_sql = "WHERE `id` IN({$ids})";
        $limit = '';
    } else {
        if ($map_order_sql) {
            $order_sql = $map_order_sql;
        }
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/article/' . $hash;
        $resource = iCache::get($cache_name);
    }
    // $func = '__article_array';
    // if($vars['func']=="user_home"){ //暂时只有一个选项
    //     $func = '__article_user_home_array';
    // }
    if (empty($resource)) {
        $resource = iDB::all("SELECT `#iCMS@__article`.* FROM `#iCMS@__article` {$where_sql} {$order_sql} {$limit}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        $resource = __article_array($vars, $resource);
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    //print_r($resource);
    return $resource;
}
Beispiel #17
0
 function doEdit()
 {
     foreach ((array) $_POST['name'] as $id => $value) {
         iCMS_DB::query("update `#iCMS@__tags` set `name`='{$value}',`sortid`='" . $_POST['sortid'][$id] . "',`ordernum`=" . _int($_POST['ordernum'][$id]) . ",`updatetime`='" . time() . "' where `id`='{$id}'");
         tags_cache($id);
     }
     javascript::dialog('TAG更新完成!', 'url:1');
 }
Beispiel #18
0
 function doadd()
 {
     include iPATH . 'include/from.fun.php';
     $mid = $_GET['mid'];
     $table = model::tbn($_GET['table']);
     $model = model::data($mid);
     $fArray = explode(',', $model['field']);
     $_count = count($fArray);
     $rs = array();
     $id = $_GET['id'];
     $id && ($rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` where `id`='{$id}'", ARRAY_A));
     $rs['mName'] = $_GET['table'];
     $rs['mid'] = $mid;
     $rs['fid'] = empty($rs['fid']) ? intval($_GET['fid']) : $rs['fid'];
     $rs['pubdate'] = empty($id) ? get_date('', "Y-m-d H:i:s") : get_date($rs['pubdate'], 'Y-m-d H:i:s');
     empty($rs['editor']) && ($rs['editor'] = empty(member::$Rs->name) ? member::$Rs->username : member::$Rs->name);
     empty($rs['userid']) && ($rs['userid'] = member::$uId);
     $rs['orderNum'] = _int($rs['orderNum']);
     $rs['top'] = _int($rs['top']);
     $formArray = FormArray($mid, $fArray, $rs);
     $strpos = strpos(__REF__, '?');
     $REFERER = $strpos === false ? '' : substr(__REF__, $strpos);
     include admincp::tpl();
 }
Beispiel #19
0
function iCMS_list($vars, &$iCMS)
{
    if ($vars['loop'] == "rel" && empty($vars['id'])) {
        return false;
    }
    $whereSQL = " status='1'";
    $_cache = $iCMS->getCache(array('system/forum.cache', 'system/forum.hidden'));
    $_cache['system/forum.hidden'] && ($whereSQL .= getSQL($_cache['system/forum.hidden'], 'fid', 'not'));
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
    isset($vars['userid']) && ($whereSQL .= " AND `userid`='{$vars['userid']}'");
    isset($vars['author']) && ($whereSQL .= " AND `author`='{$vars['author']}'");
    isset($vars['top']) && ($whereSQL .= " AND `top`='" . _int($vars['top']) . "'");
    $vars['call'] == 'user' && ($whereSQL .= " AND `postype`='0'");
    $vars['call'] == 'admin' && ($whereSQL .= " AND `postype`='1'");
    $forum = $_cache['system/forum.cache'];
    if (isset($vars['fid!'])) {
        $_Nfid = getfids($vars['fid!']);
        $_Nfid && ($Nfids[] = $_Nfid);
        $vars['sub'] == 'all' && ($Nfids[] = $vars['fid!']);
        $ids = $Nfids && $vars['sub'] == 'all' ? implode(',', $Nfids) : $vars['fid!'];
        $whereSQL .= getSQL($ids, 'fid', 'not');
    }
    if (isset($vars['fid'])) {
        $_fid = getfids($vars['fid']);
        $_fid && ($fids[] = $_fid);
        $vars['sub'] == 'all' && ($fids[] = $vars['fid']);
        $ids = $fids && $vars['sub'] == 'all' ? implode(',', $fids) : $vars['fid'];
        $whereSQL .= getSQL($ids, 'fid');
    }
    isset($vars['type']) && ($whereSQL .= " AND `type` ='{$vars['type']}'");
    $vars['id'] && ($whereSQL .= getSQL($vars['id'], 'id'));
    $vars['id!'] && ($whereSQL .= getSQL($vars['id!'], 'id', 'not'));
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    if ($vars['keywords']) {
        if (strpos($vars['keywords'], ',') === false) {
            $vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
            $whereSQL .= " AND CONCAT(title,keywords,description) like '%" . addslashes($vars['keywords']) . "%'";
        } else {
            $kw = explode(',', $vars['keywords']);
            foreach ($kw as $v) {
                $keywords .= addslashes($v) . "|";
            }
            $keywords = substr($keywords, 0, -1);
            $whereSQL .= "  And CONCAT(title,keywords,description) REGEXP '{$keywords}' ";
        }
    }
    isset($vars['pic']) && ($whereSQL .= " AND `isPic`='1'");
    switch ($vars['orderby']) {
        case "id":
            $orderSQL = " ORDER BY `id` {$by}";
            break;
        case "hot":
            $orderSQL = " ORDER BY `hits` {$by}";
            break;
        case "comment":
            $orderSQL = " ORDER BY `comments` {$by}";
            break;
        case "pubdate":
            $orderSQL = " ORDER BY `pubdate` {$by}";
            break;
        case "disorder":
            $orderSQL = " ORDER BY `orderNum` {$by}";
            break;
            //        case "rand":    $orderSQL=" ORDER BY rand() $by";    break;
        //        case "rand":    $orderSQL=" ORDER BY rand() $by";    break;
        case "top":
            $orderSQL = " ORDER BY `top`,`orderNum` ASC";
            break;
        default:
            $orderSQL = " ORDER BY `id` DESC";
    }
    isset($vars['date']) && (list($iCMS->date['y'], $iCMS->date['m'], $iCMS->date['d']) = explode('-', $vars['date']));
    if ($iCMS->date) {
        $day = empty($iCMS->date['d']) ? '01' : $iCMS->date['d'];
        $start = strtotime($iCMS->date['y'] . $iCMS->date['m'] . $day);
        $end = empty($iCMS->date['d']) ? $start + 86400 * $iCMS->date['total'] : $start + 86400;
        $whereSQL .= " AND `pubdate`<='{$end}' AND `pubdate`>='{$start}'";
    } else {
        isset($vars['startdate']) && ($whereSQL .= " AND `pubdate`>='" . strtotime($vars['startdate']) . "'");
        isset($vars['enddate']) && ($whereSQL .= " AND `pubdate`<='" . strtotime($vars['enddate']) . "'");
    }
    isset($vars['where']) && ($whereSQL .= $vars['where']);
    if ($vars['action'] == 'search') {
        $whereSQL .= $iCMS->actionSQL;
        //    }elseif($vars['action']=='vlink'){
        //        $this->countSQL    = 'SELECT count(#iCMS@__article.id) FROM `#iCMS@__article`,`#iCMS@__vlink` WHERE #iCMS@__article.id = `indexId` AND `fid`=\''.$vars['fid'].'\' AND';
        //        $this->selectSQL= 'SELECT #iCMS@__article.* FROM `#iCMS@__article`,`#iCMS@__vlink` WHERE #iCMS@__article.id = `indexId` AND `fid`=\''.$vars['fid'].'\' AND';
        //         $orderSQL        = " ORDER BY #iCMS@__vlink.indexId $by";
    } elseif ($vars['action'] == 'tag') {
        if (empty($vars['tag'])) {
            return false;
        }
        if (is_array($vars['tag'])) {
            $_tCache = $vars['tag'];
        } else {
            $_tCache = $iCMS->getCache($iCMS->getTagKey($vars['tag']));
        }
        if ($_tCache['id']) {
            $tidSQL = 'AND `tid`=\'' . $_tCache['id'] . '\'';
        } else {
            if ($_tCache) {
                foreach ($_tCache as $_tag) {
                    if ($_tag) {
                        $_tids[] = $_tag['id'];
                    }
                }
            }
            if (empty($_tids)) {
                return false;
            }
            $tidSQL = 'AND `tid` in (' . implode(',', $_tids) . ')';
        }
        $countSQL = 'SELECT count(#iCMS@__article.id) FROM `#iCMS@__article`,`#iCMS@__taglist` WHERE #iCMS@__article.id = `indexId` ' . $tidSQL . ' AND';
        $selectSQL = 'SELECT #iCMS@__article.* FROM `#iCMS@__article`,`#iCMS@__taglist` WHERE #iCMS@__article.id = `indexId` ' . $tidSQL . ' AND';
        $orderSQL = " ORDER BY #iCMS@__taglist.indexId {$by}";
        $vars['indexId!'] && ($whereSQL .= getSQL($vars['indexId!'], '#iCMS@__article.id', 'not'));
    }
    $offset = 0;
    if ($vars['page']) {
        empty($countSQL) && ($countSQL = "SELECT count(*) FROM `#iCMS@__article` WHERE");
        $total = iCMS_DB::getValue($countSQL . " {$whereSQL}");
        //        echo iCMS_DB::last_query;
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:list'), 'url' => $iCMS->url, 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
        //        $GLOBALS['cpn'] && $iCMS->_vars['pagenav'].='<span><a class="page_more" href="more.php?fid='.$ids.'" target="_self">'.$iCMS->language('page:more').'</a></span>';
        //$iCMS->addto($pagenav,"----------------");
    }
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = '';
    } else {
        $cacheName = 'list/' . md5($whereSQL . $orderSQL . $maxperpage);
        $rs = $iCMS->getCache($cacheName);
    }
    if (empty($rs)) {
        empty($selectSQL) && ($selectSQL = "SELECT id,fid,title,stitle,clink,url,source,author,editor,userid,pic,keywords,tags,description,related,pubdate,hits,good,bad,comments,top FROM `#iCMS@__article` WHERE");
        $rs = iCMS_DB::getArray($selectSQL . " {$whereSQL} {$orderSQL} LIMIT {$offset} , {$maxperpage}");
        //echo iCMS_DB::$last_query;
        //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
        //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
        //var_dump($explain);
        $_count = count($rs);
        for ($i = 0; $i < $_count; $i++) {
            $rs[$i]['pic'] && ($rs[$i]['pic'] = uploadpath($rs[$i]['pic'], '+http'));
            $F = $forum[$rs[$i]['fid']];
            $rs[$i]['sort']['name'] = $F['name'];
            $rs[$i]['sort']['url'] = $iCMS->iurl('forum', $F)->href;
            $rs[$i]['sort']['link'] = "<a href='{$rs[$i]['sort']['url']}'>{$rs[$i]['sort']['name']}</a>";
            $rs[$i]['url'] = $iCMS->iurl('show', array($rs[$i], $F))->href;
            $rs[$i]['link'] = "<a href='{$rs[$i]['url']}'>{$rs[$i]['title']}</a>";
            if ($rs[$i]['tags'] && isset($vars['tag'])) {
                $tagarray = explode(',', $rs[$i]['tags']);
                foreach ($tagarray as $tk => $tag) {
                    $t = $iCMS->getTag($tag);
                    if ($t) {
                        $rs[$i]['tag'][$tk]['name'] = $tag;
                        $rs[$i]['tag'][$tk]['url'] = $t['url'];
                        $rs[$i]['taglink'] .= '<a href="' . $rs[$i]['tag'][$tk]['url'] . '" class="tag" target="_self">' . $tag . '</a> ';
                    }
                }
            }
        }
        $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
    }
    return $rs;
}