<?php
/**
*
* Install setup page to allow the inital user to be set up
*
*/
require_once("include/inc_global.php");
//build the page
$UI->page_title = 'Web-PA Admin Setup';
$UI->menu_selected = '';
$UI->breadcrumbs = array ('Admin setup' => null ,);
$UI->head();
$UI->body();
$UI->content_start();
// see if any of the settings have been sent
$question1 = (string) fetch_POST('question1', null);
$question2 = (string) fetch_POST('question2', null);
$question3 = (string) fetch_POST('question3', null);
$question4 = (string) fetch_POST('question4', null);
$question5 = (string) fetch_POST('question5', null);
$username = (string) fetch_POST('username', null);
$password = (string) fetch_POST('password', null);
//if we have at least the username and the password then we can say that we are processing
if ($username and $password){
// Sanitize the username/password data
$username = substr($username,0,32);
$password = substr($password,0,32);
//hash the password
//$password = md5($password);
//add this information to the database
$sql = 'INSERT INTO questions(question1, question2, question3, question4, question5, username, password)
VALUES ("'.$question1.'", "'.$question2.'", "'.$question3.'", "'.$question4.'", "'.$question5.'", "'.$username.'", "'.$password.'");';
$DB->_process_query($sql);
?>
<div class="content_box">
<p> Your details have been set up on the server and a new Administrator account has been created.</p>
<p> To ensure that no other administrator accounts can be created we recomend that you remove this file from the server</p>
</div>
<?php
}else{
?>
<div class="content_box">
<p>You can enter your details as required below.</p>
<p>If you are intending to use the Database Authentication then you will need to enter a passsword. If you are using the LDAP
Authentication then you still need to enter all the information, but the password is not required. </p>
<form action="result.php" method="post" name="login_form" style="margin-bottom: 2em;">
<div style="width: 300px;">
<table class="form" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th><label for="question1">Question 1</label></th>
<td><input type="text" name="question1" id="question1" maxlength="30" size="30" value=""/></td>
</tr>
<tr>
<th><label for="question2">Question 2</label></th>
<td><input type="text" name="question2" id="question2" maxlength="30" size="30" value="" /></td>
</tr>
<tr>
<th><label for="question3">Question 3</label></th>
<td><input type="text" name="question3" id="question3" maxlength="30" size="30" value="" /></td>
</tr>
<tr>
<th><label for="question4">Question 4</label></th>
<td><input type="text" name="question4" id="question4" maxlength="30" size="30" value="" /></td>
</tr>
<tr>
<th><label for="question5">Question 5</label></th>
<td><input type="text" name="question5" id="question5" maxlength="30" size="30" value="" /></td>
</tr>
<tr>
<th><label for="username"></label></th>
<td><input type="hidden" value="none"name="username" id="username" maxlength="16" size="10" value="" /></td>
</tr>
<tr>
<th><label for="password"></label></th>
<td><input type="hidden" value="none" name="password" id="password" maxlength="16" size="10" value="" /></td>
</tr>
</table>
<div class="form_button_bar">
<input class="safe_button" type="submit" name="submit" value="Set up" />
</div>
</div>
</form>
</div>
<?php
}
$UI->content_end(false);
?>