Project

General

Profile

Download (9.73 KB) Statistics
| Branch: | Tag: | Revision:
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_MODULE:	pkgs
31
*/
32

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

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

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

    
47
date_default_timezone_set($timezone);
48

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

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

    
80
$pgtitle = array(gettext("System"),gettext("Package Manager"));
81
include("head.inc");
82

    
83
?>
84
<script type="text/javascript" src="javascript/domTT/domLib.js"></script>
85
<script type="text/javascript" src="javascript/domTT/domTT.js"></script>
86
<script type="text/javascript" src="javascript/domTT/behaviour.js"></script>
87
<script type="text/javascript" src="javascript/domTT/fadomatic.js"></script>
88
<script type="text/javascript" language="javascript" src="/javascript/row_helper_dynamic.js"></script>
89
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
90
	<?php include("fbegin.inc"); ?>
91
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
92
		<tr>
93
			<td>
94
				<?php
95
					$version = file_get_contents("/etc/version");
96
					$tab_array = array();
97
					$tab_array[] = array(gettext("Available Packages"), false, "pkg_mgr.php");
98
//					$tab_array[] = array("{$version} " . gettext("packages"), false, "pkg_mgr.php");
99
//					$tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
100
//					$tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
101
					$tab_array[] = array(gettext("Installed Packages"), true, "pkg_mgr_installed.php");
102
					display_top_tabs($tab_array);
103
				?>
104
			</td>
105
		</tr>
106
		<tr>
107
			<td>
108
				<div id="mainarea">
109
					<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
110
						<tr>
111
							<td width="12%" class="listhdrr"><?=gettext("Name"); ?></td>
112
							<td width="16%" class="listhdrr"><?=gettext("Category"); ?></td>
113
							<td width="15%" class="listhdrr"><?=gettext("Version"); ?></td>
114
							<td width="53%" class="listhdr"><?=gettext("Description"); ?></td>
115
							<td width="40" >&nbsp</td>
116
						</tr>
117
						<?php
118
							if(is_array($config['installedpackages']['package'])):
119

    
120
								$instpkgs = array();
121
								foreach($config['installedpackages']['package'] as $instpkg) {
122
									$instpkgs[] = $instpkg['name'];
123
								}
124
								natcasesort($instpkgs);
125

    
126
								foreach ($instpkgs as $index => $pkgname):
127

    
128
									$pkg = $config['installedpackages']['package'][$index];
129
									if(!$pkg['name'])
130
										continue;
131

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