Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- edit_account.php
- <div id="box4" class="box">
- <h1 id="heading4" class="heading"><center>Edit Account</center></h1>
- <div class="content"> <br />
- <?php
- include ('login_check.php');
- if ($logged_in == 0) {
- ?>
- You are not allowed to view this page. Please <a href="/login.php">Log
- In</a> or <a href="/register.php">Register</a>.
- <?php
- }
- else {
- ?>
- <?php
- require 'db_connect.php';
- session_start();
- $user = $_SESSION['username'];
- $article = $_GET['art'];
- $qrybu = "SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'";
- $point = mysql_query($qrybu);
- $db = mysql_fetch_array ($point);
- $regdate = $db['regdate'];
- $date = date('m d, Y');
- $newdate = $date - $regdate;
- $reg_date = $db['reg_date'];
- $reg_month = $db['reg_month'];
- $date = date('d');
- $month = date('m');
- $article = $_SESSION['id'];
- if($date >= $reg_date)
- {
- if($reg_month != $month)
- {
- $newedit = "11";
- }
- else
- {
- $newedit = $date - $reg_date;
- }
- }
- else
- {
- if($reg_month != $month)
- {
- if($date >= 11)
- {
- $newedit = "11";
- }
- else
- {
- if($reg_date <= 20)
- {
- $newedit = "11";
- }
- else
- {
- $newedit = $date;
- }
- }
- }
- else
- {
- $newedit = "1";
- }
- }
- ?>
- <script type="text/javascript">
- var myConfirm = {
- type: "confirm",
- title: "Confirm Account Deletion",
- text: "Do you really want to delete your account and all your data?",
- yes_button: "Yes",
- no_button: "No",
- yes: function() {
- window.location.href="deleteaccount.php?art=<?php echo $article; ?>";
- },
- no: function() {
- window.location.href="index.php?id=edit_account&art=<?php echo $article; ?>";
- }
- };
- </script>
- <?php
- require 'db_connect.php';
- $result = mysql_query("SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'");
- $myrow = mysql_fetch_array($result);
- $error = $_GET['error'];
- $url = $myrow['url'];
- $url_seal = $myrow['url_seal'];
- $seal = $myrow['seal'];
- ?>
- <center>
- Current Insignia<br />
- <a href="/index.php?id=update&art=<?php echo $_SESSION['id'];?>">
- <?php
- if($url_seal == '1') {
- ?>
- <img src="<?php if ($url == ""){
- echo "seals/noseal.jpg";}
- else{
- echo $url; } ?>" width="50%" height="50%" ALT="Seal" style="border:none;">
- <?php } else {
- ?>
- <img src="seals/<?php if ($myrow['seal'] == ""){
- echo "noseal.jpg";}
- else{
- echo $myrow['seal']; } ?>" width="50%" height="50%" ALT="Seal" style="border:none;">
- <?php
- }
- ?>
- </a>
- <br />
- <br />
- *Image name may only contain letters, numbers, spaces, and underscores.
- <br />
- <?php
- if($error == 5) {
- echo "<br /><br /><font color='#FF0000'>There was an error while trying to upload your file. Please try again.</font><br /><br /><br />";
- }
- ?>
- <br />
- <form enctype="multipart/form-data" action="upload.php" method="POST">
- <!-- MAX_FILE_SIZE must precede the file input field -->
- <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
- <!-- Name of input element determines name in $_FILES array -->
- Upload Seal:
- <input name="file" type="file" id="file" />
- <input type="radio" name="upload" value="file"><br />
- <br />
- Use URL:
- <input name="url" type="text" id="url" />
- <input type="radio" name="upload" value="url"><br />
- <br />
- <input type="submit" value="Upload" />
- </form>
- </center>
- <br />
- <br />
- <?php include("db_connect.php"); ?>
- <?php
- $result = mysql_query("SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'");
- $myrow = mysql_fetch_array($result);
- $decree = $myrow['city_decree'];
- $current_tax = $myrow['tax_rate'];
- $current_continent = $myrow['continent'];
- $current_government = $myrow['government'];
- $current_idealism = $myrow['idealism'];
- $current_capital = $myrow['capital'];
- $current_alliance = $myrow['alliance'];
- $last_edit_date = $myrow['last_edit_date'];
- $last_edit_day = $myrow['last_edit_day'];
- $error = $_GET['error'];
- $idday = $myrow['iddays'];
- $allow_admin = $myrow['admin_email'];
- $peace_mode = $myrow['peace_mode'];
- $peace_mode_day = $myrow['peace_mode_day'];
- $nowday = mysql_query('SELECT * FROM `users` WHERE `iddays` < DATE_SUB(NOW, INTERVAL 5 DAY)');
- if($nowday >= $idday) {
- $govbox = "<select name='government' id='government'>
- <option value='Authoritarian'>Authoritarian</option>
- <option value='Republic'>Republic</option>
- <option value='Oligarchy'>Oligarchy</option>
- <option value='Communism'>Communism</option>
- <option value='Noocracy'>Noocracy</option>
- </select>";
- } else {
- $govbox = "You have changed either your government or idealism preferences in the last 5 days.";
- }
- if($nowday >= $idday) {
- $idbox = "<select name='idealism' id='idealism'>
- <option value='Aesthetics'>Aesthetics</option>
- <option value='Ethics'>Ethics</option>
- <option value='Logic'>Logic</option>
- <option value='Metaphysics'>Metaphysics</option>
- <option value='Physique'>Physique</option>
- <option value='Conservation'>Conservation</option>
- </select>";
- } else {
- $idbox = "You have changed either your government or idealism preferences in the last 5 days.";
- }
- $day = date('z');
- $days_left = ($day - $peace_mode_day);
- $day_left = (5 - $days_left);
- if($days_left <= 5) {
- $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.";
- } else {
- if($peace_mode == 1) {
- $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>
- <option value='0'>Your planet has defenses, but is still susceptible to attack.</option></select>";
- } else {
- $peace = "<select name='peace_mode'><option value='0'>Your planet has some defenses, but is still susceptible to attack.</option>
- <option value='1'>Your planet is being protected by the Universal Federation. No outside entities may assault your planet.</option></select>";
- }
- if($allow_admin == yes) {
- $checked = "checked";
- } else {
- $checked = "";
- }
- }
- ?>
- <center>
- Last Edit Date: <?php echo $last_edit_date; ?>
- </center>
- <?php
- if($error == 1) {
- echo "<font color='#FF0000'>Error - Your new passwords dont match.</font><br /><br /><br />";
- }
- if($error == 2) {
- echo "<font color='#FF0000'>Error - Your old password does not match with your current password.</font><br /><br /><br />";
- }
- if($error == 15) {
- 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 />";
- }
- if($error == 17) {
- echo "<br /><br /><font color='#FF0000'>You can not join the Admin affiliation.</font><br /><br /><br />";
- }
- ?>
- <table width="100%">
- <form enctype="multipart/form-data" action="index.php?id=update_pass&art=<?php echo $_SESSION['id'];?>" method="post">
- <tr>
- <td width="40%" align="left" valign="top">Old Password:</td>
- <td width="" align="left" valign="top"><input type="password" name="old_passwd" id="old_passwd"></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">New Password:</td>
- <td width="" align="left" valign="top"><input type="password" name="passwd" id="passwd"></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Confirm New Password:</td>
- <td width="" align="left" valign="top"><input type="password" name="passwd_confirm" id="passwd_confirm"></td>
- </tr>
- <tr><td></td><td>
- <input type="hidden" value="<?php echo $myrow['id']; ?>" name="id" id="id">
- <input type="submit" name="Edit" value="Save Password">
- </td></tr>
- </form>
- </table>
- <br />
- <table width="100%">
- <form enctype="multipart/form-data" action="index.php?id=update_account&art=<?php echo $_SESSION['id'];?>" method="post">
- <tr>
- <td width="40%" align="left" valign="top">Email:</td>
- <td width="" align="left" valign="top"><input type="text" value="<?php echo $myrow['email']; ?>" name="email" id="email"></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Planet Description:</td>
- <td width="" align="left" valign="top"><TEXTAREA NAME="decree" COLS=40 ROWS=6>
- <?php echo $decree; ?>
- </TEXTAREA></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Affiliation:</td>
- <?php
- $usersql = mysql_query("SELECT * FROM users");
- $alliancesql = "DELETE * FROM alliance";
- $query = mysql_query($alliancesql);
- while($row = mysql_fetch_array($usersql))
- {
- $alliance = $row['alliance'];
- $query = mysql_query("SELECT * FROM users WHERE alliance='".$alliance."'") or die(mysql_error());
- $row = mysql_num_rows($query);
- $alliance_count = $row;
- $query = mysql_query("SELECT SUM(city_strength) as sum_total FROM users WHERE alliance='".$alliance."'") or die(mysql_error());
- $row = mysql_fetch_object($query);
- $alliance_strength = $row->sum_total;
- $alliance_score = round(($alliance_strength / 100000) + ($alliance_count / 10), 3);
- $query = mysql_query("SELECT * FROM alliance WHERE alliance='".$alliance."'") or die(mysql_error());
- $number = mysql_num_rows($query);
- $str = strlen($alliance_score);
- if($str < 10) {
- if($str == 9) {
- $alliance_score = "0".$alliance_score;
- } else {
- if($str == 8) {
- $alliance_score = "00".$alliance_score;
- } else {
- if($str == 7) {
- $alliance_score = "000".$alliance_score;
- } else {
- if($str == 6) {
- $alliance_score = "0000".$alliance_score;
- } else {
- if($str == 5) {
- $alliance_score = "00000".$alliance_score;
- } else {
- $alliance_score = "000000".$alliance_score;
- }}}}}
- } else {
- $alliance_score = $alliance_score;
- }
- if($alliance != "Admin" && $alliance != "None" && $alliance != "") {
- if($number == 0) {
- $sqldd = "INSERT INTO alliance SET alliance='".$alliance."', alliance_number='$alliance_count', alliance_score='$alliance_score', alliance_strength='$alliance_strength'";
- $querydd=mysql_query($sqldd);
- } else {
- $sqldd = "UPDATE alliance SET alliance_number='$alliance_count', alliance_score='$alliance_score', alliance_strength='$alliance_strength' WHERE alliance='".$alliance."'";
- $querydd=mysql_query($sqldd);
- }
- } else {
- $sqldd = "DELETE * FROM alliance WHERE alliance='Admin'";
- $sqldd = "DELETE * FROM alliance WHERE alliance=''";
- $sqldd = "DELETE * FROM alliance WHERE alliance='None'";
- }
- }
- $result = mysql_query("SELECT * FROM alliance ORDER BY alliance_score DESC LIMIT 0, 10");
- $row = mysql_fetch_array($result);
- ?>
- <script>
- function checkForOther(obj) {
- if (!document.layers) {
- var txt = document.getElementById("alliance");
- if (obj.value == "other") {
- txt.style.display = "inline";
- // gives the text field the name of the drop-down, for easy processing
- txt.name = "alliance";
- obj.name = "";
- } else {
- txt.style.display = "none";
- txt.name = "";
- obj.name = "alliance";
- }
- }
- }
- </script>
- <td width="" align="left" valign="top">
- <select name="alliance" onchange="checkForOther(this)">
- <option value="<?php echo $current_alliance; ?>"><?php echo $current_alliance; ?></option>
- <?php
- while($row = mysql_fetch_array($result))
- {
- $alliance = $row['alliance'];
- ?>
- <option value="<?php echo $alliance; ?>"><?php echo $alliance; ?></option>
- <?php
- }
- ?>
- <option value="other">Specify Other</option>
- </select><br />
- <input type="text" id="alliance" style="display:none;"> </td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Capital City:</td>
- <td width="" align="left" valign="top"><input type="text" value="<?php echo $myrow['capital']; ?>" name="capital" id="capital"></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Galaxy:</td>
- <td width="" align="left" valign="top"><select name="continent">
- <option value="<?php echo $current_continent; ?>"><?php echo $current_continent; ?></option>
- <option value="Andromeda">Andromeda</option>
- <option value="Corvus">Corvus</option>
- <option value="Draco">Draco</option>
- <option value="Orion">Orion</option>
- <option value="Phoenix">Phoenix</option>
- <option value="Scorpius">Scorpius</option>
- <option value="Taurus">Taurus</option>
- </select></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Government:</td>
- <td width="" align="left" valign="top">
- <?php echo $govbox; ?>
- <tr>
- <td width="40%" align="left" valign="top">Idealism:</td>
- <td width="" align="left" valign="top">
- <?php echo $idbox ?></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Tax Rate:</td>
- <td width="" align="left" valign="top"><select name="tax_rate">
- <option value="<?php echo $current_tax; ?>"><?php echo $current_tax; ?>%</option>
- <option value="10">10%</option>
- <option value="12">12%</option>
- <option value="14">14%</option>
- <option value="16">16%</option>
- <option value="18">18%</option>
- <option value="20">20%</option>
- <option value="22">22%</option>
- <option value="24">24%</option>
- <option value="26">26%</option>
- <option value="28">28%</option>
- </select></td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Peace Preferences:</td>
- <td width="" align="left" valign="top">
- <?php echo $peace; ?>
- </td>
- </tr>
- <tr>
- <td width="40%" align="left" valign="top">Allow Admin to email you? (Recommended)</td>
- <td width="" align="left" valign="top"><input type="checkbox" name="admin_email" value="yes" <?php echo $checked; ?> /> </td>
- </tr>
- <tr><td></td><td>
- <input type="hidden" value="<?php echo $myrow['id']; ?>" name="id" id="id">
- <input type="submit" name="Edit" value="Save ">
- </td></tr>
- </form>
- </table>
- <?php
- }
- ?>
- </div></div>
- update_account.php
- <?php
- // database connect script.
- require 'db_connect.php';
- ?>
- <center>
- <?php
- ?>
- <?php
- // database connect script.
- require 'db_connect.php';
- $qrybu = "SELECT * FROM users WHERE governor_name = '".$_SESSION['username']."'";
- $point = mysql_query($qrybu);
- $db = mysql_fetch_array($point);
- $email = $_POST['email'];
- $decree = $_POST['decree'];
- $continent = $_POST['continent'];
- $government = $_POST['government'];
- $idealism = $_POST['idealism'];
- $alliance = $_POST['alliance'];
- $capital = $_POST['capital'];
- $current_government = $db['government'];
- $current_idealism = $db['idealism'];
- $tax_rate = $_POST['tax_rate'];
- $admin_email = $_POST['admin_email'];
- $id = $db['id'];
- $last_edit_date = $db['last_edit_date'];
- $last_edit_day = $db['last_edit_day'];
- $edit_day_all = $db['edit_day_all'];
- $date = date('d m, Y');
- $day = date('d');
- $article = $_GET['art'];
- $happiness = $db['happiness'];
- $old_tax_rate = $db['tax_rate'];
- $old_alliance = $db['alliance'];
- $city_strength = $db['city_strength'];
- $pass = $db['password'];
- $peace_modes = $_POST['peace_mode'];
- $peace_mode_day = $db['peace_mode_day'];
- $peace_mode = $db['peace_mode'];
- include 'config_all.php';
- // Replace bad characters //
- $clean_string = preg_replace($allowed_char_pattern, "", $alliance);
- $alliance = $clean_string;
- $new_alliance = $alliance;
- if($new_alliance == 'Admin') {
- ?>
- <script type="text/javascript">
- <!--
- window.location = "/index.php?id=edit_account&art=<?php echo $_SESSION['id'];?>&error=17"
- //-->
- </script>
- <?php
- $new_alliance = $old_alliance;
- }
- $date = date('d m, Y');
- $day = date('z');
- $days_left = ($day - $peace_mode_day);
- if($peace_modes == $peace_mode) {
- $days = $peace_mode_day;
- } else {
- $day_left = (5 - $days_left);
- if($days_left <= 5) {
- $days = $peace_mode_day;
- } else {
- $days = $day;
- }
- }
- if($government != $current_government)
- {
- $sql = "UPDATE users SET iddays=NOW() WHERE id='".$_SESSION['id']."'";
- $query=mysql_query($sql);
- }
- if($idealism != $current_idealism)
- {
- $sql = "UPDATE users SET iddays=NOW() WHERE id='".$_SESSION['id']."'";
- }
- if($days_left > 5) {
- $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']."'";
- $query=mysql_query($sql);
- } else {
- $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']."'";
- $query=mysql_query($sql);
- }
- ?>
- <script type="text/javascript">
- <!--
- window.location = "/index.php?id=edit_account&art=<?php echo $_SESSION['id'];?>"
- //-->
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement