Location: PHPKode > projects > ACollab > install/include/step3.php
<?php
/****************************************************************************************/
/* ACollab                                                                              */
/****************************************************************************************/
/* Copyright (c) 2002-2005  Adaptive Technology Resource Centre / University of Toronto */
/*                                                                                      */
/* http://atutor.ca/acollab                                                             */
/*                                                                                      */
/* This program is free software. You may redistribute it and/or                        */
/* modify it under the terms of the GNU General Public License                          */
/* as published by the Free Software Foundation; either version 2 of the License,       */
/* or (at your option) any later version.                                               */
/*                                                                                      */
/* This program 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 General Public License for more details.                                 */
/*                                                                                      */
/* You may access the GNU General Public License at:                                    */
/* http://www.opensource.org/licenses/gpl-license.php                                   */
/*                                                                                      */
/* You may contact the Adaptive Technology Resource Centre at                           */
/* Robarts Library, University of Toronto                                               */
/* 130 St. George Street, Toronto, Ontario, Canada M5S 1A5                              */
/* Further contact information is available at http://www.utoronto.ca/atrc/             */
/****************************************************************************************/
/* Programmer:                                                                          */
/* Joel Kronenberg - ATRC                                                               */
/****************************************************************************************/
// $Id: step3.php 463 2005-03-09 19:47:35Z shozubq $

if (!defined('AC_INCLUDE_PATH')) { exit; }


if(isset($_POST['submit']) && ($_POST['action'] == 'process')) {
	unset($errors);

	$_POST['admin_username'] = trim($_POST['admin_username']);
	$_POST['admin_password'] = trim($_POST['admin_password']);
	$_POST['admin_email']    = trim($_POST['admin_email']);
	$_POST['site_name']      = trim($_POST['site_name']);

	$_POST['upload_dir']     = trim($_POST['upload_dir']);

	/* login name check */
	if ($_POST['admin_username'] == ''){
		$errors[] = 'Administrator username cannot be empty.';
	} else {
		/* check for special characters */
		if (!(eregi("^[a-zA-Z0-9_]([a-zA-Z0-9_])*$", $_POST['admin_username']))){
			$errors[] = 'Administrator username is not valid.';
		}
	}

	if ($_POST['admin_password'] == '') {
		$errors[] = 'Administrator password cannot be empty.';
	}

	if ($_POST['admin_email'] == '') {
		$errors[] = 'Administrator email cannot be empty.';
	}

	if ($_POST['site_name'] == '') {
		$errors[] = 'Site name cannot be empty.';
	}

	if ($_POST['upload_dir'] != '') {
		if ((substr($_POST['upload_dir'], -1) != '/') &&  (substr($_POST['upload_dir'], -1) != '\\')) {
			$_POST['upload_dir'] .= DIRECTORY_SEPARATOR;
		}

		if (!is_dir($_POST['upload_dir'])) {
			$errors[] = 'The Upload Directory chosen does not exist.';
		} else if (!is_writable($_POST['upload_dir'])){
			$errors[] = 'The Upload Directory is not writable. Issue the command <kbd>chmod a+rwx '.$_POST['upload_dir'].'</kbd> to change its permissions.';
		} else if (is_link($_POST['upload_dir'])) {
			$errors[] = 'The Upload Directory cannot contain symbolic links. Real path translates to: '.realpath($_POST['upload_dir']);
		}
	} else {
		$errors[] = 'You must specify an Upload Directory.';
	}


	if (!isset($errors)) {
		//put quotes around each extension

		unset($errors);
		unset($_POST['submit']);
		unset($action);
		store_steps($step);
		$step++;
		return;
	}
}	

print_progress($step);

if (isset($errors)) {
	print_errors($errors);
}

if (isset($_POST['step1']['old_version']) && $_POST['upgrade_action']) {
	$defaults['admin_username'] = urldecode($_POST['step1']['admin_username']);
	$defaults['admin_password'] = urldecode($_POST['step1']['admin_password']);
	$defaults['admin_email']    = urldecode($_POST['step1']['admin_email']);
	$defaults['site_name']  = urldecode($_POST['step1']['site_name']);
	$defaults['upload_dir'] = urldecode($_POST['step1']['upload_dir']);

} else {
	$defaults = $_defaults;
	$blurb = '';
}

?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
	<input type="hidden" name="action" value="process" />
	<input type="hidden" name="step" value="<?php echo $step; ?>" />

	<?php 
		if (@ini_get('sendmail_path') == '') { 
			$smtp = 'true';
		} else {
			$smtp = 'false';
		}
	?>
	<input type="hidden" name="smtp" value="<?php echo $smtp; ?>" />
	
	<?php print_hidden($step); ?>

	<h4>Administrator Account</h4>
	<p>The Administrator account is used for managing ACollab user accounts.</p>

	<table width="70%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
	<?php echo $blurb; ?>
	<tr>
		<td class="row1"><small><b><label for="username">Administrator Username:</label></b><br />
		May contain only letters, numbers, or underscores. 20 character maximum. A username other than <kbd>admin</kbd> is recommended.</small></td>
		<td class="row1"><input type="text" name="admin_username" id="username" maxlength="20" size="20" value="<?php if (!empty($_POST['admin_username'])) { echo stripslashes(htmlspecialchars($_POST['admin_username'])); } else { echo $defaults['admin_username']; } ?>" class="formfield" /></td>
	</tr>
	<tr>
		<td class="row1"><small><b><label for="password">Password:</label></b><br />
		Use a combination of letters, numbers and symbols.<br />15 character maximum.</small></td>
		<td class="row1"><input type="text" name="admin_password" id="password" maxlength="15" size="15" value="<?php if (!empty($_POST['admin_password'])) { echo stripslashes(htmlspecialchars($_POST['admin_password'])); } else { echo $defaults['admin_password']; } ?>" class="formfield" /></td>
	</tr>
	<tr>
		<td class="row1"><small><b><label for="email">Email:</label></b><br />
		The email that will be used as the return email throughout ACollab.</small></td>
		<td class="row1"><input type="text" name="admin_email" id="email" size="30" value="<?php if (!empty($_POST['admin_email'])) { echo stripslashes(htmlspecialchars($_POST['admin_email'])); } else { echo $defaults['admin_email']; } ?>" class="formfield" /></td>
	</tr>
	</table>

	<br />
	<h4>System Preferences</h4>
	<p>These preferences affect the general operation of the ACollab server.</p>
	<table width="80%" class="tableborder" cellspacing="0" cellpadding="1" align="center">
	<tr>
		<td class="row1"><small><b><label for="sitename">Site Name:</b><br />
		The name of your course server website.<br />Default: <kbd><?php echo $defaults['site_name']; ?></kbd></small></td>
		<td class="row1"><input type="text" name="site_name" size="28" maxlength="60" id="sitename" value="<?php if (!empty($_POST['site_name'])) { echo stripslashes(htmlspecialchars($_POST['site_name'])); } else { echo $defaults['site_name']; } ?>" class="formfield" /></td>
	</tr>
	<tr>
		<td class="row1"><small><b><label for="upload_dir">Upload Directory:</b><br />
		The upload directory should <strong>not</strong> be under the web server's document root. Example: <kbd>/usr/local/acollab/uploads/</kbd> on Unix and <kbd>C:\acollab\uploads\</kbd> on Windows. Unix paths cannot contain symbolic links.<br /></small></td>
		<td class="row1"><input type="text" name="upload_dir" size="28" maxlength="100" id="upload_dir" value="<?php if (!empty($_POST['upload_dir'])) { echo htmlspecialchars($_POST['upload_dir']); } else { echo $defaults['upload_dir']; } ?>" class="formfield" /></td>
	</tr>
	<tr>
		<td class="row1"><small><b>Allow Group Admin Notifications:</b><br />
		Allow users to notify the group admin of file and revision additions?<br />
		Default: <kbd>Yes</kbd></small></td>
		<td class="row1"><input type="radio" name="notify_group_admin" value="TRUE" id="notify_y" <?php if($_POST['notify_group_admin']=='TRUE' || empty($_POST['notify_group_admin'])) { echo 'checked="checked"'; }?>/><label for="notify_y">Yes</label>, <input type="radio" name="notify_group_admin" value="FALSE" id="notify_n" <?php if($_POST['notify_group_admin']=='FALSE') { echo 'checked="checked"'; }?>/><label for="notify_n">No</label></td>
	</tr>
	</table>
	<br /><br /><p align="center"><input type="submit" class="button" value=" Next ยป" name="submit" /></p>
</form>
Return current item: ACollab