@@ -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 | } |
@@ -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,19 +17,19 @@ 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 | - // fetch a bunch of un-geolocated IPs from the database. |
|
| 25 | - // note we have to parse the forwardedip field in the database so we can test against the geolocation table. |
|
| 26 | - // This guarantees we get ten unlocated IPs back, unless there actually aren't 10 available. |
|
| 27 | - // Alternatives include downloading a small set of forwarded IPs, splitting it in PHP, constructing an IN() |
|
| 28 | - // clause dynamically, sending that back to the database to check if there are geolocation entries, then repeating |
|
| 29 | - // until we have 10 to process - and the fact that we'd have to potentially retrieve all IPs from the database |
|
| 30 | - // before we find any at all. This way keeps all of that legwork in the database, at the cost of a more complex |
|
| 31 | - // query. |
|
| 32 | - $statement = $database->query(<<<SQL |
|
| 23 | + try { |
|
| 24 | + // fetch a bunch of un-geolocated IPs from the database. |
|
| 25 | + // note we have to parse the forwardedip field in the database so we can test against the geolocation table. |
|
| 26 | + // This guarantees we get ten unlocated IPs back, unless there actually aren't 10 available. |
|
| 27 | + // Alternatives include downloading a small set of forwarded IPs, splitting it in PHP, constructing an IN() |
|
| 28 | + // clause dynamically, sending that back to the database to check if there are geolocation entries, then repeating |
|
| 29 | + // until we have 10 to process - and the fact that we'd have to potentially retrieve all IPs from the database |
|
| 30 | + // before we find any at all. This way keeps all of that legwork in the database, at the cost of a more complex |
|
| 31 | + // query. |
|
| 32 | + $statement = $database->query(<<<SQL |
|
| 33 | 33 | SELECT p.prox |
| 34 | 34 | FROM ( |
| 35 | 35 | SELECT trim(substring_index(substring_index(r.forwardedip, ',', n.n), ',', -1)) prox |
@@ -46,38 +46,38 @@ discard block |
||
| 46 | 46 | WHERE NOT EXISTS (SELECT 1 FROM geolocation g WHERE g.address = p.prox) |
| 47 | 47 | LIMIT 10; |
| 48 | 48 | SQL |
| 49 | - ); |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | - $missingIps = $statement->fetchAll(PDO::FETCH_COLUMN); |
|
| 51 | + $missingIps = $statement->fetchAll(PDO::FETCH_COLUMN); |
|
| 52 | 52 | |
| 53 | - $count = count($missingIps); |
|
| 54 | - if ($count === 0) { |
|
| 55 | - echo ". Found nothing to do.\n"; |
|
| 56 | - break; |
|
| 57 | - } |
|
| 53 | + $count = count($missingIps); |
|
| 54 | + if ($count === 0) { |
|
| 55 | + echo ". Found nothing to do.\n"; |
|
| 56 | + break; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - echo ". Picked {$count} IP addresses\n"; |
|
| 59 | + echo ". Picked {$count} IP addresses\n"; |
|
| 60 | 60 | |
| 61 | - foreach ($missingIps as $ip) { |
|
| 62 | - echo ". . Getting location for {$ip}...\n"; |
|
| 63 | - $data = json_encode($locationProvider->getIpLocation($ip)); |
|
| 64 | - echo ". . . {$data}\n"; |
|
| 65 | - } |
|
| 61 | + foreach ($missingIps as $ip) { |
|
| 62 | + echo ". . Getting location for {$ip}...\n"; |
|
| 63 | + $data = json_encode($locationProvider->getIpLocation($ip)); |
|
| 64 | + echo ". . . {$data}\n"; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - echo ". IP location fetch complete.\n"; |
|
| 68 | - $database->commit(); |
|
| 69 | - echo ". Committed txn.\n"; |
|
| 70 | - } catch (Exception $ex) { |
|
| 71 | - echo ". Encountered exception: " . $ex->getMessage(). "\n"; |
|
| 72 | - $database->rollBack(); |
|
| 73 | - echo ". Rolled back txn\n"; |
|
| 74 | - throw $ex; |
|
| 75 | - } finally { |
|
| 76 | - if($database->hasActiveTransaction()){ |
|
| 77 | - $database->rollBack(); |
|
| 78 | - echo ". Rolled back txn\n"; |
|
| 79 | - } |
|
| 80 | - } |
|
| 67 | + echo ". IP location fetch complete.\n"; |
|
| 68 | + $database->commit(); |
|
| 69 | + echo ". Committed txn.\n"; |
|
| 70 | + } catch (Exception $ex) { |
|
| 71 | + echo ". Encountered exception: " . $ex->getMessage(). "\n"; |
|
| 72 | + $database->rollBack(); |
|
| 73 | + echo ". Rolled back txn\n"; |
|
| 74 | + throw $ex; |
|
| 75 | + } finally { |
|
| 76 | + if($database->hasActiveTransaction()){ |
|
| 77 | + $database->rollBack(); |
|
| 78 | + echo ". Rolled back txn\n"; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | echo "Done.\n"; |
@@ -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; |