PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Garefild   PHP MySQL User Manager   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: example
Class: PHP MySQL User Manager
Manage users that access a MySQL database server
Author: By
Last change: delete: delete sql user
setHost: set sql user host
setPassword: set sql user password
setPrivileges: set sql user privileges
Date: 9 years ago
Size: 4,132 bytes
 

Contents

Class file image Download
<?php

/** I
 *
 * GGGGG A RRRR EEEEEE FFFFFF I L DDDD
 * G A A R R E F I L D D
 * G GGG A A R RR EEEEEE FFFFFF I L D D
 * G G AAAAAAA R R E F I L D D
 * GGGG A A R R EEEEEE F I LLLLLL DDDD
 *
 * Powered by Garefild
 * @Author Garefild
 * @Copyright 2010-2014
 *
 *
 * ********************************************************************************
 * ** -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- *
 * ** --------------------------------------------------------------------------- *
 * ** PHP index.php - www
 * ** Cerate: 11/15/2014
 * ** Developed by: Garefild <Garefild2@gmail.com> *
 * ********************************************************************************
 *
 */

include ('mysqlUserManager.php');

$users = new MysqlUserManager('localhost', 'root', '', 'db');


/**
 * Checks if a user exists
 * Must use isset
 */

//if(isset($users -> testUsername)) {
// //user exists
//}


/**
 * if testUsername exists (If you are an existing user can manipulate the user)
 * if testUsername not exists (If the user does not exist it creates a new user with the name without a password and server localhost)
 */

//$users -> testUsername;


/**
 * if testUsername exists (If you are an existing user can manipulate the user)
 * if testUsername not exists (If the user does not exist it creates a new user with the name)
 *
 * password the password
 * localhost the server
 */

//$users -> testUsername('password', 'localhost');

/**
 * Changing a user password
 */

//$users -> testUsername -> setPassword('123');


/**
 * Adding user permissions
 * Default Permissions - ALL PRIVILEGES + All the database and all the tables (*.*)
 *
 * ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
 * CREATE- allows them to create new tables or databases
 * DROP- allows them to them to delete tables or databases
 * DELETE- allows them to delete rows from tables
 * INSERT- allows them to insert rows into tables
 * SELECT- allows them to use the Select command to read through databases
 * UPDATE- allow them to update table rows
 * GRANT OPTION- allows them to grant or remove other users' privileges
 *
 * @param $privileges
 * @param string $database - database name or * for all database
 * @param string $table - table name or * for all table
 *
 */

//$users -> testUsername -> setPrivileges('ALL PRIVILEGES', 'database', 'table');

/**
 * Remove user permissions
 * Default Permissions - ALL PRIVILEGES + All the database and all the tables (*.*)
 *
 * ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
 * CREATE- allows them to create new tables or databases
 * DROP- allows them to them to delete tables or databases
 * DELETE- allows them to delete rows from tables
 * INSERT- allows them to insert rows into tables
 * SELECT- allows them to use the Select command to read through databases
 * UPDATE- allow them to update table rows
 * GRANT OPTION- allows them to grant or remove other users' privileges
 *
 * @param $privileges
 * @param string $database - database name or * for all database
 * @param string $table - table name or * for all table
 *
 */

//$users -> testUsername -> removePrivileges('CREATE, DROP, SELECT, UPDATE', 'database', 'table');

/**
 * delete user
 */

//$users -> testUsername -> delete();

/**
 * if user exists
 */

//if(isset($users -> garefild)) {
//
//} else {
//
//}


$users -> administrator -> setPassword('123') -> setHost('192.168.1.1') -> setPrivileges('CREATE, DROP', 'db', 'members');