@@ -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 | |
@@ -31,8 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | if (isset($_GET['ecoverride']) && User::getCurrent()->isAdmin()) { |
| 33 | 33 | $smarty->assign('ecoverride', true); |
| 34 | - } |
|
| 35 | - else { |
|
| 34 | + } else { |
|
| 36 | 35 | $smarty->assign('ecoverride', false); |
| 37 | 36 | } |
| 38 | 37 | |
@@ -79,16 +78,14 @@ discard block |
||
| 79 | 78 | if ($request->getStatus() == "Closed") { |
| 80 | 79 | $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 | 80 | $smarty->assign("isclosed", true); |
| 82 | - } |
|
| 83 | - else { |
|
| 81 | + } else { |
|
| 84 | 82 | $hash = md5($request->getId() . $request->getEmail() . $request->getTrustedIp()); |
| 85 | 83 | $smarty->assign("isclosed", false); |
| 86 | 84 | } |
| 87 | 85 | $smarty->assign("hash", $hash); |
| 88 | 86 | if ($hash == $urlhash) { |
| 89 | 87 | $correcthash = true; |
| 90 | - } |
|
| 91 | - else { |
|
| 88 | + } else { |
|
| 92 | 89 | $correcthash = false; |
| 93 | 90 | } |
| 94 | 91 | |
@@ -127,8 +124,7 @@ discard block |
||
| 127 | 124 | if (!$ipisprivate) { |
| 128 | 125 | $iprdns = $rdnsProvider->getRdns($p2); |
| 129 | 126 | $iplocation = $locationProvider->getIpLocation($p2); |
| 130 | - } |
|
| 131 | - else { |
|
| 127 | + } else { |
|
| 132 | 128 | // this is going to fail, so why bother trying? |
| 133 | 129 | $iprdns = false; |
| 134 | 130 | $iplocation = false; |
@@ -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 | } |
@@ -69,13 +69,15 @@ |
||
| 69 | 69 | echo ". IP location fetch complete.\n"; |
| 70 | 70 | $database->commit(); |
| 71 | 71 | echo ". Committed txn.\n"; |
| 72 | - } catch (Exception $ex) { |
|
| 72 | + } |
|
| 73 | + catch (Exception $ex) { |
|
| 73 | 74 | echo ". Encountered exception: " . $ex->getMessage(). "\n"; |
| 74 | 75 | $database->rollBack(); |
| 75 | 76 | echo ". Rolled back txn\n"; |
| 76 | 77 | throw $ex; |
| 77 | - } finally { |
|
| 78 | - if($database->hasActiveTransaction()){ |
|
| 78 | + } |
|
| 79 | + finally { |
|
| 80 | + if($database->hasActiveTransaction()) { |
|
| 79 | 81 | $database->rollBack(); |
| 80 | 82 | echo ". Rolled back txn\n"; |
| 81 | 83 | } |
@@ -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 | |
@@ -89,8 +89,7 @@ discard block |
||
| 89 | 89 | BootstrapSkin::displayAlertBox($ex->getMessage(), "alert-error", "Unknown error", true, false); |
| 90 | 90 | BootstrapSkin::displayPublicFooter(); |
| 91 | 91 | } |
| 92 | -} |
|
| 93 | -else { |
|
| 92 | +} else { |
|
| 94 | 93 | if ($_SERVER['REQUEST_METHOD'] == "POST") { |
| 95 | 94 | $errorEncountered = false; |
| 96 | 95 | |
@@ -127,8 +126,7 @@ discard block |
||
| 127 | 126 | } |
| 128 | 127 | |
| 129 | 128 | $smarty->display("request/request-form.tpl"); |
| 130 | - } |
|
| 131 | - else if ($enableEmailConfirm == 1) { |
|
| 129 | + } else if ($enableEmailConfirm == 1) { |
|
| 132 | 130 | $request->generateEmailConfirmationHash(); |
| 133 | 131 | |
| 134 | 132 | $database->transactionally(function() use($request) |
@@ -143,8 +141,7 @@ discard block |
||
| 143 | 141 | $request->sendConfirmationEmail(); |
| 144 | 142 | |
| 145 | 143 | $smarty->display("request/email-confirmation.tpl"); |
| 146 | - } |
|
| 147 | - else { |
|
| 144 | + } else { |
|
| 148 | 145 | $request->setEmailConfirm(0); // Since it can't be null |
| 149 | 146 | $database->transactionally(function() use($request) |
| 150 | 147 | { |
@@ -158,8 +155,7 @@ discard block |
||
| 158 | 155 | } |
| 159 | 156 | |
| 160 | 157 | BootstrapSkin::displayPublicFooter(); |
| 161 | - } |
|
| 162 | - else { |
|
| 158 | + } else { |
|
| 163 | 159 | $smarty->display("request/request-form.tpl"); |
| 164 | 160 | BootstrapSkin::displayPublicFooter(); |
| 165 | 161 | } |
@@ -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++; |
@@ -360,8 +360,7 @@ discard block |
||
| 360 | 360 | $countStatement->bindValue(":userFilter", 0, PDO::PARAM_INT); |
| 361 | 361 | $searchStatement->bindValue(":userid", 0, PDO::PARAM_INT); |
| 362 | 362 | $countStatement->bindValue(":userid", 0, PDO::PARAM_INT); |
| 363 | - } |
|
| 364 | - else { |
|
| 363 | + } else { |
|
| 365 | 364 | $searchStatement->bindValue(":userFilter", 1, PDO::PARAM_INT); |
| 366 | 365 | $countStatement->bindValue(":userFilter", 1, PDO::PARAM_INT); |
| 367 | 366 | $searchStatement->bindValue(":userid", User::getByUsername($userFilter, $database)->getId(), PDO::PARAM_INT); |
@@ -373,8 +372,7 @@ discard block |
||
| 373 | 372 | $countStatement->bindValue(":actionFilter", 0, PDO::PARAM_INT); |
| 374 | 373 | $searchStatement->bindValue(":action", "", PDO::PARAM_STR); |
| 375 | 374 | $countStatement->bindValue(":action", "", PDO::PARAM_STR); |
| 376 | - } |
|
| 377 | - else { |
|
| 375 | + } else { |
|
| 378 | 376 | $searchStatement->bindValue(":actionFilter", 1, PDO::PARAM_INT); |
| 379 | 377 | $countStatement->bindValue(":actionFilter", 1, PDO::PARAM_INT); |
| 380 | 378 | $searchStatement->bindValue(":action", $actionFilter, PDO::PARAM_STR); |
@@ -292,7 +292,7 @@ |
||
| 292 | 292 | $template = EmailTemplate::getById((int)$id, $entry->getDatabase()); |
| 293 | 293 | |
| 294 | 294 | if ($template != false) { |
| 295 | - return "closed (" . $template->getName() . ")"; |
|
| 295 | + return "closed (".$template->getName().")"; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | } |
@@ -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(); |
@@ -49,8 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | if ($username !== '') { |
| 51 | 51 | $this->user = \User::getByUsername($username, $this->database); |
| 52 | - } |
|
| 53 | - else { |
|
| 52 | + } else { |
|
| 54 | 53 | $this->user = \User::getByOnWikiUsername($wikiusername, $this->database); |
| 55 | 54 | } |
| 56 | 55 | |
@@ -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 | } |