8
|
1 |
<?php |
|
2 |
|
|
3 |
// addslashes to vars if magic_quotes_gpc is off |
|
4 |
function slash_input_data(&$data) |
|
5 |
{ |
|
6 |
if ( is_array($data) ) |
|
7 |
{ |
|
8 |
foreach ( $data as $k => $v ) |
|
9 |
{ |
|
10 |
$data[$k] = ( is_array($v) ) ? slash_input_data($v) : addslashes($v); |
|
11 |
} |
|
12 |
} |
|
13 |
return $data; |
|
14 |
} |
|
15 |
|
|
16 |
set_magic_quotes_runtime(0); |
|
17 |
|
|
18 |
// If magic quotes is off, addslashes |
|
19 |
if ( !get_magic_quotes_gpc() ) |
|
20 |
{ |
|
21 |
$_GET = slash_input_data($_GET); |
|
22 |
$_POST = slash_input_data($_POST); |
|
23 |
$_COOKIE = slash_input_data($_COOKIE); |
|
24 |
} |
|
25 |
|
|
26 |
|
|
27 |
error_reporting(E_ALL); |
|
28 |
if(!@require_once("inc/config.inc.php")) |
|
29 |
{ |
|
30 |
error("You have to create a config.inc.php!"); |
|
31 |
} |
|
32 |
include_once("inc/header.inc.php"); |
|
33 |
|
|
34 |
$sup_types = array('mysql'); |
|
35 |
|
|
36 |
function error($msg=false) |
|
37 |
{ |
|
38 |
// General function for printing critical errors. |
|
39 |
if ($msg) |
|
40 |
{ |
|
41 |
?> |
|
42 |
<P><TABLE CLASS="error"><TR><TD CLASS="error"><H2><? echo _('Oops! An error occured!'); ?></H2> |
|
43 |
<BR> |
|
44 |
<FONT STYLE="font-weight: Bold"><?= nl2br($msg) ?><BR><BR><a href="javascript:history.go(-1)"><< back</a></FONT><BR></TABLE> |
|
45 |
<? |
|
46 |
die(); |
|
47 |
} |
|
48 |
else |
|
49 |
{ |
|
50 |
die("No error specified!"); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
if(isset($_POST["submit"])) |
|
55 |
{ |
|
56 |
//$dbtype = $_POST["dbtype"]; |
|
57 |
require_once("inc/database.inc.php"); |
|
58 |
|
|
59 |
if($dbdsntype == "mysql") |
|
60 |
{ |
|
61 |
$sqlusers = "CREATE TABLE users ( |
|
62 |
id int(11) NOT NULL auto_increment, |
|
63 |
username varchar(16) NOT NULL default '', |
|
64 |
password varchar(34) NOT NULL default '', |
|
65 |
fullname varchar(255) NOT NULL default '', |
|
66 |
email varchar(255) NOT NULL default '', |
|
67 |
description text NOT NULL, |
|
68 |
level tinyint(3) NOT NULL default '0', |
|
69 |
active tinyint(1) NOT NULL default '0', |
|
70 |
PRIMARY KEY (id) |
|
71 |
) TYPE=InnoDB"; |
|
72 |
$sqlzones = "CREATE TABLE zones ( |
|
73 |
id int(11) NOT NULL auto_increment, |
|
74 |
domain_id int(11) NOT NULL default '0', |
|
75 |
owner int(11) NOT NULL default '0', |
|
76 |
comment text, |
|
77 |
PRIMARY KEY (id) |
|
78 |
) TYPE=InnoDB"; |
27
|
79 |
$sqlrecowns = "CREATE TABLE record_owners ( |
|
80 |
id int(11) NOT NULL auto_increment, |
|
81 |
user_id int(11) NOT NULL default '0', |
|
82 |
record_id int(11) NOT NULL default '0', |
|
83 |
PRIMARY KEY (id) |
|
84 |
) TYPE=InnoDB"; |
8
|
85 |
} |
|
86 |
|
|
87 |
// PGSQL Is trivial still, the relations are different. |
|
88 |
if($dbdsntype == "pgsql") |
|
89 |
{ |
|
90 |
$sqlusers = "CREATE TABLE users ( |
|
91 |
id SERIAL PRIMARY KEY, |
|
92 |
username varchar(16) NOT NULL, |
|
93 |
password varchar(255) NOT NULL, |
|
94 |
fullname varchar(255) NOT NULL, |
|
95 |
email varchar(255) NOT NULL, |
|
96 |
description text NOT NULL, |
|
97 |
level smallint DEFAULT 0, |
|
98 |
active smallint DEFAULT 0 |
|
99 |
)"; |
|
100 |
$sqlzones = "CREATE TABLE zones ( |
|
101 |
id SERIAL PRIMARY KEY, |
|
102 |
name varchar(255) NOT NULL, |
|
103 |
owner smallint NOT NULL, |
|
104 |
comment text NULL |
|
105 |
)"; |
27
|
106 |
$sqlrecowns = "CREATE TABLE record_owners ( |
|
107 |
id SERIAL PRIMARY KEY, |
|
108 |
user_id smallint NOT NULL, |
|
109 |
record_id smallint NOT NULL |
|
110 |
)"; |
8
|
111 |
} |
|
112 |
|
|
113 |
if(!empty($_POST['login']) && !empty($_POST['password']) && !empty($_POST['fullname']) && !empty($_POST['email'])) |
|
114 |
{ |
|
115 |
// Declare default tables. |
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
// It just tries to rough create. If it flunks.. bad a user exists or the dbase exists. |
|
120 |
|
|
121 |
$resusers = $db->query($sqlusers); |
|
122 |
|
|
123 |
if($db->isError($resusers)) |
|
124 |
{ |
|
125 |
error("Can not create table users in $dbdatabase"); |
|
126 |
} |
|
127 |
|
|
128 |
$reszones = $db->query($sqlzones); |
|
129 |
|
|
130 |
if($db->isError($reszones)) |
|
131 |
{ |
|
132 |
error("Can not create zones table in $dbdatabase"); |
|
133 |
} |
27
|
134 |
$reszones = $db->query($sqlrecowns); |
8
|
135 |
|
27
|
136 |
if($db->isError($reszones)) |
|
137 |
{ |
|
138 |
error("Can not create record_owners table in $dbdatabase"); |
|
139 |
} |
|
140 |
|
8
|
141 |
$sqlinsert = "INSERT INTO |
|
142 |
users |
9
|
143 |
(username, password, fullname, email, description, level, active) |
8
|
144 |
VALUES ( |
|
145 |
'". $_POST['login'] ."', |
|
146 |
'". md5(stripslashes($_POST['password'])) ."', |
|
147 |
'". $_POST["fullname"] ."', |
|
148 |
'". $_POST["email"] ."', |
|
149 |
'". $_POST["description"] ."', |
|
150 |
10, |
|
151 |
1)"; |
|
152 |
|
|
153 |
$resadmin = $db->query($sqlinsert); |
|
154 |
|
|
155 |
if($db->isError($resadmin)) |
|
156 |
{ |
|
157 |
|
|
158 |
error("Can not add the admin to database $dbdatabase.users"); |
|
159 |
} |
|
160 |
else |
|
161 |
{ |
|
162 |
|
|
163 |
?> |
|
164 |
<h2><? echo _('PowerAdmin has succesfully been installed.'); ?></h2> |
|
165 |
<br /> |
|
166 |
<? echo _('Remove this file (install.php) from your webdir.'); ?><br /> |
|
167 |
<b><? echo _('WARNING'); ?>:</b> <? echo _('PowerAdmin will not work until you delete install.php'); ?><br /> |
|
168 |
<br /> |
|
169 |
<? echo _('You can click'); ?> <a href="index.php">here</a> <? echo _('to start using PowerAdmin'); ?> |
|
170 |
</BODY></HTML> |
|
171 |
<?php |
|
172 |
die(); |
|
173 |
} |
|
174 |
|
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
echo "<DIV CLASS=\"warning\">" . _('You didnt fill in one of the required fields!') . "</DIV>"; |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
else |
|
183 |
{ |
|
184 |
?> |
|
185 |
|
|
186 |
<H2><? echo _('PowerAdmin for PowerDNS'); ?></H2> |
|
187 |
<BR> |
|
188 |
<B><? echo _('This config file will setup your database to be ready for PowerAdmin. Please fill in the next fields which will create an |
|
189 |
administrator login.'); ?><BR> |
|
190 |
<? echo _('Fields marked with a'); ?> <FONT COLOR="#FF0000">*</FONT> <? echo _('are required.'); ?> |
|
191 |
</B><BR><BR> |
|
192 |
|
|
193 |
<FORM METHOD="post"> |
|
194 |
<TABLE BORDER="0" CELLSPACING="4"> |
|
195 |
<TR><TD CLASS="tdbg"><? echo _('Login Name'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="login" VALUE=""> <FONT COLOR="#FF0000">*</FONT> </TD></TR> |
|
196 |
<TR><TD CLASS="tdbg"><? echo _('Password'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="password" CLASS="input" NAME="password" VALUE=""> <FONT COLOR="#FF0000">*</FONT> </TD></TR> |
|
197 |
<TR><TD CLASS="tdbg"><? echo _('Full name'); ?>:</TD><TD WIDTH="510" CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="fullname" VALUE=""> <FONT COLOR="#FF0000">*</FONT> </TD></TR> |
|
198 |
<TR><TD CLASS="tdbg"><? echo _('Email'); ?>:</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="email" VALUE=""> <FONT COLOR="#FF0000">*</FONT> </TD></TR> |
|
199 |
<TR><TD CLASS="tdbg"><? echo _('Description'); ?>:</TD><TD CLASS="tdbg"><TEXTAREA ROWS="6" COLS="30" CLASS="inputarea" NAME="description"></TEXTAREA></TD></TR> |
|
200 |
<TR><TD CLASS="tdbg"> </TD><TD CLASS="tdbg"><INPUT TYPE="submit" CLASS="button" NAME="submit" VALUE="<? echo _('Make Account'); ?>"></TD></TR> |
|
201 |
</TABLE> |
|
202 |
</FORM> |
|
203 |
|
|
204 |
<BR><BR> |
|
205 |
<FONT CLASS="footer"><B>PowerAdmin v1.0</B> Copyright ©2002 The |
|
206 |
PowerAdmin Team</FONT></BODY></HTML><? } ?> |