Annotation of FreeBSD/tinderbox/webui/index.php, revision 1.1.1.1
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: #
27: # $MCom: portstools/tinderbox/webui/index.php,v 1.22 2007/10/13 02:28:47 ade Exp $
28: #
29:
30: $starttimer = explode( ' ', microtime() );
31:
32: require_once 'module/moduleBuilds.php';
33: require_once 'module/moduleBuildPorts.php';
34: require_once 'module/moduleConfig.php';
35: require_once 'module/modulePorts.php';
36: require_once 'module/modulePortFailureReasons.php';
37: require_once 'module/moduleSession.php';
38: require_once 'module/moduleTinderd.php';
39: require_once 'module/moduleUsers.php';
40:
41: require_once $templatesdir.'/messages.inc';
42:
43: $moduleBuilds = new moduleBuilds();
44: $moduleBuildPorts = new moduleBuildPorts();
45: $moduleConfig = new moduleConfig();
46: $modulePorts = new modulePorts();
47: $modulePortFailureReasons = new modulePortFailureReasons();
48: $moduleSession = new moduleSession();
49: $moduleTinderd = new moduleTinderd();
50: $moduleUsers = new moduleUsers();
51:
52: $moduleSession->start();
53: if( isset($_POST['do_login']) ) {
54: $moduleUsers->do_login( $_POST['User_Name'], $_POST['User_Password'] );
55: } elseif( isset($_POST['do_logout']) || ( $moduleUsers->is_logged_in() && !$moduleUsers->get_www_enabled() ) ) {
56: $moduleUsers->do_logout();
57: header( 'Location: index.php' );
58: }
59:
60: $display_login = $moduleUsers->display_login();
61:
62: $action = $_REQUEST['action'];
63:
64: switch( $action ) {
65: case 'describe_port': $port_id = $_REQUEST['id'];
66: $display = $modulePorts->display_describe_port( $port_id );
67: break;
68: case 'failed_buildports': $build = $_REQUEST['build'];
69: $maintainer = $_REQUEST['maintainer'];
70: $display = $moduleBuildPorts->display_failed_buildports( $build, $maintainer, null );
71: break;
72: case 'bad_buildports': $build = $_REQUEST['build'];
73: $maintainer = $_REQUEST['maintainer'];
74: $display = $moduleBuildPorts->display_failed_buildports( $build, $maintainer, 'foo' );
75: break;
76: case 'latest_buildports': $build = $_REQUEST['build'];
77: $display = $moduleBuildPorts->display_latest_buildports( $build );
78: break;
79: case 'list_buildports': $build = $_REQUEST['build'];
80: $sort = '';
81: if (isset($_REQUEST['sort'])) {
82: $sort = $_REQUEST['sort'];
83: }
84: $display = $moduleBuildPorts->display_list_buildports( $build, $sort );
85: break;
86: case 'list_tinderd_queue': $build_id = $_REQUEST['filter_build_id'];
87: $display = $moduleTinderd->list_tinderd_queue( $build_id );
88: break;
89: case 'change_tinderd_queue': $ctinderdq = $_REQUEST['change_tinderd_queue'];
90: $entry_id = $_REQUEST['entry_id'];
91: $build_id = $_REQUEST['build_id'];
92: $priority = $_REQUEST['priority'];
93: $emailoc = $_REQUEST['email_on_completion'];
94: $moduleTinderd->change_tinderd_queue( $ctinderdq, $entry_id, $build_id, $priority, $emailoc );
95: $build_id = $_REQUEST['filter_build_id'];
96: $display = $moduleTinderd->list_tinderd_queue( $build_id );
97: break;
98: case 'add_tinderd_queue': $atinderdq = $_REQUEST['add_tinderd_queue'];
99: $build_id = $_REQUEST['new_build_id'];
100: $priority = $_REQUEST['new_priority'];
101: $directory = $_REQUEST['new_port_directory'];
102: $emailoc = $_REQUEST['new_email_on_completion'];
103: $moduleTinderd->add_tinderd_queue( $atinderdq, $build_id, $priority, $directory, $emailoc );
104: $build_id = $_REQUEST['filter_build_id'];
105: $display = $moduleTinderd->list_tinderd_queue( $build_id );
106: break;
107: case 'display_add_user': $display = $moduleUsers->display_add_user( '', '', '', '', array() );
108: break;
109: case 'add_user': $user_name = $_REQUEST['user_name'];
110: $user_email = $_REQUEST['user_email'];
111: $user_pwd = $_REQUEST['user_password'];
112: $wwwenabled = $_REQUEST['www_enabled'];
113: $display = $moduleUsers->action_user( 'add', '', $user_name, $user_email, $user_pwd, $wwwenabled );
114: switch( $display ) {
115: case '1': unset( $display ); header( 'Location: index.php' ); break;
116: case '0': $display = $moduleUsers->display_add_user( $user_name, $user_email, $user_pwd, $wwwenabled ); break;
117: }
118: break;
119: case 'display_modify_user': $user_id = $_REQUEST['modify_user_id'];
120: $display = $moduleUsers->display_modify_user( 1, $user_id, '', '', '', '', array() );
121: break;
122: case 'modify_user': $actionuser = $_REQUEST['action_user'];
123: $user_id = $_REQUEST['user_id'];
124: $user_name = $_REQUEST['user_name'];
125: $user_email = $_REQUEST['user_email'];
126: $user_pwd = $_REQUEST['user_password'];
127: $wwwenabled = $_REQUEST['www_enabled'];
128: $display = $moduleUsers->action_user( $actionuser, $user_id, $user_name, $user_email, $user_pwd, $wwwenabled );
129: switch( $display ) {
130: case '1': unset( $display ); header( 'Location: index.php' ); break;
131: case '0': $display = $moduleUsers->display_modify_user( 0, $user_id, $user_name, $user_email, $user_pwd, $www_enabled ); break;
132: }
133: break;
134: case 'display_failure_reasons': $failure_reason_tag = $_REQUEST['failure_reason_tag'];
135: $display = $modulePortFailureReasons->display_failure_reasons( $failure_reason_tag );
136: break;
137: case 'config': $display = $moduleConfig->display_config();
138: break;
139: case 'list_builds':
140: default: $display = $moduleBuilds->display_list_builds();
141: break;
142: }
143:
144: echo $display;
145:
146: if( isset( $with_timer ) && $with_timer == 1 ) {
147: $endtimer = explode( ' ', microtime() );
148: $timer = ( $endtimer[1]-$starttimer[1] )+( $endtimer[0]-$starttimer[0] );
149: printf( '<p style="color:#FF0000;font-size:10px;">elapsed: %03.6f seconds, %s', $timer, ' </p>' );
150: }
151: echo '<p style="font-size:10px;"><b>Note:</b> The Tinderbox web interface requires cookies to be enable.</p>';
152: ?>