--- FreeBSD/tinderbox/webui/index.php 2007/11/13 07:39:25 1.1.1.1.2.1 +++ FreeBSD/tinderbox/webui/index.php 2007/11/16 23:03:38 1.1.1.1.2.4 @@ -24,38 +24,88 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Paefchen$ +# $Paefchen: FreeBSD/tinderbox/webui/index.php,v 1.1.1.1.2.3 2007/11/16 22:52:43 as Exp $ # $MCom: portstools/tinderbox/webui/index.php,v 1.22 2007/10/13 02:28:47 ade Exp $ # -$starttimer = microtime(true); +define('STARTTIME', microtime(true)); -$cfg_modules = array('Builds', 'BuildPorts', 'Config', 'Ports', - 'PortFailureReasons', 'Session', 'Tinderd', 'Users'); +if ((int)PHP_VERSION < 5) + die ("Error: TB-WebUI needs PHP5!\n"); -set_include_path(get_include_path() . PATH_SEPARATOR . 'module' - . PATH_SEPARATOR . 'core'); +foreach (array('pcre') as $phpmodule) + if (! extension_loaded($phpmodule)) + die (sprintf("Error: TB-WebUI needs PHP-Module '%s'\n", + $phpmodule)); -function __autoload($class) { - require_once $class . '.php'; -} +if (! is_readable('inc_ds.php')) + die ("Error: Configuration File not found (inc_ds.php)\n"); +require_once 'inc_ds.php'; -foreach ($cfg_modules as $module) { - $className = 'module' . $module; +if (is_readable('inc_tinderbox.php')) + require_once 'inc_tinderbox.php'; + +/* ...defaults && compat... */ +if (! defined('MODULES')) define('MODULES', 'Builds, BuildPorts, Config, Ports, PortFailureReasons, Tinderd, Users'); +if (! defined('TB_NAME')) define('TB_NAME', isset($tinderbox_name) ? $tinderbox_name : 'Example Tinderbox'); +if (! defined('TB_TITLE')) define('TB_TITLE', isset($tinderbox_title) ? $tinderbox_title : 'Example Tinderbox'); +if (! defined('WWWROOT')) define('WWWROOT', isset($wwwrooturi) ? $wwwrooturi : dirname(__FILE__)); +if (! defined('TBROOT')) define('TBROOT', isset($rootdir) ? $rootdir : realpath(WWWROOT.'/../..')); +if (! defined('TEMPLATE')) define('TEMPLATE', isset($template_dir) ? $template_dir : 'default'); +if (! defined('URLROOT')) define('URLROOT', dirname($_SERVER['SCRIPT_NAME'])); +if (! defined('PROTOCOL')) define('PROTOCOL', isset($_SERVER['HTTPS'])?'https':'http'); +if (! defined('HOSTNAME')) define('HOSTNAME', $_SERVER['SERVER_NAME']); +if (! defined('PORT')) define('PORT', $_SERVER['SERVER_PORT']); +if (! defined('URL')) define('URL', PROTOCOL.'://'.HOSTNAME.(PORT!=80?':80':'').URLROOT); +if (! defined('PKGURL')) define('PKGURL', isset($pkguri) ? $pkguri : URL.'/packages'); +if (! defined('PKGDIR')) define('PKGDIR', isset($pkgdir) ? $pkgdir : TBROOT.'/packages'); +if (! defined('LOGURL')) define('LOGURL', isset($loguri) ? $loguri : URL.'/logs'); +if (! defined('LOGDIR')) define('LOGDIR', isset($lodir) ? $logdir : TBROOT.'/logs'); +if (! defined('ERRORLOGURL')) define('ERRORLOGURL', isset($errorloguri) ? $errorloguri : URL.'/errors'); +if (! defined('ERRORLOGDIR')) define('ERRORLOGDIR', isset($errorlogdir) ? $errorlogdir : TBROOT.'/errors'); +if (! defined('TEMPLATESURL')) define('TEMPLATESURL', isset($templatesuri) ? $templatesuri : URL.'/templates/'.TEMPLATE); +if (! defined('TEMPLATESDIR')) define('TEMPLATESDIR', isset($templatesdir) ? $templatesdir : WWWROOT.'/templates/'.TEMPLATE); +if (! defined('SHOWTIMER')) define('SHOWTIMER', false); + +foreach (array('WWWROOT', 'TBROOT', 'TEMPLATESDIR') as $dir) + if (! is_dir(constant($dir))) + die(sprintf("Error => config: dir %s not found (%s)\n", + constant($dir), $dir)); + +set_include_path(get_include_path().PATH_SEPARATOR.'module' + .PATH_SEPARATOR.'core'); + +require_once 'functions.php'; +require_once TEMPLATESDIR.'/messages.inc'; + +foreach (module_list() as $moduleName) { + $className = 'module' . $moduleName; + + if (! is_readable('module/'.$className.'.php')) + die (sprintf("Error: Module not found (%s)\n", + $moduleName)); + + define('MODULE_'.strtoupper($moduleName), $className); + /* as xxx */ $$className = new $className; } -require_once $templatesdir.'/messages.inc'; +if (defined('MODULE_USERS')) { + $moduleUsers->start(); -$moduleSession->start(); -if( isset($_POST['do_login']) ) { - $moduleUsers->do_login( $_POST['User_Name'], $_POST['User_Password'] ); -} elseif( isset($_POST['do_logout']) || ( $moduleUsers->is_logged_in() && !$moduleUsers->get_www_enabled() ) ) { - $moduleUsers->do_logout(); - header( 'Location: index.php' ); + if (isset($_POST['do_login'])) { + $moduleUsers->do_login( $_POST['User_Name'], $_POST['User_Password']); + } + else if(isset($_POST['do_logout']) + || ($moduleUsers->is_logged_in() && ! $moduleUsers->get_www_enabled())) { + $moduleUsers->do_logout(); + header('Location: index.php'); + exit; + } } -$display_login = $moduleUsers->display_login(); +/* as xxx */ +#$display_login = $moduleUsers->display_login(); $action = $_REQUEST['action'];