No table name specified. Please specify a table to edit.

\n"; exit; } //echo "

" . implode(',',array_keys($_SESSION)) . "

\n"; //if (array_key_exists("editable-$tab",$_SESSION)) { echo "

count=".count($_SESSION["editable-$tab"])."

\n"; } if(isset($_REQUEST['kill'])) { unset($_SESSION["editable-$tab"]); } if(isset($_REQUEST['save'])) { $rsp = savexCATchanges($tab,$_SESSION["editable-$tab"]); $errors = array(); if (getXmlErrors($rsp,$errors)) { echo "

Tabrestore failed: ", implode(' ',$errors), "

\n"; } else { echo "

Changes have been saved.

\n"; } } // Get table contents //$f = splitTableFields2('"node01","node02","5000","off",,'); echo '

'; foreach ($f as $k => $v) { echo "$k=$v
"; } echo "

\n"; echo "

$tab Table

"; echo "\n"; echo "\n"; echo "
", getTabDescription($tab), "Column Descriptions
Regular Expression Support
\n"; // Display the column names $xml = docmd('tabdump','',array($tab)); $headers = getTabHeaders($xml); if(!is_array($headers)){ die("

Can't find header line in $tab

"); } echo "\n"; echo "\n"; // extra cell is for the red x foreach($headers as $colHead) { echo ""; } echo "\n"; # close header table // Save the width of the table for adding a new row when they click that button $tableWidth = count($headers); // Display table contents and remember its contents in a session variable. $ooe = 0; // alternates the background of the table $item = 0; // the column # $line = 0; $editable = array(); foreach ($xml->children() as $response) foreach ($response->children() as $arr){ $arr = (string) $arr; if(ereg("^#", $arr)){ // handle the header specially $editable[$line++][$item] = $arr; continue; } $cl = "ListLine$ooe"; $values = splitTableFields($arr); // If you change this line, be sure to change the formRow function in db.js echo ""; foreach($values as $v){ //$v = preg_replace('/\"/','', $v); echo ""; $editable[$line][$item++] = $v; } echo "\n"; $line++; $item = 0; $ooe = 1 - $ooe; } echo "
$colHead
$v
\n"; $_SESSION["editable-$tab"] = & $editable; // save the array so we can access it in the next call of this file or change.php //unset($_SESSION["editable-$tab"]); echo "

Add Row\n"; echo "Save\n"; echo "Cancel

\n"; ?> children() as $response) foreach ($response->children() as $line) { $line = (string) $line; if (ereg("^#", $line)) { $line = preg_replace('/^#/','', $line); $headers = explode(',', $line); return $headers; } } // If we get here, we never found the header line return NULL; } //----------------------------------------------------------------------------- function savexCATchanges($tab, & $editable){ $request = simplexml_load_string(''); $request->addChild('command','tabrestore'); foreach($editable as $line){ foreach ($line as &$f) { if (!empty($f) && !preg_match('/^".*"$/', $f)) { $f = '"'.$f.'"'; } } $linestr = implode(",",$line); $linestr = str_replace('"', '"',$linestr); //todo: should we use the htmlentities function? $linestr = str_replace("'", ''',$linestr); //echo "

addChild:$linestr.

\n"; $request->addChild('data', $linestr); } $request->addChild('table',$tab); $resp = submit_request($request, 0); return $resp; } //----------------------------------------------------------------------------- function getTabDescription($tab) { $xml = docmd('tabdump','',array('-d')); foreach ($xml->children() as $response) foreach ($response->children() as $line) { $line = (string) $line; if (ereg("^$tab:",$line)) { $line = preg_replace("/^$tab:\s*/", '', $line); return $line; } } return ''; } ?>