Esempio n. 1
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;
 }
Esempio n. 2
0
 public function API_list()
 {
     iPHP::app('user.class', 'static');
     user::get_cookie() or iPHP::code(0, 'iCMS:!login', 0, 'json');
     iPHP::app('favorite.func');
     $array = favorite_list(array('userid' => user::$userid));
     iPHP::json($array);
 }
Esempio n. 3
0
 function do_login()
 {
     if ($this->uid) {
         $user = iDB::row("SELECT * FROM `#iCMS@__user` WHERE `uid`='{$this->uid}' LIMIT 1;", ARRAY_A);
         iPHP::app('user.class', 'static');
         user::set_cookie($user['username'], $user['password'], $user);
         $url = iPHP::router(array('/{uid}/', $this->uid), iPHP_ROUTER_REWRITE);
         iPHP::gotourl($url);
     }
 }
Esempio n. 4
0
function favorite_list($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'] . "' ");
    isset($vars['fid']) && ($where_sql .= " AND `fid`='" . (int) $vars['fid'] . "' ");
    isset($vars['mode']) && ($where_sql .= " AND `mode`='" . (int) $vars['mode'] . "'");
    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']) {
        case 'hot':
            $order_sql = " ORDER BY `count` {$by}";
            break;
        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` {$where_sql} ");
        iPHP::assign("fav_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 = iPHP_DEVICE . '/favorite/' . $md5 . "/" . (int) $GLOBALS['page'];
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $rs = iDB::all("SELECT * FROM `#iCMS@__favorite` {$where_sql} {$order_sql} LIMIT {$offset},{$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        $resource = array();
        $vars['user'] && iPHP::app('user.class', 'static');
        if ($rs) {
            foreach ($rs as $key => $value) {
                $value['url'] = iPHP::router(array('/favorite/{id}/', $value['id']), iPHP_ROUTER_REWRITE);
                $vars['user'] && ($value['user'] = user::info($value['uid'], $value['nickname']));
                if (isset($vars['loop'])) {
                    $resource[$key] = $value;
                } else {
                    $resource[$value['id']] = $value;
                }
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Esempio n. 5
0
 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("MOBILE" => iPHP::$mobile, 'COOKIE_PRE' => iPHP_COOKIE_PRE, 'REFER' => __REF__, 'CONFIG' => self::$config, "APP" => array('NAME' => self::$app_name, 'DO' => self::$app_do, 'METHOD' => self::$app_method));
     iPHP::$iTPL->_iTPL_VARS['SAPI'] .= 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');
     }
 }
Esempio n. 6
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');
 }
Esempio n. 7
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: category.tpl.php 2379 2014-03-19 02:37:47Z coolmoo $
 */
function category_array($vars)
{
    $cid = (int) $vars['cid'];
    return iPHP::app("category")->category($cid, false);
}
Esempio n. 8
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: tags.app.php 2406 2014-04-28 02:24:46Z coolmoo $
*/
defined('iPHP') or exit('What are you doing?');
iPHP::app('tag.class', 'static');
class tagsApp
{
    public $callback = array();
    function __construct()
    {
        $this->appid = iCMS_APP_TAG;
        $this->id = (int) $_GET['id'];
        $this->tagcategory = iACP::app('tagcategory');
        $this->categoryApp = iACP::app('category', 'all');
    }
    function do_add()
    {
        $this->id && ($rs = iDB::row("SELECT * FROM `#iCMS@__tags` WHERE `id`='{$this->id}' LIMIT 1;", ARRAY_A));
        $rs['metadata'] && ($rs['metadata'] = json_decode($rs['metadata']));
        include iACP::view('tags.add');
    }
    function do_update()
Esempio n. 9
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');
     }
 }
Esempio n. 10
0
function __article_array($vars, $variable)
{
    $resource = array();
    if ($variable) {
        $articleApp = iPHP::app("article");
        $vars['category_lite'] = true;
        foreach ($variable as $key => $value) {
            $value = $articleApp->value($value, false, $vars);
            if ($value === false) {
                continue;
            }
            if ($vars['page']) {
                $value['page'] = $GLOBALS['page'] ? $GLOBALS['page'] : 1;
                $value['total'] = $total;
            }
            if ($vars['archive'] == "date") {
                $_date = archive_date($value['postime']);
                //var_dump($_date);
                //$_date = get_date($value['postime'],'Ymd');
                unset($resource[$key]);
                $resource[$_date][$key] = $value;
            } else {
                $resource[$key] = $value;
            }
        }
    }
    return $resource;
}
Esempio n. 11
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.app.php 2406 2014-04-28 02:24:46Z coolmoo $
*/
defined('iPHP') or exit('What are you doing?');
iPHP::app('category.class', 'include');
class categoryApp extends category
{
    protected $category_uri = APP_URI;
    protected $category_furi = APP_FURI;
    protected $category_name = "栏目";
    protected $_app = 'article';
    protected $_app_name = '文章';
    protected $_app_table = 'article';
    protected $_app_cid = 'cid';
    protected $_app_indexTPL = '{iTPL}/category.index.htm';
    protected $_app_listTPL = '{iTPL}/category.list.htm';
    protected $_app_contentTPL = '{iTPL}/article.htm';
    function __construct($appid = null)
    {
        $this->cid = (int) $_GET['cid'];
        $this->appid = iCMS_APP_ARTICLE;
        $appid && ($this->appid = $appid);
Esempio n. 12
0
<?php

/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: user.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
defined('iPHP') or exit('What are you doing?');
iPHP::app('user.class', 'static');
function user_data($vars = null)
{
    $vars['uid'] or iPHP::warning('iCMS&#x3a;user&#x3a;data 标签出错! 缺少"uid"属性或"uid"值为空.');
    $uid = $vars['uid'];
    if ($uid == 'me') {
        $uid = 0;
        $auth = user::get_cookie();
        $auth && ($uid = user::$userid);
    }
    if (strpos($uid, ',') === false) {
        $user = (array) user::get($uid);
        if ($vars['data']) {
            $user += (array) user::data($uid);
        }
    } else {
        $uid_array = explode(',', $uid);
        foreach ($uid_array as $key => $value) {
            $user[$key] = (array) user::get($uid);
            if ($vars['data']) {
                $user[$key] += (array) user::data($uid);
Esempio n. 13
0
function __tag_array($vars, $resource)
{
    $tagApp = iPHP::app("tag");
    if ($resource) {
        foreach ($resource as $key => $value) {
            $resource[$key] = $tagApp->value($value);
        }
    }
    return $resource;
}
Esempio n. 14
0
 public function openid()
 {
     if (!isset($_GET['sign'])) {
         return;
     }
     $sign = $_GET['sign'];
     $code = $_GET['code'];
     $state = $_GET['state'];
     $platform_map = array('WX' => 1, 'QQ' => 2, 'WB' => 3, 'TB' => 4);
     $class_name = strtoupper($sign);
     $platform = $platform_map[$class_name];
     $bind = $sign;
     if ($platform) {
         iPHP::app('user.open/' . $class_name . '.class', 'static');
         $api = new $class_name();
         $api->appid = iCMS::$config['open'][$class_name]['appid'];
         $api->appkey = iCMS::$config['open'][$class_name]['appkey'];
         $redirect_uri = rtrim(iCMS::$config['open'][$class_name]['redirect'], '/');
         $api->url = user::login_uri($redirect_uri) . 'sign=' . $sign;
         if (isset($_GET['bind']) && $_GET['bind'] == $sign) {
             $api->get_openid();
         } else {
             $api->callback();
         }
         $userid = user::openid($api->openid, $platform);
         if ($userid) {
             $user = user::get($userid, false);
             user::set_cookie($user->username, $user->password, array('uid' => $userid, 'username' => $user->username, 'nickname' => $user->nickname, 'status' => $user->status));
             $api->cleancookie();
             iPHP::gotourl($this->forward);
         } else {
             if (isset($_GET['bind'])) {
                 $user = array();
                 $user['openid'] = $api->openid;
                 $user['platform'] = $platform;
                 $api->cleancookie();
                 iPHP::assign('user', $user);
                 iPHP::view('iCMS://user/login.htm');
             } else {
                 $user = $api->get_user_info();
                 $user['openid'] = $api->openid;
                 $user['platform'] = $platform;
                 iDB::value("SELECT `uid` FROM `#iCMS@__user` where `nickname`='" . $user['nickname'] . "' LIMIT 1") && ($user['nickname'] = $sign . '_' . $user['nickname']);
                 iPHP::assign('user', $user);
                 iPHP::assign('query', compact(array('sign', 'code', 'state', 'bind')));
                 iPHP::view('iCMS://user/register.htm');
             }
             exit;
         }
     }
 }
Esempio n. 15
0
 function delArticle($id, $uid = '0', $postype = '1')
 {
     $id = (int) $id;
     $id or iPHP::alert("请选择要删除的文章");
     $uid && ($sql = "and `userid`='{$uid}' and `postype`='{$postype}'");
     $art = articleTable::row($id, 'cid,pic,tags', $sql);
     iACP::CP($art['cid'], 'cd', 'alert');
     $frs = articleTable::select_filedata_indexid($id);
     for ($i = 0; $i < count($frs); $i++) {
         if ($frs[$i]) {
             $path = $frs[$i]['path'] . '/' . $frs[$i]['filename'] . '.' . $frs[$i]['ext'];
             iFS::del(iFS::fp($frs[$i]['path'], '+iPATH'));
             $msg .= $this->del_msg($path . ' 文件删除');
         }
     }
     if ($art['tags']) {
         iPHP::app('tag.class', 'static');
         $msg .= tag::del($art['tags']);
     }
     iDB::query("DELETE FROM `#iCMS@__category_map` WHERE `iid` = '{$id}' AND `appid` = '" . $this->appid . "';");
     iDB::query("DELETE FROM `#iCMS@__prop_map` WHERE `iid` = '{$id}' AND `appid` = '" . $this->appid . "' ;");
     articleTable::del_filedata($id, 'indexid');
     $msg .= $this->del_msg('相关文件数据删除');
     articleTable::del_comment($id);
     $msg .= $this->del_msg('评论数据删除');
     articleTable::del($id);
     articleTable::del_data($id);
     $msg .= $this->del_msg('文章数据删除');
     $this->categoryApp->update_count_one($art['cid'], '-');
     $msg .= $this->del_msg('栏目数据更新');
     $msg .= $this->del_msg('删除完成');
     return $msg;
 }
Esempio n. 16
0
 public static function del($tags, $field = 'name', $iid = 0)
 {
     $tagArray = explode(",", $tags);
     $iid && ($sql = "AND `iid`='{$iid}'");
     foreach ($tagArray as $k => $v) {
         $tag = iDB::row("SELECT * FROM `#iCMS@__tags` WHERE `{$field}`='{$v}' LIMIT 1;");
         $tRS = iDB::all("SELECT `iid` FROM `#iCMS@__tags_map` WHERE `node`='{$tag->id}' AND `appid`='" . TAG_APPID . "' {$sql}");
         foreach ((array) $tRS as $TL) {
             $idA[] = $TL['iid'];
         }
         if ($idA) {
             $ids = iPHP::get_ids($idA, null);
             if ($ids) {
                 iPHP::app('apps.class', 'static');
                 $table = APPS::table(TAG_APPID);
                 iDB::query("\n                        UPDATE `#iCMS@__{$table}`\n                        SET `tags`= REPLACE(tags, '{$tag->name},',''),\n                        `tags`= REPLACE(tags, ',{$tag->name}','')\n                        WHERE id IN({$ids})\n                    ");
             }
         }
         self::$remove && iDB::query("DELETE FROM `#iCMS@__tags`  WHERE `{$field}`='{$v}'");
         iDB::query("\n                DELETE FROM\n                `#iCMS@__tags_map`\n                WHERE `node`='{$tag->id}'\n                AND `appid`='" . TAG_APPID . "' {$sql}");
         $ckey = self::tkey($tag->cid);
         iCache::delete($ckey);
     }
 }
Esempio n. 17
0
 public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
 {
     $article['appid'] = iCMS_APP_ARTICLE;
     $categoryApp = iPHP::app("category");
     $category = $categoryApp->category($article['cid'], false);
     if ($tpl) {
         $category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
     } else {
         if (empty($category)) {
             return false;
         }
     }
     if ($category['status'] == 0) {
         return false;
     }
     if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
         return false;
     }
     $_iurlArray = array($article, $category);
     $article['iurl'] = iURL::get('article', $_iurlArray, $page);
     $article['url'] = $article['iurl']->href;
     $article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
     $tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
     if ($vars['category_lite']) {
         $article['category'] = $categoryApp->get_lite($category);
     } else {
         $article['category'] = $category;
     }
     $this->taoke = false;
     if ($art_data) {
         $pageurl = $article['iurl']->pageurl;
         // if(strpos($art_data['body'], '#--iCMS.ArticleData--#')!==false){
         //     iPHP::app('article.table');
         //     $art_data['body'] = articleTable::get_text($article['id']);
         // }
         $art_data['body'] = $this->ubb($art_data['body']);
         preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
         $p_array = array_unique($pic_array[1]);
         if ($p_array) {
             foreach ($p_array as $key => $_pic) {
                 $article['pics'][$key] = trim($_pic);
             }
         }
         if (strpos($art_data['body'], '#--iCMS.Markdown--#') !== false) {
             $art_data['body'] = iPHP::Markdown($art_data['body']);
         }
         $body = explode('#--iCMS.PageBreak--#', $art_data['body']);
         $count = count($body);
         $total = $count + intval(iCMS::$config['article']['pageno_incr']);
         $article['body'] = $this->keywords($body[intval($page - 1)]);
         $article['body'] = $this->taoke($article['body']);
         $article['subtitle'] = $art_data['subtitle'];
         $article['taoke'] = $this->taoke;
         unset($art_data);
         if ($total > 1) {
             $flag = 0;
             $num_nav = '';
             for ($i = $page - 3; $i <= $page - 1; $i++) {
                 if ($i < 1) {
                     continue;
                 }
                 $num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
                 $flag++;
             }
             $num_nav .= '<span class="current">' . $page . '</span>';
             for ($i = $page + 1; $i <= $total; $i++) {
                 $num_nav .= "<a href='" . iPHP::p2num($pageurl, $i) . "' target='_self'>{$i}</a>";
                 $flag++;
                 if ($flag == 6) {
                     break;
                 }
             }
             $index_nav = '<a href="' . $article['url'] . '" class="first" target="_self">' . iPHP::lang('iCMS:page:index') . '</a>';
             $prev_url = iPHP::p2num($pageurl, $page - 1 > 1 ? $page - 1 : 1);
             $prev_nav = '<a href="' . $prev_url . '" class="prev" target="_self">' . iPHP::lang('iCMS:page:prev') . '</a>';
             $next_url = iPHP::p2num($pageurl, $total - $page > 0 ? $page + 1 : $page);
             $next_nav = '<a href="' . $next_url . '" class="next" target="_self">' . iPHP::lang('iCMS:page:next') . '</a>';
             $end_nav = '<a href="' . iPHP::p2num($pageurl, $total) . '" class="end" target="_self">共' . $total . '页</a>';
             $text_nav = $index_nav . $prev_nav . '<span class="current">第' . $page . '页</span>' . $next_nav . $end_nav;
             $pagenav = $index_nav . $prev_nav . $num_nav . $next_nav . $end_nav;
         }
         $article['page'] = array('total' => $total, 'count' => $count, 'current' => $page, 'num' => $num_nav, 'text' => $text_nav, 'nav' => $pagenav, 'prev' => $prev_url, 'next' => $next_url, 'pageurl' => $pageurl, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false);
         unset($index_nav, $prev_nav, $num_nav, $next_nav, $end_nav, $pagenav);
         //var_dump($page,$total,$count);
         if ($pic_array[0]) {
             $img_array = array_unique($pic_array[0]);
             foreach ($img_array as $key => $img) {
                 $img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
                 if (iCMS::$config['article']['pic_center']) {
                     $img_replace[$key] = '<p align="center">' . $img . '</p>';
                 } else {
                     $img_replace[$key] = $img;
                 }
                 if (iCMS::$config['article']['pic_next'] && $count > 1) {
                     $clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
                     $clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
                     if (iCMS::$config['article']['pic_center']) {
                         $img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
                     } else {
                         $img_replace[$key] = '<p>' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p>' . $clickimg . '</p>';
                     }
                 }
             }
             $article['body'] = str_replace($img_array, $img_replace, $article['body']);
         }
     }
     if ($vars['prev_next'] && iCMS::$config['article']['prev_next']) {
         //上一篇
         $prev_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/prev';
         $prev_array = iCache::get($prev_cache);
         if (empty($prev_array)) {
             $prev_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:first'), 'pic' => array(), 'url' => 'javascript:;');
             $prevrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` < '{$article['id']}' AND `cid`='{$article['cid']}' AND `status`='1' order by id DESC LIMIT 1;");
             if ($prevrs) {
                 $prev_array = array('empty' => false, 'title' => $prevrs->title, 'pic' => get_pic($prevrs->pic), 'url' => iURL::get('article', array((array) $prevrs, $category))->href);
             }
             iCache::set($prev_cache, $prev_array);
         }
         $article['prev'] = $prev_array;
         //下一篇
         $next_cache = iPHP_DEVICE . '/article/' . $article['id'] . '/next';
         $next_array = iCache::get($next_cache);
         if (empty($next_array)) {
             $next_array = array('empty' => true, 'title' => iPHP::lang('iCMS:article:last'), 'pic' => array(), 'url' => 'javascript:;');
             $nextrs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id` > '{$article['id']}'  and `cid`='{$article['cid']}' AND `status`='1' order by id ASC LIMIT 1;");
             if ($nextrs) {
                 $next_array = array('empty' => false, 'title' => $nextrs->title, 'pic' => get_pic($nextrs->pic), 'url' => iURL::get('article', array((array) $nextrs, $category))->href);
             }
             iCache::set($next_cache, $next_array);
         }
         $article['next'] = $next_array;
     }
     if ($vars['tags']) {
         $article['tags_fname'] = $category['name'];
         if ($article['tags']) {
             $tagApp = iPHP::app("tag");
             $tagArray = $tagApp->get_array($article['tags']);
             $article['tag_array'] = array();
             foreach ((array) $tagArray as $tk => $tag) {
                 $article['tag_array'][$tk]['name'] = $tag['name'];
                 $article['tag_array'][$tk]['url'] = $tag['url'];
                 $article['tag_array'][$tk]['link'] = $tag['link'];
                 $article['tags_link'] .= $tag['link'];
                 $tag_name_array[] = $tag['name'];
             }
             $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]);
             unset($tagApp, $tagArray, $tag_name_array);
         }
     }
     if ($vars['meta']) {
         if ($article['metadata']) {
             $article['meta'] = unserialize($article['metadata']);
             unset($article['metadata']);
         }
     }
     if ($vars['user']) {
         iPHP::app('user.class', 'static');
         if ($article['postype']) {
             $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']);
         } else {
             $article['user'] = user::info($article['userid'], $article['author']);
         }
     }
     if (strstr($article['source'], '||')) {
         list($s_name, $s_url) = explode('||', $article['source']);
         $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>';
     }
     if (strstr($article['author'], '||')) {
         list($a_name, $a_url) = explode('||', $article['author']);
         $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>';
     }
     $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']);
     $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']);
     if ($article['picdata']) {
         $picdata = unserialize($article['picdata']);
     }
     unset($article['picdata']);
     $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth']));
     $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth']));
     $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth']));
     $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']);
     return $article;
 }
Esempio n. 18
0
 function do_allcategory($dialog = true)
 {
     $category = iPHP::app('category.class');
     $category->cache(true);
     $dialog && iPHP::success('更新完成');
 }
Esempio n. 19
0
 public function value($article, $art_data = "", $vars = array(), $page = 1, $tpl = false)
 {
     $article['appid'] = iCMS_APP_ARTICLE;
     $categoryApp = iPHP::app("category");
     $category = $categoryApp->category($article['cid'], false);
     if ($tpl) {
         $category or iPHP::throw404('运行出错!找不到该文章的栏目缓存<b>cid:' . $article['cid'] . '</b> 请更新栏目缓存或者确认栏目是否存在', 10002);
     } else {
         if (empty($category)) {
             return false;
         }
     }
     if ($category['status'] == 0) {
         return false;
     }
     if (iPHP::$iTPL_MODE == "html" && $tpl && (strstr($category['contentRule'], '{PHP}') || $category['outurl'] || $category['mode'] == "0")) {
         return false;
     }
     $_iurlArray = array($article, $category);
     $article['iurl'] = iURL::get('article', $_iurlArray, $page);
     $article['url'] = $article['iurl']->href;
     $article['link'] = "<a href='{$article['url']}'>{$article['title']}</a>";
     $tpl && $category['mode'] == '1' && iCMS::gotohtml($article['iurl']->path, $article['iurl']->href);
     if ($vars['category_lite']) {
         $article['category'] = $categoryApp->get_lite($category);
     } else {
         $article['category'] = $category;
     }
     $this->taoke = false;
     if ($art_data) {
         $pkey = intval($page - 1);
         $pageurl = $article['iurl']->pageurl;
         if ($article['chapter']) {
             $chapterArray = $art_data;
             $count = count($chapterArray);
             $adid = $chapterArray[$pkey]['id'];
             $art_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $article['id'] . "' AND id='" . (int) $adid . "' LIMIT 1;", ARRAY_A);
         }
         $art_data['body'] = $this->ubb($art_data['body']);
         preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $art_data['body'], $pic_array);
         $p_array = array_unique($pic_array[1]);
         if ($p_array) {
             foreach ($p_array as $key => $_pic) {
                 $article['pics'][$key] = trim($_pic);
             }
         }
         if (substr($art_data['body'], 0, 19) == '#--iCMS.Markdown--#') {
             // $art_data['body']    = iPHP::Markdown($art_data['body']);
             $art_data['body'] = substr($art_data['body'], 19);
             $article['markdown'] = ture;
         }
         if ($article['chapter']) {
             $article['body'] = $art_data['body'];
         } else {
             $body = explode('#--iCMS.PageBreak--#', $art_data['body']);
             $count = count($body);
             $article['body'] = $body[$pkey];
         }
         $total = $count + intval(iCMS::$config['article']['pageno_incr']);
         $article['body'] = $this->keywords($article['body']);
         $article['body'] = $this->taoke($article['body']);
         $article['taoke'] = $this->taoke;
         $article['subtitle'] = $art_data['subtitle'];
         unset($body, $art_data);
         $pageArray = array();
         if ($total > 1) {
             iPHP::loadClass("Pages");
             $_GLOBALS_iPage = $GLOBALS['iPage'];
             $category['mode'] && iCMS::set_html_url($article['iurl']);
             $pageconf = array('page_name' => 'p', 'url' => $pageurl, 'total' => $total, 'perpage' => 1, 'nowindex' => (int) $_GET['p'], 'lang' => iPHP::lang(iPHP_APP . ':page'));
             if ($article['chapter']) {
                 foreach ((array) $chapterArray as $key => $value) {
                     $pageconf['titles'][$key + 1] = $value['subtitle'];
                 }
             }
             $iPages = new iPages($pageconf);
             unset($GLOBALS['iPage']);
             $GLOBALS['iPage'] = $_GLOBALS_iPage;
             unset($_GLOBALS_iPage);
             $pageArray['list'] = $iPages->list_page();
             $pageArray['index'] = $iPages->first_page('array');
             $pageArray['prev'] = $iPages->prev_page('array');
             $pageArray['next'] = $iPages->next_page('array');
             $pageArray['endof'] = $iPages->last_page('array');
             $pagenav = $iPages->show(0);
             $pagetext = $iPages->show(10);
         }
         $article['page'] = array('pn' => $page, 'total' => $total, 'count' => $count, 'current' => $page, 'nav' => $pagenav, 'pageurl' => $pageurl, 'text' => $pagetext, 'PAGES' => $iPages, 'args' => iS::escapeStr($_GET['pageargs']), 'first' => $page == "1" ? true : false, 'last' => $page == $count ? true : false, 'end' => $page == $total ? true : false) + $pageArray;
         $next_url = $pageArray['next']['url'];
         unset($pagenav, $pagetext, $iPages, $pageArray);
         if ($pic_array[0]) {
             $img_array = array_unique($pic_array[0]);
             foreach ($img_array as $key => $img) {
                 $img = str_replace('<img', '<img title="' . $article['title'] . '" alt="' . $article['title'] . '"', $img);
                 if (iCMS::$config['article']['pic_center']) {
                     $img_replace[$key] = '<p align="center">' . $img . '</p>';
                 } else {
                     $img_replace[$key] = $img;
                 }
                 if (iCMS::$config['article']['pic_next'] && $count > 1) {
                     $clicknext = '<a href="' . $next_url . '"><b>' . iPHP::lang('iCMS:article:clicknext') . '</b></a>';
                     $clickimg = '<a href="' . $next_url . '" title="' . $article['title'] . '" class="img">' . $img . '</a>';
                     if (iCMS::$config['article']['pic_center']) {
                         $img_replace[$key] = '<p align="center">' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p align="center">' . $clickimg . '</p>';
                     } else {
                         $img_replace[$key] = '<p>' . $clicknext . '</p>';
                         $img_replace[$key] .= '<p>' . $clickimg . '</p>';
                     }
                 }
             }
             $article['body'] = str_replace($img_array, $img_replace, $article['body']);
         }
     }
     if ($vars['tags']) {
         $article['tags_fname'] = $category['name'];
         if ($article['tags']) {
             $tagApp = iPHP::app("tag");
             $tagArray = $tagApp->get_array($article['tags']);
             $article['tag_array'] = array();
             foreach ((array) $tagArray as $tk => $tag) {
                 $article['tag_array'][$tk] = $tag;
                 $article['tags_link'] .= $tag['link'];
                 $tag_name_array[] = $tag['name'];
             }
             $tag_name_array && ($article['tags_fname'] = $tag_name_array[0]);
             unset($tagApp, $tagArray, $tag_name_array);
         }
     }
     if ($vars['meta']) {
         if ($article['metadata']) {
             $article['meta'] = unserialize($article['metadata']);
             unset($article['metadata']);
         }
     }
     if ($vars['user']) {
         iPHP::app('user.class', 'static');
         if ($article['postype']) {
             $article['user'] = user::empty_info($article['userid'], '#' . $article['editor']);
         } else {
             $article['user'] = user::info($article['userid'], $article['author']);
         }
     }
     if (strstr($article['source'], '||')) {
         list($s_name, $s_url) = explode('||', $article['source']);
         $article['source'] = '<a href="' . $s_url . '" target="_blank">' . $s_name . '</a>';
     }
     if (strstr($article['author'], '||')) {
         list($a_name, $a_url) = explode('||', $article['author']);
         $article['author'] = '<a href="' . $a_url . '" target="_blank">' . $a_name . '</a>';
     }
     $article['hits'] = array('script' => iCMS_API . '?app=article&do=hits&cid=' . $article['cid'] . '&id=' . $article['id'], 'count' => $article['hits'], 'today' => $article['hits_today'], 'yday' => $article['hits_yday'], 'week' => $article['hits_week'], 'month' => $article['hits_month']);
     $article['comment'] = array('url' => iCMS_API . "?app=article&do=comment&appid={$article['appid']}&iid={$article['id']}&cid={$article['cid']}", 'count' => $article['comments']);
     if ($article['picdata']) {
         $picdata = unserialize($article['picdata']);
     }
     unset($article['picdata']);
     $article['pic'] = get_pic($article['pic'], $picdata['b'], get_twh($vars['btw'], $vars['bth']));
     $article['mpic'] = get_pic($article['mpic'], $picdata['m'], get_twh($vars['mtw'], $vars['mth']));
     $article['spic'] = get_pic($article['spic'], $picdata['s'], get_twh($vars['stw'], $vars['sth']));
     $article['param'] = array("appid" => $article['appid'], "iid" => $article['id'], "cid" => $article['cid'], "suid" => $article['userid'], "title" => $article['title'], "url" => $article['url']);
     return $article;
 }
Esempio n. 20
0
 /**
  * [API_weixin 向下兼容]
  */
 public function API_weixin()
 {
     $weixinApp = iPHP::app("weixin");
     $weixinApp->API_interface();
 }