Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 176 lines (151 sloc) 5.816 kb
eff2851 @flol Initial revision
authored
1 <?php
2 /**
3 * filename: $Source$
4 * begin: Friday, Aug 06, 2004
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version. This program is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
11 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * @author Florian Lippert <flo@redenswert.de>
15 * @copyright (C) 2003-2004 Florian Lippert
16 * @package Panel
17 * @version $Id$
18 */
19
20 define('AREA', 'customer');
21
22 /**
23 * Include our init.php, which manages Sessions, Language etc.
24 */
25 require("./lib/init.php");
26
27 if(isset($_POST['id']))
28 {
29 $id=intval($_POST['id']);
30 }
31 elseif(isset($_GET['id']))
32 {
33 $id=intval($_GET['id']);
34 }
35
36 if($page=='overview')
37 {
38 eval("echo \"".getTemplate("mysql/mysql")."\";");
39 }
40
41 elseif($page=='mysqls')
42 {
43 if($action=='')
44 {
1c31abe @flol Fixed some issues with the MySQL Queries
authored
45 $result=$db->query( "SELECT `id`, `databasename` FROM `" . TABLE_PANEL_DATABASES . "` WHERE `customerid`='" . $userinfo['customerid'] . "' ORDER BY `databasename` ASC" );
eff2851 @flol Initial revision
authored
46 $mysqls='';
47 while($row=$db->fetch_array($result))
48 {
49 eval("\$mysqls.=\"".getTemplate("mysql/mysqls_database")."\";");
50 }
4de0694 @flol Bug behoben: Ein Kunde konnte trotzdem er keine Domain hatte, Subdomains...
authored
51 $mysqls_count = $db->num_rows($result);
52
eff2851 @flol Initial revision
authored
53 eval("echo \"".getTemplate("mysql/mysqls")."\";");
54 }
55
56 elseif($action=='delete' && $id!=0)
57 {
1c31abe @flol Fixed some issues with the MySQL Queries
authored
58 $result=$db->query_first( 'SELECT `id`, `databasename` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . $userinfo['customerid'] . '" AND `id`="' . $id . '"' );
eff2851 @flol Initial revision
authored
59 if(isset($result['databasename']) && $result['databasename'] != '')
60 {
61 if(isset($_POST['send']) && $_POST['send']=='send')
62 {
1c31abe @flol Fixed some issues with the MySQL Queries
authored
63 // Begin root-session
eff2851 @flol Initial revision
authored
64 $db_root=new db($sql['host'],$sql['root_user'],$sql['root_password'],'');
65 unset($db_root->password);
1c31abe @flol Fixed some issues with the MySQL Queries
authored
66
67 $db_root->query( 'REVOKE ALL PRIVILEGES ON * . * FROM `' . $result['databasename'] . '`@localhost' );
68 $db_root->query( 'REVOKE ALL PRIVILEGES ON `' . $result['databasename'] . '` . * FROM `' . $result['databasename'] . '`@localhost;' );
69 $db_root->query( 'DELETE FROM `mysql`.`user` WHERE `User` = "' . $result['databasename'] . '" AND `Host` = "localhost"' );
70 $db_root->query( 'DROP DATABASE IF EXISTS `' . $result['databasename'] . '`' );
71 $db_root->query( 'FLUSH PRIVILEGES' );
72
eff2851 @flol Initial revision
authored
73 $db_root->close();
1c31abe @flol Fixed some issues with the MySQL Queries
authored
74 // End root-session
75
76 $db->query( 'DELETE FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . $userinfo['customerid'] . '" AND `id`="' . $id . '"' );
77
eff2851 @flol Initial revision
authored
78 if($userinfo['mysqls_used']=='1')
79 {
1c31abe @flol Fixed some issues with the MySQL Queries
authored
80 $resetaccnumber=" , `mysql_lastaccountnumber`='0' ";
eff2851 @flol Initial revision
authored
81 }
d238608 @flol Moeglichkeit hinzugefuegt, dass man auch unendlich Ressourcen an einen K...
authored
82 else
83 {
84 $resetaccnumber='';
85 }
1c31abe @flol Fixed some issues with the MySQL Queries
authored
86
87 $result=$db->query( 'UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`-1 ' . $resetaccnumber . 'WHERE `customerid`="' . $userinfo['customerid'] .'"' );
88
eff2851 @flol Initial revision
authored
89 header("Location: $filename?page=$page&s=$s");
90 }
b704baf Fixed Bug #6: It is now possible to create MySQL databases for users wit...
Martin Burchert authored
91 else
92 {
efcfe12 @flol In the securityquestions the target (eg email, domain, databasename etc)...
authored
93 ask_yesno('mysql_reallydelete', $filename, "id=$id;page=$page;action=$action", $result['databasename']);
eff2851 @flol Initial revision
authored
94 }
95 }
96 }
97
98 elseif($action=='add')
99 {
d238608 @flol Moeglichkeit hinzugefuegt, dass man auch unendlich Ressourcen an einen K...
authored
100 if($userinfo['mysqls_used'] < $userinfo['mysqls'] || $userinfo['mysqls'] == '-1')
eff2851 @flol Initial revision
authored
101 {
102 if(isset($_POST['send']) && $_POST['send']=='send')
103 {
104 $password=addslashes($_POST['password']);
105 if($password=='')
106 {
107 standard_error('notallreqfieldsorerrors');
108 exit;
109 }
110 else
111 {
112 $username=$userinfo['loginname'].$settings['customer']['mysqlprefix'].(intval($userinfo['mysql_lastaccountnumber'])+1);
1c31abe @flol Fixed some issues with the MySQL Queries
authored
113
114 // Begin root-session
eff2851 @flol Initial revision
authored
115 $db_root=new db($sql['host'],$sql['root_user'],$sql['root_password'],'');
116 unset($db_root->password);
1c31abe @flol Fixed some issues with the MySQL Queries
authored
117
118 $db_root->query( 'CREATE DATABASE `' . $username . '`' );
119 $db_root->query( 'GRANT ALL PRIVILEGES ON `' . $username . '`.* TO `' . $username . '`@localhost IDENTIFIED BY \'password\'' );
120 $db_root->query( 'SET PASSWORD FOR `' . $username .'`@localhost = PASSWORD(\'' . $password . '\')' );
121 $db_root->query( 'FLUSH PRIVILEGES' );
122
eff2851 @flol Initial revision
authored
123 $db_root->close();
1c31abe @flol Fixed some issues with the MySQL Queries
authored
124 // End root-session
125
126 $result=$db->query( 'INSERT INTO `' . TABLE_PANEL_DATABASES . '` (`customerid`, `databasename`) VALUES ("' . $userinfo['customerid'] .'", "' . $username .'")' );
127 $result=$db->query( 'UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`+1, `mysql_lastaccountnumber`=`mysql_lastaccountnumber`+1 WHERE `customerid`="' . $userinfo['customerid'] . '"' );
128
eff2851 @flol Initial revision
authored
129 header("Location: $filename?page=$page&s=$s");
130 }
131 }
b704baf Fixed Bug #6: It is now possible to create MySQL databases for users wit...
Martin Burchert authored
132 else
133 {
eff2851 @flol Initial revision
authored
134 eval("echo \"".getTemplate("mysql/mysqls_add")."\";");
135 }
136 }
137 }
138
139 elseif($action=='edit' && $id!=0)
140 {
1c31abe @flol Fixed some issues with the MySQL Queries
authored
141 $result=$db->query_first( 'SELECT `id`, `databasename` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . $userinfo['customerid'] . '" AND `id`="' . $id . '"' );
eff2851 @flol Initial revision
authored
142 if(isset($result['databasename']) && $result['databasename'] != '')
143 {
144 if(isset($_POST['send']) && $_POST['send']=='send')
145 {
146 $password=addslashes($_POST['password']);
147 if($password=='')
148 {
149 standard_error('notallreqfieldsorerrors');
150 exit;
151 }
152 else
153 {
1c31abe @flol Fixed some issues with the MySQL Queries
authored
154 // Begin root-session
eff2851 @flol Initial revision
authored
155 $db_root=new db($sql['host'],$sql['root_user'],$sql['root_password'],'');
156 unset($db_root->password);
1c31abe @flol Fixed some issues with the MySQL Queries
authored
157
b704baf Fixed Bug #6: It is now possible to create MySQL databases for users wit...
Martin Burchert authored
158 $db_root->query('SET PASSWORD FOR `'.$result['databasename'].'`@localhost = PASSWORD(\'' . $password .'\')');
159 $db_root->query('FLUSH PRIVILEGES');
1c31abe @flol Fixed some issues with the MySQL Queries
authored
160
eff2851 @flol Initial revision
authored
161 $db_root->close();
1c31abe @flol Fixed some issues with the MySQL Queries
authored
162 // End root-session
163
eff2851 @flol Initial revision
authored
164 header("Location: $filename?page=$page&s=$s");
165 }
166 }
b704baf Fixed Bug #6: It is now possible to create MySQL databases for users wit...
Martin Burchert authored
167 else
168 {
eff2851 @flol Initial revision
authored
169 eval("echo \"".getTemplate("mysql/mysqls_edit")."\";");
170 }
171 }
172 }
173 }
174
175 ?>
Something went wrong with that request. Please try again.