Project

General

Profile

Download (5.91 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'));
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
$pgtitle = "System: Package Manager";
50
include("head.inc");
51

    
52
?>
53

    
54
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
55
<?php
56
include("fbegin.inc");
57
?>
58
<p class="pgtitle"><?=$pgtitle?></p>
59
<?php if ($savemsg) print_info_box($savemsg); ?>
60
<?php
61

    
62
?>
63

    
64
<br>
65

    
66
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
67
<?php
68
	$tab_array = array();
69
	$tab_array[0] = array("Available Packages", true, "pkg_mgr.php");
70
	$tab_array[1] = array("Installed Packages", false, "pkg_mgr_installed.php");
71
	display_top_tabs($tab_array);
72
?> 
73
  </td></tr>
74
  <tr>
75
    <td>
76
	<div id="mainarea">
77
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
78
                <tr>
79
                  <td width="10%" class="listhdrr">Package Name</td>
80
                  <td width="25%" class="listhdrr">Category</td>
81
<!--
82
		  <td width="10%" class="listhdrr">Size</td>
83
-->
84
		  <td width="5%" class="listhdrr">Status</td>
85
		  <td width="5%" class="listhdrr">Maintainer</td>
86
                  <td width="50%" class="listhdr">Description</td>
87
                </tr>
88

    
89
		<?php
90
		 if(!$pkg_info) {
91
			echo "<tr><td colspan=\"5\"><center>There are currently no packages available for installation.</td></tr>";
92
		 } else {
93
		 $pkgs = array();
94
		 $instpkgs = array();
95
		    if($config['installedpackages']['package'] != "")
96
			foreach($config['installedpackages']['package'] as $instpkg) $instpkgs[] = $instpkg['name'];
97
		    $pkg_names = array_keys($pkg_info);
98
		    $pkg_keys = array();
99
		    foreach($pkg_names as $name) {
100
			if(!in_array($name, $instpkgs)) $pkg_keys[] = $name;
101
		    }
102
		    sort($pkg_keys);
103
		    if(count($pkg_keys) != 0) {
104
		    	foreach($pkg_keys as $key) {
105
			    $index = &$pkg_info[$key];
106
			    if(in_array($index['name'], $instpkgs)) continue;
107
                            ?>
108
                            <tr valign="top">
109
                                <td class="listlr">
110
                                    <A target="_new" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
111
                                </td>
112
                                <td class="listlr">
113
                                    <?= $index['category'] ?>
114
    				</td>
115
				<?php
116
					/*
117
					if(!$using_cache) {
118
						$size = get_package_install_size($index['name'], $pkg_sizes);
119
                               			$size = squash_from_bytes($size[$index['name']], 1);
120
					}
121
					if(!$size) $size = "Unknown.";
122
					*/
123
				?>
124
				<!--
125
				<td class="listlr">
126
                                 	<?= $size ?>
127
                                </td>
128
				-->
129
				<td class="listlr">
130
					<?= $index['status'] ?>
131
					<br>
132
					<?= $index['version'] ?>
133
                                </td>
134
                                <td class="listlr">
135
					<?php
136
						if($index['maintainer'] != "") {
137
							echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
138
						} else {
139
							echo "Nobody. <a href='mailto:coreteam@pfsense.com'>Apply</a> for it!";
140
						}
141
					?>
142
                                </td>									
143
                                <td class="listbg">
144
                                    <font color="#ffffff">
145
                                    <?= $index['descr'] ?>
146
                                </td>
147
                                <td valign="middle" class="list" nowrap>
148
                                    <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>
149
                                </td>
150
                            </tr>
151
                            <?php
152
                        }
153
		    } else {
154
			echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
155
		    }
156
		}
157
		?>
158
        </table>
159
	</div>
160
    </td>
161
  </tr>
162
</table>
163
<?php include("fend.inc"); ?>
164
</body>
165
</html>
(84-84/163)