Location: PHPKode > scripts > LinkShort > LinkShort/users.php
<?php
	session_start();
	
	include('includes/settings.inc.php');
	include('includes/db.inc.php');
	include('includes/functions.inc.php');
	
	$hdrtheme = file_get_contents('themes/header.theme.html');
	$ftrtheme = file_get_contents('themes/footer.theme.html');
	$login = file_get_contents('themes/login.theme.html');
	if(!$_SESSION['ID']){
		if(!empty($_POST['uname']) && isset($_POST['uname'])){
			if(!empty($_POST['pass']) && isset($_POST['pass'])){
				$uname = htmlspecialchars($_POST['uname']);
				$pass = htmlspecialchars($_POST['pass']);
				FUNCT_VERIFY_PASS($uname, $pass);
			}else{
				//empty password
				$entirepage = $hdrtheme.$login.$ftrtheme;
			}
		}else{
			//empty username
			$entirepage = $hdrtheme.$login.$ftrtheme;
		}	
	}else{
		$act = htmlspecialchars($_GET['act'],ENT_QUOTES);

		switch($act){
			case 1:
				$mpage = file_get_contents('themes/userform.theme.html');
				$userbody = FUNCT_ADD_URL_FORM($mpage);
				if(isset($_GET['add'])&& !empty($_GET['add'])){
					$add = htmlspecialchars($_GET['add'],ENT_QUOTES);
				}
				if ($add == 'true'){
					$murl = htmlspecialchars($_POST['url'],ENT_QUOTES);
					$perm = htmlspecialchars($_POST['permanent'],ENT_QUOTES);
					$statusmsg = FUNCT_ADD_URL($murl, $perm);
				}
				break;
			case 2:
				$funct = htmlspecialchars($_GET['funct'],ENT_QUOTES);
				$id = htmlspecialchars($_GET['id'],ENT_QUOTES);
				
				switch($funct){
					case 1: //delete item
						mysql_query("DELETE FROM links WHERE UID = '".$id."' AND UNAME = '".$_SESSION['NICK']."' LIMIT 1") or die("<BR>" .mysql_errno().": ".mysql_error()."<BR>");
						$userbody = FUNCT_LIST_URLS();
						break;
					case 2:
						$mpage = file_get_contents('themes/userform.theme.html');
						$userbody = FUNCT_EDIT_URL_FORM($id,$mpage);
						break;
					case 3:
						$murl = htmlspecialchars($_POST['url'],ENT_QUOTES);
						$perm = htmlspecialchars($_POST['permanent'],ENT_QUOTES);
						mysql_query("UPDATE links SET MURL = '".$murl."', PERMANENT = '".$perm."' WHERE UID = '".$id."' AND UNAME = '".$_SESSION['NICK']."' LIMIT 1") or  die("<BR>" .mysql_errno().": ".mysql_error()."<BR>");
						$userbody = FUNCT_LIST_URLS();
						break;
				}
				
				break;
			case "logout":
				session_destroy();
				header("Location: #");
				break;
			default:
				$userbody = FUNCT_LIST_URLS();
		}
		$entirepage = $hdrtheme.$userbody.$statusmsg.$ftrtheme;	
	}
	
	if (strrpos($entirepage, '%LOGIN%') > 0){
		if($_SESSION['ID']){
			$entirepage = str_replace('%LOGIN%','<span><a href="users.php?act=logout">logout</a></span><span><a href="users.php">user area</span></a>',$entirepage);
		}else{
			$entirepage = str_replace('%LOGIN%','<span><a href="users.php">login</a></span>',$entirepage);
		}
	}
	
	echo $entirepage;
?>
Return current item: LinkShort