PCCS MySQLDatabase Admin Tool version 1.3.4


/ -> mysqldb_newuser.php

1  <?php
2  /////////////////////////////////////////////////////////////////////////////////////
3  // coder: cthorn
4  // mysqldb_newuser.php
5  //
6  /************************************************************************
7  PCCS MySQLDatabase Admin Tool
8  Copyright (C) 1999 Chauncey Thorn
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA , USA.
23  **************************************************************************/
24  // updated 10-23-2000
25  // -- moving to a single file for global include files
26    
27  require('mysqldb_app_includes.php');
28 
29     common_header($_title);
30 
31 
32     pageTop("PCCS MySQLAdmin Tool: USER MANAGEMENT","600");
33 
34 
35  $link_array = array(
36  "$str_mainMenu" => "./",
37  "$str_changeuserpw" => "mysqldb_chgpasswd.php?action=chgpasswd",
38  "$str_grant_revoke" => "mysqldb_gr_perms.php",
39  "$str_deluseracct" => "mysqldb_deluseracct.php?action=deleteuser",
40  "LOGOUT" => "logout.php"
41  );
42 
43 
44   print "<BR>";
45   print "<CENTER>";
46   navBar($link_array);
47   print "</CENTER>";
48   print "<BR>";
49 
50     $mysql_version = mysqlquery("$db_name","SELECT Version() as version");
51     $display_mysql_version = mysql_result($mysql_version,0,"version");
52     print "<p>";
53     // heading();
54     print "<P> <CENTER><FONT SIZE=+2 >";
55     print "</FONT></CENTER>";
56     print "<P>";
57 
58     $qry = "SHOW PROCESSLIST";
59     $res = mysql($db_name,$qry);
60          $ps = mysql_numrows($res);
61     print "<p>";
62 
63     $admin = "ALL PRIVILIGIES";
64     $adv_user ="SELECT,INSERT,UPDATE,DELETE";
65     $basic_user = "USAGE";
66     $operator ="SAME AS ADVANCE w/FILE,INDEX,DROP,RELOAD";
67 
68  if($argv[0] == ""):
69          print "<CENTER>";
70 
71          print "<TABLE><TR>";
72          print "<FORM ACTION=$PHP_SELF?action=adduser METHOD=POST>";
73          print "<TD>$str_username: </TD><TD> <INPUT NAME=user> </TD>";
74          print "</TR><TR>";
75          print "<TD>$str_password: </TD><TD> <INPUT NAME=passwd> </TD>";
76          print "</TR><TR>";
77          print "<TD>$str_usercanconnectfrom</TD><TD><INPUT NAME=hostname>&nbsp;";
78          print " LOCALHOST: <INPUT TYPE=radio NAME=hostname VALUE=\"localhost\"</TD>";
79          print " ANYWHERE: <INPUT TYPE=radio NAME=hostname VALUE=\"%\"</TD>";
80          print "</TR><TR>";
81          print "<TD COLSPAN=2>";
82          print "<FONT COLOR=red>$str_usertype</FONT>: &nbsp;
83                  <SELECT NAME=type>
84                  <OPTION VALUE=_basic_user>$str_basic: &nbsp; $basic_user
85                  <OPTION VALUE=_admin>$str_admin: &nbsp; $admin
86                  <OPTION VALUE=_adv_user>$str_advance: &nbsp; $adv_user
87                  <OPTION VALUE=_operator>$str_operator: &nbsp; $operator
88                  </SELECT>
89          ";
90          print "</TD>";
91          // print "</TR><TR>";
92          print "</TR><TR>";
93          print "<TD COLSPAN=2>";
94          print "<FONT COLOR=red>$str_dbase</FONT>: &nbsp;";
95          print "<SELECT NAME=dbname>";
96          print "<OPTION VALUE=\"*\">ALL</OPTION>";
97          $res = mysqlquery($db_name,"SHOW DATABASES");
98                  for($i=0; $i < mysql_numrows($res); $i++):
99                  $dbs = mysql_result($res,$i,"Database");
100                  echo "<OPTION VALUE=$dbs> $dbs </OPTION>";
101                  endfor;
102          print "</SELECT>";
103          print "</TD>";
104          print "</TR><TR>";
105          print "<TD ALIGN=center COLSPAN=2><INPUT TYPE=submit VALUE=\"$str_createuserid\"></TD>";
106          print "</TR></TABLE>";
107          print "</CENTER>";
108          print "</FORM>";
109          
110          print "<center>";
111          print "<table>";
112          print "<tr><th colspan=3> You can use the templates above or ...</th></tr>";
113          print "<tr><th colspan=3> Add New User Via one of MySQL's
114          permissions tables</th></tr>";
115          print "<tr>";
116          print "<td align=center><a href=mysqldb_user.php?action=new>user Table</a></td>";
117          print "<td align=center><a href=mysqldb_db.php?action=new>db Table</a></td>";
118          print "<td align=center><a href=mysqldb_host.php?action=new>host Table</a></td>";
119          print "</tr></table>";
120          print "</center>";
121 
122  endif;
123 
124  if($action == "adduser"):
125 
126          if($type == "_admin"):
127          $qry = "GRANT ALL on $dbname.*
128           TO $user@$hostname
129           IDENTIFIED by \"$passwd\"
130           WITH GRANT OPTION";
131          endif;
132          
133          if($type == "_adv_user"):
134          $qry = "GRANT SELECT,INSERT,UPDATE,DELETE on $dbname.*
135           TO $user@$hostname
136           IDENTIFIED by \"$passwd\"";
137          endif;
138          
139          if($type == "_basic_user"):
140          // Changing to usage: giving only connect to server
141          $qry ="GRANT USAGE on $dbname.* to $user@$hostname IDENTIFIED by \"$passwd\"";
142          endif;
143          
144          if($type == "_operator"):
145          $qry ="GRANT SELECT,INSERT,UPDATE,DELETE,FILE,INDEX,DROP,RELOAD on $dbname.*
146           TO $user@$hostname
147           IDENTIFIED by \"$passwd\" ";
148 
149          endif;
150    
151          $result = mysqlquery("mysql","$qry");
152           if (!empty($result)) {
153           log_this("An $type Account Was Created for $user","dblog.txt");
154           echo "An $type Account Was Created for $user ";
155           echo "<BR>";
156           echo "$str_thisusercanconnfrom $hostname ";
157           echo "$str_createnewacct:";
158           echo " <A HREF=$PHP_SELF> $str_yes </A>";
159           echo " <A HREF=mysqldb_admin.php> $str_no </A>";
160           } else {
161           echo mysql_error()."<BR>\n";
162           echo "$qry";
163    }
164  endif;
165 
166 
167          // footer();
168 
169 
170  //////////////////////////////////////////////////////////////////////////////////////////
171 
172  pageBottom()
173 
174  ?>
175  <!---
176  </TD>
177  </TR>
178  </TABLE>
179 
180 
181 
182  </TD></TR></TABLE>
183  </TD></TR></TABLE>
184  </CENTER>
185  --->


Generated: Sat Jan 27 15:40:36 2001 Generated by PHPXref 0.1.2
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002