Project

General

Profile

Feature #3456 » status_ladvd.php

Andrea Tuccia, 02/17/2014 04:52 AM

 
1
<?php
2
/*
3
	status_ladvd.php
4
        Copyright (C) 2006 Scott Ullrich
5
	All rights reserved.
6

    
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9

    
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12

    
13
	2. Redistributions in binary form must reproduce the above copyright
14
	   notice, this list of conditions and the following disclaimer in the
15
	   documentation and/or other materials provided with the distribution.
16

    
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28

    
29
require("guiconfig.inc");
30

    
31
$pgtitle = "LADVD: Status";
32
include("head.inc");
33

    
34
$control_script = "/usr/local/sbin/ladvdc";
35

    
36
/* List all of the commands as an index. */
37
function listCmds() {
38
	global $commands;
39
	echo "<br/>This status page includes the following information:\n";
40
	echo "<ul width=\"100%\">\n";
41
	for ($i = 0; isset($commands[$i]); $i++ ) {
42
		echo "<li><strong><a href=\"#" . $commands[$i][0] . "\">" . $commands[$i][0] . "</a></strong></li>\n";
43
	}
44
	echo "</ul>\n";
45
}
46

    
47
function execCmds() {
48
	global $commands;
49
	for ($i = 0; isset($commands[$i]); $i++ ) {
50
		doCmdT($commands[$i][0], $commands[$i][1]);
51
	}
52
}
53

    
54
/* Define a command, with a title, to be executed later. */
55
function defCmdT($title, $command) {
56
	global $commands;
57
	$title = htmlspecialchars($title,ENT_NOQUOTES);
58
	$commands[] = array($title, $command);
59
}
60

    
61
function doCmdT($title, $command) {
62
	echo "<p>\n";
63
	echo "<a name=\"" . $title . "\">\n";
64
	echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
65
	echo "<tr><td class=\"listtopic\">" . $title . "</td></tr>\n";
66
	echo "<tr><td class=\"listlr\"><pre>";		/* no newline after pre */
67

    
68
	$execOutput = "";
69
	$execStatus = "";
70
	$fd = popen("{$command} 2>&1", "r");
71
	while (($line = fgets($fd)) !== FALSE) {
72
		echo htmlspecialchars($line, ENT_NOQUOTES);
73
	}
74
	pclose($fd);
75
	echo "</pre></tr>\n";
76
	echo "</table>\n";
77
}
78

    
79
?>
80

    
81
<html>
82
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
83
		<?php include("fbegin.inc"); ?>
84
		<?php if ($savemsg) print_info_box($savemsg); ?>
85

    
86
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
87
  			<tr><td class="tabnavtbl">
88
<?php
89
				$tab_array = array();
90
				$tab_array[] = array(gettext("General"), false, "/pkg_edit.php?xml=ladvd.xml&id=0");
91
				$tab_array[] = array(gettext("Status"), true, "/status_ladvd.php");
92
				display_top_tabs($tab_array);
93
			?>
94
			</td></tr>
95
			  <tr>
96
				<td>
97
				<div id="mainarea">
98
					<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
99
						<tr>
100
							<td>
101
<?php
102
								defCmdT("LADVD Devices", "{$control_script}");
103
								defCmdT("LADVD Detailed decode", "{$control_script} -f");
104
?>
105
								<div id="cmdspace" style="width:100%">
106
									<?php listCmds(); ?>
107
									<?php execCmds(); ?>
108
								</div>
109
							</td>
110
						</tr>
111
					</table>
112
				</div>
113
				</td>
114
			   </tr>
115
		</table>
116
		<?php include("fend.inc"); ?>
117
	</body>
118
</html>
(3-3/4)