Project

General

Profile

Download (7.35 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4
    pkg_mgr.php
5 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
6 ee11cc6e Scott Ullrich
    All rights reserved.
7
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
31 f8e335a3 Scott Ullrich
require_once("pkg-utils.inc");
32 ee11cc6e Scott Ullrich
33 61a48553 Scott Ullrich
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version'));
34 3f3a5bef Colin Smith
if($pkg_info) {
35
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
36
	fwrite($fout, serialize($pkg_info));
37 1d1630ec Colin Smith
	fclose($fout);
38 47c44d0a Scott Ullrich
    //$pkg_sizes = get_pkg_sizes();
39 3f3a5bef Colin Smith
} else {
40
	$using_cache = true;
41 47c44d0a Scott Ullrich
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
42
	    $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
43
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
44
	} else {
45
		$savemsg = "Unable to communicate to pfSense.com.  Please check DNS, default gateway, etc.";
46
	}
47 3f3a5bef Colin Smith
}
48 52380979 Scott Ullrich
49 61a48553 Scott Ullrich
if (! empty($_GET)) {
50
  if (isset($_GET['ver'])) {
51
    $requested_version = $_GET['ver'];
52
  }
53
}
54
55 96d9f5c9 Bill Marquette
$pgtitle = "System: Package Manager";
56 52380979 Scott Ullrich
include("head.inc");
57
58 ee11cc6e Scott Ullrich
?>
59
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61 859329c8 Scott Ullrich
<?php
62
include("fbegin.inc");
63
?>
64 96d9f5c9 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
65 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
66
<?php
67 859329c8 Scott Ullrich
68 ee11cc6e Scott Ullrich
?>
69 323d040b Scott Ullrich
70 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
71 e3ebc979 Scott Ullrich
<?php
72 61a48553 Scott Ullrich
	$version = file_get_contents("/etc/version");
73 64b243d2 Scott Ullrich
  $dot = strpos($version, ".");
74
  $hyphen = strpos($version, "-");
75
  $major = substr($version, 0, $dot);
76
  $minor = substr($version, $dot + 1, $hyphen - $dot - 1);
77
  $testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
78
79 e3ebc979 Scott Ullrich
	$tab_array = array();
80 64b243d2 Scott Ullrich
	$tab_array[] = array("Available {$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
81
	$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
82
/*  $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
83 61a48553 Scott Ullrich
	$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
84 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
85 5bd87465 Scott Ullrich
?>
86 ee11cc6e Scott Ullrich
  </td></tr>
87
  <tr>
88 d732f186 Bill Marquette
    <td>
89
	<div id="mainarea">
90
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
91 ee11cc6e Scott Ullrich
                <tr>
92 a15a15e7 Scott Ullrich
                  <td width="10%" class="listhdrr">Package Name</td>
93 ee11cc6e Scott Ullrich
                  <td width="25%" class="listhdrr">Category</td>
94 bfccf041 Colin Smith
<!--
95 ea395bfd Colin Smith
		  <td width="10%" class="listhdrr">Size</td>
96 bfccf041 Colin Smith
-->
97 9345a13c Colin Smith
		  <td width="5%" class="listhdrr">Status</td>
98 f417ddcc Scott Ullrich
		  <td width="5%" class="listhdrr">Maintainer</td>
99 ee11cc6e Scott Ullrich
                  <td width="50%" class="listhdr">Description</td>
100
                </tr>
101
102
		<?php
103 3f3a5bef Colin Smith
		 if(!$pkg_info) {
104 58d797bf Colin Smith
			echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
105 3f3a5bef Colin Smith
		 } else {
106 0db271e0 Colin Smith
		 $pkgs = array();
107
		 $instpkgs = array();
108 94fbf631 Colin Smith
		    if($config['installedpackages']['package'] != "")
109
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
110 b426850b Colin Smith
		    $pkg_names = array_keys($pkg_info);
111 1507bd61 Colin Smith
		    $pkg_keys = array();
112 b426850b Colin Smith
		    foreach($pkg_names as $name) {
113
			if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
114 0db271e0 Colin Smith
		    }
115 b426850b Colin Smith
		    sort($pkg_keys);
116
		    if(count($pkg_keys) != 0) {
117
		    	foreach($pkg_keys as $key) {
118
			    $index = &$pkg_info[$key];
119
			    if(in_array($index['name'], $instpkgs)) continue;
120 64b243d2 Scott Ullrich
          $dot = strpos($index['required_version'], ".");
121
          $index['major_version'] = substr($index['required_version'], 0, $dot);
122
123
          if ($version <> "HEAD" &&
124
              $index['required_version'] == "HEAD" &&
125
              $requested_version <> "other") { continue; }
126
          if (empty($index['required_version']) &&
127
                    $requested_version <> "none") { continue; }
128
          if($index['major_version'] > $major &&
129
             $requested_version <> "other") { continue; }
130
          if(isset($index['major_version']) &&
131
             $requested_version == "none") { continue; }
132
          if($index['major_version'] == $major &&
133
             $requested_version == "other") { continue; }
134
135 ee11cc6e Scott Ullrich
                            ?>
136
                            <tr valign="top">
137
                                <td class="listlr">
138 61a48553 Scott Ullrich
                                    <A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
139 ee11cc6e Scott Ullrich
                                </td>
140
                                <td class="listlr">
141 b426850b Colin Smith
                                    <?= $index['category'] ?>
142 9345a13c Colin Smith
    				</td>
143
				<?php
144 bfccf041 Colin Smith
					/*
145 3f3a5bef Colin Smith
					if(!$using_cache) {
146
						$size = get_package_install_size($index['name'], $pkg_sizes);
147
                               			$size = squash_from_bytes($size[$index['name']], 1);
148
					}
149
					if(!$size) $size = "Unknown.";
150 bfccf041 Colin Smith
					*/
151 9345a13c Colin Smith
				?>
152 bfccf041 Colin Smith
				<!--
153 9345a13c Colin Smith
				<td class="listlr">
154 3f3a5bef Colin Smith
                                 	<?= $size ?>
155
                                </td>
156 bfccf041 Colin Smith
				-->
157 9345a13c Colin Smith
				<td class="listlr">
158 3f3a5bef Colin Smith
					<?= $index['status'] ?>
159
					<br>
160
					<?= $index['version'] ?>
161 61a48553 Scott Ullrich
					<br />
162
					platform: <?= $index['required_version'] ?>
163 ee11cc6e Scott Ullrich
                                </td>
164 76341f29 Scott Ullrich
                                <td class="listlr">
165
					<?php
166
						if($index['maintainer'] != "") {
167 2c9d3735 Scott Ullrich
							echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
168 76341f29 Scott Ullrich
						} else {
169 1f546354 Scott Ullrich
							echo "Nobody. <a href='mailto:coreteam@pfsense.com'>Apply</a> for it!";
170 76341f29 Scott Ullrich
						}
171
					?>
172 5bd87465 Scott Ullrich
                                </td>
173 61a48553 Scott Ullrich
                                <td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
174 b426850b Colin Smith
                                    <?= $index['descr'] ?>
175 ee11cc6e Scott Ullrich
                                </td>
176
                                <td valign="middle" class="list" nowrap>
177 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>
178 ee11cc6e Scott Ullrich
                                </td>
179
                            </tr>
180
                            <?php
181 b426850b Colin Smith
                        }
182
		    } else {
183 bfccf041 Colin Smith
			echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
184 b426850b Colin Smith
		    }
185 3f3a5bef Colin Smith
		}
186 ee11cc6e Scott Ullrich
		?>
187
        </table>
188 d732f186 Bill Marquette
	</div>
189 ee11cc6e Scott Ullrich
    </td>
190
  </tr>
191
</table>
192
<?php include("fend.inc"); ?>
193
</body>
194
</html>