Location: PHPKode > projects > Siteman personal website CMS > siteman-personal-website-cms/users.php
<?php
	if (substr_count($_SERVER["PHP_SELF"],"users.php") == 0) {
		die("Security violation!");
	}
	$members = file("data/members.txt");
	if (!isset($class_included)) {
		include("data/class.php");
	}
	if (!isset($Siteman)) {
		$Siteman = new Website("1.1.11");
	}
	include("data/userdets.php");
	if ($do == "default") {
		if ($Siteman->loginok) {
			$do = "edinfo";
		}
		else {
			$do = "new";
		}		
	}
	$visitors = file("data/count.txt");
	$resetdate = date($short_dateformat,$visitors[0]);	
	
	if ($do == "create") {
		$passok = 0;$unameok = 1;$cbars = 0;$emailok = 1;$allfieldsok = 0;$createok = 0;$sansok = 0;$dispok = 1;
		if (isset($_POST["username"]) && isset($_POST["email"]) && isset($_POST["pass"]) && isset($_POST["pass2"]) && isset($_POST["dispname"]) && isset($_POST["squest"]) && isset($_POST["sans"])) {
			if ($_POST["username"] != "" && $_POST["email"] != "" && $_POST["pass"] != "" && $_POST["pass2"] != "" && $_POST["dispname"] != "" && $_POST["squest"] != "" && $_POST["sans"] != "") {
				$allfieldsok = 1;
				if ($_POST["pass"] == $_POST["pass2"]) {
					$passok = 1;
				}
				if (substr_count($_POST["username"],"|") > 0) {
					$unameok = 0;
					$cbars = 1;
				}
				if ($_POST["sans"] == $_POST["sans2"]) {
					$sansok = 1;
				}
				$id = 0;
				foreach ($members as $memb) {
					$gts = explode("|",$memb);
					if ($gts[1] == $_POST["username"]) {
						$unameok = 0;
					}
					if ($gts[4] == $_POST["email"]) {
						$emailok = 0;
					}
					if ($gts[5] == $_POST["dispname"]) {
						$dispok = 0;
					}
				}
			}
		}
		if ($passok && $unameok && $emailok && $allfieldsok && $dispok && $sansok) {
			$createok = 1;
			$newline = array($_POST["username"],md5($_POST["pass"]),$newlevel,$_POST["email"],stripslashes($_POST["dispname"]),time()+$time_offset,$_POST["squest"],md5($_POST["sans"]),$_POST["hideemail"],0,"0",stripslashes($_POST["sign"]));
		}
	}
	
	if ($do == "docreate") {
		if (isset($_POST["uname"])) {
			$createok = 1;
			foreach ($members as $line) {
				$gt = explode("|",$line);
				$id = $gt[0]+1;
			}
			if ($require_approval) {
				$level = 1;
			}
			else {
				$level = 2;
			}
			$writeline = "\n$id|" . $_POST["uname"] . "|" . $_POST["pass"] . "|$level|" . $_POST["email"] . "|" . $_POST["dispname"] . "|" . $_POST["new5"] . "|" . $_POST["new6"] . "|" . $_POST["new7"] . "|" . $_POST["new8"] . "|0|0|" . $_POST["new11"];
			$cp = 0;
			while ($cp < 5) {
				$cp++;
				$Siteman->wait_for_unlock("data/members.txt",200);
				if (!$Siteman->is_locked("data/members.txt")) {
					$Siteman->write_lock("data/members.txt");
					$fp = fopen("data/members.txt","a");
					fwrite($fp,$writeline);
					fclose($fp);
					$Siteman->write_unlock("data/members.txt");
					$cp = 400;
				}
			}
		}
		else {
			$createok = 0;
		}
	}
	
	if ($do == "resetpass") {
		$fieldsok = 0;$passok = 0;$userok = 0;$sansok = 0;
		if (isset($_POST["ma"]) && isset($_POST["sans"])&& isset($_POST["pass"]) && isset($_POST["pass2"])) {
			$fieldsok = 1;
			if ($_POST["pass"] != "" && $_POST["pass2"] != "" && $_POST["pass"] == $_POST["pass2"]) {
				$passok = 1;
				$old = $Siteman->db_get(4,$_POST["ma"],"data/members");
				if ($old[0]) {
					if (md5($_POST["sans"]) == $old[5]) {
						$sansok = 1;
						$userok = 1;
						$old[2] = md5($_POST["pass2"]);
						$wrt = implode("|",$old);
						$gts = file("data/members.txt");
						$first = 1;
						$cp = 0;
						while ($cp < 5) {
							$cp++;
							$Siteman->wait_for_unlock("data/members.txt",200);
							if (!$Siteman->is_locked("data/members.txt")) {
								$Siteman->write_lock("data/members.txt");
								$fp = fopen("data/members.txt","w");
								foreach ($gts as $gst) {
									$gst = trim($gst);
									if ($first) {
										$first = 0;
									}
									else {
										fwrite($fp,"\n");
									}
									$info = explode("|",$gst);
									if ($info[0] == $old[0]) {
										fwrite($fp,trim($wrt));
									}
									else {
										fwrite($fp,$gst);
									}
								}
								fclose($fp);
								$Siteman->write_unlock("data/members.txt");
								$cp = 400;
							}
						}
					}
				}
			}
		}
	}
	
	if ($do == "chinfo") {
		if ($Siteman->loginok) {
			$info = $Siteman->db_get(0,$Siteman->userid,"data/members");
			$update = $info;
			$members = file("data/members.txt");
			$chpass = 0;$chsans = 0;$passok = 0;$oldpassok = 0;$sansok = 0;$fieldsok = 0;$emailok = 1;$dispok = 1;
			if (isset($_POST["disp"]) && $_POST["disp"] != "" && isset($_POST["email"]) && $_POST["email"] != "" && isset($_POST["squest"]) && $_POST["squest"] != "") {
				$fieldsok = 1;
				if (isset($_POST["newpass"]) && $_POST["newpass"] != "") {
					$chpass = 1;
					if (md5($_POST["oldpass"]) == $info[2]) {
						$oldpassok = 1;
						if ($_POST["newpass"] == $_POST["newpass2"]) {
							$passok = 2;
							$update[2] = md5($_POST["newpass"]);
							$Siteman->cookie($admincookie,$Siteman->userid . "|" . $_POST["newpass"],time()+604800);
						}
					}
				}
				if (isset($_POST["sans"]) && $_POST["sans"] != "") {
					$chsans = 1;
					if (md5($_POST["oldpass"]) == $info[2]) {
						if ($_POST["sans"] == $_POST["sans2"]) {
							$sansok = 1;
							$update[8] = md5($_POST["sans"]);
						}
					}
				}
				foreach ($members as $lines) {
					$gt = explode("|",$lines);
					if ($gt[0] != $Siteman->userid) {
						if ($gt[4] == $_POST["email"]) {
							$emailok = 0;
						}
						if ($gt[5] == $_POST["disp"]) {
							$dispok = 0;
						}
					}
				}
				if ($emailok) {
					$update[4] = $_POST["email"];
				}
				if ($dispok) {
					$update[5] = stripslashes($_POST["disp"]);
				}
				$update[7] = $_POST["squest"];
				$update[9] = $_POST["hideemail"];
				$update[12] = stripslashes($_POST["sign"]);
				$wrt = implode("|",$update);
				$first = 1;
				$fp = fopen("data/members.txt","w");
				foreach ($members as $line) {
					$line = trim($line);
					if ($first) {
						$first = 0;
					}
					else {
						fwrite($fp,"\n");
					}
					$int = explode("|",$line);
					if ($int[0] == $Siteman->userid) {
						fwrite($fp,trim($wrt));
					}
					else {
						fwrite($fp,$line);
					}
				}
				fclose($fp);
			}
		}
	}
	if ($do == "dodelacc") {
		if ($Siteman->loginok) {
			if ($Siteman->userid != "1" && $Siteman->mlevel != "5") {
				$fieldsok = 0;$passok = 0;$sansok = 0;$sure = 0;
				if (isset($_POST["sans"]) && $_POST["sans"] != "" && isset($_POST["pass"]) && $_POST["pass"] != "" && isset($_POST["sure"]) && $_POST["sure"] == 1) {
					$fieldsok = 1;
					$sure = 1;
					$user = $Siteman->db_get(0,$Siteman->userid,"data/members");
					if (md5($_POST["sans"]) == $user[8]) {
						$sansok = 1;
						if (md5($_POST["pass"]) == $user[2]) {
							$passok = 1;
							$gt = file("data/members.txt");
							$fp = fopen("data/members.txt","w");
							$first = 1;
							foreach ($gt as $gtr) {
								$gtr = trim($gtr);
								$it = explode("|",$gtr);
								if ($it[0] != $user[0]) {
									if ($first) {
										$first = 0;
									}
									else {
										fwrite($fp,"\n");
									}
									fwrite($fp,$gtr);
								}
							}
							fclose($fp);
							$Siteman->logout();
						}
					}
				}
			}
		}
	}
	
	if ($do == "ppm") {
		if ($Siteman->loginok) {
			$to = $Siteman->db_get(0,$_GET["id"],"data/members");
			$id = 0;
			$pms = array();
			if ($to[13] != "") {
				$pms = explode(";",$to[13]);
				foreach ($pms as $pmr) {
					$ita = explode(":",$pmr);
					$id = $ita[0];
				}
			}
			$id++;
			$new[0] = $id;
			$new[1] = 1;
			$new[2] = $Siteman->userid;
			$new[3] = time()+$time_offset;
			if (strlen($_POST["msg"]) > 250) {
				$_POST["msg"] = substr($_POST["msg"],0,250);
			}
			$new[4] = stripslashes(str_replace("\r","",str_replace("\n","##NEWLINE##",str_replace(":","##COLON##",str_replace(";","##SCOLON##",str_replace("|","&brvbar;",$_POST["msg"]))))));
			$arrid = count($pms);
			$pms[$arrid] = implode(":",$new);
			$newpms = implode(";",$pms);
			$members = file("data/members.txt");
			$fp = fopen("data/members.txt","w");
			foreach ($members as $gts) {
				$gts = trim($gts);
				$gtr = explode("|",$gts);
				if ($gtr[0] > 1) {
					fwrite($fp,"\n");
				}
				if ($gtr[0] == $to[0]) {
					$gtr[12] .= " ";
					if (strlen($gtr[12] > 1)) {
						$gtr[12] = rtrim($gtr[12]);
					}
					$gtr[13] = trim($newpms);
					$gts = implode("|",$gtr);
				}
				fwrite($fp,$gts);
			}
			fclose($fp);
		}
	}
	
	$Siteman->load_lang("users");
	$Siteman->load_lang("forum");
	$title_bar = $heading;
	$page_title = $heading;
	if ($do == "list") {
		$title_bar = $Siteman->lang["mlist"];
		$page_title = $title_bar;
	}
	if ($do == "inbox") {
		$usr = $Siteman->db_get(0,$Siteman->userid,"data/members");
		if ($usr[13] == "") {
			$do = "edinfo";
		}
		else {
			$fp = fopen("data/members.txt","w");
			foreach ($members as $gti) {
				$gti = trim($gti);
				$gtr = explode("|",$gti);
				if ($gtr[0] > 1) {
					fwrite($fp,"\n");
				}
				if ($gtr[0] == $Siteman->userid) {
					$pms = explode(";",$gtr[13]);
					$i = 0;
					while (isset($pms[$i])) {
						$gvrs = explode(":",$pms[$i]);
						$gvrs[1] = 0;
						$pms[$i] = implode(":",$gvrs);
						$i++;
					}
					$gtr[13] = implode(";",$pms);
					$gti = implode("|",$gtr);
				}
				fwrite($fp,$gti);
			}
			fclose($fp);
			$Siteman->newmsg = 0;
		}
	}
	
	if ($do == "dpm") {
		if ($Siteman->loginok) {
			$id = $_GET["id"];
			$usr = $Siteman->db_get(0,$Siteman->userid,"data/members");
			$pms = explode(";",$usr[13]);
			$msgs = array();
			$i = 0;
			foreach ($pms as $pmi) {
				$inf = explode(":",$pmi);
				if ($inf[0] != $id) {
					$msgs[$i] = $pmi;
					$i++;
				}
			}
			$usr[13] = implode(";",$msgs);
			$wrtr = implode("|",$usr);
			$fp = fopen("data/members.txt","w");
			foreach ($members as $gtr) {
				$gtr = trim($gtr);
				$gti = explode("|",$gtr);
				if ($gti[0] > 1) {
					fwrite($fp,"\n");
				}
				if ($gti[0] == $Siteman->userid) {
					fwrite($fp,$wrtr);
				}
				else {
					fwrite($fp,$gtr);
				}
			}
			fclose($fp);
			$do = "inbox";
		}
	}
	
	if ($do == "inbox") {
		$title_bar = $Siteman->lang["inbox"];
		$page_title = $title_bar;
	}
		
	include("data/page_header.php");
	if ($Siteman->loginok && $do != "edinfo") {
		echo"<a href=\"users.php?do=edinfo\">" . $Siteman->lang["changedets"] . "</a><br /><br />";
	}
		switch ($do) {
			case "new":
				if (!$Siteman->loginok) {
					echo"<br /><br /><b>" . $Siteman->lang["register"] . "</b><br /><br />" . $Siteman->lang["fillin"] . "<br />				
					<form action=\"users.php?do=create\" method=\"post\"><table cellspacing=\"0\" cellpadding=\"1\"><tr><td width=\"40%\">" . $Siteman->lang["username"] .
					"</td><td>&nbsp;<input type=\"text\" size=\"40\" name=\"username\" /></td></tr><tr><td>" . $Siteman->lang["email"] .
					"</td><td>&nbsp;<input type=\"text\" size=\"40\" name=\"email\" /></td></tr><tr><td>" . $Siteman->lang["password"] .
					"</td><td>&nbsp;<input type=\"password\" size=\"40\" name=\"pass\" /></td></tr><tr><td>" . $Siteman->lang["cpass"] .
					"</td><td>&nbsp;<input type=\"password\" size=\"40\" name=\"pass2\" /></td></tr><tr><td>" . $Siteman->lang["dispexp"] .
					"</td><td>&nbsp;<input type=\"text\" size=\"40\" name=\"dispname\" /></td></tr><tr><td>" . $Siteman->lang["squest"] .
					"</td><td>&nbsp;<input type=\"text\" size=\"40\" name=\"squest\" /></td></tr><tr><td>" . $Siteman->lang["sans"] . $Siteman->lang["casesens"] .
					"</td><td>&nbsp;<input type=\"password\" size=\"40\" name=\"sans\" /></td></tr><tr><td>" . $Siteman->lang["repsans"] .
					"</td><td>&nbsp;<input type=\"password\" size=\"40\" name=\"sans2\" /></td></tr><tr><td>" . $Siteman->lang["hideemail"] .
					"</td><td>&nbsp;<table cellspacing=\"0\" cellpadding=\"0\"><tr><td><input type=\"radio\" name=\"hideemail\" value=\"1\" /></td><td>" . $Siteman->lang["yes"] . "</td><td><input type=\"radio\" name=\"hideemail\" value=\"0\" checked /></td><td>" .
					$Siteman->lang["no"] . "</td></tr></table></tr></td><tr><td>" . $Siteman->lang["sign"] .
					"</td><td>&nbsp;<input type=\"text\" size=\"40\" name=\"sign\" /></td></tr><tr><td><input type=\"submit\" value=\"" .
					$Siteman->lang["register"] . "\" /></td><td>&nbsp;</td></tr></table></form>";
				}
				else {
					echo $Siteman->lang["alreadyreg"];
				}
				break 1;
			
			case "create":
				if ($createok) {
					echo "<b>" . $Siteman->lang["datareg"] . "</b><br /><br /><table cellspacing=\"0\" cellpadding=\"2\"><tr><td>" .
					$Siteman->lang["username"] . $Siteman->lang["forlogin"] . "</td><td align=\"right\">" . $_POST["username"] . "</td></tr><tr><td>" .
					$Siteman->lang["password"] . "</td><td align=\"right\"><form><select><option>" . $Siteman->lang["showpass"] . "</option>
					<option>" . $_POST["pass"] . "</option></select></form></td></tr><tr><td>" . $Siteman->lang["squest"] . "</td><td align=\"right\">" . $_POST["squest"] . "</td></tr><tr><td>" .
					$Siteman->lang["sans"] . "</td><td align=\"right\"><form><select><option>" . $Siteman->lang["showans"] . "</option><option>" . $_POST["sans"] .
					"</option></select></form></td></tr><tr><td>" . $Siteman->lang["realname"] . "</td><td align=\"right\">" . stripslashes($_POST["dispname"]) . "</td></tr><tr><td>" . $Siteman->lang["mlevel"] . "</td><td align=\"right\"><b>2</b> (" .
					$Siteman->lang["member"] . ")</td></tr><tr><td>" . $Siteman->lang["email"] . "</td><td align=\"right\">" . $_POST["email"] . "</td></tr><tr><td>" .
					$Siteman->lang["hideemail"] . "</td><td align=\"right\">" . str_replace("0",$Siteman->lang["no"],str_replace("1",$Siteman->lang["yes"],$_POST["hideemail"])) . "</td></tr><tr><td>" .
					$Siteman->lang["sign"] . "</td><td align=\"right\">" . stripslashes($_POST["sign"]) . "</td></table><br /><br />" .
					$Siteman->lang["iscorrect"] . "<br /><table cellspacing=\"0\" cellpadding=\"3\"><tr><td>
					<form action=\"users.php?do=new\" method=\"post\"><input type=\"submit\" value=\"" . $Siteman->lang["no"] . "\" /></form></td><td><form action=\"users.php?do=docreate\" method=\"post\">
					<input type=\"hidden\" name=\"uname\" value=\"". $_POST["username"] ."\" />
					<input type=\"hidden\" name=\"pass\" value=\"". $newline[1] ."\" />
					<input type=\"hidden\" name=\"email\" value=\"". $newline[3] ."\" />
					<input type=\"hidden\" name=\"dispname\" value=\"$newline[4]\" />
					<input type=\"hidden\" name=\"new5\" value=\"$newline[5]\" />
					<input type=\"hidden\" name=\"new6\" value=\"$newline[6]\" />
					<input type=\"hidden\" name=\"new7\" value=\"$newline[7]\" />
					<input type=\"hidden\" name=\"new8\" value=\"$newline[8]\" />
					<input type=\"hidden\" name=\"new11\" value=\"$newline[11]\" />
					<input type=\"submit\" value=\"" . $Siteman->lang["yes"] . "\" /></form></td></tr></table>";
				}
				else {
					echo $Siteman->lang["erroroccured"] . "<br /><br />";
					if (!$allfieldsok) {
						echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["allfieldsfilled"] . "</span><br />";
					}
					else if (!$passok) {
						echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["passnomatch"] . "</span><br />";
					}
					if (!$unameok) {
						if ($cbars) {
							echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["containsbars"] . "</span><br />";
						}
						else {
							echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["usertaken"] . "</span><br />";
						}
					}
					
					if (!$emailok) {
						echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["emailused"] . "</span><br />";
					}
					if (!$sansok) {
						echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["sansnomatch"] . "</span><br />";
					}
					if (!$dispok) {
						echo"<span style=\"color: #BB0000;\">" . $Siteman->lang["disptaken"] . "</span><br />";
					}
					echo"<br />" . $Siteman->lang["pleasecorrect"];
				}
				break 1;
				
			case "docreate":
				if ($createok) {
					echo $Siteman->lang["createdone"];
				}
				else {
					echo $Siteman->lang["error"];
				}
				break 1;
			
			case "forgotpass":
				if ($Siteman->loginok == 0) {
					echo"<b>" . $Siteman->lang["forgotpass"] . "</b><br /><br /><form action=\"users.php?do=showsec\" method=\"post\">
					<table cellspacing=\"0\" cellpadding=\"3\"><tr><td>" . $Siteman->lang["entemail"] . "&nbsp;&nbsp;</td><td><input type=\"text\" size=\"50\" name=\"mail\" /></td>
					<td><input type=\"submit\" value=\"" . $Siteman->lang["go"] . "\" /></td></tr></table></form><br /><br /><br />";
				}
				break 1;
			
			case "showsec":
				if (isset($_POST["mail"])) {
					$nowuser = $Siteman->getuserinfo(4,$_POST["mail"]);
					if ($nowuser[0]) {
						echo"<b>" . $Siteman->lang["forgotpass"] . "</b><br /><br /><form action=\"users.php?do=resetpass\" method=\"post\"><input type=\"hidden\" name=\"ma\" value=\"$nowuser[4]\" />
						<table cellspacing=\"0\" cellpadding=\"3\"><tr><td>" . $Siteman->lang["uname"] . "</td><td>$nowuser[1]</td></tr><tr><td><b>" . $Siteman->lang["squ"] . ":</b></td><td>$nowuser[7]</td></tr>
						<tr><td><b>" . $Siteman->lang["ans"] . " " . $Siteman->lang["casesens"] . "</b></td><td><input type=\"password\" size=\"35\" name=\"sans\" /></td></tr>
						<tr><td>" . $Siteman->lang["newpass"] . "</td><td><input type=\"password\" size=\"35\" name=\"pass\" /></td></tr>
						<tr><td>" . $Siteman->lang["repnewpass"] . "</td><td><input type=\"password\" size=\"35\" name=\"pass2\" /></td></tr>
						<tr><td>&nbsp;</td><td><input type=\"submit\" value=\"" . $Siteman->lang["resetpass"] . "\" /></td></tr></table></form>";
					}
					else {
						echo"<span style=\"color:#BB0000\">" . $Siteman->lang["emailnotfound"] . "</span>";
					}
				}
				break 1;
			
			case "resetpass":
				if (!$fieldsok) {
					echo "<span style=\"color:#BB0000;\">" . $Siteman->lang["allfieldsfilled"] . "</span><br />";
				}
				if (!$passok) {
					echo "<span style=\"color:#BB0000;\">" . $Siteman->lang["passnomatch"] . "</span><br />";
				}
				if (!$sansok) {
					echo"<span style=\"color:#BB0000;\">" . $Siteman->lang["sanserr"] . "</span><br />";
				}
				if ($userok) {
					echo $Siteman->lang["passwordreset"];
				}
				break 1;
			
			case "edinfo":
				if ($Siteman->loginok) {
					$info = $Siteman->getuserinfo(0,$Siteman->userid);
					echo"<b>" . $Siteman->lang["changedets"] . "</b><br /><br /><form action=\"users.php?do=chinfo&amp;id=" . $Siteman->userid . "\" method=\"post\">
					<table cellspacing=\"0\" cellpadding=\"2\"><tr><td>" . $Siteman->lang["dispexp"] . "</td><td><input type=\"text\" size=\"35\" name=\"disp\" value=\"" . htmlspecialchars($info[5]) . "\" />
					</td></tr><tr><td>" . $Siteman->lang["email"] . "</td><td><input type=\"text\" size=\"35\" name=\"email\" value=\"$info[4]\" /></td></tr>
					<tr><td>" . $Siteman->lang["oldpass"] . " " . $Siteman->lang["dontentert"] . "</td><td><input type=\"password\" size=\"35\" name=\"oldpass\" /></td></tr>
					<tr><td>" . $Siteman->lang["newpass"] . " " . $Siteman->lang["dontenter"] . "</td><td><input type=\"password\" size=\"35\" name=\"newpass\" /></td></tr>
					<tr><td>" . $Siteman->lang["repnewpass"] . " " . $Siteman->lang["dontenter"] . "</td><td><input type=\"password\" size=\"35\" name=\"newpass2\" /></td></tr>
					<tr><td>" . $Siteman->lang["squest"] . "</td><td><input type=\"text\" size=\"35\" name=\"squest\" value=\"$info[7]\" /></td></tr>
					<tr><td>" . $Siteman->lang["sans"] . " " . $Siteman->lang["casesens"] . $Siteman->lang["dontentersans"] . "</td><td><input type=\"password\" size=\"35\" name=\"sans\" /></td></tr>
					<tr><td>" . $Siteman->lang["repsans"] . " " . $Siteman->lang["dontentersans"] . "</td><td><input type=\"password\" size=\"35\" name=\"sans2\" /></td></tr>
					<tr><td>" . $Siteman->lang["mlevel"] . "</td><td>" . $Siteman->mlevel . "</td></tr>
					<tr><td>" . $Siteman->lang["hideemail"] . "</td><td><input type=\"radio\" name=\"hideemail\" value=\"1\"";
					if (trim($info[9]) == 1) { echo" checked"; }
					echo" />&nbsp;" . $Siteman->lang["yes"] . "<input type=\"radio\" name=\"hideemail\" value=\"0\"";
					if (trim($info[9]) == 0) { echo" checked"; }
					echo" />&nbsp;" . $Siteman->lang["no"] . "</td></tr>
					<tr><td>" . $Siteman->lang["sign"] . "</td><td><input type=\"text\" size=\"35\" name=\"sign\" value=\"" . htmlspecialchars($info[12]) . "\" /></td></tr>
					<tr><td>&nbsp;</td><td><input type=\"submit\" value=\"" . $Siteman->lang["savedata"] . "\" /></td></tr></table></form><a href=\"users.php?do=delacc\">" . $Siteman->lang["delacc"] . "</a>";
				}
				break 1;
			
			case "chinfo":
				if ($Siteman->loginok) {
					if ($fieldsok) {
						echo $Siteman->lang["infoch"] . "<br /><br /><table cellspacing=\"0\" cellpadding=\"2\">";
						if ($chpass) {
							if ($passok) {
								echo "<tr><td>" . $Siteman->lang["passwordch"] . "</td><td><form><select><option>" . $Siteman->lang["showpass"] . "</option><option>" . $_POST["newpass"] .
								"</option></select></form></td></tr>";
							}
							else if (!$oldpassok) {
								echo"<tr><td>&nbsp;</td><td><span style=\"color:#BB0000;\">" . $Siteman->lang["passerr"] . "</span></td></tr>";
							}
							else if (!$passok) {
								echo"<tr><td>&nbsp;</td><td><span style=\"color:#BB0000;\">" . $Siteman->lang["passerrnomatch"] . "</span></td></tr>";
							}
						}
						echo"<tr><td>" . $Siteman->lang["squest"] . "</td><td>" . $_POST["squest"] . "</td></tr>";
						if ($chsans) {
							if ($sansok) {
								echo"<tr><td>" . $Siteman->lang["sansch"] . "</td><td><form><select><option>" . $Siteman->lang["showans"] . "</option><option>" . $_POST["sans"] . "</option></select></form></td></tr>";
							}
							else if (!$oldpassok) {
								echo"<tr><td>&nbsp;</td><td><span style=\"color:#BB0000;\">" . $Siteman->lang["sanspasserr"] . "</span></td></tr>";
							}
							else if (!$sansok) {
								echo"<tr><td>&nbsp;</td><td><span style=\"color:#BB0000;\">" . $Siteman->lang["sanserrnomatch"] . "</span></td></tr>";
							}
						}
						echo"<tr><td>" . $Siteman->lang["email"] . "</td><td>" . $_POST["email"] . "</td></tr>";
						echo"<tr><td>" . $Siteman->lang["realname"] . "</td><td>" . stripslashes($_POST["disp"]) . "</td></tr>";
						echo"<tr><td>" . $Siteman->lang["hideemail"] . "</td><td>" . str_replace("1",$Siteman->lang["yes"],str_replace("0",$Siteman->lang["no"],$_POST["hideemail"])) . "</td></tr>
						<tr><td>" . $Siteman->lang["sign"] . "</td><td>" . stripslashes($_POST["sign"]) . "</td></tr></table>";
					}
					else {
						echo"<span style=\"color:#BB0000;\">" . $Siteman->lang["infonoch"] . "</span>";
					}
				}
				break 1;
			
			case "delacc":
				if ($Siteman->loginok) {
					if ($Siteman->userid != "1" && $Siteman->mlevel != "5") {
						$inf = $Siteman->getuserinfo(0,$Siteman->userid);
						echo $Siteman->lang["delent"] . "<br /><br /><form action=\"users.php?do=dodelacc\" method=\"post\">
						<table cellspacing=\"0\" cellpadding=\"2\"><tr><td><b>" . $Siteman->lang["squ"] . "</b></td><td>$inf[7]</td></tr>
						<tr><td><b>" . $Siteman->lang["ans"] . "</b></td><td><input type=\"password\" size=\"35\" name=\"sans\" /></td></tr>
						<tr><td><b>" . $Siteman->lang["password"] . "</b></td><td><input type=\"password\" size=\"35\" name=\"pass\" /></td></tr>
						<tr><td align=\"right\"><input type=\"checkbox\" value=\"1\" name=\"sure\" /></td><td>" . $Siteman->lang["sure"] . "</td></tr>
						<tr><td>&nbsp;</td><td><input type=\"submit\" value=\"" . $Siteman->lang["delete"] . "\" /></td></tr></table></form>";
					}
					else {
						echo $Siteman->lang["nodel"];
					}
				}
				break 1;
			
			case "dodelacc":
				if ($fieldsok && $passok && $sansok && $sure) {
					echo $Siteman->lang["accdeleted"];
				}
				else {
					echo $Siteman->lang["accnodel"];
				}
				break 1;
							
			case "list":
				if ($Siteman->loginok && $Siteman->mlevel > 1) {
					$Siteman->load_lang["forum"];
					if (isset($_GET["sort"])) {
						$sort = $_GET["sort"];
					}
					else {
						$sort = "j";
					}
					if ($sort == "u" && $Siteman->mlevel < 2) {
						$sort = "j";
					}
					$gts = file("data/members.txt");
					switch ($sort) {
						case "u":
							$field = 1;
							break 1;
						case "l":
							$field = 3;
							break 1;
						case "d":
							$field = 5;
							break 1;
						case "e":
							$field = 4;
							break 1;
						case "o":
							$field = 10;
							break 1;
						default:
							$sort = "j";
							$field = 0;
							break 1;
					}
					$i = 0;
					while (isset($gts[$i])) {
						$igs = explode("|",$gts[$i]);
						$sorted[$i] = strtolower($igs[$field]) . "|" . trim($gts[$i]);
						$i++;
					}
					if ($sort != "j") {
						sort($sorted);
					}
					if ($sort == "l" || $sort == "o") {
						$sorted = array_reverse($sorted);
					}
					echo"<table cellspacing=\"1\" cellpadding=\"2\" width=\"100%\"><tr><td class=\"g\">" . $Siteman->lang["online"] . "</td>";
					if ($Siteman->mlevel >= 3) {
						echo"<td class=\"g\">";
						if ($sort == "u") { echo"<b>" . $Siteman->lang["username"] . "</b>"; }
						else { echo"<a class=\"g\" href=\"users.php?do=list&amp;sort=u\">" . $Siteman->lang["username"] . "</a>"; }
						echo"</td>";
					}
					echo"<td class=\"g\">&nbsp;</td><td class=\"g\">";
					if ($sort == "l") { echo"<b>" . $Siteman->lang["mlevel"] . "</b>"; }
					else { echo"<a class=\"g\" href=\"users.php?do=list&amp;sort=l\">" . $Siteman->lang["mlevel"] . "</a>"; }
					echo"</td><td class=\"g\">";
					if ($sort == "d") { echo"<b>" . $Siteman->lang["realname"] . "</b>"; }
					else { echo"<a class=\"g\" href=\"users.php?do=list&amp;sort=d\">" . $Siteman->lang["realname"] . "</a>"; }
					echo"</td><td class=\"g\">";
					if ($sort == "e") { echo"<b>" . $Siteman->lang["email"] . "</b>"; }
					else { echo"<a class=\"g\" href=\"users.php?do=list&amp;sort=e\">" . $Siteman->lang["email"] . "</a>"; }
					echo"</td><td class=\"g\">";
					if ($sort == "j") { echo"<b>" . $Siteman->lang["joined"] . "</b>"; }
					else { echo"<a class=\"g\" href=\"users.php?do=list\">" . $Siteman->lang["joined"] . "</a>"; }
					echo"</td><td class=\"g\">";
					if ($sort == "o") { echo"<b>" . $Siteman->lang["last"] . "</b>"; }
					else { echo"<a class=\"g\" href=\"users.php?do=list&amp;sort=o\">" . $Siteman->lang["last"] . "</a>"; }
					echo"</td></tr>";
					foreach ($sorted as $gtr) {
						$info = explode("|",$gtr);
						if (trim($info[10])) {
							$info[5] = $Siteman->lang["hidden"];
						}
						$join = date($long_dateformat,$info[7]);
						if (trim($info[11])) {
							$last = date($long_dateformat,trim($info[11]));
						}
						else {
							$last = "<i>never</i>";
						}
						if (trim($info[11])+300 > time()+$time_offset) {
							$online = $Siteman->lang["yes"];
						}
						else {
							$online = "&nbsp;";
						}
						$levexp = str_replace("2",$Siteman->lang["member"],str_replace("3",$Siteman->lang["admin"],str_replace("4",$Siteman->lang["sadmin"],str_replace("5",$Siteman->lang["sowner"],$info[4]))));
						echo"<tr><td>$online</td>";
						if ($Siteman->mlevel >= 3) {
							echo"<td>$info[2]</td>";
						}
						echo"<td><a href=\"users.php?do=spm&amp;id=$info[1]\">" . $Siteman->lang["spm"] . "</a></td><td><b>$info[4]</b> ($levexp)</td><td>$info[6]</td><td>$info[5]</td><td>$join</td><td";
						if (date("d.m.y",trim($info[11])) == date("d.m.y",time()+$time_offset)) {
							echo" class=\"g\"";
						}
						echo">$last</td></tr>";
					}
					echo"</table>";
				}
				else {
					echo $Siteman->lang["monly"];
				}
				break 1;
			
			case "spm":
				if ($Siteman->loginok) {
					$to = $Siteman->db_get(0,$_GET["id"],"data/members");
					if ($to[0] == $Siteman->userid) {
						$rec = str_replace("%user%",$Siteman->lang["self"],$Siteman->lang["spmtu"]);
					}
					else {
						$rec = str_replace("%user%",$to[5],$Siteman->lang["spmtu"]);
					}
					echo"<b>$rec</b><br /><br />
					<form action=\"users.php?do=ppm&amp;id=$to[0]\" method=\"post\" id=\"pmform\" name=\"pmform\">
					<table cellspacing=\"0\" cellpadding=\"2\">
					<tr><td>" . $Siteman->lang["pmsg"] . "</td><td><textarea onkeydown=\"update();\" onkeyup=\"update();\"  rows=\"12\" cols=\"50\" name=\"msg\" id=\"msg\"></textarea></td></tr>
					<tr><td>&nbsp;</td><td><table cellspacing=\"0\" cellpadding=\"2\" align=\"right\"><tr><td>" . $Siteman->lang["chleft"] . "</td><td><input type=\"text\" size=\"5\" onkeydown=\"update();\" onkeyup=\"update();\" name=\"chs\" id=\"chs\" value=\"250\" /></td></tr></table></td></tr>
					<tr><td><input type=\"submit\" value=\"" . $Siteman->lang["send"] . "\" /></td><td>&nbsp;</td></tr></table></form>
					<script language=\"Javascript\" type=\"text/javascript\">
					function update() {
						if (document.pmform.msg.value.length > 250) {
							document.pmform.msg.value = document.pmform.msg.value.substring(0,250);
						}
						var left = 250-document.pmform.msg.value.length;
						document.pmform.chs.value = left;
					}
					</script>";
				}
				break 1;
			
			case "ppm":
				if ($Siteman->loginok) {
					echo"<br /><br /><br />" . $Siteman->lang["wassent"] . "<br /><br /><br />";
				}
				break 1;
			
			case "inbox":
				if ($Siteman->loginok) {
					if ($usr[13] != "") {
						$pms = explode(";",$usr[13]);
						echo"<b>" . $Siteman->lang["inbox"] . "</b><br /><br />
						<table cellspacing=\"1\" cellpadding=\"2\"><tr><td class=\"g\">&nbsp;</td><td class=\"g\">&nbsp;</td><td class=\"g\">" . $Siteman->lang["from"] . "</td><td class=\"g\">" . $Siteman->lang["date"] . "</td><td class=\"g\">" . $Siteman->lang["message"] . "</td></tr>";
						foreach ($pms as $pmr) {
							$pmi = explode(":",$pmr);
							if ($pmi[2] == $Siteman->userid) {
								$sender = $Siteman->lang["self"];
							}
							else {
								$stm = $Siteman->db_get(0,$pmi[2],"data/members");
								$sender = $stm[5] . " (<a href=\"users.php?do=spm&amp;id=$stm[0]\">" . $Siteman->lang["spm"] . "</a>)";
							}
							$date = date($long_dateformat,$pmi[3]);
							$message = str_replace("##COLON##",":",str_replace("##SCOLON##",";",str_replace("##NEWLINE##","<br />",$pmi[4])));
							echo"<tr><td>";
							if ($pmi[1]) {
								echo"<img src=\"images/new.gif\" />";
							}
							else {
								echo"<img src=\"images/nonew.gif\" />";
							}
							echo"</td><td><a href=\"users.php?do=dpm&amp;id=$pmi[0]\">" . $Siteman->lang["del"] . "</a></td><td>$sender</td><td>$date</td><td>$message</td></tr>";
						}
						echo"</table>";
					}
					else {
						echo"<br /><br /><br />" . $Siteman->lang["inempt"] . "<br /><br />";
					}
				}
				break 1;
		}
	include("data/page_footer.php");
?>
Return current item: Siteman personal website CMS