Project

General

Profile

Download (7.51 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("guiconfig.inc");
31
require_once("pkg-utils.inc");
32

    
33
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version', 'pkginfolink'));
34
if($pkg_info) {
35
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
36
	fwrite($fout, serialize($pkg_info));
37
	fclose($fout);
38
    //$pkg_sizes = get_pkg_sizes();
39
} else {
40
	$using_cache = true;
41
	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 {$g['product_name']}.com.  Please check DNS, default gateway, etc.";
46
	}
47
}
48

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

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

    
58
?>
59

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

    
68
?>
69

    
70
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
71
<?php
72
	$version = file_get_contents("/etc/version");
73
  $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
	$tab_array = array();
80
	$tab_array[] = array("{$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
	$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
84
	display_top_tabs($tab_array);
85
?>
86
  </td></tr>
87
  <tr>
88
    <td>
89
	<div id="mainarea">
90
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
91
                <tr>
92
                  <td width="10%" class="listhdrr">Package Name</td>
93
                  <td width="25%" class="listhdrr">Category</td>
94
<!--
95
		  <td width="10%" class="listhdrr">Size</td>
96
-->
97
		  <td width="5%" class="listhdrr">Status</td>
98
		  <td width="5%" class="listhdrr">Package Info</td>
99
                  <td width="50%" class="listhdr">Description</td>
100
                </tr>
101

    
102
		<?php
103
		 if(!$pkg_info) {
104
			echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
105
		 } else {
106
			$pfSense_installed_version = rtrim(file_get_contents("/etc/version"));
107
		 	$pkgs = array();
108
		 	$instpkgs = array();
109
		    if($config['installedpackages']['package'] != "")
110
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
111
		    $pkg_names = array_keys($pkg_info);
112
		    $pkg_keys = array();
113
		    foreach($pkg_names as $name) {
114
				if(!in_array($name, $instpkgs)) 
115
					$pkg_keys[] = $name;
116
		    }
117
		    sort($pkg_keys);
118
		    if(count($pkg_keys) != 0) {
119
		    	foreach($pkg_keys as $key) {
120
			    $index = &$pkg_info[$key];
121
			    if(in_array($index['name'], $instpkgs)) continue;
122
          		$dot = strpos($index['required_version'], ".");
123
          		$index['major_version'] = substr($index['required_version'], 0, $dot);
124

    
125
          		if ($version <> "HEAD" &&
126
              		$index['required_version'] == "HEAD" &&
127
              		$requested_version <> "other") { continue; }
128
          		if (empty($index['required_version']) &&
129
                    $requested_version <> "none") { continue; }
130
          		if($index['major_version'] > $major &&
131
             		$requested_version <> "other") { continue; }
132
          		if(isset($index['major_version']) &&
133
					$requested_version == "none") { continue; }
134
          		if($index['major_version'] == $major &&
135
             		$requested_version == "other") { continue; }
136

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