Project

General

Profile

Download (5.96 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
#!/usr/local/bin/php
2
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 ee11cc6e Scott Ullrich
/*
5
    pkg_mgr.php
6 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
7 ee11cc6e Scott Ullrich
    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 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
32 f8e335a3 Scott Ullrich
require_once("pkg-utils.inc");
33 ee11cc6e Scott Ullrich
34
if ($_POST) {
35
36
    $pconfig = $_POST;
37
38
    $retval = 0;
39
40
    if (!file_exists($d_sysrebootreqd_path)) {
41
		config_lock();
42
        $retval |= filter_configure();
43
		config_unlock();
44
    }
45
    $savemsg = get_std_save_message($retval);
46
47
    if ($retval == 0) {
48
        if (file_exists($d_natconfdirty_path))
49
            unlink($d_natconfdirty_path);
50
        if (file_exists($d_filterconfdirty_path))
51
            unlink($d_filterconfdirty_path);
52
    }
53
}
54
55 3f3a5bef Colin Smith
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr'));
56
if($pkg_info) {
57
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
58
	fwrite($fout, serialize($pkg_info));
59
        $pkg_sizes = get_pkg_sizes();
60
} else {
61
	$using_cache = true;
62
        $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
63
	$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
64
}
65 52380979 Scott Ullrich
66 96d9f5c9 Bill Marquette
$pgtitle = "System: Package Manager";
67 52380979 Scott Ullrich
include("head.inc");
68
69 ee11cc6e Scott Ullrich
?>
70
71
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
72 859329c8 Scott Ullrich
<?php
73
include("fbegin.inc");
74
?>
75 96d9f5c9 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
76 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
77
<?php
78 859329c8 Scott Ullrich
79 ee11cc6e Scott Ullrich
?>
80 323d040b Scott Ullrich
81 7af5497a Scott Ullrich
<br>
82
83 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
84 e3ebc979 Scott Ullrich
<?php
85
	$tab_array = array();
86
	$tab_array[0] = array("Available Packages", true, "pkg_mgr.php");
87 338ec5f4 Scott Ullrich
	$tab_array[1] = array("Installed Packages", false, "pkg_mgr_installed.php");
88 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
89
?> 
90 ee11cc6e Scott Ullrich
  </td></tr>
91
  <tr>
92 d732f186 Bill Marquette
    <td>
93
	<div id="mainarea">
94
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
95 ee11cc6e Scott Ullrich
                <tr>
96 a15a15e7 Scott Ullrich
                  <td width="10%" class="listhdrr">Package Name</td>
97 ee11cc6e Scott Ullrich
                  <td width="25%" class="listhdrr">Category</td>
98 ea395bfd Colin Smith
		  <td width="10%" class="listhdrr">Size</td>
99 9345a13c Colin Smith
		  <td width="5%" class="listhdrr">Status</td>
100 ee11cc6e Scott Ullrich
                  <td width="50%" class="listhdr">Description</td>
101
                </tr>
102
103
		<?php
104 3f3a5bef Colin Smith
		 if(!$pkg_info) {
105 7ee5da3a Scott Ullrich
			$ip = gethostbyname("www.pfsense.com");
106
			if($ip == "") {
107
				    echo "<tr><td colspan=\"5\"><center>Could not contact pfsense.com.  Check your dns/connection settings.</td></tr>";
108
			} else {
109
				    echo "<tr><td colspan=\"5\"><center>There are currently no available packages for installation.</td></tr>";
110
			}
111 3f3a5bef Colin Smith
		 } else {
112 0db271e0 Colin Smith
		 $pkgs = array();
113
		 $instpkgs = array();
114 62fc920d Scott Ullrich
		    if($config['installedpackages']['package'] != "")
115 ff3a5e37 Colin Smith
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
116 b426850b Colin Smith
		    $pkg_names = array_keys($pkg_info);
117 1507bd61 Colin Smith
		    $pkg_keys = array();
118 b426850b Colin Smith
		    foreach($pkg_names as $name) {
119
			if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
120 0db271e0 Colin Smith
		    }
121 b426850b Colin Smith
		    sort($pkg_keys);
122
		    if(count($pkg_keys) != 0) {
123
		    	foreach($pkg_keys as $key) {
124
			    $index = &$pkg_info[$key];
125
			    if(in_array($index['name'], $instpkgs)) continue;
126 ee11cc6e Scott Ullrich
                            ?>
127
                            <tr valign="top">
128
                                <td class="listlr">
129 b426850b Colin Smith
                                    <A target="_new" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
130 ee11cc6e Scott Ullrich
                                </td>
131
                                <td class="listlr">
132 b426850b Colin Smith
                                    <?= $index['category'] ?>
133 9345a13c Colin Smith
    				</td>
134
				<?php
135 3f3a5bef Colin Smith
					if(!$using_cache) {
136
						$size = get_package_install_size($index['name'], $pkg_sizes);
137
                               			$size = squash_from_bytes($size[$index['name']], 1);
138
					}
139
					if(!$size) $size = "Unknown.";
140 9345a13c Colin Smith
				?>
141
				<td class="listlr">
142 3f3a5bef Colin Smith
                                 	<?= $size ?>
143
                                </td>
144 9345a13c Colin Smith
				<td class="listlr">
145 3f3a5bef Colin Smith
					<?= $index['status'] ?>
146
					<br>
147
					<?= $index['version'] ?>
148 ee11cc6e Scott Ullrich
                                </td>
149
                                <td class="listbg">
150 ae0c2a1c Scott Ullrich
                                    <font color="#ffffff">
151 b426850b Colin Smith
                                    <?= $index['descr'] ?>
152 ee11cc6e Scott Ullrich
                                </td>
153
                                <td valign="middle" class="list" nowrap>
154 677c0869 Erik Kristensen
                                    <a onclick="return confirm('Do you really want to install this package?')" href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
155 ee11cc6e Scott Ullrich
                                </td>
156
                            </tr>
157
                            <?php
158 b426850b Colin Smith
                        }
159
		    } else {
160 148ed32f Scott Ullrich
			echo "<tr><td colspan=\"5\"><center>There are currently no available packages for installation.</td></tr>";
161 b426850b Colin Smith
		    }
162 3f3a5bef Colin Smith
		}
163 ee11cc6e Scott Ullrich
		?>
164
        </table>
165 d732f186 Bill Marquette
	</div>
166 ee11cc6e Scott Ullrich
    </td>
167
  </tr>
168
</table>
169
<?php include("fend.inc"); ?>
170
</body>
171
</html>