Project

General

Profile

Download (7.37 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg_mgr.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
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
require_once("guiconfig.inc");
31
require_once("pkg-utils.inc");
32

    
33
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr', 'maintainer', 'required_version'));
34
if($pkg_info) {
35
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
36
	fwrite($fout, serialize($pkg_info));
37
	fclose($fout);
38
    //$pkg_sizes = get_pkg_sizes();
39
} else {
40
	$using_cache = true;
41
	if(file_exists("{$g['tmp_path']}/pkg_info.cache")) {
42
	    $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
43
		$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
44
	} else {
45
		$savemsg = "Unable to communicate to pfSense.com.  Please check DNS, default gateway, etc.";
46
	}
47
}
48

    
49
if (! empty($_GET)) {
50
  if (isset($_GET['ver'])) {
51
    $requested_version = htmlspecialchars($_GET['ver']);
52
  }
53
}
54

    
55
$pgtitle = "System: Package Manager";
56
include("head.inc");
57

    
58
?>
59

    
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61
<?php
62
include("fbegin.inc");
63
?>
64
<p class="pgtitle"><?=$pgtitle?></p>
65
<?php if ($savemsg) print_info_box($savemsg); ?>
66
<?php
67

    
68
?>
69

    
70
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
71
<?php
72
	$version = file_get_contents("/etc/version");
73
  $dot = strpos($version, ".");
74
  $hyphen = strpos($version, "-");
75
  $major = substr($version, 0, $dot);
76
  $minor = substr($version, $dot + 1, $hyphen - $dot - 1);
77
  $testing_version = substr($version, $hyphen + 1, strlen($version) - $hyphen);
78

    
79
	$tab_array = array();
80
	$tab_array[] = array("Available {$version} packages", $requested_version <> "" ? false : true, "pkg_mgr.php");
81
	$tab_array[] = array("Packages for any platform", $requested_version == "none" ? true : false, "pkg_mgr.php?ver=none");
82
/*  $tab_array[] = array("Packages with a different version", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
83
	$tab_array[] = array("Installed Packages", false, "pkg_mgr_installed.php");
84
	display_top_tabs($tab_array);
85
?>
86
  </td></tr>
87
  <tr>
88
    <td>
89
	<div id="mainarea">
90
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
91
                <tr>
92
                  <td width="10%" class="listhdrr">Package Name</td>
93
                  <td width="25%" class="listhdrr">Category</td>
94
<!--
95
		  <td width="10%" class="listhdrr">Size</td>
96
-->
97
		  <td width="5%" class="listhdrr">Status</td>
98
		  <td width="5%" class="listhdrr">Maintainer</td>
99
                  <td width="50%" class="listhdr">Description</td>
100
                </tr>
101

    
102
		<?php
103
		 if(!$pkg_info) {
104
			echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
105
		 } else {
106
		 $pkgs = array();
107
		 $instpkgs = array();
108
		    if($config['installedpackages']['package'] != "")
109
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
110
		    $pkg_names = array_keys($pkg_info);
111
		    $pkg_keys = array();
112
		    foreach($pkg_names as $name) {
113
			if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
114
		    }
115
		    sort($pkg_keys);
116
		    if(count($pkg_keys) != 0) {
117
		    	foreach($pkg_keys as $key) {
118
			    $index = &$pkg_info[$key];
119
			    if(in_array($index['name'], $instpkgs)) continue;
120
          $dot = strpos($index['required_version'], ".");
121
          $index['major_version'] = substr($index['required_version'], 0, $dot);
122

    
123
          if ($version <> "HEAD" &&
124
              $index['required_version'] == "HEAD" &&
125
              $requested_version <> "other") { continue; }
126
          if (empty($index['required_version']) &&
127
                    $requested_version <> "none") { continue; }
128
          if($index['major_version'] > $major &&
129
             $requested_version <> "other") { continue; }
130
          if(isset($index['major_version']) &&
131
             $requested_version == "none") { continue; }
132
          if($index['major_version'] == $major &&
133
             $requested_version == "other") { continue; }
134

    
135
                            ?>
136
                            <tr valign="top">
137
                                <td class="listlr">
138
                                    <A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
139
                                </td>
140
                                <td class="listlr">
141
                                    <?= $index['category'] ?>
142
    				</td>
143
				<?php
144
					/*
145
					if(!$using_cache) {
146
						$size = get_package_install_size($index['name'], $pkg_sizes);
147
                               			$size = squash_from_bytes($size[$index['name']], 1);
148
					}
149
					if(!$size) $size = "Unknown.";
150
					*/
151
				?>
152
				<!--
153
				<td class="listlr">
154
                                 	<?= $size ?>
155
                                </td>
156
				-->
157
				<td class="listlr">
158
					<?= $index['status'] ?>
159
					<br>
160
					<?= $index['version'] ?>
161
					<br />
162
					platform: <?= $index['required_version'] ?>
163
                                </td>
164
                                <td class="listlr">
165
					<?php
166
						if($index['maintainer'] != "") {
167
							echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
168
						} else {
169
							echo "Nobody. <a href='mailto:coreteam@pfsense.com'>Apply</a> for it!";
170
						}
171
					?>
172
                                </td>
173
                                <td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
174
                                    <?= $index['descr'] ?>
175
                                </td>
176
                                <td valign="middle" class="list" nowrap>
177
                                    <a onclick="return confirm('Do you really want to install this package?')" href="pkg_mgr_install.php?id=<?=$index['name'];?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
178
                                </td>
179
                            </tr>
180
                            <?php
181
                        }
182
		    } else {
183
			echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
184
		    }
185
		}
186
		?>
187
        </table>
188
	</div>
189
    </td>
190
  </tr>
191
</table>
192
<?php include("fend.inc"); ?>
193
</body>
194
</html>
(90-90/173)