enwikipedia-acc /
waca
| 1 | <?php |
||||||
| 2 | /************************************************************************** |
||||||
| 3 | ********** English Wikipedia Account Request Interface ********** |
||||||
| 4 | *************************************************************************** |
||||||
| 5 | ** Wikipedia Account Request Graphic Design by Charles Melbye, ** |
||||||
| 6 | ** which is licensed under a Creative Commons ** |
||||||
| 7 | ** Attribution-Noncommercial-Share Alike 3.0 United States License. ** |
||||||
| 8 | ** ** |
||||||
| 9 | ** All other code are released under the Public Domain ** |
||||||
| 10 | ** by the ACC Development Team. ** |
||||||
| 11 | ** ** |
||||||
| 12 | ** See CREDITS for the list of developers. ** |
||||||
| 13 | ***************************************************************************/ |
||||||
| 14 | |||||||
| 15 | function zoomPage($id, $urlhash) |
||||||
| 16 | { |
||||||
| 17 | global $session, $availableRequestStates, $createdid; |
||||||
| 18 | global $smarty, $locationProvider, $rdnsProvider, $antispoofProvider; |
||||||
| 19 | global $xffTrustProvider, $enableEmailConfirm; |
||||||
| 20 | |||||||
| 21 | $database = gGetDb(); |
||||||
| 22 | $request = Request::getById($id, $database); |
||||||
| 23 | if ($request == false) { |
||||||
| 24 | // Notifies the user and stops the script. |
||||||
| 25 | BootstrapSkin::displayAlertBox("Could not load the requested request!", "alert-error", "Error", true, false); |
||||||
| 26 | BootstrapSkin::displayInternalFooter(); |
||||||
| 27 | die(); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 28 | } |
||||||
| 29 | |||||||
| 30 | $smarty->assign('ecenable', $enableEmailConfirm); |
||||||
| 31 | |||||||
| 32 | if (isset($_GET['ecoverride']) && User::getCurrent()->isAdmin()) { |
||||||
| 33 | $smarty->assign('ecoverride', true); |
||||||
| 34 | } |
||||||
| 35 | else { |
||||||
| 36 | $smarty->assign('ecoverride', false); |
||||||
| 37 | } |
||||||
| 38 | |||||||
| 39 | $smarty->assign('request', $request); |
||||||
| 40 | |||||||
| 41 | $smarty->assign("usernamerawunicode", html_entity_decode($request->getName())); |
||||||
|
0 ignored issues
–
show
The method
getName() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as Request or EmailTemplate.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 42 | |||||||
| 43 | $smarty->assign("iplocation", $locationProvider->getIpLocation($request->getTrustedIp())); |
||||||
|
0 ignored issues
–
show
The method
getTrustedIp() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 44 | |||||||
| 45 | $createdreason = EmailTemplate::getById($createdid, gGetDb()); |
||||||
| 46 | $smarty->assign("createdEmailTemplate", $createdreason); |
||||||
| 47 | |||||||
| 48 | #region setup whether data is viewable or not |
||||||
| 49 | |||||||
| 50 | $viewableDataStatement = $database->prepare(<<<SQL |
||||||
| 51 | SELECT COUNT(*) |
||||||
| 52 | FROM request |
||||||
| 53 | WHERE |
||||||
| 54 | ( |
||||||
| 55 | email = :email |
||||||
| 56 | OR ip = :trustedIp |
||||||
| 57 | OR forwardedip LIKE :trustedProxy |
||||||
| 58 | ) |
||||||
| 59 | AND reserved = :reserved |
||||||
| 60 | AND emailconfirm = 'Confirmed' |
||||||
| 61 | AND status != 'Closed'; |
||||||
| 62 | SQL |
||||||
| 63 | ); |
||||||
| 64 | |||||||
| 65 | $viewableDataStatement->bindValue(":email", $request->getEmail()); |
||||||
|
0 ignored issues
–
show
The method
getEmail() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User or Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 66 | $viewableDataStatement->bindValue(":reserved", User::getCurrent()->getId()); |
||||||
| 67 | $viewableDataStatement->bindValue(":trustedIp", $request->getTrustedIp()); |
||||||
| 68 | $viewableDataStatement->bindValue(":trustedProxy", '%' . $request->getTrustedIp() . '%'); |
||||||
| 69 | |||||||
| 70 | $viewableDataStatement->execute(); |
||||||
| 71 | |||||||
| 72 | $viewableData = $viewableDataStatement->fetchColumn(); |
||||||
| 73 | $viewableDataStatement->closeCursor(); |
||||||
| 74 | |||||||
| 75 | $hideinfo = ($viewableData == 0); |
||||||
| 76 | |||||||
| 77 | #endregion |
||||||
| 78 | |||||||
| 79 | if ($request->getStatus() == "Closed") { |
||||||
|
0 ignored issues
–
show
The method
getStatus() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as User or Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 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 | $smarty->assign("isclosed", true); |
||||||
| 82 | } |
||||||
| 83 | else { |
||||||
| 84 | $hash = md5($request->getId() . $request->getEmail() . $request->getTrustedIp()); |
||||||
| 85 | $smarty->assign("isclosed", false); |
||||||
| 86 | } |
||||||
| 87 | $smarty->assign("hash", $hash); |
||||||
| 88 | if ($hash == $urlhash) { |
||||||
| 89 | $correcthash = true; |
||||||
| 90 | } |
||||||
| 91 | else { |
||||||
| 92 | $correcthash = false; |
||||||
| 93 | } |
||||||
| 94 | |||||||
| 95 | $smarty->assign("showinfo", false); |
||||||
| 96 | if ($hideinfo == false || $correcthash == true || User::getCurrent()->isAdmin() || User::getCurrent()->isCheckuser()) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 97 | $smarty->assign("showinfo", true); |
||||||
| 98 | } |
||||||
| 99 | |||||||
| 100 | // force to not show, overriden later |
||||||
| 101 | $smarty->assign("proxyip", ""); |
||||||
| 102 | |||||||
| 103 | if ($hideinfo == false || $correcthash == true || User::getCurrent()->isAdmin() || User::getCurrent()->isCheckuser()) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 104 | $smarty->assign("proxyip", $request->getForwardedIp()); |
||||||
|
0 ignored issues
–
show
The method
getForwardedIp() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 105 | if ($request->getForwardedIp()) { |
||||||
| 106 | $smartyproxies = array(); // Initialize array to store data to be output in Smarty template. |
||||||
| 107 | $smartyproxiesindex = 0; |
||||||
| 108 | |||||||
| 109 | $proxies = explode(",", $request->getForwardedIp()); |
||||||
| 110 | $proxies[] = $request->getIp(); |
||||||
|
0 ignored issues
–
show
The method
getIp() does not exist on DataObject. Did you maybe mean getId()?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 111 | |||||||
| 112 | $origin = $proxies[0]; |
||||||
| 113 | $smarty->assign("origin", $origin); |
||||||
| 114 | |||||||
| 115 | $proxies = array_reverse($proxies); |
||||||
| 116 | $trust = true; |
||||||
| 117 | global $rfc1918ips; |
||||||
| 118 | |||||||
| 119 | foreach ($proxies as $proxynum => $p) { |
||||||
| 120 | $p2 = trim($p); |
||||||
| 121 | $smartyproxies[$smartyproxiesindex]['ip'] = $p2; |
||||||
| 122 | |||||||
| 123 | // get data on this IP. |
||||||
| 124 | $trusted = $xffTrustProvider->isTrusted($p2); |
||||||
| 125 | $ipisprivate = ipInRange($rfc1918ips, $p2); |
||||||
| 126 | |||||||
| 127 | if (!$ipisprivate) { |
||||||
| 128 | $iprdns = $rdnsProvider->getRdns($p2); |
||||||
| 129 | $iplocation = $locationProvider->getIpLocation($p2); |
||||||
| 130 | } |
||||||
| 131 | else { |
||||||
| 132 | // this is going to fail, so why bother trying? |
||||||
| 133 | $iprdns = false; |
||||||
| 134 | $iplocation = false; |
||||||
| 135 | } |
||||||
| 136 | |||||||
| 137 | // current trust chain status BEFORE this link |
||||||
| 138 | $pretrust = $trust; |
||||||
| 139 | |||||||
| 140 | // is *this* link trusted? |
||||||
| 141 | $smartyproxies[$smartyproxiesindex]['trustedlink'] = $trusted; |
||||||
| 142 | |||||||
| 143 | // current trust chain status AFTER this link |
||||||
| 144 | $trust = $trust & $trusted; |
||||||
| 145 | if ($pretrust && $p2 == $origin) { |
||||||
| 146 | $trust = true; |
||||||
| 147 | } |
||||||
| 148 | $smartyproxies[$smartyproxiesindex]['trust'] = $trust; |
||||||
| 149 | |||||||
| 150 | $smartyproxies[$smartyproxiesindex]['rdnsfailed'] = $iprdns === false; |
||||||
| 151 | $smartyproxies[$smartyproxiesindex]['rdns'] = $iprdns; |
||||||
| 152 | $smartyproxies[$smartyproxiesindex]['routable'] = !$ipisprivate; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 153 | |||||||
| 154 | $smartyproxies[$smartyproxiesindex]['location'] = $iplocation; |
||||||
| 155 | |||||||
| 156 | if ($iprdns == $p2 && $ipisprivate == false) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 157 | $smartyproxies[$smartyproxiesindex]['rdns'] = null; |
||||||
| 158 | } |
||||||
| 159 | |||||||
| 160 | $smartyproxies[$smartyproxiesindex]['showlinks'] = (!$trust || $p2 == $origin) && !$ipisprivate; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 161 | |||||||
| 162 | $smartyproxiesindex++; |
||||||
| 163 | } |
||||||
| 164 | |||||||
| 165 | $smarty->assign("proxies", $smartyproxies); |
||||||
| 166 | } |
||||||
| 167 | } |
||||||
| 168 | |||||||
| 169 | global $defaultRequestStateKey; |
||||||
| 170 | |||||||
| 171 | // TODO: remove me and replace with call in the template directly |
||||||
| 172 | $smarty->assign("isprotected", $request->isProtected()); |
||||||
|
0 ignored issues
–
show
The method
isProtected() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 173 | |||||||
| 174 | $smarty->assign("defaultstate", $defaultRequestStateKey); |
||||||
| 175 | $smarty->assign("requeststates", $availableRequestStates); |
||||||
| 176 | |||||||
| 177 | try { |
||||||
| 178 | $spoofs = $antispoofProvider->getSpoofs($request->getName()); |
||||||
| 179 | } |
||||||
| 180 | catch (Exception $ex) { |
||||||
| 181 | $spoofs = $ex->getMessage(); |
||||||
| 182 | } |
||||||
| 183 | |||||||
| 184 | $smarty->assign("spoofs", $spoofs); |
||||||
| 185 | |||||||
| 186 | // START LOG DISPLAY |
||||||
| 187 | |||||||
| 188 | $logs = Logger::getRequestLogsWithComments($request->getId(), $request->getDatabase()); |
||||||
| 189 | $requestLogs = array(); |
||||||
| 190 | |||||||
| 191 | if (trim($request->getComment()) !== "") { |
||||||
|
0 ignored issues
–
show
The method
getComment() does not exist on DataObject. It seems like you code against a sub-type of DataObject such as Comment or Log or Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 192 | $requestLogs[] = array( |
||||||
| 193 | 'type' => 'comment', |
||||||
| 194 | 'security' => 'user', |
||||||
| 195 | 'userid' => null, |
||||||
| 196 | 'user' => $request->getName(), |
||||||
| 197 | 'entry' => null, |
||||||
| 198 | 'time' => $request->getDate(), |
||||||
|
0 ignored issues
–
show
The method
getDate() does not exist on DataObject. Did you maybe mean getDatabase()?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 199 | 'canedit' => false, |
||||||
| 200 | 'id' => $request->getId(), |
||||||
| 201 | 'comment' => $request->getComment(), |
||||||
| 202 | ); |
||||||
| 203 | } |
||||||
| 204 | |||||||
| 205 | $namecache = array(); |
||||||
| 206 | |||||||
| 207 | $editableComments = false; |
||||||
| 208 | if (User::getCurrent()->isAdmin() || User::getCurrent()->isCheckuser()) { |
||||||
| 209 | $editableComments = true; |
||||||
| 210 | } |
||||||
| 211 | |||||||
| 212 | foreach ($logs as $entry) { |
||||||
| 213 | // both log and comment have a 'user' field |
||||||
| 214 | if (!array_key_exists($entry->getUser(), $namecache)) { |
||||||
| 215 | $namecache[$entry->getUser()] = $entry->getUserObject(); |
||||||
| 216 | } |
||||||
| 217 | |||||||
| 218 | if ($entry instanceof Comment) { |
||||||
| 219 | $requestLogs[] = array( |
||||||
| 220 | 'type' => 'comment', |
||||||
| 221 | 'security' => $entry->getVisibility(), |
||||||
| 222 | 'user' => $namecache[$entry->getUser()]->getUsername(), |
||||||
| 223 | 'userid' => $entry->getUser() == -1 ? null : $entry->getUser(), |
||||||
| 224 | 'entry' => null, |
||||||
| 225 | 'time' => $entry->getTime(), |
||||||
| 226 | 'canedit' => ($editableComments || $entry->getUser() == User::getCurrent()->getId()), |
||||||
| 227 | 'id' => $entry->getId(), |
||||||
| 228 | 'comment' => $entry->getComment(), |
||||||
| 229 | ); |
||||||
| 230 | } |
||||||
| 231 | |||||||
| 232 | if ($entry instanceof Log) { |
||||||
| 233 | $requestLogs[] = array( |
||||||
| 234 | 'type' => 'log', |
||||||
| 235 | 'security' => 'user', |
||||||
| 236 | 'userid' => $entry->getUser() == -1 ? null : $entry->getUser(), |
||||||
| 237 | 'user' => $namecache[$entry->getUser()]->getUsername(), |
||||||
| 238 | 'entry' => Logger::getLogDescription($entry), |
||||||
| 239 | 'time' => $entry->getTimestamp(), |
||||||
| 240 | 'canedit' => false, |
||||||
| 241 | 'id' => $entry->getId(), |
||||||
| 242 | 'comment' => $entry->getComment(), |
||||||
| 243 | ); |
||||||
| 244 | } |
||||||
| 245 | } |
||||||
| 246 | |||||||
| 247 | $smarty->assign("requestLogs", $requestLogs); |
||||||
| 248 | |||||||
| 249 | |||||||
| 250 | // START OTHER REQUESTS BY IP AND EMAIL STUFF |
||||||
| 251 | |||||||
| 252 | // Displays other requests from this ip. |
||||||
| 253 | |||||||
| 254 | // assign to user |
||||||
| 255 | $userListQuery = "SELECT username FROM user WHERE status = 'User' or status = 'Admin';"; |
||||||
| 256 | $userListResult = gGetDb()->query($userListQuery); |
||||||
| 257 | $userListData = $userListResult->fetchAll(PDO::FETCH_COLUMN); |
||||||
| 258 | $userListProcessedData = array(); |
||||||
| 259 | foreach ($userListData as $userListItem) { |
||||||
| 260 | $userListProcessedData[] = "\"" . htmlentities($userListItem) . "\""; |
||||||
| 261 | } |
||||||
| 262 | |||||||
| 263 | $userList = '[' . implode(",", $userListProcessedData) . ']'; |
||||||
| 264 | $smarty->assign("jsuserlist", $userList); |
||||||
| 265 | // end: assign to user |
||||||
| 266 | |||||||
| 267 | // TODO: refactor this! |
||||||
| 268 | $createreasons = EmailTemplate::getActiveTemplates(EmailTemplate::CREATED); |
||||||
| 269 | $smarty->assign("createreasons", $createreasons); |
||||||
| 270 | |||||||
| 271 | $declinereasons = EmailTemplate::getActiveTemplates(EmailTemplate::NOT_CREATED); |
||||||
| 272 | $smarty->assign("declinereasons", $declinereasons); |
||||||
| 273 | |||||||
| 274 | $allcreatereasons = EmailTemplate::getAllActiveTemplates(EmailTemplate::CREATED); |
||||||
| 275 | $smarty->assign("allcreatereasons", $allcreatereasons); |
||||||
| 276 | |||||||
| 277 | $alldeclinereasons = EmailTemplate::getAllActiveTemplates(EmailTemplate::NOT_CREATED); |
||||||
| 278 | $smarty->assign("alldeclinereasons", $alldeclinereasons); |
||||||
| 279 | |||||||
| 280 | $allotherreasons = EmailTemplate::getAllActiveTemplates(false); |
||||||
| 281 | $smarty->assign("allotherreasons", $allotherreasons); |
||||||
| 282 | |||||||
| 283 | return $smarty->fetch("request-zoom.tpl"); |
||||||
| 284 | } |
||||||
| 285 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.