Example #1
0
 function do_del($id = null, $dialog = true)
 {
     $id === null && ($id = $this->id);
     $id or iPHP::alert('请选择要删除的网站!');
     iDB::query("DELETE FROM `#iCMS@__links` WHERE `id` = '{$id}'");
     $dialog && iPHP::success('网站已经删除', 'js:parent.$("#tr' . $id . '").remove();');
 }
Example #2
0
 function get_array($cache = false)
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__menu` ORDER BY `ordernum` , `id` ASC");
     $this->menu_array = array();
     $this->root_array = array();
     $this->parent = array();
     $this->menu_uri = array();
     $this->child_array = array();
     foreach ((array) $rs as $M) {
         $this->menu_array[$M['id']] = $M;
         $this->root_array[$M['rootid']][$M['id']] = $M;
         $this->parent[$M['id']] = $M['rootid'];
         $M['app'] != 'separator' && ($this->child_array[$M['rootid']][$M['id']] = $M['id']);
         if (!$this->menu_uri[$M['app']][$M['href']]) {
             $this->menu_uri[$M['app']][$M['href']] = $M['id'];
         }
         $this->menu_uri[$M['app']]['#'] = $M['rootid'];
     }
     foreach ((array) $this->root_array as $rid => $array) {
         uasort($array, "order_num");
         $this->root_array[$rid] = $array;
     }
     if ($cache) {
         iCache::set('iCMS/iMenu/menu_array', $this->menu_array, 0);
         iCache::set('iCMS/iMenu/root_array', $this->root_array, 0);
         iCache::set('iCMS/iMenu/child_array', $this->child_array, 0);
         iCache::set('iCMS/iMenu/parent', $this->parent, 0);
         iCache::set('iCMS/iMenu/menu_uri', $this->menu_uri, 0);
     }
 }
Example #3
0
 public static function send($a = array("send_uid" => 0, "send_name" => NULL, "receiv_uid" => 0, "receiv_name" => NULL, "content" => NULL), $type = 1)
 {
     // $userid = (int)$a['userid'];
     // $friend = (int)$a['friend'];
     $send_uid = (int) $a['send_uid'];
     $send_name = iS::escapeStr($a['send_name']);
     $receiv_uid = (int) $a['receiv_uid'];
     $receiv_name = iS::escapeStr($a['receiv_name']);
     $content = iS::escapeStr($a['content']);
     $sendtime = time();
     if ($send_uid && $send_uid == $receiv_uid && !$a['self']) {
         return;
     }
     $fields = array('userid', 'friend', 'send_uid', 'send_name', 'receiv_uid', 'receiv_name', 'content', 'type', 'sendtime', 'readtime', 'status');
     $data = compact($fields);
     $data['userid'] = $send_uid;
     $data['friend'] = $receiv_uid;
     $data['readtime'] = "0";
     $data['status'] = "1";
     iDB::insert('message', $data);
     if ($type == "1") {
         $data['userid'] = $receiv_uid;
         $data['friend'] = $send_uid;
         iDB::insert('message', $data);
     }
 }
Example #4
0
 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;
     }
 }
Example #5
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 */
function iCMS_link($vars)
{
    $limit = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
    switch ($vars['type']) {
        case "text":
            $sql[] = " `logo`='' ";
            break;
        case "logo":
            $sql[] = " `logo`!='' ";
            break;
    }
    isset($vars['cid']) && ($sql[] = " cid='" . $vars['cid'] . "'");
    $sql && ($where = 'WHERE ' . implode(' AND ', $sql));
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = '';
    } else {
        $cacheName = 'links/' . md5($sql);
        $rs = iCache::get($cacheName);
    }
    if (empty($rs)) {
        $rs = iDB::all("SELECT * FROM `#iCMS@__links`{$where} ORDER BY ordernum ASC,id ASC LIMIT 0 , {$limit}");
        $iscache && iCache::set($cacheName, $rs, $cache_time);
    }
    return $rs;
}
Example #6
0
 public static function ids($nodes = 0)
 {
     if (empty($nodes)) {
         return false;
     }
     $sql = self::sql($nodes);
     $all = iDB::all($ids . 'Limit 10000');
     return iCMS::get_ids($all, 'iid');
 }
Example #7
0
 private function slog($search)
 {
     $sid = iDB::value("SELECT `id` FROM `#iCMS@__search_log` WHERE `search` = '{$search}' LIMIT 1");
     if ($sid) {
         iDB::query("UPDATE `#iCMS@__search_log` SET `times` = times+1 WHERE `id` = '{$sid}';");
     } else {
         iDB::query("INSERT INTO `#iCMS@__search_log` (`search`, `times`, `addtime`) VALUES ('{$search}', '1', '" . time() . "');");
     }
 }
Example #8
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: push.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
function push_list($vars)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $where_sql = "WHERE `status`='1'";
    isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
    if (isset($vars['cid!'])) {
        $ncids = explode(',', $vars['cid!']);
        $vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
        $where_sql .= iPHP::where($ncids, 'cid', 'not');
    }
    if (isset($vars['cid'])) {
        $cid = explode(',', $vars['cid']);
        $vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
        $where_sql .= iPHP::where($cid, 'cid');
    }
    isset($vars['pid']) && ($where_sql .= " AND `type` ='{$vars['pid']}'");
    isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
    isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
    isset($vars['startdate']) && ($where_sql .= " AND `addtime`>='" . strtotime($vars['startdate']) . "'");
    isset($vars['enddate']) && ($where_sql .= " AND `addtime`<='" . strtotime($vars['enddate']) . "'");
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "addtime":
            $order_sql = " ORDER BY `addtime` {$by}";
            break;
        case "disorder":
            $order_sql = " ORDER BY `ordernum` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` DESC";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/push/' . md5($where_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__push` {$where_sql} {$order_sql} LIMIT {$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['pic'] && ($value['pic'] = iFS::fp($value['pic'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['pic2'] && ($value['pic2'] = iFS::fp($value['pic2'], '+http'));
                $value['metadata'] && ($value['metadata'] = unserialize($value['metadata']));
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Example #9
0
 public static function get_rand_ids($table, $where = null, $limit = '10', $primary = 'id')
 {
     $whereSQL = $where ? "{$where} AND `{$table}`.`{$primary}` >= rand_id" : ' WHERE `{$table}`.`{$primary}` >= rand_id';
     // $limitNum = rand(2,10);
     // $prelimit = ceil($limit/rand(2,10));
     $randSQL = "\n            SELECT `{$table}`.`{$primary}` FROM `{$table}`\n            JOIN (SELECT\n                  ROUND(RAND() * (\n                      (SELECT MAX(`{$table}`.`{$primary}`) FROM `{$table}`) -\n                      (SELECT MIN(`{$table}`.`{$primary}`) FROM `{$table}`)\n                    ) + (SELECT MIN(`{$table}`.`{$primary}`) FROM `{$table}`)\n                 ) AS rand_id) RAND_DATA\n            {$whereSQL}\n            LIMIT {$limit};\n        ";
     $randIdsArray = iDB::all($randSQL);
     // $randIdsArray = null;
     // for ($i=0; $i <=$prelimit; $i++) {
     //     $randIdsArray[$i] = array('id'=>iDB::value($randSQL));
     //     echo iDB::$last_query;
     // }
     return $randIdsArray;
 }
Example #10
0
 public static function cache()
 {
     $rs = iDB::all("SELECT `id`,`name`,`title`,`table`,`field` FROM `#iCMS@__app`");
     foreach ((array) $rs as $a) {
         $tb_array = json_decode($a['table']);
         $table = array('name' => '#iCMS@__' . $tb_array[0][0], 'primary' => $tb_array[0][1]);
         if ($tb_array[1]) {
             $table['join'] = '#iCMS@__' . $tb_array[1][0];
             $table['on'] = $tb_array[1][1];
         }
         $a['table'] = $table;
         $app_id_array[$a['id']] = $a;
         $app_name_array[$a['name']] = $a;
         iCache::delete('iCMS/app/' . $a['id']);
         iCache::set('iCMS/app/' . $a['id'], $a, 0);
         iCache::delete('iCMS/app/' . $a['name']);
         iCache::set('iCMS/app/' . $a['name'], $a, 0);
     }
     iCache::set('iCMS/app/cache_id', $app_id_array, 0);
     iCache::set('iCMS/app/cache_name', $app_name_array, 0);
 }
Example #11
0
 public static function init()
 {
     self::config();
     iFS::init(self::$config['FS'], self::$config['watermark'], 'filedata');
     iCache::init(self::$config['cache']);
     iURL::init(self::$config['router']);
     iPHP::iTemplate();
     iPHP_DEBUG && (iDB::$show_errors = true);
     iPHP_TPL_DEBUG && iPHP::clear_compiled_tpl();
     define('iCMS_DIR', self::$config['router']['DIR']);
     define('iCMS_URL', self::$config['router']['URL']);
     define('iCMS_PUBLIC_URL', self::$config['router']['public_url']);
     define('iCMS_USER_URL', self::$config['router']['user_url']);
     define('iCMS_FS_URL', self::$config['FS']['url']);
     define('iCMS_REWRITE', self::$config['router']['rewrite']);
     define('iCMS_API', iCMS_PUBLIC_URL . '/api.php');
     define('iCMS_UI', iCMS_DIR . 'app/ui/common');
     define('iCMS_UI_URL', iCMS_URL . '/app/ui/common');
     self::$apps = self::$config['apps'];
     self::assign_site();
 }
Example #12
0
 public static function checkLogin()
 {
     //        self::$LOGIN_COUNT = (int)authcode(get_cookie('iCMS_LOGIN_COUNT'),'DECODE');
     //        if(self::$LOGIN_COUNT>iCMS_LOGIN_COUNT) exit();
     $a = iS::escapeStr($_POST['username']);
     $p = iS::escapeStr($_POST['password']);
     $ip = iPHP::getIp();
     $sep = iPHP_AUTH_IP ? '#=iCMS[' . $ip . ']=#' : '#=iCMS=#';
     if (empty($a) && empty($p)) {
         $auth = iPHP::get_cookie(self::$AUTH);
         list($a, $p) = explode($sep, authcode($auth, 'DECODE'));
         return self::check($a, $p);
     } else {
         $p = md5($p);
         $crs = self::check($a, $p);
         iDB::query("UPDATE `#iCMS@__members` SET `lastip`='" . $ip . "',`lastlogintime`='" . time() . "',`logintimes`=logintimes+1 WHERE `uid`='" . self::$userid . "'");
         iPHP::set_cookie(self::$AUTH, authcode($a . $sep . $p, 'ENCODE'));
         self::$AJAX && iPHP::json(array('code' => 1));
         return $crs;
     }
 }
Example #13
0
 function count_post($userid)
 {
     $rs = iDB::all("SELECT `postime`,`status` FROM #iCMS@__article where `userid`='" . $userid . "'");
     $this->total = count($rs);
     $this->today['count'] = $this->yesterday['count'] = $this->month['count'] = $this->pmonth['count'] = 0;
     $this->day_count_post = array();
     $this->count0post = 0;
     foreach ((array) $rs as $key => $a) {
         $this->day_count_post[date('Y-m-j', $a['postime'])]++;
         if ($a['status'] != "1") {
             $this->count0post++;
         }
         if ($a['status'] == "1") {
             $this->count_time_post($a['postime'], $this->today['start'], $this->today['end'], $this->today['count']);
             $this->count_time_post($a['postime'], $this->yesterday['start'], $this->yesterday['end'], $this->yesterday['count']);
             $this->count_time_post($a['postime'], $this->month['start'], $this->month['end'], $this->month['count']);
             $this->count_time_post($a['postime'], $this->pmonth['start'], $this->pmonth['end'], $this->pmonth['count']);
         } else {
             $this->count_time_post($a['postime'], $this->today['start'], $this->today['end'], $this->today['count0']);
         }
     }
 }
Example #14
0
 function do_iCMS()
 {
     //数据统计
     $rs = iDB::all("SHOW FULL TABLES FROM `" . iPHP_DB_NAME . "` WHERE table_type = 'BASE TABLE';");
     foreach ($rs as $k => $val) {
         if (strstr(iPHP_DB_PREFIX, $val['Tables_in_' . iPHP_DB_NAME]) === false) {
             $iTable[] = strtoupper($val['Tables_in_' . iPHP_DB_NAME]);
         } else {
             $oTable[] = $val['Tables_in_' . iPHP_DB_NAME];
         }
     }
     $content_datasize = 0;
     $tables = iDB::all("SHOW TABLE STATUS");
     $_count = count($tables);
     for ($i = 0; $i < $_count; $i++) {
         $tableName = strtoupper($tables[$i]['Name']);
         if (in_array($tableName, $iTable)) {
             $datasize += $tables[$i]['Data_length'];
             $indexsize += $tables[$i]['Index_length'];
             if (stristr(strtoupper(iPHP_DB_PREFIX . "article," . iPHP_DB_PREFIX . "category," . iPHP_DB_PREFIX . "comment," . iPHP_DB_PREFIX . "article_data"), $tableName)) {
                 $content_datasize += $tables[$i]['Data_length'] + $tables[$i]['Index_length'];
             }
         }
     }
     $acc = iDB::value("SELECT count(*) FROM `#iCMS@__category` WHERE `appid`='" . iCMS_APP_ARTICLE . "'");
     $tac = iDB::value("SELECT count(*) FROM `#iCMS@__category` WHERE `appid`='" . iCMS_APP_TAG . "'");
     $pac = iDB::value("SELECT count(*) FROM `#iCMS@__category` WHERE `appid`='" . iCMS_APP_PUSH . "'");
     $ac = iDB::value("SELECT count(*) FROM `#iCMS@__article`");
     $ac0 = iDB::value("SELECT count(*) FROM `#iCMS@__article` WHERE `status`='0'");
     $ac2 = iDB::value("SELECT count(*) FROM `#iCMS@__article` WHERE `status`='2'");
     $ctc = iDB::value("SELECT count(*) FROM `#iCMS@__comment`");
     $tc = iDB::value("SELECT count(*) FROM `#iCMS@__tags`");
     $kc = iDB::value("SELECT count(*) FROM `#iCMS@__keywords`");
     $pc = iDB::value("SELECT count(*) FROM `#iCMS@__push`");
     $uc = iDB::value("SELECT count(*) FROM `#iCMS@__user`");
     $fdc = iDB::value("SELECT count(*) FROM `#iCMS@__filedata`");
     $lc = iDB::value("SELECT count(*) FROM `#iCMS@__links`");
     include iACP::view("home");
 }
Example #15
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'];
    }
}
Example #16
0
/**
 * @package iCMS
 * @copyright 2007-2010, iDreamSoft
 * @license http://www.idreamsoft.com iDreamSoft
 * @author coolmoo <*****@*****.**>
 * @$Id: search.tpl.php 1392 2013-05-20 12:28:08Z coolmoo $
 */
function search_list($vars)
{
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "100";
    $cache_time = isset($vars['time']) ? (int) $vars['time'] : "-1";
    $where_sql = '';
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    switch ($vars['orderby']) {
        case "id":
            $order_sql = " ORDER BY `id` {$by}";
            break;
        case "addtime":
            $order_sql = " ORDER BY `addtime` {$by}";
            break;
        case "times":
            $order_sql = " ORDER BY `times` {$by}";
            break;
        default:
            $order_sql = " ORDER BY `id` DESC";
    }
    if ($vars['cache']) {
        $cache_name = iPHP_DEVICE . '/search/' . md5($where_sql . $order_sql);
        $resource = iCache::get($cache_name);
    }
    if (empty($resource)) {
        $resource = iDB::all("SELECT * FROM `#iCMS@__search_log` {$where_sql} {$order_sql} LIMIT {$maxperpage}");
        iPHP_SQL_DEBUG && iDB::debug(1);
        if ($resource) {
            foreach ($resource as $key => $value) {
                $value['name'] = $value['search'];
                $value['url'] = search_url(array('query' => $value['name'], 'ret' => true));
                $resource[$key] = $value;
            }
        }
        $vars['cache'] && iCache::set($cache_name, $resource, $cache_time);
    }
    return $resource;
}
Example #17
0
 public function API_crontab()
 {
     $timeline = iCMS::timeline();
     //var_dump($timeline);
     $pieces = array();
     foreach ($timeline as $key => $bool) {
         $field = "hits_{$key}";
         if ($key == 'yday') {
             if ($bool == 1) {
                 $pieces[] = "`hits_yday` = hits_today";
             } elseif ($bool > 1) {
                 $pieces[] = "`hits_yday` = 0";
             }
         } else {
             $bool or $pieces[] = "`{$field}` = 0";
         }
     }
     $pieces && ($sql = implode(',', $pieces));
     if ($sql) {
         //点击初始化
         iDB::query("UPDATE `#iCMS@__article` SET {$sql}");
         iDB::query("UPDATE `#iCMS@__user` SET {$sql}");
     }
 }
Example #18
0
 public static function total($tnkey, $sql, $type = null)
 {
     $tnkey == 'sql.md5' && ($tnkey = md5($sql));
     $tnkey = substr($tnkey, 8, 16);
     $total = (int) $_GET['total_num'];
     if (empty($total) && $type === null && !isset($_GET['total_cahce'])) {
         $total = (int) iCache::get('total/' . $tnkey);
     }
     if (empty($total) || $type === 'nocache' || isset($_GET['total_cahce'])) {
         $total = iDB::value($sql);
         if ($type === null) {
             iCache::set('total/' . $tnkey, $total);
         }
     }
     return $total;
 }
Example #19
0
 function do_batch()
 {
     $idArray = (array) $_POST['id'];
     $idArray or iPHP::alert("请选择要操作的标签");
     $ids = implode(',', $idArray);
     $batch = $_POST['batch'];
     switch ($batch) {
         case 'dels':
             iPHP::$break = false;
             foreach ($idArray as $id) {
                 $this->do_del($id, false);
             }
             iPHP::$break = true;
             iPHP::success('标签全部删除完成!', 'js:1');
             break;
         case 'move':
             $_POST['cid'] or iPHP::alert("请选择目标栏目!");
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $cid = (int) $_POST['cid'];
             foreach ($idArray as $id) {
                 $_cid = iDB::value("SELECT `cid` FROM `#iCMS@__tags` where `id` ='{$id}'");
                 iDB::update("tags", compact('cid'), compact('id'));
                 if ($_cid != $cid) {
                     map::diff($cid, $_cid, $id);
                     $this->categoryApp->update_count_one($_cid, '-');
                     $this->categoryApp->update_count_one($cid);
                 }
             }
             iPHP::success('成功移动到目标栏目!', 'js:1');
             break;
         case 'mvtcid':
             $_POST['tcid'] or iPHP::alert("请选择目标分类!");
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $tcid = (int) $_POST['tcid'];
             foreach ($idArray as $id) {
                 $_tcid = iDB::value("SELECT `tcid` FROM `#iCMS@__tags` where `id` ='{$id}'");
                 iDB::update("tags", compact('tcid'), compact('id'));
                 if ($_tcid != $tcid) {
                     map::diff($tcid, $_tcid, $id);
                     $this->categoryApp->update_count_one($_tcid, '-');
                     $this->categoryApp->update_count_one($tcid);
                 }
             }
             iPHP::success('成功移动到目标分类!', 'js:1');
             break;
         case 'prop':
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $pid = implode(',', (array) $_POST['pid']);
             foreach ((array) $_POST['id'] as $id) {
                 $_pid = iDB::value("SELECT pid FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                 iDB::update("tags", compact('pid'), compact('id'));
                 map::diff($pid, $_pid, $id);
             }
             iPHP::success('属性设置完成!', 'js:1');
             break;
         case 'weight':
             $weight = _int($_POST['mweight']);
             $sql = "`weight` = '{$weight}'";
             break;
         case 'tpl':
             $tpl = iS::escapeStr($_POST['mtpl']);
             $sql = "`tpl` = '{$tpl}'";
             break;
         case 'keyword':
             if ($_POST['pattern'] == 'replace') {
                 $sql = "`keywords` = '" . iS::escapeStr($_POST['mkeyword']) . "'";
             } elseif ($_POST['pattern'] == 'addto') {
                 foreach ($idArray as $id) {
                     $keywords = iDB::value("SELECT keywords FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                     $sql = "`keywords` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mkeyword']) : iS::escapeStr($_POST['mkeyword'])) . "'";
                     iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
                 }
                 iPHP::success('关键字更改完成!', 'js:1');
             }
             break;
         case 'tag':
             if ($_POST['pattern'] == 'replace') {
                 $sql = "`related` = '" . iS::escapeStr($_POST['mtag']) . "'";
             } elseif ($_POST['pattern'] == 'addto') {
                 foreach ($idArray as $id) {
                     $keywords = iDB::value("SELECT related FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                     $sql = "`related` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mtag']) : iS::escapeStr($_POST['mtag'])) . "'";
                     iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
                 }
                 iPHP::success('相关标签更改完成!', 'js:1');
             }
             break;
         default:
             if (strpos($batch, ':')) {
                 $data = iACP::fields($batch);
                 foreach ($idArray as $id) {
                     $data && iDB::update("tags", $data, array('id' => $id));
                 }
                 iPHP::success('操作成功!', 'js:1');
             } else {
                 iPHP::alert('请选择要操作项!', 'js:1');
             }
     }
     $sql && iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id` IN ({$ids})");
     iPHP::success('操作成功!', 'js:1');
 }
Example #20
0
 function do_createArticle($aid = null)
 {
     $category = $this->PG['cid'];
     $startime = $this->PG['startime'];
     $endtime = $this->PG['endtime'];
     $startid = $this->PG['startid'];
     $endid = $this->PG['endid'];
     $perpage = (int) $this->PG['perpage'];
     $offset = (int) $this->PG['offset'];
     $orderby = $this->PG['orderby'];
     $whereSQL = "WHERE `status` ='1'";
     $aid === null && ($aid = $this->PG['aid']);
     if ($aid) {
         $title = self::Article($aid);
         iPHP::success($title . '<hr />生成静态完成!');
     }
     $category[0] == 'all' && ($category = $this->get_category(iCMS_APP_ARTICLE));
     if ($category) {
         $cids = implode(',', (array) $category);
         $whereSQL .= " AND `cid` IN({$cids})";
     }
     $startime && ($whereSQL .= " AND `pubdate`>=UNIX_TIMESTAMP('{$startime} 00:00:00')");
     $endtime && ($whereSQL .= " AND `pubdate`<=UNIX_TIMESTAMP('{$endtime} 23:59:59')");
     $startid && ($whereSQL .= " AND `id`>='{$startid}'");
     $endid && ($whereSQL .= " AND `id`<='{$endid}'");
     $perpage or $perpage = $this->CP;
     $orderby or $orderby = "id DESC";
     $total = iPHP::total(false, "SELECT count(*) FROM `#iCMS@__article` {$whereSQL}", "G");
     $looptimes = ceil($total / $perpage);
     $offset = $this->page * $perpage;
     $rs = iDB::all("SELECT `id` FROM `#iCMS@__article` {$whereSQL} order by {$orderby} LIMIT {$offset},{$perpage}");
     $_count = count($rs);
     $msg = "共<span class='label label-info'>{$total}</span>篇文章,将分成<span class='label label-info'>{$looptimes}</span>次完成<hr />开始执行第<span class='label label-info'>" . ($this->page + 1) . "</span>次生成,共<span class='label label-info'>{$_count}</span>篇<hr />";
     for ($i = 0; $i < $_count; $i++) {
         self::Article($rs[$i]['id']);
         $msg .= '<span class="label label-success">' . $rs[$i]['id'] . ' <i class="fa fa-check"></i></span> ';
     }
     $GLOBALS['page']++;
     $use_time = iPHP::timer_stop();
     $msg .= "<hr />用时<span class='label label-info'>{$use_time}</span>秒";
     $query["total_num"] = $total;
     $query["alltime"] = $this->alltime + $use_time;
     $loopurl = $this->loopurl($looptimes, $query);
     if ($loopurl) {
         $moreBtn = array(array("id" => "btn_stop", "text" => "停止", "url" => APP_URI . "&do=article"), array("id" => "btn_next", "text" => "继续", "src" => $loopurl, "next" => true));
         $dtime = 1;
         $all_time = $looptimes * $use_time + $looptimes + 1;
         $msg .= "<hr />预计全部生成还需要<span class='label label-info'>{$all_time}</span>秒";
     } else {
         $moreBtn = array(array("id" => "btn_next", "text" => "完成", "url" => APP_URI . "&do=article"));
         $dtime = 5;
         $msg .= "<hr />已全部生成完成<hr />总共用时<span class='label label-info'>" . $query["alltime"] . "</span>秒";
     }
     $updateMsg = $this->page ? true : false;
     iPHP::dialog($msg, $loopurl ? "src:" . $loopurl : '', $dtime, $moreBtn, $updateMsg);
 }
Example #21
0
function article_search($vars)
{
    if (empty(iCMS::$config['sphinx']['host'])) {
        return array();
    }
    $resource = array();
    $hidden = iCache::get('iCMS/category/hidden');
    $hidden && ($where_sql .= iPHP::where($hidden, 'cid', 'not'));
    $SPH = iCMS::sphinx();
    $SPH->init();
    $SPH->SetArrayResult(true);
    if (isset($vars['weights'])) {
        //weights='title:100,tags:80,keywords:60,name:50'
        $wa = explode(',', $vars['weights']);
        foreach ($wa as $wk => $wv) {
            $waa = explode(':', $wv);
            $FieldWeights[$waa[0]] = $waa[1];
        }
        $FieldWeights or $FieldWeights = array("title" => 100, "tags" => 80, "name" => 60, "keywords" => 40);
        $SPH->SetFieldWeights($FieldWeights);
    }
    $page = (int) $_GET['page'];
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $start = $page && isset($vars['page']) ? ($page - 1) * $maxperpage : 0;
    $SPH->SetMatchMode(SPH_MATCH_EXTENDED);
    if ($vars['mode']) {
        $vars['mode'] == "SPH_MATCH_BOOLEAN" && $SPH->SetMatchMode(SPH_MATCH_BOOLEAN);
        $vars['mode'] == "SPH_MATCH_ANY" && $SPH->SetMatchMode(SPH_MATCH_ANY);
        $vars['mode'] == "SPH_MATCH_PHRASE" && $SPH->SetMatchMode(SPH_MATCH_PHRASE);
        $vars['mode'] == "SPH_MATCH_ALL" && $SPH->SetMatchMode(SPH_MATCH_ALL);
        $vars['mode'] == "SPH_MATCH_EXTENDED" && $SPH->SetMatchMode(SPH_MATCH_EXTENDED);
    }
    isset($vars['userid']) && $SPH->SetFilter('userid', array($vars['userid']));
    isset($vars['postype']) && $SPH->SetFilter('postype', array($vars['postype']));
    if (isset($vars['cid'])) {
        $cids = $vars['sub'] ? iCMS::get_category_ids($vars['cid'], true) : (array) $vars['cid'];
        $cids or $cids = (array) $vars['cid'];
        $cids = array_map("intval", $cids);
        $SPH->SetFilter('cid', $cids);
    }
    if (isset($vars['startdate'])) {
        $startime = strtotime($vars['startdate']);
        $enddate = empty($vars['enddate']) ? time() : strtotime($vars['enddate']);
        $SPH->SetFilterRange('pubdate', $startime, $enddate);
    }
    $SPH->SetLimits($start, $maxperpage, 10000);
    $orderby = '@id DESC, @weight DESC';
    $order_sql = ' order by id DESC';
    $vars['orderby'] && ($orderby = $vars['orderby']);
    $vars['ordersql'] && ($order_sql = ' order by ' . $vars['ordersql']);
    $vars['pic'] && $SPH->SetFilter('haspic', array(1));
    $vars['id!'] && $SPH->SetFilter('@id', array($vars['id!']), true);
    $SPH->setSortMode(SPH_SORT_EXTENDED, $orderby);
    $query = str_replace(',', '|', $vars['q']);
    $vars['acc'] && ($query = '"' . $vars['q'] . '"');
    $vars['@'] && ($query = '@(' . $vars['@'] . ') ' . $query);
    $res = $SPH->Query($query, iCMS::$config['sphinx']['index']);
    if (is_array($res["matches"])) {
        foreach ($res["matches"] as $docinfo) {
            $aid[] = $docinfo['id'];
        }
        $aids = implode(',', (array) $aid);
    }
    if (empty($aids)) {
        return;
    }
    $where_sql = " `id` in({$aids})";
    $offset = 0;
    if ($vars['page']) {
        $total = $res['total'];
        iPHP::assign("article_search_total", $total);
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
        $offset = $multi->offset;
    }
    $resource = iDB::all("SELECT * FROM `#iCMS@__article` WHERE {$where_sql} {$order_sql} LIMIT {$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $resource = __article_array($vars, $resource);
    return $resource;
}
Example #22
0
 function do_del($uid = null, $dialog = true)
 {
     $uid === null && ($uid = $this->uid);
     $uid or iPHP::alert('请选择要删除的用户');
     $uid == "1" && iPHP::alert('不能删除超级管理员');
     iDB::query("DELETE FROM `#iCMS@__members` WHERE `uid` = '{$uid}'");
     $dialog && iPHP::success('用户删除完成', 'js:parent.$("#tr' . $uid . '").remove();');
 }
Example #23
0
 function do_saveproject()
 {
     $id = (int) $_POST['id'];
     $name = iS::escapeStr($_POST['name']);
     $urls = iS::escapeStr($_POST['urls']);
     $list_url = $_POST['list_url'];
     $cid = iS::escapeStr($_POST['cid']);
     $rid = iS::escapeStr($_POST['rid']);
     $poid = iS::escapeStr($_POST['poid']);
     $poid = iS::escapeStr($_POST['poid']);
     $checker = iS::escapeStr($_POST['checker']);
     $self = isset($_POST['self']) ? '1' : '0';
     $sleep = (int) $_POST['sleep'];
     $auto = iS::escapeStr($_POST['auto']);
     $psleep = (int) $_POST['psleep'];
     $lastupdate = $_POST['lastupdate'] ? iPHP::str2time($_POST['lastupdate']) : '';
     empty($name) && iPHP::alert('名称不能为空!');
     empty($cid) && iPHP::alert('请选择绑定的栏目');
     empty($rid) && iPHP::alert('请选择采集规则');
     //empty($poid)	&& iPHP::alert('请选择发布规则');
     $fields = array('name', 'urls', 'list_url', 'cid', 'rid', 'poid', 'checker', 'self', 'sleep', 'auto', 'lastupdate', 'psleep');
     $data = compact($fields);
     if ($id) {
         iDB::update('spider_project', $data, array('id' => $id));
     } else {
         iDB::insert('spider_project', $data);
     }
     iPHP::success('完成', 'url:' . APP_URI . '&do=project');
 }
Example #24
0
<?php

/**
 * iCMS - i Content Management System
 * Copyright (c) 2007-2012 idreamsoft.com iiimon Inc. All rights reserved.
 *
 * @author coolmoo <*****@*****.**>
 * @site http://www.idreamsoft.com
 * @licence http://www.idreamsoft.com/license.php
 * @version 6.0.0
 * @$Id: admincp.class.php 2361 2014-02-22 01:52:39Z coolmoo $
 */
defined('iPHP') or exit('What are you doing?');
iDB::$show_errors = true;
iPHP::$dialog['title'] = 'iCMS';
define('iCMS_SUPERADMIN_UID', '1');
define('__ADMINCP__', __SELF__ . '?app');
define('ACP_PATH', iPHP_APP_DIR . '/admincp');
define('ACP_HOST', "http://" . $_SERVER['HTTP_HOST']);
require iPHP_APP_CORE . '/iMenu.class.php';
require iPHP_APP_CORE . '/iMember.class.php';
iMember::$LOGIN_TPL = ACP_PATH;
iMember::$AUTH = 'ADMIN_AUTH';
iMember::$AJAX = iPHP::PG('ajax');
$_GET['do'] == 'seccode' && iACP::get_seccode();
class iACP
{
    public static $apps = NULL;
    public static $frames = NULL;
    public static $menu = NULL;
    public static $app = NULL;
Example #25
0
function user_inbox($vars = null)
{
    $maxperpage = 30;
    $where_sql = "WHERE `status` ='1'";
    if ($_GET['user']) {
        if ($_GET['user'] == "10000") {
            $where_sql .= " AND `userid`='10000' AND `friend` IN ('" . user::$userid . "','0')";
        } else {
            $friend = (int) $_GET['user'];
            $where_sql .= " AND `userid`='" . user::$userid . "' AND `friend`='" . $friend . "'";
        }
        $group_sql = '';
        $p_fields = 'COUNT(*)';
        $s_fields = '*';
        iPHP::assign("msg_count", false);
    } else {
        //	 	$where_sql.= " AND (`userid`='".user::$userid."' OR (`userid`='10000' AND `friend`='0'))";
        $where_sql .= " AND `userid`='" . user::$userid . "'";
        $group_sql = ' GROUP BY `friend` DESC';
        $p_fields = 'COUNT(DISTINCT id)';
        $s_fields = 'max(id) AS id ,COUNT(id) AS msg_count,`userid`, `friend`, `send_uid`, `send_name`, `receiv_uid`, `receiv_name`, `content`, `type`, `sendtime`, `readtime`';
        iPHP::assign("msg_count", true);
    }
    $offset = 0;
    $total = iPHP::total($md5, "SELECT {$p_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql}", 'nocache');
    iPHP::assign("msgs_total", $total);
    $multi = iCMS::page(array('total' => $total, 'perpage' => $maxperpage, 'unit' => iPHP::lang('iCMS:page:list'), 'nowindex' => $GLOBALS['page']));
    $offset = $multi->offset;
    $resource = iDB::all("SELECT {$s_fields} FROM `#iCMS@__message` {$where_sql} {$group_sql} ORDER BY `id` DESC LIMIT {$offset},{$maxperpage}");
    iPHP_SQL_DEBUG && iDB::debug(1);
    $msg_type_map = array('0' => '系统信息', '1' => '私信', '2' => '提醒', '3' => '留言');
    if ($resource) {
        foreach ($resource as $key => $value) {
            $value['sender'] = user::info($value['send_uid'], $value['send_name']);
            $value['receiver'] = user::info($value['receiv_uid'], $value['receiv_name']);
            $value['label'] = $msg_type_map[$value['type']];
            if ($value['userid'] == $value['send_uid']) {
                $value['is_sender'] = true;
                $value['user'] = $value['receiver'];
            }
            if ($value['userid'] == $value['receiv_uid']) {
                $value['is_sender'] = false;
                $value['user'] = $value['sender'];
            }
            $value['url'] = iPHP::router(array('/user/inbox/{uid}', $value['user']['uid']), iPHP_ROUTER_REWRITE);
            $resource[$key] = $value;
        }
    }
    return $resource;
}
Example #26
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);
     }
 }
Example #27
0
 function cache()
 {
     $rs = iDB::all("SELECT * FROM `#iCMS@__prop`");
     foreach ((array) $rs as $row) {
         $type_field_id[$row['type'] . '/' . $row['field']][$row['pid']] = $type_field_val[$row['type']][$row['field']][$row['val']] = $row;
     }
     // prop/article/author
     foreach ((array) $type_field_id as $key => $a) {
         iCache::set('iCMS/prop/' . $key, $a, 0);
     }
     // prop/article
     foreach ((array) $type_field_val as $k => $a) {
         iCache::set('iCMS/prop/' . $k, $a, 0);
     }
 }
Example #28
0
 public static function del_comment($iid)
 {
     iDB::query("DELETE FROM `#iCMS@__comment` WHERE iid='{$iid}' and appid='" . iCMS_APP_ARTICLE . "'");
 }
Example #29
0
 function update_count($cid)
 {
     $cc = iDB::value("SELECT count(*) FROM `#iCMS@__" . $this->_app_table . "` where `" . $this->_app_cid . "`='{$cid}'");
     iDB::query("UPDATE `#iCMS@__category` SET `count` ='{$cc}' WHERE `cid` ='{$cid}'");
 }
Example #30
0
 /**
  * Starts the timer, for debugging purposes
  */
 public static function timer_start()
 {
     $mtime = microtime();
     $mtime = explode(' ', $mtime);
     self::$time_start = $mtime[1] + $mtime[0];
     return true;
 }