PHP Classes

File: xml/xml.pgsql.php

Recommend this page to a friend!
  Classes of giuseppe lucarelli   dbuser   xml/xml.pgsql.php   Download  
File: xml/xml.pgsql.php
Role: Auxiliary script
Content type: text/plain
Description: php class for postgresql
Class: dbuser
Manage MySQL or PostgreSQL users using reconfig
Author: By
Last change: changed visibility
Date: 9 years ago
Size: 5,705 bytes
 

Contents

Class file image Download
<?php
define
('__DRIVER__','pgsql');
define('__HOST__','localhost');
define('__DBNAME__','postgres');
define('__USER__','postgres');
define('__PASS__','postgres');

$userdes=@$_POST['userdes'];
$db=@$_POST['json_data']['building'][0]['value'][0];
$cname='constant';

$XML = <<<EOF
<root>
 <building>
  <source>
   <in>
    <type>sql</type>
    <driver>
{$cname('__DRIVER__')}</driver><dbhost>{$cname('__HOST__')}</dbhost><dbname>{$cname('__DBNAME__')}</dbname><dbuser>{$cname('__USER__')}</dbuser><dbpass>{$cname('__PASS__')}</dbpass>
    <query>SELECT usename as User,'' as password,'n' as Select_priv,'n' as Insert_priv,'n' as Update_priv,'n' as Delete_priv,'n' as Grant_priv FROM pg_user LIMIT 0</query>
   </in>
   <out>
    <type>sql</type>
    <driver>
{$cname('__DRIVER__')}</driver><dbhost>{$cname('__HOST__')}</dbhost><dbname>{$cname('__DBNAME__')}</dbname><dbuser>{$cname('__USER__')}</dbuser><dbpass>{$cname('__PASS__')}</dbpass>
   </out>
  </source>
  <item>
   <type>select</type><name>dblist</name><label>db list</label><display>1</display>
   <attrs><class>selbox</class></attrs>
   <html><prepend><![CDATA[<h3>Manage PostgreSql users</h3><div id="dleft">]]></prepend></html>
   <in><group>dblist</group><column>datname</column></in><value>
$db</value>
   <out>false</out>
  </item>
  <item>
   <type>select</type><name>userlist</name><label>user list</label><display>1</display>
   <attrs><class>selbox</class><size>9</size></attrs>
   <html><append><![CDATA[</div>]]></append></html>
   <event><onchange><![CDATA['\$reconfig.selectuser("user.php",this);']]></onchange></event>
   <in><group>userlist</group><column>usename</column></in><value>
$userdes</value>
   <out>false</out>
  </item>
  <item>
   <type>input</type><name>User</name><label>User</label>
   <html><prepend><![CDATA[<div id="dright"><ul><li>]]></prepend></html>
   <in><column>user</column></in><out>true</out>
  </item>
  <item>
   <type>input</type><name>Password</name><label>Password</label>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <value>*</value><in><column>Password</column></in><out>true</out>
  </item>
  <item>
   <type>radio</type><name>all</name><label>all privs</label>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <attrs><class>chkbox</class></attrs>
   <values><Y>yes</Y><N>no</N></values><value>no</value>
   <in>false</in><out>false</out>
  </item>
  <item>
   <type>radio</type><name>select</name><label>select priv</label><selbycode>true</selbycode>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <attrs><class>chkbox</class></attrs>
   <values><Y>yes</Y><N>no</N></values>
   <in><column>Select_priv</column><target>value</target></in><out>true</out>
  </item>
  <item>
   <type>radio</type><name>insert</name><label>Insert priv</label><selbycode>true</selbycode>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <attrs><class>chkbox</class></attrs>
   <values><Y>yes</Y><N>no</N></values>
   <in><column>Insert_priv</column><target>value</target></in><out>true</out>
  </item>
  <item>
   <type>radio</type><name>update</name><label>Update priv</label><selbycode>true</selbycode>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <attrs><class>chkbox</class></attrs>
   <values><Y>yes</Y><N>no</N></values>
   <in><column>Update_priv</column><target>value</target></in><out>true</out>
  </item>
  <item>
   <type>radio</type><name>delete</name><label>Delete priv</label><selbycode>true</selbycode>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <attrs><class>chkbox</class></attrs>
   <values><Y>yes</Y><N>no</N></values>
   <in><column>Delete_priv</column><target>value</target></in><out>true</out>
  </item>
  <item>
   <type>radio</type><name>grant</name><label>Grant priv</label><selbycode>true</selbycode>
   <html><prepend><![CDATA[</li><li>]]></prepend></html>
   <attrs><class>chkbox</class></attrs>
   <values><Y>yes</Y><N>no</N></values>
   <in><column>Grant_priv</column><target>value</target></in><out>true</out>
  </item>
  <item>
   <type>button</type><name>update</name><value>update</value>
   <html><prepend><![CDATA[<br /><br /></li><li class="btns">]]></prepend></html>
   <attrs><class>btn</class></attrs>
   <event><onclick><![CDATA['\$reconfig.save("user.php","update");']]></onclick></event>
   <in>false</in><out>false</out>
  </item>
  <item>
   <type>button</type><name>insert</name><value>insert</value>
   <attrs><class>btn</class></attrs>
   <event><onclick><![CDATA['\$reconfig.save("user.php","insert");']]></onclick></event>
   <in>false</in><out>false</out>
  </item>
  <item>
   <type>button</type><name>remove</name><value>revoke privs</value>
   <html><append><![CDATA[</li></ul>]]></append></html>
   <attrs><class>btn</class></attrs>
   <event><onclick><![CDATA['\$reconfig.save("user.php","delete");']]></onclick></event>
   <in>false</in><out>false</out>
  </item>
 </building>
 <dblist>
  <source>
   <in>
    <type>sql</type>
    <driver>
{$cname('__DRIVER__')}</driver><dbhost>{$cname('__HOST__')}</dbhost><dbname>{$cname('__DBNAME__')}</dbname><dbuser>{$cname('__USER__')}</dbuser><dbpass>{$cname('__PASS__')}</dbpass>
    <query>SELECT datname FROM pg_database;</query>
   </in>
  </source>
 </dblist>
 <userlist>
  <source>
   <in>
    <type>sql</type>
    <driver>
{$cname('__DRIVER__')}</driver><dbhost>{$cname('__HOST__')}</dbhost><dbname>{$cname('__DBNAME__')}</dbname><dbuser>{$cname('__USER__')}</dbuser><dbpass>{$cname('__PASS__')}</dbpass>
    <query>SELECT usename FROM pg_user;</query>
   </in>
  </source>
 </userlist>
</root>
EOF;