Location: PHPKode > projects > Particle Blogger > particle-blogger/includes/admin.php
<?php
class Admin{

	// allow admins to update a users profile
	function EditUser($username, $email, $userlevel, $userid){
		
		// globalise variables
		global $db, $dbprefix, $usr;
		
		// authorise the user
		$usr->Auth(2);
		
		// validate information
		if ($username == ""){ return "You did not enter a username"; }
		if ($email == ""){ return "You did not enter an email address"; }
		
		// user level
		$level = intval($userlevel);
		if ($level == 2){
			$level = 2;
		} elseif ($level == 0) {
			$level = 0;
		} else {
			$level = 1;
		}
		
		// ok, go ahead and run update
		$sql = "UPDATE " . $dbprefix . "users SET username = '" . dbSecure($username);
		$sql .= "', email = '" . dbSecure($email) . "', status = " . $level . " WHERE ID = ";
		$sql .= $userid;
		$db->execute($sql);
		
		// and do confirmation
		return "User has been edited successfully!";
	}
	
	// allow admins to reset a password
	function EditPass($pass1, $pass2, $userid){
		
		// globalise variables
		global $dbprefix, $db, $usr;
		
		// authorise user
		$usr->Auth(2);
		
		// validate information
		if ($pass1 == ""){ return "You did not enter a password"; }
		if ($pass1 <> $pass2){ return "The passwords did not match"; }
		
		// ok, run the update
		$sql = "UPDATE " . dbSecure($dbprefix) . "users SET password = '" . md5(dbSecure($pass1)) . "' WHERE";
		$sql .= " ID = " . dbSecure($userid);
		$db->execute($sql);
		
		// and do confirmation
		return "The users password has been changed!";
	}
}
?>
Return current item: Particle Blogger