PHP Classes

File: user.php

Recommend this page to a friend!
  Packages of giuseppe lucarelli   dbuser   user.php   Download  
File: user.php
Role: Example script
Content type: text/plain
Description: main php script
Class: dbuser
Manage MySQL or PostgreSQL users using reconfig
Author: By
Last change: changed visibility
Date: 12 years ago
Size: 2,385 bytes
 

 

Contents

Class file image Download
<?php
/*
 * @$Header: /var/cvsroot/reconfig/example/dbuser/user.php,v 1.9 2014/11/17 12:21:09 giuseppe Exp $
 */
/*  
    Copyright (C) 2014- Giuseppe Lucarelli <giu.lucarelli@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of version 2 of the GNU General Public License as
    published by the Free Software Foundation.

    This program 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 this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

header('Content-type: text/html; charset=UTF-8');

ini_set('display_errors', 1);
error_reporting(~0);

    $driver=(isset($_POST['driver']) ? $_POST['driver'] : 'mysql');
    require_once("class.reconfig.php");
    require_once("xml/xml.$driver.php");
    require_once("sql/class.$driver.php");

    $REC = new REConfigUser();
    $REC->time=time();
    $REC->action = (isset($_POST['action']) ? $_POST['action'] : null);
    $REC->auth_type='none';
/* ENABLE TO RUN WITH AUTHENTICATION (change js/user.js too)
 *  $REC->auth_type='httpHeader';
 *  $REC->auth_passwd='.htpasswd';
 *  $REC->auth_script = 'validate.php';
 *  $REC->auth_func = 'ValidateUser';
 *  $REC->auth_driver = __DRIVER__;
 *  $REC->auth_host = @$_POST['auth_host'];
 *  $REC->auth_user = @$_POST['auth_user'];
 *  $REC->auth_pass = @$_POST['auth_pass'];
 */
    $REC->user = @$_POST['user'];
    $HTML=$REC->XmlConvert($XML);
    if(isset($_POST['userdes'])) {
        $REC->userdes = explode('@',rawurldecode($_POST['userdes']));
        if(count($REC->userdes) <=1) $REC->userdes=array($REC->userdes[0],'localhost');
        $REC->sources['building']['in']['query']=$REC->SqlListPrivs($REC->userdes[1],$REC->userdes[0]);
    }

    $json_data=&$_POST['json_data']['building'];
    $privs='';
    $REC->BuildQuery($json_data);
    $REC->Init($HTML['building'],'building',true);
    if(!strcasecmp('mysql',@$_POST['driver']))
        $HTML['building'][0]['values'][]='all';
    echo json_encode($HTML);