예제 #1
0
function server_update_points($server)
{
    global $no_ranking_clusters;
    mysql_select_db(dbname($server));
    file_put('data/calc-stat.dat', 'Berechnung von Server $server ...');
    ignore_user_abort(0);
    $clusters = array();
    // Alle Datensätze zurcksetzen,
    // damit es bei herrenlosen PCs keine falschen Anzeigen gibt:
    #db_query('UPDATE pcs SET owner_name=\'\', owner_points=0, owner_cluster=0, owner_cluster_code=\'\';');
    $current = 0;
    $u_result = db_query('SELECT * FROM users');
    $total = mysql_num_rows($u_result);
    while ($user = mysql_fetch_assoc($u_result)) {
        $current++;
        $upoints = 0;
        if ($current % 100 == 0) {
            file_put('data/calc-stat.dat', 'Berechnung von Server ' . $server . ' ... ' . $current . ' / ' . $total);
        }
        $pc_result = db_query('SELECT * FROM pcs WHERE owner=\'' . mysql_escape_string($user['id']) . '\';');
        $pc_cnt = mysql_num_rows($pc_result);
        while ($pc = mysql_fetch_assoc($pc_result)) {
            processupgrades($pc);
            $pcpoints = getpcpoints($pc, 'bydata');
            db_query('UPDATE pcs SET points=\'' . mysql_escape_string($pcpoints) . '\' WHERE id=\'' . mysql_escape_string($pc['id']) . '\';');
            $upoints += $pcpoints;
        }
        #reset($pcs);
        #foreach($pcs As $pcid):
        #$sql='UPDATE pcs SET owner_points=$upoints,owner_name=\''.mysql_escape_string($user['name']).'\' ';
        #$cluster=getcluster($user['cluster']);
        #if($cluster!==false) {
        #  $sql.=',owner_cluster='.mysql_escape_string($cluster['id']).', owner_cluster_code=\''.mysql_escape_string($cluster['code']).'\' ';
        #}
        #$sql.='WHERE id=\''.mysql_escape_string($pcid).'\'';
        #db_query($sql);
        #endforeach;
        $c = $user['cluster'];
        if ($c != '' && $c != 0) {
            #$r=db_query('SELECT id FROM clusters WHERE id=\''.mysql_escape_string($c).'\' LIMIT 1');
            #if(mysql_num_rows($r)>0) {
            $clusters['c' . $c]['points'] += $upoints;
            $clusters['c' . $c]['members'] += 1;
            $clusters['c' . $c]['pcs'] += $pc_cnt;
            #}
        }
        if (is_noranKINGuser($user['id']) == false && $user['id'] != 6249 && $user['id'] != 19061) {
            $rank[$user['id'] . ';' . $user['name'] . ';' . $user['cluster']] = $upoints;
        } else {
            db_query('UPDATE users SET points=\'' . mysql_escape_string($upoints) . '\',rank=\'0\' WHERE id=\'' . mysql_escape_string($user['id']) . '\';');
        }
    }
    #$pcinfo=gettableinfo('pcs',dbname($server));
    #file_put('data/_server'.$server.'/pc-count.dat', $pcinfo['Rows']);
    file_put('data/_server' . $server . '/user-count.dat', mysql_num_rows($u_result));
    ignore_user_abort(0);
    file_put('data/calc-stat.dat', 'Berechnung von Server ' . $server . ' ... Berechnung abgeschlossen: Schreiben in DB ...');
    arsort($rank);
    db_query('TRUNCATE TABLE rank_users');
    # Tabelle leeren
    #$platz=0;
    while (list($dat, $points) = each($rank)) {
        #$platz++;
        $dat = explode(';', $dat);
        $dat[2] = (int) $dat[2];
        db_query('INSERT INTO rank_users VALUES(0, ' . mysql_escape_string($dat[0]) . ', \'' . mysql_escape_string($dat[1]) . '\', ' . mysql_escape_string($points) . ', ' . mysql_escape_string($dat[2]) . ');');
        db_query('UPDATE users SET points=' . mysql_escape_string($points) . ', rank=' . mysql_insert_id() . ' WHERE id=' . mysql_escape_string($dat[0]) . ' LIMIT 1;');
    }
    #file_put('data/_server'.$server.'/rank-user-count.dat', count($rank));
    db_query('TRUNCATE TABLE rank_clusters');
    # Tabelle leeren
    unset($b);
    settype($b, 'array');
    while (list($bez, $val) = each($clusters)) {
        $b[$bez] = $clusters[$bez]['points'];
    }
    arsort($b);
    unset($c);
    settype($c, 'array');
    while (list($bez, $val) = each($b)) {
        $c[$bez]['points'] = $val;
        $c[$bez]['pcs'] = $clusters[$bez]['pcs'];
        $c[$bez]['members'] = $clusters[$bez]['members'];
    }
    while (list($bez, $dat) = each($c)) {
        $bez = substr($bez, 1);
        $av_p = round($dat['points'] / $dat['members'], 2);
        $av_pcs = round($dat['pcs'] / $dat['members'], 2);
        // SUCCESS RATE CALCULATION START
        $cluster = getcluster($bez);
        $total = $cluster['srate_total_cnt'];
        $scnt = $cluster['srate_success_cnt'];
        $ncnt = $cluster['srate_noticed_cnt'];
        if ($total > 0) {
            $psucceeded = $scnt * 100 / $total;
            $pnoticed = $ncnt * 100 / $total;
            // Erfolg ist gut und zählt 75%
            // Bemerkt ist schlecht (deshalb 100-$pnoticed) und zählt 25%
            $srate = $psucceeded * 0.75 + (100 - $pnoticed) * 0.25;
        } else {
            $srate = 0;
        }
        // SUCCESS RATE CALCULATION END
        if ($bez != $no_ranking_clusters) {
            db_query('INSERT INTO rank_clusters VALUES(0,\'' . mysql_escape_string($bez) . '\',\'' . mysql_escape_string($dat['members']) . '\',\'' . mysql_escape_string($dat['points']) . '\',\'' . mysql_escape_string($av_p) . '\',\'' . mysql_escape_string($dat['pcs']) . '\',\'' . mysql_escape_string($av_pcs) . '\',\'' . mysql_escape_string($srate) . '\');');
        }
        db_query('UPDATE clusters SET points=\'' . mysql_escape_string($dat['points']) . '\',rank=\'' . mysql_insert_id() . '\' WHERE id=\'' . mysql_escape_string($bez) . '\' LIMIT 1;');
    }
    file_put('data/calc-stat.dat', 'Gleich fertig!!!');
    cleardir('data/_server' . $server . '/usrimgs');
}
예제 #2
0
    setcookie('htnLoginData');
    badsession('Deine IP ist nicht dieser Session-ID zugeordnet!<br />Benutz die \'erweitertes LogIn\'-Funktion auf der Startseite.');
}
/*if($usr['bigacc']!='yes' && (time()-1*60*60)>$usr['login_time'] ) {
  $sid='';
  @unlink($sidfile);
  simple_message('Du warst jetzt eine Stunde eingeloggt. Um Platz f&uuml;r andere Spieler zu machen, wurdest du automatisch ausgeloggt.','warning');
  exit;
}*/
if ($FILE_REQUIRES_PC == true) {
    $pc = @mysql_fetch_assoc(db_query('SELECT * FROM pcs WHERE id=\'' . mysql_escape_string($pcid) . '\' LIMIT 1'));
    if ($pc['owner'] != $usrid) {
        badsession('Das ist nicht dein PC!');
    }
}
if ($usr['stat'] > 100 && is_noranKINGuser($usrid) == false) {
    $usr['stat'] = 0;
}
$STYLESHEET = $usr['stylesheet'];
if ($usr['liu'] > $usr['lic']) {
    $unread = (int) @mysql_num_rows(db_query('SELECT mail FROM mails WHERE user=\'' . mysql_escape_string($usrid) . '\' AND box=\'in\' AND xread=\'no\';'));
    $unread += (int) @mysql_num_rows(db_query('SELECT msg FROM sysmsgs WHERE user=\'' . mysql_escape_string($usrid) . '\' AND xread=\'no\';'));
    $usr['newmail'] = $unread;
    db_query('UPDATE users SET newmail=\'' . mysql_escape_string($unread) . '\' WHERE id=\'' . mysql_escape_string($usrid) . '\';');
    db_query('UPDATE users SET lic=\'' . time() . '\' WHERE id=\'' . mysql_escape_string($usrid) . '\';');
}
// Der gefährliche Wurm wird von hier aus gestartet!
$modulo = time() % 60;
if (file_exists('data/worm.txt') === true && ($modulo == 0 || $modulo == 30)) {
    include 'worm.php';
}