Project

General

Profile

Download (5.13 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
    pkg.php
5
    Copyright (C) 2004 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("guiconfig.inc");
31
require("xmlparse_pkg.inc");
32

    
33
function gentitle_pkg($pgname) {
34
	global $config;
35
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
36
}
37

    
38
$xml = $_GET['xml'];
39

    
40
if($xml == "") {
41
            $xml = "not_defined";
42
            print_info_box_np("ERROR:  Could not open " . $xml . ".");
43
            die;
44
} else {
45
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
46
}
47

    
48
if($pkg['donotsave'] <> "") {
49
	header("Location:  pkg_edit.php?xml=" . $xml);
50
}
51

    
52
$package_name = $pkg['menu'][0]['name'];
53
$section      = $pkg['menu'][0]['section'];
54
$config_path  = $pkg['configpath'];
55
$title        = $section . ": " . $package_name;
56

    
57
$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
58
eval($toeval);
59

    
60
if ($_GET['act'] == "del") {
61
	    // loop through our fieldnames and automatically setup the fieldnames
62
	    // in the environment.  ie: a fieldname of username with a value of
63
            // testuser would automatically eval $username = "testuser";
64
	    foreach ($evaledvar as $ip) {
65
			if($pkg['adddeleteeditpagefields']['columnitem'])
66
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
67
				  $toeval = "\$" . xml_safe_fieldname($column['fielddescr']) . " = " . "\$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
68
				  eval($toeval);
69
			  }
70
	    }
71

    
72
	    $toeval = "\$a_pkg = &\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
73
	    eval($toeval);
74

    
75
	    if ($a_pkg[$_GET['id']]) {
76
		if($pkg['custom_delete_php_command'] <> "") {
77
		    eval($pkg['custom_delete_php_command']);
78
		}
79

    
80
		unset($a_pkg[$_GET['id']]);
81
		write_config();
82
		header("Location:  pkg.php?xml=" . $xml);
83
		exit;
84
	    }
85
}
86

    
87
$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
88
eval($toeval);
89

    
90
?>
91
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
92
<html>
93
<head>
94
<title><?=gentitle_pkg($title);?></title>
95
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
96
<link href="gui.css" rel="stylesheet" type="text/css">
97
</head>
98

    
99
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
100
<?php
101
include("fbegin.inc");
102
?>
103
<p class="pgtitle"><?=$title?></p>
104
<form action="firewall_nat_out_load_balancing.php" method="post">
105
<?php if ($savemsg) print_info_box($savemsg); ?>
106
<table width="100%" border="0" cellpadding="0" cellspacing="0">
107
  <tr>
108
    <td class="tabcont">
109
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
110
                <tr>
111
                <?php
112
                $cols = 0;
113
                foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
114
                        echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
115
                        $cols++;
116
                }
117
                echo "</tr>";
118
			$i=0;
119
			if($evaledvar)
120
			foreach ($evaledvar as $ip) {
121
				    echo "<tr valign=\"top\">\n";
122
				    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
123
				       ?>
124
						<td class="listlr">
125
							<?php
126
							    $toeval="echo \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
127
							    eval($toeval);
128
							?>
129
						</td>
130
				       <?php
131
				    }
132
				    ?>
133
				    <td valign="middle" class="list" nowrap>
134
				    &nbsp;<a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this item?')"><img src="x.gif" width="17" height="17" border="0"></a>
135
				    </td>
136
				    <?php
137
				    echo "</tr>\n";
138
				    $i++;
139
			}
140
				    ?>
141

    
142
               <tr><td colspan="<?=$cols?>"></td><td><a href="pkg_edit.php?xml=<?=$xml?>"><img src="plus.gif" width="17" height="17" border="0"></a></td></tr>
143
        </table>
144
    </td>
145
  </tr>
146
</table>
147
</form>
148
<?php include("fend.inc"); ?>
149
</body>
150
</html>
(52-52/99)