function upload_stats($subreddit, $thing_id) { global $db; print "Generating stats...\n"; $users = sqlCount("SELECT COUNT(*) AS count FROM users"); $teams = sqlCount("SELECT COUNT(DISTINCT teams.id) AS count FROM users LEFT JOIN teams WHERE users.team=teams.id"); $countries = sqlCount("SELECT COUNT(DISTINCT teams.country) AS count FROM users LEFT JOIN teams WHERE users.team=teams.id"); $timestamp = date('Y-m-d'); $text = "LAST UPDATED: {$timestamp}\n\n"; $text .= "*There are currently {$users} users supporting {$teams} teams from {$countries} countries.*\n\n"; $text .= build_stats_table('Team', 'Top 100 Teams', "SELECT * FROM teams ORDER BY count DESC", 100) . "\n\n"; $text .= build_stats_table('Country', 'Top 30 Countries', "SELECT countries.name AS name, COUNT(countries.name) AS count FROM countries LEFT JOIN teams ON countries.code=teams.country LEFT JOIN users ON users.team=teams.id GROUP BY countries.name ORDER BY count DESC", 30) . "\n\n"; print "Posting stats...\n"; reddit_editusertext($subreddit, $thing_id, $text); print "Stats generated.\n"; }
<?php include "../function.php"; $url = "?page="; $page = isset($_REQUEST["page"]) ? intval($_REQUEST["page"]) : 1; $pagesize = 20; $sql = "select t.param_key, t.param_value, t.id from " . $mysqlConfig["db_perfix"] . "param t order by t.id desc"; //获取总数 $totalCount = sqlCount($sql, "", "", "t.id"); $pageCount = ceil($totalCount / $pagesize); $limit = " limit " . ($page - 1) * $pagesize . " , " . $pagesize; $rs = sqlArray($sql . $limit); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php //导入meta数据及js库 echo $systemHead["meta"] . $systemHead["title"] . CSS_BASE . JS_JQUERY . JS_DIALOG . JS_BASE . JS_COMMON . KINDEDITOR . LIB_LIGERUI; ?> <style> body{ background:#FFF} .grid tr{ height:30px; border-bottom:1px #999 dotted} .grid th{ text-align:center; background:#F2F2F2; font-weight:bold; border-right:1px #999 dotted } .grid td a{text-decoration:none} .grid td{ border-right: 1px #999 dotted } .l-table-edit {}
/** * 登录 * @return String 后台地址 */ public function loginIn() { $uid = isset($_REQUEST["uid"]) ? trim($_REQUEST["uid"]) : ""; if (empty($uid)) { $this->addActionError("loginIn", "用户名为空"); return $this->ERROR; } $pwd = isset($_REQUEST["pwd"]) ? $_REQUEST["pwd"] : ""; if (empty($uid)) { parent::addActionError("loginIn", "密码为空"); return $this->ERROR; } $sql = "select * from " . $this->mysqlConfig["db_perfix"] . "user where uid = '{$uid}' limit 1"; if (sqlCount($sql) == 0) { $this->addActionError("loginIn", "没有找到此用户"); return $this->ERROR; } //获取一行数据 $rs = sqlRow($sql); if ($rs["pwd"] != md5($pwd)) { error("密码错误", "alertGoBack"); } //存入SESSION $_SESSION["user_arr"] = array("uid" => $rs["uid"], "id" => $rs["id"], "nid" => $rs["nid"], "isAdmin" => $rs["isAdmin"] == 1 ? true : false); //return ($_SESSION["user_arr"]["isAdmin"] ? "admin/index.php" : "user/index.php"); return parent::SUCCESS; }