/* ***** LOGIN ***** */ include "accounts.php"; include "check_session.php"; /*GS* Enable GET for logins, to let search bots in if ( $username == "" && isset( $_POST ) ) { $login_username = $_POST["login_username"]; $login_password = $_POST["login_password"]; */ if ( $username == "" && (isset( $_POST ) || isset( $_GET )) ) { if ( $_GET["guest"] == "guest" ) { $login_username = "guest"; $login_password = "guest"; } else { $login_username = $_POST["login_username"]; $login_password = $_POST["login_password"]; } /*GS -END- */ if ( !empty($login_username) || !empty($login_password) ) { $result = "ok"; if ( empty($login_username) ) $result = "Username is missing!"; if ( empty($login_password) ) $result = "Password is missing!"; if ( !isset($passwords[$login_username]) ) $result = "Invalid username or password!"; else if ( $passwords[$login_username] != $login_password ) $result = "Invalid username or password!"; if ( $result == "ok" ) { $_SESSION["username"] = $login_username; if ( $admins[$login_username] == "yes" ) $_SESSION["is_admin"] = true; else $_SESSION["is_admin"] = false; $_SESSION["cat"] = "my"; $_SESSION["filter"] = ":::"; $_SESSION["gamefile"] = "main"; $_SESSION["theme"] = "wcg"; $_SESSION["noteskey"] = crypt($login_password,"noteskey"); $_SESSION["posts_blocked"] = 0; $username = $login_username; /*GS* User logged in, add to login log*/ $logfile = fopen( "occ-data/logs/logins.".date("Ym"), "a" ); fwrite( $logfile, str_pad($username, 12, " ", STR_PAD_BOTH)." | " .str_pad($_SERVER['REMOTE_ADDR'].":".$_SERVER['REMOTE_PORT'], 21, " ", STR_PAD_BOTH)." | " .date("Y/m/d H:i:s l\n") ); fclose( $logfile ); /*GS*/ } if ( $result != "ok" ) $errmsg = $result; } } include "misc.php"; /* read first two lines of file and return as info * starting date * last move * white player * black player * moves * user's turn? */ function getQuickInfo( $folder, $gamefile ) { global $username, $res_games; $info = array(); $hfile = fopen( "$folder/$gamefile", "r" ); $aux = explode( " ", trim(fgets( $hfile, 128 )) ); $info[0] = $gamefile; $info[1] = printDate($aux[0],$aux[1],$aux[2],$aux[3],$aux[4]); $info[2] = printDate($aux[5],$aux[6],$aux[7],$aux[8],$aux[9]); $timestamp=mktime($aux[8],$aux[9],0,$aux[6],$aux[7],$aux[5]); $aux = explode( " ", trim(fgets( $hfile, 128 )) ); $info[3] = $aux[0]; $info[4] = $aux[1]; $info[5] = $aux[2]; $info[6] = 0; /* indicator is set as long as game is not archived. then it is always off */ if ( $folder == $res_games ) if ( ($aux[3] == "w" && $username==$info[3]) || ($aux[3] == "b" && $username==$info[4]) ) $info[6] = 1; $info[7]=$timestamp; /* timestamp of last move */ fclose( $hfile ); return $info; } function cmpLMTo($a,$b) { if ( $a[7]==$b[7] ) return 0; return ($a[7] < $b[7]) ? -1 : 1; } function cmpLMTr($a,$b) { if ( $a[7]==$b[7] ) return 0; return ($a[7] < $b[7]) ? 1 : -1; } function selectGames( $filter, $oldest_first ) { /* format of file name: yyyymmddhhmmss-white-black- */ global $username, $user_restr, $res_games, $res_archive; $aux = explode( ":", $filter ); $s_loc = $aux[0]; $s_ply = $aux[1]; $s_clr = $aux[2]; $s_opp = $aux[3]; if ( $s_loc == "games" ) $s_loc = $res_games; else $s_loc = $res_archive; $games = array(); $i = 0; $hdir = opendir( $s_loc ); while ( $entry = readdir( $hdir ) ) { if ( $entry == "." || $entry == ".." ) continue; /* player selected but game does not feature the name */ if ( !empty( $s_ply ) ) if ( strpos($entry,"-$s_ply-") === false ) continue; /* opponent selected but game does not feature the name */ if ( !empty( $s_opp ) ) if ( strpos($entry,"-$s_opp-") === false ) continue; /* color of player */ if ( !empty( $s_clr ) ) { $aux = explode( "-", $entry ); if ( $s_clr=="w" && $s_ply != $aux[1] ) continue; if ( $s_clr=="b" && $s_ply != $aux[2] ) continue; } $games[$i++] = getQuickInfo( $s_loc, $entry ); } closedir( $hdir ); if ( count( $games ) > 0 ) { if ( $oldest_first ) usort($games,"cmpLMTo"); /*last move timestamp*/ else usort($games,"cmpLMTr"); /*most recent move timestamp*/ } $games[count($games)] = $s_loc; return $games; } ?>
|
/*GS* No Break!
*/ ?> ![]() /*GS* -START- Added by Gokhan San - Psycho Image */?> ![]() /*GS* -END- */?> if ( !empty($errmsg) ) { ?> =$errmsg?> } ?> /*GS* Reformat of login window
/*GS* -START- Added by Gokhan San - Guest User */?> Login as Guest /*GS* -END- */?> /*GS* -END- Login reformat */?> |
|
|