1 |
d47013e1
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
4 |
d47013e1
|
Scott Ullrich
|
/*
|
5 |
|
|
pkg_edit.php
|
6 |
|
|
Copyright (C) 2004 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 |
9f9dcd98
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
32 |
f8e335a3
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
33 |
d47013e1
|
Scott Ullrich
|
|
34 |
|
|
function gentitle_pkg($pgname) {
|
35 |
|
|
global $pfSense_config;
|
36 |
|
|
return $pfSense_config['system']['hostname'] . "." . $pfSense_config['system']['domain'] . " - " . $pgname;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
// XXX: Make this input safe.
|
40 |
|
|
$xml = $_GET['xml'];
|
41 |
19fd2947
|
Scott Ullrich
|
if($_POST['xml']) $xml = $_POST['xml'];
|
42 |
d47013e1
|
Scott Ullrich
|
|
43 |
|
|
if($xml == "") {
|
44 |
e307a809
|
Colin Smith
|
print_info_box_np("ERROR: No package defined.");
|
45 |
d47013e1
|
Scott Ullrich
|
die;
|
46 |
|
|
} else {
|
47 |
19a11678
|
Colin Smith
|
$pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
|
48 |
d47013e1
|
Scott Ullrich
|
}
|
49 |
a28c8b59
|
Scott Ullrich
|
$package_name = $pkg['menu'][0]['name'];
|
50 |
|
|
$section = $pkg['menu'][0]['section'];
|
51 |
d47013e1
|
Scott Ullrich
|
$config_path = $pkg['configpath'];
|
52 |
bb940538
|
Scott Ullrich
|
$name = $pkg['name'];
|
53 |
3eaeb703
|
Scott Ullrich
|
$title = $section . ": " . $package_name;
|
54 |
96d9f5c9
|
Bill Marquette
|
$pgtitle = $title;
|
55 |
d47013e1
|
Scott Ullrich
|
|
56 |
da7bf505
|
Scott Ullrich
|
$id = $_GET['id'];
|
57 |
|
|
if (isset($_POST['id']))
|
58 |
|
|
$id = $_POST['id'];
|
59 |
9b8837be
|
Scott Ullrich
|
|
60 |
529ffadb
|
Bill Marquette
|
if($pkg['custom_php_global_functions'] <> "")
|
61 |
|
|
eval($pkg['custom_php_global_functions']);
|
62 |
|
|
|
63 |
31d27c6c
|
Scott Ullrich
|
// grab the installedpackages->package_name section.
|
64 |
7db8ff99
|
Colin Smith
|
$a_pkg = &$config['installedpackages'][$name]['config'];
|
65 |
31d27c6c
|
Scott Ullrich
|
|
66 |
e315cfa1
|
Colin Smith
|
if(!is_array($config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config']))
|
67 |
7db8ff99
|
Colin Smith
|
$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'] = array();
|
68 |
da7bf505
|
Scott Ullrich
|
|
69 |
7db8ff99
|
Colin Smith
|
$a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
|
70 |
da7bf505
|
Scott Ullrich
|
|
71 |
19d360bf
|
Scott Ullrich
|
if($_GET['savemsg'] <> "")
|
72 |
|
|
$savemsg = $_GET['savemsg'];
|
73 |
f9a91638
|
Scott Ullrich
|
|
74 |
194b4e0a
|
Colin Smith
|
if($pkg['custom_php_command_before_form'] <> "")
|
75 |
|
|
eval($pkg['custom_php_command_before_form']);
|
76 |
f9a91638
|
Scott Ullrich
|
|
77 |
6483da5d
|
Scott Ullrich
|
if ($_POST) {
|
78 |
b3235baa
|
Scott Ullrich
|
if($_POST['act'] == "del") {
|
79 |
|
|
if($pkg['custom_delete_php_command']) {
|
80 |
5cd30ac3
|
Scott Ullrich
|
if($pkg['custom_php_command_before_form'] <> "")
|
81 |
|
|
eval($pkg['custom_php_command_before_form']);
|
82 |
b3235baa
|
Scott Ullrich
|
eval($pkg['custom_delete_php_command']);
|
83 |
|
|
}
|
84 |
e3c4b6b7
|
Scott Ullrich
|
write_config();
|
85 |
facd08f9
|
Scott Ullrich
|
// resync the configuration file code if defined.
|
86 |
|
|
if($pkg['custom_php_resync_config_command'] <> "") {
|
87 |
86f3fc00
|
Scott Ullrich
|
if($pkg['custom_php_command_before_form'] <> "")
|
88 |
|
|
eval($pkg['custom_php_command_before_form']);
|
89 |
|
|
eval($pkg['custom_php_resync_config_command']);
|
90 |
facd08f9
|
Scott Ullrich
|
}
|
91 |
b3235baa
|
Scott Ullrich
|
} else {
|
92 |
|
|
if($pkg['custom_add_php_command']) {
|
93 |
90779bf7
|
Scott Ullrich
|
if($pkg['donotsave'] <> "" or $pkg['preoutput'] <> "") {
|
94 |
12123e25
|
Colin Smith
|
?>
|
95 |
afe4a7d3
|
Erik Kristensen
|
|
96 |
539b4c44
|
Colin Smith
|
<?php include("head.inc"); ?>
|
97 |
3eaeb703
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
98 |
2fe6c52b
|
Colin Smith
|
<?php include("fbegin.inc"); ?>
|
99 |
96d9f5c9
|
Bill Marquette
|
<p class="pgtitle"><?=$pgtitle?></p>
|
100 |
3eaeb703
|
Scott Ullrich
|
<?php
|
101 |
|
|
}
|
102 |
|
|
if($pkg['preoutput']) echo "<pre>";
|
103 |
|
|
eval($pkg['custom_add_php_command']);
|
104 |
|
|
if($pkg['preoutput']) echo "</pre>";
|
105 |
b3235baa
|
Scott Ullrich
|
}
|
106 |
6483da5d
|
Scott Ullrich
|
}
|
107 |
e3c4b6b7
|
Scott Ullrich
|
|
108 |
eec70f21
|
Scott Ullrich
|
// donotsave is enabled. lets simply exit.
|
109 |
3eaeb703
|
Scott Ullrich
|
if($pkg['donotsave'] <> "") exit;
|
110 |
|
|
|
111 |
b6e87566
|
Scott Ullrich
|
$firstfield = "";
|
112 |
|
|
$rows = 0;
|
113 |
|
|
|
114 |
b3235baa
|
Scott Ullrich
|
// store values in xml configration file.
|
115 |
|
|
if (!$input_errors) {
|
116 |
|
|
$pkgarr = array();
|
117 |
|
|
foreach ($pkg['fields']['field'] as $fields) {
|
118 |
eec70f21
|
Scott Ullrich
|
if($fields['type'] == "rowhelper") {
|
119 |
|
|
// save rowhelper items.
|
120 |
|
|
for($x=0; $x<99; $x++) { // XXX: this really should be passed from the form.
|
121 |
628b33c1
|
Scott Ullrich
|
// XXX: this really is not helping embedded platforms.
|
122 |
0e730fee
|
Scott Ullrich
|
foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) {
|
123 |
b6e87566
|
Scott Ullrich
|
if($firstfield == "") {
|
124 |
|
|
$firstfield = $rowhelperfield['fieldname'];
|
125 |
|
|
} else {
|
126 |
|
|
if($firstfield == $rowhelperfield['fieldname']) $rows++;
|
127 |
|
|
}
|
128 |
d2ac2599
|
Scott Ullrich
|
$comd = "\$value = \$_POST['" . $rowhelperfield['fieldname'] . $x . "'];";
|
129 |
|
|
echo($comd . "<br>");
|
130 |
eec70f21
|
Scott Ullrich
|
eval($comd);
|
131 |
|
|
if($value <> "") {
|
132 |
b6e87566
|
Scott Ullrich
|
$comd = "\$pkgarr['row'][" . $x . "]['" . $rowhelperfield['fieldname'] . "'] = \"" . $value . "\";";
|
133 |
|
|
//echo($comd . "<br>");
|
134 |
eec70f21
|
Scott Ullrich
|
eval($comd);
|
135 |
|
|
}
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
} else {
|
139 |
|
|
// simply loop through all field names looking for posted
|
140 |
0e730fee
|
Scott Ullrich
|
// values matching the fieldnames. if found, save to package
|
141 |
|
|
// configuration area.
|
142 |
d2ac2599
|
Scott Ullrich
|
if(is_array( $_POST[$fields['fieldname']] )) {
|
143 |
|
|
$pkgarr[$fields['fieldname']]=array();
|
144 |
|
|
foreach($_POST[$fields['fieldname']] as $v) {
|
145 |
|
|
$pkgarr[$fields['fieldname']][] = $v;
|
146 |
|
|
eval($comd);
|
147 |
|
|
}
|
148 |
|
|
continue;
|
149 |
|
|
}
|
150 |
eec70f21
|
Scott Ullrich
|
$fieldname = $fields['fieldname'];
|
151 |
|
|
$fieldvalue = $_POST[$fieldname];
|
152 |
7db8ff99
|
Colin Smith
|
$pkgarr[$fieldname] = $fieldvalue;
|
153 |
eec70f21
|
Scott Ullrich
|
}
|
154 |
b3235baa
|
Scott Ullrich
|
}
|
155 |
0e730fee
|
Scott Ullrich
|
|
156 |
e3c4b6b7
|
Scott Ullrich
|
if (isset($id) && $a_pkg[$id])
|
157 |
|
|
$a_pkg[$id] = $pkgarr;
|
158 |
|
|
else
|
159 |
|
|
$a_pkg[] = $pkgarr;
|
160 |
0e730fee
|
Scott Ullrich
|
|
161 |
b3235baa
|
Scott Ullrich
|
write_config();
|
162 |
0e730fee
|
Scott Ullrich
|
|
163 |
facd08f9
|
Scott Ullrich
|
// late running code
|
164 |
2a520a0a
|
Scott Ullrich
|
if($pkg['custom_add_php_command_late'] <> "") {
|
165 |
|
|
eval($pkg['custom_add_php_command_late']);
|
166 |
|
|
}
|
167 |
0e730fee
|
Scott Ullrich
|
|
168 |
facd08f9
|
Scott Ullrich
|
// resync the configuration file code if defined.
|
169 |
|
|
if($pkg['custom_php_resync_config_command'] <> "") {
|
170 |
|
|
eval($pkg['custom_php_resync_config_command']);
|
171 |
|
|
}
|
172 |
|
|
|
173 |
dcbe6f52
|
Scott Ullrich
|
parse_package_templates();
|
174 |
|
|
|
175 |
a485a6f5
|
Scott Ullrich
|
/* if start_command is defined, restart w/ this */
|
176 |
|
|
if($pkg['start_command'] <> "")
|
177 |
|
|
exec($pkg['start_command'] . ">/dev/null 2&>1");
|
178 |
|
|
|
179 |
|
|
/* if restart_command is defined, restart w/ this */
|
180 |
|
|
if($pkg['restart_command'] <> "")
|
181 |
|
|
exec($pkg['restart_command'] . ">/dev/null 2&>1");
|
182 |
|
|
|
183 |
dcbe6f52
|
Scott Ullrich
|
if($pkg['aftersaveredirect'] <> "") {
|
184 |
|
|
header("Location: " . $pkg['aftersaveredirect']);
|
185 |
3089059e
|
Colin Smith
|
} elseif(!$pkg['adddeleteeditpagefields']) {
|
186 |
|
|
header("Location: pkg_edit.php?xml={$xml}&id=0");
|
187 |
|
|
} elseif(!$pkg['preoutput']) {
|
188 |
|
|
header("Location: pkg.php?xml=" . $xml);
|
189 |
dcbe6f52
|
Scott Ullrich
|
}
|
190 |
0e730fee
|
Scott Ullrich
|
exit;
|
191 |
e3c4b6b7
|
Scott Ullrich
|
}
|
192 |
da7bf505
|
Scott Ullrich
|
}
|
193 |
|
|
|
194 |
83ddedcd
|
Scott Ullrich
|
if($pkg['title'] <> "")
|
195 |
|
|
$title = $pkg['title'];
|
196 |
|
|
else
|
197 |
|
|
$title = "Package Editor";
|
198 |
|
|
|
199 |
|
|
$pgtitle = $title;
|
200 |
|
|
include("head.inc");
|
201 |
|
|
|
202 |
d47013e1
|
Scott Ullrich
|
?>
|
203 |
|
|
|
204 |
2fe6c52b
|
Colin Smith
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onLoad="enablechange();">
|
205 |
|
|
<?php if($pkg['fields']['field'] <> "") { ?>
|
206 |
|
|
<script language="JavaScript">
|
207 |
|
|
<!--
|
208 |
|
|
function enablechange() {
|
209 |
|
|
<?php
|
210 |
|
|
foreach($pkg['fields']['field'] as $field) {
|
211 |
|
|
if(isset($field['enablefields']) or isset($field['checkenablefields'])) {
|
212 |
|
|
print "\t" . 'if (document.iform.' . strtolower($field['name']) . '.checked == false) {' . "\n";
|
213 |
|
|
if(isset($field['enablefields'])) {
|
214 |
|
|
$enablefields = explode(',', $field['enablefields']);
|
215 |
|
|
foreach($enablefields as $enablefield) {
|
216 |
|
|
$enablefield = strtolower($enablefield);
|
217 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 1;' . "\n";
|
218 |
|
|
}
|
219 |
|
|
}
|
220 |
|
|
if(isset($field['checkenablefields'])) {
|
221 |
|
|
$checkenablefields = explode(',', $field['checkenablefields']);
|
222 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
223 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
224 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 0;' . "\n";
|
225 |
|
|
}
|
226 |
|
|
}
|
227 |
|
|
print "\t" . '} else {' . "\n";
|
228 |
|
|
if(isset($field['enablefields'])) {
|
229 |
|
|
foreach($enablefields as $enablefield) {
|
230 |
|
|
$enablefield = strtolower($enablefield);
|
231 |
|
|
print "\t\t" . 'document.iform.' . $enablefield . '.disabled = 0;' . "\n";
|
232 |
|
|
}
|
233 |
|
|
}
|
234 |
|
|
if(isset($field['checkenablefields'])) {
|
235 |
|
|
foreach($checkenablefields as $checkenablefield) {
|
236 |
|
|
$checkenablefield = strtolower($checkenablefield);
|
237 |
|
|
print "\t\t" . 'document.iform.' . $checkenablefield . '.checked = 1;' . "\n";
|
238 |
|
|
}
|
239 |
|
|
}
|
240 |
|
|
print "\t" . '}' . "\n";
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
?>
|
244 |
|
|
}
|
245 |
|
|
//-->
|
246 |
|
|
</script>
|
247 |
|
|
<?php } ?>
|
248 |
eec70f21
|
Scott Ullrich
|
<script type="text/javascript" language="javascript" src="row_helper_dynamic.js">
|
249 |
|
|
</script>
|
250 |
|
|
|
251 |
96d9f5c9
|
Bill Marquette
|
<?php include("fbegin.inc"); ?>
|
252 |
|
|
<p class="pgtitle"><?=$pgtitle?></p>
|
253 |
19fd2947
|
Scott Ullrich
|
<form action="pkg_edit.php" method="post">
|
254 |
|
|
<input type="hidden" name="xml" value="<?= $xml ?>">
|
255 |
d47013e1
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
256 |
f4cb26b7
|
Colin Smith
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
257 |
7c061036
|
Scott Ullrich
|
<?php
|
258 |
|
|
if ($pkg['tabs'] <> "") {
|
259 |
f4cb26b7
|
Colin Smith
|
echo '<tr><td>';
|
260 |
|
|
$tab_array = array();
|
261 |
7c061036
|
Scott Ullrich
|
foreach($pkg['tabs']['tab'] as $tab) {
|
262 |
f4cb26b7
|
Colin Smith
|
if(isset($tab['active'])) {
|
263 |
|
|
$active = true;
|
264 |
|
|
} else {
|
265 |
|
|
$active = false;
|
266 |
|
|
}
|
267 |
e17ce934
|
Scott Ullrich
|
$urltmp = "";
|
268 |
|
|
if($tab['url'] <> "") $urltmp = $tab['url'];
|
269 |
|
|
if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
|
270 |
|
|
|
271 |
7db8ff99
|
Colin Smith
|
$myurl = getenv("HTTP_HOST");
|
272 |
e17ce934
|
Scott Ullrich
|
// eval url so that above $myurl item can be processed if need be.
|
273 |
f4cb26b7
|
Colin Smith
|
$url = str_replace('$myurl', $myurl, $urltmp);
|
274 |
|
|
$tab_array[] = array(
|
275 |
|
|
$tab['text'],
|
276 |
|
|
$active,
|
277 |
|
|
$url
|
278 |
|
|
);
|
279 |
7c061036
|
Scott Ullrich
|
}
|
280 |
f4cb26b7
|
Colin Smith
|
display_top_tabs($tab_array);
|
281 |
|
|
echo '</td></tr>';
|
282 |
7c061036
|
Scott Ullrich
|
}
|
283 |
|
|
?>
|
284 |
f4cb26b7
|
Colin Smith
|
<tr><td><div id="mainarea"><table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
|
285 |
d47013e1
|
Scott Ullrich
|
<?php
|
286 |
|
|
$cols = 0;
|
287 |
3eaeb703
|
Scott Ullrich
|
$savevalue = "Save";
|
288 |
|
|
if($pkg['savetext'] <> "") $savevalue = $pkg['savetext'];
|
289 |
|
|
foreach ($pkg['fields']['field'] as $pkga) { ?>
|
290 |
5c74f339
|
Scott Ullrich
|
|
291 |
facd08f9
|
Scott Ullrich
|
<?php if(!$pkga['combinefieldsend']) echo "<tr valign=\"top\">"; ?>
|
292 |
|
|
|
293 |
d47013e1
|
Scott Ullrich
|
<?php
|
294 |
5c74f339
|
Scott Ullrich
|
|
295 |
|
|
$size = "";
|
296 |
|
|
|
297 |
facd08f9
|
Scott Ullrich
|
if(!$pkga['dontdisplayname']) {
|
298 |
31d27c6c
|
Scott Ullrich
|
echo "<td width=\"22%\" class=\"vncellreq\">";
|
299 |
d51f86e0
|
Scott Ullrich
|
echo fixup_string($pkga['fielddescr']);
|
300 |
31d27c6c
|
Scott Ullrich
|
echo "</td>";
|
301 |
facd08f9
|
Scott Ullrich
|
}
|
302 |
|
|
|
303 |
|
|
if(!$pkga['dontcombinecells'])
|
304 |
|
|
echo "<td class=\"vtable\">";
|
305 |
3eaeb703
|
Scott Ullrich
|
|
306 |
31d27c6c
|
Scott Ullrich
|
// if user is editing a record, load in the data.
|
307 |
|
|
if (isset($id) && $a_pkg[$id]) {
|
308 |
|
|
$fieldname = $pkga['fieldname'];
|
309 |
7db8ff99
|
Colin Smith
|
$value = $a_pkg[$id][$fieldname];
|
310 |
31d27c6c
|
Scott Ullrich
|
}
|
311 |
|
|
|
312 |
3eaeb703
|
Scott Ullrich
|
if($pkga['type'] == "input") {
|
313 |
b6e87566
|
Scott Ullrich
|
if($pkga['size']) $size = " size='" . $pkga['size'] . "' ";
|
314 |
|
|
echo "<input " . $size . " name='" . $pkga['fieldname'] . "' value='" . $value . "'>\n";
|
315 |
d51f86e0
|
Scott Ullrich
|
echo "<br>" . fixup_string($pkga['description']) . "\n";
|
316 |
3eaeb703
|
Scott Ullrich
|
} else if($pkga['type'] == "password") {
|
317 |
b6e87566
|
Scott Ullrich
|
echo "<input type='password' " . $size . " name='" . $pkga['fieldname'] . "' value='" . $value . "'>\n";
|
318 |
d51f86e0
|
Scott Ullrich
|
echo "<br>" . fixup_string($pkga['description']) . "\n";
|
319 |
3eaeb703
|
Scott Ullrich
|
} else if($pkga['type'] == "select") {
|
320 |
|
|
if($pkga['size']) $size = " size='" . $pkga['size'] . "' ";
|
321 |
|
|
if($pkga['multiple'] == "yes") $multiple = "MULTIPLE ";
|
322 |
2c634bdd
|
Scott Ullrich
|
echo "<select " . $multiple . $size . "id='" . $pkga['fieldname'] . "' name='" . $pkga['fieldname'] . "'>\n";
|
323 |
|
|
foreach ($pkga['options']['option'] as $opt) {
|
324 |
|
|
$selected = "";
|
325 |
|
|
if($opt['value'] == $value) $selected = " SELECTED";
|
326 |
|
|
echo "\t<option name='" . $opt['name'] . "' value='" . $opt['value'] . "'" . $selected . ">" . $opt['name'] . "</option>\n";
|
327 |
|
|
}
|
328 |
|
|
echo "</select>\n";
|
329 |
|
|
echo "<br>" . fixup_string($pkga['description']) . "\n";
|
330 |
|
|
} else if($pkga['type'] == "vpn_selection") {
|
331 |
|
|
echo "<select name='" . $vpn['name'] . "'>\n";
|
332 |
|
|
foreach ($config['ipsec']['tunnel'] as $vpn) {
|
333 |
|
|
echo "\t<option value=\"" . $vpn['descr'] . "\">" . $vpn['descr'] . "</option>\n";
|
334 |
|
|
}
|
335 |
|
|
echo "</select>\n";
|
336 |
03f0bfe7
|
Scott Ullrich
|
echo "<br>" . fixup_string($pkga['description']) . "\n";
|
337 |
3eaeb703
|
Scott Ullrich
|
} else if($pkga['type'] == "checkbox") {
|
338 |
64c1ebbb
|
Scott Ullrich
|
$checkboxchecked = "";
|
339 |
34865da0
|
Scott Ullrich
|
if($value == "on") $checkboxchecked = " CHECKED";
|
340 |
64c1ebbb
|
Scott Ullrich
|
echo "<input type='checkbox' name='" . $pkga['fieldname'] . "'" . $checkboxchecked . ">\n";
|
341 |
d51f86e0
|
Scott Ullrich
|
echo "<br>" . fixup_string($pkga['description']) . "\n";
|
342 |
3eaeb703
|
Scott Ullrich
|
} else if($pkga['type'] == "textarea") {
|
343 |
|
|
if($pkga['rows']) $rows = " rows='" . $pkga['rows'] . "' ";
|
344 |
|
|
if($pkga['cols']) $cols = " cols='" . $pkga['cols'] . "' ";
|
345 |
b6e87566
|
Scott Ullrich
|
echo "<textarea " . $rows . $cols . " name='" . $pkga['fieldname'] . "'>" . $value . "</textarea>\n";
|
346 |
d51f86e0
|
Scott Ullrich
|
echo "<br>" . fixup_string($pkga['description']) . "\n";
|
347 |
ab73789e
|
Scott Ullrich
|
} else if($pkga['type'] == "interfaces_selection") {
|
348 |
76584e25
|
Scott Ullrich
|
$size = "";
|
349 |
7502342a
|
Scott Ullrich
|
$multiple = "";
|
350 |
|
|
$fieldname = $pkga['fieldname'];
|
351 |
76584e25
|
Scott Ullrich
|
if($pkga['size'] <> "") $size = " size=\"" . $pkga['size'] . "\"";
|
352 |
d6a84c31
|
Scott Ullrich
|
if($pkga['multiple'] <> "" and $pkga['multiple'] <> "0") {
|
353 |
7502342a
|
Scott Ullrich
|
$multiple = " multiple=\"multiple\"";
|
354 |
|
|
$fieldname .= "[]";
|
355 |
|
|
}
|
356 |
|
|
echo "<select name='" . $fieldname . "'" . $size . $multiple . ">\n";
|
357 |
4a91019e
|
Scott Ullrich
|
if($pkga['add_to_interfaces_selection'] <> "") {
|
358 |
|
|
$SELECTED = "";
|
359 |
|
|
if($pkga['add_to_interfaces_selection'] == $value) $SELECTED = " SELECTED";
|
360 |
|
|
echo "<option value='" . $pkga['add_to_interfaces_selection'] . "'" . $SELECTED . ">" . $pkga['add_to_interfaces_selection'] . "</option>\n";
|
361 |
e4a72146
|
Scott Ullrich
|
}
|
362 |
|
|
$interfaces = &$config['interfaces'];
|
363 |
|
|
if($pkga['all_interfaces'] <> "") {
|
364 |
e6a12151
|
Scott Ullrich
|
$ints = split(" ", `/sbin/ifconfig -l`);
|
365 |
e4a72146
|
Scott Ullrich
|
$interfaces = array();
|
366 |
|
|
foreach ($ints as $int) {
|
367 |
e6a12151
|
Scott Ullrich
|
$interfaces[]['descr'] = $int;
|
368 |
e4a72146
|
Scott Ullrich
|
$interfaces[] = $int;
|
369 |
|
|
}
|
370 |
|
|
}
|
371 |
|
|
foreach ($interfaces as $ifname => $iface) {
|
372 |
ab73789e
|
Scott Ullrich
|
if ($iface['descr'])
|
373 |
|
|
$ifdescr = $iface['descr'];
|
374 |
|
|
else
|
375 |
|
|
$ifdescr = strtoupper($ifname);
|
376 |
b39f5ac4
|
Scott Ullrich
|
$ifname = $iface['descr'];
|
377 |
201bf2ee
|
Scott Ullrich
|
$ip = "";
|
378 |
|
|
if($pkga['all_interfaces'] <> "") {
|
379 |
e6a12151
|
Scott Ullrich
|
$ifdescr = $iface;
|
380 |
201bf2ee
|
Scott Ullrich
|
$ip = " " . find_interface_ip($iface);
|
381 |
|
|
}
|
382 |
378f7d3a
|
Scott Ullrich
|
$SELECTED = "";
|
383 |
34591684
|
Scott Ullrich
|
if($value == $ifdescr) $SELECTED = " SELECTED";
|
384 |
201bf2ee
|
Scott Ullrich
|
$to_echo = "<option value='" . $ifdescr . "'" . $SELECTED . ">" . $ifdescr . $ip . "</option>\n";
|
385 |
c98e7fb7
|
Scott Ullrich
|
$to_echo .= "<!-- {$value} -->";
|
386 |
e6a12151
|
Scott Ullrich
|
$to_echo .= "<!-- {$iface} -->";
|
387 |
c98e7fb7
|
Scott Ullrich
|
$canecho = 0;
|
388 |
|
|
if($pkga['interface_filter'] <> "") {
|
389 |
e6a12151
|
Scott Ullrich
|
if(stristr($iface, $pkga['interface_filter']) == true)
|
390 |
c98e7fb7
|
Scott Ullrich
|
$canecho = 1;
|
391 |
|
|
} else {
|
392 |
|
|
$canecho = 1;
|
393 |
|
|
}
|
394 |
e4a72146
|
Scott Ullrich
|
if($canecho == 1)
|
395 |
c98e7fb7
|
Scott Ullrich
|
echo $to_echo;
|
396 |
ab73789e
|
Scott Ullrich
|
}
|
397 |
e6a12151
|
Scott Ullrich
|
echo "</select>\n<br>" . fixup_string($pkga['description']) . "\n";
|
398 |
3eaeb703
|
Scott Ullrich
|
} else if($pkga['type'] == "radio") {
|
399 |
b6e87566
|
Scott Ullrich
|
echo "<input type='radio' name='" . $pkga['fieldname'] . "' value='" . $value . "'>";
|
400 |
eec70f21
|
Scott Ullrich
|
} else if($pkga['type'] == "rowhelper") {
|
401 |
|
|
?>
|
402 |
|
|
<script type="text/javascript" language='javascript'>
|
403 |
|
|
<!--
|
404 |
0e730fee
|
Scott Ullrich
|
|
405 |
eec70f21
|
Scott Ullrich
|
<?php
|
406 |
|
|
$rowcounter = 0;
|
407 |
|
|
$fieldcounter = 0;
|
408 |
|
|
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
|
409 |
|
|
echo "rowname[" . $fieldcounter . "] = \"" . $rowhelper['fieldname'] . "\";\n";
|
410 |
|
|
echo "rowtype[" . $fieldcounter . "] = \"" . $rowhelper['type'] . "\";\n";
|
411 |
|
|
$fieldcounter++;
|
412 |
|
|
}
|
413 |
|
|
?>
|
414 |
0e730fee
|
Scott Ullrich
|
|
415 |
eec70f21
|
Scott Ullrich
|
-->
|
416 |
|
|
</script>
|
417 |
0e730fee
|
Scott Ullrich
|
|
418 |
eec70f21
|
Scott Ullrich
|
<table name="maintable" id="maintable">
|
419 |
b6e87566
|
Scott Ullrich
|
<tr>
|
420 |
eec70f21
|
Scott Ullrich
|
<?php
|
421 |
31d27c6c
|
Scott Ullrich
|
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
|
422 |
d51f86e0
|
Scott Ullrich
|
echo "<td><b>" . fixup_string($rowhelper['fielddescr']) . "</td>\n";
|
423 |
31d27c6c
|
Scott Ullrich
|
}
|
424 |
b6e87566
|
Scott Ullrich
|
echo "</tr>";
|
425 |
|
|
echo "<tbody>";
|
426 |
|
|
|
427 |
eec70f21
|
Scott Ullrich
|
echo "<tr>";
|
428 |
|
|
// XXX: traverse saved fields, add back needed rows.
|
429 |
|
|
echo "</tr>";
|
430 |
0e730fee
|
Scott Ullrich
|
|
431 |
31d27c6c
|
Scott Ullrich
|
echo "<tr>\n";
|
432 |
|
|
$rowcounter = 0;
|
433 |
|
|
$trc = 0;
|
434 |
|
|
if(isset($a_pkg[$id]['row'])) {
|
435 |
|
|
foreach($a_pkg[$id]['row'] as $row) {
|
436 |
|
|
/*
|
437 |
|
|
* loop through saved data for record if it exists, populating rowhelper
|
438 |
bb940538
|
Scott Ullrich
|
*/
|
439 |
31d27c6c
|
Scott Ullrich
|
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
|
440 |
|
|
if($rowhelper['value'] <> "") $value = $rowhelper['value'];
|
441 |
|
|
$fieldname = $rowhelper['fieldname'];
|
442 |
|
|
// if user is editing a record, load in the data.
|
443 |
bb940538
|
Scott Ullrich
|
if (isset($id) && $a_pkg[$id]) {
|
444 |
7db8ff99
|
Colin Smith
|
$value = $row[$fieldname];
|
445 |
bb940538
|
Scott Ullrich
|
}
|
446 |
31d27c6c
|
Scott Ullrich
|
$options = "";
|
447 |
|
|
$type = $rowhelper['type'];
|
448 |
|
|
$fieldname = $rowhelper['fieldname'];
|
449 |
|
|
if($type == "option") $options = &$rowhelper['options']['option'];
|
450 |
e70e0b76
|
Scott Ullrich
|
$size = "8";
|
451 |
|
|
if($rowhelper['size'] <> "") $size = $rowhelper['size'];
|
452 |
|
|
display_row($rowcounter, $value, $fieldname, $type, $rowhelper, $size);
|
453 |
bb940538
|
Scott Ullrich
|
// javascript helpers for row_helper_dynamic.js
|
454 |
|
|
echo "</td>\n";
|
455 |
|
|
echo "<script language=\"JavaScript\">\n";
|
456 |
|
|
echo "<!--\n";
|
457 |
|
|
echo "newrow[" . $trc . "] = \"" . $text . "\";\n";
|
458 |
|
|
echo "-->\n";
|
459 |
|
|
echo "</script>\n";
|
460 |
|
|
$text = "";
|
461 |
|
|
$trc++;
|
462 |
eec70f21
|
Scott Ullrich
|
}
|
463 |
bb940538
|
Scott Ullrich
|
|
464 |
31d27c6c
|
Scott Ullrich
|
$rowcounter++;
|
465 |
|
|
echo "<td>";
|
466 |
677c0869
|
Erik Kristensen
|
echo "<input type=\"image\" src=\"./themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\">";
|
467 |
eec70f21
|
Scott Ullrich
|
echo "</td>\n";
|
468 |
31d27c6c
|
Scott Ullrich
|
echo "</tr>\n";
|
469 |
|
|
}
|
470 |
|
|
}
|
471 |
|
|
if($trc == 0) {
|
472 |
|
|
/*
|
473 |
|
|
* no records loaded.
|
474 |
|
|
* just show a generic line non-populated with saved data
|
475 |
|
|
*/
|
476 |
|
|
foreach($pkga['rowhelper']['rowhelperfield'] as $rowhelper) {
|
477 |
|
|
if($rowhelper['value'] <> "") $value = $rowhelper['value'];
|
478 |
bb940538
|
Scott Ullrich
|
$fieldname = $rowhelper['fieldname'];
|
479 |
31d27c6c
|
Scott Ullrich
|
$options = "";
|
480 |
|
|
$type = $rowhelper['type'];
|
481 |
|
|
$fieldname = $rowhelper['fieldname'];
|
482 |
|
|
if($type == "option") $options = &$rowhelper['options']['option'];
|
483 |
e70e0b76
|
Scott Ullrich
|
$size = "8";
|
484 |
|
|
if($rowhelper['size'] <> "") $size = $rowhelper['size'];
|
485 |
|
|
display_row($rowcounter, $value, $fieldname, $type, $rowhelper, $size);
|
486 |
bb940538
|
Scott Ullrich
|
// javascript helpers for row_helper_dynamic.js
|
487 |
|
|
echo "</td>\n";
|
488 |
|
|
echo "<script language=\"JavaScript\">\n";
|
489 |
|
|
echo "<!--\n";
|
490 |
|
|
echo "newrow[" . $trc . "] = \"" . $text . "\";\n";
|
491 |
|
|
echo "-->\n";
|
492 |
|
|
echo "</script>\n";
|
493 |
|
|
$text = "";
|
494 |
eec70f21
|
Scott Ullrich
|
$trc++;
|
495 |
|
|
}
|
496 |
bb940538
|
Scott Ullrich
|
|
497 |
|
|
$rowcounter++;
|
498 |
eec70f21
|
Scott Ullrich
|
}
|
499 |
|
|
?>
|
500 |
0e730fee
|
Scott Ullrich
|
|
501 |
eec70f21
|
Scott Ullrich
|
</tbody>
|
502 |
|
|
</table>
|
503 |
0e730fee
|
Scott Ullrich
|
|
504 |
677c0869
|
Erik Kristensen
|
<br><a onClick="javascript:addRowTo('maintable'); return false;" href="#"><img border="0" src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif"></a>
|
505 |
eec70f21
|
Scott Ullrich
|
<script language="JavaScript">
|
506 |
|
|
<!--
|
507 |
|
|
field_counter_js = <?= $fieldcounter ?>;
|
508 |
|
|
rows = <?= $rowcounter ?>;
|
509 |
|
|
totalrows = <?php echo $rowcounter; ?>;
|
510 |
|
|
loaded = <?php echo $rowcounter; ?>;
|
511 |
e02a6839
|
Scott Ullrich
|
//typesel_change();
|
512 |
eec70f21
|
Scott Ullrich
|
//-->
|
513 |
|
|
</script>
|
514 |
|
|
|
515 |
|
|
<?php
|
516 |
d47013e1
|
Scott Ullrich
|
}
|
517 |
3eaeb703
|
Scott Ullrich
|
if($pkga['typehint']) echo " " . $pkga['typehint'];
|
518 |
facd08f9
|
Scott Ullrich
|
?>
|
519 |
|
|
|
520 |
d47013e1
|
Scott Ullrich
|
<?php
|
521 |
facd08f9
|
Scott Ullrich
|
if(!$pkga['combinefieldsbegin']) echo "</td></tr>";
|
522 |
d47013e1
|
Scott Ullrich
|
$i++;
|
523 |
|
|
}
|
524 |
|
|
?>
|
525 |
b6e87566
|
Scott Ullrich
|
<tr>
|
526 |
|
|
<td> </td>
|
527 |
|
|
</tr>
|
528 |
d47013e1
|
Scott Ullrich
|
<tr>
|
529 |
|
|
<td width="22%" valign="top"> </td>
|
530 |
|
|
<td width="78%">
|
531 |
eaa55df2
|
Scott Ullrich
|
<input name="Submit" type="submit" class="formbtn" value="<?= $savevalue ?>"> <input class="formbtn" type="button" value="cancel" onclick="history.back()">
|
532 |
d47013e1
|
Scott Ullrich
|
<?php if (isset($id) && $a_pkg[$id]): ?>
|
533 |
|
|
<input name="id" type="hidden" value="<?=$id;?>">
|
534 |
|
|
<?php endif; ?>
|
535 |
|
|
</td>
|
536 |
|
|
</tr>
|
537 |
|
|
</table>
|
538 |
f4cb26b7
|
Colin Smith
|
</div></tr></td></table>
|
539 |
7c061036
|
Scott Ullrich
|
|
540 |
fb8d451e
|
Colin Smith
|
<?php if($pkga['note'] <> "") echo "<br><center>" . $pkga['note'] . "</center>"; ?>
|
541 |
95736b54
|
Scott Ullrich
|
|
542 |
d47013e1
|
Scott Ullrich
|
</form>
|
543 |
|
|
<?php include("fend.inc"); ?>
|
544 |
|
|
</body>
|
545 |
|
|
</html>
|
546 |
|
|
|
547 |
31d27c6c
|
Scott Ullrich
|
<?php
|
548 |
|
|
|
549 |
|
|
/*
|
550 |
|
|
* ROW Helpers function
|
551 |
|
|
*/
|
552 |
e70e0b76
|
Scott Ullrich
|
function display_row($trc, $value, $fieldname, $type, $rowhelper, $size) {
|
553 |
bb940538
|
Scott Ullrich
|
global $text;
|
554 |
31d27c6c
|
Scott Ullrich
|
echo "<td>\n";
|
555 |
|
|
if($type == "input") {
|
556 |
e70e0b76
|
Scott Ullrich
|
echo "<input size='" . $size . "' name='" . $fieldname . $trc . "' value='" . $value . "'>\n";
|
557 |
31d27c6c
|
Scott Ullrich
|
} else if($type == "password") {
|
558 |
e70e0b76
|
Scott Ullrich
|
echo "<input size='" . $size . "' type='password' name='" . $fieldname . $trc . "' value='" . $value . "'>\n";
|
559 |
31d27c6c
|
Scott Ullrich
|
} else if($type == "textarea") {
|
560 |
e70e0b76
|
Scott Ullrich
|
echo "<textarea rows='2' cols='12' name='" . $fieldname . $trc . "'>" . $value . "</textarea>\n";
|
561 |
31d27c6c
|
Scott Ullrich
|
} else if($type == "select") {
|
562 |
|
|
echo "<select name='" . $fieldname . $trc . "'>\n";
|
563 |
|
|
foreach($rowhelper['options']['option'] as $rowopt) {
|
564 |
|
|
$selected = "";
|
565 |
|
|
if($rowopt['value'] == $value) $selected = " SELECTED";
|
566 |
|
|
$text .= "<option value='" . $rowopt['value'] . "'" . $selected . ">" . $rowopt['name'] . "</option>";
|
567 |
|
|
echo "<option value='" . $rowopt['value'] . "'" . $selected . ">" . $rowopt['name'] . "</option>\n";
|
568 |
|
|
}
|
569 |
|
|
echo "</select>\n";
|
570 |
|
|
}
|
571 |
|
|
}
|
572 |
|
|
|
573 |
d51f86e0
|
Scott Ullrich
|
function fixup_string($string) {
|
574 |
d2133701
|
Scott Ullrich
|
global $config;
|
575 |
d51f86e0
|
Scott Ullrich
|
// fixup #1: $myurl -> http[s]://ip_address:port/
|
576 |
|
|
$https = "";
|
577 |
|
|
$port = $config['system']['webguiport'];
|
578 |
63637de9
|
Bill Marquette
|
if($port <> "443" and $port <> "80")
|
579 |
|
|
$urlport = ":" . $port;
|
580 |
|
|
else
|
581 |
|
|
$urlport = "";
|
582 |
|
|
|
583 |
d51f86e0
|
Scott Ullrich
|
if($config['system']['webguiproto'] == "https") $https = "s";
|
584 |
63637de9
|
Bill Marquette
|
$myurl = "http" . $https . "://" . getenv("HTTP_HOST") . $urlport;
|
585 |
d51f86e0
|
Scott Ullrich
|
$newstring = str_replace("\$myurl", $myurl, $string);
|
586 |
d2133701
|
Scott Ullrich
|
$string = $newstring;
|
587 |
|
|
// fixup #2: $wanip
|
588 |
|
|
$curwanip = get_current_wan_address();
|
589 |
|
|
$newstring = str_replace("\$wanip", $curwanip, $string);
|
590 |
|
|
$string = $newstring;
|
591 |
|
|
// fixup #3: $lanip
|
592 |
|
|
$lancfg = $config['interfaces']['lan'];
|
593 |
|
|
$lanip = $lancfg['ipaddr'];
|
594 |
|
|
$newstring = str_replace("\$lanip", $lanip, $string);
|
595 |
|
|
$string = $newstring;
|
596 |
|
|
// fixup #4: fix'r'up here.
|
597 |
d51f86e0
|
Scott Ullrich
|
return $newstring;
|
598 |
|
|
}
|
599 |
|
|
|
600 |
dcbe6f52
|
Scott Ullrich
|
/*
|
601 |
|
|
* Parse templates if they are defined
|
602 |
|
|
*/
|
603 |
|
|
function parse_package_templates() {
|
604 |
|
|
global $pkg, $config;
|
605 |
|
|
if($pkg['templates']['template'] <> "")
|
606 |
|
|
foreach($pkg['templates']['template'] as $pkg_template_row) {
|
607 |
|
|
$filename = $pkg_template_row['filename'];
|
608 |
|
|
$template_text = $pkg_template_row['templatecontents'];
|
609 |
|
|
|
610 |
|
|
/* calculate total row helpers count */
|
611 |
|
|
foreach ($pkg['fields']['field'] as $fields) {
|
612 |
|
|
if($fields['type'] == "rowhelper") {
|
613 |
|
|
// save rowhelper items.
|
614 |
|
|
$row_helper_total_rows = 0;
|
615 |
|
|
for($x=0; $x<99; $x++) { // XXX: this really should be passed from the form.
|
616 |
|
|
foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) {
|
617 |
|
|
if($firstfield == "") {
|
618 |
|
|
$firstfield = $rowhelperfield['fieldname'];
|
619 |
|
|
} else {
|
620 |
|
|
if($firstfield == $rowhelperfield['fieldname']) $rows++;
|
621 |
|
|
}
|
622 |
|
|
$comd = "\$value = \$_POST['" . $rowhelperfield['fieldname'] . $x . "'];";
|
623 |
|
|
eval($comd);
|
624 |
|
|
if($value <> "") {
|
625 |
|
|
//$template_text = str_replace($fieldname . "_fieldvalue", $fieldvalue, $template_text);
|
626 |
|
|
} else {
|
627 |
|
|
$row_helper_total_rows = $rows;
|
628 |
|
|
break;
|
629 |
|
|
}
|
630 |
|
|
}
|
631 |
|
|
}
|
632 |
|
|
}
|
633 |
|
|
}
|
634 |
|
|
|
635 |
|
|
/* replace $domain_total_rows with total rows */
|
636 |
|
|
$template_text = str_replace("$domain_total_rows", $row_helper_total_rows, $template_text);
|
637 |
|
|
|
638 |
|
|
/* change fields defined as fieldname_fieldvalue to their value */
|
639 |
|
|
foreach ($pkg['fields']['field'] as $fields) {
|
640 |
|
|
if($fields['type'] == "rowhelper") {
|
641 |
|
|
// save rowhelper items.
|
642 |
|
|
for($x=0; $x<99; $x++) { // XXX: this really should be passed from the form.
|
643 |
|
|
$row_helper_data = "";
|
644 |
1be00369
|
Scott Ullrich
|
$isfirst = 0;
|
645 |
dcbe6f52
|
Scott Ullrich
|
foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) {
|
646 |
|
|
if($firstfield == "") {
|
647 |
|
|
$firstfield = $rowhelperfield['fieldname'];
|
648 |
|
|
} else {
|
649 |
|
|
if($firstfield == $rowhelperfield['fieldname']) $rows++;
|
650 |
|
|
}
|
651 |
|
|
$comd = "\$value = \$_POST['" . $rowhelperfield['fieldname'] . $x . "'];";
|
652 |
|
|
eval($comd);
|
653 |
|
|
if($value <> "") {
|
654 |
1be00369
|
Scott Ullrich
|
if($isfirst == 1) $row_helper_data .= " " ;
|
655 |
|
|
$row_helper_data .= $value;
|
656 |
|
|
$isfirst = 1;
|
657 |
dcbe6f52
|
Scott Ullrich
|
}
|
658 |
|
|
ereg($rowhelperfield['fieldname'] . "_fieldvalue\[(.*)\]", $template_text, $sep);
|
659 |
|
|
foreach ($sep as $se) $seperator = $se;
|
660 |
|
|
if($seperator <> "") {
|
661 |
|
|
$row_helper_data = ereg_replace(" ", $seperator, $row_helper_data);
|
662 |
|
|
$template_text = ereg_replace("\[" . $seperator . "\]", "", $template_text);
|
663 |
|
|
}
|
664 |
|
|
$template_text = str_replace($rowhelperfield['fieldname'] . "_fieldvalue", $row_helper_data, $template_text);
|
665 |
|
|
}
|
666 |
|
|
}
|
667 |
|
|
} else {
|
668 |
|
|
$fieldname = $fields['fieldname'];
|
669 |
|
|
$fieldvalue = $_POST[$fieldname];
|
670 |
|
|
$template_text = str_replace($fieldname . "_fieldvalue", $fieldvalue, $template_text);
|
671 |
|
|
}
|
672 |
|
|
}
|
673 |
|
|
|
674 |
|
|
/* replace cr's */
|
675 |
|
|
$template_text = str_replace("\\n", "\n", $template_text);
|
676 |
|
|
|
677 |
|
|
/* write out new template file */
|
678 |
|
|
$fout = fopen($filename,"w");
|
679 |
|
|
fwrite($fout, $template_text);
|
680 |
|
|
fclose($fout);
|
681 |
|
|
}
|
682 |
|
|
}
|
683 |
|
|
|
684 |
3e304594
|
Colin Smith
|
?>
|