Project

General

Profile

Download (11 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4 29840546 Renato Botelho
	pkg_mgr.php
5 d4b2cd35 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6 29840546 Renato Botelho
	Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
7
	Copyright (C) 2013 Marcello Coutinho
8
9
	All rights reserved.
10
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31 ee11cc6e Scott Ullrich
*/
32 1d333258 Scott Ullrich
/*
33
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
34
	pfSense_MODULE:	pkgs
35
*/
36 ee11cc6e Scott Ullrich
37 6b07c15a Matthew Grooms
##|+PRIV
38
##|*IDENT=page-system-packagemanager
39
##|*NAME=System: Package Manager page
40
##|*DESCR=Allow access to the 'System: Package Manager' page.
41
##|*MATCH=pkg_mgr.php*
42
##|-PRIV
43
44 0089af7c Scott Ullrich
ini_set('max_execution_time', '0');
45
46 9bcf197e Scott Ullrich
require_once("globals.inc");
47 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
48 f8e335a3 Scott Ullrich
require_once("pkg-utils.inc");
49 ee11cc6e Scott Ullrich
50 c8083ee2 Phil Davis
$timezone = $config['system']['timezone'];
51 943994ff Scott Ullrich
if (!$timezone)
52
	$timezone = "Etc/UTC";
53
54
date_default_timezone_set($timezone);
55
56 261c7de8 jim-p
/* if upgrade in progress, alert user */
57
if(is_subsystem_dirty('packagelock')) {
58
	$pgtitle = array(gettext("System"),gettext("Package Manager"));
59
	include("head.inc");
60
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
61
	include("fbegin.inc");
62
	echo "Please wait while packages are reinstalled in the background.";
63
	include("fend.inc");
64
	echo "</body>";
65
	echo "</html>";
66
	exit;
67
}
68 29840546 Renato Botelho
function domTT_title($title_msg) {
69
	if (!empty($title_msg)) {
70 36d82968 Marcello Coutinho
		$title_msg=preg_replace("/\s+/"," ",$title_msg);
71 29840546 Renato Botelho
		$title_msg=preg_replace("/'/","\'",$title_msg);
72 36d82968 Marcello Coutinho
		echo "onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\" onmouseover=\"domTT_activate(this, event, 'content', '{$title_msg}', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\"";
73
	}
74
}
75 9b4df982 marcelloc
//get_pkg_info only if cache file has more then $g[min_pkg_cache_file_time] seconds
76
$pkg_cache_file_time=($g['min_pkg_cache_file_time'] ? $g['min_pkg_cache_file_time'] : 120);
77
78 7c8f3711 jim-p
$xmlrpc_base_url = get_active_xml_rpc_base_url();
79 29840546 Renato Botelho
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
80 6dc2a349 Chris Buechler
	$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
81 29840546 Renato Botelho
	//create cache file after get_pkg_info
82 9b4df982 marcelloc
	if($pkg_info) {
83
		$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
84
		fwrite($fout, serialize($pkg_info));
85
		fclose($fout);
86
		//$pkg_sizes = get_pkg_sizes();
87 29840546 Renato Botelho
	} else {
88 9b4df982 marcelloc
		$using_cache = true;
89
		if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
90
			$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
91
			$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
92
		} else {
93
			$savemsg = sprintf(gettext('Unable to communicate with %1$s. Please verify DNS and interface configuration, and that %2$s has functional Internet connectivity.'), $xmlrpc_base_url, $g['product_name']);
94
		}
95 47c44d0a Scott Ullrich
	}
96 29840546 Renato Botelho
} else {
97
	$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
98
}
99 52380979 Scott Ullrich
100 d591e2e1 Matthew Grooms
if (! empty($_GET))
101
	if (isset($_GET['ver']))
102
		$requested_version = htmlspecialchars($_GET['ver']);
103 61a48553 Scott Ullrich
104 bf5b29ec Colin Fleming
$closehead = false;
105 82b15b70 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Package Manager"));
106 52380979 Scott Ullrich
include("head.inc");
107
108 ee11cc6e Scott Ullrich
?>
109 36d82968 Marcello Coutinho
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
110
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
111
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
112
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
113 07130afe ayvis
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
114 bf5b29ec Colin Fleming
</head>
115
116 ee11cc6e Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
117 859329c8 Scott Ullrich
<?php
118 d591e2e1 Matthew Grooms
	include("fbegin.inc");
119 c55dfc4a jim-p
120 7c8f3711 jim-p
	/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
121 c55dfc4a jim-p
	if (!verify_all_package_servers())
122 7c8f3711 jim-p
		print_info_box(package_server_mismatch_message());
123 c55dfc4a jim-p
124 6916360e jim-p
	/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
125
	if (check_package_server_ssl() === false)
126
		print_info_box(package_server_ssl_failure_message());
127
128 d591e2e1 Matthew Grooms
	if ($savemsg)
129
		print_info_box($savemsg);
130 5bd87465 Scott Ullrich
?>
131 bf5b29ec Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
132 9b4df982 marcelloc
	<tr><td>
133 f70121be Renato Botelho
<?php
134 9b4df982 marcelloc
	$version = rtrim(file_get_contents("/etc/version"));
135 d591e2e1 Matthew Grooms
136 9b4df982 marcelloc
	$tab_array = array();
137
	$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
138
	$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
139
	display_top_tabs($tab_array);
140 f70121be Renato Botelho
?>
141 9b4df982 marcelloc
	</td></tr>
142
	<tr><td>
143 f70121be Renato Botelho
<?php
144 9b4df982 marcelloc
	$version = rtrim(file_get_contents("/etc/version"));
145
	if($pkg_info) {
146
		$pkg_keys = array_keys($pkg_info);
147
		natcasesort($pkg_keys);
148 29840546 Renato Botelho
149 9b4df982 marcelloc
		//Check categories
150
		$categories=array();
151
		if(is_array($pkg_keys)) {
152 29840546 Renato Botelho
			foreach($pkg_keys as $key) {
153 9b4df982 marcelloc
				if (!package_skip_tests($pkg_info[$key],$requested_version))
154
					$categories[$pkg_info[$key]['category']]++;
155
				}
156
			}
157
		ksort($categories);
158
		$cm_count=0;
159
		$tab_array = array();
160
		$visible_categories=array();
161 f70121be Renato Botelho
		$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
162
		$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
163 29840546 Renato Botelho
164 f70121be Renato Botelho
		/* check selected category or define default category to show */
165
		if (isset($_REQUEST['category']))
166
			$menu_category = $_REQUEST['category'];
167
		else if (isset($g['pkg_default_category']))
168
			$menu_category = $g['pkg_default_category'];
169
		else
170
			$menu_category = "All";
171
172
		$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
173
		$show_category = ($menu_category == "Other" || $menu_category == "All");
174 29840546 Renato Botelho
175 f70121be Renato Botelho
		$tab_array[] = array(gettext("All"), $menu_category=="All" ? true : false, "pkg_mgr.php?category=All");
176 29840546 Renato Botelho
		foreach ($categories as $category => $c_count) {
177
			if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
178 9b4df982 marcelloc
				$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
179
				$visible_categories[]=$category;
180
				$cm_count++;
181
			}
182 f70121be Renato Botelho
		}
183 9b4df982 marcelloc
		$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
184
		if (count($categories) > 1)
185 d591e2e1 Matthew Grooms
			display_top_tabs($tab_array);
186 f70121be Renato Botelho
	}
187
?>
188 9b4df982 marcelloc
	</td></tr>
189
	<tr><td>
190
	<div id="mainarea">
191
		<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
192 f70121be Renato Botelho
		<tr><td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
193
<?php
194
		if ($show_category)
195
			print '<td width="18%" class="listhdr">'.gettext("Category").'</td>'."\n";
196
?>
197
		<td width="<?php print $show_category ? "15%" : "20%"; ?>" class="listhdr"><?=gettext("Status"); ?></td>
198
		<td width="<?php print $show_category ? "58%" : "70%"; ?>" class="listhdr"><?=gettext("Description"); ?></td>
199 9b4df982 marcelloc
		<td width="17">&nbsp;</td></tr>
200 f70121be Renato Botelho
<?php
201 9b4df982 marcelloc
		if(!$pkg_info) {
202
			echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
203
		} else {
204
			if(is_array($pkg_keys)) {
205 f70121be Renato Botelho
				foreach($pkg_keys as $key):
206 9b4df982 marcelloc
					$index = &$pkg_info[$key];
207
					if(get_pkg_id($index['name']) >= 0 )
208
						continue;
209 29840546 Renato Botelho
210 9b4df982 marcelloc
					if (package_skip_tests($index,$requested_version))
211
						continue;
212 29840546 Renato Botelho
213 9b4df982 marcelloc
					/* get history/changelog git dir */
214
					$commit_dir=explode("/",$index['config_file']);
215 aed5ba4e Renato Botelho
					$changeloglink = "https://github.com/pfsense/pfsense-packages/commits/master/config/";
216
					if ($commit_dir[(count($commit_dir)-2)] == "config")
217
						$changeloglink .= $commit_dir[(count($commit_dir)-1)];
218
					else
219
						$changeloglink .= $commit_dir[(count($commit_dir)-2)];
220 9b4df982 marcelloc
221
					/* Check package info link */
222 29840546 Renato Botelho
					if($index['pkginfolink']) {
223 9b4df982 marcelloc
						$pkginfolink = $index['pkginfolink'];
224
						$pkginfo=gettext("Package info");
225 29840546 Renato Botelho
					} else {
226 e1a456e6 Chris Buechler
						$pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
227 9b4df982 marcelloc
						$pkginfo=gettext("No package info, check the forum");
228 29840546 Renato Botelho
					}
229 f70121be Renato Botelho
230
					if ($menu_category == "All" || $index['category'] == $menu_category || ($menu_category == "Other" && !in_array($index['category'],$visible_categories)) ):
231
?>
232 9b4df982 marcelloc
						<tr valign="top" class="<?= $index['category'] ?>">
233 eb004d5d Chris Buechler
						<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
234 bf5b29ec Colin Fleming
							<a target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
235 d591e2e1 Matthew Grooms
						</td>
236 f70121be Renato Botelho
<?php
237
						if ($show_category)
238
							print '<td class="listr">'.gettext($index['category']).'</td>'."\n";
239 9b4df982 marcelloc
240 29840546 Renato Botelho
						if ($g['disablepackagehistory']) {
241 9b4df982 marcelloc
							print '<td class="listr">'."\n";
242 29840546 Renato Botelho
						} else {
243
							print '<td class="listr" ';
244 9b4df982 marcelloc
							domTT_title(gettext("Click ").ucfirst($index['name']).gettext(" version to check its change log."));
245
							print ">\n";
246 29840546 Renato Botelho
						}
247 9b4df982 marcelloc
248 8cd558b6 ayvis
						print "{$index['status']} <br />\n";
249 29840546 Renato Botelho
250 9a19c316 jim-p
						if ($g['disablepackagehistory'])
251 36d82968 Marcello Coutinho
							echo"<a>{$index['version']}</a>";
252
						else
253 bf5b29ec Colin Fleming
							echo "<a target='_blank' href='{$changeloglink}'>{$index['version']}</a>";
254 f70121be Renato Botelho
?>
255 8cd558b6 ayvis
						<br />
256 36d82968 Marcello Coutinho
						<?=gettext("platform") .": ". $index['required_version'] ?>
257 8cd558b6 ayvis
						<br />
258 36d82968 Marcello Coutinho
						<?=$index['maximum_version'] ?>
259 d591e2e1 Matthew Grooms
						</td>
260 36d82968 Marcello Coutinho
						<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($index['name'])." package."))?>>
261 93888ad9 jim-p
						<?= $index['descr'] ?>
262 f70121be Renato Botelho
<?php
263
						if (! $g['disablepackageinfo']):
264
?>
265 8cd558b6 ayvis
							<br /><br />
266 f70121be Renato Botelho
							<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
267
<?php
268
						endif;
269
?>
270 d591e2e1 Matthew Grooms
						</td>
271 bf5b29ec Colin Fleming
						<td valign="middle" class="list nowrap" width="17">
272 3e38084b Ermal
							<a href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img <?=domTT_title(gettext("Install ".ucfirst($index['name'])." package."))?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a>
273 9b4df982 marcelloc
						</td></tr>
274 f70121be Renato Botelho
<?php
275
					endif;
276
				endforeach;
277
			} else {
278
				echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
279
			} /* if(is_array($pkg_keys)) */
280
		} /* if(!$pkg_info) */
281
?>
282 9b4df982 marcelloc
		</table>
283
	</div>
284
	</td></tr>
285 ee11cc6e Scott Ullrich
</table>
286
<?php include("fend.inc"); ?>
287
</body>
288
</html>