Project

General

Profile

Download (7.39 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
    pkg.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
function gentitle_pkg($pgname) {
35
	global $config;
36
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
37
}
38

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

    
41
if($xml == "") {
42
            print_info_box_np("ERROR: No package defined.");
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
		    if($pkg['custom_php_command_before_form'] <> "")
78
			eval($pkg['custom_php_command_before_form']);
79
		    eval($pkg['custom_delete_php_command']);
80
		}
81

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

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

    
92
if($pkg['custom_php_global_functions'] <> "")
93
        eval($pkg['custom_php_global_functions']);
94

    
95
if($pkg['custom_php_command_before_form'] <> "")
96
	eval($pkg['custom_php_command_before_form']);
97

    
98
$pgtitle = $title;
99
include("head.inc");
100

    
101
?>
102

    
103
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
104
<?php
105
include("fbegin.inc");
106
?>
107
<p class="pgtitle"><?=$pgtitle?></p>
108
<form action="pkg.php" method="post">
109
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
110
<?php if ($savemsg) print_info_box($savemsg); ?>
111

    
112
<?php
113
if ($pkg['tabs'] <> "") {
114
    echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
115
    echo "<tr><td>";
116
    echo "  <ul id=\"tabnav\">";
117
    foreach($pkg['tabs']['tab'] as $tab) {
118
	$active = "tabinact";
119
	if(isset($tab['active'])) $active = "tabact";
120
	$urltmp = "";
121
	$title = $tab['text'];
122
	if($tab['url'] <> "") $urltmp = $tab['url'];
123
	if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
124

    
125
	$toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n";
126
	eval($toeval);
127
	// eval url so that above $myurl item can be processed if need be.
128
	$toeval = "\$url = \"" . $urltmp . "\"; \n";
129
	eval($toeval);
130

    
131
	if($active == "tabinact") {
132
	    echo "<li class=\"{$active}\">";
133
	    echo "<a href=\"";
134
	    echo $url;
135
	    echo "\">";
136
	    echo $title;
137
	    echo "</a>";
138
	    echo "</li>";
139
	} else {
140
	    echo "<li class=\"{$active}\">";
141
	    echo $title;
142
	    echo "</li>";
143
	}
144
    }
145
    echo "  </ul>";
146
    echo "</td></tr>";
147
    echo "<tr>";
148
    echo "<td class=\"tabcont\">";
149
}
150
?>
151

    
152
<div id="mainarea">
153
<table width="100%" border="0" cellpadding="0" cellspacing="0">
154
  <tr>
155
    <td class="tabcont">
156
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
157
                <tr>
158
                <?php
159
                $cols = 0;
160
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
161
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
162
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
163
			$cols++;
164
		    }
165
		}
166
                echo "</tr>";
167
		    $i=0;
168
		    if($evaledvar)
169
		    foreach ($evaledvar as $ip) {
170
			echo "<tr valign=\"top\">\n";
171
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
172
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
173
				   ?>
174
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
175
						<?php
176
						    $toeval="\$fieldname = \$ip['" . xml_safe_fieldname($column['fieldname']) . "'];";
177
						    eval($toeval);
178
						    if($column['type'] == "checkbox") {
179
							if($fieldname == "") {
180
							    echo "No";
181
							} else {
182
							    echo "Yes";
183
							}
184
						    } else {
185
							echo $column['prefix'] . $fieldname . $column['suffix'];
186
						    }
187
						?>
188
					</td>
189
				   <?php
190
				}
191
			?>
192
			<td valign="middle" class="list" nowrap>
193
                          <table border="0" cellspacing="0" cellpadding="1">
194
                            <tr>
195
                              <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>
196
			      <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>
197
                            </tr>
198
                          </table>
199
			</td>
200
			<?php
201
			echo "</tr>\n";
202
			$i++;
203
		    }
204
		?>
205
               <tr>
206
                 <td colspan="<?=$cols?>"></td>
207
                 <td>
208
                    <table border="0" cellspacing="0" cellpadding="1">
209
                      <tr>
210
                        <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>"><img src="plus.gif" width="17" height="17" border="0"></a></td>
211
                     </tr>
212
                   </table>
213
                 </td>
214
               </tr>
215
        </table>
216
    </td>
217
  </tr>
218
</table>
219
</div>
220

    
221
<?php
222
if ($pkg['tabs'] <> "") {
223
    echo "</td></tr></table>";
224
}
225
?>
226

    
227
</form>
228
<?php include("fend.inc"); ?>
229

    
230
<script type="text/javascript">
231
NiftyCheck();
232
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
233
</script>
234

    
235
</body>
236
</html>
(65-65/128)