0) {
$line = mysql_fetch_object($res);
IF (isset($_SESSION['s_serverurl']) && ($_SESSION['s_serverurl'] != $_SERVER['HTTP_HOST'].$path) ) {
echo "running backup...
";
backup_session();
}
// don't forget session_handler.inc.php!
$_SESSION['s_username'] = $line->username;
$_SESSION['s_userid'] = $line->id;
$_SESSION['s_ogame_playerid'] = $line->ogame_playerid;
$_SESSION['s_loggedin'] = true;
$_SESSION['s_stylepath'] = $line->stylepath;
$_SESSION['s_timezone_offset'] = $line->timezone_offset;
// websim data
$_SESSION['s_waffentech'] = (empty($line->waffentech)) ? 0 : $line->waffentech;
$_SESSION['s_schildtech'] = (empty($line->schildtech)) ? 0 : $line->schildtech;
$_SESSION['s_rpz'] = (empty($line->rpz)) ? 0 : $line->rpz;
$_SESSION['s_vbt'] = (empty($line->vbt)) ? 0 : $line->vbt;
$_SESSION['s_hra'] = (empty($line->hra)) ? 0 : $line->hra;
$_SESSION['s_impulse'] = (empty($line->impulse)) ? 0 : $line->impulse;
$_SESSION['s_serverurl'] = $_SERVER['HTTP_HOST'].$path;
$_SESSION['s_isadmin'] = ($line->is_admin =="true") ? true : false;
$_SESSION['s_cansearch'] = ($line->cansearch =="true") ? true : false;
$_SESSION['s_caninsert'] = ($line->caninsert =="true") ? true : false;
$_SESSION['s_statusview'] = ($line->statusview =="true") ? true : false;
$_SESSION['s_probeview'] = ($line->probeview =="true") ? true : false;
$_SESSION['s_userman'] = ($line->userman =="true") ? true : false;
$_SESSION['s_allyhistory'] = ($line->allyhistory =="true") ? true : false;
$_SESSION['s_diplomatic'] = ($line->diplomatic =="true") ? true : false;
$_SESSION['s_hits'] = 20;
$_SESSION['s_statspage'] = $line->statspage;
$loginfailure = false;
// personal links
$addinonal_links_lines = explode("\n",$line->links);
$_SESSION['s_additional_links'] = array();
foreach ($addinonal_links_lines as $link_line) {
$line_parts = explode(";",$link_line);
if (count($line_parts) == 2) {
if (trim($line_parts[1]) == "") {
array_push($_SESSION['s_additional_links'],array(trim($line_parts[0])));
} else {
if (substr($line_parts[1],0,7) != "http://" && substr($line_parts[1],0,8) != "https://") {
$line_parts[1] = "http://".$line_parts[1];
}
array_push($_SESSION['s_additional_links'],array(trim($line_parts[0]),trim($line_parts[1])));
}
}
}
if (count($_SESSION['s_additional_links']) == 0) {
array_push($_SESSION['s_additional_links'],array("Ogame","http://www.ogame.de"));
}
unset($addinonal_links_lines);
unset($line_parts);
unset($link_line);
// colors
$_SESSION['s_bb_coordinates'] = $line->bb_coordinates;
$_SESSION['s_bb_moon'] = $line->bb_moon;
$_SESSION['s_bb_debris'] = $line->bb_debris;
$_SESSION['s_bb_ally'] = $line->bb_ally;
$_SESSION['s_bb_allydetails'] = $line->bb_allydetails;
$_SESSION['s_bb_playername'] = $line->bb_playername;
$_SESSION['s_bb_banned'] = $line->bb_banned;
$_SESSION['s_bb_vacation'] = $line->bb_vacation;
$_SESSION['s_bb_noob'] = $line->bb_noob;
$_SESSION['s_bb_inactive'] = $line->bb_inactive;
$_SESSION['s_bb_longinactive'] = $line->bb_longinactive;
// global links - from admin account
if ($_SESSION['s_isadmin'] != true) {
$query = "SELECT * FROM $utablename WHERE is_admin='true'";
$res = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
$line = mysql_fetch_object($res);
$global_links_lines = explode("\n",$line->links);
$_SESSION['s_global_links'] = array();
foreach ($global_links_lines as $link_line) {
$line_parts = explode(";",$link_line);
if (count($line_parts) == 2) {
if (trim($line_parts[1]) == "") {
array_push($_SESSION['s_global_links'],array(trim($line_parts[0])));
} else {
if (substr($line_parts[1],0,7) != "http://" && substr($line_parts[1],0,8) != "https://") {
$line_parts[1] = "http://".$line_parts[1];
}
array_push($_SESSION['s_global_links'],array(trim($line_parts[0]),trim($line_parts[1])));
}
}
}
} // else - no amin account any more
}
}
if (!$loginfailure) {
$query = "UPDATE $utablename SET logins=logins+1, lastlogin=NOW() WHERE id='".$_SESSION['s_userid']."'";
$res = mysql_query($query) or die(mysql_error());
$query = "INSERT INTO $iptablename (userid,ip,logintime) VALUES ('".$_SESSION['s_userid']."','".$_SERVER['REMOTE_ADDR']."',NOW())";
$res = mysql_query($query) or die(mysql_error());
$query = "SELECT id FROM $iptablename WHERE userid='".$_SESSION['s_userid']."' ORDER BY logintime ASC";
$res = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($res) > 50) {
$number = mysql_num_rows($res);
$where = " id IN (";
$i = 0;
while ($line = mysql_fetch_object($res)) {
if ($i < ($number-50)) $where .= $line->id.",";
else break;
$i++;
}
$where = substr($where,0,strlen($where)-1).")";
$query = "DELETE FROM $iptablename WHERE ".$where;
$res = mysql_query($query) or die(mysql_error());
}
}
}
if (!isset($_SESSION['s_loggedin']) || $_SESSION['s_loggedin'] && $_SESSION['s_serverurl'] != $_SERVER['HTTP_HOST'].$path) { // Loginseite
?>