Projet

Général

Profil

Télécharger (10,9 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / pkg_mgr.php @ fab1cd2f

1
<?php
2
/* $Id$ */
3
/*
4
	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
*/
31
/*
32
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
33
	pfSense_MODULE:	pkgs
34
*/
35

    
36
##|+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
ini_set('max_execution_time', '0');
44

    
45
require_once("globals.inc");
46
require_once("guiconfig.inc");
47
require_once("pkg-utils.inc");
48

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

    
53
date_default_timezone_set($timezone);
54

    
55
/* 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
function domTT_title($title_msg) {
68
	if (!empty($title_msg)) {
69
		$title_msg=preg_replace("/\s+/"," ",$title_msg);
70
		$title_msg=preg_replace("/'/","\'",$title_msg);
71
		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
//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
$xmlrpc_base_url = get_active_xml_rpc_base_url();
78
if (!file_exists("{$g['tmp_path']}/pkg_info.cache") || (time() - filemtime("{$g['tmp_path']}/pkg_info.cache")) > $pkg_cache_file_time) {
79
	$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
80
	//create cache file after get_pkg_info
81
	if($pkg_info) {
82
		$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
83
		fwrite($fout, serialize($pkg_info));
84
		fclose($fout);
85
		//$pkg_sizes = get_pkg_sizes();
86
	} else {
87
		$using_cache = true;
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
	}
95
} else {
96
	$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
97
}
98

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

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

    
107
?>
108
<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
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
113
</head>
114

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

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

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

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

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

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

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

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

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

    
209
					if (package_skip_tests($index,$requested_version))
210
						continue;
211

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

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

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

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

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

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