Project

General

Profile

Download (11.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	pkg_mgr.php
5
        Copyright (C) 2013-2014 Electric Sheep Fencing, LP
6
	Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
7
	Copyright (C) 2013 Marcello Coutinho
8
        Copyright (C) 2013-2014 Electric Sheep Fencing, LP
9

    
10
	All rights reserved.
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17

    
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
/*
34
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
35
	pfSense_MODULE:	pkgs
36
*/
37

    
38
##|+PRIV
39
##|*IDENT=page-system-packagemanager
40
##|*NAME=System: Package Manager page
41
##|*DESCR=Allow access to the 'System: Package Manager' page.
42
##|*MATCH=pkg_mgr.php*
43
##|-PRIV
44

    
45
ini_set('max_execution_time', '0');
46

    
47
require_once("globals.inc");
48
require_once("guiconfig.inc");
49
require_once("pkg-utils.inc");
50

    
51
$timezone = $config['system']['timezone'];
52
if (!$timezone)
53
	$timezone = "Etc/UTC";
54

    
55
date_default_timezone_set($timezone);
56

    
57
/* if upgrade in progress, alert user */
58
if(is_subsystem_dirty('packagelock')) {
59
	$pgtitle = array(gettext("System"),gettext("Package Manager"));
60
	include("head.inc");
61
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
62
	include("fbegin.inc");
63
	echo "Please wait while packages are reinstalled in the background.";
64
	include("fend.inc");
65
	echo "</body>";
66
	echo "</html>";
67
	exit;
68
}
69
function domTT_title($title_msg) {
70
	if (!empty($title_msg)) {
71
		$title_msg=preg_replace("/\s+/"," ",$title_msg);
72
		$title_msg=preg_replace("/'/","\'",$title_msg);
73
		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');\"";
74
	}
75
}
76
//get_pkg_info only if cache file has more then $g[min_pkg_cache_file_time] seconds
77
$pkg_cache_file_time=($g['min_pkg_cache_file_time'] ? $g['min_pkg_cache_file_time'] : 120);
78

    
79
$xmlrpc_base_url = get_active_xml_rpc_base_url();
80
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
81
	$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
82
	//create cache file after get_pkg_info
83
	if($pkg_info) {
84
		$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
85
		fwrite($fout, serialize($pkg_info));
86
		fclose($fout);
87
		//$pkg_sizes = get_pkg_sizes();
88
	} else {
89
		$using_cache = true;
90
		if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
91
			$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
92
			$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
93
		} else {
94
			$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']);
95
		}
96
	}
97
} else {
98
	$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
99
}
100

    
101
if (! empty($_GET))
102
	if (isset($_GET['ver']))
103
		$requested_version = htmlspecialchars($_GET['ver']);
104

    
105
$closehead = false;
106
$pgtitle = array(gettext("System"),gettext("Package Manager"));
107
include("head.inc");
108

    
109
?>
110
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
111
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
112
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
113
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
114
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
115
</head>
116

    
117
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
118
<?php
119
	include("fbegin.inc");
120

    
121
	/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
122
	if (!verify_all_package_servers())
123
		print_info_box(package_server_mismatch_message());
124

    
125
	/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
126
	if (check_package_server_ssl() === false)
127
		print_info_box(package_server_ssl_failure_message());
128

    
129
	if ($savemsg)
130
		print_info_box($savemsg);
131
?>
132
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
133
	<tr><td>
134
<?php
135
	$version = rtrim(file_get_contents("/etc/version"));
136

    
137
	$tab_array = array();
138
	$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
139
	$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
140
	display_top_tabs($tab_array);
141
?>
142
	</td></tr>
143
	<tr><td>
144
<?php
145
	$version = rtrim(file_get_contents("/etc/version"));
146
	if($pkg_info) {
147
		$pkg_keys = array_keys($pkg_info);
148
		natcasesort($pkg_keys);
149

    
150
		//Check categories
151
		$categories=array();
152
		if(is_array($pkg_keys)) {
153
			foreach($pkg_keys as $key) {
154
				if (!package_skip_tests($pkg_info[$key],$requested_version))
155
					$categories[$pkg_info[$key]['category']]++;
156
				}
157
			}
158
		ksort($categories);
159
		$cm_count=0;
160
		$tab_array = array();
161
		$visible_categories=array();
162
		$categories_min_count=($g['pkg_categories_min_count'] ? $g['pkg_categories_min_count'] : 3);
163
		$categories_max_display=($g['pkg_categories_max_display'] ? $g['pkg_categories_max_display'] : 6);
164

    
165
		/* check selected category or define default category to show */
166
		if (isset($_REQUEST['category']))
167
			$menu_category = $_REQUEST['category'];
168
		else if (isset($g['pkg_default_category']))
169
			$menu_category = $g['pkg_default_category'];
170
		else
171
			$menu_category = "All";
172

    
173
		$menu_category = (isset($_REQUEST['category']) ? $_REQUEST['category'] : "All");
174
		$show_category = ($menu_category == "Other" || $menu_category == "All");
175

    
176
		$tab_array[] = array(gettext("All"), $menu_category=="All" ? true : false, "pkg_mgr.php?category=All");
177
		foreach ($categories as $category => $c_count) {
178
			if ($c_count >= $categories_min_count && $cm_count <= $categories_max_display) {
179
				$tab_array[] = array(gettext($category) , $menu_category==$category ? true : false, "pkg_mgr.php?category={$category}");
180
				$visible_categories[]=$category;
181
				$cm_count++;
182
			}
183
		}
184
		$tab_array[] = array(gettext("Other Categories"), $menu_category=="Other" ? true : false, "pkg_mgr.php?category=Other");
185
		if (count($categories) > 1)
186
			display_top_tabs($tab_array);
187
	}
188
?>
189
	</td></tr>
190
	<tr><td>
191
	<div id="mainarea">
192
		<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
193
		<tr><td width="10%" class="listhdrr"><?=gettext("Name"); ?></td>
194
<?php
195
		if ($show_category)
196
			print '<td width="18%" class="listhdr">'.gettext("Category").'</td>'."\n";
197
?>
198
		<td width="<?php print $show_category ? "15%" : "20%"; ?>" class="listhdr"><?=gettext("Status"); ?></td>
199
		<td width="<?php print $show_category ? "58%" : "70%"; ?>" class="listhdr"><?=gettext("Description"); ?></td>
200
		<td width="17">&nbsp;</td></tr>
201
<?php
202
		if(!$pkg_info) {
203
			echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
204
		} else {
205
			if(is_array($pkg_keys)) {
206
				foreach($pkg_keys as $key):
207
					$index = &$pkg_info[$key];
208
					if(get_pkg_id($index['name']) >= 0 )
209
						continue;
210

    
211
					if (package_skip_tests($index,$requested_version))
212
						continue;
213

    
214
					/* get history/changelog git dir */
215
					$commit_dir=explode("/",$index['config_file']);
216
					$changeloglink = "https://github.com/pfsense/pfsense-packages/commits/master/config/";
217
					if ($commit_dir[(count($commit_dir)-2)] == "config")
218
						$changeloglink .= $commit_dir[(count($commit_dir)-1)];
219
					else
220
						$changeloglink .= $commit_dir[(count($commit_dir)-2)];
221

    
222
					/* Check package info link */
223
					if($index['pkginfolink']) {
224
						$pkginfolink = $index['pkginfolink'];
225
						$pkginfo=gettext("Package info");
226
					} else {
227
						$pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
228
						$pkginfo=gettext("No package info, check the forum");
229
					}
230

    
231
					if ($menu_category == "All" || $index['category'] == $menu_category || ($menu_category == "Other" && !in_array($index['category'],$visible_categories)) ):
232
?>
233
						<tr valign="top" class="<?= $index['category'] ?>">
234
						<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
235
							<a target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
236
						</td>
237
<?php
238
						if ($show_category)
239
							print '<td class="listr">'.gettext($index['category']).'</td>'."\n";
240

    
241
						if ($g['disablepackagehistory']) {
242
							print '<td class="listr">'."\n";
243
						} else {
244
							print '<td class="listr" ';
245
							domTT_title(gettext("Click ").ucfirst($index['name']).gettext(" version to check its change log."));
246
							print ">\n";
247
						}
248

    
249
						print "{$index['status']} <br />\n";
250

    
251
						if ($g['disablepackagehistory'])
252
							echo"<a>{$index['version']}</a>";
253
						else
254
							echo "<a target='_blank' href='{$changeloglink}'>{$index['version']}</a>";
255
?>
256
						<br />
257
						<?=gettext("platform") .": ". $index['required_version'] ?>
258
						<br />
259
						<?=$index['maximum_version'] ?>
260
						</td>
261
						<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($index['name'])." package."))?>>
262
						<?= $index['descr'] ?>
263
<?php
264
						if (! $g['disablepackageinfo']):
265
?>
266
							<br /><br />
267
							<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
268
<?php
269
						endif;
270
?>
271
						</td>
272
						<td valign="middle" class="list nowrap" width="17">
273
							<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>
274
						</td></tr>
275
<?php
276
					endif;
277
				endforeach;
278
			} else {
279
				echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
280
			} /* if(is_array($pkg_keys)) */
281
		} /* if(!$pkg_info) */
282
?>
283
		</table>
284
	</div>
285
	</td></tr>
286
</table>
287
<?php include("fend.inc"); ?>
288
</body>
289
</html>
(132-132/256)