Project

General

Profile

Download (10.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr_installed.php
5
    Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
    Copyright (C) 2004-2012 Scott Ullrich <sullrich@gmail.com>
7
    All rights reserved.
8

    
9
    Redistribution and use in source and binary forms, with or without
10
    modification, are permitted provided that the following conditions are met:
11

    
12
    1. Redistributions of source code must retain the above copyright notice,
13
       this list of conditions and the following disclaimer.
14

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

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

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

    
41
require_once("guiconfig.inc");
42
require_once("pkg-utils.inc");
43

    
44
$timezone = $config['system']['timezone'];
45
if (!$timezone)
46
	$timezone = "Etc/UTC";
47

    
48
date_default_timezone_set($timezone);
49

    
50
/* if upgrade in progress, alert user */
51
if(is_subsystem_dirty('packagelock')) {
52
	$pgtitle = array(gettext("System"),gettext("Package Manager"));
53
	include("head.inc");
54
	echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
55
	include("fbegin.inc");
56
	echo "Please wait while packages are reinstalled in the background.";
57
	include("fend.inc");
58
	echo "</body>";
59
	echo "</html>";
60
	exit;
61
}
62

    
63
function domTT_title($title_msg, $return="echo"){
64
	if (!empty($title_msg)){
65
		$title_msg=preg_replace("/\s+/"," ",$title_msg);
66
        $title_msg=preg_replace("/'/","\'",$title_msg);
67
        $title= "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');\"";
68
        if ($return =="echo")
69
		 echo $title;
70
		else
71
		return $title;	
72
	}
73
}
74
if(is_array($config['installedpackages']['package'])) {
75
	foreach($config['installedpackages']['package'] as $instpkg) {
76
		$tocheck[] = $instpkg['name'];
77
	}
78
	$currentvers = get_pkg_info($tocheck, array('version', 'xmlver', 'pkginfolink','descr'));
79
}
80
$closehead = false;
81
$pgtitle = array(gettext("System"),gettext("Package Manager"));
82
include("head.inc");
83

    
84
?>
85
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
86
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
87
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
88
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
89
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
90
</head>
91

    
92
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
93
	<?php include("fbegin.inc"); 
94

    
95
	/* Print package server mismatch warning. See https://redmine.pfsense.org/issues/484 */
96
	if (!verify_all_package_servers())
97
		print_info_box(package_server_mismatch_message());
98

    
99
	/* Print package server SSL warning. See https://redmine.pfsense.org/issues/484 */
100
	if (check_package_server_ssl() === false)
101
		print_info_box(package_server_ssl_failure_message()); ?>
102

    
103
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="packages installed">
104
		<tr>
105
			<td>
106
				<?php
107
					$version = file_get_contents("/etc/version");
108
					$tab_array = array();
109
					$tab_array[] = array(gettext("Available Packages"), false, "pkg_mgr.php");
110
//					$tab_array[] = array("{$version} " . gettext("packages"), false, "pkg_mgr.php");
111
//					$tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
112
//					$tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
113
					$tab_array[] = array(gettext("Installed Packages"), true, "pkg_mgr_installed.php");
114
					display_top_tabs($tab_array);
115
				?>
116
			</td>
117
		</tr>
118
		<tr>
119
			<td>
120
				<div id="mainarea">
121
					<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
122
						<tr>
123
							<td width="12%" class="listhdrr"><?=gettext("Name"); ?></td>
124
							<td width="16%" class="listhdrr"><?=gettext("Category"); ?></td>
125
							<td width="15%" class="listhdrr"><?=gettext("Version"); ?></td>
126
							<td width="53%" class="listhdr"><?=gettext("Description"); ?></td>
127
							<td width="40">&nbsp;</td>
128
						</tr>
129
						<?php
130
							if(is_array($config['installedpackages']['package'])):
131

    
132
								$instpkgs = array();
133
								foreach($config['installedpackages']['package'] as $instpkg) {
134
									$instpkgs[] = $instpkg['name'];
135
								}
136
								natcasesort($instpkgs);
137

    
138
								foreach ($instpkgs as $index => $pkgname):
139

    
140
									$pkg = $config['installedpackages']['package'][$index];
141
									if(!$pkg['name'])
142
										continue;
143

    
144
									// get history/changelog git dir
145
									$commit_dir=explode("/",$pkg['config_file']);
146
									$changeloglink ="https://github.com/pfsense/pfsense-packages/commits/master/config/".$commit_dir[(count($commit_dir)-2)]; 
147
									#check package version
148
									$latest_package = $currentvers[$pkg['name']]['version'];
149
									if ($latest_package) {
150
										// we're running a newer version of the package
151
										if(strcmp($pkg['version'], $latest_package) > 0) {
152
											$tdclass = "listbggrey";
153
											if ($g['disablepackagehistory'])
154
												$pkgver  = "<a>".gettext("Available") .": ". $latest_package . "<br />";
155
											else
156
												$pkgver  = "<a target='_blank' href='$changeloglink'>".gettext("Available") .": ". $latest_package . "<br />";
157
											$pkgver .= gettext("Installed") .": ". $pkg['version']. "</a>";
158
										}
159
										// we're running an older version of the package
160
										if(strcmp($pkg['version'], $latest_package) < 0) {
161
											$tdclass = "listbg";
162
											if ($g['disablepackagehistory'])
163
												$pkgver  = "<a><font color='#ffffff'>" . gettext("Available") .": ". $latest_package . "</font><br />";
164
											else
165
												$pkgver  = "<a target='_blank' href='$changeloglink'><font color='#ffffff'>" . gettext("Available") .": ". $latest_package . "<br />";
166
											$pkgver .= gettext("Installed") .": ". $pkg['version']."</font></a>";
167
										}
168
										// we're running the current version
169
										if(!strcmp($pkg['version'], $latest_package)) {
170
											$tdclass = "listr";
171
											if ($g['disablepackagehistory'])
172
												$pkgver = "<a>{$pkg['version']}</a>";
173
											else
174
												$pkgver = "<a target='_blank' href='$changeloglink'>{$pkg['version']}</a>";
175
										}
176
										$pkgdescr = $currentvers[$pkg['name']]['descr'];
177
									} else {
178
										// unknown available package version
179
										$tdclass = "listbg";
180
										if ($g['disablepackagehistory'])
181
											$pkgver = "<a><font color='#ffffff'>" . gettext("Latest") .": ". gettext("N/A") . "</font><br />";
182
										else
183
											$pkgver = "<a target='_blank' href='$changeloglink'><font color='#ffffff'>" . gettext("Latest") .": ". gettext("N/A") . "<br />";
184
										$pkgver .= gettext("Installed") .": ". $pkg['version']."</font></a>";
185
										$pkgdescr = $pkg['descr'];
186
									}
187
									/* Check package info link */
188
									if($pkg['pkginfolink']){
189
										$pkginfolink = $pkg['pkginfolink'];
190
										$pkginfo=gettext("Package info");
191
										}
192
									else{
193
										$pkginfolink = "https://forum.pfsense.org/index.php/board,15.0.html";
194
										$pkginfo=gettext("No package info, check the forum");
195
										}
196
									
197
						?>
198
						<tr valign="top">
199
							<td class="listlr">
200
								<?=$pkg['name'];?>
201
							</td>
202
							<td class="listr">
203
								<?=$pkg['category'];?>
204
							</td>
205
							<?php 
206
							if (isset($g['disablepackagehistory']))
207
									echo "<td class='{$tdclass}'>{$pkgver}</td>";
208
							else
209
									echo "<td class='{$tdclass}' ".domTT_title(gettext("Click on ".ucfirst($pkg['name'])." version to check its change log."),"return").">{$pkgver}</td>";
210
							?>
211
							<td class="listbg" style="overflow:hidden; text-align:justify;" <?=domTT_title(gettext("Click package info for more details about ".ucfirst($pkg['name'])." package."))?>>
212
									<?=$pkgdescr;?>
213
							<?php if (! $g['disablepackageinfo']): ?>
214
							<br /><br />
215
							<a target='_blank' href='<?=$pkginfolink?>' style='align:center;color:#ffffff; filter:Glow(color=#ff0000, strength=12);'><?=$pkginfo?></a>
216
							<?php endif; ?>
217
							</td>
218
							<td valign="middle" class="list nowrap">
219
								<a href="pkg_mgr_install.php?mode=delete&amp;pkg=<?= $pkg['name']; ?>">
220
									<img <?=domTT_title(gettext("Remove ".ucfirst($pkg['name'])." package."))?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" />
221
								</a>
222
								<br />
223
								<a href="pkg_mgr_install.php?mode=reinstallpkg&amp;pkg=<?= $pkg['name']; ?>">
224
									<img <?=domTT_title(gettext("Reinstall ".ucfirst($pkg['name'])." package."));?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_reinstall_pkg.gif" width="17" height="17" border="0" alt="reinstall" />
225
								</a>
226
								<a href="pkg_mgr_install.php?mode=reinstallxml&amp;pkg=<?= $pkg['name']; ?>">
227
									<img <?=domTT_title(gettext("Reinstall ".ucfirst($pkg['name'])."'s GUI components."));?> src="./themes/<?= $g['theme']; ?>/images/icons/icon_reinstall_xml.gif" width="17" height="17" border="0" alt="reinstall" />
228
								</a>
229
							</td>
230
						</tr>
231
						<?php
232
								endforeach;
233
							else:
234
						 ?>
235
						<tr>
236
							<td colspan="5" align="center">
237
								<?=gettext("There are no packages currently installed."); ?>
238
							</td>
239
						</tr>
240
						<?php endif; ?>
241
					</table>
242
				</div>
243
			</td>
244
		</tr>
245
	</table>
246
<?php include("fend.inc"); ?>
247
</body>
248
</html>
(134-134/256)