Location: PHPKode > projects > Mummi (Multi-user MOD_MP3 Interface) > mummi.0.6/lib/user_db.inc
<?

class USER_DB extends MYSQL_DB{



	// Declare all the varibles that will be used by this class.
	var $userdb_user_name;
	var $userdb_user_pass;
	var $userdb_user_email;

	// Main function to set whatever will be needed later in the class
	function USER_DB(){
		$this->userdb_user_name = $GLOBALS[user_name];
		$this->userdb_user_email = $GLOBALS[user_email];
	}//eo USER_DB function


	// This will check if an email address is valid or not.. just check the format hide@address.com
	function chk_email($user_email){
		if(!eregi("^[_\\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\\.)+[a-z]{2,3}$", trim($user_email))) return false;
		else return true;
	}//eo chk_email function


	// This will check for an existing user in the database
	function chk_user_name($user_name, $table="users"){
		$query = "SELECT user_name FROM $table WHERE user_name='$user_name'";
		if(!$this->num_rows($query)) return false;
		else return true;
	}//eo chk_user function


	// This will check for an existing password for a specified user
	function get_user_pass($user_name, $table="users"){
		$query = "SELECT user_pass FROM $table WHERE user_name='$user_name'";
		if(!$result_array = $this->fetch_numeric($query)) return false;
		else return $result_array[0][0];
	}


	// This function will get the username from the email addy in the db
	function get_user_name_from_email($user_email, $table="users"){
		$query = "SELECT user_name FROM $table WHERE user_email='$user_email'";
		if(!$result_array = $this->fetch_numeric($query)) return false;
		else return $result_array[0][0];
	}//eo get_user_name_from_email


	// returns an array with all the users information in it
	function get_user_info($user_name, $table="users"){
		$query = "SELECT * FROM $table WHERE user_name='$user_name'";
		if(!$result_array = $this->fetch_assoc($query)) return false;
		return $result_array[0];
	}





	// ADDED 2 functions 03.01.2002 by Jack Mays
	// This function will return the users navbox array

	// Sets the navbox array when the user is created...
	function set_navbox_array($user_name, $navbox_array, $table="user_prefrences"){
		$query = "INSERT INTO $table VALUES('NULL', '$user_name', '$navbox_array')";
		if(!$this->affected_rows($query)) return false;
		else return true;

	}


	// this functions will update
	function update_navbox_array($user_name, $navbox_array){
		$navbox_array = OVERSEER::encipher($navbox_array,$GLOBALS[secret_key]);
		$query = "UPDATE user_prefrences SET user_navbox_array='$navbox_array' WHERE user_name='$user_name'";
		//echo serialize($navbox_array)."<br>";
		if(!$this->affected_rows($query)) return false;
		else return true;
	}


	// This will check for an existing email address in the database
	function chk_user_email($user_email, $table="users"){
		$query = "SELECT user_email FROM $table WHERE user_email='$user_email'";
		if(!$this->num_rows($query)) return false;
		else return true;
	}//eo chk_user_email function



	// This fucntion generates a random password of "X" length using speakable works
	function pass_gen($length){
		srand((double)microtime()*1000000);
		$vowels = array("a", "e", "i", "o", "u");
		$cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
		"cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
		$num_vowels = count($vowels);
		$num_cons = count($cons);
		for($i = 0; $i < $length; $i++){
		    $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
		}
		return substr($password, 0, $length);
	}//eo pass_gen function


	function create_tmp_user($user_name, $user_pass, $first_name, $last_name, $user_email, $modified){
		$query = "INSERT INTO tmp_users VALUES(NULL, '$user_name', '$user_pass', '$first_name', '$last_name','$user_email', '$modified')";
		if(!$this->affected_rows($query)) return false;
		else return true;
	}

	function create_user($user_name, $user_pass, $first_name, $last_name, $user_email, $type, $status, $created, $modified){
		$query = "INSERT INTO users VALUES('NULL', '$user_name','$user_pass','$first_name','$last_name','$user_email','$type','$status','$created','$modified')";
		if(!$this->affected_rows($query)) return false;
		else return true;
	}


	// This will update the users password in the database...
	function update_user_pass($user_name, $user_pass){
		$query = "UPDATE users SET user_pass='$user_pass' WHERE user_name='$user_name'";
		if(!$this->affected_rows($query)) return false;
		else return true;
	}//eo update_user_pass


	// This will check for an existing user in the database
	function get_tmp_user($user_name, $table="tmp_users"){
		$query = "SELECT * FROM $table WHERE user_name='$user_name'";
		return $this->fetch_assoc($query);
	}//eo chk_user function






}//eo USERDB class

?>
Return current item: Mummi (Multi-user MOD_MP3 Interface)