Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/shared/user_mysql.inc
<?php

# -----------------------------------------------------------------------------
#
# Contains all the MySQL querries for the user administration
#
# -----------------------------------------------------------------------------
#
# Copyright (C) 2003 Christian Eheim and Alex Pachikov
#
# This file is part of TVEz (tvez.sourceforge.net).
#
# TVEz is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# TVEz is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with TVEz; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# -----------------------------------------------------------------------------
#
# Created on 12/12/2003 by Christian Eheim (hide@address.com)
#
# LAST MODIFIED:
# $Date: 2004/02/03 00:10:20 $
# $Revision: 1.3 $
# $Author: eheim $
#
# -----------------------------------------------------------------------------

function get_all_users() {
	$query = "select * from users order by access,username";
	return query_user($query);
}

function get_user_by_name_and_passwd($name,$md5) {
	$query = "select * from users where username='$name' and password='$md5'";
	return query_user($query);
}

function get_user_by_name($name) {
	$query = "select * from users where username='$name'";
	return query_user($query);
}

function get_user_by_id($id) {
	$query = "select * from users where id=$id";
	return query_user($query);
}

function delete_user_by_id($id) {
	$query = "delete from users where id=$id";
	return query_user($query);
}

function get_admin_users() {
	$query = "select * from users where access='admin'";
	return query_user($query);
}

function create_user_account($user) {
	$user['id'] = '';
	$query = "replace into users values(
	'".$user['id']."','".$user['username']."','".$user['firstname']."','".$user['lastname']."','".$user['email']."','".$user['password']."','".$user['access']."')";
	return query_user($query);
}

function query_user($query) {
    global $MYSQL;
                                                                                
    if (! $db_connection = mysql_connect($MYSQL{'host'},$MYSQL{'user'},$MYSQL{'passwd'}) ) {
        dbErrorHandler(mysql_error());
        return array(0,0);
    }
    if (! $db_select = mysql_select_db($MYSQL{'db'}) ) {
        dbErrorHandler(mysql_error());
        return array(0,0);
    }
                                                                                
	$entries = array();
    if ($db_query = mysql_query($query,$db_connection)) {
        $success = mysql_affected_rows();
        while ($db_fields =  mysql_fetch_array($db_query)) {
            array_push($entries,$db_fields);
        }
    } else {
#        dbErrorHandler(mysql_error());
        $success = 0;
        $entries    = mysql_error();
    }
    mysql_close($db_connection);

	return array($success,$entries);
}

?>
Return current item: TVEz - Media Library