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 iCMS_link($vars, &$iCMS) { $limit = isset($vars['row']) ? (int) $vars['row'] : "100"; $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; switch ($vars['type']) { case "text": $sql[] = " `logo`='' "; break; case "logo": $sql[] = " `logo`!='' "; break; } isset($vars['sortid']) && ($sql[] = " sortid='" . $vars['sortid'] . "'"); $sql && ($where = 'WHERE ' . implode(' AND ', $sql)); $iscache = true; if ($vars['cache'] == false || isset($vars['page'])) { $iscache = false; $rs = ''; } else { $cacheName = 'links/' . md5($sql); $rs = $iCMS->getCache($cacheName); } if (empty($rs)) { $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__links`{$where} ORDER BY orderNum ASC,id DESC LIMIT 0 , {$limit}"); $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime); } return $rs; }
function doSave() { $uid = (int) $_POST['uid']; $info = array(); if ($_POST['pwd'] || $_POST['pwd1'] || $_POST['pwd2']) { $pwd = md5(trim($_POST['pwd'])); $pwd1 = md5(trim($_POST['pwd1'])); $pwd2 = md5(trim($_POST['pwd2'])); if (!$_POST['pwd'] || !$_POST['pwd1'] || !$_POST['pwd2']) { javascript::alert("修改密码.原密码,新密码,确认密码不能为空"); } $pwd != $user['password'] && javascript::alert("原密码错误!"); $pwd1 != $pwd2 && javascript::alert("新密码与确认密码不一致!"); iCMS_DB::query("UPDATE `#iCMS@__members` SET `password` = '{$pwd2}' WHERE `uid` ='{$uid}' LIMIT 1"); } // $username=dhtmlspecialchars($_POST['name']); $_POST['email'] && !eregi("^([_\\.0-9a-z-]+)@([0-9a-z][0-9a-z-]+)\\.([a-z]{2,6})\$", $_POST['email']) && javascript::alert("E-mail格式错误!!"); $email = stripslashes($_POST['email']); $gender = intval($_POST['gender']); $info['nickname'] = dhtmlspecialchars(stripslashes($_POST['nickname'])); cstrlen($info['nickname']) > 12 && javascript::alert("昵称长度大于12"); $info['icq'] = intval($_POST['icq']); $info['home'] = dhtmlspecialchars(stripslashes($_POST['home'])); $info['year'] = intval($_POST['year']); $info['month'] = intval($_POST['month']); $info['day'] = intval($_POST['day']); $info['from'] = dhtmlspecialchars(stripslashes($_POST['from'])); $info['signature'] = dhtmlspecialchars(stripslashes($_POST['signature'])); $user['info'] = $info; iCMS_DB::query("UPDATE `#iCMS@__members` SET `info` = '" . addslashes(serialize($user['info'])) . "',`email`='{$email}',`gender`='{$gender}' WHERE `uid` ='{$uid}' LIMIT 1"); javascript::dialog('用户编辑完成!', 'url:' . __SELF__ . '?mo=user&do=manage'); }
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 iCMS_DB($vars, &$iCMS) { if (empty($vars['sql'])) { echo $iCMS->language('SQL:empty'); return false; } else { if (preg_match("/^\\s*(insert|delete|update|replace) /i", $vars['sql'])) { echo $iCMS->language('SQL:IDUR'); return false; } if (strstr($vars['sql'], 'members')) { echo $iCMS->language('SQL:members'); return false; } if (strstr($vars['sql'], 'admin')) { echo $iCMS->language('SQL:admin'); return false; } $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1; $iscache = true; if ($vars['cache'] == false || isset($vars['page'])) { $iscache = false; $rs = ''; } else { $cacheName = 'DB/' . md5($vars['sql']); $rs = $iCMS->getCache($cacheName); } if (empty($rs)) { $rs = iCMS_DB::getArray($vars['sql']); $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime); } return $rs; } }
function doDefault() { $_configRs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`"); foreach ($_configRs as $_C) { $configRs[$_C['name']] = $_C['value']; } include admincp::tpl("setting"); }
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 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 table($id) { if ($id) { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__model` where id='{$id}'", ARRAY_A); if (!isSysTable($rs['table'])) { $rs['table'] = $rs['table'] . '_content'; } return $rs; } else { return false; } }
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 doEdit() { foreach ($_POST['name'] as $id => $value) { iCMS_DB::query("update `#iCMS@__group` set `name`='{$value}',`order`='" . $_POST['order'][$id] . "' where `gid`='{$id}'"); } if ($_POST['addnewname']) { iCMS_DB::query("INSERT INTO `#iCMS@__group`(`gid`,`name`,`order`,`power`,`cpower`,`type`) VALUES (NULL,'" . $_POST['addnewname'] . "','" . $_POST['addneworder'] . "','','','" . $_POST['type'] . "')"); javascript::dialog('添加完成!', 'url:1'); exit; } javascript::dialog('更新完成!', 'url:1'); //_Header(); }
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 doSave() { $sortid = (int) $_POST['sortid']; $name = dhtmlspecialchars($_POST['name']); $url = dhtmlspecialchars($_POST['url']); $desc = dhtmlspecialchars($_POST['description']); $logo = dhtmlspecialchars($_POST['logo']); $orderNum = intval($_POST['orderNum']); empty($name) && javascript::alert('网站名称不能为空!'); empty($url) && javascript::alert('网站URL不能为空!'); strpos($url, 'http://') === false && ($url = 'http://' . $url); iCMS_DB::query("INSERT INTO `#iCMS@__links` (`sortid`,`name`,`logo`,`desc`,`url`,`orderNum`) VALUES ('{$sortid}','{$name}','{$logo}','{$desc}','{$url}','{$orderNum}')"); javascript::dialog("添加完成!", 'url:' . __SELF__ . '?mo=link'); }
function dosetting() { $gender = intval($_POST['gender']); $nickname = dhtmlspecialchars($_POST['nickname']); $info['icq'] = intval($_POST['icq']); $info['home'] = dhtmlspecialchars(stripslashes($_POST['home'])); $info['year'] = intval($_POST['year']); $info['month'] = intval($_POST['month']); $info['day'] = intval($_POST['day']); $info['from'] = dhtmlspecialchars(stripslashes($_POST['from'])); $info['signature'] = dhtmlspecialchars(stripslashes($_POST['signature'])); iCMS_DB::query("UPDATE `#iCMS@__members` SET `info` = '" . addslashes(serialize($info)) . "',`nickname`='{$nickname}',`gender`='{$gender}' WHERE `uid` ='" . member::$uId . "' LIMIT 1"); javascript::dialog("资料修改完成!"); }
function __construct($id = '', $status = "1", $attr = "1") { global $iCMS; $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__forum` ORDER BY `orderNum` , `fid` ASC", ARRAY_A); //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); //exit; foreach ((array) $rs as $row) { $this->forum[$row['fid']] = $this->_array[$row['rootid']][$row['fid']] = $this->parent[$row['fid']][$row['rootid']] = $row; $this->cacheRootId[$row['rootid']][$row['fid']] = $row['fid']; $this->cacheParent[$row['fid']] = $row['rootid']; } }
function UA($act, $cid) { global $iCMS; $cookietime = $iCMS->config['diggtime']; $ajax = intval($_GET['ajax']); $cTime = time() - get_cookie($cid . '_up') > $cookietime && time() - get_cookie($cid . '_against') > $cookietime ? true : false; if ($cTime) { set_cookie($cid . '_' . $act, time(), $cookietime); if ($cid && iCMS_DB::query("UPDATE `#iCMS@__comment` SET `{$act}` = {$act}+1 WHERE `id` ='{$cid}'")) { $ajax ? jsonp("{state:'1'}", $_GET['callback']) : _Header($iCMS->config['publicURL'] . "/comment.php?indexId=" . $id); } } else { $ajax ? jsonp("{state:'0',text:'" . $iCMS->language('digged') . "' }", $_GET['callback']) : alert($iCMS->language('digged')); } }
/** * @package iCMS * @copyright 2007-2010, iDreamSoft * @license http://www.idreamsoft.cn iDreamSoft * @author coolmoo <*****@*****.**> */ function FormArray($mId, $F, $rs = array(), $isUser = false) { //字段定义 $rst = iCMS_DB::getArray("SELECT * FROM `#iCMS@__field` where (mid='{$mId}' OR mid='0')"); foreach ($rst as $key => $a) { $FA[$a['field']] = $a; } //遍历传入字段数组 if ($F) { foreach ($F as $key => $field) { $HA[$key] = form($FA[$field], $rs, $isUser); } } return $HA; }
function checklogin($a, $p, $Ret = false) { $ip = getip(); if (empty($a) && empty($p)) { $auth = get_cookie('auth'); list($a, $p) = explode('#=iCMS[' . $ip . ']=#', authcode($auth, 'DECODE')); return self::checkadmin($a, $p, $Ret); } else { $crs = self::checkadmin($a, $p, $Ret); set_cookie('auth', authcode($a . '#=iCMS[' . $ip . ']=#' . $p, 'ENCODE')); iCMS_DB::query("UPDATE `#iCMS@__admin` SET `lastip`='" . $ip . "',`lastlogintime`='" . time() . "',`logintimes`=logintimes+1 WHERE `uid`='" . self::$uId . "'"); !$Ret && javascript::dialog("登陆成功!", 'url:' . __SELF__); //UI::redirect('登陆成功, 请稍候......', __SELF__); return $crs; } }
function dosave() { $author = dhtmlspecialchars($_POST['author']); $email = dhtmlspecialchars($_POST['email']); $url = dhtmlspecialchars($_POST['url']); $content = dhtmlspecialchars($_POST['content']); empty($author) && exit('昵称不能为空!'); empty($content) && exit('留言内容不能为空!'); WordFilter($author) && exit('昵称包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($url) && exit('您的网址包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($content) && exit('留言内容包含被系统屏蔽的字符,请返回重新填写。'); !preg_match("/^([\\w\\.-]+)@([a-zA-Z0-9-]+)(\\.[a-zA-Z\\.]+)\$/i", $email) && exit('邮箱格式错误!'); strpos($url, 'http://') === false && ($url = 'http://' . $url); iCMS_DB::query("INSERT INTO `#iCMS@__plugins_message` (`author`,`email`,`url`,`content`,`reply`,`addtime`,`ip`,`status`) VALUES ('{$author}','{$email}','{$url}','{$content}','','" . time() . "','" . getip() . "','0')"); exit('1'); }
function iCMS_plugins_archives($vars, &$iCMS) { $rs = iCMS_DB::getArray("SELECT A.pubdate FROM `#iCMS@__article` AS A,#iCMS@__forum AS F WHERE A.status='1' AND A.fid=F.fid AND F.status='1' ORDER BY pubdate DESC"); $_count = count($rs); for ($i = 0; $i < $_count; $i++) { $article[] = get_date($rs[$i]['pubdate'], 'Y-m'); } $arr = array_count_values($article); $i = 0; foreach ($arr as $key => $val) { list($y, $m) = explode('-', $key); $archive[$i]['url'] = $y . '_' . $m; $archive[$i]['date'] = "{$y}年{$m}月"; $archive[$i]['count'] = $val; $i++; } $iCMS->value('archive', $archive); $iCMS->output('archive', plugin::tpl('archives')); }
function dosetup($isSetup = 1) { $plugName = $_GET['name']; $plugins = $this->iCMS->getCache('system/plugins'); // $plugins[$plugName]=plugin::config($plugName,'config'); $plugins[$plugName]['isSetup'] = $plugins[$plugName]['status'] = $isSetup; $this->iCMS->setCache('system/plugins', $plugins, 0); $rs = plugin::config($plugName, 'admincp'); $plang = $this->iCMS->getCache('system/plugins.lang'); if ($rs['lang']) { foreach ($rs['lang'] as $key => $val) { if ($isSetup) { $plang[$key] = $val; } else { unset($plang[$key]); } } $this->iCMS->setCache('system/plugins.lang', $plang, 0); } $pmenu = $this->iCMS->getCache('system/plugins.menu'); if ($rs['menu']) { foreach ($rs['menu'] as $key => $val) { if ($isSetup) { $pmenu[$key] = $val; } else { unset($pmenu[$key]); } } $this->iCMS->setCache('system/plugins.menu', $pmenu, 0); } $data = plugin::sql($plugName, $isSetup ? 'install' : 'uninstall'); if ($data) { $sqlArray = explode(";", $data); foreach ($sqlArray as $sql) { $sql = trim($sql); $sql && iCMS_DB::query($sql); } } javascript::dialog($isSetup ? '安装完成!' : '卸载成功', 'url:1'); }
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() { $uid = (int) $_POST['uid']; $info = array(); if ($_POST['pwd1'] && $_POST['pwd2']) { $pwd1 = md5(trim($_POST['pwd1'])); $pwd2 = md5(trim($_POST['pwd2'])); (!$_POST['pwd1'] || !$_POST['pwd2']) && javascript::alert("新密码,确认密码不能为空"); $pwd1 != $pwd2 && javascript::alert("新密码与确认密码不一致!"); iCMS_DB::query("UPDATE `#iCMS@__members` SET `password` = '{$pwd2}' WHERE `uid` ='{$uid}' LIMIT 1"); } //$_POST['username']&&!preg_match("/^([_\.0-9a-z-]+)@([0-9a-z][0-9a-z-]+)\.([a-z]{2,6})$/i",$_POST['username'])&&javascript::alert("E-mail格式错误!!"); $gender = intval($_POST['gender']); $nickname = dhtmlspecialchars($_POST['nickname']); $info['icq'] = intval($_POST['icq']); $info['home'] = dhtmlspecialchars(stripslashes($_POST['home'])); $info['year'] = intval($_POST['year']); $info['month'] = intval($_POST['month']); $info['day'] = intval($_POST['day']); $info['from'] = dhtmlspecialchars(stripslashes($_POST['from'])); $info['signature'] = dhtmlspecialchars(stripslashes($_POST['signature'])); iCMS_DB::query("UPDATE `#iCMS@__members` SET `info` = '" . addslashes(serialize($info)) . "',`nickname`='{$nickname}',`gender`='{$gender}' WHERE `uid` ='{$uid}' LIMIT 1"); javascript::dialog('用户编辑完成!', 'url:' . __SELF__ . '?mo=user&do=manage'); }
function dotrash() { $id = (int) $_GET['id']; $mid = (int) $_GET['mid']; $table = model::tbn($_GET['table']); iCMS_DB::query("UPDATE `#iCMS@__{$table}` SET `status` = '2' WHERE `id` ='{$id}'"); javascript::dialog('此项目已经移动到回收站!', 'js:parent.$("#aid' . $id . '").remove();parent.iCMS.closeDialog();'); }
function bakindata($filename) { $sql = file($filename); $query = ''; $num = 0; foreach ($sql as $key => $value) { $value = trim($value); if (!$value || $value[0] == '#') { continue; } if (eregi("\\;\$", $value)) { $query .= $value; if (eregi("^CREATE", $query)) { $extra = substr(strrchr($query, ')'), 1); $tabtype = substr(strchr($extra, '='), 1); $tabtype = substr($tabtype, 0, strpos($tabtype, strpos($tabtype, ' ') ? ' ' : ';')); $query = str_replace($extra, '', $query); if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) { $extra = DB_CHARSET ? "ENGINE={$tabtype} DEFAULT CHARSET=" . DB_CHARSET . ";" : "ENGINE={$tabtype};"; } else { $extra = "TYPE={$tabtype};"; } $query .= $extra; } elseif (eregi("^INSERT", $query)) { $query = 'REPLACE ' . substr($query, 6); } iCMS_DB::query(str_replace('iCMS_', DB_PREFIX, $query)); $query = ''; } else { $query .= $value; } } }
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 { javascript::json(0, 'login:failed'); } } }
function CreateConfigFile() { global $iCMS; $tmp = iCMS_DB::getArray("SELECT * FROM `#iCMS@__config`"); $config_data = "<?php\n\t\$config=array(\n"; for ($i = 0; $i < count($tmp); $i++) { $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . $tmp[$i]['value'] . "\",\n"; } $config_data .= substr($_config, 0, -2); $config_data .= "\t\n);?>"; FS::write(iPATH . 'include/site.config.php', $config_data); }
</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 cQuote($id = 0, $i = 0) { global $iCMS; if ($id) { $i++; $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__comment` WHERE `id`='{$id}'"); $text = '<div class="quote">'; $i < 52 && $rs->quote && ($text .= cQuote($rs->quote, $i)); $text .= '<span class="floor">#' . ($rs->floor + 1) . '</span>'; // $text.='<span>----- 以下引用 <strong><em>'.$rs->username.'</em></strong> 于 '.get_date($rs->addtime,'Y-m-d H:i').' 的发言 -----</span><p>'.$rs->contents. '</p>'; // $text.='<span>'.$rs->username.'的原贴:</span><p>'.ubb($rs->contents). '</p>'; $text .= '<span>' . $rs->username . '的原贴:</span><p>' . str_replace("\r", '<br />', $rs->contents) . '</p>'; // $text.='<div class="comment-action"><span><a href=\'javascript:iCMS.digg("up",'.$rs->indexId.','.$rs->id.')\'>支持[+<span id="up_'.$rs->id.'">'.$rs->up.'</span>]</a></span><span><a href=\'javascript:iCMS.digg("down",'.$rs->indexId.','.$rs->id.')\'>反对[-<span id="down_'.$rs->id.'">'.$rs->down.'</span>]</a></span><span><a href=\'javascript:iCMS.quote('.$rs->id.','.$rs->floor.')\' id="quote'.$rs->id.'">回复</a> <a href=\'javascript:iCMS.unquote('.$rs->id.')\' id="unquote'.$rs->id.'" style="display:none;">取消回复</a></span></div>'; $text .= '</div>'; return $text; } }