<?php
/*
This file contains the startup readin in of get/post vars
Any and all checking should happen here.
*/
pma_debug("start setup");
// Detect how we were called
// for our purpose, it should be POST or GET only
$opt['reqm'] = $_SERVER['REQUEST_METHOD'];
$opt['self'] = basename($_SERVER['PHP_SELF']);
// ******************** Field Defaults *********************************
// edit to your own tastes, settings for data entry defaults
// Do not just remove, some checks depend on them.
$opt['ydefault'] = 2002;
$opt['ydefnum'] = 10;
$opt['booltrue'] = 'Y';
$opt['boolfalse'] = 'N';
$opt['rdefstart'] = 1;
$opt['rdefstep'] = 1;
$opt['rdefnosteps'] = 10;
$opt['maxdisp'] = 60;
$opt['nopasswd'] = 'Not Set';
$opt['SearchFieldSize'] = 15;
// We never send out plaintext passwords, so we need to be
// tricky to detect changed entries, we use our own fake pwd.
// Change if you want to, it's just got to be hard to
// accidentally use, since otherwise there's a chance some user
// actually picked it as his/her pasword
$opt['pwchangedet'] = "Ijs25dq1";
// Maximum rows to show for print request
$opt['maxprintrows'] = 50;
// Table/fields definitions from calling program
while (list($a,$b) = each($fdd)) {
$fds[] = $a; /*SQL Field Names*/
}
// Number of fields
$opt['num_fds'] = sizeof($fds);
if ( $key_type=='string'||$key_type=='blob'||$key_type=='date'||$key_type=='time') {
$opt['key_delim']='"';
} else {
$opt['key_delim']='';
}
// set the other opt array values, some of these are hidden vars from forms,
// others need cleaning up, which we can do here
// We use the opt array to ease the use of all of these values within function context
// using a single global declaration.
#$opt['tb'] = $tb;
#if(!isset($_POST['tb'])) { $opt['tb'] = $tb; } else { $opt['tb'] = $_POST['tb']; }
if(!array_key_exists('tb', $_POST)) { $opt['tb'] = $tb; } else { $opt['tb'] = $_POST['tb']; }
if(!array_key_exists('rec',$_POST)) { $opt['rec'] = $rec; } else { $opt['rec']= $_POST['rec']; }
if(!array_key_exists('fm',$_POST)) { $opt['fm'] = $fm; } else { $opt['fm'] = $_POST['fm']; }
if(!array_key_exists('sfn',$_POST)) { $opt['sfn'] = $sfn; } else { $opt['sfn']= $_POST['sfn']; }
if(!array_key_exists('qfn',$_POST)) { $opt['qfn'] = $qfn; } else { $opt['qfn']= $_POST['qfn']; }
if(!array_key_exists('fl',$_POST)) { $opt['fl'] = $fl; } else { $opt['fl'] = $_POST['fl']; }
if(!array_key_exists('sw',$_POST)) { $opt['sw'] = $sw; } else { $opt['sw'] = $_POST['sw']; }
if(!array_key_exists('inc',$_POST)) { $opt['inc'] = $inc; } else { $opt['inc']= $_POST['inc']; }
if(!array_key_exists('keyoptions',$_POST)) { $opt['options'] = $options; } else { $opt['options']= $_POST['options']; }
if(!array_key_exists('key',$_POST)) { $opt['key'] = $key; } else { $opt['key'] = $_POST['key']; }
if(!array_key_exists('key_type',$_POST)) { $opt['key_type'] = $key_type; } else { $opt['key_type'] = $_POST['key_type']; }
if(!array_key_exists('apply',$_POST)) { $opt['apply'] = $apply; } else { $opt['apply'] = $_POST['apply']; }
// table edit buttons (only have a value when button is pressed in forms)
if(!array_key_exists('add',$_POST)) { $opt['add'] = $add; } else { $opt['add'] = $_POST['add']; }
if(!array_key_exists('saveadd',$_POST)) { $opt['saveadd'] = $saveadd; } else { $opt['saveadd'] = $_POST['saveadd']; }
if(!array_key_exists('savedelete',$_POST)) { $opt['savedelete'] = $savedelete; } else { $opt['savedelete'] = $_POST['savedelete']; }
if(!array_key_exists('change',$_POST)) { $opt['change'] = $change; } else { $opt['change'] = $_POST['change']; }
if(!array_key_exists('savechange',$_POST)) { $opt['savechange'] = $savechange; } else { $opt['savechange'] = $_POST['savechange']; }
if(!array_key_exists('delete',$_POST)) { $opt['delete'] = $delete; } else { $opt['delete'] = $_POST['delete']; }
if(!array_key_exists('zoom',$_POST)) { $opt['zoom'] = $zoom; } else { $opt['zoom'] = $_POST['zoom']; }
if(!array_key_exists('prev',$_POST)) { $opt['prev'] = $prev; } else { $opt['prev'] = $_POST['prev']; }
if(!array_key_exists('next',$_POST)) { $opt['next'] = $next; } else { $opt['next'] = $_POST['next']; }
if(!array_key_exists('sw',$_POST)) { $opt['sw'] = $sw; } else { $opt['sw'] = $_POST['sw']; }
if(!array_key_exists('jump',$_POST)) { $opt['jump'] = $jump; } else { $opt['jump'] = $_POST['jump']; }
if(!array_key_exists('jumpto',$_POST)) { $opt['jumpto'] = $jumpto; } else { $opt['jumpto'] = $_POST['jumpto']; }
if(!array_key_exists('doprint',$_POST)) { $opt['doprint'] = $doprint; } else { $opt['doprint'] = $_POST['print']; }
if(!array_key_exists('xls',$_POST)) { $opt['xls'] = $xls; } else { $opt['xls'] = $_POST['xls']; }
// query buttons (only have a value when button is pressed in forms)
if(!array_key_exists('query',$_POST)) { $opt['query'] = $query; } else { $opt['query'] = $_POST['query']; }
if(!array_key_exists('qadd',$_POST)) { $opt['qadd'] = $qadd; } else { $opt['qadd'] = $_POST['qadd']; }
if(!array_key_exists('qchange',$_POST)) { $opt['qchange'] = $qchange; } else { $opt['qchange'] = $_POST['qchange']; }
if(!array_key_exists('qdel',$_POST)) { $opt['qdel'] = $qdel; } else { $opt['qdel'] = $_POST['qdel']; }
if(!array_key_exists('qshow',$_POST)) { $opt['qshow'] = $qshow; } else { $opt['qshow'] = $_POST['qshow']; }
if(!array_key_exists('qsave',$_POST)) { $opt['qsave'] = $qsave; } else { $opt['qsave'] = $_POST['qsave']; }
if(!array_key_exists('qswitch',$_POST)) { $opt['qswitch'] = $qswitch; } else { $opt['qswitch'] = $_POST['qswitch']; }
if(!array_key_exists('qtable',$_POST)) { $opt['qtable'] = $qtable; } else { $opt['qtable'] = $_POST['qtable']; }
if(!array_key_exists('querytable',$_POST)) { $opt['querytable'] = $querytable; } else { $opt['querytable'] = $_POST['querytable']; }
if(!array_key_exists('sel_query_ID',$_POST)){ $opt['sel_query_ID'] = $sel_query_ID; } else { $opt['sel_query_ID'] = $_POST['sel_query_ID']; }
if(!array_key_exists('clearfilter',$_POST)) { $opt['clearfilter'] = $clearfilter; } else { $opt['clearfilter'] = $_POST['cfilter']; }
// get the filter settings into opt[]
if ($opt['clearfilter'] != "Clear Filter" ) {
if ($opt['reqm']=='GET') {
for ($k=0 ; $k<$opt['num_fds']; $k++) {
$l = 'qf'.$k;
if ($_GET[$l]!='') {
$opt[$l] = $_GET[$l];
$opt['searchactive'] = 1;
}
}
} else if ($opt['reqm']=='POST') {
for ($k=0 ; $k<$opt['num_fds']; $k++) {
$l = 'qf'.$k;
if ($_POST[$l]!='') {
$opt[$l] = $_POST[$l];
$opt['searchactive'] = 1;
}
}
}
}
// mind the order of the mode setting
// Deafault to table mode unless a form var says not to
if ($_POST['xlsdump']=='xls'){
$opt['mode'] = "xls";
} else if ($_POST['mode']) {
$opt['mode'] = $_POST['mode'];
} else {
$opt['mode'] = "table";
}
// use the query button to switch around between table and query mode
if ($opt['query'] == "Query") {
$opt['mode'] = "query";
}
if ($opt['qtable'] == "table") {
$opt['mode'] = "table";
}
function save_form_state($type=0) {
echo " <!--// save_form_state //--!>\n";
echo ' <input type="hidden" name="mode" value="' . $GLOBALS['opt']['mode'] . "\" />\n";
if ($type) {
echo ' <input type="hidden" name="rec" value="'.$GLOBALS['opt']['rec'].'" />'."\n";
}
echo ' <input type="hidden" name="sfn" value="'.$GLOBALS['opt']['sfn'].'" />'."\n";
echo ' <input type="hidden" name="fl" value="'.$GLOBALS['opt']['fl'].'" />'."\n";
// preserve the values of any filter fields $qf0..$qfn for Pass 3
$prev_qfn=urldecode($GLOBALS['opt']['qfn']);
$qfn='';
for ($k=0 ; $k<$GLOBALS['opt']['num_fds']; $k++) {
$l='qf'.$k;
if ($GLOBALS['opt'][$l] != '') {
//only save if query data not displayed
if (!$GLOBALS['opt']['fl']) {
echo ' <input type="hidden" name="'.$l.'" value="'.$GLOBALS['opt'][$l].'" />'."\n";
}
$qfn = $qfn.'&qf'.$k.'='.$GLOBALS['opt'][$l];
}
}
if ($qfn != $prev_qfn) {
$GLOBALS['opt']['fm'] = 0;
$GLOBALS['opt']['qfn'] = $qfn;
}
echo ' <input type="hidden" name="fm" value="'.$GLOBALS['opt']['fm'].'" />'."\n";
echo ' <input type="hidden" name="qfn" value="'.$GLOBALS['opt']['qfn'].'" />'."\n";
}
function PostruncheckAndExecute() {
if (function_exists('Post_Run')) {
Post_Run();
}
}
function FootercheckAndExecute() {
if (function_exists('footer')) {
footer ();
}
}
?>