@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $viewableDataStatement->bindValue(":email", $request->getEmail()); |
| 66 | 66 | $viewableDataStatement->bindValue(":reserved", User::getCurrent()->getId()); |
| 67 | 67 | $viewableDataStatement->bindValue(":trustedIp", $request->getTrustedIp()); |
| 68 | - $viewableDataStatement->bindValue(":trustedProxy", '%' . $request->getTrustedIp() . '%'); |
|
| 68 | + $viewableDataStatement->bindValue(":trustedProxy", '%'.$request->getTrustedIp().'%'); |
|
| 69 | 69 | |
| 70 | 70 | $viewableDataStatement->execute(); |
| 71 | 71 | |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | #endregion |
| 78 | 78 | |
| 79 | 79 | if ($request->getStatus() == "Closed") { |
| 80 | - $hash = md5($request->getId() . $request->getEmail() . $request->getTrustedIp() . microtime()); //If the request is closed, change the hash based on microseconds similar to the checksums. |
|
| 80 | + $hash = md5($request->getId().$request->getEmail().$request->getTrustedIp().microtime()); //If the request is closed, change the hash based on microseconds similar to the checksums. |
|
| 81 | 81 | $smarty->assign("isclosed", true); |
| 82 | 82 | } |
| 83 | 83 | else { |
| 84 | - $hash = md5($request->getId() . $request->getEmail() . $request->getTrustedIp()); |
|
| 84 | + $hash = md5($request->getId().$request->getEmail().$request->getTrustedIp()); |
|
| 85 | 85 | $smarty->assign("isclosed", false); |
| 86 | 86 | } |
| 87 | 87 | $smarty->assign("hash", $hash); |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | $userListData = $userListResult->fetchAll(PDO::FETCH_COLUMN); |
| 258 | 258 | $userListProcessedData = array(); |
| 259 | 259 | foreach ($userListData as $userListItem) { |
| 260 | - $userListProcessedData[] = "\"" . htmlentities($userListItem) . "\""; |
|
| 260 | + $userListProcessedData[] = "\"".htmlentities($userListItem)."\""; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - $userList = '[' . implode(",", $userListProcessedData) . ']'; |
|
| 263 | + $userList = '['.implode(",", $userListProcessedData).']'; |
|
| 264 | 264 | $smarty->assign("jsuserlist", $userList); |
| 265 | 265 | // end: assign to user |
| 266 | 266 | |
@@ -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"; |
@@ -70,12 +70,12 @@ |
||
| 70 | 70 | $database->commit(); |
| 71 | 71 | echo ". Committed txn.\n"; |
| 72 | 72 | } catch (Exception $ex) { |
| 73 | - echo ". Encountered exception: " . $ex->getMessage(). "\n"; |
|
| 73 | + echo ". Encountered exception: ".$ex->getMessage()."\n"; |
|
| 74 | 74 | $database->rollBack(); |
| 75 | 75 | echo ". Rolled back txn\n"; |
| 76 | 76 | throw $ex; |
| 77 | 77 | } finally { |
| 78 | - if($database->hasActiveTransaction()){ |
|
| 78 | + if ($database->hasActiveTransaction()) { |
|
| 79 | 79 | $database->rollBack(); |
| 80 | 80 | echo ". Rolled back txn\n"; |
| 81 | 81 | } |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | if (count($validationErrors) > 0) { |
| 123 | 123 | foreach ($validationErrors as $validationError) { |
| 124 | 124 | BootstrapSkin::displayAlertBox( |
| 125 | - $smarty->fetch("validation/" . $validationError->getErrorCode() . ".tpl"), |
|
| 125 | + $smarty->fetch("validation/".$validationError->getErrorCode().".tpl"), |
|
| 126 | 126 | "alert-error"); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // username can't contain #@/<>[]|{} |
| 64 | - if (preg_match("/[" . preg_quote("#@/<>[]|{}", "/") . "]/", $this->request->getName()) === 1) { |
|
| 64 | + if (preg_match("/[".preg_quote("#@/<>[]|{}", "/")."]/", $this->request->getName()) === 1) { |
|
| 65 | 65 | $errorList[ValidationError::NAME_INVALIDCHAR] = new ValidationError(ValidationError::NAME_INVALIDCHAR); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | { |
| 177 | 177 | global $enableTitleblacklist; |
| 178 | 178 | if ($enableTitleblacklist == 1) { |
| 179 | - $apiResult = file_get_contents("https://en.wikipedia.org/w/api.php?action=titleblacklist&tbtitle=" . urlencode($this->request->getName()) . "&tbaction=new-account&tbnooverride&format=php"); |
|
| 179 | + $apiResult = file_get_contents("https://en.wikipedia.org/w/api.php?action=titleblacklist&tbtitle=".urlencode($this->request->getName())."&tbaction=new-account&tbnooverride&format=php"); |
|
| 180 | 180 | |
| 181 | 181 | $data = unserialize($apiResult); |
| 182 | 182 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | global $mediawikiWebServiceEndpoint; |
| 194 | 194 | |
| 195 | - $userexist = file_get_contents($mediawikiWebServiceEndpoint . "?action=query&list=users&ususers=" . urlencode($this->request->getName()) . "&format=php"); |
|
| 195 | + $userexist = file_get_contents($mediawikiWebServiceEndpoint."?action=query&list=users&ususers=".urlencode($this->request->getName())."&format=php"); |
|
| 196 | 196 | $ue = unserialize($userexist); |
| 197 | 197 | if (!isset ($ue['query']['users']['0']['missing']) && isset ($ue['query']['users']['0']['userid'])) { |
| 198 | 198 | return true; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | global $mediawikiWebServiceEndpoint; |
| 207 | 207 | |
| 208 | 208 | $reqname = str_replace("_", " ", $this->request->getName()); |
| 209 | - $userexist = file_get_contents($mediawikiWebServiceEndpoint . "?action=query&meta=globaluserinfo&guiuser=" . urlencode($reqname) . "&format=php"); |
|
| 209 | + $userexist = file_get_contents($mediawikiWebServiceEndpoint."?action=query&meta=globaluserinfo&guiuser=".urlencode($reqname)."&format=php"); |
|
| 210 | 210 | $ue = unserialize($userexist); |
| 211 | 211 | if (isset ($ue['query']['globaluserinfo']['id'])) { |
| 212 | 212 | return true; |
@@ -26,10 +26,10 @@ |
||
| 26 | 26 | $output .= "#{$count}: "; |
| 27 | 27 | |
| 28 | 28 | if (isset($line['type']) && $line['type'] != "") { |
| 29 | - $output .= $line['class'] . $line['type']; |
|
| 29 | + $output .= $line['class'].$line['type']; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $output .= $line['function'] . "(...)"; |
|
| 32 | + $output .= $line['function']."(...)"; |
|
| 33 | 33 | $output .= " [{$line['file']}#{$line['line']}\r\n"; |
| 34 | 34 | |
| 35 | 35 | $count++; |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | |
| 96 | 96 | $statement = $this->database->prepare($query); |
| 97 | 97 | $statement->bindValue(":username", $this->user->getUsername()); |
| 98 | - $statement->bindValue(":date", date('Y-m-d') . "%"); |
|
| 98 | + $statement->bindValue(":date", date('Y-m-d')."%"); |
|
| 99 | 99 | $statement->execute(); |
| 100 | 100 | $today = $statement->fetchColumn(); |
| 101 | 101 | $statement->closeCursor(); |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | global $CORSallowed; |
| 17 | 17 | |
| 18 | 18 | if (in_array($httpOrigin, $CORSallowed)) { |
| 19 | - header("Access-Control-Allow-Origin: " . $httpOrigin); |
|
| 19 | + header("Access-Control-Allow-Origin: ".$httpOrigin); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | $substr = mb_substr($string, 0, 1); |
| 13 | 13 | $substr2 = mb_substr($string, 1, $strlen - 1); |
| 14 | 14 | $upstring = mb_strtoupper($substr); |
| 15 | - $ustring = $upstring . $substr2; |
|
| 15 | + $ustring = $upstring.$substr2; |
|
| 16 | 16 | return $ustring; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $cacheResult = AntiSpoofCache::getByUsername($username, gGetDb()); |
| 16 | 16 | if ($cacheResult == false) { |
| 17 | 17 | // get the data from the API |
| 18 | - $data = file_get_contents($mediawikiWebServiceEndpoint . "?action=antispoof&format=php&username=" . urlencode($username)); |
|
| 18 | + $data = file_get_contents($mediawikiWebServiceEndpoint."?action=antispoof&format=php&username=".urlencode($username)); |
|
| 19 | 19 | |
| 20 | 20 | $cacheEntry = new AntiSpoofCache(); |
| 21 | 21 | $cacheEntry->setDatabase(gGetDb()); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $cacheResult->delete(); |
| 36 | 36 | |
| 37 | 37 | if (isset($result['error']['info'])) { |
| 38 | - throw new Exception("Unrecognised API response to query: " . $result['error']['info']); |
|
| 38 | + throw new Exception("Unrecognised API response to query: ".$result['error']['info']); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | throw new Exception("Unrecognised API response to query."); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | if ($result['antispoof']['result'] == "error") { |
| 55 | 55 | // we've got conflicts, let's do something with them. |
| 56 | - throw new Exception("Encountered error while getting result: " . $result['antispoof']['error']); |
|
| 56 | + throw new Exception("Encountered error while getting result: ".$result['antispoof']['error']); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | throw new Exception("Unrecognised API response to query."); |