<?php
/*
Copyright (C) 2001-2004 ZZOSS GbR, http://www.zzoss.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
@version $Id: authentication.php,v 1.3 2004/01/29 14:09:16 ordnas Exp $
@copyright Copyright © 2001-2004 ZZ/OSS GbR, http://www.zzoss.com
@license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
*/
require_once 'inc/init.php';
/***************************************************************************
* INSTALLER FRAMEWORK FUNCTIONS *
***************************************************************************/
// additional checks
function zi_validate()
{
$errors = array();
if( ( $_REQUEST['ZI_VALUES']['password'] !=
$_REQUEST['ZI_VALUES']['password_confirm'] )
&&
( strlen($_REQUEST['ZI_VALUES']['password']) > 0 )
) {
$errors["password"] = 'passwords do not match';
$errors["password_confirm"] = '';
}
return $errors;
}
function zi_process()
{
// generate random salt
srand((double)microtime()*1000000);
$saltseeds = array( '.','/','0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$salt = $saltseeds[rand(0,63)] . $saltseeds[rand(0,63)];
// encrypt
$crypted_password = crypt(trim($_REQUEST['ZI_VALUES']['password']),$salt);
// write the data to the password file
$filename = $GLOBALS['ZI']['installer_data_dir'].'.htpasswd';
$fp = fopen( $filename, "w");
fputs( $fp, $_REQUEST['ZI_VALUES']['username'].':'.$crypted_password);
fclose( $fp );
}
/***************************************************************************
* STARTUP *
***************************************************************************/
// check if the password file exists
if(file_exists($GLOBALS['ZI']['installer_data_dir'].'.htpasswd')){
// redirect to the start page of the installer
header('Location: index.php');
exit;
}
/***************************************************************************
* PAGE CONTENT *
***************************************************************************/
include 'themes/'.$GLOBALS['ZI']['theme'].'/header.php';
?>
<h1>Create Login</h1>
<p>Please enter and <em>remember</em> the login data of the installation administrator. Make sure that <em>cookies</em> are enabled in your browser past this point.</p>
<table border="0" cellspacing="0" cellpadding="8">
<tr>
<td align="right" valign="middle"><span class="label">Username:</span></td>
<td align="left" valign="middle"><?php
if(isset($zi_errors['username']) > 0){
echo $zi_errors['username'].'<br/>';
}
?><input type="text" name="ZI_VALUES[username]" size="20" style="width:160" value="<?php if(isset($_REQUEST['ZI_VALUES']['username'])) echo $_REQUEST['ZI_VALUES']['username']; ?>">
<input type="hidden" name="ZI_VALIDATIONS[username]" value="not empty"></td>
</tr>
<tr>
<td align="right" valign="middle"><span class="label">Password:</span></td>
<td align="left" valign="middle"><?php
if(isset($zi_errors['password']) > 0){
echo $zi_errors['password'].'<br/>';
}
?><input type="password" name="ZI_VALUES[password]" size="20" style="width:160">
<input type="hidden" name="ZI_VALIDATIONS[password]" value="not empty"></td>
</tr>
<tr>
<td align="right" valign="middle"><span class="label">Confirm password:</span></td>
<td align="left" valign="middle"><?php
if(isset($zi_errors['password_confirm']) > 0){
echo $zi_errors['password_confirm'].'<br/>';
}
?><input type="password" name="ZI_VALUES[password_confirm]" size="20" style="width:160">
<input type="hidden" name="ZI_VALIDATIONS[password_confirm]" value="not empty"></td>
</tr>
</table>
<?php
//unset($zi_buttons['cancel']);
$zi_buttons['next'] = 'index.php';
include 'themes/'.$GLOBALS['ZI']['theme'].'/footer.php';
?>