Project

General

Profile

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

    
34
if ($_POST) {
35

    
36
    $pconfig = $_POST;
37

    
38
    $retval = 0;
39

    
40
    if (!file_exists($d_sysrebootreqd_path)) {
41
		config_lock();
42
        $retval |= filter_configure();
43
		config_unlock();
44
    }
45
    $savemsg = get_std_save_message($retval);
46

    
47
    if ($retval == 0) {
48
        if (file_exists($d_natconfdirty_path))
49
            unlink($d_natconfdirty_path);
50
        if (file_exists($d_filterconfdirty_path))
51
            unlink($d_filterconfdirty_path);
52
    }
53
}
54

    
55
$pkg_info = get_pkg_info('all', array('name', 'category', 'website', 'version', 'status', 'descr'));
56
if($pkg_info) {
57
	$fout = fopen("{$g['tmp_path']}/pkg_info.cache", "w");
58
	fwrite($fout, serialize($pkg_info));
59
	fclose($fout);
60
        $pkg_sizes = get_pkg_sizes();
61
} else {
62
	$using_cache = true;
63
        $savemsg = "Unable to retrieve package info from {$g['xmlrpcbaseurl']}. Cached data will be used.";
64
	$pkg_info = unserialize(@file_get_contents("{$g['tmp_path']}/pkg_info.cache"));
65
}
66

    
67
$pgtitle = "System: Package Manager";
68
include("head.inc");
69

    
70
?>
71

    
72
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
73
<?php
74
include("fbegin.inc");
75
?>
76
<p class="pgtitle"><?=$pgtitle?></p>
77
<?php if ($savemsg) print_info_box($savemsg); ?>
78
<?php
79

    
80
?>
81

    
82
<br>
83

    
84
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
85
<?php
86
	$tab_array = array();
87
	$tab_array[0] = array("Available Packages", true, "pkg_mgr.php");
88
	$tab_array[1] = array("Installed Packages", false, "pkg_mgr_installed.php");
89
	display_top_tabs($tab_array);
90
?> 
91
  </td></tr>
92
  <tr>
93
    <td>
94
	<div id="mainarea">
95
              <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
96
                <tr>
97
                  <td width="10%" class="listhdrr">Package Name</td>
98
                  <td width="25%" class="listhdrr">Category</td>
99
		  <td width="10%" class="listhdrr">Size</td>
100
		  <td width="5%" class="listhdrr">Status</td>
101
                  <td width="50%" class="listhdr">Description</td>
102
                </tr>
103

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

    
(78-78/144)