optimize climber points update (work really fast now)

This commit is contained in:
yi12345
2013-05-14 00:40:10 +03:00
parent 9dffb208e3
commit 544de58737
4 changed files with 154 additions and 39 deletions
+24 -3
View File
@@ -19,11 +19,11 @@ class MYSQL_DB {
}
function register($username, $password, $email, $tribe, $act) {
$time = time();
$time = time();
$timep = time() + PROTECTION;
if(strtotime(START_TIME) > time()){
$time = strtotime(START_TIME);
$timep = (strtotime(START_TIME) + PROTECTION);
}
$timep = ($time + PROTECTION);
$q = "INSERT INTO " . TB_PREFIX . "users (username,password,access,email,timestamp,tribe,act,protect,lastupdate,regtime) VALUES ('$username', '$password', " . USER . ", '$email', $time, $tribe, '$act', $timep, $time, $time)";
if(mysql_query($q, $this->connection)) {
return mysql_insert_id($this->connection);
@@ -1161,6 +1161,27 @@ class MYSQL_DB {
mysql_query($q, $this->connection);
return mysql_insert_id($this->connection);
}
function procAllyPop($aid) {
$ally = $this->getAlliance($aid);
$memberlist = $this->getAllMember($ally['id']);
$oldrank = 0;
foreach($memberlist as $member) {
$oldrank += $this->getVSumField($member['id'],"pop");
}
if($ally['oldrank'] != $oldrank){
if($ally['oldrank'] < $oldrank) {
$totalpoints = $oldrank - $ally['oldrank'];
$this->addclimberrankpopAlly($ally['id'], $totalpoints);
$this->updateoldrankAlly($ally['id'], $oldrank);
} else
if($ally['oldrank'] > $oldrank) {
$totalpoints = $ally['oldrank'] - $oldrank;
$this->removeclimberrankpopAlly($ally['id'], $totalpoints);
$this->updateoldrankAlly($ally['id'], $oldrank);
}
}
}
/*****************************************
Function to insert an alliance new