1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
pkg_mgr.php
|
6
|
Copyright (C) 2004, 2005 Scott Ullrich
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
|
31
|
require("guiconfig.inc");
|
32
|
require("xmlparse_pkg.inc");
|
33
|
|
34
|
$a_out = &$pkg_config['packages'];
|
35
|
|
36
|
if ($_POST) {
|
37
|
|
38
|
$pconfig = $_POST;
|
39
|
|
40
|
$retval = 0;
|
41
|
|
42
|
if (!file_exists($d_sysrebootreqd_path)) {
|
43
|
config_lock();
|
44
|
$retval |= filter_configure();
|
45
|
config_unlock();
|
46
|
}
|
47
|
$savemsg = get_std_save_message($retval);
|
48
|
|
49
|
if ($retval == 0) {
|
50
|
if (file_exists($d_natconfdirty_path))
|
51
|
unlink($d_natconfdirty_path);
|
52
|
if (file_exists($d_filterconfdirty_path))
|
53
|
unlink($d_filterconfdirty_path);
|
54
|
}
|
55
|
}
|
56
|
|
57
|
?>
|
58
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
59
|
<html>
|
60
|
<head>
|
61
|
<title><?=gentitle("System: Package Manager");?></title>
|
62
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
63
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
64
|
</head>
|
65
|
|
66
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
67
|
<?php
|
68
|
include("fbegin.inc");
|
69
|
?>
|
70
|
<p class="pgtitle">System: Package Manager</p>
|
71
|
<br>
|
72
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
73
|
<?php
|
74
|
|
75
|
if(!file_exists("{$g['tmp_path']}/pkg_config.xml")) {
|
76
|
fetch_latest_pkg_config();
|
77
|
}
|
78
|
|
79
|
$pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs");
|
80
|
|
81
|
if(!$pkg_config['packages']) {
|
82
|
print_info_box_np("Could not find any packages in pkg_config.xml");
|
83
|
}
|
84
|
?>
|
85
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
86
|
<ul id="tabnav">
|
87
|
<li class="tabact">Available Packages</a></li>
|
88
|
<li class="tabinact"><a href="pkg_mgr_installed.php">Installed Packages</a></li>
|
89
|
</ul>
|
90
|
</td></tr>
|
91
|
<tr>
|
92
|
<td class="tabcont">
|
93
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
94
|
<tr>
|
95
|
<td width="10%" class="listhdrr">Package Name</td>
|
96
|
<td width="25%" class="listhdrr">Category</td>
|
97
|
<td width="5%" class="listhdrr">Status</td>
|
98
|
<td width="50%" class="listhdr">Description</td>
|
99
|
</tr>
|
100
|
|
101
|
<?php
|
102
|
$pkgs = array();
|
103
|
$instpkgs = array();
|
104
|
if($config['installedpackages']['package'] != "")
|
105
|
foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
|
106
|
|
107
|
foreach ($pkg_config['packages']['package'] as $key => $pkg) {
|
108
|
if(!in_array($pkg['name'], $instpkgs)) {
|
109
|
$pkgs[$key] = $pkg['name'];
|
110
|
}
|
111
|
}
|
112
|
asort($pkgs);
|
113
|
$pkgs = array_keys($pkgs);
|
114
|
foreach($pkgs as $index) {
|
115
|
if($pkgs[0] == "") {
|
116
|
echo "<tr><td colspan=\"3\"><center>There are currently no available packages for installation.</td></tr>";
|
117
|
}
|
118
|
?>
|
119
|
<tr valign="top">
|
120
|
<td class="listlr">
|
121
|
<A target="_new" href="<?= $pkg_config['packages']['package'][$index]['website'] ?>"><?= $pkg_config['packages']['package'][$index]['name'] ?></a>
|
122
|
</td>
|
123
|
<td class="listlr">
|
124
|
<?= $pkg_config['packages']['package'][$index]['category'] ?>
|
125
|
</td>
|
126
|
<td class="listlr">
|
127
|
<?= $pkg_config['packages']['package'][$index]['status'] ?>
|
128
|
<br>
|
129
|
<?= $pkg_config['packages']['package'][$index]['version'] ?>
|
130
|
</td>
|
131
|
<td class="listbg">
|
132
|
<font color="#FFFFFFF">
|
133
|
<?= $pkg_config['packages']['package'][$index]['descr'] ?>
|
134
|
</td>
|
135
|
<td valign="middle" class="list" nowrap>
|
136
|
<a onclick="return confirm('Do you really want to install this package?')" href="pkg_mgr_install.php?id=<?=$index;?>"><img src="plus.gif" width="17" height="17" border="0"></a>
|
137
|
</td>
|
138
|
</tr>
|
139
|
<?php
|
140
|
}
|
141
|
?>
|
142
|
</table>
|
143
|
</td>
|
144
|
</tr>
|
145
|
</table>
|
146
|
<?php include("fend.inc"); ?>
|
147
|
</body>
|
148
|
</html>
|
149
|
|
150
|
<?php unlink_if_exists("{$g['tmp_path']}/pkg*"); ?>
|