Project

General

Profile

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