function doDefault() { //数据统计 $rs = iCMS_DB::getArray("SHOW FULL TABLES FROM `" . DB_NAME . "` WHERE table_type = 'BASE TABLE';"); foreach ($rs as $k => $val) { if (strstr(DB_PREFIX, $val['Tables_in_' . DB_NAME]) === false) { $iCMSTable[] = $val['Tables_in_' . DB_NAME]; } else { $oTable[] = $val['Tables_in_' . DB_NAME]; } } $content_datasize = 0; $tables = iCMS_DB::getArray("SHOW TABLE STATUS"); $_count = count($tables); $tableStr = strtoupper(implode(",", $iCMSTable)); for ($i = 0; $i < $_count; $i++) { $tableName = strtoupper($tables[$i]['Name']); if (stristr($tableStr, $tableName)) { $datasize += $tables[$i]['Data_length']; $indexsize += $tables[$i]['Index_length']; if (stristr(strtoupper(DB_PREFIX . "article," . DB_PREFIX . "forum," . DB_PREFIX . "comment," . DB_PREFIX . "article_data"), $tableName)) { $content_datasize += $tables[$i]['Data_length'] + $tables[$i]['Index_length']; } } } $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__forum"); $a = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article"); file_exists(iPATH . 'license.php') && ($license = (include iPATH . 'license.php')); include admincp::tpl("home"); }
function doSave() { $id = (int) $_POST['id']; $name = dhtmlspecialchars($_POST['name']); $table = dhtmlspecialchars($_POST['table']); $description = dhtmlspecialchars($_POST['desc']); $position2 = $_POST['pos']; $position = $_POST['position']; $binding = isset($_POST['binding']) ? 1 : 0; empty($name) && javascript::alert('模块名称不能为空!'); empty($table) && $binding && javascript::alert('模块名不能为空!'); if (!$binding && empty($id)) { if (empty($table)) { include iPATH . 'include/cn.class.php'; $table = CN::pinyin($name); } $table = $table . '_content'; } if ($id) { iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}' and `id`!='{$id}'") && javascript::alert('该模块已经存在!请检查是否重复'); iCMS_DB::query("UPDATE `#iCMS@__model` SET `name` = '{$name}', `table` = '{$table}', `binding` = '{$binding}', `description` = '{$description}', `position` = '{$position}', `position2` = '{$position2}' WHERE `id` = '{$id}';"); } else { iCMS_DB::query("INSERT INTO `#iCMS@__model`(`name`, `table`, `binding`, `description`, `position`,`position2`, `addtime`)VALUES ('{$name}', '{$table}', '{$binding}', '{$description}', '{$position}','{$position2}', '" . time() . "');"); $id = iCMS_DB::$insert_id; } model::cache(); $moreaction = array(array("text" => "下一步添加字段", "url" => __SELF__ . "?mo=models&do=addfield&id=<?php echo {$id};?>"), array("text" => "返回模块列表", "url" => __SELF__ . "?mo=models&do=manage")); javascript::dialog('模块添加完成!<br />10秒后返回模块列表', "url:" . __SELF__ . "?mo=models&do=manage", $moreaction, 10); }
function dodefault() { member::MP(array("menu_index_advertise", "menu_advertise")); $maxperpage = 30; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__advertise`") : (int) $_GET['rowNum']; page($total, $maxperpage, "个广告"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__advertise` order by id DESC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include admincp::tpl("advertise"); }
function dodefault() { Admin::MP(array("menu_index_link", "menu_link")); $maxperpage = 60; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__links`") : (int) $_GET['rowNum']; page($total, $maxperpage, '个链接'); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__links` ORDER BY `logo`, `orderNum` ASC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include admincp::tpl('link'); }
function dodefault() { member::MP("menu_search"); $maxperpage = 20; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__search`") : (int) $_GET['rowNum']; page($total, $maxperpage, "个关键字"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__search` order by id DESC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include admincp::tpl('search'); }
function domanage() { member::MP("menu_user_manage"); $maxperpage = 20; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__members`") : (int) $_GET['rowNum']; page($total, $maxperpage, "位会员"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__members` where `type`='0' order by uid DESC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include admincp::tpl('user.manage'); }
function iCMS_tag($vars, &$iCMS) { $whereSQL = " status='1'"; isset($vars['sortid']) && ($whereSQL .= " AND sortid='" . (int) $vars['sortid'] . "'"); $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10"; $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; $by = $vars['by'] == 'ASC' ? "ASC" : "DESC"; switch ($vars['orderby']) { case "hot": $orderSQL = " ORDER BY `count` {$by}"; break; case "new": $orderSQL = " ORDER BY `id` {$by}"; break; case "order": $orderSQL = " ORDER BY `ordernum` {$by}"; break; // case "rand": $orderSQL=" ORDER BY rand() $by"; break; // case "rand": $orderSQL=" ORDER BY rand() $by"; break; default: $orderSQL = " ORDER BY `id` {$by}"; } $offset = 0; if ($vars['page']) { $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__tags` WHERE {$whereSQL} {$orderSQL}"); $iCMS->assign("total", $total); $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav"; $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0; $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:tag'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle)); } $iscache = true; if ($vars['cache'] == false || isset($vars['page'])) { $iscache = false; $rs = ''; } else { $cacheName = 'tags/' . md5($whereSQL . $orderSQL); $rs = $iCMS->getCache($cacheName); } if (empty($rs)) { $frs = $iCMS->getCache('system/forum.cache'); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__tags` WHERE {$whereSQL} {$orderSQL} LIMIT {$offset},{$maxperpage}"); //echo iCMS_DB::$last_query; //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query; //$explain=iCMS_DB::getRow(iCMS_DB::$last_query); //var_dump($explain); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $rs[$i]['url'] = $iCMS->iurl('tag', array($rs[$i], $frs[$rs[$i]['sortid']]))->href; $rs[$i]['link'] = '<a href="' . $rs[$i]['url'] . '" class="tag" target="_self">' . $rs[$i]['name'] . '</a> '; $rs[$i]['tags'] .= $rs[$i]['link']; } $iscache && $iCMS->setCache($cacheName, $rs, $cacheTime); } return $rs; }
function doUpdate() { include_once iPATH . 'include/forum.class.php'; if ($_POST['forum']) { $forum = new forum(); $forum->cache(); } if ($_POST['adm']) { include_once iPATH . 'admin/advertise.mo.php'; $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__advertise`", OBJECT); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { adm($rs[$i]); } } $_POST['tpl'] && $this->iCMS->clear_compiled_tpl(); $_POST['iCMS_list'] && FS::rmdir(iPATH . 'cache/list'); $_POST['iCMS_forum'] && FS::rmdir(iPATH . 'cache/forum'); $_POST['iCMS_tag'] && FS::rmdir(iPATH . 'cache/tags'); if ($_POST['iCMS_ALL']) { FS::rmdir(iPATH . 'cache/list'); FS::rmdir(iPATH . 'cache/forum'); FS::rmdir(iPATH . 'cache/tags'); } $_POST['keywords'] && keywords_cache(); $_POST['tags'] && tags_cache(); if ($_POST['model']) { include iPATH . 'include/model.class.php'; model::cache(); } $_POST['field'] && field_cache(); $_POST['config'] && CreateConfigFile(); if ($_POST['Re-Article-Count']) { $rs = iCMS_DB::getArray("SELECT fid FROM `#iCMS@__forum`"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article where `fid`='" . $rs[$i]['fid'] . "' LIMIT 1 "); iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` ='{$c}' WHERE `fid` ='" . $rs[$i]['fid'] . "' LIMIT 1 "); } } if ($_POST['Re-Tag-Count']) { include_once iPATH . 'include/forum.class.php'; $rs = iCMS_DB::getArray("SELECT id FROM `#iCMS@__tags`"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $_count = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__taglist` WHERE `tid`='" . $rs[$i]['id'] . "'"); iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count` = '{$_count}' WHERE `id` ='" . $rs[$i]['id'] . "'"); tags_cache($rs[$i]['id']); } } javascript::dialog("执行完毕!", 'url:1'); }
function dodefault() { member::MP("menu_keywords"); $_GET['keywords'] && ($sql[] = " `keyword` REGEXP '{$_GET['keywords']}'"); $_GET['replace'] && ($sql[] = " `replace` REGEXP '{$_GET['replace']}'"); isset($_GET['status']) && $_GET['status'] != '-1' && ($sql[] = " `status`='" . $_GET['status'] . "'"); $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : ''; $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__keywords` {$where}") : (int) $_GET['rowNum']; page($total, $maxperpage, "个关键字"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__keywords` {$where} order by id DESC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include admincp::tpl('keywords'); }
function dodefault() { global $firstcount, $pagenav; Admin::MP("menu_message"); $_GET['keywords'] && ($sql[] = " CONCAT(author,email,url,ip) REGEXP '{$_GET['keywords']}'"); isset($_GET['status']) && ($sql[] = " `status`='" . $_GET['status'] . "'"); $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : ''; $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20; $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__plugins_message` {$where} order by id DESC"); page($total, $maxperpage, "条留言"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__plugins_message` {$where} order by id DESC LIMIT {$firstcount},{$maxperpage}"); $_count = count($rs); include plugin::acptpl(); }
function doDefault() { Admin::MP(array("menu_index_comment", "menu_comment")); include_once iPATH . 'include/model.class.php'; if ($_GET['st'] == "title") { $_GET['keywords'] && ($sql[] = " `title` REGEXP '{$_GET['keywords']}'"); } else { if ($_GET['st'] == "contents") { $_GET['keywords'] && ($sql[] = " `contents` REGEXP '{$_GET['keywords']}'"); } } $_GET['starttime'] && ($sql[] = " `addtime`>='" . strtotime($_GET['starttime']) . "'"); $_GET['endtime'] && ($sql[] = " `addtime`<='" . strtotime($_GET['endtime']) . "'"); $_GET['mid'] && ($sql[] = " `mid`='" . strtotime($_GET['mid']) . "'"); isset($_GET['status']) && $_GET['status'] != '-1' && ($sql[] = " `status`='" . $_GET['status'] . "'"); $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : ''; $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__comment` {$where}") : (int) $_GET['rowNum']; page($total, $maxperpage, "条评论"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__comment` {$where} order by id DESC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include admincp::tpl('comment'); }
function iCMS_plugins_message($vars, &$iCMS) { if (isset($vars['call'])) { if ($vars['call'] == 'form') { echo $iCMS->output('form', plugin::tpl('message')); exit; } } else { $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "20"; $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; $offset = 0; if ($vars['page']) { $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__plugins_message` WHERE `status`='0'"); $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav"; $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0; $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:message'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle)); } $iscache = true; if ($vars['cache'] == false || isset($vars['page'])) { $iscache = false; $rs = ''; } else { $cacheName = 'message/cache'; $rs = $iCMS->getCache($cacheName); } if (empty($rs)) { $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__plugins_message` WHERE `status`='0' order by `id` DESC LIMIT {$offset},{$maxperpage}"); for ($i = 0; $i < count($rs); $i++) { if ($rs[$i]['reply']) { $rs[$i]['reply'] = '<strong>' . $iCMS->language('reply:admin') . '</strong>' . $rs[$i]['reply']; } } $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime); } return $rs; } }
function doSave() { $fid = (int) $_POST['fid']; $rootid = (int) $_POST['rootid']; $modelid = (int) $_POST['modelid']; $status = (int) $_POST['status']; $issend = (int) $_POST['issend']; $isexamine = (int) $_POST['isexamine']; $orderNum = (int) $_POST['orderNum']; $mode = (int) $_POST['mode']; $name = dhtmlspecialchars($_POST['name']); $subname = dhtmlspecialchars($_POST['subname']); $domain = dhtmlspecialchars($_POST['domain']); $htmlext = dhtmlspecialchars($_POST['htmlext']); $url = dhtmlspecialchars($_POST['url']); $password = dhtmlspecialchars($_POST['password']); $pic = dhtmlspecialchars($_POST['pic']); $dir = dhtmlspecialchars($_POST['dir']); $title = dhtmlspecialchars($_POST['title']); $keywords = dhtmlspecialchars($_POST['keywords']); $description = dhtmlspecialchars($_POST['description']); $attr = dhtmlspecialchars($_POST['attr']); $forumRule = dhtmlspecialchars($_POST['forumRule']); $contentRule = dhtmlspecialchars($_POST['contentRule']); $indexTPL = dhtmlspecialchars($_POST['indexTPL']); $listTPL = dhtmlspecialchars($_POST['listTPL']); $contentTPL = dhtmlspecialchars($_POST['contentTPL']); $fid && $fid == $rootid && javascript::dialog('不能以自身做为上级栏目'); empty($name) && javascript::dialog('栏目名称不能为空!'); if (empty($dir) && empty($url)) { include iPATH . 'include/cn.class.php'; $dir = strtolower(CN::pinyin($name)); } if ($mode == "2") { if (strpos($forumRule, '{FDIR}') === FALSE && strpos($forumRule, '{FID}') === FALSE) { javascript::dialog('伪静态模式下版块URL规则<br />必需要有<br />{FDIR}版块目录<br />或者<br />{FID}版块ID', 'js:', 'ok', 10); } if (strpos($contentRule, '{AID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) { javascript::dialog('伪静态模式下内容URL规则<br />必需要有<br />{AID}文章ID <br />或者<br />{0xID}文章ID补零<br />或者<br />{LINK}文章自定义链接', 'js:', 'ok', 10); } global $iCMS; $htaFile = iPATH . "/.htaccess"; // if(file_exists($htaFile)){ // $RewriteRule=FS::read($htaFile); // } // if(empty($RewriteRule)){ $RewriteBase = $iCMS->config['dir'] == "/" ? '' : $iCMS->config['dir']; $RewriteRule = "RewriteEngine On\nRewriteBase /" . $RewriteBase . "\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\n\n"; // } //内容 $contentRR = RewriteRule($contentRule, "show", $htmlext, $iCMS->config['htmldir']); $cmd5 = md5($contentRR); if (strstr($RewriteRule, $cmd5) === false) { $RewriteRule .= "#{$cmd5}\n" . $contentRR . "#{$cmd5}\n\n\n"; } //版块 $forumRR = RewriteRule($forumRule, "forum", $htmlext, $iCMS->config['htmldir']); $fmd5 = md5($forumRR); if (strstr($RewriteRule, $fmd5) === false) { $RewriteRule .= "#{$fmd5}\n" . $forumRR . "#{$fmd5}\n\n\n"; } FS::write($htaFile, $RewriteRule); } if (empty($fid)) { iCMS_DB::getValue("SELECT `dir` FROM `#iCMS@__forum` where `dir` ='{$dir}'") && empty($url) && javascript::dialog('该栏目别名/目录已经存在!请另选一个'); iCMS_DB::query("INSERT INTO `#iCMS@__forum` (`rootid`,`modelid`,`orderNum`,`name`,`subname`,`password`,`title`,`keywords`,`description`,`dir`,`mode`,`domain`,`url`,`pic`,`htmlext`,`forumRule`,`contentRule`,`indexTPL`,`listTPL`,`contentTPL`,`attr`,`isexamine`,`issend`,`status`)\n \t\tVALUES ('{$rootid}','{$modelid}', '{$orderNum}', '{$name}','{$subname}','{$password}','{$title}','{$keywords}', '{$description}', '{$dir}','{$mode}','{$domain}', '{$url}','{$pic}','{$htmlext}','{$forumRule}', '{$contentRule}','{$indexTPL}', '{$listTPL}', '{$contentTPL}', '{$attr}','{$isexamine}','{$issend}','{$status}')"); $forum = new forum(); $forum->cache(); $msg = "栏目添加完成!"; } else { Admin::CP($fid, 'Permission_Denied', __SELF__ . '?mo=forums'); $rootid != $forum->forum[$fid]['rootid'] && Admin::CP($rootid, 'Permission_Denied', __SELF__ . '?mo=forums'); iCMS_DB::getValue("SELECT `dir` FROM `#iCMS@__forum` where `dir` ='{$dir}' AND `fid` !='{$fid}'") && empty($url) && javascript::alert('该栏目别名/目录已经存在!请另选一个'); iCMS_DB::query("UPDATE `#iCMS@__forum` SET `rootid` = '{$rootid}',`modelid` = '{$modelid}',`orderNum` = '{$orderNum}',`name` = '{$name}',`subname` = '{$subname}',`password`='{$password}',`title` = '{$title}',`keywords` = '{$keywords}',`description` = '{$description}',`dir` = '{$dir}',`url` = '{$url}',`mode` = '{$mode}',`domain` = '{$domain}',`pic`='{$pic}',`htmlext`='{$htmlext}',`forumRule`='{$forumRule}',`contentRule`='{$contentRule}',`indexTPL` = '{$indexTPL}',`listTPL` = '{$listTPL}',`contentTPL` = '{$contentTPL}',`attr` = '{$attr}',`isexamine`='{$isexamine}',`status`='{$status}',`issend`='{$issend}' WHERE `fid` ='{$fid}' "); $forum = new forum(); $forum->cache(); $msg = "栏目编辑完成!"; } javascript::dialog($msg, 'url:' . __SELF__ . '?mo=forums'); }
function delArticleTag($tId, $aId = '') { $sql = '#iCMS@__article.id = `indexId`'; $aId && ($sql .= " AND #iCMS@__article.id='{$aId}'"); $tagName = iCMS_DB::getValue("SELECT name FROM #iCMS@__tags WHERE id='{$tId}'"); $rs = iCMS_DB::getArray("SELECT #iCMS@__article.id,#iCMS@__article.tags FROM `#iCMS@__article`,`#iCMS@__taglist` WHERE {$sql} AND `tid`='" . $tId . "'"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { if ($rs[$i]['tags']) { $tagArray = explode(',', $rs[$i]['tags']); $key = array_search($tagName, $tagArray); unset($tagArray[$key]); $tags = implode(',', $tagArray); iCMS_DB::query("update `#iCMS@__article` set `tags`='{$tags}' where id='" . $rs[$i]['id'] . "'"); iCMS_DB::query("DELETE FROM `#iCMS@__taglist` WHERE `tid`='{$tId}' and `indexId`='" . $rs[$i]['id'] . "'"); } } }
function insert_db_remote($content, $aid) { $content = stripslashes($content); preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*((http|file):\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $content, $match); $_array = array_unique($match[1]); set_time_limit(0); foreach ($_array as $key => $value) { $value = uploadpath($value, '-http'); $filename = basename($value); $pic = iCMS_DB::getValue("SELECT `pic` FROM `#iCMS@__article` WHERE `id` = '{$aid}'"); $this->autopic && $key == 0 && empty($pic) && iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '{$value}' WHERE `id` = '{$aid}'"); $faid = iCMS_DB::getValue("SELECT `aid` FROM `#iCMS@__file` WHERE `filename` ='{$filename}'"); empty($faid) && iCMS_DB::query("UPDATE `#iCMS@__file` SET `aid` = '{$aid}' WHERE `filename` ='{$filename}'"); } }
$iCMS->assign('config', array('seccode' => $iCMS->config['userseccode'])); $iCMS->assign('forward', __REF__); $iCMS->iPrint("usercp/login.htm", "login"); break; case 'logout': member::cleancookie(); break; default: require_once iPATH . 'include/UI.class.php'; $action = $_POST['action']; //$forward= $_POST['forward']; if ($action == 'register') { ckseccode($_POST['seccode'], 'U') && javascript::json('seccode', 'error:seccode'); $username = dhtmlspecialchars($_POST['username']); !preg_match("/^([\\w\\.-]+)@([a-zA-Z0-9-]+)(\\.[a-zA-Z\\.]+)\$/i", $username) && javascript::json('username', 'register:emailerror'); iCMS_DB::getValue("SELECT uid FROM `#iCMS@__members` where `username`='{$username}'") && javascript::json('username', 'register:emailusr'); $password = md5(trim($_POST['password'])); $pwdrepeat = md5(trim($_POST['pwdrepeat'])); $password != $pwdrepeat && javascript::json('pwdrepeat', 'register:different'); $nickname = dhtmlspecialchars($_POST['nickname']); cstrlen($nickname) > 12 && javascript::json(0, 'register:nicknamelong'); iCMS_DB::query("INSERT INTO `#iCMS@__members` (`groupid`,`username`,`password`,`nickname`,`gender`,`info`,`power`,`cpower`,`regtime`,`lastip`,`lastlogintime`,`logintimes`,`post`,`type`,`status`) VALUES ('4','{$username}','{$password}', '{$nickname}','2','','','','" . time() . "','" . getip() . "', '" . time() . "','0','0','0','1') "); $uid = iCMS_DB::$insert_id; //设置为登陆状态 member::set_user_cookie($username, $password, $nickname); javascript::json(1, 'register:finish'); } elseif ($action == "login") { ckseccode($_POST['seccode'], 'U') && javascript::json(0, 'error:seccode'); if (member::checklogin(true)) { javascript::json(1, 'login:success'); } else {
function iCMS_comment($vars, &$iCMS) { if (!$iCMS->config['iscomment']) { return false; } $iCMS->assign('commentInfo', array('indexId' => (int) $iCMS->commentInfo['indexId'], 'sortId' => (int) $iCMS->commentInfo['sortId'], 'title' => $iCMS->commentInfo['title'], 'mId' => $iCMS->commentInfo['mId'])); if (isset($vars['call'])) { if (in_array($vars['call'], array('js', 'frame'))) { echo $iCMS->iPrint("iTPL", "comment_show_" . $vars['call']); } } elseif (isset($vars['loop'])) { $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10"; $whereSQL = "`mid`='{$mid}' and `status`='1'"; isset($vars['sortid']) && ($whereSQL .= " and `sortId`='" . (int) $vars['sortid'] . "'"); // ($iCMS->comment['indexId'] && $vars['type']!='all') && $whereSQL.=" AND `indexId`='".(int)$iCMS->comment['indexId']."'"; $vars['indexid'] && $vars['type'] != 'all' && ($whereSQL .= " AND `indexId`='" . (int) $vars['indexid'] . "'"); switch ($vars['orderby']) { case "hot": $orderSQL = " ORDER BY up+against DESC"; break; case "new": $orderSQL = " ORDER BY `addtime` DESC"; break; default: $orderSQL = " ORDER BY `id` DESC"; } $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__comment` WHERE {$whereSQL}"); $offset = 0; if ($vars['page']) { $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav"; $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0; $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:comment'), 'url' => $iCMS->url, 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle)); } $iscache = true; if ($vars['cache'] == false || isset($vars['page'])) { $iscache = false; $rs = ''; } else { $cacheName = 'comment/' . md5($whereSQL . $orderSQL); $rs = $iCMS->getCache($cacheName); } if (empty($rs)) { // include_once(iPATH.'include/ubb.fun.php'); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__comment` WHERE {$whereSQL}{$orderSQL} LIMIT {$offset},{$maxperpage}"); //echo iCMS_DB::$last_query; //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query; //$explain=iCMS_DB::getRow(iCMS_DB::$last_query); //var_dump($explain); $_count = count($rs); $ln = $GLOBALS['page'] - 1 < 0 ? 0 : $GLOBALS['page'] - 1; for ($i = 0; $i < $_count; $i++) { $rs[$i]['url'] = $iCMS->config['publicURL'] . '/comment.php?indexId=' . $rs[$i]['indexId'] . '&mId=' . $rs[$i]['mid'] . '&sortId=' . $rs[$i]['sortId']; $rs[$i]['lou'] = $total - ($i + $ln * $maxperpage); $rs[$i]['content'] = str_replace("\r", '<br />', $rs[$i]['contents']); // $rs[$i]['content']=ubb($rs[$i]['contents']); $rs[$i]['contents'] = $rs[$i]['quote'] ? cQuote($rs[$i]['quote']) : ''; $rs[$i]['contents'] .= $rs[$i]['content']; // if($rs[$i]['reply']){ // $reply=explode('||',$rs[$i]['reply']); // $rs[$i]['reply']=$reply[0]=='admin'?'<strong>'.$iCMS->language('reply:admin').'</strong>'.$reply[1]:'<strong>'.$iCMS->language('reply:author').'</strong>'.$reply[1]; // } } $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime); } return $rs; } else { $vars['width'] = is_numeric($vars['width']) ? $vars['width'] . 'px' : $vars['width']; $iCMS->append('commentInfo', array('anonymous' => $iCMS->config['anonymous'], 'anonymousname' => $iCMS->config['anonymousname'], 'width' => $vars['width'] ? $vars['width'] : '98%', 'height' => $vars['height'] ? $vars['height'] : '140'), true); echo $iCMS->iPrint("iTPL", "comment.form"); } }
$dir = $_GET['dir']; if (empty($fid)) { $fid = $iCMS->getCache('system/forum.dir2fid', $_GET['dir']); } if (empty($fid)) { header("HTTP/1.1 404 Not Found"); exit; } $F = $iCMS->getCache('system/forum.cache', $fid); $iCMS->htmlConf = array('enable' => true, 'ext' => empty($F['htmlext']) ? $iCMS->config['htmlext'] : $F['htmlext']); $iCMS->url = $iCMS->getCache('system/forum.url', $fid)->href . "/index_"; $iCMS->iList($fid); break; case 'show': $id = (int) $_GET['id']; if (empty($id)) { $id = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__article` WHERE `clink`='" . irawurldecode($_GET['clink']) . "'"); } if (empty($id)) { header("HTTP/1.1 404 Not Found"); exit; } $iCMS->htmlConf = array('enable' => true, 'ext' => $iCMS->config['htmlext']); $iCMS->Show($id, $page); break; case 'tag': $name = irawurldecode($_GET['name']); $iCMS->htmlConf = array('enable' => true, 'ext' => $iCMS->config['htmlext']); $iCMS->tag($name); break; }
function iCMS_bbs($vars, &$iCMS) { if ($iCMS->config["bbs"]["call"]) { $maxperpage = isset($vars['row']) ? (int) $vars['row'] : "10"; $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; $bbsurl = $iCMS->config["bbs"]["url"]; $dbpre = $iCMS->config["bbs"]["dbpre"]; $dbname = $iCMS->config["bbs"]["dbname"]; $charset = $iCMS->config["bbs"]["charset"]; if (empty($iCMS->config["bbs"]["dbuser"]) && empty($iCMS->config["bbs"]["dbpw"]) && $iCMS->config["bbs"]["dbhost"] == "localhost") { $DB = $iCMS->db; } else { $DB = new iCMS_DB($iCMS->config["bbs"]["dbuser"], $iCMS->config["bbs"]["dbpw"], $dbname, $iCMS->config["bbs"]["dbhost"]); $DB->hide_errors(); } if (strtolower($charset) != DB_CHARSET && !empty($charset)) { $DB->query("SET NAMES '{$charset}'"); } $by = $vars['by'] == 'ASC' ? "ASC" : "DESC"; if ($iCMS->config["bbs"]["type"] == "PHPWind") { empty($dbpre) && ($dbpre = 'pw_'); $dbname = $dbname != DB_NAME ? $dbname . '.' . $dbpre : $dbpre; $threads = $dbname . 'threads t'; $forums = $dbname . 'forums f'; $vars['fid!'] && ($whereSQL .= GetIDSQL($vars['fid!'], 't.fid', 'not')); $vars['fid'] && ($whereSQL .= GetIDSQL($vars['fid'], 't.fid')); if ($vars['call'] == "forum") { } else { switch ($vars['orderby']) { case "view": $orderSQL = " ORDER BY t.hits {$by}"; break; case "hot": $orderSQL = " ORDER BY t.replies {$by}"; break; case "lastpost": $orderSQL = " ORDER BY t.lastpost {$by}"; break; case "new": $orderSQL = " ORDER BY t.postdate {$by}"; break; case "rand": $orderSQL = " ORDER BY rand() {$by}"; break; default: $orderSQL = " ORDER BY t.tid {$by}"; } $whereSQL = "f.fid=t.fid "; $vars['tid'] && ($whereSQL .= GetIDSQL($vars['tid'], 't.tid')); $vars['tid!'] && ($whereSQL .= GetIDSQL($vars['tid!'], 't.tid', 'not')); $offset = 0; if ($vars['page']) { $total = $DB->getValue("SELECT count(*) FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL}"); $iCMS->assign("total", $total); $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav"; $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0; $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:list'), 'url' => $iCMS->url, 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle)); } if ($vars['cache'] == false || isset($vars['page'])) { $iCMS->config['iscache'] = false; $rs = ''; } else { $iCMS->config['iscache'] = true; $cacheName = 'bbs/' . md5($iCMS->config["bbs"]["type"] . $whereSQL . $orderSQL); $rs = $iCMS->cache($cacheName); } if (empty($rs)) { $rs = $DB->getArray("SELECT t.*, f.name FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL} LIMIT {$offset},{$maxperpage}"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $rs[$i]['forumname'] = $rs[$i]['name']; $rs[$i]["url"] = $bbsurl . "/read.php?tid={$rs[$i]['tid']}"; $rs[$i]["forumurl"] = $bbsurl . "/thread.php?fid={$rs[$i]['fid']}"; if ($iCMS->config["bbs"]["htmifopen"]) { $db_dir = $iCMS->config["bbs"]["htmdir"]; $db_ext = $iCMS->config["bbs"]["htmext"]; $rs[$i]["url"] = PHPWind_BBS_Htm_cv($rs[$i]["url"], $db_dir, $db_ext); $rs[$i]["forumurl"] = PHPWind_BBS_Htm_cv($rs[$i]["forumurl"], $db_dir, $db_ext); } } $iCMS->cache(false)->addcache($cacheName, $rs, $cacheTime); } } } elseif ($iCMS->config["bbs"]["type"] == "Discuz") { empty($dbpre) && ($dbpre = 'cdb_'); $dbname = $dbname != DB_NAME ? $dbname . '.' . $dbpre : $dbpre; $threads = $dbname . 'threads t'; $forums = $dbname . 'forums f'; $vars['fid!'] && ($whereSQL .= GetIDSQL($vars['fid!'], 't.fid', 'not')); $vars['fid'] && ($whereSQL .= GetIDSQL($vars['fid'], 't.fid')); if ($vars['call'] == "forum") { } else { switch ($vars['orderby']) { case "view": $orderSQL = " ORDER BY t.views {$by}"; break; case "hot": $orderSQL = " ORDER BY t.replies {$by}"; break; case "lastpost": $orderSQL = " ORDER BY t.lastpost {$by}"; break; case "new": $orderSQL = " ORDER BY t.dateline {$by}"; break; case "rand": $orderSQL = " ORDER BY rand() {$by}"; break; default: $orderSQL = " ORDER BY t.tid {$by}"; } $whereSQL = "f.fid=t.fid"; $vars['reply'] && ($whereSQL .= " AND t.closed NOT LIKE 'moved|%' AND t.replies !=0"); $vars['tid'] && ($whereSQL .= GetIDSQL($vars['tid'], 't.tid')); $vars['tid!'] && ($whereSQL .= GetIDSQL($vars['tid!'], 't.tid', 'not')); $offset = 0; if ($vars['page']) { $total = $DB->getValue("SELECT count(*) FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL}"); $iCMS->assign("total", $total); $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav"; $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0; $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:list'), 'url' => $iCMS->url, 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle)); } if ($vars['cache'] == false || $vars['page']) { $iCMS->config['iscache'] = false; $rs = ''; } else { $cacheName = 'bbs/' . md5($iCMS->config["bbs"]["type"] . $whereSQL . $orderSQL); $rs = $iCMS->cache($cacheName); } if (empty($rs)) { $rs = $DB->getArray("SELECT t.*, f.name FROM {$threads},{$forums} WHERE {$whereSQL} {$orderSQL} LIMIT {$offset},{$maxperpage}"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $rs[$i]['forumname'] = $rs[$i]['name']; if ($rs[$i]['highlight']) { $string = sprintf('%02d', $rs[$i]['highlight']); $stylestr = sprintf('%03b', $string[0]); $rs[$i]['highlight'] = 'style="'; $rs[$i]['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : ''; $rs[$i]['highlight'] .= $stylestr[1] ? 'font-style: italic;' : ''; $rs[$i]['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : ''; $rs[$i]['highlight'] .= $string[1] ? 'color: ' . $colorarray[$string[1]] : ''; $rs[$i]['highlight'] .= '"'; } else { $rs[$i]['highlight'] = ''; } if ($iCMS->config["bbs"]["htmifopen"]) { $rs[$i]["url"] = $bbsurl . "/thread-{$rs[$i]['tid']}-1-1.html"; $rs[$i]["forumurl"] = $bbsurl . "/forum-{$rs[$i]['fid']}-1.html"; } else { $rs[$i]["url"] = $bbsurl . "/viewthread.php?tid={$rs[$i]['tid']}"; $rs[$i]["forumurl"] = $bbsurl . "/forumdisplay.php?fid={$rs[$i]['fid']}"; } } $iCMS->cache(false)->addcache($cacheName, $rs, $cacheTime); } } } } return $rs; }
function doCreateArticle() { $mtime = microtime(); $mtime = explode(' ', $mtime); $time_start = $mtime[1] + $mtime[0]; $speed = $this->PG('speed', 25); //生成速度 $fids = $this->PG('fid'); $startid = (int) $this->PG('startid'); $endid = (int) $this->PG('endid'); $starttime = $this->PG('starttime'); $endtime = $this->PG('endtime'); $atime = isset($_GET['atime']) ? $_GET['atime'] : 0; $attime = isset($_GET['attime']) ? $_GET['attime'] : 0; $totle = isset($_GET['totle']) ? $_GET['totle'] : 0; $loop = isset($_GET['loop']) ? $_GET['loop'] : 1; $i = isset($_GET['i']) ? $_GET['i'] : 0; if ($fids) { empty($fids) && javascript::alert("请选择版块"); is_array($fids) && ($fids = implode(",", $fids)); $isA = $this->isAll(); if (strstr($fids, 'all')) { $forum = new forum(); $fids = substr($forum->fid(), 0, -1); _header(__SELF__ . '?mo=html&do=CreateArticle&fid=' . $fids . $isA); } else { $cArray = explode(',', $fids); $cCount = count($cArray); $k = isset($_GET['k']) ? $_GET['k'] : 0; $fidsql = strstr($fids, ',') ? " fid in ({$fids})" : " fid='{$fids}'"; empty($totle) && ($totle = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` WHERE {$fidsql} and `status`='1'")); $offset = ($loop - 1) * $speed; $totlepg = ceil($totle / $speed); $loop = min($totlepg, $loop); $offset < 0 && ($offset = 0); $rs = iCMS_DB::getArray("SELECT id FROM #iCMS@__article WHERE {$fidsql} and `status`='1' order by id DESC LIMIT {$offset} , {$speed}"); $max = count($rs); if ($loop <= $totlepg && $max > 0) { $msg = "共有文章{$totle}篇,已生成{$offset}篇,完成" . round($offset / $totle, 3) * 100 . "%<br />预计用时" . $this->Hms(ceil($totlepg * $atime / 60) * 60) . ",生成{$speed}篇用时" . $this->Hms($atime) . ",已用时" . $this->Hms($attime) . "<br />"; for ($j = 0; $j < $max; $j++) { $Art = iHtml::Article($rs[$j]['id']); $msg .= "文章ID:" . $rs[$j]['id'] . "生成…<span style='color:green;'>" . ($Art == false ? '×' : '√') . "</span> "; if ($j % 2) { $msg .= '<br />'; } } $mtime = microtime(); $mtime = explode(' ', $mtime); $time_end = $mtime[1] + $mtime[0]; $atime = round($time_end - $time_start, 2); javascript::dialog($msg, 'src:' . __SELF__ . '?mo=html&do=CreateArticle&speed=' . $speed . '&atime=' . $atime . '&attime=' . ($atime + $attime) . '&fid=' . $fids . '&totle=' . $totle . '&loop=' . ($loop + 1) . '&i=' . $j . $isA, 'ok', 0); } else { $msg = "共生成文章{$totle}篇,用时" . $this->Hms($attime) . "<br />文章更新完毕!"; $isA && javascript::dialog($msg . "<br />开始生成列表...", 'src:' . __SELF__ . '?mo=html&do=CreateForum&fid=all&all=true'); javascript::dialog($msg); } } } elseif ($startid && $endid) { $startid > $endid && !isset($_GET['g']) && javascript::alert("开始ID不能大于结束ID"); empty($totle) && ($totle = $endid - $startid + 1); empty($i) && ($i = $startid); $tloop = ceil($totle / $speed); if ($loop <= $tloop) { $max = $i + $speed > $endid ? $endid : $i + $speed; for ($j = $i; $j <= $max; $j++) { $Art = iHtml::Article($j); $msg .= "文章ID:" . $j . "生成…<span style='color:green;'>" . ($Art == false ? '×' : '√') . "</span> "; if (($j - 1) % 2) { $msg .= '<br />'; } } javascript::dialog($msg, 'src:' . __SELF__ . '?mo=html&do=CreateArticle&startid=' . $startid . '&endid=' . $endid . '&g&loop=' . ($loop + 1) . '&i=' . $j, 'ok', 0); } else { javascript::dialog("文章更新完毕!"); } } elseif ($starttime) { $s = strtotime($starttime); $e = empty($endtime) ? time() + 86400 : strtotime($endtime); empty($totle) && ($totle = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` WHERE `pubdate`>='{$s}' and `pubdate`<='{$e}' and `status`='1'")); $offset = ($loop - 1) * $speed; $totlepg = ceil($totle / $speed); $loop = min($totlepg, $loop); $offset < 0 && ($offset = 0); $rs = iCMS_DB::getArray("SELECT id FROM #iCMS@__article WHERE `pubdate`>='{$s}' and `pubdate`<='{$e}' and `status`='1' order by id DESC LIMIT {$offset} , {$speed}"); $max = count($rs); if ($loop <= $totlepg && $max > 0) { $msg = "共有文章{$totle}篇,已生成{$offset}篇,完成" . round($offset / $totle, 3) * 100 . "%<br />预计用时" . $this->Hms(ceil($totlepg * $atime / 60) * 60) . ",生成{$speed}篇用时" . $this->Hms($atime) . ",已用时" . $this->Hms($attime) . "<br />"; for ($j = 0; $j < $max; $j++) { $Art = iHtml::Article($rs[$j]['id']); $msg .= "文章ID:" . $rs[$j]['id'] . "生成…<span style='color:green;'>" . ($Art == false ? '×' : '√') . "</span> "; if ($j % 2) { $msg .= '<br />'; } } $mtime = microtime(); $mtime = explode(' ', $mtime); $time_end = $mtime[1] + $mtime[0]; $atime = round($time_end - $time_start, 2); javascript::dialog($msg, 'src:' . __SELF__ . '?mo=html&do=CreateArticle&speed=' . $speed . '&atime=' . $atime . '&attime=' . ($atime + $attime) . '&starttime=' . $starttime . '&endtime=' . $endtime . '&totle=' . $totle . '&loop=' . ($loop + 1) . '&i=' . $j, 'ok', 0); } else { javascript::dialog("共生成文章{$totle}篇,用时" . $this->Hms($attime) . "<br />文章更新完毕!"); } } else { javascript::dialog("请选择方式"); } }
function domanage() { $mid = $_GET['mid']; $model = model::data($mid); $table = $model['tbn']; $forum = new forum(); $fid = (int) $_GET['fid']; $sql = " where `userid`='" . (int) member::$uId . "' AND `postype`='0'"; //postype: [0:用户][1:管理员] status:[0:草稿][1:正常][2:回收] $_GET['keyword'] && ($sql .= " AND CONCAT(title,tags) REGEXP '{$_GET['keyword']}'"); $_GET['status'] != "" && ($sql .= " AND `status`='" . $_GET['status'] . "'"); if ($fid) { $fidIN = $forum->fid($fid) . $fid; if (isset($_GET['sub']) && strstr($fidIN, ',')) { $sql .= " AND fid IN(" . $fidIN . ")"; } else { $sql .= " AND fid ='{$fid}'"; } //$sql.=" OR `vlink` REGEXP '[[:<:]]".preg_quote($fid, '/')."[[:>:]]')"; } // $_GET['starttime'] && $sql.=" and `pubdate`>='".strtotime($_GET['starttime'])."'"; // $_GET['endtime'] && $sql.=" and `pubdate`<='".strtotime($_GET['endtime'])."'"; isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']); $orderby = $_GET['orderby'] ? $_GET['orderby'] : "id DESC"; $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__{$table}` {$sql}") : (int) $_GET['rowNum']; page($total, $maxperpage, "条记录"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__{$table}` {$sql} order by {$orderby} LIMIT {$this->firstcount} , {$maxperpage}"); $_count = count($rs); include $this->tpl(); }
function domy() { $sql[] = " `userId`='" . member::$uId . "'"; $_GET['keyword'] && ($sql[] = "CONCAT(title,contents) REGEXP '{$_GET['keyword']}'"); $mid = (int) $_GET['mid']; $mid && ($sql[] = " `mId`='" . $mid . "'"); isset($_GET['status']) && $_GET['status'] != '' && ($sql[] = " `status`='" . $_GET['status'] . "'"); $where = $sql ? ' where ' . implode(' AND ', (array) $sql) : ''; $maxperpage = (int) $_GET['perpage'] > 0 ? $_GET['perpage'] : 20; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__comment` {$where}") : (int) $_GET['rowNum']; page($total, $maxperpage, "条评论"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__comment` {$where} order by id DESC LIMIT {$this->firstcount},{$maxperpage}"); $_count = count($rs); include $this->tpl(); }
function del($tags) { global $iCMS; $tagArray = explode(",", $tags); foreach ($tagArray as $k => $v) { if (iCMS_DB::getValue("SELECT `count` FROM `#iCMS@__tags` WHERE `name`='{$v}'") == "1") { iCMS_DB::query("DELETE FROM `#iCMS@__tags` WHERE `name`='{$v}'"); $iCMS->iCache->delete($iCMS->getTagKey($v)); } else { iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count`=count-1 ,`updatetime`='" . time() . "' WHERE `name`='{$v}'"); } } iCMS_DB::query("DELETE FROM `#iCMS@__taglist` WHERE indexId='{$id}' AND modelId='0'"); return '标签更新…<span style=\'color:green;\'>√</span><br />'; }
function iCMS_plugins_statistics($vars, &$iCMS) { $a = iCMS_DB::getRow("SELECT count(*) AS c,SUM(hits) AS h FROM #iCMS@__article WHERE status='1'"); $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__comment WHERE `status`='1'"); echo "<p>日志: <b>{$a->c}</b> 篇</p><p>评论: <b>{$c}</b> 个</p><p>访问: <b>{$a->h}</b> 次</p>"; }
</td> <td width="80">文章总数</td> <td><?php echo $a; ?> </td> </tr> <tr> <td>侍审内容</td> <td><?php echo iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__article WHERE status='0'"); ?> </td> <td>评论总数</td> <td><?php echo iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__comment"); ?> </td> </tr> <tr> <td>数据库大小</td> <td><?php echo FS::sizeUnit($datasize + $indexsize); ?> </td> <td>文章数据大小</td> <td><?php echo FS::sizeUnit($content_datasize); ?> </td> </tr>
function comment($indexId = 0, $mId = 0, $sortId = 0) { if (empty($indexId)) { $this->iList($sortId, false); $this->iPrint("iTPL", "comment.sort"); } else { $total = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__comment` WHERE `mid`='{$mId}' and `sortId`='{$sortId}' and `status`='1' AND indexId='{$indexId}'"); $this->assign("total", $total); if (empty($mId)) { $this->Show($indexId, 1, false); $this->iPrint("iTPL", "comment.article"); } else { $this->content($mId, $indexId, false); $this->iPrint("iTPL", "comment.content"); } } }
function vlinkDiff($Nsid, $Osid, $indexId = "0") { global $iCMS; $N = explode(',', $Nsid); $O = explode(',', $Osid); $diff = array_diff_values($N, $O); foreach ((array) $diff['+'] as $sortid) { //新增 if (!iCMS_DB::getValue("SELECT indexId FROM `#iCMS@__vlink` WHERE `indexId`='{$indexId}' and `sortId`='{$sortid}' and `modelId`='0'")) { iCMS_DB::query("INSERT INTO `#iCMS@__vlink` (`indexId`, `sortId`, `modelId` ) VALUES ('{$indexId}', '{$sortid}', '0' )"); } } foreach ((array) $diff['-'] as $sortid) { //减少 iCMS_DB::query("DELETE FROM `#iCMS@__vlink` WHERE `indexId`='{$indexId}' and `sortId`='{$sortid}' and `modelId`='0'"); } }
function doarticle() { $forum = new forum(); $callback = $_GET['callback']; $fid = (int) $_GET['fid']; $sql = " where "; $sql .= $_GET['type'] == 'draft' ? "`status` ='0'" : "`status` ='1'"; $sql .= $act == 'user' ? " AND `postype`='0'" : " AND `postype`='1'"; $_GET['keywords'] && ($sql .= " AND CONCAT(title,keywords,description) REGEXP '{$_GET['keywords']}'"); $fid = member::CP($fid) ? $fid : "0"; if ($fid) { if (isset($_GET['sub'])) { $sql .= " AND ( fid IN(" . $forum->fid($fid) . $fid . ")"; } else { $sql .= " AND ( fid ='{$fid}'"; } $sql .= " OR `vlink` REGEXP '[[:<:]]" . preg_quote($fid, '/') . "[[:>:]]')"; } else { member::$cpower && ($sql .= " AND fid IN(" . implode(',', member::$cpower) . ")"); } isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']); $maxperpage = 8; $total = $page == 1 || empty($_GET['rowNum']) ? iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` {$sql}") : (int) $_GET['rowNum']; page($total, $maxperpage, "篇文章"); $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__article`{$sql} order by id DESC LIMIT {$this->firstcount} , {$maxperpage}"); $_count = count($rs); include admincp::tpl(); }
function dosave() { include_once iPATH . 'include/tag.class.php'; $id = $_POST['id']; $mid = $_POST['mid']; $FArray = model::field($mid); $model = model::data($mid); $content = array(); if ($_POST['content']) { foreach ($_POST['content'] as $field => $value) { if (model::isDefField($field)) { switch ($field) { case "userid": $value = intval($value); break; case "fid": $value = $fid = intval($value); empty($value) && javascript::alert('请选择所属栏目'); break; case "orderNum": $value = _int($value); break; case "top": $value = _int($value); break; case "title": $value = dhtmlspecialchars($value); empty($value) && javascript::alert('标题不能为空!'); break; case "editor": $value = dhtmlspecialchars($value); break; case "tags": $value = iTAG::split(dhtmlspecialchars($value), true); break; case "type": $value = intval($value); break; case "vlink": $value = implode(',', $value); break; case "postype": $value = empty($value) ? intval($value) : "1"; break; case "pubdate": $value = _strtotime($value); break; case "clink": $value = dhtmlspecialchars($value); if ($value) { $clinklen = strlen($value); for ($i = 0; $i < $clinklen; $i++) { !preg_match("/[a-zA-Z0-9_\\-~" . preg_quote($this->iCMS->config['CLsplit'], '/') . "]/", $value[$i]) && javascript::alert('自定链接只能由英文字母、数字或_-~组成(不支持中文)'); } } break; } } elseif ($F = $FArray[$field]) { switch ($F['type']) { case "number": $value = intval($value); break; case "calendar": $value = _strtotime($value); break; case in_array($F['type'], array('text', 'textarea', 'radio', 'select', 'email', 'url', 'image', 'upload')): $value = dhtmlspecialchars($value); break; case in_array($F['type'], array('checkbox', 'multiple')): $value = implode(',', $value); break; case 'editor': $this->iCMS->config['autoformat'] && ($value = autoformat($value)); break; default: $value = dhtmlspecialchars($value); } } WordFilter($value) && javascript::alert($field . '字段包含被系统屏蔽的字符,请返回重新填写。'); $content[$field] = $value; $PF[] = $field; } } if (empty($content['clink'])) { include iPATH . 'include/cn.class.php'; $content['clink'] = CN::pinyin($content['title'], $this->iCMS->config['CLsplit']); } $table = model::tbn($_POST['table']); $MF = explode(',', $model['field']); $diff = array_diff_values($PF, $MF); if ($diff['-']) { foreach ($diff['-'] as $field) { $content[$field] = ''; } } //缺少的字段 填认空值 $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=content&do=manage' : $_POST['REFERER']); $forum = new forum(); if (empty($id)) { empty($content['userid']) && ($content['userid'] = member::$uId); $content['hits'] = $content['good'] = $content['bad'] = $content['comments'] = 0; $content['status'] = "1"; $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `clink` ='" . $content['clink'] . "'"); if ($this->iCMS->config['repeatitle']) { iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `title` = '{$title}'") && alert('该标题内容已经存在!请检查是否重复'); $checkCL && javascript::alert('该自定链接已经存在!请另选一个'); } else { $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1)); } iCMS_DB::insert($table, $content); $id = iCMS_DB::$insert_id; model::upload($table, $id, $title); iTAG::add($content['tags'], $content['userid'], $id, $forum->rootid($fid), $mid); $vlink = empty($content['vlink']) ? $fid : $content['vlink'] . ',' . $fid; vlinkDiff($vlink, '', $id, $mid); if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $content['status']) { include iPATH . 'include/iHtml.class.php'; iHtml::content($id, $mid, $table); iHtml::forum($fid, 1, 0, 1); } iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 "); // $moreaction=array( // array("text"=>"编辑该内容","url"=>__SELF__."?do=content&operation=add&table=".$table."&mid=".$mid."&id=".$id), // array("text"=>"继续添加内容","url"=>__SELF__."?do=content&operation=add&table=".$table."&mid=".$mid."&cid=".$cid), // array("text"=>"查看该内容","url"=>$iCMS->iurl('content',array('mId'=>$mid,'id'=>$id,'link'=>$clink,'pubdate'=>$pubdate,'cid'=>$cid,'dir'=>$catalog->catalog[$cid]['dir'],'domain'=>$catalog->catalog[$cid]['domain'],'htmlext'=>$catalog->catalog[$cid]['htmlext']))->href,"o"=>'target="_blank"'), // array("text"=>"查看网站首页","url"=>"../index.php","o"=>'target="_blank"') // ); javascript::dialog("添加完成!", 'url:' . __SELF__ . "?mo=content&do=manage&table=" . $table . "&mid=" . $mid); } else { $checkCL = iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__{$table}` where `clink` ='{$clink}' AND `id` !='{$id}'"); if ($this->iCMS->config['repeatitle']) { $checkCL && alert('该自定链接已经存在!请另选一个'); } else { $checkCL && ($clink .= $this->iCMS->config['CLsplit'] . random(6, 1)); } $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__{$table}` where `id` ='{$id}'"); iTAG::diff($content['tags'], member::$uId, $art->tags, $id, $forum->rootid($fid)); iCMS_DB::update($table, $content, array('id' => $id)); model::upload($table, $id, $title); $vlink = empty($content['vlink']) ? $fid : $content['vlink'] . ',' . $fid; vlinkDiff($vlink, $art->vlink, $id); if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) { include iPATH . 'include/iHtml.class.php'; iHtml::content($id, $mid, $table); iHtml::forum($fid, 1, 0, 1); } if ($art->fid != $fid) { iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 "); iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 "); } javascript::dialog('编辑完成!<br />3秒后返回项目列表', 'url:' . $SELFURL); } }
function doSave() { $id = (int) $_POST['id']; $name = dhtmlspecialchars($_POST['name']); $table = dhtmlspecialchars($_POST['table']); $description = dhtmlspecialchars($_POST['desc']); $show = (int) $_POST['show']; $position = $_POST['position']; $position2 = $_POST['pos']; $form = dhtmlspecialchars($_POST['form']); $binding = isset($_POST['binding']) ? 1 : 0; empty($name) && javascript::alert('模块名称不能为空!'); empty($table) && $binding && javascript::alert('模块名不能为空!'); if (!$binding && empty($id)) { if (empty($table)) { include iPATH . 'include/cn.class.php'; $table = CN::pinyin($name); } } !preg_match("/[a-zA-Z]/", $table[0]) && javascript::alert('模型表名只能以英文字母开头'); !preg_match("/[a-zA-Z0-9_\\-~]/", $table) && javascript::alert('模型表名只能由英文字母或数字组成'); //model::isSysTable($table) && javascript::alert('您所填写的模块表名是系统表!请重新填写.'); if ($id) { iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}' and `id`!='{$id}'") && javascript::alert('该模块已经存在!请检查是否重复'); iCMS_DB::query("UPDATE `#iCMS@__model` SET `name` = '{$name}', `table` = '{$table}', `binding` = '{$binding}', `description` = '{$description}', `show` = '{$show}', `position` = '{$position}', `position2` = '{$position2}', `form` = '{$form}' WHERE `id` = '{$id}';"); if (!$binding) { $oTable = iCMS_DB::getValue("SELECT `table` FROM `#iCMS@__model` where `id` ='{$id}'"); if ($oTable != $table) { iCMS_DB::query("RENAME TABLE `#iCMS@__" . model::tbn($oTable) . "` TO `#iCMS@__" . model::tbn($table) . "`"); } } } else { iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__model` where `table` = '{$table}'") && javascript::alert('该模块已经存在!请检查是否重复'); $field = $binding ? '' : model::$defaultField; iCMS_DB::query("INSERT INTO `#iCMS@__model`(`name`, `table`, `field`, `binding`, `description`,`show`, `position`,`position2`,`form`, `addtime`)VALUES ('{$name}', '{$table}','{$field}', '{$binding}', '{$description}','{$show}', '{$position}','{$position2}','{$form}', '" . time() . "');"); $id = iCMS_DB::$insert_id; if (!$binding) { //创建模块基础表 $tableSQL = "CREATE TABLE `#iCMS@__" . model::tbn($table) . "` (\n\t\t\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t `fid` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `orderNum` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t `title` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t `clink` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t `editor` varchar(200) NOT NULL DEFAULT '',\n\t\t\t\t\t `userid` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `tags` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t `pubdate` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `hits` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `comments` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `good` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `bad` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `vlink` varchar(255) NOT NULL DEFAULT '',\n\t\t\t\t\t `type` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t `top` smallint(6) NOT NULL DEFAULT '0',\n\t\t\t\t\t `postype` tinyint(1) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t\t `status` tinyint(1) unsigned NOT NULL DEFAULT '1',\n\t\t\t\t\t PRIMARY KEY (`id`),\n\t\t\t\t\t KEY `pubdate` (`pubdate`),\n\t\t\t\t\t KEY `comment` (`comments`),\n\t\t\t\t\t KEY `hit` (`hits`),\n\t\t\t\t\t KEY `order` (`orderNum`),\n\t\t\t\t\t KEY `sortid` (`fid`,`id`),\n\t\t\t\t\t KEY `topord` (`top`,`orderNum`),\n\t\t\t\t\t KEY `userid` (`userid`),\n\t\t\t\t\t KEY `postype` (`postype`,`id`),\n\t\t\t\t\t KEY `status` (`status`,`postype`,`id`)\n\t\t\t\t\t ) ENGINE=MyISAM DEFAULT CHARSET=" . DB_CHARSET; iCMS_DB::query($tableSQL); } } model::cache(); $moreaction = array(array("text" => "下一步添加字段", "url" => __SELF__ . "?mo=models&do=addfield&id=" . $id), array("text" => "返回模块列表", "url" => __SELF__ . "?mo=models&do=manage")); javascript::dialog('模块' . ($id ? '编辑' : '添加') . '完成!<br />模块基础建表完成...<br />10秒后返回模块列表', "url:" . __SELF__ . "?mo=models&do=manage", $moreaction, 10); }