Example #1
0
 public function Payment($id = 0, $status = 0)
 {
     $this->Payment = new Payment();
     // Try finding the payment
     $this->Payment->include_related("fixture", array("owner"))->where("id", $id)->get();
     // Make sure the payment exists
     if (!$this->Payment->exists()) {
         $this->json->error("Payment could not be found.");
     }
     // Make sure the payment has right status
     if (!in_array(strtolower($this->Payment->status), array("active"))) {
         $this->json->error("Payment has invalid status.");
     }
     // Make sure you are the owner of paid fixture
     if ($this->Payment->fixture_owner != Auth::Get("id")) {
         $this->json->error("Payment could not be found.");
     }
     // Make sure status is valid
     if (!in_array($status, array(0, 1))) {
         $this->json->error("Invalid payment status.");
     }
     // Set and save the status
     $this->Payment->paid = $status;
     $this->Payment->save();
     // Send success response
     $this->json->success();
 }
Example #2
0
 public function index()
 {
     $this->template->setData("SelectedTab", "Dashboard");
     if (Auth::Get("manager")) {
         // Get Next Game
         $this->NextGame = new Game_Block();
         $this->NextGame->include_related("fixture", array("id"))->include_related_count("account", "players_count", array("active" => 1))->where(array("fixtures.owner" => Auth::Get("id"), "game_blocks.time > " => time()))->limit(1)->order_by("game_blocks.time", "ASC")->get();
         // Get Total Owned Money
         $this->TotalOwned = $this->db->query("\tSELECT COALESCE(SUM(payments.amount), 0) AS TotalOwned\n\t\t\t\t\tFROM players_managers\n\t\t\t\t\tLEFT JOIN accounts ON accounts.id = players_managers.player_id\n\t\t\t\t\tLEFT JOIN payments ON players_managers.player_id = payments.account_id AND payments.paid = 0 AND payments.status = 'active'\n\t\t\t\t\tWHERE players_managers.manager_id = " . Auth::Get('id') . "\n\t\t\t\t")->result();
         // Count Connected Players
         $this->ConnectedPlayers = new Player_Manager();
         $this->ConnectedPlayers = $this->ConnectedPlayers->where(array("manager_id" => Auth::Get("id")))->count();
         // Get Confirmed Games
         $this->ConfirmedGames = new Game_Block();
         $this->ConfirmedGames->include_related("fixture", array("owner"))->where(array("fixtures.owner" => Auth::Get("id"), "game_blocks.time >=" => time()))->get_iterated();
         $this->load->view("dashboard/manager");
     } else {
         // Get Next Game Block
         $this->NextGame = new Account();
         $this->NextGame->where(array("accounts.id" => Auth::Get("id"), "game_blocks.time >" => time()))->include_related("game_block")->limit(1)->order_by("game_blocks.time", "ASC")->get();
         // Count connected players
         $this->ConnectedPlayers = $this->db->query("\n\t\t\t\t\tSELECT count(DISTINCT accounts_game_blocks.account_id) as ConnectedPlayers\n\t\t\t\t\tFROM fixtures\n\t\t\t\t\tLEFT JOIN game_blocks ON game_blocks.fixture_id = fixtures.id\n\t\t\t\t\tLEFT JOIN accounts_game_blocks ON accounts_game_blocks.game_block_id = game_blocks.id\n\t\t\t\t\tWHERE accounts_game_blocks.account_id != " . Auth::Get("id") . "\n\t\t\t\t")->result();
         $this->ConnectedPlayers = $this->ConnectedPlayers[0]->ConnectedPlayers;
         // Owned money to
         $this->OwnedTo = $this->db->query("SELECT COALESCE(SUM(payments.amount), 0) AS TotalOwned, accounts.first_name, accounts.last_name\n\t\t\t\tFROM payments\n\t\t\t\tLEFT JOIN fixtures ON fixtures.id = payments.fixture_id\n\t\t\t\tLEFT JOIN accounts ON accounts.id = fixtures.owner\n\t\t\t\tWHERE payments.paid = 0 AND payments.status = 'active' AND payments.account_id = " . Auth::Get('id') . "\n\t\t\t\tGROUP BY accounts.id\n\t\t\t\tORDER BY TotalOwned DESC\n\t\t\t\t")->result();
         // Confirmed Games
         $this->ConfirmedGames = new Account(Auth::Get("id"));
         if (!$this->ConfirmedGames->exists()) {
             exit("Your account could not be loaded.");
         }
         // Get Games
         $this->ConfirmedGames = $this->ConfirmedGames->game_block->where(array("time >=" => time()))->get_iterated();
         $this->load->view("dashboard/player");
     }
 }
Example #3
0
function ShowModifications(&$p, $db_table, $db_id)
{
    global $database;
    $m_mod = new Modification($database);
    $m_auth = new Auth($database);
    $mods = $m_mod->byTableID($db_table, $db_id);
    if (!false_or_null($mods)) {
        $data = array();
        foreach ($mods as $mod) {
            $user = $m_auth->Get($mod['r_Auth']);
            $what = '';
            $w = json_decode($mod['What'], true);
            foreach ($w as $dataset) {
                foreach ($dataset as $table => $change) {
                    $what .= $table . ' #' . $change['I'] . '\'s ' . $change['F'] . (isset($change['E']) ? ' » ' . $change['E'] : '');
                }
            }
            $data[] = array($user['username'], $what, $mod['Message'], human_datetime(intval($mod['Timestamp'])));
        }
        $table = new TableHelper(array('table' => "table wide", 'thead' => "tablehead", 'th' => "tablehead", 'td' => "tablecell", 'headings' => array('Who', 'What', ' ', 'When'), 'data' => $data));
        $p->HTML('<div class="formgroup">');
        $p->HTML('<h4>Recent Activity</h4>');
        $p->Table($table);
        $p->HTML('</div>');
    }
}
Example #4
0
 public static function RequireManager($JSON = false)
 {
     if (!Auth::Get("manager") && !$JSON) {
         redirect("accounts/login");
     }
     if (!Auth::Get("manager") && $JSON) {
         $CI->json->send(array("LoginRequired" => true));
     }
 }
Example #5
0
 public function LockedTo($lock)
 {
     if (false_or_null($lock)) {
         return FALSE;
     }
     global $database;
     $a_model = new Auth($database);
     $user = $a_model->Get($lock['r_Auth']);
     if (false_or_null($user)) {
         return FALSE;
     }
     return $user['username'];
 }
Example #6
0
 public function Get($id = 0)
 {
     // Load Fixture
     $this->Fixture = new Fixture($id);
     // Make sure it exists
     if (!$this->Fixture->exists()) {
         $this->json->error("Fixture could not be found.");
     }
     // Get Game Blocks
     $this->GameBlocks = array();
     foreach ($this->Fixture->game_block->order_by("time", "ASC")->get_iterated() as $GameBlock) {
         $this->GameBlocks[] = array("id" => $GameBlock->id, "time" => $GameBlock->time == 0 ? "Unknown" : date(TIME_FORMAT, $GameBlock->time), "day" => date("l", $GameBlock->time), "future" => $GameBlock->time > time() ? true : false);
     }
     // Send Back Response
     $this->json->send(array("success" => "OK", "location" => $this->Fixture->location, "type" => $this->Fixture->type, "pitch_cost" => $this->Fixture->pitch_cost, "player_cost" => $this->Fixture->player_cost, "payp_cost" => $this->Fixture->payp_cost, "blocks" => $this->Fixture->blocks, "address" => $this->Fixture->address, "location" => $this->Fixture->location, "directions" => $this->Fixture->directions, "postcode" => $this->Fixture->postcode, "is_manager" => $this->Fixture->owner == Auth::Get("id"), "GameBlocks" => $this->GameBlocks));
 }
Example #7
0
 public function Get()
 {
     // Require Login
     Auth::RequireLogin(true);
     if (Auth::Get("manager")) {
         // Get Next Game
         $this->NextGame = new Game_Block();
         $this->NextGame->include_related("fixture", array("id"))->include_related_count("account", "players_count", array("active" => 1))->where(array("fixtures.owner" => Auth::Get("id"), "game_blocks.time > " => time()))->limit(1)->order_by("game_blocks.time", "ASC")->get();
         // Count connected players
         $this->ConnectedPlayers = new Player_Manager();
         $this->ConnectedPlayers = $this->ConnectedPlayers->where(array("manager_id" => Auth::Get("id")))->count();
         // Get Next Game
         $NextGameTime = false;
         if ($this->NextGame->exists() && $this->NextGame->time) {
             $NextGameTime = date(TIME_FORMAT, $this->NextGame->time);
         }
         // Get Confirmed Games
         $this->ConfirmedGames = new Game_Block();
         $this->ConfirmedGames->include_related("fixture", array("owner", "id", "location"))->where(array("fixtures.owner" => Auth::Get("id"), "game_blocks.time >=" => time()))->get_iterated();
         $ConfirmedGames = array();
         foreach ($this->ConfirmedGames as $Game) {
             $ConfirmedGames[] = array("day" => date("l", $Game->time), "date" => date(TIME_FORMAT, $Game->time), "future" => $Game->time > time() ? true : false, "game_id" => $Game->id, "location" => $Game->fixture_location);
         }
         $this->json->send(array("success" => "OK", "ConnectedPlayers" => $this->ConnectedPlayers, "NextGame" => $NextGameTime, "ConfirmedGames" => $ConfirmedGames));
     } else {
         // Get Next Game Block
         $this->NextGame = new Account();
         $this->NextGame->game_block->where(array("accounts.id" => Auth::Get("id"), "game_blocks.time >" => time()))->limit(1)->order_by("game_blocks.time", "ASC")->get();
         // Count connected players
         $this->ConnectedPlayers = $this->db->query("\n\t\t\t\t\tSELECT count(DISTINCT accounts_game_blocks.account_id) as ConnectedPlayers\n\t\t\t\t\tFROM fixtures\n\t\t\t\t\tLEFT JOIN game_blocks ON game_blocks.fixture_id = fixtures.id\n\t\t\t\t\tLEFT JOIN accounts_game_blocks ON accounts_game_blocks.game_block_id = game_blocks.id\n\t\t\t\t\tWHERE accounts_game_blocks.account_id != " . Auth::Get("id") . "\n\t\t\t\t")->result();
         $this->ConnectedPlayers = $this->ConnectedPlayers[0]->ConnectedPlayers;
         // Get Next Game
         $NextGameTime = false;
         if ($this->NextGame->exists() && $this->NextGame->time) {
             $NextGameTime = date(TIME_FORMAT, $this->NextGame->time);
         }
         // Get Confirmed Games
         $this->ConfirmedGames = new Game_Block();
         $this->ConfirmedGames = $this->ConfirmedGames->where(array("time >=" => time()))->include_related("fixture", array("location", "id"))->get_iterated();
         $ConfirmedGames = array();
         foreach ($this->ConfirmedGames as $Game) {
             $ConfirmedGames = array("day" => date("l", $Game->time), "date" => date(TIME_FORMAT, $Game->time), "game_id" => $Game->id, "location" => $Game->fixture_location);
         }
         $this->json->send(array("success" => "OK", "ConnectedPlayers" => $this->ConnectedPlayers, "NextGame" => $NextGameTime, "ConfirmedGames" => $ConfirmedGames));
     }
 }
Example #8
0
 public function Refresh($session)
 {
     global $no_session_refresh;
     global $session_refreshed;
     if ($session_refreshed === FALSE) {
         if ($no_session_refresh === TRUE) {
         } else {
             $this->Set($session['ID'], array("last_refreshed" => $session['refreshed'], "refreshed" => strtotime('now'), "requests" => intval($session['requests']) + 1));
             global $database;
             $a_model = new Auth($database);
             $a = $a_model->Get($session['r_Auth']);
             cook("username", $a['username'], timeout);
             cook("session", $session['ID'], timeout);
         }
     }
     $session_refreshed = TRUE;
 }
Example #9
0
	
							<form action="<?php 
echo url("accounts/register");
?>
" method="post" id="login_form" class="form">
								
								<input type="hidden" name="tracking_code" value="<?php 
echo set_value("tracking_code", $this->code);
?>
" />
								
								<label for="form-name">First Name*</label>
					<div class="input-prepend">
					<span class="add-on"><i class="icon-user"></i></span>
					<?php 
echo form_input("first_name", set_value("first_name", Auth::Get("first_name")));
?>
					</div>
					
					<div class="clear_10"></div>
					
					<label for="form-lastname">Last Name*</label>
					<div class="input-prepend">
					<span class="add-on"><i class="icon-user"></i></span>
					<?php 
echo form_input("last_name", set_value("last_name"));
?>
					</div>
					
					<div class="clear_10"></div>
		
Example #10
0
$p->title = "Your Website";
$p->CSS("main.css");
$p->Jquery();
$getpost = getpost();
if (!isset($getpost['ID'])) {
    Page::Redirect('dash');
}
if (isset($getpost['new'])) {
    $p->JS('notifier.js');
    $p->JS('Notifier.info("Editing new Item");');
}
$p->HTML('<BR>');
global $auth_database;
$profile_model = new Profile($auth_database);
$auth_model = new Auth($auth_database);
$a = $auth_model->Get($getpost['ID']);
if (false_or_null($a)) {
    Page::Redirect('profiles');
}
$pro = $profile_model->Get($a['r_Profile']);
if (false_or_null($pro)) {
    Page::Redirect('profiles');
}
$p->HTML('<span class="breadcrumbs">Editing Profile #' . $pro['ID'] . ' and Auth #' . $a['ID'] . '</span>');
$p->HTML('<span class="breadcrumbs-link"><a href="profiles" class="bare">&larr; Profiles</a></span>');
$p->Bind_LoadPlugins();
$p->HTML('<div class="formboundary">');
$p->HTML('<div class="formgroup wide">');
$p->HTML('Username');
$p->BindString("Auth", $a['ID'], "username", $a['username'], "Enter username", FALSE, "texty");
$p->HTML('</div>');
Example #11
0
    $p->HTML('header.html', array("###MENU###" => Dropdown_menu($p)));
}
$p->title = "Your Website";
$p->CSS("main.css");
$p->Jquery();
$getpost = getpost();
$p->HTML('<BR>');
global $auth_database;
plog("Get mods!");
$m = new Modification($auth_database);
$mods = $m->All('ORDER BY Timestamp DESC');
$m_auth = new Auth($auth_database);
if (!false_or_null($mods)) {
    $datatemp = array();
    foreach ($mods as $mod) {
        $user = $m_auth->Get($mod['r_Auth']);
        if (!isset($datatemp[$user['username']])) {
            $datatemp[$user['username']] = 1;
        } else {
            $datatemp[$user['username']] += 1;
        }
    }
    $datapoints = array();
    foreach ($datatemp as $username => $events) {
        $datapoints[] = array("value" => $events, "color" => "#FFAAAA", "highlight" => "5AD3D1", "label" => $username);
    }
    $chart = Pie($p, 400, 400, $datapoints);
    //  $p->CSS('.'.$chart.' { }');
    $data = array();
    foreach ($mods as $mod) {
        $user = $m_auth->Get($mod['r_Auth']);
Example #12
0
 public function SaveTeamName($block = 0, $team = 0)
 {
     // Require Manager Login
     Auth::RequireManager(true);
     // Get Block
     $this->Block = new Game_Block($block);
     if (!$this->Block->exists()) {
         $this->json->error("Block could not be found.");
     }
     // Get Fixture
     $this->Fixture = $this->Block->fixture->get();
     if (!$this->Fixture->exists()) {
         $this->json->error("Fixture could not be found.");
     }
     // Check ownership
     if ($this->Fixture->owner != Auth::Get("id")) {
         $this->json->error("You are not owner of this fixture.");
     }
     // Make sure the team is ok
     if (!in_array($team, array(1, 2))) {
         $this->json->error("Team could not be found.");
     }
     $this->Block->{"team_" . $team} = $this->input->post("name");
     // Try saving
     if ($this->Block->save()) {
         $this->json->success();
     } else {
         $this->json->error(strip_tags($this->Block->error->string));
     }
 }
Example #13
0
		$("#BlockData").html("<h3>Please Wait...</h3>").load( "<?php 
echo url('game_blocks/getData/');
?>
" + $(this).attr("block_id") ).attr("block_id", $(this).attr("block_id"));
		
	});
	
	$(".BlockJoinButton").live("click", function(e) {
		
		e.preventDefault(); 
		
		<?php 
if ($this->Fixture->player_cost) {
    ?>
			if( $("#BlockData .BlockPlayer[player=<?php 
    echo Auth::Get('id');
    ?>
]").length > 0 )
			{
				var Confirm = "Are you sure you want to rejoin? Your last refund will be cancelled.";
			}
			else
			{
				var Confirm = "Are you sure you want to join this game? You will be charged \u00A3<?php 
    echo number_format($this->Fixture->payp_cost, 2);
    ?>
 credits.";
			}
		
			if( confirm(Confirm) )
			{
Example #14
0
 public function leave($block = 0)
 {
     $this->template->disable();
     // Make sure the user is logged in
     if (!$this->auth->isLogged()) {
         $this->json->error("You need to be logged in.");
     }
     // Find the game
     $this->Block = new Game_Block($block);
     // Make sure the game exists
     if (!$this->Block->exists()) {
         $this->json->error("Block could not be found.");
     }
     // Make sure the game is not in the past
     if ($this->Block->time != 0 && $this->Block->time < time()) {
         $this->json->error("This block is already in the past.");
     }
     // Load your account
     $this->Account = new Account(Auth::Get("id"));
     // Make sure your account has been loaded
     if (!$this->Account->exists()) {
         $this->json->error("Your account could not be loaded.");
     }
     // Make sure you are playing this game
     if (!$this->Block->is_related_to($this->Account)) {
         $this->json->error("You are not playing this block.");
     }
     // Try getting the fixture
     $this->Fixture = $this->Block->fixture->get();
     // Make sure fixture is loaded
     if (!$this->Fixture->exists()) {
         $this->json->error("Fixture could not be loaded.");
     }
     $this->Related_Account = $this->Block->account->where("id", Auth::Get("id"))->include_join_fields()->get();
     if ($this->Related_Account->exists() && !$this->Related_Account->join_active) {
         $this->json->error("You already left this game.");
     }
     // If the fixture is not free
     if ($this->Fixture->payp_cost || $this->Fixture->player_cost) {
         // Mark his last payment cancelled
         $this->LastPayment = new Payment();
         $this->LastPayment = $this->LastPayment->where(array("account_id" => Auth::Get("id"), "game_block_id" => $this->Block->id, "type" => "game", "amount >" => 0))->order_by("id", "DESC")->limit(1)->get();
         if ($this->LastPayment->exists()) {
             $this->LastPayment->status = "cancelled";
             $this->LastPayment->save();
         }
         // Return the money
         $Payment = new Payment();
         if ($this->Related_Account->join_type == "game") {
             $Payment->amount = 0 - $this->Fixture->payp_cost;
         } else {
             if ($this->Related_Account->join_type == "block") {
                 $Payment->amount = 0 - $this->Fixture->player_cost;
             }
         }
         $Payment->date = time();
         $Payment->account_id = Auth::Get("id");
         $Payment->game_block_id = $this->Block->id;
         $Payment->fixture_id = $this->Fixture->id;
         $Payment->type = "game";
         $Payment->status = "active";
         if ($this->LastPayment->exists()) {
             if ($this->LastPayment->paid) {
                 $Payment->save();
             }
         } else {
             $Payment->save();
         }
         // Return credits to your account
         $this->Account->credits += $Payment->amount;
         $this->Account->save();
         $CreditedAccount = abs($Payment->amount);
     }
     // Set this account inactive
     $this->Block->set_join_field($this->Account, "active", 0);
     $data = array();
     if (isset($CreditedAccount)) {
         $data['credited'] = $CreditedAccount;
     }
     $this->json->success($data);
 }
Example #15
0
 public function enter($player = 0, $block = 0)
 {
     Auth::RequireManager();
     $this->Block = new Game_Block($block);
     if (!$this->Block->exists()) {
         Session::GoBack("Game could not be found.");
     }
     // Try Getting Fixture
     if (!$this->Block->fixture->get()->exists()) {
         Session::GoBack("Fixture could not be found.");
     }
     if ($this->Block->fixture->owner != Auth::Get("id")) {
         Session::GoBack("You cannot manage this block.");
     }
     $this->Account = new Account($player);
     if (!$this->Account->exists()) {
         Session::GoBack("Player could not be found.");
     }
     if (!$this->Block->is_related_to($this->Account)) {
         Session::GoBack("This player is not playing in this game.");
     }
     // Check the limit of this block
     $this->PlayersCount = $this->Block->account->include_join_fields()->where(array("active" => 1))->count();
     if ($this->PlayersCount >= (int) $this->Block->fixture->type * 2) {
         Session::GoBack("This game is already full!");
     }
     $this->Block->set_join_field($this->Account, "active", 1);
     Session::GoBack("Player has joined.");
 }
Example #16
0
 public static function LoadMyAccount()
 {
     $Account = new Account(Auth::Get("id"));
     return $Account->exists() ? $Account : false;
 }
Example #17
0
			<div class="main-inner">
				<div class="container" style="margin-top:10px">
						<div class="span3 bs-docs-sidebar" style="min-height:500px; width:190px">
							<!-- Secondary vertical navigation
					    ================================================== -->
							<ul class="nav nav-list bs-docs-sidenav" style="margin-top:50px">
							  <li <?php 
echo $template->getData("SelectedTab") == "Dashboard" ? "class='active'" : "";
?>
><a href="<?php 
echo url("dashboard/index");
?>
"> <i class="icon-chevron-right"></i>Dashboard</a></li>
							  <?php 
if (Auth::Get("manager")) {
    ?>
							  <li <?php 
    echo $template->getData("SelectedTab") == "Games I manage" ? "class='active'" : "";
    ?>
><a href="<?php 
    echo url("fixtures/my_fixtures");
    ?>
"><i class="icon-chevron-right"></i>Games I manage</a></li>
							  <li <?php 
    echo $template->getData("SelectedTab") == "Connected players" ? "class='active'" : "";
    ?>
><a href="<?php 
    echo url("manager/ConnectedPlayers");
    ?>
"><i class="icon-chevron-right"></i>Connected players</a></li>
Example #18
0
 public function payments()
 {
     Auth::RequireLogin();
     $this->template->setData("SelectedTab", "Payments");
     if (Auth::Get("manager")) {
         // Get Payments - Manager
         $this->Payments = $this->db->query("\n\t\t\t\t\tSELECT fixtures.id as FixtureID, accounts.first_name, accounts.last_name, payments.amount, fixtures.location as FixtureLocation, game_blocks.time as GameBlockTime, payments.date as PaymentTime\n\t\t\t\t\tFROM payments\n\t\t\t\t\tLEFT JOIN game_blocks ON game_blocks.id = payments.game_block_id\n\t\t\t\t\tLEFT JOIN accounts ON accounts.id = payments.account_id\n\t\t\t\t\tLEFT JOIN fixtures ON fixtures.id = game_blocks.fixture_id\n\t\t\t\t\tWHERE fixtures.owner = " . Auth::Get("id") . "\n\t\t\t\t\tORDER BY payments.id DESC \n\t\t\t\t")->result();
         $this->load->view("accounts/payments_manager");
     } else {
         // Get Payments - Player
         $this->Payments = $this->db->query("\n\t\t\t\t\tSELECT fixtures.id as FixtureID, payments.amount, fixtures.location as FixtureLocation, game_blocks.time as GameBlockTime, payments.date as PaymentTime\n\t\t\t\t\tFROM payments\n\t\t\t\t\tLEFT JOIN game_blocks ON game_blocks.id = payments.game_block_id\n\t\t\t\t\tLEFT JOIN fixtures ON fixtures.id = game_blocks.fixture_id\n\t\t\t\t\tWHERE payments.account_id = " . Auth::Get("id") . "\n\t\t\t\t\tORDER BY payments.id DESC \n\t\t\t\t")->result();
         $this->load->view("accounts/payments_player");
     }
 }
Example #19
0
    echo '0';
    die;
}
$sessions = $m_sess->ActiveUsers();
$m_auth = new Auth($auth_database);
$mod_model = new Modification($auth_database);
$result = array();
$was = array();
foreach ($sessions as $s) {
    if (!$m_sess->LoggedOut($s)) {
        $activity = ' ';
        $activity .= get_url_map($s['last_url'], $url_map);
        if (matches($activity, 'request_login.php')) {
            continue;
        }
        $a = $m_auth->Get($s['r_Auth']);
        if (false_or_null($a)) {
            continue;
        }
        $found = FALSE;
        foreach ($was as $u) {
            if (matches($u, $a['username'])) {
                $found = TRUE;
                break;
            }
        }
        if ($found === TRUE) {
            continue;
        }
        $was[] = $a['username'];
        $mod = $mod_model->Select(array('r_Auth' => $a['ID']), '*', "", 'ORDER BY Timestamp DESC', 1);