Project

General

Profile

Download (7.36 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 {$g['product_website']}.  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 = array("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
<?php if ($savemsg) print_info_box($savemsg); ?>
65
<?php
66

    
67
?>
68

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

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

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

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

    
134
                            ?>
135
                            <tr valign="top">
136
                                <td class="listlr">
137
                                    <A target="_blank" href="<?= $index['website'] ?>"><?= $index['name'] ?></a>
138
                                </td>
139
                                <td class="listlr">
140
                                    <?= $index['category'] ?>
141
    				</td>
142
				<?php
143
					/*
144
					if(!$using_cache) {
145
						$size = get_package_install_size($index['name'], $pkg_sizes);
146
                               			$size = squash_from_bytes($size[$index['name']], 1);
147
					}
148
					if(!$size) $size = "Unknown.";
149
					*/
150
				?>
151
				<!--
152
				<td class="listlr">
153
                                 	<?= $size ?>
154
                                </td>
155
				-->
156
				<td class="listlr">
157
					<?= $index['status'] ?>
158
					<br>
159
					<?= $index['version'] ?>
160
					<br />
161
					platform: <?= $index['required_version'] ?>
162
                                </td>
163
                                <td class="listlr">
164
					<?php
165
						if($index['maintainer'] != "") {
166
							echo "<a href='mailto:{$index['maintainer']}'>{$index['maintainer']}</a>";
167
						} else {
168
							echo "Nobody. <a href='mailto:{$g['product_email']}'>Apply</a> for it!";
169
						}
170
					?>
171
                                </td>
172
                                <td class="listbg" class="listbg" style="color: #FFFFFF; overflow: hidden;">
173
                                    <?= $index['descr'] ?>
174
                                </td>
175
                                <td valign="middle" class="list" nowrap>
176
                                    <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>
177
                                </td>
178
                            </tr>
179
                            <?php
180
                        }
181
		    } else {
182
			echo '<tr><td colspan="5"><center>There are currently no packages available for installation.</center></td></tr>';
183
		    }
184
		}
185
		?>
186
        </table>
187
	</div>
188
    </td>
189
  </tr>
190
</table>
191
<?php include("fend.inc"); ?>
192
</body>
193
</html>
(96-96/193)