本文整理汇总了PHP中iPHP::import方法的典型用法代码示例。如果您正苦于以下问题:PHP iPHP::import方法的具体用法?PHP iPHP::import怎么用?PHP iPHP::import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iPHP
的用法示例。
在下文中一共展示了iPHP::import方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: API_goto
public function API_goto()
{
$appid = (int) $_GET['appid'];
$iid = (int) $_GET['iid'];
$_GET = iS::escapeStr($_GET);
iPHP::import(iPHP_APP_CORE . '/iAPP.class.php');
$url = app::get_url($appid, $iid);
iPHP::gotourl($url);
}
示例2: do_del
function do_del($id = null, $dialog = true)
{
$id === null && ($id = $this->id);
$id or iPHP::alert('请选择要删除的评论!');
$comment = iDB::row("SELECT * FROM `#iCMS@__comment` WHERE `id`='{$id}' LIMIT 1");
iPHP::import(iPHP_APP_CORE . '/iAPP.class.php');
$table = app::get_table($comment->appid);
iDB::query("UPDATE {$table['name']} SET comments = comments-1 WHERE `comments`>0 AND `{$table['primary']}`='{$comment->iid}' LIMIT 1;");
iDB::query("UPDATE `#iCMS@__user` SET comments = comments-1 WHERE `comments`>0 AND `uid`='{$comment->userid}' LIMIT 1;");
iDB::query("DELETE FROM `#iCMS@__comment` WHERE `id` = '{$id}';");
$dialog && iPHP::success('评论删除完成', 'js:parent.$("#id-' . $id . '").remove();');
}
示例3: yun
public static function yun($vendor = null)
{
if ($vendor === null) {
return false;
}
$conf = self::$config['sdk'][$vendor];
if ($conf['AccessKey'] && $conf['SecretKey']) {
iPHP::import(iPHP_LIB . '/' . $vendor . '.php');
return new $vendor($conf['AccessKey'], $conf['SecretKey'], $conf['AppId']);
} else {
return false;
}
}
示例4: match
public static function match($html, $data, $rule)
{
$match_hash = array();
if ($data['dom']) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
spider::$dataTest && $_GET['pq_debug'] && (phpQuery::$debug = 1);
$doc = phpQuery::newDocumentHTML($html, 'UTF-8');
if (strpos($data['rule'], '@') !== false) {
list($content_dom, $content_attr) = explode("@", $data['rule']);
$content_fun = 'attr';
} else {
list($content_dom, $content_fun, $content_attr) = explode("\n", $data['rule']);
}
$content_dom = trim($content_dom);
$content_fun = trim($content_fun);
$content_attr = trim($content_attr);
$content_fun or $content_fun = 'html';
if ($data['multi']) {
$conArray = array();
$_content = null;
foreach ($doc[$content_dom] as $doc_key => $doc_value) {
if ($content_attr) {
$_content = phpQuery::pq($doc_value)->{$content_fun}($content_attr);
} else {
$_content = phpQuery::pq($doc_value)->{$content_fun}();
}
$cmd5 = md5($_content);
if ($match_hash[$cmd5]) {
break;
}
$conArray[$doc_key] = $_content;
$match_hash[$cmd5] = true;
}
if (spider::$dataTest) {
echo "<b>多条匹配结果:</b><pre>";
print_r($match_hash);
echo "</pre><hr />";
}
$content = implode('#--iCMS.PageBreak--#', $conArray);
unset($conArray, $_content, $match_hash);
} else {
if ($content_attr) {
$content = $doc[$content_dom]->{$content_fun}($content_attr);
} else {
$content = $doc[$content_dom]->{$content_fun}();
}
}
phpQuery::unloadDocuments($doc->getDocumentID());
unset($doc);
} else {
if (trim($data['rule']) == '<%content%>') {
$content = $html;
} else {
$data_rule = spiderTools::pregTag($data['rule']);
if (preg_match('/(<\\w+>|\\.\\*|\\.\\+|\\\\d|\\\\w)/i', $data_rule)) {
if ($data['multi']) {
preg_match_all('|' . $data_rule . '|is', $html, $matches, PREG_SET_ORDER);
$conArray = array();
foreach ((array) $matches as $mkey => $mat) {
$cmd5 = md5($mat['content']);
if ($match_hash[$cmd5]) {
break;
}
$conArray[$mkey] = $mat['content'];
$match_hash[$cmd5] = true;
}
if (spider::$dataTest) {
echo "<b>多条匹配结果:</b><pre>";
print_r($match_hash);
echo "</pre><hr />";
}
$content = implode('#--iCMS.PageBreak--#', $conArray);
unset($conArray, $match_hash);
} else {
preg_match('|' . $data_rule . '|is', $html, $matches, $PREG_SET_ORDER);
$content = $matches['content'];
}
} else {
$content = $data_rule;
}
}
}
return $content;
}
示例5: TBAPI
public static function TBAPI()
{
iPHP::import(iPHP_APP_CORE . '/tbapi.class.php');
if (isset($GLOBALS['TBAPI'])) {
return $GLOBALS['TBAPI'];
}
$GLOBALS['TBAPI'] = new TBAPI();
return $GLOBALS['TBAPI'];
}
示例6: tag_list
/**
* @package iCMS
* @copyright 2007-2016, iDreamSoft
* @license http://www.idreamsoft.com iDreamSoft
* @author coolmoo <idreamsoft@qq.com>
* @$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} ");
//.........这里部分代码省略.........
示例7: __action_manage_comment
private function __action_manage_comment()
{
$act = iS::escapeStr($_POST['act']);
if ($act == "del") {
$id = (int) $_POST['id'];
$id or iPHP::code(0, 'iCMS:error', 0, 'json');
$comment = iDB::row("SELECT `appid`,`iid` FROM `#iCMS@__comment` WHERE `userid` = '" . user::$userid . "' AND `id`='{$id}' LIMIT 1;");
iPHP::import(iPHP_APP_CORE . '/iAPP.class.php');
$table = app::get_table($comment->appid);
iDB::query("\n UPDATE {$table['name']}\n SET comments = comments-1\n WHERE `comments`>0\n AND `{$table['primary']}`='{$comment->iid}'\n LIMIT 1;\n ");
iDB::query("\n DELETE FROM `#iCMS@__comment`\n WHERE `userid` = '" . user::$userid . "'\n AND `id`='{$id}' LIMIT 1;\n ");
user::update_count(user::$userid, 1, 'comments', '-');
iPHP::code(1, 0, 0, 'json');
}
}
示例8: do_save
function do_save($callback = false)
{
$aid = (int) $_POST['aid'];
$cid = (int) $_POST['cid'];
$userid = (int) $_POST['userid'];
$scid = implode(',', (array) $_POST['scid']);
$pid = implode(',', (array) $_POST['pid']);
$status = (int) $_POST['status'];
$chapter = (int) $_POST['chapter'];
$ordernum = _int($_POST['ordernum']);
$_cid = iS::escapeStr($_POST['_cid']);
$_pid = iS::escapeStr($_POST['_pid']);
$_scid = iS::escapeStr($_POST['_scid']);
$_tags = iS::escapeStr($_POST['_tags']);
$title = iS::escapeStr($_POST['title']);
$stitle = iS::escapeStr($_POST['stitle']);
$pic = iS::escapeStr($_POST['pic']);
$mpic = iS::escapeStr($_POST['mpic']);
$spic = iS::escapeStr($_POST['spic']);
$source = iS::escapeStr($_POST['source']);
$author = iS::escapeStr($_POST['author']);
$editor = iS::escapeStr($_POST['editor']);
$description = iS::escapeStr($_POST['description']);
$keywords = iS::escapeStr($_POST['keywords']);
$tags = str_replace(',', ',', iS::escapeStr($_POST['tags']));
$clink = iS::escapeStr($_POST['clink']);
$url = iS::escapeStr($_POST['url']);
$tpl = iS::escapeStr($_POST['tpl']);
$metadata = iS::escapeStr($_POST['metadata']);
$metadata = $metadata ? addslashes(serialize($metadata)) : '';
$body = (array) $_POST['body'];
$creative = (int) $_POST['creative'];
iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert');
empty($_POST['pubdate']) && ($_POST['pubdate'] = get_date(0, 'Y-m-d H:i:s'));
$pubdate = iPHP::str2time($_POST['pubdate']);
$weight = _int($_POST['weight']);
$postype = $_POST['postype'] ? $_POST['postype'] : 0;
$ischapter = isset($_POST['ischapter']) ? 1 : 0;
isset($_POST['inbox']) && ($status = "0");
$tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags));
empty($title) && iPHP::alert('标题不能为空!');
empty($cid) && iPHP::alert('请选择所属栏目');
empty($body) && empty($url) && iPHP::alert('文章内容不能为空!');
$userid or $userid = iMember::$userid;
iFS::$userid = $userid;
if (empty($aid) && iCMS::$config['publish']['repeatitle']) {
articleTable::check_title($title) && iPHP::alert('该标题的文章已经存在!请检查是否重复');
}
if (strstr($this->category[$cid]['contentRule'], '{LINK}') !== false) {
empty($clink) && ($clink = strtolower(pinyin($title)));
if (empty($aid) && $clink) {
articleTable::check_clink($clink) && iPHP::alert('该文章自定义链接已经存在!请检查是否重复');
}
}
if (empty($description) && empty($url)) {
$description = $this->autodesc($body);
}
stripos($pic, 'http://') === false or $pic = iFS::http($pic);
stripos($mpic, 'http://') === false or $mpic = iFS::http($mpic);
stripos($spic, 'http://') === false or $spic = iFS::http($spic);
$haspic = empty($pic) ? 0 : 1;
$SELFURL = __SELF__ . $_POST['REFERER'];
if (empty($_POST['REFERER']) || strstr($_POST['REFERER'], '=save')) {
$SELFURL = __SELF__ . '?app=article&do=manage';
}
$editor or $editor = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname;
// if($aid && $ischapter){
// $this->article_data($body,$aid);
// iDB::query("UPDATE `#iCMS@__article` SET `chapter`=chapter+1 WHERE `id` = '$aid'");
// iPHP::success('章节添加完成!','url:'.$SELFURL);
// }
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
$picdata = '';
$ucid = 0;
$fields = articleTable::fields($aid);
if (empty($aid)) {
$postime = $pubdate;
$hits = 0;
$good = $bad = $comments = 0;
$ischapter && ($chapter = 1);
$mobile = 0;
$aid = articleTable::insert(compact($fields));
if ($this->callback['primary']) {
$PCB = $this->callback['primary'];
$handler = $PCB[0];
$params = (array) $PCB[1] + array('indexid' => $aid);
if (is_callable($handler)) {
call_user_func_array($handler, $params);
}
}
if ($tags) {
iPHP::app('tag.class', 'static');
tag::add($tags, $userid, $aid, $cid);
//articleTable::update(compact('tags'),array('id'=>$aid));
}
map::init('prop', $this->appid);
$pid && map::add($pid, $aid);
map::init('category', $this->appid);
map::add($cid, $aid);
$scid && map::add($scid, $aid);
//.........这里部分代码省略.........
示例9: defined
<?php
/**
* iCMS - i Content Management System
* Copyright (c) 2007-2012 idreamsoft.com iiimon Inc. All rights reserved.
*
* @author coolmoo <idreamsoft@qq.com>
* @site http://www.idreamsoft.com
* @licence http://www.idreamsoft.com/license.php
* @version 6.0.0
* @$Id: spider.app.php 634 2013-04-03 06:02:53Z coolmoo $
*/
defined('iPHP') or exit('What are you doing?');
iPHP::import(iPHP_APP_CORE . '/iSpider.class.php');
iPHP::import(iPHP_APP_CORE . '/iSpider.Tools.php');
iPHP::import(iPHP_APP_CORE . '/iSpider.Content.php');
iPHP::import(iPHP_APP_CORE . '/iSpider.Urls.php');
iPHP::import(iPHP_APP_CORE . '/iSpider.Data.php');
示例10: article_list
function article_list($vars)
{
if ($vars['loop'] === "rel" && empty($vars['id'])) {
return false;
}
$resource = array();
$map_where = array();
$status = '1';
isset($vars['status']) && ($status = (int) $vars['status']);
$where_sql = "WHERE `status`='{$status}'";
$vars['call'] == 'user' && ($where_sql .= " AND `postype`='0'");
$vars['call'] == 'admin' && ($where_sql .= " AND `postype`='1'");
$hidden = iCache::get('iCMS/category/hidden');
$hidden && ($where_sql .= iPHP::where($hidden, 'cid', 'not'));
$maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
$cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
isset($vars['weight']) && ($where_sql .= " AND `weight`='" . _int($vars['weight']) . "'");
if (isset($vars['ucid']) && $vars['ucid'] != '') {
$where_sql .= " AND `ucid`='{$vars['ucid']}'";
}
if (isset($vars['cid!'])) {
$ncids = explode(',', $vars['cid!']);
$vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
$where_sql .= iPHP::where($ncids, 'cid', 'not');
}
if ($vars['cid'] && !isset($vars['cids'])) {
$cid = explode(',', $vars['cid']);
$vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
$where_sql .= iPHP::where($cid, 'cid');
}
if (isset($vars['cids']) && !$vars['cid']) {
$cids = explode(',', $vars['cids']);
$vars['sub'] && ($cids += iCMS::get_category_ids($vars['cids'], true));
if ($cids) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('category', iCMS_APP_ARTICLE);
$map_where += map::where($cids);
}
}
if (isset($vars['pid']) && !isset($vars['pids'])) {
$where_sql .= iPHP::where($vars['pid'], 'pid');
}
if (isset($vars['pids']) && !isset($vars['pid'])) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('prop', iCMS_APP_ARTICLE);
$map_where += map::where($vars['pids']);
}
if (isset($vars['tids'])) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('tags', iCMS_APP_ARTICLE);
$map_where += map::where($vars['tids']);
}
if (isset($vars['keywords'])) {
//最好使用 iCMS:article:search
if (empty($vars['keywords'])) {
return;
}
if (strpos($vars['keywords'], ',') === false) {
$vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
$where_sql .= " AND CONCAT(title,keywords,description) like '%" . addslashes($vars['keywords']) . "%'";
} else {
$kws = explode(',', $vars['keywords']);
foreach ($kws as $kwv) {
$keywords .= addslashes($kwv) . "|";
}
$keywords = substr($keywords, 0, -1);
$where_sql .= " AND CONCAT(title,keywords,description) REGEXP '{$keywords}' ";
}
}
$vars['id'] && ($where_sql .= iPHP::where($vars['id'], 'id'));
$vars['id!'] && ($where_sql .= iPHP::where($vars['id!'], 'id', 'not'));
$by = $vars['by'] == "ASC" ? "ASC" : "DESC";
isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
switch ($vars['orderby']) {
case "id":
$order_sql = " ORDER BY `id` {$by}";
break;
case "hot":
$order_sql = " ORDER BY `hits` {$by}";
break;
case "week":
$order_sql = " ORDER BY `hits_week` {$by}";
break;
case "month":
$order_sql = " ORDER BY `hits_month` {$by}";
break;
case "comment":
$order_sql = " ORDER BY `comments` {$by}";
break;
case "pubdate":
$order_sql = " ORDER BY `pubdate` {$by}";
break;
case "disorder":
$order_sql = " ORDER BY `ordernum` {$by}";
break;
case "rand":
$order_sql = " ORDER BY rand() {$by}";
break;
//.........这里部分代码省略.........
示例11: defined
<?php
/**
* iCMS - i Content Management System
* Copyright (c) 2007-2012 idreamsoft.com iiimon Inc. All rights reserved.
*
* @author coolmoo <idreamsoft@qq.com>
* @site http://www.idreamsoft.com
* @licence http://www.idreamsoft.com/license.php
* @version 6.0.0
* @$Id: spider.app.php 156 2013-03-22 13:40:07Z coolmoo $
*/
defined('iPHP') or exit('What are you doing?');
iPHP::import(iPHP_APP_CORE . '/iSpider.Autoload.php');
class spiderApp
{
function __construct()
{
spider::$cid = $this->cid = (int) $_GET['cid'];
spider::$rid = $this->rid = (int) $_GET['rid'];
spider::$pid = $this->pid = (int) $_GET['pid'];
spider::$sid = $this->sid = (int) $_GET['sid'];
spider::$title = $this->title = $_GET['title'];
spider::$url = $this->url = $_GET['url'];
spider::$work = $this->work = false;
$this->poid = (int) $_GET['poid'];
}
function do_update()
{
if ($this->sid) {
$data = iACP::fields($_GET['iDT']);
示例12: user_list
function user_list($vars = null)
{
$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 `uid`='{$vars['userid']}'");
isset($vars['gid']) && ($where_sql .= " AND `gid` ='{$vars['gid']}'");
isset($vars['type']) && ($where_sql .= " AND `type` ='{$vars['type']}'");
if (isset($vars['pid']) && !isset($vars['pids'])) {
$where_sql .= iPHP::where($vars['pid'], 'pid');
}
if (isset($vars['pids']) && !isset($vars['pid'])) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('prop', iCMS_APP_USER);
//$where_sql.= map::exists($vars['pid'],'`#iCMS@__user`.uid'); //map 表大的用exists
$map_where = map::where($vars['pids']);
}
$by = $vars['by'] == "ASC" ? "ASC" : "DESC";
switch ($vars['orderby']) {
case "id":
$order_sql = " ORDER BY `uid` {$by}";
break;
case "article":
$order_sql = " ORDER BY `article` {$by}";
break;
case "comments":
$order_sql = " ORDER BY `comments` {$by}";
break;
case "follow":
$order_sql = " ORDER BY `follow` {$by}";
break;
case "fans":
$order_sql = " ORDER BY `fans` {$by}";
break;
case "hits":
$order_sql = " ORDER BY `hits` {$by}";
break;
default:
$order_sql = " ORDER BY `uid` {$by}";
}
if ($map_where) {
$map_sql = iCMS::map_sql($map_where);
$where_sql = ",({$map_sql}) map {$where_sql} AND `uid` = map.`iid`";
}
$offset = 0;
$limit = "LIMIT {$maxperpage}";
if ($vars['page']) {
$total = iPHP::total('sql.md5', "SELECT count(*) FROM `#iCMS@__user` {$where_sql} ");
$multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:sql'), 'nowindex' => $GLOBALS['page']));
$offset = $multi->offset;
$limit = "LIMIT {$offset},{$maxperpage}";
iPHP::assign("user_list_total", $total);
}
$hash = md5($where_sql . $order_sql . $limit);
if ($map_sql || $offset) {
if ($vars['cache']) {
$map_cache_name = iPHP_DEVICE . '/user_map/' . $hash;
$ids_array = iCache::get($map_cache_name);
}
if (empty($ids_array)) {
$ids_array = iDB::all("SELECT `id` FROM `#iCMS@__user` {$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);
$ids = iCMS::get_ids($ids_array, 'uid');
$ids = $ids ? $ids : '0';
$where_sql = "WHERE `uid` IN({$ids})";
}
if ($vars['cache']) {
$cache_name = iPHP_DEVICE . '/user_list/' . $hash;
$resource = iCache::get($cache_name);
}
if (empty($resource)) {
$resource = iDB::all("SELECT * FROM `#iCMS@__user` {$where_sql} {$order_sql} {$limit}");
iPHP_SQL_DEBUG && iDB::debug(1);
if ($resource) {
foreach ($resource as $key => $value) {
$value['url'] = user::router($value['uid'], "url");
$value['urls'] = user::router($value['uid'], "urls");
$value['avatar'] = user::router($value['uid'], "avatar", $vars['size'] ? $vars['size'] : 0);
$value['at'] = '<a href="' . $value['url'] . '" class="iCMS_user_link" target="_blank" data-tip="iCMS:ucard:' . $value['uid'] . '">@' . $value['nickname'] . '</a>';
$value['link'] = '<a href="' . $value['url'] . '" class="iCMS_user_link" target="_blank" data-tip="iCMS:ucard:' . $value['uid'] . '">' . $value['nickname'] . '</a>';
$value['gender'] = $value['gender'] ? 'male' : 'female';
isset($vars['data']) && ($value['data'] = (array) user::data($value['uid']));
$resource[$key] = $value;
}
}
$vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
}
return $resource;
}
示例13: check_content_code
public static function check_content_code($content)
{
if (spider::$content_right_code) {
if (strpos(spider::$content_right_code, 'DOM::') !== false) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
$doc = phpQuery::newDocumentHTML($content, 'UTF-8');
$pq_dom = str_replace('DOM::', '', spider::$content_right_code);
$matches = (bool) (string) phpQuery::pq($pq_dom);
phpQuery::unloadDocuments($doc->getDocumentID());
unset($doc, $content);
} else {
$matches = strpos($content, spider::$content_right_code);
unset($content);
}
if ($matches === false) {
return false;
}
}
if (spider::$content_error_code) {
if (strpos(spider::$content_error_code, 'DOM::') !== false) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
$doc = phpQuery::newDocumentHTML($content, 'UTF-8');
$pq_dom = str_replace('DOM::', '', spider::$content_error_code);
$_matches = (bool) (string) phpQuery::pq($pq_dom);
phpQuery::unloadDocuments($doc->getDocumentID());
unset($doc, $content);
} else {
$_matches = strpos($content, spider::$content_error_code);
unset($content);
}
if ($_matches !== false) {
return false;
}
}
return true;
}
示例14: check_content_code
function check_content_code($content)
{
if ($this->content_right_code) {
if (strpos($this->content_right_code, 'DOM::') !== false) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
$doc = phpQuery::newDocumentHTML($content, 'UTF-8');
$pq_dom = str_replace('DOM::', '', $this->content_right_code);
$matches = (bool) (string) phpQuery::pq($pq_dom);
} else {
$matches = strpos($content, $this->content_right_code);
}
if ($matches === false) {
$match = false;
return false;
}
}
if ($this->content_error_code) {
if (strpos($this->content_right_code, 'DOM::') !== false) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
$doc = phpQuery::newDocumentHTML($content, 'UTF-8');
$pq_dom = str_replace('DOM::', '', $this->content_right_code);
$_matches = (bool) (string) phpQuery::pq($pq_dom);
} else {
$_matches = strpos($content, $this->content_error_code);
}
if ($_matches !== false) {
$match = false;
return false;
}
}
$match = true;
return compact('content', 'match');
}
示例15: crawl
public static function crawl($work = NULL, $pid = NULL, $_rid = NULL, $_urls = null, $callback = null)
{
$pid === NULL && ($pid = spider::$pid);
if ($pid) {
$project = spider::project($pid);
$cid = $project['cid'];
$rid = $project['rid'];
$prule_list_url = $project['list_url'];
$lastupdate = $project['lastupdate'];
} else {
$cid = spider::$cid;
$rid = spider::$rid;
}
if (empty($rid) && $_rid !== NULL) {
$rid = $_rid;
}
if ($work == 'shell') {
$lastupdate = $project['lastupdate'];
if ($project['psleep']) {
if (time() - $lastupdate < $project['psleep']) {
echo '采集方案[' . $pid . "]:" . format_date($lastupdate) . "刚采集过了,请" . $project['psleep'] / 3600 . "小时后在继续采集\n";
return;
}
}
echo "[32m开始采集方案[" . $pid . "] 采集规则[" . $rid . "][0m\n";
}
$ruleA = spider::rule($rid);
$rule = $ruleA['rule'];
$urls = $rule['list_urls'];
$project['urls'] && ($urls = $project['urls']);
spiderUrls::$urls && ($urls = spiderUrls::$urls);
$_urls && ($urls = $_urls);
$urlsArray = explode("\n", $urls);
$urlsArray = array_filter($urlsArray);
$_urlsArray = $urlsArray;
$urlsList = array();
if ($work == 'shell') {
// echo "$urls\n";
print_r($urlsArray);
}
foreach ($_urlsArray as $_key => $_url) {
$_url = htmlspecialchars_decode($_url);
$_urlsList = array();
/**
* RULE@rid@url
* url使用[rid]规则采集并返回列表结果
*/
if (strpos($_url, 'RULE@') !== false) {
list($___s, $_rid, $_urls) = explode('@', $_url);
if (spider::$ruleTest) {
print_r('<b>使用[rid:' . $_rid . ']规则抓取列表</b>:' . $_urls);
echo "<hr />";
}
$_urlsList = spiderUrls::crawl($work, false, $_rid, $_urls, 'CALLBACK@URL');
$urlsList = array_merge($urlsList, $_urlsList);
unset($urlsArray[$_key]);
} else {
preg_match('|.*<(.*)>.*|is', $_url, $_matches);
if ($_matches) {
list($format, $begin, $num, $step, $zeroize, $reverse) = explode(',', $_matches[1]);
$url = str_replace($_matches[1], '*', trim($_matches[0]));
$_urlsList = spiderTools::mkurls($url, $format, $begin, $num, $step, $zeroize, $reverse);
unset($urlsArray[$_key]);
$urlsList = array_merge($urlsList, $_urlsList);
}
}
}
$urlsList && ($urlsArray = array_merge($urlsArray, $urlsList));
unset($_urlsArray, $_key, $_url, $_matches, $_urlsList, $urlsList);
$urlsArray = array_unique($urlsArray);
// spider::$useragent = $rule['user_agent'];
// spider::$encoding = $rule['curl']['encoding'];
// spider::$referer = $rule['curl']['referer'];
// spider::$charset = $rule['charset'];
if (empty($urlsArray)) {
if ($work == 'shell') {
echo "采集列表为空!请填写!\n";
return false;
}
iPHP::alert('采集列表为空!请填写!', 'js:parent.window.iCMS_MODAL.destroy();');
}
// if(spider::$ruleTest){
// echo "<pre>";
// print_r(iS::escapeStr($project));
// print_r(iS::escapeStr($rule));
// echo "</pre>";
// echo "<hr />";
// }
if ($rule['mode'] == "2") {
iPHP::import(iPHP_LIB . '/phpQuery.php');
spider::$ruleTest && $_GET['pq_debug'] && (phpQuery::$debug = 1);
}
$pubArray = array();
$pubCount = array();
$pubAllCount = array();
spider::$curl_proxy = $rule['proxy'];
spider::$urlslast = null;
foreach ($urlsArray as $key => $url) {
$url = trim($url);
spider::$urlslast = $url;
//.........这里部分代码省略.........