| @@ -2036,41 +2036,41 @@ | ||
| 2036 | 2036 | }); | 
| 2037 | 2037 | } | 
| 2038 | 2038 |  elseif ($action == "listall") { | 
| 2039 | - global $availableRequestStates, $enableEmailConfirm; | |
| 2039 | + global $availableRequestStates, $enableEmailConfirm; | |
| 2040 | 2040 | |
| 2041 | 2041 |  	if (isset($_GET['status']) && isset($availableRequestStates[$_GET['status']])) { | 
| 2042 | 2042 | $type = $_GET['status']; // safe, we've verified it's sane in the above if statement. | 
| 2043 | 2043 | |
| 2044 | - $database = gGetDb(); | |
| 2044 | + $database = gGetDb(); | |
| 2045 | 2045 | |
| 2046 | -	    if ($enableEmailConfirm == 1) { | |
| 2047 | - $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; | |
| 2048 | -	    } else { | |
| 2049 | - $query = "SELECT * FROM request WHERE status = :type;"; | |
| 2050 | - } | |
| 2046 | +		if ($enableEmailConfirm == 1) { | |
| 2047 | + $query = "SELECT * FROM request WHERE status = :type AND emailconfirm = 'Confirmed';"; | |
| 2048 | +		} else { | |
| 2049 | + $query = "SELECT * FROM request WHERE status = :type;"; | |
| 2050 | + } | |
| 2051 | 2051 | |
| 2052 | - $statement = $database->prepare($query); | |
| 2052 | + $statement = $database->prepare($query); | |
| 2053 | 2053 | |
| 2054 | -        $statement->bindValue(":type", $type); | |
| 2055 | - $statement->execute(); | |
| 2054 | +		$statement->bindValue(":type", $type); | |
| 2055 | + $statement->execute(); | |
| 2056 | 2056 | |
| 2057 | - $requests = $statement->fetchAll(PDO::FETCH_CLASS, "Request"); | |
| 2058 | -        foreach ($requests as $req) { | |
| 2059 | - /** @var Request $req */ | |
| 2060 | - $req->setDatabase($database); | |
| 2061 | - } | |
| 2057 | + $requests = $statement->fetchAll(PDO::FETCH_CLASS, "Request"); | |
| 2058 | +		foreach ($requests as $req) { | |
| 2059 | + /** @var Request $req */ | |
| 2060 | + $req->setDatabase($database); | |
| 2061 | + } | |
| 2062 | 2062 | |
| 2063 | - global $smarty; | |
| 2064 | -        $smarty->assign("requests", $requests); | |
| 2065 | -        $smarty->assign("showStatus", false); | |
| 2066 | -        $html = $smarty->fetch("mainpage/requesttable.tpl"); | |
| 2067 | - echo $html; | |
| 2068 | -    } else { | |
| 2069 | - echo defaultpage(); | |
| 2070 | - } | |
| 2063 | + global $smarty; | |
| 2064 | +		$smarty->assign("requests", $requests); | |
| 2065 | +		$smarty->assign("showStatus", false); | |
| 2066 | +		$html = $smarty->fetch("mainpage/requesttable.tpl"); | |
| 2067 | + echo $html; | |
| 2068 | +	} else { | |
| 2069 | + echo defaultpage(); | |
| 2070 | + } | |
| 2071 | 2071 | |
| 2072 | - BootstrapSkin::displayInternalFooter(); | |
| 2073 | - die(); | |
| 2072 | + BootstrapSkin::displayInternalFooter(); | |
| 2073 | + die(); | |
| 2074 | 2074 | } | 
| 2075 | 2075 | # If the action specified does not exist, goto the default page. | 
| 2076 | 2076 |  else { | 
| @@ -654,9 +654,9 @@ | ||
| 654 | 654 | |
| 655 | 655 | public function isCheckuser() | 
| 656 | 656 |  	{ | 
| 657 | -	    if($this->isCheckuserCache === null) { | |
| 658 | - $this->isCheckuserCache = $this->checkuser == 1 || $this->oauthCanCheckUser(); | |
| 659 | - } | |
| 657 | +		if($this->isCheckuserCache === null) { | |
| 658 | + $this->isCheckuserCache = $this->checkuser == 1 || $this->oauthCanCheckUser(); | |
| 659 | + } | |
| 660 | 660 | |
| 661 | 661 | return $this->isCheckuserCache; | 
| 662 | 662 | } | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 | |
| 29 | 29 | /** Initialises the PHP Session */ | 
| 30 | 30 |  function initialiseSession() { | 
| 31 | - session_start(); | |
| 31 | + session_start(); | |
| 32 | 32 | } | 
| 33 | 33 | |
| 34 | 34 | /** | 
| @@ -160,7 +160,7 @@ discard block | ||
| 160 | 160 | "requests" => $requests, | 
| 161 | 161 | "total" => $totalRequests, | 
| 162 | 162 | "api" => $v['api'], | 
| 163 | - "type" => $type); | |
| 163 | + "type" => $type); | |
| 164 | 164 | } | 
| 165 | 165 | |
| 166 | 166 | global $smarty; | 
| @@ -1,7 +1,7 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | 3 |  if (isset($_SERVER['REQUEST_METHOD'])) { | 
| 4 | - die(); | |
| 4 | + die(); | |
| 5 | 5 | } // Web clients die. | 
| 6 | 6 | |
| 7 | 7 |  ini_set('display_errors', 1); | 
| @@ -17,21 +17,21 @@ discard block | ||
| 17 | 17 | $locationProvider = new IpLocationProvider($database, $locationProviderApiKey); | 
| 18 | 18 | |
| 19 | 19 |  while (true) { | 
| 20 | - echo "Beginning txn\n"; | |
| 21 | - $database->beginTransaction(); | |
| 20 | + echo "Beginning txn\n"; | |
| 21 | + $database->beginTransaction(); | |
| 22 | 22 | |
| 23 | -    try { | |
| 24 | - echo ". Fetching data...\n"; | |
| 23 | +	try { | |
| 24 | + echo ". Fetching data...\n"; | |
| 25 | 25 | |
| 26 | - // fetch a bunch of un-geolocated IPs from the database. | |
| 27 | - // note we have to parse the forwardedip field in the database so we can test against the geolocation table. | |
| 28 | - // This guarantees we get ten unlocated IPs back, unless there actually aren't 10 available. | |
| 29 | - // Alternatives include downloading a small set of forwarded IPs, splitting it in PHP, constructing an IN() | |
| 30 | - // clause dynamically, sending that back to the database to check if there are geolocation entries, then repeating | |
| 31 | - // until we have 10 to process - and the fact that we'd have to potentially retrieve all IPs from the database | |
| 32 | - // before we find any at all. This way keeps all of that legwork in the database, at the cost of a more complex | |
| 33 | - // query. | |
| 34 | - $statement = $database->query(<<<SQL | |
| 26 | + // fetch a bunch of un-geolocated IPs from the database. | |
| 27 | + // note we have to parse the forwardedip field in the database so we can test against the geolocation table. | |
| 28 | + // This guarantees we get ten unlocated IPs back, unless there actually aren't 10 available. | |
| 29 | + // Alternatives include downloading a small set of forwarded IPs, splitting it in PHP, constructing an IN() | |
| 30 | + // clause dynamically, sending that back to the database to check if there are geolocation entries, then repeating | |
| 31 | + // until we have 10 to process - and the fact that we'd have to potentially retrieve all IPs from the database | |
| 32 | + // before we find any at all. This way keeps all of that legwork in the database, at the cost of a more complex | |
| 33 | + // query. | |
| 34 | + $statement = $database->query(<<<SQL | |
| 35 | 35 | SELECT p.prox | 
| 36 | 36 | FROM ( | 
| 37 | 37 | SELECT trim(substring_index(substring_index(r.forwardedip, ',', n.n), ',', -1)) prox | 
| @@ -48,38 +48,38 @@ discard block | ||
| 48 | 48 | WHERE NOT EXISTS (SELECT 1 FROM geolocation g WHERE g.address = p.prox FOR UPDATE) | 
| 49 | 49 | LIMIT 10; | 
| 50 | 50 | SQL | 
| 51 | - ); | |
| 51 | + ); | |
| 52 | 52 | |
| 53 | - $missingIps = $statement->fetchAll(PDO::FETCH_COLUMN); | |
| 53 | + $missingIps = $statement->fetchAll(PDO::FETCH_COLUMN); | |
| 54 | 54 | |
| 55 | - $count = count($missingIps); | |
| 56 | -        if ($count === 0) { | |
| 57 | - echo ". Found nothing to do.\n"; | |
| 58 | - break; | |
| 59 | - } | |
| 55 | + $count = count($missingIps); | |
| 56 | +		if ($count === 0) { | |
| 57 | + echo ". Found nothing to do.\n"; | |
| 58 | + break; | |
| 59 | + } | |
| 60 | 60 | |
| 61 | -        echo ". Picked {$count} IP addresses\n"; | |
| 61 | +		echo ". Picked {$count} IP addresses\n"; | |
| 62 | 62 | |
| 63 | -        foreach ($missingIps as $ip) { | |
| 64 | -            echo ". . Getting location for {$ip}...\n"; | |
| 65 | - $data = json_encode($locationProvider->getIpLocation($ip)); | |
| 66 | -            echo ". . . {$data}\n"; | |
| 67 | - } | |
| 63 | +		foreach ($missingIps as $ip) { | |
| 64 | +			echo ". . Getting location for {$ip}...\n"; | |
| 65 | + $data = json_encode($locationProvider->getIpLocation($ip)); | |
| 66 | +			echo ". . . {$data}\n"; | |
| 67 | + } | |
| 68 | 68 | |
| 69 | - echo ". IP location fetch complete.\n"; | |
| 70 | - $database->commit(); | |
| 71 | - echo ". Committed txn.\n"; | |
| 72 | -    } catch (Exception $ex) { | |
| 73 | - echo ". Encountered exception: " . $ex->getMessage(). "\n"; | |
| 74 | - $database->rollBack(); | |
| 75 | - echo ". Rolled back txn\n"; | |
| 76 | - throw $ex; | |
| 77 | -    } finally { | |
| 78 | -        if($database->hasActiveTransaction()){ | |
| 79 | - $database->rollBack(); | |
| 80 | - echo ". Rolled back txn\n"; | |
| 81 | - } | |
| 82 | - } | |
| 69 | + echo ". IP location fetch complete.\n"; | |
| 70 | + $database->commit(); | |
| 71 | + echo ". Committed txn.\n"; | |
| 72 | +	} catch (Exception $ex) { | |
| 73 | + echo ". Encountered exception: " . $ex->getMessage(). "\n"; | |
| 74 | + $database->rollBack(); | |
| 75 | + echo ". Rolled back txn\n"; | |
| 76 | + throw $ex; | |
| 77 | +	} finally { | |
| 78 | +		if($database->hasActiveTransaction()){ | |
| 79 | + $database->rollBack(); | |
| 80 | + echo ". Rolled back txn\n"; | |
| 81 | + } | |
| 82 | + } | |
| 83 | 83 | } | 
| 84 | 84 | |
| 85 | 85 | echo "Done.\n"; | 
| @@ -14,31 +14,31 @@ discard block | ||
| 14 | 14 | |
| 15 | 15 | class StatsIdUsers extends StatisticsPage | 
| 16 | 16 |  { | 
| 17 | - protected function execute() | |
| 18 | -    { | |
| 19 | - return $this->getUserList(); | |
| 20 | - } | |
| 17 | + protected function execute() | |
| 18 | +	{ | |
| 19 | + return $this->getUserList(); | |
| 20 | + } | |
| 21 | 21 | |
| 22 | - public function getPageTitle() | |
| 23 | -    { | |
| 24 | - return "User identification status"; | |
| 25 | - } | |
| 22 | + public function getPageTitle() | |
| 23 | +	{ | |
| 24 | + return "User identification status"; | |
| 25 | + } | |
| 26 | 26 | |
| 27 | - public function getPageName() | |
| 28 | -    { | |
| 29 | - return "IdUsers"; | |
| 30 | - } | |
| 27 | + public function getPageName() | |
| 28 | +	{ | |
| 29 | + return "IdUsers"; | |
| 30 | + } | |
| 31 | 31 | |
| 32 | - public function isProtected() | |
| 33 | -    { | |
| 34 | - return true; | |
| 35 | - } | |
| 32 | + public function isProtected() | |
| 33 | +	{ | |
| 34 | + return true; | |
| 35 | + } | |
| 36 | 36 | |
| 37 | - private function getUserList() | |
| 38 | -    { | |
| 39 | - global $currentIdentificationVersion, $forceIdentification; | |
| 37 | + private function getUserList() | |
| 38 | +	{ | |
| 39 | + global $currentIdentificationVersion, $forceIdentification; | |
| 40 | 40 | |
| 41 | - $query = <<<SQL | |
| 41 | + $query = <<<SQL | |
| 42 | 42 | select username, status, checkuser, identified, case | 
| 43 | 43 | when coalesce(identified, 0) = 0 then 'Not identified' | 
| 44 | 44 |      when identified < ${forceIdentification} then 'Expired' | 
| @@ -51,16 +51,16 @@ discard block | ||
| 51 | 51 | order by username; | 
| 52 | 52 | SQL; | 
| 53 | 53 | |
| 54 | - $qb = new QueryBrowser(); | |
| 55 | - $qb->rowFetchMode = PDO::FETCH_NUM; | |
| 56 | -        $qb->overrideTableTitles = array("User name", "Access level", "Checkuser?", "Version", "Identification status"); | |
| 57 | - $r = $qb->executeQueryToTable($query); | |
| 54 | + $qb = new QueryBrowser(); | |
| 55 | + $qb->rowFetchMode = PDO::FETCH_NUM; | |
| 56 | +		$qb->overrideTableTitles = array("User name", "Access level", "Checkuser?", "Version", "Identification status"); | |
| 57 | + $r = $qb->executeQueryToTable($query); | |
| 58 | 58 | |
| 59 | - return $r; | |
| 60 | - } | |
| 59 | + return $r; | |
| 60 | + } | |
| 61 | 61 | |
| 62 | - public function requiresWikiDatabase() | |
| 63 | -    { | |
| 64 | - return false; | |
| 65 | - } | |
| 62 | + public function requiresWikiDatabase() | |
| 63 | +	{ | |
| 64 | + return false; | |
| 65 | + } | |
| 66 | 66 | } |