示例#1
0
 function do_add()
 {
     if ($this->cid) {
         iACP::CP($this->cid, 'e', 'page');
         $rs = iDB::row("SELECT * FROM `#iCMS@__category` WHERE `cid`='{$this->cid}' LIMIT 1;", ARRAY_A);
         $rootid = $rs['rootid'];
         $rs['metadata'] && ($rs['metadata'] = unserialize($rs['metadata']));
         $rs['contentprop'] && ($rs['contentprop'] = unserialize($rs['contentprop']));
         $rs['body'] = iCache::get('iCMS/category/' . $this->cid . '.body');
         $rs['body'] && ($rs['body'] = stripslashes($rs['body']));
     } else {
         $rootid = (int) $_GET['rootid'];
         $rootid && iACP::CP($rootid, 'a', 'page');
     }
     if (empty($rs)) {
         $rs = array('pid' => '0', 'status' => '1', 'isexamine' => '1', 'issend' => '1', 'hasbody' => '2', 'ordernum' => '0', 'mode' => '0', 'htmlext' => iCMS::$config['router']['html_ext'], 'categoryURI' => 'category', 'categoryRule' => '/{CDIR}/index' . iCMS::$config['router']['html_ext'], 'contentRule' => '/{CDIR}/{YYYY}/{MM}{DD}/{ID}' . iCMS::$config['router']['html_ext'], 'indexTPL' => $this->_app_indexTPL, 'listTPL' => $this->_app_listTPL, 'contentTPL' => $this->_app_contentTPL, 'metadata' => '', 'contentprop' => '');
         if ($rootid) {
             $rootRs = iDB::row("SELECT * FROM `#iCMS@__category` WHERE `cid`='" . $rootid . "' LIMIT 1;", ARRAY_A);
             $rs['htmlext'] = $rootRs['htmlext'];
             $rs['categoryRule'] = $rootRs['categoryRule'];
             $rs['contentRule'] = $rootRs['contentRule'];
             $rs['indexTPL'] = $rootRs['indexTPL'];
             $rs['listTPL'] = $rootRs['listTPL'];
             $rs['contentTPL'] = $rootRs['contentTPL'];
         }
     }
     include iACP::view("category.add");
 }
示例#2
0
文件: tag.app.php 项目: sunhk25/iCMS
 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;
     }
 }
示例#3
0
 public function cahce_one($C = null)
 {
     if (!is_array($C)) {
         $C = iDB::row("SELECT * FROM `#iCMS@__category` where `cid`='{$C}' LIMIT 1;", ARRAY_A);
         $C = $this->C($C);
     }
     iCache::delete('iCMS/category/' . $C['cid']);
     iCache::set('iCMS/category/' . $C['cid'], $C, 0);
 }
示例#4
0
 function do_add()
 {
     if ($this->uid) {
         $rs = iDB::row("SELECT * FROM `#iCMS@__members` WHERE `uid`='{$this->uid}' LIMIT 1;");
         $rs->info && ($rs->info = unserialize($rs->info));
         $rs->info = (array) $rs->info;
     }
     include iACP::view("account.add");
 }
示例#5
0
 function do_add()
 {
     if ($this->id) {
         $rs = iDB::row("SELECT * FROM `#iCMS@__keywords` WHERE `id`='{$this->id}' LIMIT 1;", ARRAY_A);
     } else {
         $rs['keyword'] = $_GET['keyword'];
         $rs['url'] = $_GET['url'];
     }
     include iACP::view("keywords.add");
 }
示例#6
0
文件: user.app.php 项目: sunhk25/iCMS
 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);
     }
 }
示例#7
0
文件: menu.app.php 项目: sunhk25/iCMS
 function do_add()
 {
     $id = $_GET['id'];
     if ($id) {
         $rs = iDB::row("SELECT * FROM `#iCMS@__menu` WHERE `id`='{$id}' LIMIT 1;", ARRAY_A);
         $rootid = $rs['rootid'];
     } else {
         $rootid = $_GET['rootid'];
     }
     include iACP::view("menu.add");
 }
示例#8
0
function comment_array($vars)
{
    $where_sql = " `status`='1'";
    isset($vars['id']) && ($where_sql .= " AND `id`='" . (int) $vars['id'] . "'");
    isset($vars['userid']) && ($where_sql .= " AND `userid`='" . (int) $vars['userid'] . "'");
    $rs = iDB::row("SELECT * FROM `#iCMS@__comment` WHERE {$where_sql} LIMIT 1;", ARRAY_A);
    iPHP_SQL_DEBUG && iDB::debug(1);
    if ($rs) {
        $rs['user'] = user::info($rs['userid'], $rs['username']);
    }
    return $rs;
}
示例#9
0
 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();');
 }
示例#10
0
 function do_add()
 {
     $this->id && ($rs = iDB::row("SELECT * FROM `#iCMS@__marker` WHERE `id`='{$this->id}' LIMIT 1;", ARRAY_A));
     if ($_GET['act'] == "copy") {
         $this->id = 0;
         $rs['name'] = '';
         $rs['key'] = '';
     }
     if (empty($rs)) {
         $rs['status'] = '1';
     }
     include iACP::view("marker.add");
 }
示例#11
0
文件: prop.app.php 项目: sunhk25/iCMS
 function do_add()
 {
     $this->pid && ($rs = iDB::row("SELECT * FROM `#iCMS@__prop` WHERE `pid`='{$this->pid}' LIMIT 1;", ARRAY_A));
     if ($_GET['act'] == "copy") {
         $this->pid = 0;
         $rs['val'] = '';
     }
     if (empty($rs)) {
         $_GET['type'] && ($rs['type'] = iS::escapeStr($_GET['type']));
         $_GET['field'] && ($rs['field'] = iS::escapeStr($_GET['field']));
     }
     include iACP::view("prop.add");
 }
示例#12
0
 public static function data($id = 0, $adid = 0, $userid = 0)
 {
     $userid && ($sql = " AND `userid`='{$userid}'");
     $rs = iDB::row("SELECT * FROM `#iCMS@__article` WHERE `id`='{$id}' {$sql} LIMIT 1;", ARRAY_A);
     if ($rs) {
         $aid = $rs['id'];
         if (iCMS_ARTICLE_DATA === "TEXT") {
             $adrs = self::get_text($aid);
         } else {
             $adsql = $adid ? " AND `id`='{$adid}'" : '';
             $adrs = iDB::row("SELECT * FROM `#iCMS@__article_data` WHERE `aid`='{$aid}' {$adsql}", ARRAY_A);
         }
     }
     return array($rs, $adrs);
 }
示例#13
0
 function check($a, $p)
 {
     if (empty($a) && empty($p)) {
         self::LoginPage();
     }
     self::$data = iDB::row("SELECT * FROM `#iCMS@__users` WHERE `username`='{$a}' AND `password`='{$p}' AND `status`='1' LIMIT 1;");
     self::$data or self::LoginPage();
     self::$data->info && (self::$data->info = unserialize(self::$data->info));
     self::$userid = self::$data->uid;
     self::$group = iDB::row("SELECT * FROM `#iCMS@__group` WHERE `gid`='" . self::$data->gid . "' LIMIT 1;");
     self::$power = self::smerge(self::$group->power, self::$data->power);
     self::$cpower = self::smerge(self::$group->cpower, self::$data->cpower);
     self::$nickname = self::$data->nickname ? self::$data->nickname : self::$data->username;
     return self::$data;
 }
示例#14
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 marker_html($vars)
{
    $where_sql = "WHERE `status`='1'";
    $vars['key'] or iPHP::warning('iCMS&#x3a;marker&#x3a;html 标签出错! 缺少"key"属性或"key"值为空.');
    if (isset($vars['cid']) && $vars['cid'] != '') {
        $where_sql .= " AND `cid`='{$vars['cid']}'";
    }
    if (isset($vars['pid']) && $vars['pid'] != '') {
        $where_sql .= " AND `pid`='{$vars['pid']}'";
    }
    if (isset($vars['key']) && $vars['key'] != '') {
        $where_sql .= " AND `key`='{$vars['key']}'";
    }
    if (isset($vars['id']) && $vars['id'] != '') {
        $where_sql .= " AND `id`='{$vars['id']}'";
    }
    $marker = iDB::row("SELECT * FROM `#iCMS@__marker` {$where_sql}", ARRAY_A);
    iPHP_SQL_DEBUG && iDB::debug(1);
    if ($marker) {
        echo $marker['data'];
    }
}
示例#15
0
文件: push.app.php 项目: World3D/iCMS
 function do_add()
 {
     $id = (int) $_GET['id'];
     $rs = array();
     $_GET['title'] && ($rs['title'] = $_GET['title']);
     $_GET['pic'] && ($rs['pic'] = $_GET['pic']);
     $_GET['url'] && ($rs['url'] = $_GET['url']);
     $_GET['title2'] && ($rs['title2'] = $_GET['title2']);
     $_GET['pic2'] && ($rs['pic2'] = $_GET['pic2']);
     $_GET['url2'] && ($rs['url2'] = $_GET['url2']);
     $_GET['title3'] && ($rs['title3'] = $_GET['title3']);
     $_GET['pic3'] && ($rs['pic3'] = $_GET['pic3']);
     $_GET['url3'] && ($rs['url3'] = $_GET['url3']);
     $id && ($rs = iDB::row("SELECT * FROM `#iCMS@__push` WHERE `id`='{$id}' LIMIT 1;", ARRAY_A));
     empty($rs['editor']) && ($rs['editor'] = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname);
     empty($rs['userid']) && ($rs['userid'] = iMember::$userid);
     $rs['addtime'] = $id ? get_date(0, "Y-m-d H:i:s") : get_date($rs['addtime'], 'Y-m-d H:i:s');
     $cid = empty($rs['cid']) ? (int) $_GET['cid'] : $rs['cid'];
     $cata_option = $this->categoryApp->select('ca', $cid);
     empty($rs['userid']) && ($rs['userid'] = iMember::$userid);
     $strpos = strpos(__REF__, '?');
     $REFERER = $strpos === false ? '' : substr(__REF__, $strpos);
     include iACP::view("push.add");
 }
示例#16
0
文件: tags.app.php 项目: sunhk25/iCMS
 function do_save()
 {
     $id = (int) $_POST['id'];
     $uid = (int) $_POST['uid'];
     $rootid = (int) $_POST['rootid'];
     $cid = implode(',', (array) $_POST['cid']);
     $tcid = implode(',', (array) $_POST['tcid']);
     $pid = implode(',', (array) $_POST['pid']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_tcid = iS::escapeStr($_POST['_tcid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $name = iS::escapeStr($_POST['name']);
     $subtitle = iS::escapeStr($_POST['subtitle']);
     $tkey = iS::escapeStr($_POST['tkey']);
     $seotitle = iS::escapeStr($_POST['seotitle']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $pic = iS::escapeStr($_POST['pic']);
     $bpic = iS::escapeStr($_POST['bpic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $related = iS::escapeStr($_POST['related']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $weight = _int($_POST['weight']);
     $ordernum = _int($_POST['ordernum']);
     $status = (int) $_POST['status'];
     $haspic = $pic ? '1' : '0';
     $pubdate = time();
     $metadata = $_POST['metadata'];
     $uid or $uid = iMember::$userid;
     if ($callback) {
         if (empty($name)) {
             echo '标签名称不能为空!';
             return false;
         }
     }
     $name or iPHP::alert('标签名称不能为空!');
     $cid or iPHP::alert('请选择标签所属栏目!');
     if ($metadata) {
         if ($metadata['key']) {
             $md = array();
             foreach ($metadata['key'] as $_mk => $_mval) {
                 !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
                 $md[$_mval] = $metadata['value'][$_mk];
             }
         } else {
             $md = $metadata;
         }
         $metadata = addslashes(json_encode($md));
     }
     if (empty($id)) {
         $hasNameId = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'");
         if ($hasNameId) {
             if (isset($_POST['spider_update'])) {
                 $id = $hasNameId;
             } else {
                 iPHP::alert('该标签已经存在!请检查是否重复');
             }
         }
     }
     if (empty($tkey) && $url) {
         $tkey = substr(md5($url), 8, 16);
         $hasTkey = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'");
         if ($hasTkey) {
             if (isset($_POST['spider_check_tkey'])) {
                 echo '该自定义链接已经存在!请检查是否重复';
                 return false;
             } else {
                 iPHP::alert('该自定义链接已经存在!请检查是否重复');
             }
         }
     }
     $tkey or $tkey = strtolower(pinyin($name));
     iFS::$forceExt = "jpg";
     iFS::checkHttp($pic) && ($pic = iFS::http($pic));
     iFS::checkHttp($bpic) && ($bpic = iFS::http($bpic));
     iFS::checkHttp($mpic) && ($mpic = iFS::http($mpic));
     iFS::checkHttp($spic) && ($spic = iFS::http($spic));
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $fields = array('uid', 'rootid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'bpic', 'mpic', 'spic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status');
     $data = compact($fields);
     if (empty($id)) {
         $data['postime'] = $pubdate;
         $data['count'] = '0';
         $data['comments'] = '0';
         $id = iDB::insert('tags', $data);
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         $pid && map::add($pid, $id);
         map::init('category', $this->appid);
         map::add($cid, $id);
         $tcid && map::add($tcid, $id);
         $msg = '标签添加完成';
     } else {
         if (isset($_POST['spider_update'])) {
             // $data = array();
             $hasTag = iDB::row("SELECT * FROM `#iCMS@__tags` where `id` = '{$id}'", ARRAY_A);
             $this->check_spider_data($data, $hasTag, 'subtitle', $subtitle);
             $this->check_spider_data($data, $hasTag, 'description', $description);
             $this->check_spider_data($data, $hasTag, 'seotitle', $seotitle);
             $this->check_spider_data($data, $hasTag, 'keywords', $keywords);
             $this->check_spider_data($data, $hasTag, 'related', $related);
             $hasTag['cid'] && $cid && ($data['cid'] = $cid);
             $_cid = $hasTag['cid'];
             $hasTag['tcid'] && $tcid && ($data['tcid'] = $tcid);
             $_tcid = $hasTag['tcid'];
             $hasTag['pid'] && $pid && ($data['pid'] = $pid);
             $_pid = $hasTag['pid'];
         }
         unset($data['count'], $data['comments']);
         iDB::update('tags', $data, array('id' => $id));
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         map::diff($pid, $_pid, $id);
         map::init('category', $this->appid);
         map::diff($cid, $_cid, $id);
         map::diff($tcid, $_tcid, $id);
         $msg = '标签更新完成';
     }
     iACP::callback($id, $this);
     if ($this->callback['code']) {
         return array("code" => $this->callback['code'], 'indexid' => $id);
     }
     iPHP::success($msg, "url:" . APP_URI);
 }
示例#17
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);
     }
 }
示例#18
0
 function project($id)
 {
     return iDB::row("SELECT * FROM `#iCMS@__spider_project` WHERE `id`='{$id}' LIMIT 1;", ARRAY_A);
 }
示例#19
0
 public static function login($val, $pass = '', $fm = 'un')
 {
     $field_map = array('id' => 'uid', 'nk' => 'nickname', 'un' => 'username');
     $field = $field_map[$fm];
     $field or $field = 'username';
     $user = iDB::row("SELECT `uid`,`nickname`,`password`,`username`,`status` FROM `#iCMS@__user` where `{$field}`='{$val}' and `password`='{$pass}' limit 1");
     if (empty($user)) {
         return false;
     }
     if ((int) $user->status != 1) {
         return $user->status;
     }
     self::set_cookie($user->username, $user->password, (array) $user);
     self::$userid = $user->uid;
     self::$nickname = $user->nickname;
     return true;
 }
示例#20
0
 function do_addpost()
 {
     $this->poid && ($rs = iDB::row("SELECT * FROM `#iCMS@__spider_post` WHERE `id`='{$this->poid}' LIMIT 1;", ARRAY_A));
     include iACP::view("spider.addpost");
 }
示例#21
0
 public static function crawl($_pid = NULL, $_rid = NULL, $_url = NULL, $_title = NULL)
 {
     ini_get('safe_mode') or set_time_limit(0);
     $sid = spider::$sid;
     if ($sid) {
         $sRs = iDB::row("SELECT * FROM `#iCMS@__spider_url` WHERE `id`='{$sid}' LIMIT 1;");
         $title = $sRs->title;
         $cid = $sRs->cid;
         $pid = $sRs->pid;
         $url = $sRs->url;
         $rid = $sRs->rid;
     } else {
         $rid = spider::$rid;
         $pid = spider::$pid;
         $title = spider::$title;
         $url = spider::$url;
         $_rid === NULL or $rid = $_rid;
         $_pid === NULL or $pid = $_pid;
         $_title === NULL or $title = $_title;
         $_url === NULL or $url = $_url;
     }
     if ($pid) {
         $project = spider::project($pid);
         $prule_list_url = $project['list_url'];
     }
     $ruleA = spider::rule($rid);
     $rule = $ruleA['rule'];
     $dataArray = $rule['data'];
     if ($prule_list_url) {
         $rule['list_url'] = $prule_list_url;
     }
     if (spider::$dataTest) {
         echo "<b>抓取规则信息</b><pre>";
         print_r(iS::escapeStr($ruleA));
         print_r(iS::escapeStr($project));
         echo "</pre><hr />";
     }
     spider::$curl_proxy = $rule['proxy'];
     $responses = array();
     $html = spiderTools::remote($url);
     if (empty($html)) {
         $msg = '错误:001..采集 ' . $url . '文件内容为空!请检查采集规则';
         if (spider::$work == 'shell') {
             echo "{$msg}\n";
             return false;
         } else {
             iPHP::alert($msg);
         }
     }
     //      $http   = spider::check_content_code($html);
     //
     //      if($http['match']==false){
     //          return false;
     //      }
     //      $content        = $http['content'];
     spider::$allHtml = "";
     $rule['__url__'] = spider::$url;
     $responses['reurl'] = spider::$url;
     $responses['__title__'] = $title;
     foreach ((array) $dataArray as $key => $data) {
         $content_html = $html;
         $dname = $data['name'];
         /**
          * [UNSET:name]
          * 注销[name]
          * @var string
          */
         if (strpos($dname, 'UNSET:') !== false) {
             $_dname = str_replace('UNSET:', '', $dname);
             unset($responses[$_dname]);
             continue;
         }
         /**
          * [DATA:name]
          * 把之前[name]处理完的数据当作原始数据
          * 如果之前有数据会叠加
          * 用于数据多次处理
          * @var string
          */
         if (strpos($dname, 'DATA:') !== false) {
             $_dname = str_replace('DATA:', '', $dname);
             $content_html = $responses[$_dname];
             unset($responses[$dname]);
         }
         /**
          * [PRE:name]
          * 把PRE:name采集到的数据 当做原始数据
          * 一般用于下载内容
          * @var string
          */
         $pre_dname = 'PRE:' . $dname;
         if (isset($responses[$pre_dname])) {
             $content_html = $responses[$pre_dname];
             unset($responses[$pre_dname]);
         }
         /**
          * [EMPTY:name]
          * 如果[name]之前抓取结果数据为空使用这个数据项替换
          * @var string
          */
         if (strpos($dname, 'EMPTY:') !== false) {
             $_dname = str_replace('EMPTY:', '', $dname);
             if (empty($responses[$_dname])) {
                 $dname = $_dname;
             } else {
                 //有值不执行抓取
                 continue;
             }
         }
         $content = spiderContent::crawl($content_html, $data, $rule, $responses);
         unset($content_html);
         if (strpos($dname, 'ARRAY:') !== false) {
             // if(strpos($data['rule'], 'RULE@')!==false){
             $dname = str_replace('ARRAY:', '', $dname);
             // $contentArray = $responses[$dname];
             // // $contentArray = $responses[$dname];
             $cArray = array();
             foreach ((array) $content as $k => $value) {
                 foreach ((array) $value as $key => $val) {
                     $cArray[$key][$k] = $val;
                 }
             }
             if ($cArray) {
                 $content = $cArray;
                 unset($cArray);
             }
         }
         /**
          * [name.xxx]
          * 采集内容做为数组
          */
         if (strpos($dname, '.') !== false) {
             $f_key = substr($dname, 0, stripos($dname, "."));
             $s_key = substr(strrchr($dname, "."), 1);
             if (isset($responses[$f_key][$s_key])) {
                 if (is_array($responses[$f_key][$s_key])) {
                     $responses[$f_key][$s_key] = array_merge($responses[$f_key][$s_key], $content);
                 } else {
                     $responses[$f_key][$s_key] .= $content;
                 }
             } else {
                 $responses[$f_key][$s_key] = $content;
             }
         } else {
             /**
              * 多个name 内容合并
              */
             if (isset($responses[$dname])) {
                 if (is_array($responses[$dname])) {
                     $responses[$dname] = array_merge($responses[$dname], $content);
                 } else {
                     $responses[$dname] .= $content;
                 }
             } else {
                 $responses[$dname] = $content;
             }
         }
         /**
          * 对匹配多条的数据去重过滤
          */
         if (!is_array($responses[$dname]) && $data['multi']) {
             if (strpos($responses[$dname], ',') !== false) {
                 $_dnameArray = explode(',', $responses[$dname]);
                 $dnameArray = array();
                 foreach ((array) $_dnameArray as $key => $value) {
                     $value = trim($value);
                     $value && ($dnameArray[] = $value);
                 }
                 $dnameArray = array_filter($dnameArray);
                 $dnameArray = array_unique($dnameArray);
                 $responses[$dname] = implode(',', $dnameArray);
                 unset($dnameArray, $_dnameArray);
             }
         }
         gc_collect_cycles();
     }
     if (isset($responses['title']) && empty($responses['title'])) {
         $responses['title'] = $responses['__title__'];
     }
     spider::$allHtml = null;
     unset($html);
     gc_collect_cycles();
     if (spider::$dataTest) {
         echo "<pre style='width:99%;word-wrap: break-word;'>";
         print_r(iS::escapeStr($responses));
         echo '<hr />';
         echo '使用内存:' . iFS::sizeUnit(memory_get_usage()) . ' 执行时间:' . iPHP::timer_stop() . 's';
         echo "</pre>";
     }
     iFS::$CURLOPT_ENCODING = '';
     iFS::$CURLOPT_REFERER = '';
     iFS::$watermark_config['pos'] = iCMS::$config['watermark']['pos'];
     iFS::$watermark_config['x'] = iCMS::$config['watermark']['x'];
     iFS::$watermark_config['y'] = iCMS::$config['watermark']['y'];
     iFS::$watermark_config['img'] = iCMS::$config['watermark']['img'];
     $rule['fs']['encoding'] && (iFS::$CURLOPT_ENCODING = $rule['fs']['encoding']);
     $rule['fs']['referer'] && (iFS::$CURLOPT_REFERER = $rule['fs']['referer']);
     if ($rule['watermark_mode']) {
         iFS::$watermark_config['pos'] = $rule['watermark']['pos'];
         iFS::$watermark_config['x'] = $rule['watermark']['x'];
         iFS::$watermark_config['y'] = $rule['watermark']['y'];
         $rule['watermark']['img'] && (iFS::$watermark_config['img'] = $rule['watermark']['img']);
     }
     if (spider::$callback['data'] && is_callable(spider::$callback['data'])) {
         $responses = call_user_func_array(spider::$callback['data'], array($responses));
     }
     return $responses;
 }
示例#22
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;
 }
示例#23
0
文件: user.app.php 项目: sunhk25/iCMS
 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');
     }
 }
示例#24
0
 function do_add()
 {
     $this->gid && ($rs = iDB::row("SELECT * FROM `#iCMS@__group` WHERE `gid`='{$this->gid}' LIMIT 1;"));
     include iACP::view("groups.add");
 }
示例#25
0
 public static function publish($work = null)
 {
     $_POST = spiderData::crawl();
     if (spider::$work == 'shell') {
         if (empty($_POST['title'])) {
             echo "标题不能为空\n";
             return false;
         }
         if (empty($_POST['body'])) {
             echo "内容不能为空\n";
             return false;
         }
     }
     $checker = spider::checker($work, spider::$pid, $_POST['reurl'], $_POST['title']);
     if ($checker !== true) {
         return $checker;
     }
     $project = spider::project(spider::$pid);
     if (!isset($_POST['cid'])) {
         $_POST['cid'] = $project['cid'];
     }
     $postArgs = spider::postArgs($project['poid']);
     if ($_GET['indexid']) {
         $aid = (int) $_GET['indexid'];
         $_POST['aid'] = $aid;
         $_POST['adid'] = iDB::value("SELECT `id` FROM `#iCMS@__article_data` WHERE aid='{$aid}'");
     }
     $title = iS::escapeStr($_POST['title']);
     $url = iS::escapeStr($_POST['reurl']);
     $hash = md5($url);
     if (empty(spider::$sid)) {
         $spider_url = iDB::row("SELECT `id`,`publish`,`indexid` FROM `#iCMS@__spider_url` where `url`='{$url}'", ARRAY_A);
         if (empty($spider_url)) {
             $spider_url_data = array('cid' => $project['cid'], 'rid' => spider::$rid, 'pid' => spider::$pid, 'title' => addslashes($title), 'url' => $url, 'hash' => $hash, 'status' => '1', 'addtime' => time(), 'publish' => '0', 'indexid' => '0', 'pubdate' => '');
             $suid = iDB::insert('spider_url', $spider_url_data);
         } else {
             if ($spider_url['indexid']) {
                 $_POST['aid'] = $spider_url['indexid'];
                 $_POST['adid'] = iDB::value("SELECT `id` FROM `#iCMS@__article_data` WHERE aid='" . $spider_url['indexid'] . "'");
             }
             $suid = $spider_url['id'];
         }
     } else {
         $suid = spider::$sid;
     }
     if (spider::$callback['post'] && is_callable(spider::$callback['post'])) {
         $_POST = call_user_func_array(spider::$callback['post'], array($_POST));
     }
     iS::slashes($_POST);
     $app = iACP::app($postArgs->app);
     $fun = $postArgs->fun;
     $app->callback['code'] = '1001';
     /**
      * 主表 回调 更新关联ID
      */
     $app->callback['primary'] = array(array('spider', 'update_spider_url_indexid'), array('suid' => $suid));
     /**
      * 数据表 回调 成功发布
      */
     $app->callback['data'] = array(array('spider', 'update_spider_url_publish'), array('suid' => $suid));
     $callback = $app->{$fun}();
     if ($callback['code'] == $app->callback['code']) {
         if (spider::$sid) {
             $work === NULL && iPHP::success("发布成功!", 'js:1');
         } else {
             $work === NULL && iPHP::success("发布成功!", 'js:parent.$("#' . $hash . '").remove();');
         }
     }
     if ($work == "shell" || $work == "WEB@AUTO") {
         $callback['work'] = $work;
         return $callback;
     }
 }
示例#26
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;
 }
示例#27
0
 function bakupdata($tabledb, $start = 0)
 {
     //global $iCMS,$sizelimit,$tableid,$startfrom,$stop,$rows;
     $this->tableid = $this->tableid ? $this->tableid - 1 : 0;
     $this->stop = 0;
     $t_count = count($tabledb);
     for ($i = $this->tableid; $i < $t_count; $i++) {
         $ts = iDB::row("SHOW TABLE STATUS LIKE '{$tabledb[$i]}'");
         $this->rows = $ts->Rows;
         $limit = "LIMIT {$start},100000";
         if (version_compare(PHP_VERSION, '5.5', '>=')) {
             $result = mysqli_query(iDB::$link, "SELECT * FROM {$tabledb[$i]} {$limit}");
             $fnum = iDB::$link->field_count;
             if (!$result) {
                 continue;
             }
             while ($datadb = $result->fetch_row()) {
                 $start++;
                 //$table        = str_replace(iPHP_DB_PREFIX,'iCMS_',$tabledb[$i]);
                 $table = $tabledb[$i];
                 $bakupdata .= "INSERT INTO {$table} VALUES(" . "'" . addslashes($datadb[0]) . "'";
                 $tempdb = '';
                 for ($j = 1; $j < $fnum; $j++) {
                     $tempdb .= ",'" . addslashes($datadb[$j]) . "'";
                 }
                 $bakupdata .= $tempdb . ");\n";
                 if ($this->sizelimit && strlen($bakupdata) > $this->sizelimit * 1000) {
                     break;
                 }
             }
             $result->close();
         } else {
             $query = mysql_query("SELECT * FROM {$tabledb[$i]} {$limit}");
             $fnum = mysql_num_fields($query);
             while ($datadb = mysql_fetch_row($query)) {
                 $start++;
                 //$table		= str_replace(iPHP_DB_PREFIX,'iCMS_',$tabledb[$i]);
                 $table = $tabledb[$i];
                 $bakupdata .= "INSERT INTO {$table} VALUES(" . "'" . addslashes($datadb[0]) . "'";
                 $tempdb = '';
                 for ($j = 1; $j < $fnum; $j++) {
                     $tempdb .= ",'" . addslashes($datadb[$j]) . "'";
                 }
                 $bakupdata .= $tempdb . ");\n";
                 if ($this->sizelimit && strlen($bakupdata) > $this->sizelimit * 1000) {
                     break;
                 }
             }
             mysql_free_result($query);
         }
         if ($start >= $this->rows) {
             $start = 0;
             $this->rows = 0;
         }
         $bakupdata .= "\n";
         if ($this->sizelimit && strlen($bakupdata) > $this->sizelimit * 1000) {
             $start == 0 && $i++;
             $this->stop = 1;
             break;
         }
         $start = 0;
     }
     if ($this->stop == 1) {
         $i++;
         $this->tableid = $i;
         $this->startfrom = $start;
         $start = 0;
     }
     return $bakupdata;
 }
示例#28
0
 public static function del($tags, $field = 'name', $iid = 0)
 {
     $tagArray = explode(",", $tags);
     $iid && ($sql = "AND `iid`='{$iid}'");
     foreach ($tagArray as $k => $v) {
         $tagA = iDB::row("SELECT * FROM `#iCMS@__tags` WHERE `{$field}`='{$v}' LIMIT 1;");
         $tRS = iDB::all("SELECT `iid` FROM `#iCMS@__tags_map` WHERE `node`='{$tagA->id}' AND `appid`='" . TAG_APPID . "' {$sql}");
         foreach ((array) $tRS as $TL) {
             $idA[] = $TL['iid'];
         }
         // if($idA){
         // 	iPHP::appClass('model',"break");
         // 	$table	= model::table(TAG_APPID);
         // 	$ids	= implode(',',$idA);
         // 	iDB::query("UPDATE `#iCMS@__$table` SET `tags`=REPLACE(tags, '$tagA->name,',''),`tags`=REPLACE(tags, ',$tagA->name','') WHERE id IN($ids)");
         // }
         iDB::query("DELETE FROM `#iCMS@__tags`  WHERE `{$field}`='{$v}'");
         iDB::query("DELETE FROM `#iCMS@__tags_map` WHERE `node`='{$tagA->id}' AND `appid`='" . TAG_APPID . "' {$sql}");
         $ckey = self::tkey($tagA->cid);
         iCache::delete($ckey);
     }
 }
示例#29
0
 public static function getFileData($f, $v)
 {
     if (!self::$checkFileData) {
         return;
     }
     $sql = self::$userid === false ? '' : " AND `userid`='" . self::$userid . "'";
     $rs = iDB::row("SELECT * FROM " . iPHP_DB_PREFIX . self::$TABLE . " WHERE `{$f}`='{$v}' {$sql} LIMIT 1");
     if ($rs) {
         $rs->filepath = $rs->path . $rs->filename . '.' . $rs->ext;
         if ($f == 'ofilename') {
             $filepath = self::fp($rs->filepath, '+iPATH');
             if (is_file($filepath)) {
                 return $rs;
             } else {
                 return false;
             }
         }
     }
     return $rs;
 }
示例#30
0
 function do_del($id = null)
 {
     iACP::MP('FILE.DELETE', 'alert');
     $id === null && ($id = $this->id);
     $id or iPHP::alert("请选择要删除的文件");
     $indexid = (int) $_GET['indexid'];
     $sql = isset($_GET['indexid']) ? "AND `indexid`='{$indexid}'" : "";
     $rs = iDB::row("SELECT * FROM `#iCMS@__filedata` WHERE `id` = '{$id}' {$sql} LIMIT 1;");
     if ($rs) {
         $rs->filepath = rtrim($rs->path, '/') . '/' . $rs->filename . '.' . $rs->ext;
         $FileRootPath = iFS::fp($rs->filepath, "+iPATH");
         if (iFS::del($FileRootPath)) {
             iDB::query("DELETE FROM `#iCMS@__filedata` WHERE `id` = '{$id}' {$sql};");
             $msg = 'success:#:check:#:文件删除完成!';
             $_GET['ajax'] && iPHP::json(array('code' => 1, 'msg' => $msg));
         } else {
             $msg = 'warning:#:warning:#:找不到相关文件,文件删除失败!<hr/>文件相关数据已清除';
             $_GET['ajax'] && iPHP::json(array('code' => 0, 'msg' => $msg));
         }
         iPHP::dialog($msg, 'js:parent.$("#tr' . $id . '").remove();');
     }
     $msg = '文件删除失败!';
     $_GET['ajax'] && iPHP::json(array('code' => 0, 'msg' => $msg));
     iPHP::alert($msg);
 }