function ranking_to_file($file = 'ranking/week.json', $period = 'WEEK', $plength = 1) { if (!is_dir('ranking')) { mkdir('ranking'); } $fh = fopen($file, 'w') or die('can\'t open file'); $players = ranking($period, $plength); fwrite($fh, json_encode($players)); fclose($fh); }
require_once 'log.php'; require_once 'match.php'; require_once 'profile.php'; $action = $_REQUEST['action']; switch ($action) { case 'players': echo json_encode(players()); break; case 'update': echo json_encode(updateStats(time(), $_REQUEST['team1'], $_REQUEST['team2'], $_REQUEST['scores'])); break; case 'reset': resetStats(); break; case 'ranking': echo json_encode(ranking()); break; case 'history': echo json_encode(history()); break; case 'log': echo json_encode(gameLog()); break; case 'match': if (isset($_REQUEST['team2'])) { echo json_encode(match($_REQUEST['team1'], $_REQUEST['team2'])); } else { echo json_encode(bestMatch($_REQUEST['team1'])); } break; case 'profile':
} mysql_select_db("spaceregentsportal") or die("! Could not select spaceregentsportal\n"); $sth1 = mysql_query("DELETE FROM top_users"); if (!sth1) { echo "COULD NOT DELETE TOP USERS! -> " . mysql_error(); } foreach ($top_users as $user) { $sth = mysql_query("INSERT INTO top_users (name, score) VALUES ('" . $user["name"] . "','" . $user["score"] . "')"); if (!sth) { echo "COULD NOT INSERT TOP USERS! -> " . mysql_error(); } } mysql_select_db("spaceregents") or die("! Could not reselect spaceregents\n"); } echo "Step2\n"; echo "=====================\n"; echo "Connect!\n"; connect(); echo "Production delay\n"; combat_production_delay(); echo "Scanrangecalculation\n"; scanrange_calculation(); echo "Ranking\n"; ranking(); echo "Fog of war\n"; fog_of_war(); echo "INCREASING WEEK\n"; $sth = mysql_query("update timeinfo set week=week+1"); // PORTAL zeugs echo "Writing Score to Portal DB\n"; score_to_portal();
<html> <head> <title>Pascal 4fun | Lý thuyết</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/main.css"> </head> <body> <header> <a href='index.php' class='Link'></a> </header> <div id="content"> <div id="ranking"> <h2>Bảng xếp hạng</h2> <?php //ini_set('display_errors', 'On'); require 'libs/functions.php'; echo ranking(); ?> </div> </div> </body> </html>
public function login($username, $password) { include_once 'controllers/vendor/PasswordHash.php'; $user = str_replace(array("'", "-", ";", "#"), array(" ", " ", " ", " "), $username); $user_pass = $this->rip_tags($password); $pass_q = "SELECT id, password, email FROM users WHERE username = :username ORDER BY date DESC LIMIT 0,1"; $correct_pass = $this->pdo->prepare($pass_q); $correct_pass->bindValue(':username', $user, \PDO::PARAM_STR); $correct_pass->execute(); if ($correct_pass->rowCount() > 0) { $pass = $correct_pass->fetch(); $prepared_password = '******' . $pass['password']; $compare = validate_password($user_pass, $prepared_password); if ($compare == 1) { //The password is good, the user can log in if (isset($_SESSION)) { //if there is already a session session_unset(); session_destroy(); $lifetime = 3600; session_set_cookie_params($lifetime); session_start(); } else { //if there's no session $lifetime = 3600; session_set_cookie_params($lifetime); session_start(); } //else end $_SESSION['user'] = true; $_SESSION['admin'] = true; $_SESSION['user_id'] = $pass['id']; //get rank $rank_q = "SELECT rank FROM users WHERE id = :id"; $rank = $this->pdo->prepare($rank_q); $rank->bindValue(':id', $pass['id'], \PDO::PARAM_INT); $rank->execute(); if ($rank->rowCount() > 0) { include_once 'controllers/rank.php'; while ($uRank = $rank->fetch()) { if ($uRank['rank'] == 1) { $_SESSION['developer'] = true; } //if uRank = 1 (dev :D) $permission = ranking($uRank['rank']); if (isset($permission)) { foreach ($permission as $perm) { switch ($perm) { case "super": $_SESSION['super_admin'] = true; break; case "agenda": $_SESSION['agenda_admin'] = true; break; case "sponsors": $_SESSION['sponsors_admin'] = true; break; case "speakers": $_SESSION['speakers_admin'] = true; break; case "mediapartners": $_SESSION['mediapartners_admin'] = true; break; case "blogsquad": $_SESSION['blogsquad_admin'] = true; break; } //switch perm } } //if isset permission } //While uRank fetch } //if rank row count > 0 $out = '<p class="LoginResponse"><i class="fa fa-check"></i> Logged in. You will be redirected to the administration page.</p>'; //// Options for login //// basic $page = $_SERVER['PHP_SELF']; $sec = "1"; /* $sponsors = array(7,5,8,11); $speakers = array(); $mediapartners = array(10); $blogsquad = array(9); if(in_array($pass['id'],$sponsors) == true) { $page = "http://london.hrtecheurope.com/admin/sponsors"; }elseif (in_array($pass['id'],$speakers) == true) { $page = "http://london.hrtecheurope.com/admin/speakers"; }elseif (in_array($pass['id'],$mediapartners) == true) { $page = "http://london.hrtecheurope.com/admin/mediapartners"; }elseif (in_array($pass['id'],$blogsquad) == true) { $page = "http://london.hrtecheurope.com/admin/blogsquad"; } //if - else if chain ends /* if(in_array($pass['id'],$sponsors) == true) { $page = "final_new/admin/sponsors"; }elseif (in_array($pass['id'],$speakers) == true) { $page = "final_new/admin/speakers"; }elseif (in_array($pass['id'],$mediapartners) == true) { $page = "final_new/admin/mediapartners"; }elseif (in_array($pass['id'],$blogsquad) == true) { $page = "final_new/admin/blogsquad"; } */ header("Refresh:" . $sec . "; url=" . $page); return $out; } else { //If the passwords don't mach if (!isset($_SESSION)) { //if there's no session session_start(); $_SESSION['failed_login'] = 1; } else { //if there's no session else and end if (isset($_SESSION['failed_login'])) { //if this is NOT the first login attempt $_SESSION['failed_login']++; } else { //if this is the first login attepmt $_SESSION['failed_login'] = 1; } //first attempt else end } //if there's no session else end if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] > 5) { //if there's more than 5 attempts $out = '<p class="LoginResponse"><i class="fa fa-times"></i> Incorrect username or password</p>'; //for now we do nothing, but later we can add chapcha or something shit :D } else { //else $out = '<p class="LoginResponse"><i class="fa fa-times"></i> Incorrect username or password</p>'; } //more then five else ends return $out; } //passwords don't mach else ends } else { //personal num rows if end (If we don't even find the user in the db) $out = '<p class="LoginResponse"><i class="fa fa-times"></i> No such user</p>'; return $out; } //username not found else ends }