mdaniels5757 /
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 | // Get all the classes. |
||||||
| 16 | require_once 'config.inc.php'; |
||||||
| 17 | require_once 'functions.php'; |
||||||
| 18 | |||||||
| 19 | require_once 'includes/PdoDatabase.php'; |
||||||
| 20 | require_once 'includes/SmartyInit.php'; |
||||||
| 21 | |||||||
| 22 | // Check to see if the database is unavailable. |
||||||
| 23 | // Uses the true variable as the public uses this page. |
||||||
| 24 | if (Offline::isOffline()) { |
||||||
| 25 | echo Offline::getOfflineMessage(true); |
||||||
| 26 | die(); |
||||||
| 27 | } |
||||||
| 28 | |||||||
| 29 | $antispoofProvider = new $antispoofProviderClass(); |
||||||
| 30 | $xffTrustProvider = new $xffTrustProviderClass($squidIpList); |
||||||
| 31 | $database = gGetDb(); |
||||||
| 32 | |||||||
| 33 | // Display the header of the interface. |
||||||
| 34 | BootstrapSkin::displayPublicHeader(); |
||||||
| 35 | |||||||
| 36 | if (isset($_GET['action']) && $_GET['action'] == "confirm") { |
||||||
| 37 | try { |
||||||
| 38 | if (!isset($_GET['id']) || !isset($_GET['si'])) { |
||||||
| 39 | BootstrapSkin::displayAlertBox( |
||||||
| 40 | "Please check the link you received", |
||||||
| 41 | "alert-error", |
||||||
| 42 | "Missing parameters", |
||||||
| 43 | true, |
||||||
| 44 | false); |
||||||
| 45 | |||||||
| 46 | BootstrapSkin::displayPublicFooter(); |
||||||
| 47 | die(); |
||||||
| 48 | } |
||||||
| 49 | |||||||
| 50 | $request = Request::getById($_GET['id'], $database); |
||||||
| 51 | |||||||
| 52 | if ($request === false) { |
||||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||||
| 53 | BootstrapSkin::displayAlertBox( |
||||||
| 54 | $smarty->fetch('request/request-not-found.tpl'), |
||||||
| 55 | "alert-error", |
||||||
| 56 | "Request not found", |
||||||
| 57 | true, |
||||||
| 58 | false); |
||||||
| 59 | BootstrapSkin::displayPublicFooter(); |
||||||
| 60 | die(); |
||||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | if ($request->getEmailConfirm() == "Confirmed") { |
||||||
|
0 ignored issues
–
show
The method
getEmailConfirm() 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...
|
|||||||
| 64 | $smarty->display("request/email-confirmed.tpl"); |
||||||
| 65 | BootstrapSkin::displayPublicFooter(); |
||||||
| 66 | return; |
||||||
| 67 | } |
||||||
| 68 | |||||||
| 69 | $database->transactionally(function() use($database, $request, $smarty) |
||||||
| 70 | { |
||||||
| 71 | if ($request === false) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 72 | throw new TransactionException($smarty->fetch('request/request-not-found.tpl'), "Ooops!"); |
||||||
| 73 | } |
||||||
| 74 | |||||||
| 75 | $request->confirmEmail($_GET['si']); |
||||||
|
0 ignored issues
–
show
The method
confirmEmail() 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...
|
|||||||
| 76 | $request->save(); |
||||||
| 77 | |||||||
| 78 | Logger::emailConfirmed($database, $request); |
||||||
| 79 | }); |
||||||
| 80 | |||||||
| 81 | $smarty->display("request/email-confirmed.tpl"); |
||||||
| 82 | |||||||
| 83 | $request = Request::getById($_GET['id'], $database); |
||||||
| 84 | Notification::requestReceived($request); |
||||||
| 85 | |||||||
| 86 | BootstrapSkin::displayPublicFooter(); |
||||||
| 87 | } |
||||||
| 88 | catch (Exception $ex) { |
||||||
| 89 | BootstrapSkin::displayAlertBox($ex->getMessage(), "alert-error", "Unknown error", true, false); |
||||||
| 90 | BootstrapSkin::displayPublicFooter(); |
||||||
| 91 | } |
||||||
| 92 | } |
||||||
| 93 | else { |
||||||
| 94 | if ($_SERVER['REQUEST_METHOD'] == "POST") { |
||||||
| 95 | $errorEncountered = false; |
||||||
| 96 | |||||||
| 97 | $request = new Request(); |
||||||
| 98 | $request->setDatabase($database); |
||||||
| 99 | |||||||
| 100 | $request->setName($_POST['name']); |
||||||
| 101 | $request->setEmail($_POST['email']); |
||||||
| 102 | $request->setComment($_POST['comments']); |
||||||
| 103 | $request->setIp($_SERVER['REMOTE_ADDR']); |
||||||
| 104 | |||||||
| 105 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
||||||
| 106 | $request->setForwardedIp($_SERVER['HTTP_X_FORWARDED_FOR']); |
||||||
| 107 | } |
||||||
| 108 | |||||||
| 109 | if (isset($_SERVER['HTTP_USER_AGENT'])) { |
||||||
| 110 | $request->setUserAgent($_SERVER['HTTP_USER_AGENT']); |
||||||
| 111 | } |
||||||
| 112 | |||||||
| 113 | $validationHelper = new RequestValidationHelper(new BanHelper(), $request, $_POST['emailconfirm']); |
||||||
| 114 | |||||||
| 115 | // These are arrays of ValidationError. |
||||||
| 116 | $nameValidation = $validationHelper->validateName(); |
||||||
| 117 | $emailValidation = $validationHelper->validateEmail(); |
||||||
| 118 | $otherValidation = $validationHelper->validateOther(); |
||||||
| 119 | |||||||
| 120 | $validationErrors = array_merge($nameValidation, $emailValidation, $otherValidation); |
||||||
| 121 | |||||||
| 122 | if (count($validationErrors) > 0) { |
||||||
| 123 | foreach ($validationErrors as $validationError) { |
||||||
| 124 | BootstrapSkin::displayAlertBox( |
||||||
| 125 | $smarty->fetch("validation/" . $validationError->getErrorCode() . ".tpl"), |
||||||
| 126 | "alert-error"); |
||||||
| 127 | } |
||||||
| 128 | |||||||
| 129 | $smarty->display("request/request-form.tpl"); |
||||||
| 130 | } |
||||||
| 131 | else if ($enableEmailConfirm == 1) { |
||||||
| 132 | $request->generateEmailConfirmationHash(); |
||||||
| 133 | |||||||
| 134 | $database->transactionally(function() use($request) |
||||||
| 135 | { |
||||||
| 136 | $request->save(); |
||||||
| 137 | |||||||
| 138 | // checksum depends on the ID, so we have to save again! |
||||||
| 139 | $request->updateChecksum(); |
||||||
| 140 | $request->save(); |
||||||
| 141 | }); |
||||||
| 142 | |||||||
| 143 | $request->sendConfirmationEmail(); |
||||||
| 144 | |||||||
| 145 | $smarty->display("request/email-confirmation.tpl"); |
||||||
| 146 | } |
||||||
| 147 | else { |
||||||
| 148 | $request->setEmailConfirm(0); // Since it can't be null |
||||||
| 149 | $database->transactionally(function() use($request) |
||||||
| 150 | { |
||||||
| 151 | $request->save(); |
||||||
| 152 | $request->updateChecksum(); |
||||||
| 153 | $request->save(); |
||||||
| 154 | }); |
||||||
| 155 | $smarty->display("request/email-confirmed.tpl"); |
||||||
| 156 | Notification::requestReceived($request); |
||||||
| 157 | BootstrapSkin::displayPublicFooter(); |
||||||
| 158 | } |
||||||
| 159 | |||||||
| 160 | BootstrapSkin::displayPublicFooter(); |
||||||
| 161 | } |
||||||
| 162 | else { |
||||||
| 163 | $smarty->display("request/request-form.tpl"); |
||||||
| 164 | BootstrapSkin::displayPublicFooter(); |
||||||
| 165 | } |
||||||
| 166 | } |
||||||
| 167 |