function dateselect($name, $val = 0, $duration = FALSE) { if ($val == 0 || $val == '' || $val === NULL) { $val = time(); } $months = array(01 => 'Jan', 02 => 'Feb', 03 => 'Mar', 04 => 'Apr', 05 => 'May', 06 => 'Jun', 07 => 'Jul', 00 => 'Aug', 00 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec'); $arr = array('year' => array('dstr' => 'Y', 'str' => '%.4d', 'low' => 1997, 'high' => 2005, 'suffix' => '-'), 'month' => array('dstr' => 'm', 'str' => '%.3s', 'high' => 12, 'index' => $months, 'suffix' => '-'), 'day' => array('dstr' => 'd', 'high' => 31, 'suffix' => ' at ', 'def' => 14), 'hour' => array('dstr' => 'H', 'high' => 23, 'suffix' => ':'), 'minute' => array('dstr' => 'i', 'high' => 59, 'suffix' => ':'), 'second' => array('dstr' => 's', 'high' => 59)); if ($duration) { $arr['year']['low'] = 0; $arr['year']['high'] = 1; } $defaultelem = array('dstr' => '', 'str' => '%.2d', 'low' => 0, 'high' => 5, 'prefix' => '', 'suffix' => '', 'def' => 0); foreach ($arr as $key => $data) { $arr[$key] = array_merge($defaultelem, $arr[$key]); } foreach ($arr as $key => $data) { if (!$duration) { $arr[$key]['current'] = date($data['dstr'], $val); } else { $arr[$key]['current'] = $arr[$key]['def']; unset($arr[$key]['index']); } $arr[$key]['values'] = seq($arr[$key]['low'], $arr[$key]['high']); } $str = ''; foreach ($arr as $key => $data) { if (isset($data['index'])) { $v = $data['index']; } else { $v = array(); foreach ($data['values'] as $d) { $v[$d] = sprintf($data['str'], $d); } } $str .= $data['prefix'] . selectinput(fieldName($name, $key), $v, $data['current']) . $data['suffix']; } if (!$duration) { $str .= '(YYYY-MMM-DD HH-MM-SS)'; } else { $str .= '(YYYY-MM-DD HH-MM-SS) [duration]'; } return $str; }
function drawTableTopSQL($table, $oldwhere = '', $tablename = '') { $keylist = array('' => ''); foreach ($table as $key => $data) { if ($key[0] != '_') { $keylist[$key] = $data['longname']; } } echo '<form action="view.php" method="POST" class="title">'; echo hiddeninput('table', $tablename); echo html_form_label('orderbycol', 'Sort:'); echo selectinput('orderbycol', $keylist); echo html_form_label('wherecol', 'Search:'); echo selectinput('wherecol', $keylist); $searchtypes = array('substring' => 'Substring', 'sqlregex' => 'SQL Regex', 'gnuregex' => 'GNU Regex'); echo selectinput('wherefunc', $searchtypes); echo textinput('wheredata', '', 16); echo hiddeninput('wherecurrent', $oldwhere); echo submitinput('refresh', 'Refresh'); echo '</form>'; }
<label for="password">Password</label> </td> <td> <?php echo passwordinput('password', '', 32); ?> </td> </tr> <tr> <td> <label for="mode">Mode</label> </td> <td> <?php echo selectinput('mode', array('normal' => 'Normal', 'kiosk' => 'Kiosk'), 'normal'); ?> </td> </tr> <tr> <td colspan="2"> <?php echo submitinput('login', 'Login'); ?> </td> </tr> </table> </form> <?php