Annotation of FreeBSD/tinderbox/webui/index.php, revision 1.1.1.1.2.4
1.1 as 1: <?php
2: #-
3: # Copyright (c) 2005 Oliver Lehmann <oliver@FreeBSD.org>
4: # All rights reserved.
5: #
6: # Redistribution and use in source and binary forms, with or without
7: # modification, are permitted provided that the following conditions
8: # are met:
9: # 1. Redistributions of source code must retain the above copyright
10: # notice, this list of conditions and the following disclaimer
11: # 2. Redistributions in binary form must reproduce the above copyright
12: # notice, this list of conditions and the following disclaimer in the
13: # documentation and/or other materials provided with the distribution.
14: #
15: # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16: # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17: # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18: # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19: # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20: # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21: # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22: # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23: # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24: # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25: # SUCH DAMAGE.
26: #
1.1.1.1.2.4! as 27: # $Paefchen: FreeBSD/tinderbox/webui/index.php,v 1.1.1.1.2.3 2007/11/16 22:52:43 as Exp $
1.1 as 28: # $MCom: portstools/tinderbox/webui/index.php,v 1.22 2007/10/13 02:28:47 ade Exp $
29: #
30:
1.1.1.1.2.2 as 31: define('STARTTIME', microtime(true));
1.1 as 32:
1.1.1.1.2.2 as 33: if ((int)PHP_VERSION < 5)
34: die ("Error: TB-WebUI needs PHP5!\n");
1.1 as 35:
1.1.1.1.2.2 as 36: foreach (array('pcre') as $phpmodule)
37: if (! extension_loaded($phpmodule))
38: die (sprintf("Error: TB-WebUI needs PHP-Module '%s'\n",
39: $phpmodule));
40:
41: if (! is_readable('inc_ds.php'))
42: die ("Error: Configuration File not found (inc_ds.php)\n");
43: require_once 'inc_ds.php';
44:
45: if (is_readable('inc_tinderbox.php'))
46: require_once 'inc_tinderbox.php';
47:
48: /* ...defaults && compat... */
49: if (! defined('MODULES')) define('MODULES', 'Builds, BuildPorts, Config, Ports, PortFailureReasons, Tinderd, Users');
50: if (! defined('TB_NAME')) define('TB_NAME', isset($tinderbox_name) ? $tinderbox_name : 'Example Tinderbox');
51: if (! defined('TB_TITLE')) define('TB_TITLE', isset($tinderbox_title) ? $tinderbox_title : 'Example Tinderbox');
52: if (! defined('WWWROOT')) define('WWWROOT', isset($wwwrooturi) ? $wwwrooturi : dirname(__FILE__));
53: if (! defined('TBROOT')) define('TBROOT', isset($rootdir) ? $rootdir : realpath(WWWROOT.'/../..'));
54: if (! defined('TEMPLATE')) define('TEMPLATE', isset($template_dir) ? $template_dir : 'default');
55: if (! defined('URLROOT')) define('URLROOT', dirname($_SERVER['SCRIPT_NAME']));
56: if (! defined('PROTOCOL')) define('PROTOCOL', isset($_SERVER['HTTPS'])?'https':'http');
57: if (! defined('HOSTNAME')) define('HOSTNAME', $_SERVER['SERVER_NAME']);
58: if (! defined('PORT')) define('PORT', $_SERVER['SERVER_PORT']);
59: if (! defined('URL')) define('URL', PROTOCOL.'://'.HOSTNAME.(PORT!=80?':80':'').URLROOT);
60: if (! defined('PKGURL')) define('PKGURL', isset($pkguri) ? $pkguri : URL.'/packages');
61: if (! defined('PKGDIR')) define('PKGDIR', isset($pkgdir) ? $pkgdir : TBROOT.'/packages');
62: if (! defined('LOGURL')) define('LOGURL', isset($loguri) ? $loguri : URL.'/logs');
63: if (! defined('LOGDIR')) define('LOGDIR', isset($lodir) ? $logdir : TBROOT.'/logs');
64: if (! defined('ERRORLOGURL')) define('ERRORLOGURL', isset($errorloguri) ? $errorloguri : URL.'/errors');
65: if (! defined('ERRORLOGDIR')) define('ERRORLOGDIR', isset($errorlogdir) ? $errorlogdir : TBROOT.'/errors');
66: if (! defined('TEMPLATESURL')) define('TEMPLATESURL', isset($templatesuri) ? $templatesuri : URL.'/templates/'.TEMPLATE);
67: if (! defined('TEMPLATESDIR')) define('TEMPLATESDIR', isset($templatesdir) ? $templatesdir : WWWROOT.'/templates/'.TEMPLATE);
68: if (! defined('SHOWTIMER')) define('SHOWTIMER', false);
69:
1.1.1.1.2.3 as 70: foreach (array('WWWROOT', 'TBROOT', 'TEMPLATESDIR') as $dir)
71: if (! is_dir(constant($dir)))
72: die(sprintf("Error => config: dir %s not found (%s)\n",
73: constant($dir), $dir));
74:
1.1.1.1.2.2 as 75: set_include_path(get_include_path().PATH_SEPARATOR.'module'
76: .PATH_SEPARATOR.'core');
1.1.1.1.2.1 as 77:
1.1.1.1.2.4! as 78: require_once 'functions.php';
! 79: require_once TEMPLATESDIR.'/messages.inc';
1.1.1.1.2.2 as 80:
81: foreach (module_list() as $moduleName) {
82: $className = 'module' . $moduleName;
83:
84: if (! is_readable('module/'.$className.'.php'))
85: die (sprintf("Error: Module not found (%s)\n",
86: $moduleName));
87:
88: define('MODULE_'.strtoupper($moduleName), $className);
89: /* as xxx */
1.1.1.1.2.1 as 90: $$className = new $className;
91: }
1.1 as 92:
1.1.1.1.2.2 as 93: if (defined('MODULE_USERS')) {
94: $moduleUsers->start();
1.1 as 95:
1.1.1.1.2.2 as 96: if (isset($_POST['do_login'])) {
97: $moduleUsers->do_login( $_POST['User_Name'], $_POST['User_Password']);
98: }
99: else if(isset($_POST['do_logout'])
100: || ($moduleUsers->is_logged_in() && ! $moduleUsers->get_www_enabled())) {
101: $moduleUsers->do_logout();
102: header('Location: index.php');
103: exit;
104: }
1.1 as 105: }
106:
1.1.1.1.2.2 as 107: /* as xxx */
108: #$display_login = $moduleUsers->display_login();
1.1 as 109:
110: $action = $_REQUEST['action'];
111:
112: switch( $action ) {
113: case 'describe_port': $port_id = $_REQUEST['id'];
114: $display = $modulePorts->display_describe_port( $port_id );
115: break;
116: case 'failed_buildports': $build = $_REQUEST['build'];
117: $maintainer = $_REQUEST['maintainer'];
118: $display = $moduleBuildPorts->display_failed_buildports( $build, $maintainer, null );
119: break;
120: case 'bad_buildports': $build = $_REQUEST['build'];
121: $maintainer = $_REQUEST['maintainer'];
122: $display = $moduleBuildPorts->display_failed_buildports( $build, $maintainer, 'foo' );
123: break;
124: case 'latest_buildports': $build = $_REQUEST['build'];
125: $display = $moduleBuildPorts->display_latest_buildports( $build );
126: break;
127: case 'list_buildports': $build = $_REQUEST['build'];
128: $sort = '';
129: if (isset($_REQUEST['sort'])) {
130: $sort = $_REQUEST['sort'];
131: }
132: $display = $moduleBuildPorts->display_list_buildports( $build, $sort );
133: break;
134: case 'list_tinderd_queue': $build_id = $_REQUEST['filter_build_id'];
135: $display = $moduleTinderd->list_tinderd_queue( $build_id );
136: break;
137: case 'change_tinderd_queue': $ctinderdq = $_REQUEST['change_tinderd_queue'];
138: $entry_id = $_REQUEST['entry_id'];
139: $build_id = $_REQUEST['build_id'];
140: $priority = $_REQUEST['priority'];
141: $emailoc = $_REQUEST['email_on_completion'];
142: $moduleTinderd->change_tinderd_queue( $ctinderdq, $entry_id, $build_id, $priority, $emailoc );
143: $build_id = $_REQUEST['filter_build_id'];
144: $display = $moduleTinderd->list_tinderd_queue( $build_id );
145: break;
146: case 'add_tinderd_queue': $atinderdq = $_REQUEST['add_tinderd_queue'];
147: $build_id = $_REQUEST['new_build_id'];
148: $priority = $_REQUEST['new_priority'];
149: $directory = $_REQUEST['new_port_directory'];
150: $emailoc = $_REQUEST['new_email_on_completion'];
151: $moduleTinderd->add_tinderd_queue( $atinderdq, $build_id, $priority, $directory, $emailoc );
152: $build_id = $_REQUEST['filter_build_id'];
153: $display = $moduleTinderd->list_tinderd_queue( $build_id );
154: break;
155: case 'display_add_user': $display = $moduleUsers->display_add_user( '', '', '', '', array() );
156: break;
157: case 'add_user': $user_name = $_REQUEST['user_name'];
158: $user_email = $_REQUEST['user_email'];
159: $user_pwd = $_REQUEST['user_password'];
160: $wwwenabled = $_REQUEST['www_enabled'];
161: $display = $moduleUsers->action_user( 'add', '', $user_name, $user_email, $user_pwd, $wwwenabled );
162: switch( $display ) {
163: case '1': unset( $display ); header( 'Location: index.php' ); break;
164: case '0': $display = $moduleUsers->display_add_user( $user_name, $user_email, $user_pwd, $wwwenabled ); break;
165: }
166: break;
167: case 'display_modify_user': $user_id = $_REQUEST['modify_user_id'];
168: $display = $moduleUsers->display_modify_user( 1, $user_id, '', '', '', '', array() );
169: break;
170: case 'modify_user': $actionuser = $_REQUEST['action_user'];
171: $user_id = $_REQUEST['user_id'];
172: $user_name = $_REQUEST['user_name'];
173: $user_email = $_REQUEST['user_email'];
174: $user_pwd = $_REQUEST['user_password'];
175: $wwwenabled = $_REQUEST['www_enabled'];
176: $display = $moduleUsers->action_user( $actionuser, $user_id, $user_name, $user_email, $user_pwd, $wwwenabled );
177: switch( $display ) {
178: case '1': unset( $display ); header( 'Location: index.php' ); break;
179: case '0': $display = $moduleUsers->display_modify_user( 0, $user_id, $user_name, $user_email, $user_pwd, $www_enabled ); break;
180: }
181: break;
182: case 'display_failure_reasons': $failure_reason_tag = $_REQUEST['failure_reason_tag'];
183: $display = $modulePortFailureReasons->display_failure_reasons( $failure_reason_tag );
184: break;
185: case 'config': $display = $moduleConfig->display_config();
186: break;
187: case 'list_builds':
188: default: $display = $moduleBuilds->display_list_builds();
189: break;
190: }
191:
192: echo $display;
193:
1.1.1.1.2.1 as 194: if (isset($with_timer) && $with_timer)
195: printf('<p style="color:#FF0000;font-size:10px;">elapsed: %03.6f seconds, </p>', microtime(true) - $starttimer);
196:
1.1 as 197: echo '<p style="font-size:10px;"><b>Note:</b> The Tinderbox web interface requires cookies to be enable.</p>';
198: ?>