8
+ − 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
$sqlinsert = "INSERT INTO
+ − 146
users
9
+ − 147
(username, password, fullname, email, description, level, active)
8
+ − 148
VALUES (
+ − 149
'" . $_POST [ 'login' ] . "',
+ − 150
'" . md5 ( stripslashes ( $_POST [ 'password' ])) . "',
+ − 151
'" . $_POST [ "fullname" ] . "',
+ − 152
'" . $_POST [ "email" ] . "',
+ − 153
'" . $_POST [ "description" ] . "',
+ − 154
10,
+ − 155
1)" ;
+ − 156
+ − 157
$resadmin = $db -> query ( $sqlinsert );
+ − 158
+ − 159
if ( $db -> isError ( $resadmin ))
+ − 160
{
+ − 161
+ − 162
error ( "Can not add the admin to database $dbdatabase .users" );
+ − 163
}
+ − 164
else
+ − 165
{
+ − 166
+ − 167
?>
+ − 168
<h2> <? echo _ ( 'PowerAdmin has succesfully been installed.' ); ?> </h2>
+ − 169
<br />
+ − 170
<? echo _ ( 'Remove this file (install.php) from your webdir.' ); ?> <br />
+ − 171
<b> <? echo _ ( 'WARNING' ); ?> :</b> <? echo _ ( 'PowerAdmin will not work until you delete install.php' ); ?> <br />
+ − 172
<br />
+ − 173
<? echo _ ( 'You can click' ); ?> <a href="index.php">here</a> <? echo _ ( 'to start using PowerAdmin' ); ?>
+ − 174
</BODY></HTML>
+ − 175
<?php
+ − 176
die ();
+ − 177
}
+ − 178
+ − 179
}
+ − 180
else
+ − 181
{
+ − 182
echo "<DIV CLASS= \" warning \" >" . _ ( 'You didnt fill in one of the required fields!' ) . "</DIV>" ;
+ − 183
}
+ − 184
}
+ − 185
+ − 186
else
+ − 187
{
+ − 188
?>
+ − 189
+ − 190
<H2> <? echo _ ( 'PowerAdmin for PowerDNS' ); ?> </H2>
+ − 191
<BR>
+ − 192
<B> <? echo _ ( 'This config file will setup your database to be ready for PowerAdmin. Please fill in the next fields which will create an
+ − 193
administrator login.' ); ?> <BR>
+ − 194
<? echo _ ( 'Fields marked with a' ); ?> <FONT COLOR="#FF0000">*</FONT> <? echo _ ( 'are required.' ); ?>
+ − 195
</B><BR><BR>
+ − 196
+ − 197
<FORM METHOD="post">
+ − 198
<TABLE BORDER="0" CELLSPACING="4">
+ − 199
<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>
+ − 200
<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>
+ − 201
<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>
+ − 202
<TR><TD CLASS="tdbg"> <? echo _ ( 'Email' ); ?> :</TD><TD CLASS="tdbg"><INPUT TYPE="text" CLASS="input" NAME="email" VALUE=""> <FONT COLOR="#FF0000">*</FONT> </TD></TR>
+ − 203
<TR><TD CLASS="tdbg"> <? echo _ ( 'Description' ); ?> :</TD><TD CLASS="tdbg"><TEXTAREA ROWS="6" COLS="30" CLASS="inputarea" NAME="description"></TEXTAREA></TD></TR>
+ − 204
<TR><TD CLASS="tdbg"> </TD><TD CLASS="tdbg"><INPUT TYPE="submit" CLASS="button" NAME="submit" VALUE=" <? echo _ ( 'Make Account' ); ?> "></TD></TR>
+ − 205
</TABLE>
+ − 206
</FORM>
+ − 207
+ − 208
<BR><BR>
+ − 209
<FONT CLASS="footer"><B>PowerAdmin v1.0</B> Copyright ©2002 The
+ − 210
PowerAdmin Team</FONT></BODY></HTML> <? } ?>