Date: 2009-12-20 Author: zhaoshunyao QQ: 240508015 */ define('CURSCRIPT', 'scorelist'); require './include/common.inc.php'; $web_path = './'; $stype = empty($_GET['stype']) ? 'all' : $_GET['stype']; $page = intval($_GET['page']); if ($page < 1) { $page = 1; } $pagerow = 25; switch ($stype) { case 'week': $lastweek = get_weeks() - 1; $query = $dblink->query("select uid from {$tablepre}score where week={$lastweek} group by uid"); $membercount = $dblink->num_rows($query); $pagecount = ceil($membercount / $pagerow); if ($page > $pagecount) { $page = 1; } $pagestart = ($page - 1) * $pagerow; $query = $dblink->query("select uid,sum(score) as newscore from {$tablepre}score where week={$lastweek} group by uid order by newscore desc limit {$pagestart},{$pagerow}"); $i = 0; while ($temp = $dblink->fetch_array($query)) { $temp['orderid'] = $i + 1; $query1 = $dblink->query("select username,gender,lastlogin from {$tablepre}member where uid={$temp['uid']}"); $temp1 = $dblink->fetch_array($query1); $temp1['lastlogin'] = date("Y-m-d", $temp1['lastlogin']); $score_list[$i] = array_merge($temp, $temp1);
function update_score($uid, $score, $m = '+') { global $dblink, $tablepre; $score = intval($score); $day = intval(date("Ymd")); $week = get_weeks(); $month = intval(date("Ym")); if ($m == '+') { $dblink->query("UPDATE {$tablepre}member SET allscore=allscore+{$score} WHERE uid={$uid}"); $query = $dblink->query("SELECT day FROM {$tablepre}score WHERE uid={$uid} AND day={$day}"); if ($dblink->num_rows($query)) { $dblink->query("UPDATE {$tablepre}score SET score=score+{$score} WHERE uid={$uid} AND day={$day}"); } else { $dblink->query("INSERT INTO {$tablepre}score SET uid='{$uid}',day='{$day}',week='{$week}',month='{$month}',score='{$score}'"); } } else { if ($m == '-') { $dblink->query("UPDATE {$tablepre}member SET allscore=allscore-{$score} WHERE uid={$uid}"); $query = $dblink->query("SELECT day FROM {$tablepre}score WHERE uid={$uid} AND day={$day}"); if ($dblink->num_rows($query)) { $dblink->query("UPDATE {$tablepre}score SET score=score-{$score} WHERE uid={$uid} AND day={$day}"); } else { $dblink->query("INSERT INTO {$tablepre}score SET uid='{$uid}',day='{$day}',week='{$week}',month='{$month}',score=0"); } } } }