Projet

Général

Profil

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

univnautes / usr / local / www / pkg_mgr.php @ 7e736f38

1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr.php
5
    Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
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
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
31
	pfSense_MODULE:	pkgs
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-system-packagemanager
36
##|*NAME=System: Package Manager page
37
##|*DESCR=Allow access to the 'System: Package Manager' page.
38
##|*MATCH=pkg_mgr.php*
39
##|-PRIV
40

    
41
ini_set('max_execution_time', '0');
42

    
43
require_once("globals.inc");
44
require_once("guiconfig.inc");
45
require_once("pkg-utils.inc");
46

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

    
51
date_default_timezone_set($timezone);
52

    
53
/* if upgrade in progress, alert user */
54
if(is_subsystem_dirty('packagelock')) {
55
	$pgtitle = array(gettext("System"),gettext("Package Manager"));
56
	include("head.inc");
57
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
58
	include("fbegin.inc");
59
	echo "Please wait while packages are reinstalled in the background.";
60
	include("fend.inc");
61
	echo "</body>";
62
	echo "</html>";
63
	exit;
64
}
65
function domTT_title($title_msg){
66
	if (!empty($title_msg)){
67
		$title_msg=preg_replace("/\s+/"," ",$title_msg);
68
        $title_msg=preg_replace("/'/","\'",$title_msg);
69
		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');\"";
70
	}
71
}
72
$pkg_info = get_pkg_info('all', array("noembedded", "name", "category", "website", "version", "status", "descr", "maintainer", "required_version", "maximum_version", "pkginfolink", "config_file"));
73
if($pkg_info) {
74
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
75
	fwrite($fout, serialize($pkg_info));
76
	fclose($fout);
77
	//$pkg_sizes = get_pkg_sizes();
78
} else {
79
	$using_cache = true;
80
	$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
81
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
82
		$savemsg = sprintf(gettext("Unable to retrieve package info from %s. Cached data will be used."), $xmlrpc_base_url);
83
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
84
	} else {
85
		$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']);
86
	}
87
}
88

    
89
if (! empty($_GET))
90
	if (isset($_GET['ver']))
91
		$requested_version = htmlspecialchars($_GET['ver']);
92

    
93
$closehead = false;
94
$pgtitle = array(gettext("System"),gettext("Package Manager"));
95
include("head.inc");
96

    
97
?>
98
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
99
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
100
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
101
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
102
<script type="text/javascript" language="javascript" src="/javascript/row_helper_dynamic.js"></script>
103
</head>
104

    
105
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106
<?php
107
	include("fbegin.inc");
108
	if ($savemsg)
109
		print_info_box($savemsg);
110
?>
111
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="package manager">
112
	<tr>
113
		<td>
114
		<?php
115
			$version = rtrim(file_get_contents("/etc/version"));
116

    
117
			$tab_array = array();
118
			$tab_array[] = array(gettext("Available Packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
119
//			$tab_array[] = array($version . gettext("packages"), $requested_version <> "" ? false : true, "pkg_mgr.php");
120
//			$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
121
//			$tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
122
			$tab_array[] = array(gettext("Installed Packages"), false, "pkg_mgr_installed.php");
123
			display_top_tabs($tab_array);
124
		?>
125
		</td>
126
	</tr>
127
	<tr>
128
		<td>
129
			<div id="mainarea">
130
				<table class="tabcont sortable" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
131
					<tr>
132
						<td width="12%" class="listhdrr"><?=gettext("Name"); ?></td>
133
						<td width="18%" class="listhdrr"><?=gettext("Category"); ?></td>
134
						<td width="15%" class="listhdrr"><?=gettext("Status"); ?></td>
135
						<td width="53%" class="listhdr"><?=gettext("Description"); ?></td>
136
						<td width="17">&nbsp;</td>
137
					</tr>
138
					<?php
139
						if(!$pkg_info) {
140
							echo "<tr><td colspan=\"5\"><center>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
141
						} else {
142
							$pkgs = array();
143
							$instpkgs = array();
144
							if($config['installedpackages']['package'] != "")
145
								foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
146
									$pkg_names = array_keys($pkg_info);
147
							$pkg_keys = array();
148
							
149
							foreach($pkg_names as $name)
150
								if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
151
							$pkg_keys = msort($pkg_keys);
152
							if(count($pkg_keys) != 0) {
153
								foreach($pkg_keys as $key) {
154
									$index = &$pkg_info[$key];
155
									if(in_array($index['name'], $instpkgs)) 
156
										continue;
157
									if($g['platform'] == "nanobsd")
158
										if($index['noembedded']) 
159
											continue;
160
									/* If we are on not on HEAD, and the package wants it, skip */
161
									if ($version <> "HEAD" &&
162
										$index['required_version'] == "HEAD" &&
163
										$requested_version <> "other")
164
										continue;
165
									/* If there is no required version, and the requested package 
166
										version is not 'none', then skip */
167
									if (empty($index['required_version']) &&
168
										$requested_version <> "none")
169
										continue;
170
									/* If the requested version is not 'other', and the required version is newer than what we have, skip. */
171
									if($requested_version <> "other" &&
172
										(pfs_version_compare("", $version, $index['required_version']) < 0))
173
										continue;
174
									/* If the requestion version is 'other' and we are on the version requested, skip. */
175
									if($requested_version == "other" &&
176
										(pfs_version_compare("", $version, $index['required_version']) == 0))
177
										continue;
178
									/* Package is only for an older version, lets skip */
179
									if($index['maximum_version'] &&
180
										(pfs_version_compare("", $version, $index['maximum_version']) > 0))
181
										continue;
182
									/* get history/changelog git dir */
183
									$commit_dir=explode("/",$index['config_file']);
184
									$changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)];
185
									/* Check package info link */
186
									if($index['pkginfolink']){
187
										$pkginfolink = $index['pkginfolink'];
188
										$pkginfo=gettext("Package info");
189
										}
190
									else{
191
										$pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
192
										$pkginfo=gettext("No package info, check the forum");
193
										}
194
					?>
195
					<tr valign="top">
196
						<td class="listlr" <?=domTT_title(gettext("Click on package name to access its website."))?>>
197
							<a target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
198
						</td>
199
						<td class="listr">
200
							<?= $index['category'] ?>
201
						</td>
202
						<?php
203
							/*
204
							if(!$using_cache) {
205
								$size = get_package_install_size($index['name'], $pkg_sizes);
206
								$size = squash_from_bytes($size[$index['name']], 1);
207
							}
208
							if(!$size)
209
								$size = "Unknown.";
210
							*/
211
						?>
212
<!--
213
						<td class="listr">
214
							<?= $size ?>
215
						</td>
216
-->
217
						<?php if ($g['disablepackagehistory']){?>
218
							<td	class="listr">
219
						<?php }else{?>
220
							<td class="listr" <?=domTT_title(gettext("Click ".ucfirst($index['name'])." version to check its change log."))?>>
221
						<?php }?>
222
						<?=$index['status'] ?>
223
						<br/>
224
						<?php
225
						if ($g['disablepackagehistory'])
226
							echo"<a>{$index['version']}</a>";
227
						else
228
							echo "<a target='_blank' href='{$changeloglink}'>{$index['version']}</a>";
229
						?>
230
						<br/>
231
						<?=gettext("platform") .": ". $index['required_version'] ?>
232
						<br/>
233
						<?=$index['maximum_version'] ?>
234
						</td>
235
						<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($index['name'])." package."))?>>
236
						<?= $index['descr'] ?>
237
						<?php if (! $g['disablepackageinfo']): ?>
238
						<br/><br/>
239
						<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
240
						<?php endif; ?>
241
						</td>
242
						<td valign="middle" class="list nowrap" width="17">
243
							<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>
244
						</td>
245
					</tr>
246
					<?php
247
								}
248
							} else {
249
								echo "<tr><td colspan='5' align='center'>" . gettext("There are currently no packages available for installation.") . "</td></tr>";
250
							}
251
						}
252
					?>
253
				</table>
254
			</div>
255
		</td>
256
	</tr>
257
</table>
258
<?php include("fend.inc"); ?>
259
</body>
260
</html>
(130-130/246)