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