[Openupload-svn-update] SF.net SVN: openupload:[137] trunk
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-11-12 12:44:10
|
Revision: 137
http://openupload.svn.sourceforge.net/openupload/?rev=137&view=rev
Author: tsdogs
Date: 2008-11-12 12:44:00 +0000 (Wed, 12 Nov 2008)
Log Message:
-----------
Add first version of setup script (only mysql is supported)
Modified Paths:
--------------
trunk/index.php
trunk/www/index.php
Added Paths:
-----------
trunk/www/setup.inc.php
Modified: trunk/index.php
===================================================================
--- trunk/index.php 2008-11-12 12:43:04 UTC (rev 136)
+++ trunk/index.php 2008-11-12 12:44:00 UTC (rev 137)
@@ -29,6 +29,6 @@
* @package OpenUpload
* @version 0.3
*/
-
+ define('__NOT_MAIN_SCRIPT',true);
require_once('www/index.php');
?>
Modified: trunk/www/index.php
===================================================================
--- trunk/www/index.php 2008-11-12 12:43:04 UTC (rev 136)
+++ trunk/www/index.php 2008-11-12 12:44:00 UTC (rev 137)
@@ -30,13 +30,8 @@
* @version 0.3
*/
-define ('__VALID_CALLING_SCRIPT', true);
+define ('__VALID_CALLING_SCRIPT',true);
-require_once('config.inc.php');
-require_once($CONFIG['INSTALL_ROOT'].'/lib/general.inc.php');
-
-global $application;
-
/* check authentication */
if (isset($_GET['action'])) {
$action = $_GET['action'];
@@ -52,8 +47,19 @@
} else {
$step = '';
}
-
-new Application($CONFIG);
-app()->run($action,$step);
+$configfile = 'config.inc.php';
+if (defined('__NOT_MAIN_SCRIPT'))
+ $configfile = 'www/'.$configfile;
+if (file_exists($configfile)) {
+ require_once($configfile);
+ require_once($CONFIG['INSTALL_ROOT'].'/lib/general.inc.php');
+ global $application;
+ new Application($CONFIG);
+ app()->run($action,$step);
+} else {
+ require_once('setup.inc.php');
+}
+
+
?>
Added: trunk/www/setup.inc.php
===================================================================
--- trunk/www/setup.inc.php (rev 0)
+++ trunk/www/setup.inc.php 2008-11-12 12:44:00 UTC (rev 137)
@@ -0,0 +1,1250 @@
+<?php
+
+if (!defined('__VALID_CALLING_SCRIPT')) die('DIRECT ACCESS IS DENIED');
+
+ob_start();
+session_start();
+
+$steps = array (
+ 1 => array (
+ 'title' => "Welcome",
+ 'function' => 'welcome',
+ ),
+ 2 => array (
+ 'title' => "PHP Setup check",
+ 'function' => 'setupcheck',
+ ),
+ 3 => array (
+ 'title' => "Paths",
+ 'function' => 'paths',
+ ),
+ 4 => array (
+ 'title' => "Database Type",
+ 'function' => 'databasetype',
+ ),
+ 5 => array (
+ 'title' => "Database Options",
+ 'function' => 'databaseoptions',
+ ),
+ 6 => array (
+ 'title' => "Application options",
+ 'function' => 'options',
+ ),
+ 7 => array (
+ 'title' => "Users",
+ 'function' => "users",
+ ),
+ 8 => array (
+ 'title' => "Plugins",
+ 'function' => "plugins",
+ ),
+ 9 => array (
+ 'title' => "Database inizialization",
+ 'function' => "createdb",
+ ),
+ 10 => array (
+ 'title' => "Save configuration",
+ 'function' => 'save',
+ ),
+);
+
+/* DATABASE INITIALIZATION QUERY */
+$MYSQL_QUERY = array (
+ 'dropdb' => 'DROP DATABASE IF EXISTS `%1`',
+ 'createdb' => 'CREATE DATABASE `%1`',
+ 'dropuser' => '',
+ 'createuser' => '',
+ 'grant' => 'GRANT ALL PRIVILEGES ON %2.* TO "%1"@"localhost" IDENTIFIED BY "%3"',
+ 'droptable' => 'DROP TABLE IF EXISTS `%1%2`',
+ 'structure' => array (
+ 'acl' => 'CREATE TABLE `%1acl` (
+ `id` int(11) NOT NULL auto_increment,
+ `module` varchar(100) NOT NULL,
+ `action` varchar(100) NOT NULL,
+ `group_name` varchar(50) NOT NULL,
+ `access` varchar(10) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0',
+ 'banned' => 'CREATE TABLE `%1banned` (
+ `id` int(11) NOT NULL auto_increment,
+ `ip` varchar(50) NOT NULL,
+ `access` varchar(50) NOT NULL,
+ `priority` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0',
+ 'files' => 'CREATE TABLE `%1files` (
+ `id` varchar(100) NOT NULL,
+ `name` varchar(200) NOT NULL,
+ `mime` varchar(200) NOT NULL,
+ `description` tinytext NOT NULL,
+ `size` int(12) NOT NULL,
+ `remove` varchar(100) NOT NULL,
+ `user_login` varchar(100) NOT NULL,
+ `ip` varchar(40) NOT NULL,
+ `upload_date` datetime NOT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1',
+ 'file_options' => 'CREATE TABLE `%1file_options` (
+ `id` bigint(20) NOT NULL auto_increment,
+ `file_id` varchar(100) NOT NULL,
+ `module` varchar(50) NOT NULL,
+ `name` varchar(50) NOT NULL,
+ `value` varchar(200) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `file_id` (`file_id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0',
+ 'groups' => 'CREATE TABLE `%1groups` (
+ `name` varchar(50) NOT NULL,
+ `description` varchar(250) default NULL,
+ PRIMARY KEY (`name`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1',
+ 'langs' => 'CREATE TABLE `%1langs` (
+ `id` varchar(10) NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `locale` varchar(10) NOT NULL,
+ `browser` varchar(200) default NULL,
+ `charset` varchar(50) NOT NULL,
+ `active` tinyint(1) NOT NULL default \'1\',
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1',
+ 'plugin_acl' => 'CREATE TABLE `%1plugin_acl` (
+ `id` int(11) NOT NULL auto_increment,
+ `group_name` varchar(50) NOT NULL,
+ `plugin` varchar(100) NOT NULL,
+ `access` varchar(10) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `group_name` (`group_name`,`plugin`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0',
+ 'plugin_options' => 'CREATE TABLE `%1plugin_options` (
+ `id` int(11) NOT NULL auto_increment,
+ `plugin` varchar(100) NOT NULL,
+ `group_name` varchar(100) NOT NULL,
+ `name` varchar(100) NOT NULL,
+ `value` text,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0',
+ 'users' => 'CREATE TABLE `%1users` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `login` varchar(100) NOT NULL,
+ `password` varchar(100) NOT NULL,
+ `name` varchar(200) NOT NULL,
+ `group_name` varchar(50) NOT NULL default \'registered\',
+ `email` varchar(250) NOT NULL,
+ `lang` varchar(10) NOT NULL default \'en\',
+ `reg_date` datetime NOT NULL,
+ `regid` varchar(50) NOT NULL default \'\',
+ `active` tinyint(3) unsigned NOT NULL default \'1\',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `login` (`login`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0',
+ ),
+ 'base' => array (
+ "INSERT INTO `%0banned` (`id`, `ip`, `access`, `priority`) VALUES(1, '127.0.0.1', 'allow', 1)",
+ "INSERT INTO `%0banned` (`id`, `ip`, `access`, `priority`) VALUES(2, '0.0.0.0/0', 'allow', 9999999)",
+ "INSERT INTO `%0groups` (`name`, `description`) VALUES('%3', 'Administrators group')",
+ "INSERT INTO `%0groups` (`name`, `description`) VALUES('%4', 'Registered Users')",
+ "INSERT INTO `%0groups` (`name`, `description`) VALUES('%5', 'Unregistered users')",
+ "INSERT INTO `%0langs` (`id`, `name`, `locale`, `browser`, `charset`, `active`) VALUES('en', 'English', 'en_EN', '[en];[en-EN]', 'iso-8559-1', 1)",
+ "INSERT INTO `%0langs` (`id`, `name`, `locale`, `browser`, `charset`, `active`) VALUES('it', 'Italiano', 'it_IT.utf8', '[it];[it-IT]', 'utf8', 1)",
+ "INSERT INTO `%0users` (`id`, `login`, `password`, `name`, `group_name`, `email`, `lang`, `reg_date`, `regid`, `active`) VALUES(1, '%1', '%2', 'Administrator', '%3', '%6', 'en', now(), '', 1)",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(1, '*', '*', '%3', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(2, 'admin', '*', '%3', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(3, 'admin', '*', '*', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(4, 'auth', 'login', '%5', 'allow')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(1, '%3', 'password', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(2, '%3', 'captcha', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(3, '%3', 'email', 'enable')",
+ "INSERT INTO `%0plugin_options` (`id`, `plugin`, `group_name`, `name`, `value`) VALUES (1, 'mimetypes', '%5', 'message', 'Pdf, JPEG')",
+ "INSERT INTO `%0plugin_options` (`id`, `plugin`, `group_name`, `name`, `value`) VALUES (2, 'mimetypes', '%5', 'allowed', 'application/pdf
+image/jpeg')",
+ ),
+ 'mode_1' => array (
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(5, 'auth', 'register', '*', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(6, 'auth', '*', '%5', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(7, 'auth', '*', '*', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(8, 'files', '*', '%5', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(9, 'files', '*', '*', 'allow')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(4, '%4', 'password', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(5, '%4', 'captcha', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(6, '%4', 'email', 'enable')",
+ ),
+ 'mode_2' => array (
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(5, 'auth', 'register', '*', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(6, 'auth', '*', '%5', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(7, 'auth', '*', '*', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(8, 'files', 'd', '%5', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(9, 'files', 'g', '%5', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(10, 'files', '*', '%5', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(11, 'files', '*', '*', 'allow')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(4, '%4', 'password', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(5, '%4', 'captcha', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(6, '%4', 'email', 'enable')",
+ ),
+ 'mode_3' => array (
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(5, 'auth', 'register', '%5', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(6, 'auth', '*', '%5', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(7, 'auth', 'register', '*', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(8, 'auth', '*', '*', 'allow')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(9, 'files', '*', '*', 'allow')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(4, '%4', 'password', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(5, '%4', 'captcha', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(6, '%4', 'email', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(7, '%5', 'mimetypes', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(8, '%5', 'captcha', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(9, '%5', 'password', 'enable')",
+),
+ 'mode_4' => array (
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(5, 'auth', '*', '*', 'deny')",
+ "INSERT INTO `%0acl` (`id`, `module`, `action`, `group_name`, `access`) VALUES(6, 'files', '*', '*', 'allow')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(4, '%5', 'password', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(5, '%5', 'captcha', 'enable')",
+ "INSERT INTO `%0plugin_acl` (`id`, `group_name`, `plugin`, `access`) VALUES(6, '%5', 'email', 'enable')",
+ ),
+);
+$PGSQL_QUERY = array (
+ 'dropdb' => 'DROP DATABASE "%1"',
+ 'createdb' => 'CREATE DATABASE "%1"',
+ 'dropuser' => '',
+ 'createuser' => 'GRANT ALL PRIVILEGES TO "%1"@"localhost" ON %2.* IDENTIFIED BY "%3"',
+ 'grant' => '',
+ 'droptable' => 'DROP TABLE IF EXISTS `%2`',
+);
+
+
+/* try to guess the appropriate settings from the $_SERVER */
+$step = (isset($_GET['step']))?$_GET['step']:1;
+$step = (isset($_POST['step']))?$_POST['step']:$step;
+
+if ($step =='') $step = 1;
+
+$path = 'templates/default';
+if (defined('__NOT_MAIN_SCRIPT')) {
+ $path = 'www/'.$path;
+}
+
+$CONFIG = $_SESSION['config'];
+
+/********************* SUPPORT FUNCTIONS *****************************/
+
+function msg($str,$type = '') {
+ global $path;
+ echo '<div id="message">';
+ if ($type != '') {
+ echo '<img src="'.$path.'/img/setup/'.$type.'.png"> ';
+ }
+ echo $str.'</div>';
+}
+
+function listModules($path,$ext = 'inc.php') {
+ /* now list the available database types */
+ $dir = opendir($path);
+ $result = array();
+ while ($d = readdir($dir)) {
+ if ($ext != '') {
+ $n = explode('.',$d,2);
+ if ($n[1]==$ext)
+ $result[] = $n[0];
+ } else {
+ $result[] = $d;
+ }
+ }
+ closedir($dir);
+ return $result;
+}
+
+/************************ SETUP FUNCTIONS ********************/
+
+function welcome($step) {
+ global $_POST;
+ if (isset($_POST['step'])) {
+ return $step+1;
+ }
+?>
+<div id="message">
+Now to get started using OpenUpload you need to enter a few setup information...
+</div>
+<div id="message">
+Click on the Next button to proceed installing OpenUpload.
+</div>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<div><input type="submit" value="Next >>"></div>
+</form>
+<?php
+ return $step;
+}
+
+function setupcheck($step) {
+ global $_POST;
+
+ $message = 'Let\'s check your php installation';
+ if (isset($_POST['check'])) {
+ /* we do some php installation checks */
+ echo '<div id="message"><b>PHP INI Settings</b></div>';
+ if (ini_get('file_uploads') == 1) {
+ msg('File Uploads are enabled','ok');
+ } else {
+ msg('File Uploads are disable','fail');
+ msg('Please check your php.ini setting: file_uploads');
+ }
+ $msg = 'upload_max_filesize value is set to ';
+ msg($msg.': '.ini_get('upload_max_filesize'));
+ $msg = 'post_max_size value is set to ';
+ msg($msg.': '.ini_get('post_max_size'));
+ if (ini_get('register_globals') == 0) {
+ msg('Register globals disabled','ok');
+ } else {
+ msg('Register globals enabled','fail');
+ msg('Though the application should work with this set please consider disabling it');
+ }
+ echo '<div id="message"><b>Optional Values</b></div>';
+ if (function_exists('mysql_connect')) {
+ msg('MYSQL Support: exsists','ok');
+ } else {
+ msg('MYSQL Support: not found','fail');
+ msg('MYSQL is needed if you plan to use mysql');
+ }
+ if (function_exists('pg_connect')) {
+ msg('POSTGRESQL Support: exsists','ok');
+ } else {
+ msg('POSTGRESQL Support: not found','fail');
+ msg('POSTGRESQL is needed if you plan to use postgresql');
+ }
+ if (function_exists('ldap_connect')) {
+ msg('LDAP Support: exsists','ok');
+ } else {
+ msg('LDAP Support: not found','fail');
+ msg('LDAP is needed for LDAP and AD support');
+ }
+ if (function_exists('imagecreate')) {
+ msg('GD Support: exsists','ok');
+ } else {
+ msg('GD Support: not found','fail');
+ msg('GD is needed for captcha plugin');
+ }
+ echo '<hr>';
+ $checked = true;
+ $message ='If everything looks good proceed!';
+ }
+
+ if (isset($_POST['proceed'])) {
+ return $step+1;
+ }
+?>
+<div id="message">
+<?php echo $message; ?>
+</div>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<?php if ($checked) { ?>
+<input type="submit" name="check" value="Check Again">
+<input type="submit" name="proceed" value="Next >>">
+<?php } else { ?>
+<input type="submit" name="check" value="Check">
+<?php } ?>
+</form>
+<?php
+}
+
+/* INSTALLATION AND WWW PATHS */
+function guessPaths($CONFIG) {
+ global $_SERVER;
+
+echo 'guessing';
+ $srvname = $_SERVER['SERVER_NAME']; /* localhost */
+ $srvport = $_SERVER['SERVER_PORT']; /* 80 or 443 */
+
+ $http = 'http://';
+ if ($srvport == '443') {
+ $http = 'https://';
+ $srvport = '';
+ }
+ if ($srvport == '80')
+ $srvport = '';
+
+ $script = $_SERVER['SCRIPT_FILENAME']; /* full path to script */
+ /* remove index.php from script */
+ if (strpos($script,'index.php')!==FALSE)
+ $script = substr($script,0,strpos($script,'index.php')-1);
+
+ if (!defined('__NOT_MAIN_SCRIPT')) {
+ if (strpos($script,'/www')==strlen($script)-4) {
+ $script = substr($script,0,strlen($script)-4);
+ }
+ }
+
+ $uri = $_SERVER['REQUEST_URI'];
+
+ if (strpos($uri,'index.php')!==FALSE)
+ $uri = substr($uri,0,strpos($uri,'index.php')-1);
+
+ if (defined('__NOT_MAIN_SCRIPT'))
+ $uri .= '/www';
+
+ $CONFIG['WWW_SERVER']=$http.$srvname.($srvport!=''?$srvport:'');
+ $CONFIG['WWW_ROOT']=$uri;
+ $CONFIG['INSTALL_ROOT']=$script;
+ $CONFIG['DATA_PATH']=$script.'/data';
+ return $CONFIG;
+}
+
+function paths($step) {
+ global $_POST;
+ global $CONFIG;
+ global $_SESSION;
+
+ if (!isset($_POST['install_root'])) {
+ if (!isset($CONFIG['INSTALL_ROOT'])) {
+ $CONFIG = guessPaths($CONFIG);
+ }
+ } else {
+ $CONFIG['WWW_SERVER']=$_POST['www_server'];
+ $CONFIG['WWW_ROOT']=$_POST['www_root'];
+ $CONFIG['INSTALL_ROOT']=$_POST['install_root'];
+ $CONFIG['DATA_PATH']=$_POST['data_path'];
+
+ /* now check for correctness of the settings */
+ /* if ok go to next step */
+ return $step+1;
+ }
+
+ /* now I need to display and ask confirmation of the values */
+?>
+<div id="message">
+Here you must specify the paths of your installation.<br>
+Guessed values might be wrong on some circumstances so please make sure they are ok.
+</div>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<table border="0">
+<TR><TD>Install PATH:<br>(Where lib,templates,etc are)</TD>
+ <TD><input type="text" name="install_root" size="50" value="<?php echo $CONFIG['INSTALL_ROOT']; ?>"></TD></TR>
+<TR><TD>WWW Server URL:</TD>
+ <TD><input type="text" name="www_server" size="50" value="<?php echo $CONFIG['WWW_SERVER']; ?>"></TD></TR>
+<TR><TD>WWW Root Path <br>(where setup.php is):</TD>
+ <TD><input type="text" name="www_root" size="50" value="<?php echo $CONFIG['WWW_ROOT']; ?>"></TD></TR>
+<TR><TD>DATA PATH:</TD>
+ <TD><input type="text" name="data_path" size="50" value="<?php echo $CONFIG['DATA_PATH']; ?>"></TD></TR>
+<TR><TD colspan="2"><input type="submit" value="Next >>"</TD></TR>
+</table>
+</form>
+<?php
+ return $step;
+}
+
+/* DATABASE SETUP */
+
+function databasetype($step) {
+ global $CONFIG;
+ global $_POST;
+
+ if (isset($_POST['dbtype'])) {
+ $CONFIG['database']['type']=$_POST['dbtype'];
+ if ($CONFIG['database']['type']=='txt') {
+ $CONFIG['database']['rootdir']=$CONFIG['INSTALL_ROOT'].'/txtdb';
+ unset($CONFIG['database']['host']);
+ unset($CONFIG['database']['user']);
+ unset($CONFIG['database']['password']);
+ unset($CONFIG['database']['name']);
+ } else {
+ unset($CONFIG['database']['rootdir']);
+ $CONFIG['database']['host'] = 'localhost';
+ $CONFIG['database']['user'] = '';
+ $CONFIG['database']['password'] = '';
+ $CONFIG['database']['name'] = 'openupload';
+ }
+ return $step+1;
+ }
+ $db = listModules($CONFIG['INSTALL_ROOT'].'/lib/modules/db');
+?>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<table border="0">
+<TR><TD>Database Type:</TD>
+<td><select name='dbtype'><option value="">-- Select one --</option>
+<?php foreach ($db as $d) {
+ $selected = $CONFIG['database']['type']==$d?'selected':'';
+ echo '<option value="'.$d.'" '.$selected.'>'.$d.'</option>';
+} ?>
+</select></td>
+</TR>
+<TR><TD colspan="2"><input type="submit" value="Next >>"></TD></TR>
+</table>
+</form>
+<?php
+}
+
+
+function databaseoptions($step) {
+ global $CONFIG;
+ global $_POST;
+ global $_SESSION;
+
+ if (isset($_POST['dbhost'])) {
+ $CONFIG['database']['host']=$_POST['dbhost'];
+ $CONFIG['database']['user']=$_POST['dbusername'];
+ if ($_POST['dbpassword']!='')
+ $CONFIG['database']['password']=$_POST['dbpassword'];
+ $CONFIG['database']['name']=$_POST['dbname'];
+ $CONFIG['database']['prefix']=$_POST['dbprefix'];
+ $_SESSION['options']['rootuser']=$_POST['rootuser'];
+ if ($_POST['rootpassword']!='')
+ $_SESSION['options']['rootpassword']=$_POST['rootpassword'];
+ $_SESSION['options']['newdb']=$_POST['newdb'];
+ $_SESSION['options']['newuser']=$_POST['newuser'];
+ $_SESSION['options']['populate']=$_POST['populate'];
+ if (isset($_POST['test'])) {
+ if ($_SESSION['options']['newdb']==1) {
+ $user = $_SESSION['options']['rootuser'];
+ $pwd = $_SESSION['options']['rootpassword'];
+ if ($CONFIG['database']['type']=='mysql')
+ $dbn = 'mysql';
+ else
+ $dbn = 'postgres';
+ } else {
+ $user = $CONFIG['database']['user'];
+ $pwd = $CONFIG['database']['password'];
+ $dbn = $CONFIG['database']['name'];
+ }
+ if (dbconnect($CONFIG['database']['host'],$user,$pwd,$dbn,true)) {
+ msg('Database connection SUCCESSFULL.','ok');
+ } else {
+ msg('Database connection failed ','fail');
+ }
+ } else {
+ /* check the values */
+ return $step+1;
+ }
+ }
+ //TODO: ask the db class for parameters
+?>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<table border="0">
+<TR><TD>Database Type:</TD>
+ <td><?php echo $CONFIG['database']['type']; ?></td></tr>
+<?php if ($CONFIG['database']['type']=='txt') { ?>
+<TR><TD>DB File Path:</TD><TD><input type="text" size="50" name="dbrootdir" value="<?php echo $CONFIG['database']['rootdir']; ?>"></TD></TR>
+<TR><TD colspan="2"><input type="submit" value="Next >>"></TD></TR>
+<?php } else { ?>
+<TR><TD>Host:</TD><TD><input type="text" size="30" name="dbhost" value="<?php echo $CONFIG['database']['host']; ?>"></TD></TR>
+<TR><TD>Username:</TD><TD><input type="text" size="30" name="dbusername" value="<?php echo $CONFIG['database']['user']; ?>"></TD></TR>
+<TR><TD>Password:</TD><TD><input type="password" size="30" name="dbpassword" value=""></TD></TR>
+<TR><TD>DB Name:</TD><TD><input type="text" size="30" name="dbname" value="<?php echo $CONFIG['database']['name']; ?>"></TD></TR>
+<TR><TD>Table prefix:</TD><TD><input type="text" size="30" name="dbprefix" value="<?php echo $CONFIG['database']['prefix']; ?>"></TD></TR>
+<TR><TD>Create the database?</TD><TD><input type="checkbox" name="newdb" value="1" <?php if ($_SESSION['options']['newdb']==1) echo 'checked'; ?>></TD></TR>
+<TR><TD>Also create user?</TD><TD><input type="checkbox" name="newuser" value="1" <?php if ($_SESSION['options']['newuser']==1) echo 'checked'; ?>></TD></TR>
+<TR><TD>DB Admin user:</TD><TD><input type="text" name="rootuser" value="<?php echo $_SESSION['options']['rootuser']; ?>"></TD></TR>
+<TR><TD>DB Admin password:</TD><TD><input type="password" name="rootpassword" value=""></TD></TR>
+<TR><TD>Populate database</TD><TD>
+<select name="populate">
+<?php $opt = array("No","Structure only","Base System data","Private mode","Restricted mode","Service mode","Public mode");
+ foreach ($opt as $k => $v) {
+ echo '<option value="'.$k.'" '.($k==$_SESSION['options']['populate']?'selected':'').'>'.$v.'</option>';
+ }
+?>
+</select>
+</TD></TR>
+<TR><TD colspan="2"><input type="submit" name="test" value="Test connection"> <input type="submit" value="Next >>"></TD></TR>
+<?php } ?>
+</table>
+</form>
+<?php
+}
+
+function options($step) {
+ global $_POST;
+ global $CONFIG;
+
+ $tr = listModules($CONFIG['INSTALL_ROOT'].'/lib/modules/tr');
+ $auth = listModules($CONFIG['INSTALL_ROOT'].'/lib/modules/auth');
+ $templates = listModules($CONFIG['INSTALL_ROOT'].'/templates','');
+
+ if (isset($_POST['translator'])) {
+ $error = false;
+ $CONFIG['translator']=$_POST['translator'];
+ $CONFIG['auth']=$_POST['auth'];
+ $CONFIG['defaultlang']=$_POST['defaultlang'];
+ $CONFIG['site']['title']=$_POST['sitetitle'];
+ $CONFIG['site']['webmaster']= $_POST['webmaster'];
+ $CONFIG['site']['email']= $_POST['email'];
+ $CONFIG['site']['footer']=str_replace('\"','"',$_POST['sitefooter']);
+ $CONFIG['registration']['email_confirm']=isset($_POST['confirmregistration'])?$_POST['confirmregistration']:'no';
+ $CONFIG['max_upload_size']=$_POST['max_upload_size'];
+ $CONFIG['max_download_time']=$_POST['max_download_time'];
+
+ if ($CONFIG['translator']=='') {
+ $error = true;
+ msg('Please select a translator','fail');
+ }
+ if ($CONFIG['auth']=='') {
+ $error = true;
+ msg('Please select an authentication module','fail');
+ }
+ if ($CONFIG['site']['webmaster']=='') {
+ $error = true;
+ msg('Please insert a webmaster e-mail address','fail');
+ }
+ if ($CONFIG['site']['email']=='') {
+ $error = true;
+ msg('Please insert a site e-mail address','fail');
+ }
+ if ($CONFIG['max_upload_size']=='') {
+ $error = true;
+ msg('Please insert a maximum default upload size','fail');
+ }
+ if ($CONFIG['max_download_time']=='') {
+ $error = true;
+ msg('Please insert a maximum download time','fail');
+ }
+ if (!$error) {
+ return $step+1;
+ }
+ } else if (!isset($CONFIG['site']['title'])) {
+ /* init default values */
+ $CONFIG['translator']='phparray';
+ $CONFIG['auth']='default';
+ $CONFIG['defaultlang']='en';
+ $CONFIG['site']['title']='Open Upload';
+ $CONFIG['site']['webmaster']= '';
+ $CONFIG['site']['email']= '';
+ $CONFIG['site']['footer']='<a href="http://openupload.sf.net">Open Upload</a> - Created by Alessandro Briosi © 2008';
+ $CONFIG['registration']['email_confirm']='yes';
+ $CONFIG['max_upload_size']=100;
+ $CONFIG['max_download_time']=120;
+ }
+?>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<table border="0">
+<tr><td>Translation module:</td><td>
+<select name="translator">
+<option value="">-- Select one --</option>
+<?php foreach ($tr as $t) {
+ $selected = $CONFIG['translator']==$t?'selected':'';
+ echo '<option value="'.$t.'" '.$selected.'>'.$t.'</option>';
+} ?>
+</select>
+</td></tr>
+<tr><td>Default language:</td><td><input type="text" name="defaultlang" value="<?php echo $CONFIG['defaultlang']; ?>"></td></tr>
+<tr><td>Authentication module:<br>(LDAP Configuration needs to be done<br> by hand for now)</td><td>
+<select name="auth">
+<option value="">-- Select one --</option>
+<?php foreach ($auth as $t) {
+ $selected = $CONFIG['auth']==$t?'selected':'';
+ echo '<option value="'.$t.'" '.$selected.'>'.$t.'</option>';
+} ?>
+</select>
+</td></tr>
+<tr><td>Site title:</td><td><input type="text" name="sitetitle" value="<?php echo $CONFIG['site']['title']; ?>"></td></tr>
+<tr><td>WebMaster E-mail:</td><td><input type="text" name="webmaster" value="<?php echo $CONFIG['site']['webmaster']; ?>"></td></tr>
+<tr><td>Site E-mail:</td><td><input type="text" name="email" value="<?php echo $CONFIG['site']['email']; ?>"></td></tr>
+<tr><td>Confirm registration with e-mail:</td><td><input type="checkbox" name="confirmregistration" value="yes" <?php if ($CONFIG['registration']['email_confirm']=='yes') echo 'checked'; ?> ></td></tr>
+<tr><td>Template:</td><td>
+<select name="template">
+<option value="">-- Select one --</option>
+<?php foreach ($templates as $t) {
+ if ($t != '..' and $t != '.' and strpos($t,'.')!==0) {
+ $selected = $CONFIG['auth']==$t?'selected':'';
+ echo '<option value="'.$t.'" '.$selected.'>'.$t.'</option>';
+ }
+} ?>
+</select>
+</td></tr>
+<tr><td>Template Footer:</td><td><textarea name="sitefooter" cols="50" rows="5"><?php echo $CONFIG['site']['footer']; ?></textarea></td></tr>
+<tr><td>Maximum upload size (in MB):</td><td><input type="text" name="max_upload_size" value="<?php echo $CONFIG['max_upload_size']; ?>"></td></tr>
+<tr><td>Maximum download time (in Min)<br>0 disables it:</td><td><input type="text" name="max_download_time" value="<?php echo $CONFIG['max_download_time']; ?>"></td></tr>
+<TR><TD colspan="2"><input type="submit" value="Next >>"></TD></TR>
+</table>
+</form>
+<?php
+}
+
+function users($step) {
+ global $_POST;
+ global $_SESSION;
+ global $CONFIG;
+
+ if (isset($_POST['unregistered'])) {
+ $error = false;
+ $_SESSION['options']['adminuser']=$_POST['adminuser'];
+ $_SESSION['options']['adminpassword']=$_POST['adminpassword'];
+ $_SESSION['options']['admingroup']=$_POST['admingroup'];
+ $_SESSION['options']['registered']=$_POST['registered'];
+ $_SESSION['options']['unregistered']=$_POST['unregistered'];
+ $CONFIG['register']['nologingroup']=$_POST['unregistered'];
+ $CONFIG['register']['default_group']=$_POST['registered'];
+ if ($_SESSION['options']['adminuser']=='') {
+ $error = true;
+ msg('Please provide an administrator name','fail');
+ }
+ if ($_SESSION['options']['adminpassword']=='') {
+ $error = true;
+ msg('Please provide an administrator password','fail');
+ }
+ if ($_SESSION['options']['admingroup']=='') {
+ $error = true;
+ msg('Please provide an administrators group','fail');
+ }
+ if ($_SESSION['options']['registered']=='') {
+ $error = true;
+ msg('Please provide registered users group','fail');
+ }
+ if ($_SESSION['options']['unregistered']=='') {
+ $error = true;
+ msg('Please provide an unregistered users default group','fail');
+ }
+ if (!$error)
+ return $step+1;
+ } else if (!isset($_SESSION['options']['adminuser'])) {
+ $_SESSION['options']['adminuser']='admin';
+ $_SESSION['options']['adminpassword']='';
+ $_SESSION['options']['admingroup']='admins';
+ $_SESSION['options']['registered']='registered';
+ $_SESSION['options']['unregistered']='unregistered';
+ }
+?>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<table border="0">
+<tr><td>Administrator:</td><td><input type="text" name="adminuser" value="<?php echo $_SESSION['options']['adminuser']; ?>"></td></tr>
+<tr><td>Admin password:</td><td><input type="password" name="adminpassword" value=""></td></tr>
+<tr><td>Admin group:</td><td><input type="text" name="admingroup" value="<?php echo $_SESSION['options']['admingroup']; ?>"></td></tr>
+<tr><td>Users group:</td><td><input type="text" name="registered" value="<?php echo $_SESSION['options']['registered']; ?>"></td></tr>
+<tr><td>Not registered group:</td><td><input type="text" name="unregistered" value="<?php echo $_SESSION['options']['unregistered']; ?>"></td></tr>
+<TR><TD colspan="2"><input type="submit" value="Next >>"></TD></TR>
+</table>
+</form>
+<?php
+}
+
+function plugins($step) {
+ global $_POST;
+ global $CONFIG;
+
+ if (isset($_POST['step'])) {
+ $CONFIG['plugins']=array();
+ foreach ($_POST as $k => $v) {
+ if (strpos($k,'plugin_')===0) {
+ $CONFIG['plugins'][]=$v;
+ }
+ }
+ return $step+1;
+ }
+
+ $plugins = listModules($CONFIG['INSTALL_ROOT'].'/plugins');
+?>
+<div id="message">Please select which plugins you want to use (better enable all of them):</div>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<table border="0">
+<?php
+foreach ($plugins as $p) {
+ echo '<tr><td>'.$p.'</td><td><input type="checkbox" name="plugin_'.$p.'" value="'.$p.'" checked></td></tr>';
+}
+?>
+<TR><TD colspan="2"><input type="submit" value="Next >>"></TD></TR>
+</table>
+</form>
+<?php
+}
+
+function dbconnect($host,$user,$pwd,$db,$debug = false) {
+global $dbhandle;
+global $CONFIG;
+
+ switch ($CONFIG['database']['type']) {
+ case 'mysql':
+ if (!($dbhandle = mysql_connect($host,$user,$pwd))) {
+ if ($debug) echo '<div id="message">Reason: '.mysql_error().'</div>';
+ return false;
+ }
+ if ($db != '')
+ if (!(mysql_select_db($db,$dbhandle))) {
+ if ($debug) echo '<div id="message">Reason: '.mysql_error().'</div>';
+ return false;
+ }
+ break;
+ case 'pgsql':
+ $str = "host=".$host;
+ $str .= " port=5432";
+ $str .= " dbname=".$db;
+ $str .= " user=".$user;
+ $str .= " password=".$pwd;
+ if (!($dbhandle = pg_connect($str))) {
+ if ($debug) echo '<div id="message">Reason: '.pg_last_error().'</div>';
+ return false;
+ }
+ break;
+ default:
+ msg('ERROR: dbtype: '.$CONFIG['database']['type'].' not yet supported','fail');
+ return false;
+ break;
+ }
+ return true;
+}
+
+function dbquery($sql,$params = array(),$debug = false) {
+global $dbhandle;
+global $CONFIG;
+
+ $query = strtr($sql,$params);
+ if ($query == '') return true;
+
+ switch ($CONFIG['database']['type']) {
+ case 'mysql':
+ if (!mysql_query($query,$dbhandle)) {
+ if ($debug) echo '<div id="message">Query failed: '.$query.'<br>Reason: '.mysql_error().'</div>';
+ return false;
+ }
+ break;
+ case 'pgsql':
+ if (!pg_query($query)) {
+ if ($debug) echo '<div id="message">Query failed: '.$query.'<br>Reason: '.pg_last_error().'</div>';
+ return false;
+ }
+ break;
+ }
+ return true;
+}
+
+function createdb($step) {
+ global $CONFIG;
+ global $_SESSION;
+ global $_POST;
+ global $MYSQL_QUERY;
+ global $PGSQL_QUERY;
+
+ if (isset($_SESSION['substep']) and !(isset($_POST['restart']))) {
+ $substep = $_SESSION['substep'];
+ } else {
+ if ($_SESSION['options']['newdb']==1) {
+ $substep=1;
+ } else if ($_SESSION['options']['populate']>0) {
+ $substep = 2;
+ } else {
+ $substep = 5;
+ }
+ }
+ $_SESSION['substep']=$substep;
+ switch ($CONFIG['database']['type']) {
+ case 'mysql':
+ $query = $MYSQL_QUERY;
+ $dbn = 'mysql';
+ break;
+ case 'pgsql':
+ $query = $PGSQL_QUERY;
+ $dbn = 'postgres';
+ break;
+ }
+ $error = false;
+ $debug = (isset($_POST['debug']))?true:false;
+ if (isset($_POST['proceed']) or isset($_POST['retry']) or isset($_POST['next'])) {
+ /* connect to the db */
+ if (isset($_POST['proceed']) or isset($_POST['retry']))
+ $execute = true;
+ switch ($substep) {
+ case 1: /* database and user creation */
+ if ($execute) {
+ $error = false;
+ if ($_SESSION['options']['newdb']==1) {
+ if (dbconnect($CONFIG['database']['host'],$_SESSION['options']['rootuser'],$_SESSION['options']['rootpassword'],$dbn,$debug)) {
+ if ($_SESSION['options']['newuser']==1) {
+ $params['%1']=$CONFIG['database']['user'];
+ $params['%2']=$CONFIG['database']['name'];
+ $params['%3']=$CONFIG['database']['password'];
+ dbquery($query['dropuser'],$params,$debug);
+ if (dbquery($query['createuser'],$params,$debug)) {
+ msg('User creation: SUCCESS','ok');
+ } else {
+ $error = true;
+ msg('User creation: FAILED!!!','fail');
+ }
+ }
+ $params['%1']=$CONFIG['database']['name'];
+ dbquery($query['dropdb'],$params,false);
+ if (dbquery($query['createdb'],$params,$debug)) {
+ msg('Database creation: SUCCESS','ok');
+ } else {
+ $error = true;
+ msg('Database creation: FAILED!!!','fail');
+ }
+ $params['%1']=$CONFIG['database']['user'];
+ $params['%2']=$CONFIG['database']['name'];
+ $params['%3']=$CONFIG['database']['password'];
+ if (dbquery($query['grant'],$params,$debug)) {
+ msg('Grant privileges: SUCCESS','ok');
+ } else {
+ $error = true;
+ msg('Grant privileges: FAILED!!!','fail');
+ }
+ } else {
+ $error = true;
+ msg('Database connection failed, please review the connection information!','fail');
+ }
+ }
+ }
+ if (!$error) {
+ if ($_SESSION['options']['populate']>0)
+ $substep++;
+ else
+ $substep=5;
+ }
+ break;
+ case 2: /* structure load */
+ $error = false;
+ if ($execute) {
+ if (dbconnect($CONFIG['database']['host'],$CONFIG['database']['user'],$CONFIG['database']['password'],$CONFIG['database']['name'],$debug)) {
+ $params['%1']=$CONFIG['database']['prefix'];
+ foreach ($query['structure'] as $t => $q) {
+ $params['%2']=$t;
+ if (!dbquery($query['droptable'],$params,$debug))
+ $error = true;
+ if (!dbquery($q,$params,$debug)) {
+ msg('Table creation FAILED: '.$t,'fail');
+ $error = true;
+ } else {
+ msg('Table creation SUCCESS: '.$t,'ok');
+ }
+ }
+ } else {
+ msg('Database connection failed!','fail');
+ $error = true;
+ }
+ }
+ if (!$error) {
+ msg('Structure load: SUCCESS','ok');
+ if ($_SESSION['options']['populate']>1)
+ $substep++;
+ else
+ $substep=5;
+ } else {
+ msg('Structure load: FAILED','fail');
+ }
+ break;
+ case 3: /* data load */
+ $error = false;
+ if ($execute) {
+ if (dbconnect($CONFIG['database']['host'],$CONFIG['database']['user'],$CONFIG['database']['password'],$CONFIG['database']['name'],$debug)) {
+ $params['%0']=$CONFIG['database']['prefix'];
+ $params['%1']=$_SESSION['options']['adminuser'];
+ $params['%2']=crypt($_SESSION['options']['adminpassword']);
+ $params['%3']=$_SESSION['options']['admingroup'];
+ $params['%4']=$_SESSION['options']['registered'];
+ $params['%5']=$_SESSION['options']['unregistered'];
+ $params['%6']=$CONFIG['site']['webmaster'];
+ foreach ($query['base'] as $t => $q) {
+ if (!dbquery($q,$params,$debug)) {
+ msg('Query failed... n. '.$t,'fail');
+ $error = true;
+ } else {
+ msg('Data insert SUCCESS: '.$t,'ok');
+ }
+ }
+ } else {
+ msg('Database connection failed!','fail');
+ $error = true;
+ }
+ }
+ if (!$error) {
+ if ($_SESSION['options']['populate']>2)
+ $substep++;
+ else
+ $substep=5;
+ msg('<b>Base system load: SUCCESS</b>','ok');
+ } else {
+ msg('Base system load: FAILED','fail');
+ }
+ break;
+ case 4: /* mode load */
+ $mode = $_SESSION['options']['populate']-2;
+ $error = false;
+ if ($execute) {
+ if (dbconnect($CONFIG['database']['host'],$CONFIG['database']['user'],$CONFIG['database']['password'],$CONFIG['database']['name'],$debug)) {
+ $params['%0']=$CONFIG['database']['prefix'];
+ $params['%1']=$_SESSION['options']['adminuser'];
+ $params['%2']=crypt($_SESSION['options']['adminpassword']);
+ $params['%3']=$_SESSION['options']['admingroup'];
+ $params['%4']=$_SESSION['options']['registered'];
+ $params['%5']=$_SESSION['options']['unregistered'];
+ $params['%6']=$CONFIG['site']['webmaster'];
+ foreach ($query['mode_'.$mode] as $t => $q) {
+ if (!dbquery($q,$params,$debug)) {
+ msg('Query failed... n. '.$t,'fail');
+ $error = true;
+ } else {
+ msg('Data insert SUCCESS: '.$t,'ok');
+ }
+ }
+ } else {
+ msg('Database connection failed!','fail');
+ $error = true;
+ }
+ }
+ if (!$error) {
+ $substep=5;
+ msg('<b>Mode data load: SUCCESS</b>','ok');
+ } else {
+ msg('<b>Mode data load: FAILED</b>','fail');
+ }
+ break;
+ case 5: /* finished */
+ return $step+1;
+ break;
+ }
+ echo '<hr>';
+ }
+ $_SESSION['substep']=$substep;
+ $_SESSION['debug']=$debug;
+ switch ($substep) {
+ case 1: /* database and user creation */
+ if ($_SESSION['options']['newuser']==1) {
+ $msg = 'now we will proceed to the database and user creation.';
+ } else {
+ $msg = 'now we will proceed to the database creation.';
+ }
+ break;
+ case 2: /* structure load */
+ $msg = 'Let\'s proceed with structure creation.';
+ break;
+ case 3: /* data load */
+ $msg = 'Let\'s load the base system data.';
+ break;
+ case 4: /* mode load */
+ $msg = 'Let\'s load the selected mode data.';
+ break;
+ case 5: /* finished */
+ $msg = 'Database initialization finished';
+ break;
+ }
+?>
+<div id="message"><?php echo $msg; ?></div>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<input type="checkbox" name="debug" value="debug" <?php if ($_SESSION['debug']) echo 'checked'; ?>> Debug database query errors<br> <br>
+<input type="submit" name="restart" value="Restart">
+<?php if ($error) { ?><input type="submit" name="retry" value="Retry">
+<input type="submit" name="next" value="Skip to Next step >>"><?php } else if ($substep<5) { ?>
+<input type="submit" name="proceed" value="Execute">
+<?php } else { ?>
+<input type="submit" name="proceed" value="Next >>">
+<?php } ?>
+</form>
+<?php
+}
+
+function generateConfig() {
+ global $CONFIG;
+
+ $result = '<?php'."\n";
+ foreach ($CONFIG as $k => $v) {
+ if (is_array($v)) {
+ foreach ($v as $sk => $sv) {
+ $result .= '$CONFIG[\''.$k.'\'][\''.$sk.'\'] = \''.str_replace('\'','\\\'',$sv).'\';'."\n";
+ }
+ $result .= "\n\n";
+ } else {
+ $result .= '$CONFIG[\''.$k.'\'] = \''.str_replace('\'','\\\'',$v).'\';'."\n\n";
+ }
+ }
+ $result .='?>';
+ return $result;
+}
+
+function save($step) {
+ global $_POST;
+ global $CONFIG;
+ global $_SESSION;
+
+ if (isset($_POST['download'])) {
+ $result = generateConfig();
+ ob_clean();
+ header('Content-Type: text/plain');
+ header('Content-Length: '.strlen($result));
+ header('Content-Disposition: attachment; filename="config.inc.php"');
+ echo $result;
+ exit;
+ } else if (isset($_POST['save'])) {
+ $result = generateConfig();
+ $file = 'config.inc.php';
+ if (defined('__NOT_MAIN_SCRIPT')) {
+ $file = 'www/'.$file;
+ }
+ if (file_put_contents($file,$result)) {
+ msg('Configuration sucessfully saved!','ok');
+ echo '<a href="index.php">click here to start using your new site</a><br><br>';
+ } else {
+ msg('Configuration file could not be saved, please proceed with the download!','fail');
+ }
+ }
+?>
+<div id="message">Congratulations your setup is almost complete.</div>
+<div id="message">Now the remaining step is to save the config.inc.php file to your server.</div>
+<div id="message">You can try saving it automatically, and if it's ok you'll be redirected to you new installed site.<br>
+Please note that this requires write access to the "www" folder.</div>
+<div id="message">Or you can download the file to review and upload to the server.</div>
+<form method="POST" action="index.php">
+<input type="hidden" name="step" value="<?php echo $step; ?>">
+<input type="submit" name="download" value="Download Configuration">
+<input type="submit" name="save" value="Save Configuration">
+</form>
+<?php
+}
+
+/*********************** SETUP AND DISPLAY OF PAGE **********************/
+
+if (isset($_SESSION['steps'])) {
+ foreach ($_SESSION['steps'] as $k => $l) {
+ $steps[$k]['done']=$l;
+ }
+}
+
+if (isset($steps[$step])) {
+ $title = $steps[$step]['title'];
+ $fun = $steps[$step]['function'];
+}
+
+?>
+<html>
+<head><TITLE>OpenUpload Setup Script</TITLE></head>
+<style>
+body {
+ font-family: Helvetica, Arial;
+ font-size: 10pt;
+}
+#header {
+}
+#logo {
+ float:left;
+}
+#userinfo {
+ clear: right;
+ float: right;
+ height: 40px;
+ vertical-align: bottom;
+ margin-top: 40px;
+ margin-right: 20px;
+}
+#title {
+ background-color: #3161cf;
+ color: #ffffff;
+ font-size: 12pt;
+ font-weight: bold;
+ clear: right;
+ padding-left: 160px;
+ padding-top: 3px;
+ padding-bottom:3px;
+ text-align: left;
+ margin-top: 50px;
+}
+#left {
+ width: 200px;
+ float: left;
+ clear: both;
+}
+#left ul {
+ list-style:none;
+ margin-top: 10px;
+ padding: 0;
+}
+#left li {
+ padding-right: 8px;
+ padding-left: 8px;
+}
+#content {
+ margin-left: 220px;
+ padding-top: 20px;
+}
+#message {
+ padding-bottom: 10px;
+}
+a {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 11pt;
+ text-decoration: none;
+}
+a:visited {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 11pt;
+ text-decoration: none;
+}
+a:hover {
+ color: #4c8dff;
+ font-weight: bold;
+ font-size: 11pt;
+ text-decoration: none;
+}
+#footer {
+ clear: both;
+ position: fixed;
+ bottom: 0px;
+ height: 20px;
+ width: 100%;
+ font-weight: bold;
+ font-size: 9pt;
+ border-top: 1px solid #000000;
+ text-align: center;
+ background-color: #ffffff;
+}
+#footer a {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 9pt;
+ text-decoration: none;
+}
+#footer a:visited {
+ color: #3161cf;
+ font-weight: bold;
+ font-size: 9pt;
+ text-decoration: none;
+}
+</style>
+<div>
+<div id="header">
+<div id="logo"><img src="<?php echo $path; ?>/img/openupload.jpg" border="0"></div>
+</div>
+<div id="userinfo">
+</div>
+<div id="title"><?php echo $title; ?></div>
+<div id="left">
+<ul>
+<?php
+foreach ($steps as $k => $s) {
+ if ($step == $k) {
+ $img = 'current.png';
+ } else if ($s['done']) {
+ $img = 'ok.png';
+ } else {
+ $img = 'step.png';
+ }
+ if ($s['done']==false) {
+ echo '<li><img border="0" src="'.$path.'/img/setup/'.$img.'"> '.$s['title'].'</li>'."\n";
+ } else {
+ echo '<li><a href="index.php?step='.$k.'"><img border="0" src="'.$path.'/img/setup/'.$img.'"> '.$s['title'].'</a></li>'."\n";
+ }
+}
+?>
+</ul>
+</div>
+<div id="content">
+<?php
+ $res = $fun($step);
+ $_SESSION['config']=$CONFIG;
+ if ($res != '' and $res != $step) {
+ $steps[$step]['done']=true;
+ foreach ($steps as $k => $s) {
+ $_SESSION['steps'][$k]=$s['done'];
+ }
+ ob_clean();
+ header('location: index.php?step='.$res);
+ exit;
+ }
+?>
+</div>
+<br> <br>
+<!-- footer -->
+<div id="footer"><a href="http://openupload.sf.net">Open Upload</a> - Created by Alessandro Briosi © 2008</div>
+</body>
+</html>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|