Skip to content

Commit

Permalink
Strict type and fixes for variables with bad type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
thekabal committed Mar 15, 2017
1 parent dc125c1 commit 72605c5
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions navcomp.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);
// The Kabal Invasion - A web-based 4X space game
// Copyright © 2014 The Kabal Invasion development team, Ron Harwood, and the BNT development team
//
Expand Down Expand Up @@ -38,19 +38,27 @@

// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$state = null;
$state = (int) filter_input(INPUT_POST, 'state', FILTER_SANITIZE_NUMBER_INT);
if (mb_strlen(trim($state)) === 0)
$state = (string) filter_input(INPUT_POST, 'state', FILTER_SANITIZE_NUMBER_INT);
if (($state === null) || (mb_strlen(trim($state)) === 0))
{
$state = false;
}
else
{
$state = (int) $state;
}

// Detect if this variable exists, and filter it. Returns false if anything wasn't right.
$stop_sector = null;
$stop_sector = (int) filter_input(INPUT_POST, 'stop_sector', FILTER_SANITIZE_NUMBER_INT);
if (mb_strlen(trim($stop_sector)) === 0)
$stop_sector = (string) filter_input(INPUT_POST, 'stop_sector', FILTER_SANITIZE_NUMBER_INT);
if (($stop_sector === null) || (mb_strlen(trim($stop_sector)) === 0))
{
$stop_sector = false;
}
else
{
$state = (int) $state;
}

// Get playerinfo from database
$sql = "SELECT * FROM ::prefix::ships WHERE email=:email LIMIT 1";
Expand Down

0 comments on commit 72605c5

Please sign in to comment.