Exemple #1
0
function favorite_data($vars = null)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $where_sql = "WHERE 1=1 ";
    isset($vars['userid']) && ($where_sql .= " AND `uid`='" . (int) $vars['userid'] . "' ");
    $vars['fid'] && ($where_sql .= " AND `fid`='" . (int) $vars['fid'] . "' ");
    isset($vars['appid']) && ($where_sql .= " AND `appid`='" . (int) $vars['appid'] . "' ");
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    $md5 = md5($where_sql . $order_sql);
    $offset = 0;
    if ($vars['page']) {
        $total = iPHP::total($md5, "SELECT count(*) FROM `#iCMS@__favorite_data` {$where_sql} ");
        iPHP::assign("fav_data_total", $total);
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
    }
    if ($vars['cache']) {
        $cache_name = 'favorite_data/' . $md5 . "/" . (int) $GLOBALS['page'];
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__favorite_data` {$where_sql} {$order_sql} LIMIT {$offset},{$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        // $resource = array();
        // if($rs)foreach ($rs as $key => $value) {
        // }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #2
0
 public static function ids($nodes = 0)
 {
     if (empty($nodes)) {
         return false;
     }
     $sql = self::sql($nodes);
     $all = iDB::all($ids . 'Limit 10000');
     return iCMS::get_ids($all, 'iid');
 }
Exemple #3
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: push.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
function push_list($vars)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $where_sql = "WHERE `status`='1'";
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    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 (isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    isset($vars['pid']) && ($where_sql .= " AND `type` ='{$vars['pid']}'");
    isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
    isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
    isset($vars['startdate']) && ($where_sql .= " AND `addtime`>='" . strtotime($vars['startdate']) . "'");
    isset($vars['enddate']) && ($where_sql .= " AND `addtime`<='" . strtotime($vars['enddate']) . "'");
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "addtime":
            $order_sql = " ORDER BY `addtime` {$by}";
            break;
        case "disorder":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` DESC";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/push/' . md5($where_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__push` {$where_sql} {$order_sql} LIMIT {$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['pic'] && ($value['pic'] = iFS::fp($value['pic'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['metadata'] && ($value['metadata'] = unserialize($value['metadata']));
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #4
0
 public function category($id, $tpl = 'index')
 {
     $category = iCache::get('iCMS/category/' . $id);
     if (empty($category) && $tpl) {
         iPHP::throw404('运行出错!找不到该栏目<b>cid:' . $id . '</b> 请更新栏目缓存或者确认栏目是否存在', 20001);
     }
     if ($category['status'] == 0) {
         return false;
     }
     $iurl = iURL::get('category', $category);
     if ($tpl) {
         if (iPHP::$iTPL_MODE == "html" && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || empty($category['mode']))) {
             return false;
         }
         $category['url'] && iPHP::gotourl($category['url']);
         $category['mode'] == '1' && iCMS::gotohtml($iurl->path, $iurl->href);
     }
     $category['iurl'] = (array) $iurl;
     $category['subid'] = iCache::get('iCMS/category/rootid', $id);
     $category['subids'] = implode(',', (array) $category['subid']);
     $category = array_merge($category, $this->get_lite($category));
     // if($category['password']){
     //     $category_auth        = iPHP::get_cookie('category_auth_'.$id);
     //     list($ca_cid,$ca_psw) = explode('#=iCMS!=#',authcode($category_auth,'DECODE'));
     // 	if($ca_psw!=md5($category['password'])){
     // 		iPHP::assign('forward',__REF__);
     //  	iPHP::view('{iTPL}/category.password.htm','category.password');
     //  	exit;
     // 	}
     // }
     if ($category['hasbody']) {
         $category['body'] = iCache::get('iCMS/category/' . $category['cid'] . '.body');
         $category['body'] && ($category['body'] = stripslashes($category['body']));
     }
     $category['appid'] = iCMS_APP_CATEGORY;
     $category['param'] = array("appid" => $category['appid'], "iid" => $category['cid'], "cid" => $category['rootid'], "suid" => $category['userid'], "title" => $category['name'], "url" => $category['url']);
     if ($tpl) {
         $category['mode'] && iCMS::set_html_url($iurl);
         iCMS::hooks('enable_comment', true);
         iPHP::assign('category', $category);
         if (strpos($tpl, '.htm') !== false) {
             return iPHP::view($tpl, 'category');
         }
         $GLOBALS['page'] > 1 && ($tpl = 'list');
         $html = iPHP::view($category[$tpl . 'TPL'], 'category.' . $tpl);
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $category);
         }
     } else {
         return $category;
     }
 }
Exemple #5
0
 public function category($id, $tpl = 'index')
 {
     $category = iCache::get('iCMS/category/' . $id);
     if (empty($category) && $tpl) {
         iPHP::throw404('运行出错!找不到该栏目<b>cid:' . $id . '</b> 请更新栏目缓存或者确认栏目是否存在', 20001);
     }
     if ($category['status'] == 0) {
         return false;
     }
     $iurl = iURL::get('category', $category);
     if ($tpl) {
         if (iPHP::$iTPL_MODE == "html" && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || empty($category['mode']))) {
             return false;
         }
         $category['url'] && iPHP::gotourl($category['url']);
         $category['mode'] == '1' && iCMS::gotohtml($iurl->path, $iurl->href);
     }
     $category['iurl'] = (array) $iurl;
     $category['subid'] = iCache::get('iCMS/category/rootid', $id);
     $category['subids'] = implode(',', (array) $category['subid']);
     $category = array_merge($category, $this->get_lite($category));
     if ($category['hasbody']) {
         $category['body'] = iCache::get('iCMS/category/' . $category['cid'] . '.body');
         $category['body'] && ($category['body'] = stripslashes($category['body']));
     }
     $category['appid'] = iCMS_APP_CATEGORY;
     $category['param'] = array("appid" => $category['appid'], "iid" => $category['cid'], "cid" => $category['rootid'], "suid" => $category['userid'], "title" => $category['name'], "url" => $category['url']);
     if ($tpl) {
         $category['mode'] && iCMS::set_html_url($iurl);
         iCMS::hooks('enable_comment', true);
         iPHP::assign('category', $category);
         if (isset($_GET['tpl'])) {
             $tpl = iS::escapeStr($_GET['tpl']);
             if (strpos($tpl, '..') !== false) {
                 exit('what the f**k!!');
             } else {
                 $tpl = $tpl . '.htm';
             }
         }
         if (strpos($tpl, '.htm') !== false) {
             return iPHP::view($tpl, 'category');
         }
         $GLOBALS['page'] > 1 && ($tpl = 'list');
         $html = iPHP::view($category[$tpl . 'TPL'], 'category.' . $tpl);
         if (iPHP::$iTPL_MODE == "html") {
             return array($html, $category);
         }
     } else {
         return $category;
     }
 }
Exemple #6
0
 public static function init()
 {
     self::$config = iPHP::config();
     iURL::init(self::$config['router']);
     define('iCMS_DIR', self::$config['router']['DIR']);
     define('iCMS_URL', self::$config['router']['URL']);
     define('iCMS_PUBLIC_URL', self::$config['router']['public_url']);
     define('iCMS_FS_URL', self::$config['FS']['url']);
     define('iCMS_REWRITE', iPHP_ROUTER_REWRITE);
     define('iCMS_API', iCMS_PUBLIC_URL . '/api.php');
     define('iCMS_UI', iCMS_DIR . 'app/ui/common');
     define('iCMS_UI_URL', iCMS_URL . '/app/ui/common');
     define('iCMS_API_URL', iCMS_API . '?app=');
     self::assign_site();
 }
Exemple #7
0
 public function index($a = null)
 {
     $index_name = $a[1] ? $a[1] : iCMS::$config['template']['index_name'];
     $index_tpl = $a[0] ? $a[0] : iCMS::$config['template']['index'];
     $index_name or $index_name = 'index';
     $iurl = iURL::get('index', array('urlRule' => $index_name . iCMS::$config['router']['html_ext']));
     if (iCMS::$config['template']['index_mode'] && iPHP_DEVICE == "desktop") {
         iCMS::gotohtml($iurl->path, $iurl->href);
     }
     if (iPHP::$iTPL_MODE == "html" || iCMS::$config['template']['index_rewrite']) {
         iCMS::set_html_url($iurl);
     }
     $html = iPHP::view($index_tpl);
     if (iPHP::$iTPL_MODE == "html") {
         return array($html, $iurl);
     }
 }
Exemple #8
0
 function do_manage()
 {
     $sql = " where 1=1";
     $cid = (int) $_GET['cid'];
     $tcid = (int) $_GET['tcid'];
     $pid = (int) $_GET['pid'];
     $rootid = (int) $_GET['rootid'];
     $_GET['keywords'] && ($sql .= " AND CONCAT(name,seotitle,subtitle,keywords,description) REGEXP '{$_GET['keywords']}'");
     $sql .= $this->categoryApp->search_sql($cid);
     $sql .= $this->tagcategory->search_sql($tcid, 'tcid');
     $_GET['starttime'] && ($sql .= " AND `pubdate`>='" . iPHP::str2time($_GET['starttime'] . " 00:00:00") . "'");
     $_GET['endtime'] && ($sql .= " AND `pubdate`<='" . iPHP::str2time($_GET['endtime'] . " 23:59:59") . "'");
     $_GET['post_starttime'] && ($sql .= " AND `postime`>='" . iPHP::str2time($_GET['post_starttime'] . " 00:00:00") . "'");
     $_GET['post_endtime'] && ($sql .= " AND `postime`<='" . iPHP::str2time($_GET['post_endtime'] . " 23:59:59") . "'");
     isset($_GET['pic']) && ($sql .= " AND `haspic` ='" . ($_GET['pic'] ? 1 : 0) . "'");
     if (isset($_GET['pid']) && $pid != '-1') {
         $uri_array['pid'] = $pid;
         if ($_GET['pid'] == 0) {
             $sql .= " AND `pid`=''";
         } else {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $map_where = map::where($pid);
         }
     }
     if ($map_where) {
         $map_sql = iCMS::map_sql($map_where);
         $sql = ",({$map_sql}) map {$sql} AND `id` = map.`iid`";
     }
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__tags` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "个标签");
     $limit = 'LIMIT ' . iPHP::$offset . ',' . $maxperpage;
     if ($map_sql || iPHP::$offset) {
         $ids_array = iDB::all("\n                SELECT `id` FROM `#iCMS@__tags` {$sql}\n                ORDER BY {$orderby} {$limit}\n            ");
         //iDB::debug(1);
         $ids = iCMS::get_ids($ids_array);
         $ids = $ids ? $ids : '0';
         $sql = "WHERE `id` IN({$ids})";
         $limit = '';
     }
     $rs = iDB::all("SELECT * FROM `#iCMS@__tags` {$sql} ORDER BY {$orderby} {$limit}");
     $_count = count($rs);
     include iACP::view("tags.manage");
 }
Exemple #9
0
 function do_iCMS()
 {
     //iPHP::app('user.class','static');
     $sql = "WHERE 1=1";
     $pid = $_GET['pid'];
     if ($_GET['keywords']) {
         $sql .= " AND CONCAT(username,nickname) REGEXP '{$_GET['keywords']}'";
     }
     $_GET['gid'] && ($sql .= " AND `gid`='{$_GET['gid']}'");
     if (isset($_GET['status']) && $_GET['status'] !== '') {
         $sql .= " AND `status`='{$_GET['status']}'";
     }
     $_GET['regip'] && ($sql .= " AND `regip`='{$_GET['regip']}'");
     $_GET['loginip'] && ($sql .= " AND `lastloginip`='{$_GET['loginip']}'");
     if (isset($_GET['pid']) && $pid != '-1') {
         $uri_array['pid'] = $pid;
         if ($_GET['pid'] == 0) {
             $sql .= " AND `pid`=''";
         } else {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $map_where = map::where($pid);
         }
     }
     if ($map_where) {
         $map_sql = iCMS::map_sql($map_where);
         $sql = ",({$map_sql}) map {$sql} AND `uid` = map.`iid`";
     }
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "uid DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__user` {$sql}", "G");
     iPHP::pagenav($total, $maxperpage, "个用户");
     $limit = 'LIMIT ' . iPHP::$offset . ',' . $maxperpage;
     if ($map_sql || iPHP::$offset) {
         $ids_array = iDB::all("\n                SELECT `uid` FROM `#iCMS@__user` {$sql}\n                ORDER BY {$orderby} {$limit}\n            ");
         //iDB::debug(1);
         $ids = iCMS::get_ids($ids_array, 'uid');
         $ids = $ids ? $ids : '0';
         $sql = "WHERE `uid` IN({$ids})";
         $limit = '';
     }
     $rs = iDB::all("SELECT * FROM `#iCMS@__user` {$sql} ORDER BY {$orderby} {$limit}");
     $_count = count($rs);
     include iACP::view("user.manage");
 }
Exemple #10
0
 public function search($tpl = false)
 {
     $q = htmlspecialchars(rawurldecode($_GET['q']));
     $encode = mb_detect_encoding($q, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
     if (strtoupper($encode) != 'UTF-8') {
         if (function_exists('iconv')) {
             $q = iconv($encode, 'UTF-8//IGNORE', $q);
         } elseif (function_exists('mb_convert_encoding')) {
             $q = mb_convert_encoding($q, 'UTF-8//IGNORE', $encode);
         }
     }
     $q = iS::escapeStr($q);
     //empty($q) && iPHP::throw404('应用程序运行出错.亲!搜点什么吧!!', 60001);
     $fwd = iCMS::filter($q);
     $fwd && iPHP::throw404('非法搜索词!', 60002);
     $search['title'] = stripslashes($q);
     $search['keyword'] = $q;
     $tpl === false && ($tpl = '{iTPL}/search.htm');
     $q && $this->slog($q);
     iPHP::assign("search", $search);
     return iPHP::view($tpl, 'search');
 }
Exemple #11
0
 public function API_crontab()
 {
     $timeline = iCMS::timeline();
     //var_dump($timeline);
     $pieces = array();
     foreach ($timeline as $key => $bool) {
         $field = "hits_{$key}";
         if ($key == 'yday') {
             if ($bool == 1) {
                 $pieces[] = "`hits_yday` = hits_today";
             } elseif ($bool > 1) {
                 $pieces[] = "`hits_yday` = 0";
             }
         } else {
             $bool or $pieces[] = "`{$field}` = 0";
         }
     }
     $pieces && ($sql = implode(',', $pieces));
     if ($sql) {
         //点击初始化
         iDB::query("UPDATE `#iCMS@__article` SET {$sql}");
         iDB::query("UPDATE `#iCMS@__user` SET {$sql}");
     }
 }
Exemple #12
0
define('__REF__', empty($_SERVER['HTTP_REFERER']) ? '' : dhtmlspecialchars($_SERVER['HTTP_REFERER']));
if (get_magic_quotes_gpc()) {
    $_GET = stripslashes_deep($_GET);
    $_POST = stripslashes_deep($_POST);
    $_COOKIE = stripslashes_deep($_COOKIE);
}
$_GET = add_magic_quotes($_GET);
$_POST = add_magic_quotes($_POST);
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);
require_once iPATH . 'include/mysql.class.php';
require_once iPATH . 'include/FileSystem.class.php';
require_once iPATH . 'include/' . ($config['cacheEngine'] == 'memcached' ? 'memcached' : 'FileCache') . '.class.php';
require_once iPATH . 'include/template/template.class.php';
require_once iPATH . "include/iCMS.class.php";
$uri = parse_url(substr($config['setupURL'], -1) != '/' ? $config['setupURL'] . '/' : $config['setupURL']);
$config['url'] = $config['setupURL'];
$config['dir'] = $uri['path'];
$config['domain'] = substr($uri['host'], strpos($uri['host'], '.') + 1);
$iCMS = new iCMS();
unset($config, $uri);
isset($_GET['page']) && ($page = (int) $_GET['page']);
isset($GLOBALS['page']) && ($GLOBALS['page'] = (int) $GLOBALS['page']);
if (isset($_GET['date'])) {
    list($y, $m, $d) = explode('_', $_GET['date']);
    $iCMS->date = array('y' => $y, 'm' => $m, 'd' => $d, 'total' => date('t', mktime(0, 0, 0, $m + 1, 0, $y)));
}
if (iCMS_TPL_BUG) {
    iCMS_DB::$show_errors = true;
    $iCMS->clear_compiled_tpl();
}
Exemple #13
0
 /**
  * 运行应用程序
  * @param string $app 应用程序名称
  * @param string $do 动作名称
  * @return iCMS
  */
 public static function run($app = NULL, $do = NULL, $args = NULL, $prefix = "do_")
 {
     //empty($app) && $app	= $_GET['app']; //单一入口
     if (empty($app)) {
         $fi = iFS::name(__SELF__);
         $app = $fi['name'];
     }
     if (!in_array($app, self::$apps) && iPHP_DEBUG) {
         iPHP::throw404('运行出错!找不到应用程序: <b>' . $app . '</b>', '0001');
     }
     self::$app_path = iPHP_APP_DIR . '/' . $app;
     self::$app_file = self::$app_path . '/' . $app . '.app.php';
     is_file(self::$app_file) or iPHP::throw404('运行出错!找不到文件: <b>' . $app . '.app.php</b>', '0002');
     if ($do === NULL) {
         $do = iPHP_APP;
         $_GET['do'] && ($do = iS::escapeStr($_GET['do']));
     }
     if ($_POST['action']) {
         $do = iS::escapeStr($_POST['action']);
         $prefix = 'ACTION_';
     }
     self::$app_name = $app;
     self::$app_do = $do;
     self::$app_method = $prefix . $do;
     self::$app_tpl = iPHP_APP_DIR . '/' . $app . '/template';
     self::$app_vars = array('VERSION' => iCMS_VER, "MOBILE" => iPHP::$mobile, 'API' => iCMS_API, 'UI' => iCMS_UI, 'UI_URL' => iCMS_UI_URL, 'SAPI' => iCMS_API . '?app=' . self::$app_name, 'COOKIE_PRE' => iPHP_COOKIE_PRE, 'REFER' => __REF__, 'CONFIG' => self::$config, "APP" => array('NAME' => self::$app_name, 'DO' => self::$app_do, 'METHOD' => self::$app_method), "APPID" => array('ARTICLE' => iCMS_APP_ARTICLE, 'CATEGORY' => iCMS_APP_CATEGORY, 'TAG' => iCMS_APP_TAG, 'PUSH' => iCMS_APP_PUSH, 'COMMENT' => iCMS_APP_COMMENT, 'PROP' => ICMS_APP_PROP, 'MESSAGE' => iCMS_APP_MESSAGE, 'FAVORITE' => iCMS_APP_FAVORITE, 'USER' => iCMS_APP_USER));
     define('iCMS_API_URL', iCMS_API . '?app=' . self::$app_name);
     iPHP::$iTPL->_iTPL_VARS = self::$app_vars;
     self::$app = iPHP::app($app);
     if (self::$app_do && self::$app->methods) {
         in_array(self::$app_do, self::$app->methods) or iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中找不到方法定义: <b>' . self::$app_method . '</b>', '0003');
         $method = self::$app_method;
         $args === null && ($args = self::$app_args);
         if ($args) {
             if ($args === 'object') {
                 return self::$app;
             }
             return call_user_func_array(array(self::$app, $method), (array) $args);
         } else {
             method_exists(self::$app, self::$app_method) or iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中 <b>' . self::$app_method . '</b> 方法不存在', '0004');
             return self::$app->{$method}();
         }
     } else {
         iPHP::throw404('运行出错! <b>' . self::$app_name . '</b> 类中 <b>' . self::$app_method . '</b> 方法不存在', '0005');
     }
 }
Exemple #14
0
 public function ACTION_add()
 {
     if (!iCMS::$config['comment']['enable']) {
         iPHP::code(0, 'iCMS:comment:close', 0, 'json');
     }
     iPHP::app('user.class', 'static');
     user::get_cookie() or iPHP::code(0, 'iCMS:!login', 0, 'json');
     $seccode = iS::escapeStr($_POST['seccode']);
     if (iCMS::$config['comment']['seccode']) {
         iPHP::seccode($seccode, true) or iPHP::code(0, 'iCMS:seccode:error', 'seccode', 'json');
     }
     iPHP::app('user.msg.class', 'static');
     $appid = (int) $_POST['appid'];
     $iid = (int) $_POST['iid'];
     $cid = (int) $_POST['cid'];
     $suid = (int) $_POST['suid'];
     $reply_id = (int) $_POST['id'];
     $reply_uid = (int) $_POST['userid'];
     $reply_name = iS::escapeStr($_POST['name']);
     $title = iS::escapeStr($_POST['title']);
     $content = iS::escapeStr($_POST['content']);
     $iid or iPHP::code(0, 'iCMS:article:empty_id', 0, 'json');
     $content or iPHP::code(0, 'iCMS:comment:empty', 0, 'json');
     $fwd = iCMS::filter($content);
     $fwd && iPHP::code(0, 'iCMS:comment:filter', 0, 'json');
     $appid or $appid = iCMS_APP_ARTICLE;
     $addtime = $_SERVER['REQUEST_TIME'];
     $ip = iPHP::getIp();
     $userid = user::$userid;
     $username = user::$nickname;
     $status = iCMS::$config['comment']['examine'] ? '0' : '1';
     $up = '0';
     $down = '0';
     $quote = '0';
     $floor = '0';
     $fields = array('appid', 'cid', 'iid', 'suid', 'title', 'userid', 'username', 'content', 'reply_id', 'reply_uid', 'reply_name', 'addtime', 'status', 'up', 'down', 'ip', 'quote', 'floor');
     $data = compact($fields);
     $id = iDB::insert('comment', $data);
     iDB::query("UPDATE `#iCMS@__article` SET comments=comments+1 WHERE `id` ='{$iid}' limit 1");
     user::update_count($userid, 1, 'comments');
     if (iCMS::$config['comment']['examine']) {
         iPHP::code(0, 'iCMS:comment:examine', $id, 'json');
     }
     iPHP::code(1, 'iCMS:comment:success', $id, 'json');
 }
Exemple #15
0
 public function value($tag)
 {
     $categoryApp = iPHP::app("category");
     if ($tag['cid']) {
         $category = $categoryApp->category($tag['cid'], false);
         $tag['category'] = $categoryApp->get_lite($category);
     }
     if ($tag['tcid']) {
         $tag_category = $categoryApp->category($tag['tcid'], false);
         $tag['tag_category'] = $categoryApp->get_lite($tag_category);
     }
     $tag['iurl'] = iURL::get('tag', array($tag, $category, $tag_category));
     $tag['url'] or $tag['url'] = $tag['iurl']->href;
     $tag['link'] = '<a href="' . $tag['url'] . '" class="tag" target="_blank">' . $tag['name'] . '</a>';
     if ($category['mode'] && stripos($tag['url'], '.php?') === false) {
         iCMS::set_html_url($tag['iurl']);
     }
     $tag['metadata'] && ($tag['meta'] = json_decode($tag['metadata']));
     $tag['related'] && ($tag['relArray'] = explode(',', $tag['related']));
     $tag['appid'] = iCMS_APP_TAG;
     $tag['pic'] = get_pic($tag['pic']);
     $tag['bpic'] = get_pic($tag['bpic']);
     $tag['mpic'] = get_pic($tag['mpic']);
     $tag['spic'] = get_pic($tag['spic']);
     return $tag;
 }
Exemple #16
0
function article_search($vars)
{
    if (empty(iCMS::$config['sphinx']['host'])) {
        return array();
    }
    $resource = array();
    $hidden = iCache::get('iCMS/category/hidden');
    $hidden && ($where_sql .= iPHP::where($hidden, 'cid', 'not'));
    $SPH = iCMS::sphinx();
    $SPH->init();
    $SPH->SetArrayResult(true);
    if (isset($vars['weights'])) {
        //weights='title:100,tags:80,keywords:60,name:50'
        $wa = explode(',', $vars['weights']);
        foreach ($wa as $wk => $wv) {
            $waa = explode(':', $wv);
            $FieldWeights[$waa[0]] = $waa[1];
        }
        $FieldWeights or $FieldWeights = array("title" => 100, "tags" => 80, "name" => 60, "keywords" => 40);
        $SPH->SetFieldWeights($FieldWeights);
    }
    $page = (int) $_GET['page'];
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $start = $page && isset($vars['page']) ? ($page - 1) * $maxperpage : 0;
    $SPH->SetMatchMode(SPH_MATCH_EXTENDED);
    if ($vars['mode']) {
        $vars['mode'] == "SPH_MATCH_BOOLEAN" && $SPH->SetMatchMode(SPH_MATCH_BOOLEAN);
        $vars['mode'] == "SPH_MATCH_ANY" && $SPH->SetMatchMode(SPH_MATCH_ANY);
        $vars['mode'] == "SPH_MATCH_PHRASE" && $SPH->SetMatchMode(SPH_MATCH_PHRASE);
        $vars['mode'] == "SPH_MATCH_ALL" && $SPH->SetMatchMode(SPH_MATCH_ALL);
        $vars['mode'] == "SPH_MATCH_EXTENDED" && $SPH->SetMatchMode(SPH_MATCH_EXTENDED);
    }
    isset($vars['userid']) && $SPH->SetFilter('userid', array($vars['userid']));
    isset($vars['postype']) && $SPH->SetFilter('postype', array($vars['postype']));
    if (isset($vars['cid'])) {
        $cids = $vars['sub'] ? iCMS::get_category_ids($vars['cid'], true) : (array) $vars['cid'];
        $cids or $cids = (array) $vars['cid'];
        $cids = array_map("intval", $cids);
        $SPH->SetFilter('cid', $cids);
    }
    if (isset($vars['startdate'])) {
        $startime = strtotime($vars['startdate']);
        $enddate = empty($vars['enddate']) ? time() : strtotime($vars['enddate']);
        $SPH->SetFilterRange('pubdate', $startime, $enddate);
    }
    $SPH->SetLimits($start, $maxperpage, 10000);
    $orderby = '@id DESC, @weight DESC';
    $order_sql = ' order by id DESC';
    $vars['orderby'] && ($orderby = $vars['orderby']);
    $vars['ordersql'] && ($order_sql = ' order by ' . $vars['ordersql']);
    $vars['pic'] && $SPH->SetFilter('haspic', array(1));
    $vars['id!'] && $SPH->SetFilter('@id', array($vars['id!']), true);
    $SPH->setSortMode(SPH_SORT_EXTENDED, $orderby);
    $query = str_replace(',', '|', $vars['q']);
    $vars['acc'] && ($query = '"' . $vars['q'] . '"');
    $vars['@'] && ($query = '@(' . $vars['@'] . ') ' . $query);
    $res = $SPH->Query($query, iCMS::$config['sphinx']['index']);
    if (is_array($res["matches"])) {
        foreach ($res["matches"] as $docinfo) {
            $aid[] = $docinfo['id'];
        }
        $aids = implode(',', (array) $aid);
    }
    if (empty($aids)) {
        return;
    }
    $where_sql = " `id` in({$aids})";
    $offset = 0;
    if ($vars['page']) {
        $total = $res['total'];
        iPHP::assign("article_search_total", $total);
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
    }
    $resource = iDB::all("SELECT * FROM `#iCMS@__article` WHERE {$where_sql} {$order_sql} LIMIT {$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $resource = __article_array($vars, $resource);
    return $resource;
}
Exemple #17
0
 function do_save()
 {
     $aid = (int) $_POST['aid'];
     $cid = (int) $_POST['cid'];
     iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert');
     $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'];
     empty($title) && iPHP::alert('标题不能为空!');
     empty($cid) && iPHP::alert('请选择所属栏目');
     empty($body) && empty($url) && iPHP::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;
     isset($_POST['inbox']) && ($status = "0");
     $userid or $userid = iMember::$userid;
     iFS::$userid = $userid;
     $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags));
     if (iCMS::$config['article']['filter']) {
         $fwd = iCMS::filter($title);
         $fwd && iPHP::alert('标题中包含被系统屏蔽的字符,请重新填写。');
         $fwd = iCMS::filter($description);
         $fwd && iPHP::alert('简介中包含被系统屏蔽的字符,请重新填写。');
         // $fwd = iCMS::filter($body);
         // $fwd && iPHP::alert('内容中包含被系统屏蔽的字符,请重新填写。');
     }
     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;
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $picdata = '';
     $ucid = 0;
     $fields = articleTable::fields($aid);
     if (empty($aid)) {
         $postime = $pubdate;
         $hits = $good = $bad = $comments = $chapter = 0;
         $mobile = 0;
         $aid = articleTable::insert(compact($fields));
         iACP::callback($aid, $this, 'primary');
         if ($tags) {
             iPHP::app('tag.class', 'static');
             if (isset($_POST['tag_status'])) {
                 tag::$addStatus = $_POST['tag_status'];
             }
             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 ($this->callback['code']) {
             return array("code" => $this->callback['code'], '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 {
         isset($_POST['ischapter']) or $chapter = 0;
         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));
         iACP::callback($aid, $this, 'primary');
         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);
         if ($_cid != $cid) {
             $this->categoryApp->update_count_one($_cid, '-');
             $this->categoryApp->update_count_one($cid);
         }
         if ($this->callback['code']) {
             return array("code" => $this->callback['code'], '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);
     }
 }
Exemple #18
0
 function do_manage($stype = 'normal')
 {
     $cid = (int) $_GET['cid'];
     $pid = $_GET['pid'];
     //$stype OR $stype = iACP::$app_do;
     $stype_map = array('inbox' => '0', 'normal' => '1', 'trash' => '2', 'examine' => '3', 'off' => '4');
     $map_where = array();
     //status:[0:草稿][1:正常][2:回收][3:待审核][4:不合格]
     //postype: [0:用户][1:管理员]
     $stype && ($this->_status = $stype_map[$stype]);
     if (isset($_GET['pt']) && $_GET['pt'] != '') {
         $this->_postype = (int) $_GET['pt'];
     }
     $sql = "WHERE `status`='{$this->_status}'";
     $this->_postype === 'all' or $sql .= " AND `postype`='{$this->_postype}'";
     if (iACP::MP("ARTICLE.VIEW")) {
         $_GET['userid'] && ($sql .= iPHP::where($_GET['userid'], 'userid'));
     } else {
         $sql .= iPHP::where(iMember::$userid, 'userid');
     }
     if (isset($_GET['pid']) && $pid != '-1') {
         $uri_array['pid'] = $pid;
         if (empty($_GET['pid'])) {
             $sql .= " AND `pid`=''";
         } else {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $map_where += map::where($pid);
         }
     }
     $cp_cids = iACP::CP('__CID__', 'cs');
     //取得所有有权限的栏目ID
     if ($cp_cids) {
         if (is_array($cp_cids)) {
             if ($cid) {
                 array_search($cid, $cp_cids) === false && iACP::permission_msg('栏目[cid:' . $cid . ']', $ret);
             } else {
                 $cids = $cp_cids;
             }
         } else {
             $cids = $cid;
         }
         if ($_GET['sub'] && $cid) {
             $cids = $this->categoryApp->get_ids($cid, true);
             array_push($cids, $cid);
         }
         if ($_GET['scid'] && $cid) {
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $map_where += map::where($cids);
         } else {
             $sql .= iPHP::where($cids, 'cid');
         }
     } else {
         $sql .= iPHP::where('-1', 'cid');
     }
     if ($_GET['keywords']) {
         $kws = $_GET['keywords'];
         switch ($_GET['st']) {
             case "title":
                 $sql .= " AND `title` REGEXP '{$kws}'";
                 break;
             case "tag":
                 $sql .= " AND `tags` REGEXP '{$kws}'";
                 break;
             case "source":
                 $sql .= " AND `source` REGEXP '{$kws}'";
                 break;
             case "weight":
                 $sql .= " AND `weight`='{$kws}'";
                 break;
             case "id":
                 $sql .= " AND `id` REGEXP '{$kws}'";
                 break;
             case "tkd":
                 $sql .= " AND CONCAT(title,keywords,description) REGEXP '{$kws}'";
                 break;
         }
     }
     $_GET['title'] && ($sql .= " AND `title` like '%{$_GET['title']}%'");
     $_GET['tag'] && ($sql .= " AND `tags` REGEXP '[[:<:]]" . preg_quote(rawurldecode($_GET['tag']), '/') . "[[:>:]]'");
     $_GET['starttime'] && ($sql .= " AND `pubdate`>='" . iPHP::str2time($_GET['starttime'] . " 00:00:00") . "'");
     $_GET['endtime'] && ($sql .= " AND `pubdate`<='" . iPHP::str2time($_GET['endtime'] . " 23:59:59") . "'");
     isset($_GET['pic']) && ($sql .= " AND `haspic` ='" . ($_GET['pic'] ? 1 : 0) . "'");
     isset($_GET['userid']) && ($uri_array['userid'] = (int) $_GET['userid']);
     isset($_GET['keyword']) && ($uri_array['keyword'] = $_GET['keyword']);
     isset($_GET['tag']) && ($uri_array['tag'] = $_GET['tag']);
     isset($_GET['pt']) && ($uri_array['pt'] = $_GET['pt']);
     isset($_GET['cid']) && ($uri_array['cid'] = $_GET['cid']);
     $uri_array && ($uri = http_build_query($uri_array));
     $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC";
     $maxperpage = $_GET['perpage'] > 0 ? (int) $_GET['perpage'] : 20;
     if ($map_where) {
         $map_sql = iCMS::map_sql($map_where);
         $sql = ",({$map_sql}) map {$sql} AND `id` = map.`iid`";
     }
     $total = iPHP::total(false, articleTable::count_sql($sql), "G");
     iPHP::pagenav($total, $maxperpage, "篇文章");
     $limit = 'LIMIT ' . iPHP::$offset . ',' . $maxperpage;
     if ($map_sql || iPHP::$offset) {
         // if($map_sql){
         $ids_array = iDB::all("\n                    SELECT `id` FROM `#iCMS@__article` {$sql}\n                    ORDER BY {$orderby} {$limit}\n                ");
         //iDB::debug(1);
         $ids = iCMS::get_ids($ids_array);
         $ids = $ids ? $ids : '0';
         $sql = "WHERE `id` IN({$ids})";
         // }else{
         // $sql = ",(
         // SELECT `id` AS aid FROM `#iCMS@__article` {$sql}
         // ORDER BY {$orderby} {$limit}
         // ) AS art WHERE `id` = art.aid ";
         // }
         $limit = '';
     }
     $rs = iDB::all("SELECT * FROM `#iCMS@__article` {$sql} ORDER BY {$orderby} {$limit}");
     //iDB::debug(1);
     $_count = count($rs);
     include iACP::view("article.manage");
 }
Exemple #19
0
function category_list($vars)
{
    $appid = isset($vars['appid']) ? (int) $vars['appid'] : iCMS_APP_ARTICLE;
    $row = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $status = isset($vars['status']) ? (int) $vars['status'] : "1";
    $where_sql = " WHERE `appid`='{$appid}' AND `status`='{$status}'";
    $resource = array();
    isset($vars['mode']) && ($where_sql .= " AND `mode` = '{$vars['mode']}'");
    if (stripos($vars['cid'], ',') !== false) {
        $vars['cid'] = explode(',', $vars['cid']);
    }
    if (stripos($vars['cid!'], ',') !== false) {
        $vars['cid!'] = explode(',', $vars['cid!']);
    }
    isset($vars['cid']) && !isset($vars['stype']) && ($where_sql .= iPHP::where($vars['cid'], 'cid'));
    isset($vars['cid!']) && ($where_sql .= iPHP::where($vars['cid!'], 'cid', 'not'));
    switch ($vars['stype']) {
        case "top":
            $vars['cid'] && ($where_sql .= iPHP::where($vars['cid'], 'cid'));
            $where_sql .= " AND rootid='0'";
            break;
        case "sub":
            $vars['cid'] && ($where_sql .= iPHP::where($vars['cid'], 'rootid'));
            break;
            // case "subtop":
            // 	$vars['cid'] && $where_sql.= iPHP::where($vars['cid'],'cid');
            // break;
        // case "subtop":
        // 	$vars['cid'] && $where_sql.= iPHP::where($vars['cid'],'cid');
        // break;
        case "suball":
            $where_sql .= iPHP::where(iCMS::get_category_ids($vars['cid'], false), 'cid');
            break;
        case "self":
            $parent = iCache::get('iCMS/category/parent', $vars['cid']);
            $where_sql .= " AND `rootid`='{$parent}'";
            break;
    }
    if (isset($vars['pids'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('prop', iCMS_APP_CATEGORY);
        $where_sql .= map::exists($vars['pids'], '`#iCMS@__category`.cid');
        //主表小 map表大
        //		$map_where=map::where($vars['pids']); //主表大 map表大
        //		$map_ids    = map::ids($vars['pid']);
        //		$map_sql    = map::sql($vars['pid']); //map 表小的用 in
        //		$where_sql.=" AND `pid` = '{$vars['pid']}'";
        //if(empty($map_ids)) return $resource;
        //$where_sql.=" AND `cid` IN ($map_ids)";
        //$where_sql.=" AND `cid` IN ($map_sql)";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/category/' . md5($where_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $rootid_array = iCache::get('iCMS/category/rootid');
        $resource = iDB::all("SELECT * FROM `#iCMS@__category` {$where_sql} ORDER BY `ordernum`,`cid` ASC LIMIT {$row}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['child'] = $rootid_array[$value['cid']] ? true : false;
                $value['url'] = iURL::get('category', $value)->href;
                $value['link'] = "<a href='{$value['url']}'>{$value['name']}</a>";
                if ($value['metadata']) {
                    $mdArray = array();
                    $_metadata = unserialize($value['metadata']);
                    foreach ((array) $_metadata as $mkey => $md) {
                        $mdArray[$mkey] = $md;
                    }
                    $value['metadata'] = $mdArray;
                    unset($_metadata);
                }
                unset($value['contentprop']);
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #20
0
<?php

/**
* iCMS - i Content Management System
* Copyright (c) 2007-2012 idreamsoft.com iiimon Inc. All rights reserved.
*
* @author coolmoo <*****@*****.**>
* @site http://www.idreamsoft.com
* @licence http://www.idreamsoft.com/license.php
* @version 6.0.0
* @$Id: admincp.php 2329 2014-01-02 13:43:18Z coolmoo $
*/
require dirname(__FILE__) . '/../iCMS.php';
iCMS::API();
Exemple #21
0
 public function keywords($content)
 {
     if (iCMS::$config['other']['keyword_limit'] == 0) {
         return $content;
     }
     $keywords = iCache::get('iCMS/keywords');
     if ($keywords) {
         foreach ($keywords as $i => $val) {
             if ($val['times'] > 0) {
                 $search[] = $val['keyword'];
                 $replace[] = '<a class="keyword" target="_blank" href="' . $val['url'] . '">' . $val['keyword'] . '</a>';
             }
         }
         return iCMS::str_replace_limit($search, $replace, stripslashes($content), iCMS::$config['other']['keyword_limit']);
     }
     return $content;
 }
Exemple #22
0
function user_inbox($vars = null)
{
    $maxperpage = 30;
    $where_sql = "WHERE `status` ='1'";
    if ($_GET['user']) {
        if ($_GET['user'] == "10000") {
            $where_sql .= " AND `userid`='10000' AND `friend` IN ('" . user::$userid . "','0')";
        } else {
            $friend = (int) $_GET['user'];
            $where_sql .= " AND `userid`='" . user::$userid . "' AND `friend`='" . $friend . "'";
        }
        $group_sql = '';
        $p_fields = 'COUNT(*)';
        $s_fields = '*';
        iPHP::assign("msg_count", false);
    } else {
        //	 	$where_sql.= " AND (`userid`='".user::$userid."' OR (`userid`='10000' AND `friend`='0'))";
        $where_sql .= " AND `userid`='" . user::$userid . "'";
        $group_sql = ' GROUP BY `friend` DESC';
        $p_fields = 'COUNT(DISTINCT id)';
        $s_fields = 'max(id) AS id ,COUNT(id) AS msg_count,`userid`, `friend`, `send_uid`, `send_name`, `receiv_uid`, `receiv_name`, `content`, `type`, `sendtime`, `readtime`';
        iPHP::assign("msg_count", true);
    }
    $offset = 0;
    $total = iPHP::total($md5, "SELECT {$p_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql}", 'nocache');
    iPHP::assign("msgs_total", $total);
    $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
    $offset = $multi->offset;
    $resource = iDB::all("SELECT {$s_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql} ORDER BY `id` DESC LIMIT {$offset},{$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $msg_type_map = array('0' => '系统信息', '1' => '私信', '2' => '提醒', '3' => '留言');
    if ($resource) {
        foreach ($resource as $key => $value) {
            $value['sender'] = user::info($value['send_uid'], $value['send_name']);
            $value['receiver'] = user::info($value['receiv_uid'], $value['receiv_name']);
            $value['label'] = $msg_type_map[$value['type']];
            if ($value['userid'] == $value['send_uid']) {
                $value['is_sender'] = true;
                $value['user'] = $value['receiver'];
            }
            if ($value['userid'] == $value['receiv_uid']) {
                $value['is_sender'] = false;
                $value['user'] = $value['sender'];
            }
            $value['url'] = iPHP::router(array('/user/inbox/{uid}', $value['user']['uid']), iPHP_ROUTER_REWRITE);
            $resource[$key] = $value;
        }
    }
    return $resource;
}
Exemple #23
0
<?php

/**
* iCMS - i Content Management System
* Copyright (c) 2007-2012 idreamsoft.com iiimon Inc. All rights reserved.
*
* @author coolmoo <*****@*****.**>
* @site http://www.idreamsoft.com
* @licence http://www.idreamsoft.com/license.php
* @version 6.0.0
* $Id: iCMS.php 2408 2014-04-30 18:58:23Z coolmoo $
*/
define('iPHP', TRUE);
define('iPHP_APP', 'iCMS');
//应用名
define('iPATH', dirname(strtr(__FILE__, '\\', '/')) . "/");
//框架初始化
require iPATH . 'config.php';
//框架初始化配置
require iPATH . 'iPHP/iPHP.php';
//iPHP框架文件
require iPHP_APP_CORE . '/iCMS.define.php';
require iPHP_APP_CORE . '/iCMS.version.php';
require iPHP_APP_CORE . '/iCMS.class.php';
require iPHP_APP_CORE . '/iCMS.func.php';
require iPHP_APP_CORE . '/iURL.class.php';
iCMS::init();
Exemple #24
0
<?php

/**
* iCMS - i Content Management System
* Copyright (c) 2007-2012 idreamsoft.com iiimon Inc. All rights reserved.
*
* @author coolmoo <*****@*****.**>
* @site http://www.idreamsoft.com
* @licence http://www.idreamsoft.com/license.php
* @version 6.0.0
* @$Id: category.php 179 2013-03-29 03:21:28Z coolmoo $
*/
require dirname(__FILE__) . '/iCMS.php';
iCMS::run();
Exemple #25
0
 public function API_hits($uid = null)
 {
     $uid === null && ($uid = (int) $_GET['uid']);
     if ($uid) {
         $sql = iCMS::hits_sql();
         iDB::query("UPDATE `#iCMS@__user` SET {$sql} WHERE `uid` ='{$uid}'");
     }
 }
Exemple #26
0
 function Article($id)
 {
     $app = iCMS::run('article', 'article', 'object');
     $htm = $app->article($id);
     $htm or iPHP::alert("文章所属栏目URL规则设置问题! 此栏目下的文章不能生成静态,请修改栏目的访问模式和URL规则");
     $total = $htm[1]['page']['total'];
     $title = $htm[1]['title'];
     iFS::check_ext($htm[1]['iurl']->path) or iPHP::alert("文件类型不合法,禁止生成!<hr />请更改栏目->URL规则设置->内容规则");
     iFS::mkdir($htm[1]['iurl']->dir);
     iFS::write($htm[1]['iurl']->path, $htm[0]);
     if ($total >= 2) {
         for ($ap = 2; $ap <= $total; $ap++) {
             $htm = $app->article($id, $ap);
             $fpath = iPHP::p2num($htm[1]['iurl']->pagepath, $ap);
             iFS::write($fpath, $htm[0]);
         }
     }
     unset($app, $htm);
     return $title;
 }
Exemple #27
0
/**
 * @package iCMS
 * @copyright 2007-2016, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: tag.tpl.php 159 2013-03-23 04:11:53Z coolmoo $
 */
function tag_list($vars)
{
    $where_sql = "WHERE status='1' ";
    $map_where = array();
    if (isset($vars['rootid'])) {
        $where_sql .= " AND `rootid`='" . (int) $vars['rootid'] . "'";
    }
    if (!isset($vars['tcids']) && isset($vars['tcid'])) {
        $where_sql .= iPHP::where($vars['tcid'], 'tcid');
    }
    if (isset($vars['tcids']) && !isset($vars['tcid'])) {
        iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
        map::init('category', iCMS_APP_TAG);
        //$where_sql.= map::exists($vars['tcid'],'`#iCMS@__tags`.id'); //map 表大的用exists
        $map_where += map::where($vars['tcid']);
    }
    if (isset($vars['tcid!'])) {
        $where_sql .= iPHP::where($vars['tcid!'], 'tcid', 'not');
    }
    if (!isset($vars['pids']) && isset($vars['pid'])) {
        $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_TAG);
        //$where_sql.= map::exists($vars['pids'],'`#iCMS@__tags`.id'); //map 表大的用exists
        $map_where += map::where($vars['pids']);
    }
    if (isset($vars['pid!'])) {
        $where_sql .= iPHP::where($vars['pid!'], 'pid', 'not');
    }
    if (!isset($vars['cids']) && isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    if (isset($vars['cids']) && !isset($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_TAG);
            $map_where += map::where($cids);
        }
    }
    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 (isset($vars['keywords'])) {
        //最好使用 iCMS:tag:search
        if (empty($vars['keywords'])) {
            return;
        }
        if (strpos($vars['keywords'], ',') === false) {
            $vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
            $where_sql .= " AND CONCAT(tkey,name,seotitle,keywords) 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(tkey,name,seotitle,keywords) REGEXP '{$keywords}' ";
        }
    }
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    $by = $vars['by'] == 'ASC' ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "hot":
            $order_sql = " ORDER BY `count` {$by}";
            break;
        case "new":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "order":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
            //		case "rand":	$order_sql=" ORDER BY rand() $by";		break;
        //		case "rand":	$order_sql=" ORDER BY rand() $by";		break;
        default:
            $order_sql = " ORDER BY `id` {$by}";
    }
    if ($map_where) {
        $map_sql = iCMS::map_sql($map_where);
        $where_sql = ",({$map_sql}) map {$where_sql} AND `id` = map.`iid`";
    }
    $offset = 0;
    $limit = "LIMIT {$maxperpage}";
    if ($vars['page']) {
        $total = iPHP::total('sql.md5', "SELECT count(*) FROM `#iCMS@__tags` {$where_sql} ");
        iPHP::assign("tags_total", $total);
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
        $limit = "LIMIT {$offset},{$maxperpage}";
        iPHP::assign("tags_list_total", $total);
    }
    if ($vars['orderby'] == 'rand') {
        $ids_array = iCMS::get_rand_ids('#iCMS@__tags', $where_sql, $maxperpage, 'id');
    }
    $hash = md5($where_sql . $order_sql . $limit);
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/tags/' . $md5 . "/" . (int) $GLOBALS['page'];
        $resource = iCache::get($cache_name);
    }
    if ($map_sql || $offset) {
        if ($vars['cache']) {
            $map_cache_name = iPHP_DEVICE . '/tags_map/' . $hash;
            $ids_array = iCache::get($map_cache_name);
        }
        if (empty($ids_array)) {
            $ids_array = iDB::all("SELECT `id` FROM `#iCMS@__tags` {$where_sql} {$order_sql} {$limit}");
            iPHP_SQL_DEBUG && iDB::debug(1);
            $vars['cache'] && iCache::set($map_cache_name, $ids_array, $cache_time);
        }
        //iDB::debug(1);
    }
    if ($ids_array) {
        $ids = iCMS::get_ids($ids_array);
        $ids = $ids ? $ids : '0';
        $where_sql = "WHERE `#iCMS@__tags`.`id` IN({$ids})";
        $limit = '';
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/tags/' . $hash;
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__tags` {$where_sql} {$order_sql} {$limit}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        $resource = __tag_array($vars, $resource);
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Exemple #28
0
 /**
  * [ACTION_create 创建新收藏夹]
  */
 public function ACTION_create()
 {
     $this->__login();
     $uid = user::$userid;
     $nickname = user::$nickname;
     $title = iS::escapeStr($_POST['title']);
     $description = iS::escapeStr($_POST['description']);
     $mode = (int) $_POST['mode'];
     empty($title) && iPHP::code(0, 'iCMS:favorite:create_empty', 0, 'json');
     $fwd = iCMS::filter($title);
     $fwd && iPHP::code(0, 'iCMS:favorite:create_filter', 0, 'json');
     if ($description) {
         $fwd = iCMS::filter($description);
         $fwd && iPHP::code(0, 'iCMS:favorite:create_filter', 0, 'json');
     }
     $max = iDB::value("SELECT COUNT(id) FROM `#iCMS@__favorite` WHERE `uid`='{$uid}'");
     $max >= 10 && iPHP::code(0, 'iCMS:favorite:create_max', 0, 'json');
     $count = 0;
     $follow = 0;
     $fields = array('uid', 'nickname', 'title', 'description', 'follow', 'count', 'mode');
     $data = compact($fields);
     $cid = iDB::insert('favorite', $data);
     $cid && iPHP::code(1, 'iCMS:favorite:create_success', $cid, 'json');
     iPHP::code(0, 'iCMS:favorite:create_failure', 0, 'json');
 }
Exemple #29
0
function comment_form($vars)
{
    if (!iCMS::$hooks['enable_comment']) {
        iPHP::warning('此页面禁止调用 iCMS&#x3a;comment&#x3a;form 标签!');
    }
    if ($vars['ref']) {
        $_vars = iCMS::app_ref($vars['ref']);
        unset($vars['ref']);
        $vars = array_merge($vars, $_vars);
    }
    $vars['iid'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"iid"属性或"iid"值为空.');
    $vars['cid'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"cid"属性或"cid"值为空.');
    $vars['appid'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"appid"属性或"appid"值为空.');
    $vars['title'] or iPHP::warning('iCMS&#x3a;comment&#x3a;form 标签出错! 缺少"title"属性或"title"值为空.');
    switch ($vars['display']) {
        case 'iframe':
            $tpl = 'form.iframe';
            $vars['do'] = 'form';
            break;
        default:
            isset($vars['_display']) && ($vars['display'] = $vars['_display']);
            $vars['param'] = array('suid' => $vars['suid'], 'iid' => $vars['iid'], 'cid' => $vars['cid'], 'appid' => $vars['appid'], 'title' => $vars['title']);
            $tpl = 'form.default';
            break;
    }
    unset($vars['method'], $vars['_display']);
    $vars['query'] = http_build_query($vars);
    iPHP::assign('comment_vars', $vars);
    echo iPHP::view('iCMS://comment/' . $tpl . '.htm');
}