version 1.1.1.1.2.1, 2007/11/13 07:39:25
|
version 1.1.1.1.2.2, 2007/11/15 15:29:46
|
Line 24
|
Line 24
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
# SUCH DAMAGE. |
# SUCH DAMAGE. |
# |
# |
# $Paefchen$ | # $Paefchen: FreeBSD/tinderbox/webui/index.php,v 1.1.1.1.2.1 2007/11/13 07:39:25 as Exp $ |
# $MCom: portstools/tinderbox/webui/index.php,v 1.22 2007/10/13 02:28:47 ade 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', | if ((int)PHP_VERSION < 5) |
'PortFailureReasons', 'Session', 'Tinderd', 'Users'); | die ("Error: TB-WebUI needs PHP5!\n"); |
|
|
set_include_path(get_include_path() . PATH_SEPARATOR . 'module' | foreach (array('pcre') as $phpmodule) |
. PATH_SEPARATOR . 'core'); | if (! extension_loaded($phpmodule)) |
| die (sprintf("Error: TB-WebUI needs PHP-Module '%s'\n", |
| $phpmodule)); |
|
|
|
if (! is_readable('inc_ds.php')) |
|
die ("Error: Configuration File not found (inc_ds.php)\n"); |
|
require_once 'inc_ds.php'; |
|
|
|
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); |
|
|
|
set_include_path(get_include_path().PATH_SEPARATOR.'module' |
|
.PATH_SEPARATOR.'core'); |
|
|
function __autoload($class) { |
function __autoload($class) { |
require_once $class . '.php'; |
require_once $class . '.php'; |
} |
} |
|
|
foreach ($cfg_modules as $module) { | function module_list() { |
$className = 'module' . $module; | return preg_split('/[,; ]+/', MODULES); |
| } |
| |
| function module_instance($module) { |
| static $instances; |
| if (! isset($instances)) |
| $instances = array(); |
| } |
| |
| |
| 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; |
$$className = new $className; |
} |
} |
|
|
require_once $templatesdir.'/messages.inc'; | require_once TEMPLATESDIR.'/messages.inc'; |
|
|
$moduleSession->start(); | if (defined('MODULE_USERS')) { |
if( isset($_POST['do_login']) ) { | $moduleUsers->start(); |
$moduleUsers->do_login( $_POST['User_Name'], $_POST['User_Password'] ); | |
} elseif( isset($_POST['do_logout']) || ( $moduleUsers->is_logged_in() && !$moduleUsers->get_www_enabled() ) ) { | if (isset($_POST['do_login'])) { |
$moduleUsers->do_logout(); | $moduleUsers->do_login( $_POST['User_Name'], $_POST['User_Password']); |
header( 'Location: index.php' ); | } |
| 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']; |
$action = $_REQUEST['action']; |
|
|