#!/usr/local/bin/php
=$title?>
"; eval($pkg['custom_add_php_command']); if($pkg['preoutput']) echo ""; } } // donotsave is enabled. lets simply exit. if($pkg['donotsave'] <> "") exit; $firstfield = ""; $rows = 0; // store values in xml configration file. if (!$input_errors) { $pkgarr = array(); foreach ($pkg['fields']['field'] as $fields) { if($fields['type'] == "rowhelper") { // save rowhelper items. for($x=0; $x<99; $x++) { // XXX: this really should be passed from the form. // XXX: this really is not helping embedded platforms. foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) { if($firstfield == "") { $firstfield = $rowhelperfield['fieldname']; } else { if($firstfield == $rowhelperfield['fieldname']) $rows++; } $comd = "\$value = \$_POST['" . $rowhelperfield['fieldname'] . $x . "'];"; //echo($comd . "=$title?>
\n"; if($type == "input") { echo "\n"; } else if($type == "password") { echo "\n"; } else if($type == "textarea") { echo "\n"; } else if($type == "select") { echo "\n"; } } function fixup_string($string) { global $config; // fixup #1: $myurl -> http[s]://ip_address:port/ $https = ""; $port = ""; $urlport = ""; $port = $config['system']['webguiport']; if($port <> "443" and $port <> "80") $urlport = ":" . $port; if($config['system']['webguiproto'] == "https") $https = "s"; $myurl = "http" . $https . "://" . getenv("HTTP_HOST") . $urlportport; $newstring = str_replace("\$myurl", $myurl, $string); $string = $newstring; // fixup #2: $wanip $curwanip = get_current_wan_address(); $newstring = str_replace("\$wanip", $curwanip, $string); $string = $newstring; // fixup #3: $lanip $lancfg = $config['interfaces']['lan']; $lanip = $lancfg['ipaddr']; $newstring = str_replace("\$lanip", $lanip, $string); $string = $newstring; // fixup #4: fix'r'up here. return $newstring; } /* * Parse templates if they are defined */ function parse_package_templates() { global $pkg, $config; if($pkg['templates']['template'] <> "") foreach($pkg['templates']['template'] as $pkg_template_row) { $filename = $pkg_template_row['filename']; $template_text = $pkg_template_row['templatecontents']; /* calculate total row helpers count */ foreach ($pkg['fields']['field'] as $fields) { if($fields['type'] == "rowhelper") { // save rowhelper items. $row_helper_total_rows = 0; for($x=0; $x<99; $x++) { // XXX: this really should be passed from the form. foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) { if($firstfield == "") { $firstfield = $rowhelperfield['fieldname']; } else { if($firstfield == $rowhelperfield['fieldname']) $rows++; } $comd = "\$value = \$_POST['" . $rowhelperfield['fieldname'] . $x . "'];"; eval($comd); if($value <> "") { //$template_text = str_replace($fieldname . "_fieldvalue", $fieldvalue, $template_text); } else { $row_helper_total_rows = $rows; break; } } } } } /* replace $domain_total_rows with total rows */ $template_text = str_replace("$domain_total_rows", $row_helper_total_rows, $template_text); /* change fields defined as fieldname_fieldvalue to their value */ foreach ($pkg['fields']['field'] as $fields) { if($fields['type'] == "rowhelper") { // save rowhelper items. for($x=0; $x<99; $x++) { // XXX: this really should be passed from the form. $row_helper_data = ""; $isfirst = 0; foreach($fields['rowhelper']['rowhelperfield'] as $rowhelperfield) { if($firstfield == "") { $firstfield = $rowhelperfield['fieldname']; } else { if($firstfield == $rowhelperfield['fieldname']) $rows++; } $comd = "\$value = \$_POST['" . $rowhelperfield['fieldname'] . $x . "'];"; eval($comd); if($value <> "") { if($isfirst == 1) $row_helper_data .= " " ; $row_helper_data .= $value; $isfirst = 1; } ereg($rowhelperfield['fieldname'] . "_fieldvalue\[(.*)\]", $template_text, $sep); foreach ($sep as $se) $seperator = $se; if($seperator <> "") { $row_helper_data = ereg_replace(" ", $seperator, $row_helper_data); $template_text = ereg_replace("\[" . $seperator . "\]", "", $template_text); } $template_text = str_replace($rowhelperfield['fieldname'] . "_fieldvalue", $row_helper_data, $template_text); } } } else { $fieldname = $fields['fieldname']; $fieldvalue = $_POST[$fieldname]; $template_text = str_replace($fieldname . "_fieldvalue", $fieldvalue, $template_text); } } /* replace cr's */ $template_text = str_replace("\\n", "\n", $template_text); /* write out new template file */ $fout = fopen($filename,"w"); fwrite($fout, $template_text); fclose($fout); } } ?>