Project

General

Profile

Download (7.63 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
6
    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
require_once("globals.inc");
31
require_once("guiconfig.inc");
32
require_once("pkg-utils.inc");
33

    
34
$pkg_info = get_pkg_info('all', array('noembedded', 'name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version', 'pkginfolink'));
35
if($pkg_info) {
36
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
37
	fwrite($fout, serialize($pkg_info));
38
	fclose($fout);
39
    //$pkg_sizes = get_pkg_sizes();
40
} else {
41
	$using_cache = true;
42
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
43
	    $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
44
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
45
	} else {
46
		$savemsg = "Unable to communicate to {$g['product_name']}.com.  Please check DNS, default gateway, etc.";
47
	}
48
}
49

    
50
if (! empty($_GET)) {
51
  if (isset($_GET['ver'])) {
52
    $requested_version = htmlspecialchars($_GET['ver']);
53
  }
54
}
55

    
56
$pgtitle = "System: Package Manager";
57
include("head.inc");
58

    
59
?>
60

    
61
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
62
<?php
63
include("fbegin.inc");
64
?>
65
<p class="pgtitle"><?=$pgtitle?></p>
66
<?php if ($savemsg) print_info_box($savemsg); ?>
67
<?php
68

    
69
?>
70

    
71
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
72
<?php
73
	$version = file_get_contents("/etc/version");
74
  $dot = strpos($version, ".");
75
  $hyphen = strpos($version, "-");
76
  $major = substr($version, 0, $dot);
77
  $minor = substr($version, $dot + 1, $hyphen - $dot - 1);
78
  $testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
79

    
80
	$tab_array = array();
81
	$tab_array[] = array("{$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
82
//	$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
83
/*  $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
84
	$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
85
	display_top_tabs($tab_array);
86
?>
87
  </td></tr>
88
  <tr>
89
    <td>
90
	<div id="mainarea">
91
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
92
                <tr>
93
                  <td width="10%" class="listhdrr">Package Name</td>
94
                  <td width="25%" class="listhdrr">Category</td>
95
<!--
96
		  <td width="10%" class="listhdrr">Size</td>
97
-->
98
		  <td width="5%" class="listhdrr">Status</td>
99
		  <td width="5%" class="listhdrr">Package Info</td>
100
                  <td width="50%" class="listhdr">Description</td>
101
                </tr>
102

    
103
		<?php
104
		 if(!$pkg_info) {
105
			echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
106
		 } else {
107
			$pfSense_installed_version = rtrim(file_get_contents("/etc/version"));
108
		 	$pkgs = array();
109
		 	$instpkgs = array();
110
		    if($config['installedpackages']['package'] != "")
111
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
112
		    $pkg_names = array_keys($pkg_info);
113
		    $pkg_keys = array();
114
		    foreach($pkg_names as $name) {
115
				if(!in_array($name, $instpkgs)) 
116
					$pkg_keys[] = $name;
117
		    }
118
		    sort($pkg_keys);
119
		    if(count($pkg_keys) != 0) {
120
		    	foreach($pkg_keys as $key) {
121
			    $index = &$pkg_info[$key];
122
			    if(in_array($index['name'], $instpkgs)) continue;
123
          		$dot = strpos($index['required_version'], ".");
124
          		$index['major_version'] = substr($index['required_version'], 0, $dot);
125
				if($g['platform'] == "nanobsd") 
126
					if($index['noembedded']) 
127
						continue;
128
          		if ($version <> "HEAD" &&
129
              		$index['required_version'] == "HEAD" &&
130
              		$requested_version <> "other") { continue; }
131
          		if (empty($index['required_version']) &&
132
                    $requested_version <> "none") { continue; }
133
          		if($index['major_version'] > $major &&
134
             		$requested_version <> "other") { continue; }
135
          		if(isset($index['major_version']) &&
136
					$requested_version == "none") { continue; }
137
          		if($index['major_version'] == $major &&
138
             		$requested_version == "other") { continue; }
139

    
140
			?>
141
                            <tr valign="top">
142
                                <td class="listlr">
143
                                    <A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
144
                                </td>
145
                                <td class="listlr">
146
                                    <?= $index['category'] ?>
147
    				</td>
148
				<?php
149
					/*
150
					if(!$using_cache) {
151
						$size = get_package_install_size($index['name'], $pkg_sizes);
152
                               			$size = squash_from_bytes($size[$index['name']], 1);
153
					}
154
					if(!$size) $size = "Unknown.";
155
					*/
156
				?>
157
				<!--
158
				<td class="listlr">
159
                                 	<?= $size ?>
160
                                </td>
161
				-->
162
				<td class="listlr">
163
					<?= $index['status'] ?>
164
					<br>
165
					<?= $index['version'] ?>
166
					<br />
167
					platform: <?= $index['required_version'] ?>
168
                                </td>
169
				<td class="listlr">
170
				<?php
171
				if($index['pkginfolink']) {
172
                                        $pkginfolink = $index['pkginfolink'];
173
					echo "<a target='_new' href='$pkginfolink'>Package Info</a>";
174
				} else {
175
					echo "No info, check the <a href='http://forum.pfsense.org/index.php/board,15.0.html'>forum</a>";
176
				}
177
                                ?>
178
				</td>
179
                                <td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
180
                                    <?= $index['descr'] ?>
181
                                </td>
182
                                <td valign="middle" class="list" nowrap>
183
                                    <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>
184
                                </td>
185
                            </tr>
186
                            <?php
187
                        }
188
		    } else {
189
			echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
190
		    }
191
		}
192
		?>
193
        </table>
194
	</div>
195
    </td>
196
  </tr>
197
</table>
198
<?php include("fend.inc"); ?>
199
</body>
200
</html>
(93-93/176)