Project

General

Profile

Download (7.56 KB) Statistics
| Branch: | Tag: | Revision:
1 a7f908db Scott Ullrich
#!/usr/local/bin/php
2
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 a7f908db Scott Ullrich
/*
5
    pkg.php
6 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
7 a7f908db Scott Ullrich
    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("guiconfig.inc");
32
require("xmlparse_pkg.inc");
33
34
function gentitle_pkg($pgname) {
35 e3c4b6b7 Scott Ullrich
	global $config;
36
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
37 a7f908db Scott Ullrich
}
38
39
$xml = $_GET['xml'];
40
41
if($xml == "") {
42
            $xml = "not_defined";
43
            print_info_box_np("ERROR:  Could not open " . $xml . ".");
44
            die;
45
} else {
46 e3c4b6b7 Scott Ullrich
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
47 a7f908db Scott Ullrich
}
48
49 3eaeb703 Scott Ullrich
if($pkg['donotsave'] <> "") {
50
	header("Location:  pkg_edit.php?xml=" . $xml);
51
}
52
53 a28c8b59 Scott Ullrich
$package_name = $pkg['menu'][0]['name'];
54
$section      = $pkg['menu'][0]['section'];
55 a7f908db Scott Ullrich
$config_path  = $pkg['configpath'];
56 e3c4b6b7 Scott Ullrich
$title        = $section . ": " . $package_name;
57
58
$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
59
eval($toeval);
60
61
if ($_GET['act'] == "del") {
62 0bb335f4 Scott Ullrich
	    // loop through our fieldnames and automatically setup the fieldnames
63
	    // in the environment.  ie: a fieldname of username with a value of
64
            // testuser would automatically eval $username = "testuser";
65 e3c4b6b7 Scott Ullrich
	    foreach ($evaledvar as $ip) {
66 e55a0a25 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'])
67
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
68
				  $toeval = "\$" . xml_safe_fieldname($column['fielddescr']) . " = " . "\$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
69
				  eval($toeval);
70
			  }
71 e3c4b6b7 Scott Ullrich
	    }
72
73
	    $toeval = "\$a_pkg = &\$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
74
	    eval($toeval);
75
76
	    if ($a_pkg[$_GET['id']]) {
77
		if($pkg['custom_delete_php_command'] <> "") {
78 5cd30ac3 Scott Ullrich
		    if($pkg['custom_php_command_before_form'] <> "")
79
			eval($pkg['custom_php_command_before_form']);
80 e3c4b6b7 Scott Ullrich
		    eval($pkg['custom_delete_php_command']);
81
		}
82
83
		unset($a_pkg[$_GET['id']]);
84
		write_config();
85
		header("Location:  pkg.php?xml=" . $xml);
86
		exit;
87
	    }
88
}
89
90
$toeval = "\$evaledvar = \$config['installedpackages']['" . xml_safe_fieldname($pkg['name']) . "']['config'];";
91
eval($toeval);
92 a7f908db Scott Ullrich
93 194b4e0a Colin Smith
if($pkg['custom_php_global_functions'] <> "")
94
        eval($pkg['custom_php_global_functions']);
95
96 f9a91638 Scott Ullrich
if($pkg['custom_php_command_before_form'] <> "")
97 194b4e0a Colin Smith
	eval($pkg['custom_php_command_before_form']);
98 f9a91638 Scott Ullrich
99 a7f908db Scott Ullrich
?>
100
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
101
<html>
102
<head>
103 64fba011 Scott Ullrich
<?php
104
    if($pkg['title'] <> "") $title = $pkg['title'];
105
?>
106 a7f908db Scott Ullrich
<title><?=gentitle_pkg($title);?></title>
107
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
108
<link href="gui.css" rel="stylesheet" type="text/css">
109
</head>
110
111
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
112 859329c8 Scott Ullrich
<?php
113
include("fbegin.inc");
114
?>
115 a7f908db Scott Ullrich
<p class="pgtitle"><?=$title?></p>
116 64fba011 Scott Ullrich
<form action="pkg.php" method="post">
117 8596e0a4 Scott Ullrich
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
118 a7f908db Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
119 7c061036 Scott Ullrich
120
<?php
121
if ($pkg['tabs'] <> "") {
122
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
123
    echo "<tr><td>";
124
    echo "  <ul id=\"tabnav\">";
125
    foreach($pkg['tabs']['tab'] as $tab) {
126
	$active = "tabinact";
127
	if(isset($tab['active'])) $active = "tabact";
128 e17ce934 Scott Ullrich
	$urltmp = "";
129 3d335c4d Scott Ullrich
	$title = $tab['text'];
130 e17ce934 Scott Ullrich
	if($tab['url'] <> "") $urltmp = $tab['url'];
131
	if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
132
133
	$toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n";
134
	eval($toeval);
135
	// eval url so that above $myurl item can be processed if need be.
136
	$toeval = "\$url = \"" . $urltmp . "\"; \n";
137
	eval($toeval);
138
139 3d335c4d Scott Ullrich
	if($active == "tabinact") {
140
	    echo "<li class=\"{$active}\">";
141
	    echo "<a href=\"";
142
	    echo $url;
143
	    echo "\">";
144
	    echo $title;
145
	    echo "</a>";
146
	    echo "</li>";
147
	} else {
148
	    echo "<li class=\"{$active}\">";
149
	    echo $title;
150
	    echo "</li>";
151
	}
152 7c061036 Scott Ullrich
    }
153
    echo "  </ul>";
154
    echo "</td></tr>";
155
    echo "<tr>";
156
    echo "<td class=\"tabcont\">";
157
}
158
?>
159
160 a7f908db Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">
161
  <tr>
162
    <td class="tabcont">
163
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
164
                <tr>
165
                <?php
166
                $cols = 0;
167 2d512c84 Scott Ullrich
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
168
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
169
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
170
			$cols++;
171
		    }
172
		}
173 a7f908db Scott Ullrich
                echo "</tr>";
174 2cf712c4 Scott Ullrich
		    $i=0;
175
		    if($evaledvar)
176
		    foreach ($evaledvar as $ip) {
177
			echo "<tr valign=\"top\">\n";
178 7c061036 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
179 549912e3 Scott Ullrich
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
180
				   ?>
181 5f9c0e68 Bill Marquette
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
182 549912e3 Scott Ullrich
						<?php
183
						    $toeval="\$fieldname = \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
184
						    eval($toeval);
185
						    if($column['type'] == "checkbox") {
186
							if($fieldname == "") {
187
							    echo "No";
188
							} else {
189
							    echo "Yes";
190
							}
191
						    } else {
192 009c7905 Colin Smith
							echo $column['prefix'] . $fieldname . $column['suffix'];
193 549912e3 Scott Ullrich
						    }
194
						?>
195
					</td>
196
				   <?php
197
				}
198 2cf712c4 Scott Ullrich
			?>
199
			<td valign="middle" class="list" nowrap>
200 a339c26a Bill Marquette
                          <table border="0" cellspacing="0" cellpadding="1">
201
                            <tr>
202
                              <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a></td>
203
			      <td valign="middle"><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></td>
204
                            </tr>
205
                          </table>
206 2cf712c4 Scott Ullrich
			</td>
207
			<?php
208
			echo "</tr>\n";
209
			$i++;
210
		    }
211
		?>
212 a339c26a Bill Marquette
               <tr>
213
                 <td colspan="<?=$cols?>"></td>
214
                 <td>
215
                    <table border="0" cellspacing="0" cellpadding="1">
216
                      <tr>
217
                        <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>"><img src="plus.gif" width="17" height="17" border="0"></a></td>
218
                     </tr>
219
                   </table>
220
                 </td>
221
               </tr>
222 a7f908db Scott Ullrich
        </table>
223
    </td>
224
  </tr>
225
</table>
226 3d335c4d Scott Ullrich
227
<?php
228
if ($pkg['tabs'] <> "") {
229
    echo "</td></tr></table>";
230
}
231
?>
232
233 a7f908db Scott Ullrich
</form>
234
<?php include("fend.inc"); ?>
235
</body>
236
</html>