本文整理汇总了PHP中iPHP::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP iPHP::assign方法的具体用法?PHP iPHP::assign怎么用?PHP iPHP::assign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iPHP
的用法示例。
在下文中一共展示了iPHP::assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tag
public function tag($val, $field = 'name', $tpl = 'tag')
{
$val or iPHP::throw404('运行出错!TAG不能为空', 30002);
$tag = iDB::row("SELECT * FROM `#iCMS@__tags` where `{$field}`='{$val}' AND `status`='1' LIMIT 1;", ARRAY_A);
if (empty($tag)) {
if ($tpl) {
iPHP::throw404('运行出错!找不到标签: <b>' . $field . ':' . $val . '</b>', 30003);
} else {
return false;
}
}
$tag = $this->value($tag);
$tag['param'] = array("appid" => $tag['appid'], "iid" => $tag['id'], "cid" => $tag['cid'], "suid" => $tag['uid'], "title" => $tag['name'], "url" => $tag['url']);
if ($tpl) {
iCMS::hooks('enable_comment', true);
iPHP::assign('category', $tag['category']);
iPHP::assign('tag_category', $tag['tag_category']);
unset($tag['category'], $tag['tag_category']);
iPHP::assign("tag", $tag);
if (strstr($tpl, '.htm')) {
return iPHP::view($tpl, 'tag');
}
$html = iPHP::view($tag['tpl'] ? $tag['tpl'] : '{iTPL}/tag.index.htm', 'tag');
if (iPHP::$iTPL_MODE == "html") {
return array($html, $tag);
}
} else {
return $tag;
}
}
示例2: favorite_data
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;
}
示例3: public_ui
/**
* @package iCMS
* @copyright 2007-2010, iDreamSoft
* @license http://www.idreamsoft.com iDreamSoft
* @author coolmoo <idreamsoft@qq.com>
* @$Id: public.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
*/
function public_ui($vars = null)
{
if (isset($vars['js'])) {
return public_js(array('node' => $vars['js']));
}
isset($vars['script']) or $vars['script'] = true;
$dir = isset($vars['dir']) ? $vars['dir'] . '/' : '';
iPHP::assign("ui", $vars);
echo iPHP::view("iCMS://{$dir}public.ui.htm");
}
示例4: assign_site
public static function assign_site()
{
$site = self::$config['site'];
$site['title'] = self::$config['site']['name'];
$site['404'] = iPHP_URL_404;
$site['url'] = iCMS_URL;
$site['tpl'] = iPHP_DEFAULT_TPL;
$site['urls'] = array("tpl" => iCMS_URL . '/template/' . iPHP_DEFAULT_TPL, "public" => iCMS_PUBLIC_URL, "user" => iPHP_ROUTER_USER, "res" => iCMS_FS_URL, "ui" => iCMS_PUBLIC_URL . '/ui', "avatar" => iCMS_FS_URL . 'avatar/', "mobile" => self::$config['template']['mobile']['domain']);
iPHP::assign('site', $site);
iPHP::$dialog['title'] = self::$config['site']['name'];
}
示例5: category
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;
}
}
示例6: category
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 fuck!!');
} 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;
}
}
示例7: search
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');
}
示例8: article_search
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;
}
示例9: user_inbox
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;
}
示例10: tag_list
//.........这里部分代码省略.........
$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;
}
示例11: openid
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;
}
}
}
示例12: article
public function article($id, $page = 1, $tpl = true)
{
$article = iDB::row("SELECT * FROM `#iCMS@__article` WHERE id='" . (int) $id . "' AND `status` ='1' LIMIT 1;", ARRAY_A);
$article or iPHP::throw404('运行出错!找不到文章: <b>ID:' . $id . '</b>', 10001);
if ($article['url']) {
if (iPHP::$iTPL_MODE == "html") {
return false;
} else {
$this->API_hits($id);
iPHP::gotourl($article['url']);
}
}
if (iCMS_ARTICLE_DATA === "TEXT") {
iPHP::app('article.table');
$article_data = articleTable::get_text($id);
} else {
$article && ($article_data = iDB::row("SELECT body,subtitle FROM `#iCMS@__article_data` WHERE aid='" . (int) $id . "' LIMIT 1;", ARRAY_A));
}
$vars = array('tags' => true, 'user' => true, 'meta' => true, 'prev_next' => true, 'category_lite' => false);
$article = $this->value($article, $article_data, $vars, $page, $tpl);
unset($article_data);
if ($article === false) {
return false;
}
if ($tpl) {
iCMS::hooks('enable_comment', true);
$article_tpl = empty($article['tpl']) ? $article['category']['contentTPL'] : $article['tpl'];
strstr($tpl, '.htm') && ($article_tpl = $tpl);
iPHP::assign('category', $article['category']);
unset($article['category']);
iPHP::assign('article', $article);
$html = iPHP::view($article_tpl, 'article');
if (iPHP::$iTPL_MODE == "html") {
return array($html, $article);
}
} else {
return $article;
}
}
示例13: API_interface
public function API_interface()
{
if (iPHP_DEBUG) {
// ob_start();
// iDB::$show_errors = true;
}
if ($_GET["api_token"] != iCMS::$config['api']['weixin']['token']) {
throw new Exception('TOKEN is error!');
}
if ($_GET["echostr"] && !$_GET['msg_signature']) {
if ($this->checkSignature()) {
echo $_GET["echostr"];
exit;
}
}
$input = file_get_contents("php://input");
if ($input) {
$xml = simplexml_load_string($input, 'SimpleXMLElement', LIBXML_NOCDATA);
$FromUserName = $xml->FromUserName;
$ToUserName = $xml->ToUserName;
$content = trim($xml->Content);
$msgType = $xml->MsgType;
$event = $xml->Event;
$eventKey = $xml->EventKey;
$CreateTime = time();
$dayline = get_date('', 'Y-m-d H:i:s');
if ($event == 'LOCATION') {
$Latitude = $xml->Latitude;
//地理位置纬度
$Longitude = $xml->Longitude;
//地理位置经度
$Precision = $xml->Precision;
//地理位置精度
}
if ($event == 'SCAN') {
$Ticket = $xml->Ticket;
//二维码的ticket,可用来换取二维码图片
}
if ($msgType == 'voice') {
$MediaId = $xml->MediaId;
//语音消息媒体id,可以调用多媒体文件下载接口拉取该媒体
$Format = $xml->Format;
//语音格式:amr
$Recognition = $xml->Recognition;
//语音识别结果,UTF8编码
$MsgID = $xml->MsgID;
//消息id,64位整型
}
if ($msgType != "text") {
$content = $event;
}
$fields = array('ToUserName', 'FromUserName', 'CreateTime', 'content', 'dayline');
$data = compact($fields);
$content && iDB::insert('weixin_api_log', $data);
$site_name = addslashes(iCMS::$config['site']['name']);
$site_desc = addslashes(iCMS::$config['site']['description']);
$site_key = addslashes(iCMS::$config['site']['keywords']);
$site_host = str_replace('http://', '', iCMS_URL);
if (in_array($event, array('subscribe', 'unsubscribe'))) {
if ($event == 'subscribe') {
$subscribe_msg = $site_name . ' (' . $site_host . ') ' . $site_desc . "\n\n回复:" . $site_key . ' 将会收到我们最新为您准备的信息';
iCMS::$config['api']['weixin']['subscribe'] && ($subscribe_msg = iCMS::$config['api']['weixin']['subscribe']);
//$subscribe_msg = str_replace(array('{site.name}'), replace, subject)
$this->msg_xml($subscribe_msg, $FromUserName, $ToUserName);
}
if ($event == 'unsubscribe') {
$subscribe_msg = "非常感谢您一直以来对我们【" . iCMS::$config['api']['weixin']['name'] . "】的支持!我们会继续努力,做出更好的内容!\n";
iCMS::$config['api']['weixin']['unsubscribe'] && ($subscribe_msg = iCMS::$config['api']['weixin']['unsubscribe']);
//$subscribe_msg = str_replace(array('{site.name}'), replace, subject)
$this->msg_xml($subscribe_msg, $FromUserName, $ToUserName);
}
}
if (in_array($content, array("1", "2", "3", "?", "?", "你好"))) {
$this->msg_xml($site_name . ' (' . $site_host . ') ' . $site_desc . "\n\n回复:" . $site_key . ' 将会收到我们最新为您准备的信息', $FromUserName, $ToUserName);
}
iPHP::assign('weixin', $data);
iPHP::view("iCMS://weixin.api.htm");
}
if (iPHP_DEBUG) {
// $output = ob_get_contents();
// ob_end_clean();
// echo $output;
// iFS::write('weixin.api.debug.log',$output,1,'ab+');
}
}
示例14: comment_form
function comment_form($vars)
{
if (!iCMS::$hooks['enable_comment']) {
iPHP::warning('此页面禁止调用 iCMS:comment:form 标签!');
}
if ($vars['ref']) {
$_vars = iCMS::app_ref($vars['ref']);
unset($vars['ref']);
$vars = array_merge($vars, $_vars);
}
$vars['iid'] or iPHP::warning('iCMS:comment:form 标签出错! 缺少"iid"属性或"iid"值为空.');
$vars['cid'] or iPHP::warning('iCMS:comment:form 标签出错! 缺少"cid"属性或"cid"值为空.');
$vars['appid'] or iPHP::warning('iCMS:comment:form 标签出错! 缺少"appid"属性或"appid"值为空.');
$vars['title'] or iPHP::warning('iCMS:comment: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');
}
示例15: tmpl
public function tmpl($itemid, $url, $title = null)
{
iPHP::assign('taoke', array('itemid' => $itemid, 'title' => $title, 'url' => $url));
return iPHP::fetch('iCMS://taoke.tmpl.htm');
}