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