/* Login/main page */
include 'session.php';
include 'render.php';
include 'io.php';
/* Set message to be displayed on login screen for general information of users. */
$releaseinfo='';
/* ---------- Login ---------- */
$uid=$_SESSION['uid'];
if (empty($uid) && isset($_POST)) {
$uid=$_POST['uid'];
$pwd=$_POST['pwd'];
$storedpwd=ioLoadUserPassword($uid);
if (!empty($uid) || !empty($pwd)) {
$result='ok';
if (empty($uid))
$result='Username is missing!';
else if (empty($pwd))
$result='Password is missing!';
else if ($storedpwd==null || $storedpwd!=$pwd)
$result='Invalid username or password!';
if ($result=='ok') {
$_SESSION['uid']=$uid;
$_SESSION['filter_name']='Open Games';
$_SESSION['filter_loc']='opengames';
$_SESSION['filter_plyr']=$uid;
$_SESSION['filter_clr']=null;
$_SESSION['filter_opp']=null;
$_SESSION['allow_newgame']=1;
$_SESSION['theme']=ioLoadUserTheme($uid);
$theme=$_SESSION['theme'];
$_SESSION['noteskey']=crypt($pwd,'noteskey');
ioUpdateLoginHistory($uid);
} else {
$uid=null;
$errmsg=$result;
}
}
}
/* ---------- Login page ---------- */
if (empty($uid)) {
$theme='default';
renderPageBegin(null,null,null,null);
if (!empty($errmsg)) {
echo ''.$errmsg.'
';
echo 'Lost your password?
';
}
echo '
'; echo ''; echo '(Cookies must be enabled to login.)'; echo ' |
'.$releaseinfo.'
'; renderPageEnd(null); exit; } /* ---------- Main page ---------- */ /* Render page */ renderPageBegin('OCC - Overview',null,array( 'My Games'=>'index.php?mygames=1', 'Search'=>'search.php', 'Rankings'=>'rankings.php', 'Help'=>'help.php', 'Logout'=>'logout.php'), null); /* Show login info + stats */ $stats=ioLoadUserStats($uid); $gamecount=$stats['wins']+$stats['draws']+$stats['losses']; echo 'Logged in as: '.$uid.' | '; echo ' | '.$gamecount.' games total, '; echo $stats['wins'].' wins, '.$stats['draws'].' draws, '; echo $stats['losses'].' losses'; echo ' |
'.count($list).' '.$_SESSION['filter_name'].'
'; if (count($list)>0) { echo ''; echo ' | White | '; echo 'Black | '; echo 'Moves | '; echo 'Starting Date | '; echo 'Last Move On | '; echo '|||
'; if ($info['curstate']=='w' || $info['curstate']=='-') echo ' | '.$info['white'].' | '; else echo ''.$info['white'].' | '; if ($info['curstate']=='b' || $info['curstate']=='-') echo ''.$info['black'].' | '; else echo ''.$info['black'].' | '; echo ''.$info['curmove'].' | '; echo ''.$startdate.' | '; echo ''.$lastdate.' | '; echo ''; echo 'View |
[ New Game ]
'; renderPageEnd(null); ?>