Advertisement
Guest User

Untitled

a guest
May 30th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.91 KB | None | 0 0
  1. edit_account.php
  2.  
  3.  
  4. <div id="box4" class="box">
  5. <h1 id="heading4" class="heading"><center>Edit Account</center></h1>
  6. <div class="content"> <br />
  7. <?php
  8. include ('login_check.php');
  9. if ($logged_in == 0) {
  10. ?>
  11. You are not allowed to view this page. Please <a href="/login.php">Log
  12. In</a> or <a href="/register.php">Register</a>.
  13. <?php
  14. }
  15.  
  16. else {
  17. ?>
  18. <?php
  19. require 'db_connect.php';
  20.  
  21. session_start();
  22. $user = $_SESSION['username'];
  23. $article = $_GET['art'];
  24.  
  25. $qrybu = "SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'";
  26. $point = mysql_query($qrybu);
  27. $db = mysql_fetch_array ($point);
  28. $regdate = $db['regdate'];
  29. $date = date('m d, Y');
  30. $newdate = $date - $regdate;
  31. $reg_date = $db['reg_date'];
  32. $reg_month = $db['reg_month'];
  33. $date = date('d');
  34. $month = date('m');
  35. $article = $_SESSION['id'];
  36.  
  37.  
  38.  
  39. if($date >= $reg_date)
  40. {
  41.  
  42. if($reg_month != $month)
  43. {
  44. $newedit = "11";
  45.  
  46. }
  47. else
  48. {
  49.  
  50. $newedit = $date - $reg_date;
  51.  
  52. }
  53.  
  54. }
  55. else
  56. {
  57. if($reg_month != $month)
  58. {
  59. if($date >= 11)
  60. {
  61. $newedit = "11";
  62. }
  63. else
  64. {
  65. if($reg_date <= 20)
  66. {
  67.  
  68. $newedit = "11";
  69. }
  70. else
  71. {
  72. $newedit = $date;
  73. }
  74.  
  75.  
  76. }
  77.  
  78. }
  79. else
  80. {
  81.  
  82. $newedit = "1";
  83.  
  84. }
  85.  
  86. }
  87. ?>
  88. <script type="text/javascript">
  89.  
  90.  
  91.  
  92.  
  93. var myConfirm = {
  94. type: "confirm",
  95. title: "Confirm Account Deletion",
  96. text: "Do you really want to delete your account and all your data?",
  97. yes_button: "Yes",
  98. no_button: "No",
  99. yes: function() {
  100. window.location.href="deleteaccount.php?art=<?php echo $article; ?>";
  101.  
  102. },
  103. no: function() {
  104. window.location.href="index.php?id=edit_account&art=<?php echo $article; ?>";
  105.  
  106. }
  107. };
  108.  
  109. </script>
  110.  
  111.  
  112. <?php
  113.  
  114. require 'db_connect.php';
  115.  
  116. $result = mysql_query("SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'");
  117. $myrow = mysql_fetch_array($result);
  118. $error = $_GET['error'];
  119. $url = $myrow['url'];
  120. $url_seal = $myrow['url_seal'];
  121. $seal = $myrow['seal'];
  122. ?>
  123. <center>
  124. Current Insignia<br />
  125. <a href="/index.php?id=update&art=<?php echo $_SESSION['id'];?>">
  126. <?php
  127. if($url_seal == '1') {
  128. ?>
  129. <img src="<?php if ($url == ""){
  130. echo "seals/noseal.jpg";}
  131. else{
  132. echo $url; } ?>" width="50%" height="50%" ALT="Seal" style="border:none;">
  133. <?php } else {
  134. ?>
  135.  
  136.  
  137. <img src="seals/<?php if ($myrow['seal'] == ""){
  138. echo "noseal.jpg";}
  139. else{
  140. echo $myrow['seal']; } ?>" width="50%" height="50%" ALT="Seal" style="border:none;">
  141. <?php
  142. }
  143. ?>
  144.  
  145. </a>
  146. <br />
  147. <br />
  148. *Image name may only contain letters, numbers, spaces, and underscores.
  149. <br />
  150. <?php
  151. if($error == 5) {
  152.  
  153. echo "<br /><br /><font color='#FF0000'>There was an error while trying to upload your file. Please try again.</font><br /><br /><br />";
  154. }
  155.  
  156.  
  157.  
  158.  
  159.  
  160. ?>
  161. <br />
  162. <form enctype="multipart/form-data" action="upload.php" method="POST">
  163. <!-- MAX_FILE_SIZE must precede the file input field -->
  164. <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
  165. <!-- Name of input element determines name in $_FILES array -->
  166. Upload Seal:
  167. <input name="file" type="file" id="file" />
  168. <input type="radio" name="upload" value="file"><br />
  169. <br />
  170. Use URL:
  171. <input name="url" type="text" id="url" />
  172. <input type="radio" name="upload" value="url"><br />
  173. <br />
  174. <input type="submit" value="Upload" />
  175. </form>
  176. </center>
  177. <br />
  178. <br />
  179. <?php include("db_connect.php"); ?>
  180. <?php
  181. $result = mysql_query("SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'");
  182. $myrow = mysql_fetch_array($result);
  183. $decree = $myrow['city_decree'];
  184. $current_tax = $myrow['tax_rate'];
  185. $current_continent = $myrow['continent'];
  186. $current_government = $myrow['government'];
  187. $current_idealism = $myrow['idealism'];
  188. $current_capital = $myrow['capital'];
  189. $current_alliance = $myrow['alliance'];
  190. $last_edit_date = $myrow['last_edit_date'];
  191. $last_edit_day = $myrow['last_edit_day'];
  192. $error = $_GET['error'];
  193. $idday = $myrow['iddays'];
  194. $allow_admin = $myrow['admin_email'];
  195. $peace_mode = $myrow['peace_mode'];
  196. $peace_mode_day = $myrow['peace_mode_day'];
  197.  
  198. $nowday = mysql_query('SELECT * FROM `users` WHERE `iddays` < DATE_SUB(NOW, INTERVAL 5 DAY)');
  199.  
  200. if($nowday >= $idday) {
  201. $govbox = "<select name='government' id='government'>
  202. <option value='Authoritarian'>Authoritarian</option>
  203. <option value='Republic'>Republic</option>
  204. <option value='Oligarchy'>Oligarchy</option>
  205. <option value='Communism'>Communism</option>
  206. <option value='Noocracy'>Noocracy</option>
  207. </select>";
  208. } else {
  209. $govbox = "You have changed either your government or idealism preferences in the last 5 days.";
  210. }
  211.  
  212. if($nowday >= $idday) {
  213. $idbox = "<select name='idealism' id='idealism'>
  214. <option value='Aesthetics'>Aesthetics</option>
  215. <option value='Ethics'>Ethics</option>
  216. <option value='Logic'>Logic</option>
  217. <option value='Metaphysics'>Metaphysics</option>
  218. <option value='Physique'>Physique</option>
  219. <option value='Conservation'>Conservation</option>
  220. </select>";
  221. } else {
  222. $idbox = "You have changed either your government or idealism preferences in the last 5 days.";
  223. }
  224.  
  225. $day = date('z');
  226.  
  227. $days_left = ($day - $peace_mode_day);
  228. $day_left = (5 - $days_left);
  229.  
  230. if($days_left <= 5) {
  231.  
  232. $peace = "<input type='hidden' value='".$peace_mode."' name='peace_mode'>You have changed your Peace Preferences within the past 5 days, you must wait ".$day_left." more days to change this preference.";
  233. } else {
  234.  
  235. if($peace_mode == 1) {
  236. $peace = "<select name='peace_mode'><option value='1'>Your planet is being protected by the Universal Federation. No outside entities may assault your planet.</option>
  237. <option value='0'>Your planet has defenses, but is still susceptible to attack.</option></select>";
  238. } else {
  239.  
  240. $peace = "<select name='peace_mode'><option value='0'>Your planet has some defenses, but is still susceptible to attack.</option>
  241. <option value='1'>Your planet is being protected by the Universal Federation. No outside entities may assault your planet.</option></select>";
  242. }
  243.  
  244. if($allow_admin == yes) {
  245. $checked = "checked";
  246. } else {
  247. $checked = "";
  248. }
  249.  
  250. }
  251. ?>
  252. <center>
  253. Last Edit Date: <?php echo $last_edit_date; ?>
  254. </center>
  255. <?php
  256. if($error == 1) {
  257.  
  258. echo "<font color='#FF0000'>Error - Your new passwords dont match.</font><br /><br /><br />";
  259. }
  260.  
  261. if($error == 2) {
  262.  
  263. echo "<font color='#FF0000'>Error - Your old password does not match with your current password.</font><br /><br /><br />";
  264. }
  265.  
  266. if($error == 15) {
  267.  
  268. echo "<br /><br /><font color='#FF0000'>You have changed your Peace Preferences within the past 5 days, you must wait ".$day_left." more days to change this preference.</font><br /><br /><br />";
  269. }
  270.  
  271.  
  272. if($error == 17) {
  273.  
  274. echo "<br /><br /><font color='#FF0000'>You can not join the Admin affiliation.</font><br /><br /><br />";
  275. }
  276.  
  277. ?>
  278. <table width="100%">
  279. <form enctype="multipart/form-data" action="index.php?id=update_pass&art=<?php echo $_SESSION['id'];?>" method="post">
  280.  
  281. <tr>
  282. <td width="40%" align="left" valign="top">Old Password:</td>
  283. <td width="" align="left" valign="top"><input type="password" name="old_passwd" id="old_passwd"></td>
  284. </tr>
  285. <tr>
  286. <td width="40%" align="left" valign="top">New Password:</td>
  287. <td width="" align="left" valign="top"><input type="password" name="passwd" id="passwd"></td>
  288. </tr>
  289. <tr>
  290. <td width="40%" align="left" valign="top">Confirm New Password:</td>
  291. <td width="" align="left" valign="top"><input type="password" name="passwd_confirm" id="passwd_confirm"></td>
  292. </tr>
  293. <tr><td></td><td>
  294. <input type="hidden" value="<?php echo $myrow['id']; ?>" name="id" id="id">
  295. <input type="submit" name="Edit" value="Save Password">
  296. </td></tr>
  297. </form>
  298. </table>
  299. <br />
  300.  
  301. <table width="100%">
  302. <form enctype="multipart/form-data" action="index.php?id=update_account&art=<?php echo $_SESSION['id'];?>" method="post">
  303.  
  304. <tr>
  305. <td width="40%" align="left" valign="top">Email:</td>
  306. <td width="" align="left" valign="top"><input type="text" value="<?php echo $myrow['email']; ?>" name="email" id="email"></td>
  307. </tr>
  308. <tr>
  309. <td width="40%" align="left" valign="top">Planet Description:</td>
  310. <td width="" align="left" valign="top"><TEXTAREA NAME="decree" COLS=40 ROWS=6>
  311. <?php echo $decree; ?>
  312. </TEXTAREA></td>
  313. </tr>
  314. <tr>
  315.  
  316.  
  317. <td width="40%" align="left" valign="top">Affiliation:</td>
  318. <?php
  319.  
  320.  
  321. $usersql = mysql_query("SELECT * FROM users");
  322.  
  323. $alliancesql = "DELETE * FROM alliance";
  324.  
  325. $query = mysql_query($alliancesql);
  326.  
  327. while($row = mysql_fetch_array($usersql))
  328. {
  329.  
  330.  
  331.  
  332. $alliance = $row['alliance'];
  333.  
  334. $query = mysql_query("SELECT * FROM users WHERE alliance='".$alliance."'") or die(mysql_error());
  335. $row = mysql_num_rows($query);
  336.  
  337. $alliance_count = $row;
  338.  
  339. $query = mysql_query("SELECT SUM(city_strength) as sum_total FROM users WHERE alliance='".$alliance."'") or die(mysql_error());
  340. $row = mysql_fetch_object($query);
  341.  
  342. $alliance_strength = $row->sum_total;
  343.  
  344. $alliance_score = round(($alliance_strength / 100000) + ($alliance_count / 10), 3);
  345. $query = mysql_query("SELECT * FROM alliance WHERE alliance='".$alliance."'") or die(mysql_error());
  346. $number = mysql_num_rows($query);
  347.  
  348. $str = strlen($alliance_score);
  349.  
  350. if($str < 10) {
  351. if($str == 9) {
  352. $alliance_score = "0".$alliance_score;
  353. } else {
  354. if($str == 8) {
  355. $alliance_score = "00".$alliance_score;
  356. } else {
  357. if($str == 7) {
  358. $alliance_score = "000".$alliance_score;
  359. } else {
  360. if($str == 6) {
  361. $alliance_score = "0000".$alliance_score;
  362. } else {
  363. if($str == 5) {
  364. $alliance_score = "00000".$alliance_score;
  365. } else {
  366. $alliance_score = "000000".$alliance_score;
  367. }}}}}
  368. } else {
  369. $alliance_score = $alliance_score;
  370. }
  371.  
  372.  
  373. if($alliance != "Admin" && $alliance != "None" && $alliance != "") {
  374.  
  375. if($number == 0) {
  376.  
  377. $sqldd = "INSERT INTO alliance SET alliance='".$alliance."', alliance_number='$alliance_count', alliance_score='$alliance_score', alliance_strength='$alliance_strength'";
  378.  
  379. $querydd=mysql_query($sqldd);
  380. } else {
  381.  
  382.  
  383. $sqldd = "UPDATE alliance SET alliance_number='$alliance_count', alliance_score='$alliance_score', alliance_strength='$alliance_strength' WHERE alliance='".$alliance."'";
  384.  
  385. $querydd=mysql_query($sqldd);
  386.  
  387. }
  388.  
  389. } else {
  390.  
  391. $sqldd = "DELETE * FROM alliance WHERE alliance='Admin'";
  392.  
  393.  
  394. $sqldd = "DELETE * FROM alliance WHERE alliance=''";
  395.  
  396. $sqldd = "DELETE * FROM alliance WHERE alliance='None'";
  397. }
  398. }
  399.  
  400.  
  401.  
  402.  
  403.  
  404. $result = mysql_query("SELECT * FROM alliance ORDER BY alliance_score DESC LIMIT 0, 10");
  405. $row = mysql_fetch_array($result);
  406.  
  407.  
  408.  
  409.  
  410. ?>
  411. <script>
  412. function checkForOther(obj) {
  413. if (!document.layers) {
  414. var txt = document.getElementById("alliance");
  415. if (obj.value == "other") {
  416. txt.style.display = "inline";
  417. // gives the text field the name of the drop-down, for easy processing
  418. txt.name = "alliance";
  419. obj.name = "";
  420. } else {
  421. txt.style.display = "none";
  422. txt.name = "";
  423. obj.name = "alliance";
  424. }
  425. }
  426. }
  427. </script>
  428.  
  429. <td width="" align="left" valign="top">
  430.  
  431. <select name="alliance" onchange="checkForOther(this)">
  432. <option value="<?php echo $current_alliance; ?>"><?php echo $current_alliance; ?></option>
  433. <?php
  434. while($row = mysql_fetch_array($result))
  435. {
  436. $alliance = $row['alliance'];
  437. ?>
  438. <option value="<?php echo $alliance; ?>"><?php echo $alliance; ?></option>
  439. <?php
  440.  
  441. }
  442. ?>
  443. <option value="other">Specify Other</option>
  444. </select><br />
  445. <input type="text" id="alliance" style="display:none;"> </td>
  446. </tr>
  447. <tr>
  448. <td width="40%" align="left" valign="top">Capital City:</td>
  449. <td width="" align="left" valign="top"><input type="text" value="<?php echo $myrow['capital']; ?>" name="capital" id="capital"></td>
  450. </tr>
  451. <tr>
  452. <td width="40%" align="left" valign="top">Galaxy:</td>
  453. <td width="" align="left" valign="top"><select name="continent">
  454. <option value="<?php echo $current_continent; ?>"><?php echo $current_continent; ?></option>
  455. <option value="Andromeda">Andromeda</option>
  456. <option value="Corvus">Corvus</option>
  457. <option value="Draco">Draco</option>
  458. <option value="Orion">Orion</option>
  459. <option value="Phoenix">Phoenix</option>
  460. <option value="Scorpius">Scorpius</option>
  461. <option value="Taurus">Taurus</option>
  462. </select></td>
  463. </tr>
  464. <tr>
  465. <td width="40%" align="left" valign="top">Government:</td>
  466. <td width="" align="left" valign="top">
  467. <?php echo $govbox; ?>
  468. <tr>
  469. <td width="40%" align="left" valign="top">Idealism:</td>
  470. <td width="" align="left" valign="top">
  471. <?php echo $idbox ?></td>
  472. </tr>
  473. <tr>
  474. <td width="40%" align="left" valign="top">Tax Rate:</td>
  475. <td width="" align="left" valign="top"><select name="tax_rate">
  476. <option value="<?php echo $current_tax; ?>"><?php echo $current_tax; ?>%</option>
  477. <option value="10">10%</option>
  478. <option value="12">12%</option>
  479. <option value="14">14%</option>
  480. <option value="16">16%</option>
  481. <option value="18">18%</option>
  482. <option value="20">20%</option>
  483. <option value="22">22%</option>
  484. <option value="24">24%</option>
  485. <option value="26">26%</option>
  486. <option value="28">28%</option>
  487. </select></td>
  488. </tr>
  489. <tr>
  490. <td width="40%" align="left" valign="top">Peace Preferences:</td>
  491. <td width="" align="left" valign="top">
  492. <?php echo $peace; ?>
  493. </td>
  494. </tr>
  495. <tr>
  496. <td width="40%" align="left" valign="top">Allow Admin to email you? (Recommended)</td>
  497. <td width="" align="left" valign="top"><input type="checkbox" name="admin_email" value="yes" <?php echo $checked; ?> /> </td>
  498. </tr>
  499. <tr><td></td><td>
  500. <input type="hidden" value="<?php echo $myrow['id']; ?>" name="id" id="id">
  501. <input type="submit" name="Edit" value="Save ">
  502. </td></tr>
  503. </form>
  504. </table>
  505.  
  506. <?php
  507. }
  508.  
  509. ?>
  510. </div></div>
  511.  
  512. update_account.php
  513.  
  514. <?php
  515.  
  516.  
  517.  
  518. // database connect script.
  519.  
  520.  
  521.  
  522. require 'db_connect.php';
  523.  
  524.  
  525.  
  526.  
  527. ?>
  528. <center>
  529. <?php
  530.  
  531. ?>
  532. <?php
  533.  
  534. // database connect script.
  535.  
  536. require 'db_connect.php';
  537. $qrybu = "SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'";
  538. $point = mysql_query($qrybu);
  539. $db = mysql_fetch_array($point);
  540.  
  541. $email = $_POST['email'];
  542. $decree = $_POST['decree'];
  543. $continent = $_POST['continent'];
  544. $government = $_POST['government'];
  545. $idealism = $_POST['idealism'];
  546. $alliance = $_POST['alliance'];
  547. $capital = $_POST['capital'];
  548.  
  549. $current_government = $db['government'];
  550. $current_idealism = $db['idealism'];
  551. $tax_rate = $_POST['tax_rate'];
  552. $admin_email = $_POST['admin_email'];
  553. $id = $db['id'];
  554. $last_edit_date = $db['last_edit_date'];
  555. $last_edit_day = $db['last_edit_day'];
  556. $edit_day_all = $db['edit_day_all'];
  557. $date = date('d m, Y');
  558. $day = date('d');
  559. $article = $_GET['art'];
  560. $happiness = $db['happiness'];
  561. $old_tax_rate = $db['tax_rate'];
  562. $old_alliance = $db['alliance'];
  563. $city_strength = $db['city_strength'];
  564. $pass = $db['password'];
  565. $peace_modes = $_POST['peace_mode'];
  566.  
  567. $peace_mode_day = $db['peace_mode_day'];
  568. $peace_mode = $db['peace_mode'];
  569.  
  570.  
  571. include 'config_all.php';
  572.  
  573. // Replace bad characters //
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580. $clean_string = preg_replace($allowed_char_pattern, "", $alliance);
  581.  
  582. $alliance = $clean_string;
  583.  
  584.  
  585.  
  586. $new_alliance = $alliance;
  587.  
  588.  
  589.  
  590.  
  591.  
  592. if($new_alliance == 'Admin') {
  593.  
  594. ?>
  595. <script type="text/javascript">
  596. <!--
  597. window.location = "/index.php?id=edit_account&art=<?php echo $_SESSION['id'];?>&error=17"
  598. //-->
  599. </script>
  600.  
  601. <?php
  602.  
  603. $new_alliance = $old_alliance;
  604.  
  605. }
  606.  
  607.  
  608.  
  609. $date = date('d m, Y');
  610. $day = date('z');
  611.  
  612. $days_left = ($day - $peace_mode_day);
  613.  
  614.  
  615. if($peace_modes == $peace_mode) {
  616. $days = $peace_mode_day;
  617. } else {
  618. $day_left = (5 - $days_left);
  619. if($days_left <= 5) {
  620. $days = $peace_mode_day;
  621. } else {
  622. $days = $day;
  623. }
  624.  
  625. }
  626.  
  627. if($government != $current_government)
  628. {
  629. $sql = "UPDATE users SET iddays=NOW() WHERE id='".$_SESSION['id']."'";
  630.  
  631. $query=mysql_query($sql);
  632. }
  633. if($idealism != $current_idealism)
  634. {
  635. $sql = "UPDATE users SET iddays=NOW() WHERE id='".$_SESSION['id']."'";
  636. }
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643. if($days_left > 5) {
  644.  
  645. $sql = "UPDATE users SET peace_mode='$peace_modes', admin_email='$admin_email', peace_mode_day='$days', alliance='$new_alliance', last_edit_date='$date', last_edit_day='$day', email='$email', capital='$capital', continent='$continent', government='$government', idealism='$idealism', tax_rate='$tax_rate', city_decree='$decree' WHERE id='".$_SESSION['id']."'";
  646.  
  647. $query=mysql_query($sql);
  648.  
  649. } else {
  650.  
  651.  
  652.  
  653.  
  654. $sql = "UPDATE users SET admin_email='$admin_email', peace_mode_day='$days', alliance='$new_alliance', last_edit_date='$date', last_edit_day='$day', email='$email', capital='$capital', continent='$continent', government='$government', idealism='$idealism', tax_rate='$tax_rate', city_decree='$decree' WHERE id='".$_SESSION['id']."'";
  655.  
  656. $query=mysql_query($sql);
  657.  
  658. }
  659.  
  660.  
  661.  
  662.  
  663. ?>
  664.  
  665. <script type="text/javascript">
  666. <!--
  667. window.location = "/index.php?id=edit_account&art=<?php echo $_SESSION['id'];?>"
  668. //-->
  669. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement