CVE-2017-1000443: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: Eleix Openhacker version 0.1.47 is vulnerable to a XSS vulnerability in the bank transactions component resulting in arbitrary code execution in the browser.
CWE description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
CVSS v3 base score: 6.1
Published: 2018-01-02T14:29Z
Repository: https://github.com/Eleix/openhacker
Language: Other
Files changed: conf/global.php, cron/watchdog.php, game/guest/lgin.htm, game/guest/rebuild.htm, game/guest/reg.htm, game/main/user/bank.htm, game/main/user/banksend.htm, game/main/user/clanbank.htm, game/main/user/clanbankin.htm, game/main/user/clanbanksend.htm, game/main/user/clanroster.htm, game/main/user/updateacc.htm, index.php, layout/guest/footer.htm, layout/guest/header.htm, layout/main/footer.htm, layout/main/header.htm
Commit date: 2017-09-20 07:18:40 -0400
Commit message: Security Update 092017

conf/global.php -
          Increment version +1

cron/watchdog.php -
          Remove linking transaction ID's. With clan bank transfers (Hacker 2 Clan or Clan 2 Hacker) the original logic no longer works as there is now two seperate database and ID' are not one after (or below) the other.

game/guest/lgin.htm - 
           Added validation for IP addresses (see game/guest/reg.htm)

game/guest/rebuild.htm
          Alert that the site is down but link off to the bugtracking page on GitHub

game/guest/reg.htm -
           Added ip validation
           Use POST over REQUEST for username, password, and email checks.
            Added username validation and sanitation
            Fixed a known bug that if the user didn't create a bank account first then they did not recieve any money for small jobs done before visiting the bank page for the first time. (Bank registration was an unnecessary complication and should already be handled on account registration.)
               Fixes #4 (lgin.htm too)

game/main/user/bank.htm -
          Added a missing end tag for the Send Cash form.

game/main/user/banksend.htm -
          Added sanitation on extra details message for bank transactions
          Added validation to sent amount
          Added logic to send money from Hacker to Clan
          Fixes #5

game/main/user/clanbank.htm -
          Phased out old button
          Added the radio toggle between Hacker or Clan

game/main/clanbankin.htm -
          Sanitized clan password input 
          Fixes #6

game/main/user/clanbanksend.htm -
          Added sanitation on extra details message for bank transactions
          Added validation to sent amount
          Removed sameid limitation for C 2 H transactions
          Added display for C 2 C coming soon

game/main/user/clanroster.htm - 
          Added logic for clan member status (regular member or council member)

game/main/user/updateacc.htm -
         Added sanitization to bio. Utilized htmlpurifier to allow for minimal html to be added (user can format their bios)
         Note: htmlpurifier sits outside web root (SEE index.php)
         Fixed old redirect location url

index.php -
         Added additional header modification cases
         Require the HTMLPurifier (Seperate download not contained in this repository)

layout/guest/header.htm -
           Removed old starting html logic (no longer needed and handled inside index.php

layout/main/footer.htm -
           Formatting issue

layout/main/header.htm -
           Changed Cryptocurrenty to Crypto-Market (Planned feature)
Diff: diff --git a/conf/global.php b/conf/global.php
index e9e333f..4dee256 100644
--- a/conf/global.php
+++ b/conf/global.php
@@ -5,11 +5,11 @@
 WARNING EDITING THIS DOCUMENT WITHOUT UNDERSTANDING WHAT EACH OPTION DOES CAN HAVE DIRE CONSEQUENCES
 
 Each option allows for the manipulation of global values. These affect the game engine and should be tested prior to pushing to production.
 */
 
-$GAMEVERSION = "0.1.47"; // Game version
+$GAMEVERSION = "0.1.48"; // Game version
 $MAXEPCOUNT = 64000; // Max Experience allowed
 $MEP4LVL = 640; // Max experience per level
 
 // Site Registration Configurations
 
diff --git a/cron/watchdog.php b/cron/watchdog.php
index 13dfd60..1fc6a6c 100644
--- a/cron/watchdog.php
+++ b/cron/watchdog.php
@@ -20,16 +20,10 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 			while($row = $result2->fetch_assoc()) {
 				$transactionid = $row['id'];
 				$senderid = $row['userid'];
 				$recieverid = $row['recvid'];
 				$amount = $row['amount'];
-				if($transactionid % 2 == 0){
-					$linkedtransid = $transactionid -1;
-				}
-				else {
-					$linkedtransid = $transactionid +1 ;
-				};
 				
 				$checkUserIp = "SELECT regip FROM accounts WHERE id = '$senderid' limit 1";
 				$chkipResult = $conn->query($checkUserIp);
 				
 				while ($rowip = mysqli_fetch_assoc($chkipResult)) {
@@ -44,29 +38,23 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 				};
 				
 				if($senderid == $recieverid && $amount < 0 && $account1ip == $account2ip){
 					// Known bank transfer logic (A negative transaction charge is sent to the user to subtract out the dollar amount from their account.)
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);
 
 				};
 				if($senderid == $recieverid && $amount > 0 && $account1ip == $account2ip){
 					// Known bank transfer logic (Post the new balance to the user as if they deposited the money themselves.)
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);
 
 				};
 				if($senderid != $recieverid && $amount < 0 && $account1ip == $account2ip){
 					// ACCOUNT CAUGHT | User has created another account and sent the funds to alt account
 					$WD_DNY = "UPDATE bank_transactions SET watchdog_approve = '0', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_DNY);
-					$result = $conn->query($WD_LNK_TRNS);
 					
 					$sqlsearchuname = "SELECT username FROM accounts WHERE id = '$senderid' limit 1";
 					$result22 = $conn->query($sqlsearchuname);
 					$row22 = $result22->fetch_assoc();
 					$username = $row22['username'];
@@ -75,13 +63,11 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 					$result = $conn->query($WD_ALRT);
 				};
 				if($senderid != $recieverid && $amount > 0 && $account1ip == $account2ip){
 					// ACCOUNT CAUGHT | User has created another account and sent the funds to alt account
 					$WD_DNY = "UPDATE bank_transactions SET watchdog_approve = '0' AND wd_scanned = '1' WHERE id = '$transactionid";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_DNY);
-					$result = $conn->query($WD_LNK_TRNS);
 					
 					$sqlsearchuname = "SELECT username FROM accounts WHERE id = '$senderid' limit 1";
 					$result22 = $conn->query($sqlsearchuname);
 					$row22 = $result22->fetch_assoc();
 					$username = $row22['username'];
@@ -90,25 +76,19 @@ if($ip == "127.0.0.1" || $ip == "::1" || $ip == ''){
 					$result = $conn->query($WD_ALRT);
 				};
 				if($senderid != $recieverid && $amount > 0 && $account1ip != $account2ip){
 					// Known bank transfer logic ( Legit Transfer )
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
-					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);					
+					$result = $conn->query($WD_APP);				
 				};
 				if($senderid == $recieverid && $amount > 0 && $account1ip != $account2ip){
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
-					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);		
+					$result = $conn->query($WD_APP);		
 				};
 				if($senderid != $recieverid && $amount < 0 && $account1ip != $account2ip){
 					$WD_APP = "UPDATE bank_transactions SET watchdog_approve = '1', wd_scanned = '1' WHERE id = '$transactionid'";
-					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
 					$result = $conn->query($WD_APP);
-					$result = $conn->query($WD_LNK_TRNS);
 				};
 			}		
 		}
 		else {
 			// Nothing to do, do nothing.
diff --git a/game/guest/lgin.htm b/game/guest/lgin.htm
index ee1ba16..d39b27a 100755
--- a/game/guest/lgin.htm
+++ b/game/guest/lgin.htm
@@ -1,17 +1,23 @@
 <?php
 
 if (empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 	if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
+		// Check if IP is valid
+		if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+		else{$ip = $_SERVER['REMOTE_ADDR'];};		
 	}
 	else{
 	$ip = $_SERVER['REMOTE_ADDR'];
 	};
 }
 else {
 	$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
+	// Check if IP is valid
+	if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+	else{$ip = $_SERVER['REMOTE_ADDR'];};	
 };
 
 $error=''; // Variable To Store Error Message
 if (empty($_POST['username']) || empty($_POST['password'])) {
 $error = "Username or Password field is empty";
diff --git a/game/guest/rebuild.htm b/game/guest/rebuild.htm
index 9d23ee3..9e6ee42 100644
--- a/game/guest/rebuild.htm
+++ b/game/guest/rebuild.htm
@@ -1,17 +1,9 @@
 <div id='content'>
 <h2>Site Offline</h2>
 
-<h4>LiteCity is currently offline for maintenance </h4>
-
-<h5>Whats to come</h5>
-
-<ul>
-
-	<li>Anti-cheat system</li>
-	<li>Live Events</li>
-	<li>CLI game program</li>
-	<li>Redesigned UI</li>
-	<li>... and much more</li>
+<h4>HackerCity is currently offline for maintenance </h4>
 
+<p>Keep up to date on the latest bugs on our Github!</p>
+<a style="font-size:20px;color:cyan;" href="https://github.com/Eleix/openhacker/issues">HackerCity Github Issues Page</a>
 </ul>
-</div>
\ No newline at end of file
+</div>
diff --git a/game/guest/reg.htm b/game/guest/reg.htm
index d7eb48f..92ed8be 100755
--- a/game/guest/reg.htm
+++ b/game/guest/reg.htm
@@ -6,18 +6,25 @@ if ($REGISTRATION == 0) {
 else {
 
 if (empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
 	if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
+		// Check if IP is valid
+		if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+		else{$ip = $_SERVER['REMOTE_ADDR'];};		
 	}
 	else{
 	$ip = $_SERVER['REMOTE_ADDR'];
 	};
 }
 else {
 	$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
+	// Check if IP is valid
+	if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
+	else{$ip = $_SERVER['REMOTE_ADDR'];};	
 };
+
 $salt = substr(str_replace('+','.',base64_encode(md5(mt_rand(), true))),0,16);
 $rounds = 10000;
 $encpass = crypt($_POST['password'], sprintf('$6$rounds=%d$%s$', $rounds, $salt));
 $reghash = md5( rand(0,1000) );
 
@@ -50,38 +57,45 @@ if ($_POST["g-recaptcha-response"]) {
     );
 }
 
 if ($response != null && $response->success) {
 
-
 //if submit is not blanked i.e. it is clicked.
 if(isset($_REQUEST['submit'])!='')
 {
-if($_REQUEST['username']=='' || $_REQUEST['email']=='' || $_REQUEST['password']=='')
+if($_POST['username']=='' || $_POST['email']=='' || $_POST['password']=='')
 {
 echo "please fill the empty field.";
 }
 else
 {
-$sql = "INSERT INTO accounts(username,email,password,regip,reghash) VALUES('".$_REQUEST['username']."', '".$_REQUEST['email']."', '$encpass', '$ip', '$reghash')";
+
+// Validate and Sanitize Username
+
+$username = $_POST['username'];
+$safeusername = (filter_var($username, FILTER_SANITIZE_STRING));
+if(@preg_match(''/^[a-zA-Z0-9]{3,}$/', $safeusername)) { // invalid username
+	echo "Your username is not allowed. Allowed values are a-z, A-Z, 0-9 and must be at least 3 characters";
+}
+else { // valid username
+
+$sql = "INSERT INTO accounts(username,email,password,regip,reghash) VALUES('$safeusername', '$email', '$encpass', '$ip', '$reghash')";
 $result = $conn->query($sql);
 if($result)
 {
 
-$username = $_POST['username'];
-
 $to      = $email; // Send email to our user
 $subject = "Hacker City Signup | Verification"; // Give the email a subject 
 $message = "
  
 Thank you for registering an account at Hacker City.
 Your account has been created and the final step is to activate your account.
 
 We use activation emails as a way to prevent bots and trouble users from abusing the system and flooding the site with fake users.
  
 ------------------------
-Username: $username
+Username: $safeusername
 Password: Not sent via email for security 
 ------------------------
  
 Please click this link to activate your account:
 https://boothlabs.me/verify.php?email=$email&reghash=$reghash
@@ -89,29 +103,32 @@ https://boothlabs.me/verify.php?email=$email&reghash=$reghash
 "; // Our message above including the link
                      
 $headers = 'From:noreply@boothlabs.me' . "\r\n"; // Set from headers
 mail($to, $subject, $message, $headers); // Send our email
 
-$username = $_REQUEST['username'];
-
-$sql9 = "SELECT id FROM accounts WHERE username = '$username';";
+$sql9 = "SELECT id FROM accounts WHERE username = '$safeusername';";
 $result9 = $conn->query($sql9);
 while ($row9 = $result9->fetch_assoc()){
 $userid = $row9['id'];
 }
 
 $sql10 = "INSERT INTO `usersystems` (`userid`, `cpu`, `motherboard`, `ram`, `os`, `hddtype`, `hddhealth`, `size`, `spaceused`, `spacefree`, `logs`, `securitypack`, `firewall`, `sphealth`, `firewallhealth`, `connectedto`, `connectiontype`, `ipaddress`, `gatewayip`, `gatewaystatus`, `systemstatus`) VALUES ('$userid', '486', 'Simple Motherboard', '256MB', 'DOS', '10GB', '100', '10GB', '0', '10', 'Not Installed', 'Not Installed', 'Not Installed', '0', '0', 'n00bnet', 'Loopback', '127.0.0.1', '', 'Offline', 'online');";
 $result10 = $conn->query($sql10);
 
+// Create bank account
+
+$sql11 = "INSERT INTO 'economy' ('userid') VALUES ('$userid');"
+$result11 = $conn->query($sql11);
+
 echo "Account Created Successfully, Check your email for instructions on activating your account .";
 }
 else {
 echo "There is some problem creating your account, please contact an administrator to resolve the issue.";
 echo "<br>";
 echo $sql;
 };
-}
+};
 }
 }
 else {
 	echo "You did not pass the robot validation.";
 };
diff --git a/game/main/user/bank.htm b/game/main/user/bank.htm
index bf9d0e2..5dc2e80 100644
--- a/game/main/user/bank.htm
+++ b/game/main/user/bank.htm
@@ -61,10 +61,11 @@ if (isset($_SESSION['bank_login'])){
     echo "<div class='check'><div class='inside'></div></div>";
 
     echo "<br>";
 
 	echo "<button class='btn waves-effect waves-light' type='submit' name='action'>Send Cash<i class='material-icons center'></i></button>";
+	echo "</form>";
 
 	echo "<br>";
 	echo "<br>";
 	echo "<h6>Previous Transactions (Last 50)</h6>";
 	
diff --git a/game/main/user/banksend.htm b/game/main/user/banksend.htm
index c63f91a..5484226 100644
--- a/game/main/user/banksend.htm
+++ b/game/main/user/banksend.htm
@@ -4,18 +4,34 @@
 
 $SendUser=$userid;
 $SendUserName = $_SESSION['login_user'];
 $RecUser=$_POST['recvusername'];
 $type=$_POST['type'];
+$amount = $_POST['amount'];
+$details = $_POST['details'];
+
+//Sanitize details input
+
+$safedetails = (filter_var($details, FILTER_SANITIZE_STRING));
+
+if($amount < 0 ){ 
+	echo "Amount sent cannot be a negative number.";
+	echo "<br>";
+	echo "Transaction cancelled";
+
+echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+}
+else{
 
 if($type == 'hacker'){
 
 $details = "sent by $SendUserName reason: ";
-$details .= $_POST['details']; 
+$details .= $safedetails; 
 $details2 = "sent to $RecUser reason: ";
-$details2 .= $_POST['details'];
-$amount = $_POST['amount'];
+$details2 .= $safedetails;
+
+	
 $amountnegative = $amount * -1;
 
 //Check to see if RecUser has an account with the bank
 
 $sql = "SELECT id FROM accounts WHERE username = '$RecUser'";
@@ -94,11 +110,94 @@ else {
 	echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
 
 };
 }
 else{ //type is clan
-echo "Money Transfers to clan banks are unavailable at this time";
+
+$clanname = $RecUser; //Used in the error message
+
+// Convert clan name to ID
+$sqlConv2ID = "SELECT id FROM clans WHERE clanname = '$RecUser'";
+$resultConv2ID = $conn->query($sqlConv2ID);
+while($rowConvID = $resultConv2ID->fetch_assoc()){
+  $RecUser = $rowConvID['id'];
 };
 
+$details = "sent by $SendUserName reason: ";
+$details .= $safedetails; 
+$details2 = "sent to $clanname reason: ";
+$details2 .= $safedetails;
+$amount = $_POST['amount'];
+$amountnegative = $amount * -1;
+
+//Check to see if RecUser has an account with the bank
+
+$sql = "SELECT clanid FROM claneconomy WHERE clanid = '$RecUser'";
+$result = $conn->query($sql);
+
+while($row = $result->fetch_assoc()){
+$recvuser = $row['clanid']; // Clan ID return
+};
+
+$sql = "SELECT clanid FROM claneconomy WHERE clanid = '$recvuser'";
+$result = $conn->query($sql);
+
+if ($result->num_rows > 0) {
+
+$sql = "SELECT cash FROM economy WHERE userid = '$SendUser'";
+$result = $conn->query($sql);
+
+while($row = $result->fetch_assoc()){
+$oldBal = $row['cash'];
+}
+
+$newBalUs1 = $oldBal - $amount;
+
+if ($newBalUs1 < 0)
+{
+   echo "<h1>Transaction Failed</h1>";
+   echo "<br>";
+   echo "You can't send more money than you actually have.";
+   echo "<br>";
+   echo "<br>";
+   echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+} else {
+
+$sql = "SELECT cash FROM claneconomy WHERE clanid = '$recvuser'";  //fetch the recieving clan's current bank balance
+$result = $conn->query($sql);
+
+while($row = $result->fetch_assoc()){
+$oldBalUs2 = $row['cash'];   // export the returned value to a variable
+}
+
+$newBalUs2 = $oldBalUs2 + $amount;
+
+$sql = "UPDATE claneconomy SET cash='$newBalUs2' WHERE clanid = '$recvuser'";
+$result = $conn->query($sql);
+
+$sql = "UPDATE economy SET cash='$newBalUs1' WHERE userid= '$SendUser'";
+$result = $conn->query($sql);
+
+$sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
+$result = $conn->query($sql);
+
+$sql = "INSERT INTO clanbank_transactions(clanid,clanrecvid,details,amount,transactionuserid) VALUES('$recvuser', '$recvuser', '$details', '$amount', '$SendUserName')";
+$result = $conn->query($sql);
+
+   echo "Transaction Complete";
+   echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+
+}
+} 
+else {
+	echo "<h1>Transaction Failed</h1>";
+	echo "<br>";
+	echo "<p>We are sorry. Our database failed to find the clan "; echo $clanname; echo " in our banking database.</p>";
+	echo "<p>Your previous transaction has been canceled.</p>";
+	echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+
+};
+};
+};
 
 ?>
-</div>
\ No newline at end of file
+</div>
diff --git a/game/main/user/clanbank.htm b/game/main/user/clanbank.htm
index 6f4595b..fbf6127 100644
--- a/game/main/user/clanbank.htm
+++ b/game/main/user/clanbank.htm
@@ -19,11 +19,11 @@ if(!isset($_SESSION['clanbank_login'])){
 	if ($result->num_rows > 0) {
     	echo '<form name="login" method="POST" autocomplete="off" action="?a=clanbankin">';
 		echo "<br>";
 		echo 'Password:  <input type="password" name="password" value=""><br>';
 		echo "<br>";
-		echo '<input style="width:70px;" type="submit" name="submit" value="Login">';
+		echo "<button class='btn waves-effect waves-light' type='submit' name='submit'>Login<i class='material-icons center'></i></button>";
 		echo "<br>";
 		echo "<br>";
 		echo "</form>";
 	}
 	else {
@@ -60,13 +60,23 @@ $resultGetName = $conn->query($sqlGetName);
 	echo "<br>";
 	echo "To:"; echo '<input type="text" name="recvusername" value="">';
 	echo "<br>";
 	echo "Details:"; echo '<input type="text" name="details" value="">';
 	echo "<br>";
+
+    echo "<input type='radio' value='hacker' id='hacker' name='type'>";
+    echo "<label for='hacker'>Hacker</label>";
+    echo "<div class='check'><div class='inside'></div></div>";
+
+    echo "<input type='radio' value='clan' id='clan' name='type'>";
+    echo "<label for='clan'>Clan</label>";   
+    echo "<div class='check'><div class='inside'></div></div>";
+
     echo "<br>";
 
 	echo "<button class='btn waves-effect waves-light' type='submit' name='action'>Send Cash<i class='material-icons center'></i></button>";
+	echo "</form>";
 
 	echo "<br>";
 	echo "<br>";
 	echo "<h6>Previous Transactions (Last 50)</h6>";
 	
diff --git a/game/main/user/clanbankin.htm b/game/main/user/clanbankin.htm
index bf4e16a..af92dd5 100644
--- a/game/main/user/clanbankin.htm
+++ b/game/main/user/clanbankin.htm
@@ -19,12 +19,13 @@ $sql = "INSERT INTO claneconomy(clanid) VALUE('$clanid')";
 $result = $conn->query($sql);
 
 // Set Clan bank password
 
 $password = $_POST['password'];
+$safepassword = mysqli_real_escape_string($conn, $password);
 
-$sqlSetCBP = "UPDATE clans SET bankpassword = '$password' WHERE id = '$clanid'";
+$sqlSetCBP = "UPDATE clans SET bankpassword = '$safepassword' WHERE id = '$clanid'";
 $resultSetCBP = $conn->query($sqlSetCBP);
 
 header("location: ?a=bank"); // Redirecting To Other Page
 }
 else {
diff --git a/game/main/user/clanbanksend.htm b/game/main/user/clanbanksend.htm
index 7c31f8b..a930a2d 100644
--- a/game/main/user/clanbanksend.htm
+++ b/game/main/user/clanbanksend.htm
@@ -1,16 +1,43 @@
 <div id="content">
 
 <?php
 
+	$username = $_SESSION['login_user'];
+
+	$sqlGetClanID = "SELECT clan FROM accounts WHERE username = '$username'";
+	$resultGetCID = $conn->query($sqlGetClanID);
+	while($rowCID = $resultGetCID->fetch_assoc()) {
+		$clanid = $rowCID['clan'];
+	};
+
+
 $SendUser=$clanid;
 $RecUser=$_POST['recvusername'];
+$type=$_POST['type'];
+$amount = $_POST['amount'];
+$details = $_POST['details'];
+
+//Sanitize details input
+
+$safedetails = (filter_var($details, FILTER_SANITIZE_STRING));
+
+if($amount < 0 ){ 
+	echo "Amount sent cannot be a negative number.";
+	echo "<br>";
+	echo "Transaction cancelled";
+
+echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
+}
+else{
+
+if($type == 'hacker'){
 
 $details = "sent by $SendUserName reason: ";
-$details .= $_POST['details']; 
+$details .= $safedetails; 
 $details2 = "sent to $RecUser reason: ";
-$details2 .= $_POST['details'];
+$details2 .= $safedetails;
 $amount = $_POST['amount'];
 $amountnegative = $amount * -1;
 
 //Check to see if RecUser has an account with the bank
 
@@ -25,28 +52,19 @@ $sql = "SELECT id FROM economy WHERE userid = '$recvuser'";
 $result = $conn->query($sql);
 
 if ($result->num_rows > 0) {
 
 
-$sql = "SELECT cash FROM economy WHERE userid = '$SendUser'";
+$sql = "SELECT cash FROM claneconomy WHERE clanid = '$SendUser'";
 $result = $conn->query($sql);
 
 while($row = $result->fetch_assoc()){
 $oldBal = $row['cash'];
 }
 
 $newBalUs1 = $oldBal - $amount;
 
-if ($recvuser == $SendUser) {
-echo "<h1>Transaction Failed</h1>";
-echo "<br>";
-echo "You can't send money to yourself!"; 
-echo "<br>";
-echo "<br>";
-echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
-} else {
-
 if ($newBalUs1 < 0)
 {
    echo "<h1>Transaction Failed</h1>";
    echo "<br>";
    echo "You can't send more money than you actually have.";
@@ -65,32 +83,34 @@ $oldBalUs2 = $row['cash'];   // export the returned value to a variable
 $newBalUs2 = $oldBalUs2 + $amount;
 
 $sql = "UPDATE economy SET cash='$newBalUs2' WHERE userid = '$recvuser'";
 $result = $conn->query($sql);
 
-$sql = "UPDATE economy SET cash='$newBalUs1' WHERE userid= '$SendUser'";
+$sql = "UPDATE claneconomy SET cash='$newBalUs1' WHERE clanid= '$SendUser'";
 $result = $conn->query($sql);
 
-$sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
+$sql = "INSERT INTO clanbank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
 $result = $conn->query($sql);
 
 $sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$recvuser', '$recvuser', '$details', '$amount')";
 $result = $conn->query($sql);
 
    echo "Transaction Complete";
    echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
 
-}
 }
 } 
 else {
 	echo "<h1>Transaction Failed</h1>";
 	echo "<br>";
 	echo "<p>We are sorry. Our database failed to find the hacker "; echo $RecUser; echo " in our banking database.</p>";
 	echo "<p>Your previous transaction has been canceled.</p>";
 	echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
 
 };
-
-
+}
+else {
+echo "Clan to Clan coming soon";
+};
+};
 ?>
-</div>
\ No newline at end of file
+</div>
diff --git a/game/main/user/clanroster.htm b/game/main/user/clanroster.htm
index b854eb1..f800010 100644
--- a/game/main/user/clanroster.htm
+++ b/game/main/user/clanroster.htm
@@ -18,18 +18,19 @@ function checkDelete(){
 	$resultGetCID = $conn->query($sqlGetClanID);
 	while($rowCID = $resultGetCID->fetch_assoc()) {
 		$clanid = $rowCID['clan'];
 	};
 
-$sql = "SELECT id, username FROM accounts WHERE clan = '$clanid'";
+$sql = "SELECT id, username, clancouncil FROM accounts WHERE clan = '$clanid'";
 $result = $conn->query($sql);
 
 if ($result->num_rows > 0) {
      echo "<div id=admintable><table><tr><th>Username</th><th>Role</th><th>Bank Balance</th><th>Action</th>";
+
      // output data of each row
      while($row = $result->fetch_assoc()) {
-    	 echo "<tr><td><a href=?a=profile&id=" . $row["id"]. ">" . $row["username"]. "</td><td>" . $row["email"]. "</td><td>" . $row["role"]. "</td><td>" . $row["lastip"]. "</td><td>" . $row["lastlogindate"]. "</td><td>" . $row["regdate"]. "";
+    	 echo "<tr><td><a href=?a=profile&id=" . $row["id"]. ">" . $row["username"]. "</td><td>" . $row["clancouncil"]. "</td><td>" . $row["role"]. "</td><td>" . $row["lastip"]. "</td><td>" . $row["lastlogindate"]. "</td><td>" . $row["regdate"]. "";
 		 echo "<td><a href=?a=profile&id=" . $row["id"]. "><button type='submit' name='action'><i class='material-icons center'>edit</i></button></a>";
 		 echo "<input type='hidden' name='tempId' value='".$row["id"]."'/><form action='?m=deluser' method='POST'><button type='submit' name='action' action=''><i class='material-icons center'>delete</i></button></form>";
 		 echo "<input type='hidden' name='tempId' value='".$row["id"]."'/><form action='?m=banuser' method='POST'><button type='submit' name='action'><i class='material-icons center'>block</i></button></form></td>";
      }
      echo "</table>";
diff --git a/game/main/user/updateacc.htm b/game/main/user/updateacc.htm
index 6451718..bf42b5c 100644
--- a/game/main/user/updateacc.htm
+++ b/game/main/user/updateacc.htm
@@ -1,11 +1,13 @@
 <?php
 $bio = $_POST['bio'];
-$_safebio = mysqli_real_escape_string($conn, $bio);
 
-$sql = "UPDATE accounts SET bio='$_safebio' WHERE username='$username'";
+// Sanitize bio but allow for a minimal amount of HTML so the user can style their bio thir way.
+$safebio = $purifier->purify($_safebio);
+
+$sql = "UPDATE accounts SET bio='$safebio' WHERE username='$username'";
 
 $result = $conn->query($sql);
 
-header("location: /game/main/index.php?a=accountdetails");
+header("location: ?a=accountdetails");
 
 ?>
\ No newline at end of file
diff --git a/index.php b/index.php
index 2be0d6e..a0fe49b 100755
--- a/index.php
+++ b/index.php
@@ -35,10 +35,13 @@ if (empty($_GET['m'])){
 			case "fbimostwanted": echo "FBI Most Wanted List";break;
 			case "techspecs": echo "Server Resources";break;
 			case "clanbank": echo "Clan Bank";break;
 			case "clanroster": echo "Clan Roster";break;
 			case "profile": echo "Player Profile";break;
+			case "guest": echo "Guest";break;
+			case "login": echo "Login";break;
+			case "register": echo "Register";break;
 		};
 	};
 }
 else {
 	$urlm = $_GET['m'];
@@ -66,10 +69,13 @@ else {
 
 </head>
 
 <?php
 
+require_once '../htmlpurifier/library/HTMLPurifier.auto.php';
+$purifier = new HTMLPurifier();
+
 $mem = new Memcache();
 $mem->addServer("127.0.0.1", 11211);
 require 'sql/connect.php';
 require 'conf/global.php';
 
diff --git a/layout/guest/footer.htm b/layout/guest/footer.htm
index c995781..e9c1053 100755
--- a/layout/guest/footer.htm
+++ b/layout/guest/footer.htm
@@ -20,11 +20,10 @@
 <h6>Version <?php echo $GAMEVERSION; ?></h6>
 <h6>Developed by Francis Booth</h6>
 </div>
 <h6>Gameserver: <?php echo gethostname(); ?> </h6>
 
-
 <div style="clear: both"></div>
 
 <script type="text/javascript">
 var sc_project=11259067; 
 var sc_invisible=1; 
diff --git a/layout/guest/header.htm b/layout/guest/header.htm
index 388055c..804dae7 100755
--- a/layout/guest/header.htm
+++ b/layout/guest/header.htm
@@ -1,21 +1,3 @@
-<html>
-	<head>
-		<title>Hacker City | Index</title>
-		<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Ek+Mukta">
-		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
-		<link type="text/css" rel="stylesheet" href="/css/style.css">
-		<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
-		<link type="text/css" rel="stylesheet" href="/css/materialize.css">
-		<link type="text/css" rel="stylesheet" href="/css/burn.css">
-		<link rel="shortcut icon" href="/usr/share/nginx/html/images/favicon.ico" type="image/x-icon">
-		<link rel="icon" href="/usr/share/nginx/html/images/favicon.ico" type="image/x-icon">
-		<script src="/js/materialize.js"></script>
-		<script src='https://www.google.com/recaptcha/api.js'></script>
-		<script async src="/js/spanize.js"></script>
-	</head>
-	
-<body>
-
 <?php
 	include 'layout/guest/nav.htm';
 ?>	
diff --git a/layout/main/footer.htm b/layout/main/footer.htm
index e98b43e..bef9e0a 100755
--- a/layout/main/footer.htm
+++ b/layout/main/footer.htm
@@ -15,12 +15,11 @@
 ?>
 
 </div>
 
 <div class="bottomright">
-<h6>Version <?php echo $GAMEVERSION; ?>
-</h6>
+<h6>Version <?php echo $GAMEVERSION; ?></h6>
 <h6>Developed by Francis Booth</h6>
 </div>
 <h6>Gameserver: <?php echo gethostname(); ?> </h6>
 
 <div style="clear: both"></div>
diff --git a/layout/main/header.htm b/layout/main/header.htm
index dfe3cb0..0077f0e 100755
--- a/layout/main/header.htm
+++ b/layout/main/header.htm
@@ -99,11 +99,11 @@
             	<ul class="sub-menu">
             		<li><a href="?a=softwareshop">Software Shop</a></li>
             		<li><a href="?a=hardwareshop">Hardware Shop</a></li>
             		<li><a href="?a=isp">Internet Provider</a></li>
             		<li><a href="?a=h4h">Hacker for Hire</a></li>
-            		<li><a href="?a=cryptocurrency">Cryptocurrency</a></li>
+            		<li><a href="?a=cryptomarket">Crypto-Market</a></li>
             	</ul>
             </li>
             <li>
             	<a href="#">Law Enforcement</a>
             	<ul class="sub-menu">

Vulnerable code: $GAMEVERSION = "0.1.47"; // Game version
				if($transactionid % 2 == 0){
					$linkedtransid = $transactionid -1;
				}
				else {
					$linkedtransid = $transactionid +1 ;
				};
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_LNK_TRNS);
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_LNK_TRNS);
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_LNK_TRNS);
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_LNK_TRNS);
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_APP);
					$result = $conn->query($WD_LNK_TRNS);					
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_APP);
					$result = $conn->query($WD_LNK_TRNS);		
					$WD_LNK_TRNS = "UPDATE bank_transactions SET linked_transid = '$linkedtransid' WHERE id = '$transactionid'";
					$result = $conn->query($WD_LNK_TRNS);
<h4>LiteCity is currently offline for maintenance </h4>

<h5>Whats to come</h5>

<ul>

	<li>Anti-cheat system</li>
	<li>Live Events</li>
	<li>CLI game program</li>
	<li>Redesigned UI</li>
	<li>... and much more</li>
</div>

if($_REQUEST['username']=='' || $_REQUEST['email']=='' || $_REQUEST['password']=='')
$sql = "INSERT INTO accounts(username,email,password,regip,reghash) VALUES('".$_REQUEST['username']."', '".$_REQUEST['email']."', '$encpass', '$ip', '$reghash')";
$username = $_POST['username'];

Username: $username
$username = $_REQUEST['username'];

$sql9 = "SELECT id FROM accounts WHERE username = '$username';";
}
$details .= $_POST['details']; 
$details2 .= $_POST['details'];
$amount = $_POST['amount'];
echo "Money Transfers to clan banks are unavailable at this time";
</div>
		echo '<input style="width:70px;" type="submit" name="submit" value="Login">';
$sqlSetCBP = "UPDATE clans SET bankpassword = '$password' WHERE id = '$clanid'";
$details .= $_POST['details']; 
$details2 .= $_POST['details'];
$sql = "SELECT cash FROM economy WHERE userid = '$SendUser'";
if ($recvuser == $SendUser) {
echo "<h1>Transaction Failed</h1>";
echo "<br>";
echo "You can't send money to yourself!"; 
echo "<br>";
echo "<br>";
echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
} else {

$sql = "UPDATE economy SET cash='$newBalUs1' WHERE userid= '$SendUser'";
$sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
}


</div>
$sql = "SELECT id, username FROM accounts WHERE clan = '$clanid'";
    	 echo "<tr><td><a href=?a=profile&id=" . $row["id"]. ">" . $row["username"]. "</td><td>" . $row["email"]. "</td><td>" . $row["role"]. "</td><td>" . $row["lastip"]. "</td><td>" . $row["lastlogindate"]. "</td><td>" . $row["regdate"]. "";
$_safebio = mysqli_real_escape_string($conn, $bio);
$sql = "UPDATE accounts SET bio='$_safebio' WHERE username='$username'";
header("location: /game/main/index.php?a=accountdetails");

<html>
	<head>
		<title>Hacker City | Index</title>
		<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Ek+Mukta">
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
		<link type="text/css" rel="stylesheet" href="/css/style.css">
		<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
		<link type="text/css" rel="stylesheet" href="/css/materialize.css">
		<link type="text/css" rel="stylesheet" href="/css/burn.css">
		<link rel="shortcut icon" href="/usr/share/nginx/html/images/favicon.ico" type="image/x-icon">
		<link rel="icon" href="/usr/share/nginx/html/images/favicon.ico" type="image/x-icon">
		<script src="/js/materialize.js"></script>
		<script src='https://www.google.com/recaptcha/api.js'></script>
		<script async src="/js/spanize.js"></script>
	</head>
	
<body>

<h6>Version <?php echo $GAMEVERSION; ?>
</h6>
            		<li><a href="?a=cryptocurrency">Cryptocurrency</a></li>
Fixed code: $GAMEVERSION = "0.1.48"; // Game version
					$result = $conn->query($WD_APP);				
					$result = $conn->query($WD_APP);		
		// Check if IP is valid
		if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
		else{$ip = $_SERVER['REMOTE_ADDR'];};		
	// Check if IP is valid
	if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
	else{$ip = $_SERVER['REMOTE_ADDR'];};	
<h4>HackerCity is currently offline for maintenance </h4>
<p>Keep up to date on the latest bugs on our Github!</p>
<a style="font-size:20px;color:cyan;" href="https://github.com/Eleix/openhacker/issues">HackerCity Github Issues Page</a>
</div>
		// Check if IP is valid
		if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
		else{$ip = $_SERVER['REMOTE_ADDR'];};		
	// Check if IP is valid
	if(filter_var($ip, FILTER_VALIDATE_IP)){} // Leave ip as is
	else{$ip = $_SERVER['REMOTE_ADDR'];};	

if($_POST['username']=='' || $_POST['email']=='' || $_POST['password']=='')

// Validate and Sanitize Username

$username = $_POST['username'];
$safeusername = (filter_var($username, FILTER_SANITIZE_STRING));
if(@preg_match(''/^[a-zA-Z0-9]{3,}$/', $safeusername)) { // invalid username
	echo "Your username is not allowed. Allowed values are a-z, A-Z, 0-9 and must be at least 3 characters";
}
else { // valid username

$sql = "INSERT INTO accounts(username,email,password,regip,reghash) VALUES('$safeusername', '$email', '$encpass', '$ip', '$reghash')";
Username: $safeusername
$sql9 = "SELECT id FROM accounts WHERE username = '$safeusername';";
// Create bank account

$sql11 = "INSERT INTO 'economy' ('userid') VALUES ('$userid');"
$result11 = $conn->query($sql11);

};
	echo "</form>";
$amount = $_POST['amount'];
$details = $_POST['details'];

//Sanitize details input

$safedetails = (filter_var($details, FILTER_SANITIZE_STRING));

if($amount < 0 ){ 
	echo "Amount sent cannot be a negative number.";
	echo "<br>";
	echo "Transaction cancelled";

echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
}
else{
$details .= $safedetails; 
$details2 .= $safedetails;

	

$clanname = $RecUser; //Used in the error message

// Convert clan name to ID
$sqlConv2ID = "SELECT id FROM clans WHERE clanname = '$RecUser'";
$resultConv2ID = $conn->query($sqlConv2ID);
while($rowConvID = $resultConv2ID->fetch_assoc()){
  $RecUser = $rowConvID['id'];
$details = "sent by $SendUserName reason: ";
$details .= $safedetails; 
$details2 = "sent to $clanname reason: ";
$details2 .= $safedetails;
$amount = $_POST['amount'];
$amountnegative = $amount * -1;

//Check to see if RecUser has an account with the bank

$sql = "SELECT clanid FROM claneconomy WHERE clanid = '$RecUser'";
$result = $conn->query($sql);

while($row = $result->fetch_assoc()){
$recvuser = $row['clanid']; // Clan ID return
};

$sql = "SELECT clanid FROM claneconomy WHERE clanid = '$recvuser'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {

$sql = "SELECT cash FROM economy WHERE userid = '$SendUser'";
$result = $conn->query($sql);

while($row = $result->fetch_assoc()){
$oldBal = $row['cash'];
}

$newBalUs1 = $oldBal - $amount;

if ($newBalUs1 < 0)
{
   echo "<h1>Transaction Failed</h1>";
   echo "<br>";
   echo "You can't send more money than you actually have.";
   echo "<br>";
   echo "<br>";
   echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
} else {

$sql = "SELECT cash FROM claneconomy WHERE clanid = '$recvuser'";  //fetch the recieving clan's current bank balance
$result = $conn->query($sql);

while($row = $result->fetch_assoc()){
$oldBalUs2 = $row['cash'];   // export the returned value to a variable
}

$newBalUs2 = $oldBalUs2 + $amount;

$sql = "UPDATE claneconomy SET cash='$newBalUs2' WHERE clanid = '$recvuser'";
$result = $conn->query($sql);

$sql = "UPDATE economy SET cash='$newBalUs1' WHERE userid= '$SendUser'";
$result = $conn->query($sql);

$sql = "INSERT INTO bank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
$result = $conn->query($sql);

$sql = "INSERT INTO clanbank_transactions(clanid,clanrecvid,details,amount,transactionuserid) VALUES('$recvuser', '$recvuser', '$details', '$amount', '$SendUserName')";
$result = $conn->query($sql);

   echo "Transaction Complete";
   echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";

}
} 
else {
	echo "<h1>Transaction Failed</h1>";
	echo "<br>";
	echo "<p>We are sorry. Our database failed to find the clan "; echo $clanname; echo " in our banking database.</p>";
	echo "<p>Your previous transaction has been canceled.</p>";
	echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";

};
};
};
</div>
		echo "<button class='btn waves-effect waves-light' type='submit' name='submit'>Login<i class='material-icons center'></i></button>";

    echo "<input type='radio' value='hacker' id='hacker' name='type'>";
    echo "<label for='hacker'>Hacker</label>";
    echo "<div class='check'><div class='inside'></div></div>";

    echo "<input type='radio' value='clan' id='clan' name='type'>";
    echo "<label for='clan'>Clan</label>";   
    echo "<div class='check'><div class='inside'></div></div>";

	echo "</form>";
$safepassword = mysqli_real_escape_string($conn, $password);
$sqlSetCBP = "UPDATE clans SET bankpassword = '$safepassword' WHERE id = '$clanid'";
	$username = $_SESSION['login_user'];

	$sqlGetClanID = "SELECT clan FROM accounts WHERE username = '$username'";
	$resultGetCID = $conn->query($sqlGetClanID);
	while($rowCID = $resultGetCID->fetch_assoc()) {
		$clanid = $rowCID['clan'];
	};


$type=$_POST['type'];
$amount = $_POST['amount'];
$details = $_POST['details'];

//Sanitize details input

$safedetails = (filter_var($details, FILTER_SANITIZE_STRING));

if($amount < 0 ){ 
	echo "Amount sent cannot be a negative number.";
	echo "<br>";
	echo "Transaction cancelled";

echo "<td><form action='?a=bank' method='POST'><input type='submit' name='submit-btn' value='Back to account summary' /></td></form>";
}
else{

if($type == 'hacker'){
$details .= $safedetails; 
$details2 .= $safedetails;
$sql = "SELECT cash FROM claneconomy WHERE clanid = '$SendUser'";
$sql = "UPDATE claneconomy SET cash='$newBalUs1' WHERE clanid= '$SendUser'";
$sql = "INSERT INTO clanbank_transactions(userid,recvid,details,amount) VALUES('$SendUser', '$recvuser', '$details2', '$amountnegative')";
}
else {
echo "Clan to Clan coming soon";
};
};
</div>
$sql = "SELECT id, username, clancouncil FROM accounts WHERE clan = '$clanid'";

    	 echo "<tr><td><a href=?a=profile&id=" . $row["id"]. ">" . $row["username"]. "</td><td>" . $row["clancouncil"]. "</td><td>" . $row["role"]. "</td><td>" . $row["lastip"]. "</td><td>" . $row["lastlogindate"]. "</td><td>" . $row["regdate"]. "";
// Sanitize bio but allow for a minimal amount of HTML so the user can style their bio thir way.
$safebio = $purifier->purify($_safebio);

$sql = "UPDATE accounts SET bio='$safebio' WHERE username='$username'";
header("location: ?a=accountdetails");
			case "guest": echo "Guest";break;
			case "login": echo "Login";break;
			case "register": echo "Register";break;
require_once '../htmlpurifier/library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();

<h6>Version <?php echo $GAMEVERSION; ?></h6>
            		<li><a href="?a=cryptomarket">Crypto-Market</a></li>