Project

General

Profile

Download (5.51 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
    pkg.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("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
if($pkg['custom_php_command_before_form'] <> "")
91
  eval($pkg['custom_php_command_before_form']);
92

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

    
102
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
103
<?php
104
include("fbegin.inc");
105
?>
106
<p class="pgtitle"><?=$title?></p>
107
<form action="firewall_nat_out_load_balancing.php" method="post">
108
if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg'];
109
<?php if ($savemsg) print_info_box($savemsg); ?>
110
<table width="100%" border="0" cellpadding="0" cellspacing="0">
111
  <tr>
112
    <td class="tabcont">
113
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
114
                <tr>
115
                <?php
116
                $cols = 0;
117
                foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
118
		    echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
119
		    $cols++;
120
                }
121
                echo "</tr>";
122
		    $i=0;
123
		    if($evaledvar)
124
		    foreach ($evaledvar as $ip) {
125
			echo "<tr valign=\"top\">\n";
126
			foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
127
			   ?>
128
				<td class="listlr">
129
					<?php
130
					    $toeval="\$fieldname = \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
131
					    eval($toeval);
132
					    if($column['type'] == "checkbox") {
133
						if($fieldname == "") {
134
						    echo "No";
135
						} else {
136
						    echo "Yes";
137
						}
138
					    } else {
139
						echo $fieldname;
140
					    }
141
					?>
142
				</td>
143
			   <?php
144
			}
145
			?>
146
			<td valign="middle" class="list" nowrap>
147
			    &nbsp;<a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
148
			    &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>
149
			</td>
150
			<?php
151
			echo "</tr>\n";
152
			$i++;
153
		    }
154
		?>
155
               <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>
156
        </table>
157
    </td>
158
  </tr>
159
</table>
160
</form>
161
<?php include("fend.inc"); ?>
162
</body>
163
</html>
(53-53/100)