Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.51 KB | None | 0 0
  1. html><head><title>FrobozzCo Community Credit Union</title></head>
  2. <body>
  3. <h1>FrobozzCo Community Credit Union</h1>
  4. <h4><i>We're working for GUE</i></h4>
  5. <hr>
  6. <?php
  7.  
  8. $debugmode = 0;
  9. function debug($msg) {
  10.  
  11. global $debugmode;
  12.  
  13. if ($debugmode) {
  14. echo "<h4>$msg</h4>\n";
  15. }
  16. }
  17.  
  18. $thispage = 'FCCU.php';
  19. echo "<form action='$thispage' method='post' name='theform'>\n";
  20. $dbuser = 'fccu';
  21. $dbpass = 'fccubucks';
  22. $dbhost = 'localhost';
  23. $dbname = $dbuser;
  24.  
  25. $PARAM = array_merge($_GET, $_POST);
  26.  
  27. // get username and password from form
  28. if (!$PARAM['id'] || !$PARAM['password']) {
  29. login();
  30. else if(!is_numeric($id)){
  31. login();
  32. }
  33. } else { // otherwise, attempt to authenticate
  34. $id = $PARAM['id'];
  35. $password = $PARAM['password'];
  36.  
  37. $link_id = mysql_connect($dbhost, $dbuser, $dbpass);
  38. mysql_select_db($dbname);
  39.  
  40. $query = $prep->prepare("SELECT * FROM accounts WHERE id = ? AND password = ?";);
  41. debug($query);
  42. $result = $query->execute($id, $password);
  43. $row = mysql_fetch_array($result); // there should be only one row
  44.  
  45. if (!$row) { // auth failure
  46. echo "<p><b>Your ID number and password you entered do not match.</b></p>";
  47. echo "<p>Please try again.</p>";
  48. login();
  49. } else { // this user is authenticated!
  50.  
  51. // store authentication information in this form
  52. echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
  53. echo "<input type=\"hidden\" name=\"password\" value=\"$password\" />\n";
  54.  
  55. banner($row);
  56.  
  57. // perform any requested actions (wire, transfer, withdraw)
  58. if ($PARAM['action'] == 'Transfer Money') {
  59. transfer_funds($id,
  60. $password,
  61. $PARAM['transfer_to'],
  62. $PARAM['transfer_amount']);
  63. } elseif ($PARAM['action'] == 'Wire Money') {
  64. wire_funds($id,
  65. $password,
  66. $PARAM['routing'],
  67. $PARAM['wire_acct'],
  68. $PARAM['wire_amount']);
  69. } elseif ($PARAM['action'] == 'Withdraw Money') {
  70. withdraw_cash($id,
  71. $password,
  72. $PARAM['withdraw_amount']);
  73. }
  74.  
  75. // normal output
  76.  
  77. // account info
  78. $query = "SELECT * FROM accounts WHERE id = $id AND password = '$password'";
  79. $result = mysql_query($query) or die(mysql_error());
  80. $row = mysql_fetch_array($result); // there should be only one row
  81. account_info($row);
  82.  
  83. // get current account list by name
  84. $query = "SELECT first, last FROM accounts ORDER BY last";
  85. $names = mysql_query($query) or die(mysql_error());
  86. account_actions($row, $names);
  87. }
  88.  
  89.  
  90. }
  91. echo "<hr>\n";
  92. echo "Generated by FCCU.php at " . date("l M dS, Y, H:i:s",5678)."<br>";
  93.  
  94. function name_to_id($name) {
  95.  
  96. global $dbhost, $dbuser, $dbpass, $dbname;
  97. $splitname = explode(", ", $name);
  98.  
  99. $link_id = mysql_connect($dbhost, $dbuser, $dbpass);
  100. mysql_select_db($dbname);
  101. $query = "SELECT id FROM accounts WHERE first = '$splitname[1]' AND last = '$splitname[0]'";
  102. $result = mysql_query($query) or die(mysql_error());
  103. $row = mysql_fetch_array($result);
  104. $id = $row[0];
  105.  
  106. return $id;
  107. }
  108.  
  109. function action_error($msg, $error) {
  110.  
  111. echo "<table bgcolor='#ff0000' color='#ffffff' align=center border=1>
  112. <tr><td><center><b>ERROR!</b></center></td></tr>
  113. <tr><td>
  114. <p align='center'>$msg</p>
  115. <p align='center'>Please go back and try again or contact tech support.</p>
  116. <p align='center'><i>args: $error</i></p>
  117. <p align='center'><input type='submit' name='clear' value='Clear Message'></p>
  118.  
  119. </td></tr>
  120. </table>";
  121. }
  122.  
  123. function withdraw_cash($id, $password, $amount) {
  124.  
  125. global $dbhost, $dbuser, $dbpass, $dbname;
  126.  
  127. $amount = floor($amount);
  128.  
  129. $link_id = mysql_connect($dbhost, $dbuser, $dbpass);
  130. mysql_select_db($dbname);
  131.  
  132. $query = "SELECT bal FROM accounts WHERE password = '$password' AND id = $id";
  133. debug("126: ($password) " . $query);
  134. $result = mysql_query($query);
  135.  
  136. $row = mysql_fetch_array($result);
  137. $giver_has = $row[0];
  138.  
  139. if ($amount > 0 && $giver_has >= $amount) {
  140. $giver_has = $giver_has - $amount; // there's a problem here but it's not SQL Injection...
  141. pretend("withdraw cash", $amount);
  142. $query = "UPDATE accounts SET bal = $giver_has WHERE password = '$password' AND id = $id LIMIT 1";
  143. mysql_query($query) or die(mysql_error());
  144. echo "<h2 align='center'>Cash withdrawal of $$amount complete.</h2>
  145. <h3 align='center'>Your cash should be ready in accounting within 45 minutes.</h3>\n";
  146. } else {
  147. action_error("Problem with cash withdrawal!",
  148. "'$id', '$giver_has', '$amount'");
  149. }
  150. }
  151.  
  152.  
  153. function wire_funds($id, $password, $bank, $account, $amount) {
  154.  
  155. global $dbhost, $dbuser, $dbpass, $dbname;
  156.  
  157. $amount = floor($amount);
  158.  
  159. $link_id = mysql_connect($dbhost, $dbuser, $dbpass);
  160. mysql_select_db($dbname);
  161.  
  162. $query = "SELECT bal FROM accounts WHERE password = '$password' AND id = $id";
  163. debug($query);
  164. $result = mysql_query($query);
  165.  
  166. $row = mysql_fetch_array($result);
  167. $giver_has = $row[0];
  168.  
  169. if ($amount > 0 && $giver_has >= $amount && $bank && $account) {
  170. $giver_has = $giver_has - $amount; // there's a problem here but it's not SQL Injection...
  171. pretend("wire money", $amount, $bank, $acct);
  172. $query = "UPDATE accounts SET bal = $giver_has WHERE password = '$password' AND id = $id LIMIT 1";
  173. debug($query);
  174. mysql_query($query) or die(mysql_error());
  175. echo "<h2 align='center'>Wire of $$amount to bank ($bank) account ($account) complete.</h2>\n";
  176. } else {
  177. action_error("Problem with wire fund transfer!",
  178. "'$id', '$amount', '$giver_has', '$bank', '$account'");
  179. }
  180. }
  181.  
  182. function pretend() {
  183.  
  184. return 1;
  185. }
  186.  
  187. function transfer_funds($giver_id, $password, $recipient, $amount) {
  188.  
  189. global $dbhost, $dbuser, $dbpass, $dbname;
  190.  
  191. $amount = floor($amount);
  192. $recipient_id = name_to_id($recipient);
  193.  
  194. $link_id = mysql_connect($dbhost, $dbuser, $dbpass);
  195. mysql_select_db($dbname);
  196.  
  197. $query = "SELECT bal FROM accounts WHERE id = $giver_id OR id = $recipient_id";
  198. debug($query);
  199. $result = mysql_query($query);
  200.  
  201. $row = mysql_fetch_array($result);
  202. $recipient_has = $row[0];
  203. $row = mysql_fetch_array($result);
  204. $giver_has = $row[0];
  205. debug("$giver_has, $recipient_has");
  206.  
  207. if ($amount > 0 && $giver_has >= $amount && $recipient_has) {
  208. $giver_has = $giver_has - $amount; // there's a problem here but it's not SQL Injection...
  209. $recipient_has = $recipient_has + $amount; // does anyone know what it is?
  210. $query = "UPDATE accounts SET bal = $recipient_has WHERE id = $recipient_id LIMIT 1";
  211. debug($query);
  212. mysql_query($query) or die(mysql_error());
  213. $query = "UPDATE accounts SET bal = $giver_has WHERE password = '$password' AND id = $giver_id LIMIT 1";
  214. debug($query);
  215. mysql_query($query) or die(mysql_error());
  216. echo "<h2 align='center'>Transfer of $$amount to $recipient complete.</h2>\n";
  217. } else {
  218. action_error("Problem with employee fund transfer!",
  219. "'$giver_id', '$recipient', '$amount', '$giver_has'");
  220. }
  221. }
  222.  
  223. function account_info($row) {
  224.  
  225. echo "<table border='1' align='center'>
  226. <tr><td colspan='2'><p><center><b>Account Information</b></center></p></td></tr>
  227. <tr><td><b>Account:</b></td><td>$row[0]</td></tr>
  228. <tr><td><b>Balance:</b></td><td>$$row[1]</td></tr>
  229. <tr><td><b>Birthdate:</b></td><td>$row[6]</td></tr>
  230. <tr><td><b>SSN:</b></td><td>$row[5]</td></tr>
  231. <tr><td><b>Phone:</b></td><td>$row[4]</td></tr>
  232. <tr><td><b>Email:</b></td><td>$row[7]@frobozzco.com</td></tr>
  233. </table>\n";
  234. }
  235.  
  236. function account_actions($row, $names) {
  237.  
  238. global $thispage;
  239.  
  240. echo "<table border=1 width='600' align='center'>
  241.  
  242. <tr><td><center><b>Account Actions</b></center></td></tr>
  243.  
  244. <tr><td><center><b>Wire Funds</b></center></td></tr>
  245.  
  246. <tr><td>
  247. <p>To wire funds: enter the amount (in whole dollars), the
  248. receiving bank's <b>routing number</b> and <b>receiving account number</b>,
  249. and press 'Wire Funds!'</p>
  250. Wire amount: $<input name=wire_amount /><br />
  251. Routing Number: <input name=routing /> (e.g. 091000022)<br />
  252. Account Number: <input name=wire_acct /> (e.g. 923884509)<br />
  253. <p align='center'><input type='submit' name='action' value='Wire Money'></p>
  254. <p />
  255. </td></tr>
  256.  
  257. <tr><td><center><b>Transfer Money</b></center></td><tr>
  258.  
  259. <tr><td><p>To transfer money to another FCCU account holder, select the
  260. employee from the drop-down menu below, enter an ammount (in whole dollars)
  261. to transfer, and press 'Transfer Money!'</p>
  262. Transfer Amount: $<input name=transfer_amount /><br />
  263. Transfer To: ";
  264. // create dropdown menu with accounts
  265. echo "<select name='transfer_to' selected='select employee'>\n";
  266. echo "<option value='nobody'>select employee</option>\n";
  267. while ($name = mysql_fetch_array($names)) {
  268. echo "<option value=\"$name[1], $name[0]\">$name[1], $name[0]</option>\n";
  269. }
  270. echo "</select>\n";
  271. echo "<br />
  272. <p align='center'><input type='submit' name='action' value='Transfer Money'></p>
  273. <p />
  274. </td></tr>
  275.  
  276. <tr><td><center><b>Withdraw Cash</b></center></td><tr>
  277.  
  278. <tr><td><p>To withdraw cash, enter an amount (in whole dollars) and press
  279. the 'Withdraw Cash!' button. The cash will be available in the accounting
  280. office within 45 minutes.</p>
  281. Withdraw Amount: $<input name=withdraw_amount /><br />
  282. <p align='center'><input type='submit' name='action' value='Withdraw Money'></p>
  283. <p />
  284. </td></tr>
  285. </table>
  286. \n";
  287.  
  288. }
  289.  
  290. function banner($row) {
  291.  
  292. global $thispage;
  293.  
  294. $fullname = "$row[2] $row[3]";
  295. echo "<table width='100%'><tr><td>
  296. <p align='left'>Welcome, $fullname. (<a href='$thispage'>Log Out</a>)</p>
  297. </td><td>
  298. <p align='right'><i>(If you aren't $fullname, <a href='$thispage'>click here</a>.)</i></p>
  299. </td></tr></table>\n";
  300. echo "<hr>\n";
  301.  
  302.  
  303. }
  304.  
  305. function login() {
  306.  
  307. global $thispage;
  308.  
  309. echo "<p>Enter your <b>account ID</b> and password and click \"submit.\"</p>\n";
  310. echo "<table>\n";
  311. echo "<tr><td>Account ID Number: </td><td><input name='id' cols='10' /></td></tr>\n";
  312. echo "<tr><td>Password (alphanumeric only): </td><td><input name='password' cols='30' /></td></tr>\n";
  313. echo "<tr><td><input type='submit' value='Submit' name='submit'></td><td></td></tr>\n";
  314. echo "</table>\n";
  315.  
  316. }
  317.  
  318. ?>
  319. </form>
  320. <p>Done.</p>
  321. </body>
  322. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement