version 1.36, 2002/12/12 21:42:48 |
version 1.37, 2002/12/14 04:40:55 |
|
|
* http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
*/ |
*/ |
|
|
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.35 2002/12/11 23:41:54 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.36 2002/12/12 21:42:48 nepto Exp $ */ |
|
|
/* phpMyEdit intro {{{ */ |
/* phpMyEdit intro {{{ */ |
/* |
/* |
|
|
var $fds; // sql field names |
var $fds; // sql field names |
var $num_fds; // number of fields |
var $num_fds; // number of fields |
|
|
|
var $notify; // change notification e-mail adresses |
var $logtable; // name of optional logtable |
var $logtable; // name of optional logtable |
var $navigation; // navigation style |
var $navigation; // navigation style |
|
|
|
|
function debug_var($name, $val) /* {{{ */ |
function debug_var($name, $val) /* {{{ */ |
{ |
{ |
|
|
if (! is_array($ret)) { |
if (! is_array($ret)) { |
return $ret; |
return $ret; |
} |
} |
// XXX: temporary "Apply" keyword hack -- add it into lang files |
|
!isset($ret['Apply']) && $ret['Apply'] = 'Apply'; |
|
!isset($ret['of']) && $ret['of'] = '/'; |
|
$small = array( |
$small = array( |
'Search' => 'v', |
'Search' => 'v', |
'Hide' => '^', |
'Hide' => '^', |
|
|
if (! $this->displayed[$k] && $k != $this->key_num) |
if (! $this->displayed[$k] && $k != $this->key_num) |
continue; |
continue; |
if ($this->col_is_date($k)) { |
if ($this->col_is_date($k)) { |
|
//$fields[] = 'UNIX_TIMESTAMP('.$this->fqn($k).') AS qf'.$k; |
//$fields[] = 'DATE_FORMAT('.$this->fqn($k).',"%Y%m%d%H%i%s") AS qf'.$k; |
//$fields[] = 'DATE_FORMAT('.$this->fqn($k).',"%Y%m%d%H%i%s") AS qf'.$k; |
$fields[] = $this->fqn($k).' AS qf'.$k; |
$fields[] = $this->fqn($k).' AS qf'.$k; |
} else { |
} else { |
|
|
$qp = $this->query_opts; |
$qp = $this->query_opts; |
$where = array(); |
$where = array(); |
foreach ($qp as $field => $ov) { |
foreach ($qp as $field => $ov) { |
$where[] = sprintf('%s %s %s',$field,$ov['oper'],$ov['value']); |
$where[] = sprintf('%s %s %s', $field, $ov['oper'], $ov['value']); |
} |
} |
|
|
// Add any coder specified filters |
// Add any coder specified filters |
|
|
$qp = $this->query_opts; |
$qp = $this->query_opts; |
$where = array(); |
$where = array(); |
foreach ($qp as $field => $ov) { |
foreach ($qp as $field => $ov) { |
$where[] = sprintf('%s %s %s',$field,$ov['oper'],$ov['value']); |
$where[] = sprintf('%s %s %s', $field, $ov['oper'], $ov['value']); |
} |
} |
|
|
if (count($where) > 0) |
if (count($where) > 0) |
return str_replace('%','*',join(' AND ',$where)); |
return str_replace('%', '*', join(' AND ',$where)); |
|
|
return false; |
return false; |
} /* }}} */ |
} /* }}} */ |
|
|
$dont_desc = isset($this->fdd[$k]['values']['description']); |
$dont_desc = isset($this->fdd[$k]['values']['description']); |
$dont_cols = isset($this->fdd[$k]['values']['column']); |
$dont_cols = isset($this->fdd[$k]['values']['column']); |
$qo[$this->fqn($k, false, $dont_desc, $dont_cols)] = |
$qo[$this->fqn($k, false, $dont_desc, $dont_cols)] = |
array( 'oper' => $qf_op, 'value' => '('.$qf_val.')'); |
array('oper' => $qf_op, 'value' => '('.$qf_val.')'); |
} |
} |
} else { |
} else { |
$afilter = $m; |
$afilter = addslashes($m); |
if ($afilter != '*') { |
if ($afilter != '*') { |
/* XXX: This is ugly fqn() hack. We must pass third |
/* XXX: This is ugly fqn() hack. We must pass third |
$dont_desc parameter to fqn() method, as far as we |
$dont_desc parameter to fqn() method, as far as we |
|
|
} elseif ($this->col_is_string($k)) { |
} elseif ($this->col_is_string($k)) { |
// massage the filter for a string comparison |
// massage the filter for a string comparison |
if (($afilter != '') AND ($afilter != '*')) { |
if (($afilter != '') AND ($afilter != '*')) { |
$afilter = addslashes(addslashes('%' |
$afilter = '%'.str_replace('*', '%', $afilter).'%'; |
.str_replace('*', '%', $afilter).'%')); |
|
$qo[$this->fqn($k)] = |
$qo[$this->fqn($k)] = |
array('oper' => 'like', 'value' => "'".$afilter."'"); |
array('oper' => 'like', 'value' => "'".$afilter."'"); |
} |
} |
|
|
#} |
#} |
# massage the filter for a string comparison |
# massage the filter for a string comparison |
if (($afilter != '') AND ($afilter != '*')) { |
if (($afilter != '') AND ($afilter != '*')) { |
$afilter = addslashes(addslashes('%' |
$afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
.str_replace ('*', '%', $afilter).'%')); |
|
$qo[$this->fqn($k)] = |
$qo[$this->fqn($k)] = |
array('oper' => 'like', 'value' => "'".$afilter."'"); |
array('oper' => 'like', 'value' => "'".$afilter."'"); |
} |
} |
|
|
$qo[$this->fqn($k)] = |
$qo[$this->fqn($k)] = |
array( 'oper' => '=', 'value' => "'".$afilter."'"); |
array( 'oper' => '=', 'value' => "'".$afilter."'"); |
} else { |
} else { |
// unknown (to mysql/php interface) field type massage the filter for a string comparison |
// unknown (to mysql/php interface) field type |
$afilter = addslashes(addslashes('%'.str_replace ('*', '%', $afilter).'%')); |
// message the filter for a string comparison |
|
$afilter = '%'.str_replace ('*', '%', $afilter).'%'; |
$qo[$this->fqn($k)] = |
$qo[$this->fqn($k)] = |
array('oper' => 'like', 'value' => "'".$afilter."'"); |
array('oper' => 'like', 'value' => "'".$afilter."'"); |
} |
} |
|
|
|
|
if (! isset($options)) |
if (! isset($options)) |
return true; |
return true; |
if ($this->hidden($k)) |
#if ($this->hidden($k)) |
return false; |
# return false; |
|
|
return |
return |
($this->add_operation() && stristr($options, 'A')) || |
($this->add_operation() && stristr($options, 'A')) || |
Line 802 function form_control(theForm) |
|
Line 801 function form_control(theForm) |
|
function display_add_record() /* {{{ */ |
function display_add_record() /* {{{ */ |
{ |
{ |
if (0) { // XXX: WTF? |
if (0) { // XXX: WTF? |
echo ' <tr>'."\n"; |
echo '<tr>'."\n"; |
echo ' <th>Field</th>'."\n"; |
echo '<th>Field</th>'."\n"; |
echo ' <th>Value</th>'."\n"; |
echo '<th>Value</th>'."\n"; |
if ($this->guidance) |
if ($this->guidance) |
echo ' <th>Guidance</th>'."\n"; |
echo '<th>Guidance</th>'."\n"; |
echo ' </tr>'."\n"; |
echo '</tr>'."\n"; |
} |
} |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
Line 816 function form_control(theForm) |
|
Line 815 function form_control(theForm) |
|
echo '<tr>'."\n"; |
echo '<tr>'."\n"; |
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
|
|
if ($this->fdd[$k]['select'] != 'M') { $a=''; } |
if ($this->col_has_values($k) && !$this->readonly($k)) { |
else { $a = ' multiple size="'.$this->multiple.'"'; } |
echo '<td>' ."\n"; |
if ($this->col_has_values($k)) { |
|
echo ' <td>' ."\n"; |
|
$vals = isset($this->fdd[$k]['values']['table']) |
$vals = isset($this->fdd[$k]['values']['table']) |
? $this->set_values_from_table($k) |
? $this->set_values_from_table($k) |
: (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values']; |
: (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values']; |
echo $this->htmlSelect($this->fds[$k], $vals, '', $this->col_is_set($k)); |
echo $this->htmlSelect($this->fds[$k], $vals, '', $this->col_is_set($k)); |
echo '</td>'."\n"; |
echo '</td>'."\n"; |
} elseif (isset ($this->fdd[$k]['textarea'])) { |
} elseif (isset ($this->fdd[$k]['textarea']) && !$this->readonly($k)) { |
echo '<td><textarea '; |
echo '<td><textarea '; |
if (isset ($this->fdd[$k]['textarea']['rows'])) { |
if (isset ($this->fdd[$k]['textarea']['rows'])) { |
echo 'rows="'.$this->fdd[$k]['textarea']['rows'].'" '; |
echo 'rows="'.$this->fdd[$k]['textarea']['rows'].'" '; |
Line 840 function form_control(theForm) |
|
Line 837 function form_control(theForm) |
|
echo '</textarea></td>'."\n"; |
echo '</textarea></td>'."\n"; |
} else { |
} else { |
// Simple edit box required |
// Simple edit box required |
$type = $this->fdd[$k]['type']; |
|
echo '<td>'; |
echo '<td>'; |
if ($this->readonly($k)) { |
$size_ml_props = ''; |
echo $this->htmlDisplay($this->fdd[$k], '', false, false, false) |
if ($this->fdd[$k]['type'] != 'blob') { |
.'<input type="hidden" name="' |
$maxlen = intval($this->fdd[$k]['maxlen']); |
.$this->fds[$k] |
$maxlen > 0 || $maxlen = 300; |
.'" value="' |
$size = min($maxlen, 60); |
.$this->htmlDisplay($this->fdd[$k], $this->fdd[$k]['default'], |
$size && $size_ml_props .= ' size="'.$size.'"'; |
|
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
|
} |
|
if ($this->col_is_string($k) || $this->col_is_number($k)) { |
|
// string type |
|
echo '<input type="text" '.($this->readonly($k)?'disabled ':'') |
|
.' name="'.$this->fds[$k].'"'.$size_ml_props.' value="' |
|
.$this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'], |
|
false, false, false) |
|
.'">'; |
|
} elseif ($this->col_is_date($k)) { |
|
// date type, get date components |
|
//if ($this->fdd[$k]['default']) |
|
// $value = $this->mdate_set($this->fdd[$k]['default'],$this->fdd[$k]['type']); |
|
//$value = time(); |
|
//echo $this->mdate_disperse($k,$value,true); |
|
// string type |
|
echo '<input type="text" '.($this->readonly($k)?'disabled ':'') |
|
.' name="'.$this->fds[$k].'"'.$size_ml_props.' value="' |
|
.$this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'], |
false, false, false) |
false, false, false) |
.'" /> '; |
.'">'; |
} else { |
} else { |
$size_ml_props = ''; |
// unknown type |
if ($this->fdd[$k]['type'] != 'blob') { |
echo '<input type="text" '.($this->readonly($k)?'disabled ':'') |
$maxlen = intval($this->fdd[$k]['maxlen']); |
.' name="'.$this->fds[$k].'" value="' |
$maxlen > 0 || $maxlen = 300; |
.$this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'], |
$size = min($maxlen, 60); |
false, false, false) |
$size && $size_ml_props .= ' size="'.$size.'"'; |
.'">'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
|
} |
|
if ($this->col_is_string($k) || $this->col_is_number($k)) { |
|
// string type |
|
echo '<input type="text" name="'.$this->fds[$k].'"' |
|
.$size_ml_props.' value="' |
|
.$this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'], |
|
false, false, false) |
|
.'">'; |
|
} elseif ($this->col_is_date($k)) { |
|
// date type, get date components |
|
//if ($this->fdd[$k]['default']) |
|
// $value = $this->mdate_set($this->fdd[$k]['default'],$this->fdd[$k]['type']); |
|
//$value = time(); |
|
//echo $this->mdate_disperse($k,$value,true); |
|
// string type |
|
echo '<input type="text" name="'.$this->fds[$k].'"' |
|
.$size_ml_props.' value="' |
|
.$this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'], |
|
false, false, false) |
|
.'">'; |
|
} else { |
|
// unknown type |
|
echo '<input type="text" name="'.$this->fds[$k].'" value="' |
|
.$this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'], |
|
false, false, false) |
|
.'" />'; |
|
} |
|
} |
} |
echo '</td>'; |
echo '</td>'; |
} // if elseif else |
} |
if ($this->guidance) { |
if ($this->guidance) { |
if ($this->fdd[$k]['help']) |
if ($this->fdd[$k]['help']) |
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
|
else |
|
echo '<td> </td>'."\n"; |
} |
} |
echo '</tr>'."\n"; |
echo '</tr>'."\n"; |
} // for() |
} |
} // display_add_record /* }}} */ |
} /* }}} */ |
|
|
function display_copy_change_delete_record() /* {{{ */ |
function display_copy_change_delete_record() /* {{{ */ |
{ |
{ |
/* |
/* |
* for delete or change: SQL SELECT to retrieve the selected record |
* For delete or change: SQL SELECT to retrieve the selected record |
*/ |
*/ |
|
|
$qparts['type'] = 'select'; |
$qparts['type'] = 'select'; |
Line 909 function form_control(theForm) |
|
Line 898 function form_control(theForm) |
|
.$this->key_delim.$this->rec.$this->key_delim.')'; |
.$this->key_delim.$this->rec.$this->key_delim.')'; |
|
|
$res = $this->myquery($this->query_make($qparts),__LINE__); |
$res = $this->myquery($this->query_make($qparts),__LINE__); |
if ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) { |
if (! ($row = @mysql_fetch_array($res, MYSQL_ASSOC))) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
return false; |
if ($this->copy_operation()) { |
} |
if ($this->displayed[$k]) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
echo '<tr>'; |
if ($this->copy_operation() || $this->change_operation()) { |
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
if ($this->hidden($k)) { |
if ($this->readonly($k)) { |
if ($k != $this->key_num) { |
echo $this->display_delete_field($row, $k); |
echo $this->htmlHidden($this->fds[$k], $this->htmlDisplay($this->fdd[$k], |
} elseif ($this->password($k)) { |
$row["qf$k"], false, true, false)); |
echo '<td><input type="password" name="'.$this->fds[$k] |
|
.'" value="'.$this->htmlDisplay($this->fdd[$k], $row["qf$k"], |
|
false, true, false) |
|
.'" /></td>'; |
|
} else { |
|
echo $this->display_change_field($row, $k); |
|
} |
|
if ($this->guidance) { |
|
if ($this->fdd[$k]['help']) |
|
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
|
else |
|
echo '<td> </td>'."\n"; |
|
} |
|
echo '</tr>'."\n"; |
|
} // if field displayed |
|
elseif ($this->hidden($k)) { |
|
if ($k != $this->key_num) { |
|
echo '<input type="hidden" name="'.$this->fds[$k] |
|
.'" value="'.$this->htmlDisplay($this->fdd[$k], $row["qf$k"], |
|
false, true, false) |
|
.'" />'."\n"; |
|
} |
|
} |
|
} elseif ($this->change_operation()) { |
|
if ($this->hidden($k)) { |
|
echo '<input type="hidden" name="'.$this->fds[$k] |
|
.'" value="'.$this->htmlDisplay($this->fdd[$k], $row["qf$k"], |
|
false, true, false) |
|
.'" />'."\n"; |
|
} elseif ($this->displayed[$k]) { |
|
echo '<tr>'."\n"; |
|
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
|
$this->display_change_field($row, $k); |
|
if ($this->guidance) { |
|
if ($this->fdd[$k]['help']) |
|
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
|
else |
|
echo '<td> </td>'."\n"; |
|
} |
|
echo '</tr>'."\n"; |
|
} |
|
} elseif ($this->delete_operation() || $this->view_operation()) { |
|
if ($this->displayed[$k]) { |
|
echo '<tr>'."\n"; |
|
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
|
$this->display_delete_field($row, $k); |
|
if ($this->guidance) |
|
if ($this->fdd[$k]['help']) |
|
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
|
else |
|
echo '<td> </td>'."\n"; |
|
echo '</tr>'."\n"; |
|
} |
} |
|
continue; |
} |
} |
} // for |
if (! $this->displayed[$k]) { |
} // if row |
continue; |
} // display_copy_change_delete_record /* }}} */ |
} |
|
echo '<tr>'; |
|
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
|
/* There are two possibilities of readonly fields handling: |
|
1. Display plain text |
|
2. Display disabled input field |
|
In all cases particular readonly field will NOT be saved. */ |
|
if (0 && $this->readonly($k)) { |
|
echo $this->display_delete_field($row, $k); |
|
} elseif ($this->password($k)) { |
|
echo $this->display_password_field($row, $k); |
|
} else { |
|
echo $this->display_change_field($row, $k); |
|
} |
|
if ($this->guidance) { |
|
if ($this->fdd[$k]['help']) |
|
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
|
else |
|
echo '<td> </td>'."\n"; |
|
} |
|
echo '</tr>'."\n"; |
|
} elseif ($this->delete_operation() || $this->view_operation()) { |
|
if (! $this->displayed[$k]) { |
|
continue; |
|
} |
|
echo '<tr>'."\n"; |
|
echo '<td>'.$this->fdd[$k]['name'].'</td>'."\n"; |
|
if ($this->password($k)) { |
|
echo '<td><i>'.$this->labels['hidden'].'</i></td>'; |
|
} else { |
|
$this->display_delete_field($row, $k); |
|
} |
|
if ($this->guidance) { |
|
if ($this->fdd[$k]['help']) |
|
echo '<td>'.$this->fdd[$k]['help'].'</td>'."\n"; |
|
else |
|
echo '<td> </td>'."\n"; |
|
} |
|
echo '</tr>'."\n"; |
|
} |
|
} |
|
} /* }}} */ |
|
|
function display_change_field($row, $k) /* {{{ */ |
function display_change_field($row, $k) /* {{{ */ |
{ |
{ |
echo '<td>'."\n"; |
echo '<td>'."\n"; |
|
|
if ($this->col_has_values($k)) { |
if ($this->col_has_values($k) && !$this->readonly($k)) { |
$vals = isset($this->fdd[$k]['values']['table']) |
$vals = isset($this->fdd[$k]['values']['table']) |
? $this->set_values_from_table($k) |
? $this->set_values_from_table($k) |
: (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values']; |
: (array) $this->fdd[$k]['values2'] + (array) $this->fdd[$k]['values']; |
echo $this->htmlSelect($this->fds[$k], $vals, $row["qf$k"], $this->col_is_set($k)); |
echo $this->htmlSelect($this->fds[$k], $vals, $row["qf$k"], $this->col_is_set($k)); |
} elseif (isset($this->fdd[$k]['textarea'])) { |
} elseif (isset($this->fdd[$k]['textarea']) && !$this->readonly($k)) { |
echo '<textarea name="'.$this->fds[$k].'"'; |
echo '<textarea name="'.$this->fds[$k].'"'; |
// rows attr |
// rows attr |
if (isset($this->fdd[$k]['textarea']['rows'])) { |
if (isset($this->fdd[$k]['textarea']['rows'])) { |
Line 1045 function form_control(theForm) |
|
Line 1024 function form_control(theForm) |
|
echo "\n"; |
echo "\n"; |
} // if elseif else |
} // if elseif else |
echo '</td>'."\n"; |
echo '</td>'."\n"; |
} // display_change_field($row, $k) /* }}} */ |
} /* }}} */ |
|
|
|
function display_password_field($row, $k) /* {{{ */ |
|
{ |
|
echo '<td>'."\n"; |
|
$size_ml_props = ''; |
|
if ($this->fdd[$k]['type'] != 'blob') { |
|
$maxlen = intval($this->fdd[$k]['maxlen']); |
|
$maxlen > 0 || $maxlen = 300; |
|
$size = min($maxlen, 60); |
|
$size && $size_ml_props .= ' size="'.$size.'"'; |
|
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
|
} |
|
echo '<input type="password" '.($this->readonly($k)?'disabled ':'') |
|
.'name="'.$this->fds[$k].'" value="' |
|
.$this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false) |
|
.'" '.$size_ml_props.'>'; |
|
echo '</td>'."\n"; |
|
} /* }}} */ |
|
|
function display_delete_field($row, $k) /* {{{ */ |
function display_delete_field($row, $k) /* {{{ */ |
{ |
{ |
echo '<td>'; |
echo '<td>'; |
Line 1059 function form_control(theForm) |
|
Line 1056 function form_control(theForm) |
|
echo '</td>'."\n"; |
echo '</td>'."\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
function htmlHidden($name,$value) /* {{{ */ |
/** |
|
* Creates HTML hidden input element |
|
* |
|
* @param name element name |
|
* @param value value |
|
*/ |
|
function htmlHidden($name, $value) /* {{{ */ |
{ |
{ |
return '<input type=hidden name="'.htmlspecialchars($name) |
// Here are purpously not used htmlspecialchars() |
.'" value="'.htmlspecialchars($value).'">'."\n"; |
return '<input type=hidden name="'.$name.'" value="'.$value.'">'."\n"; |
} /* }}} */ |
} /* }}} */ |
|
|
/** |
/** |
Line 1125 function form_control(theForm) |
|
Line 1128 function form_control(theForm) |
|
$disallow_empty = true, |
$disallow_empty = true, |
$escape = true) |
$escape = true) |
{ |
{ |
// undo the add slashes |
|
$str = stripslashes($str); |
|
|
|
// if there's a field mask, use it as first arg to sprintf |
// if there's a field mask, use it as first arg to sprintf |
if (isset($field['mask']) && $usemask) { |
if (isset($field['mask']) && $usemask) { |
$str = sprintf($field['mask'], $str); |
$str = sprintf($field['mask'], $str); |
Line 1450 function form_control(theForm) |
|
Line 1450 function form_control(theForm) |
|
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:0;">'; |
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border:0;">'; |
echo '<tr><td align="left" style="text-align:left;border:0;">' . "\n"; |
echo '<tr><td align="left" style="text-align:left;border:0;">' . "\n"; |
if ($this->change_operation()) { |
if ($this->change_operation()) { |
echo '<input type="submit" name="savechange" value="'.$this->labels['Save'].'" />'."\n"; |
echo '<input type="submit" name="savechange" value="'.$this->labels['Save'].'">'."\n"; |
echo '<input type="submit" name="morechange" value="'.$this->labels['Apply'].'" />'."\n"; |
echo '<input type="submit" name="morechange" value="'.$this->labels['Apply'].'">'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();">'."\n"; |
} elseif ($this->add_operation()) { |
} elseif ($this->add_operation()) { |
echo '<input type="submit" name="saveadd" value="'.$this->labels['Save'].'" />'."\n"; |
echo '<input type="submit" name="saveadd" value="'.$this->labels['Save'].'">'."\n"; |
echo '<input type="submit" name="moreadd" value="'.$this->labels['More'].'" />'."\n"; |
echo '<input type="submit" name="moreadd" value="'.$this->labels['More'].'">'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();">'."\n"; |
} elseif ($this->copy_operation()) { |
} elseif ($this->copy_operation()) { |
echo '<input type="submit" name="saveadd" value="'.$this->labels['Save'].'" />'."\n"; |
echo '<input type="submit" name="saveadd" value="'.$this->labels['Save'].'">'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n"; |
echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();">'."\n"; |
} elseif ($this->delete_operation()) { |
} elseif ($this->delete_operation()) { |
echo '<input type="submit" name="savedelete" value="'.$this->labels['Delete'].'" />'."\n"; |
echo '<input type="submit" name="savedelete" value="'.$this->labels['Delete'].'">'."\n"; |
echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'" />'."\n"; |
echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'">'."\n"; |
} elseif ($this->view_operation()) { |
} elseif ($this->view_operation()) { |
if ($this->change_enabled()) { |
if ($this->change_enabled()) { |
echo '<input type="submit" name="operation" value="'.$this->labels['Change'].'" />'."\n"; |
echo '<input type="submit" name="operation" value="'.$this->labels['Change'].'">'."\n"; |
} |
} |
echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'" />'."\n"; |
echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'">'."\n"; |
} |
} |
// Message is now written here |
// Message is now written here |
echo '</td><td align="center" style="text-align:center;border:0;" ><b>'.$this->message.'</b></td>'; |
echo '</td><td align="center" style="text-align:center;border:0;" ><b>'.$this->message.'</b></td>'; |
Line 1518 function form_control(theForm) |
|
Line 1518 function form_control(theForm) |
|
'%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E'); |
'%3D'=>'%3D','%3E%3D'=>'%3E%3D','%3E'=>'%3E'); |
echo '<form action="'.$this->page_name.'" method="POST">'."\n"; |
echo '<form action="'.$this->page_name.'" method="POST">'."\n"; |
$this->write_origvars_html($this->get_sfn_cgi_vars()); |
$this->write_origvars_html($this->get_sfn_cgi_vars()); |
echo '<input type="hidden" name="fl" value="'.$this->fl.'" />'."\n"; |
echo '<input type="hidden" name="fl" value="'.$this->fl.'">'."\n"; |
|
|
$prev_qfn = $this->qfn; |
$prev_qfn = $this->qfn; |
$hidden_qfs = $this->get_qf_hidden_fields(); |
$hidden_qfs = $this->get_qf_hidden_fields(); |
Line 1581 function form_control(theForm) |
|
Line 1581 function form_control(theForm) |
|
if ($this->filter_enabled()) { |
if ($this->filter_enabled()) { |
if ($this->fl) { |
if ($this->fl) { |
echo '<input type=submit name=sw value="'.$this->labels['Hide'].'">'; |
echo '<input type=submit name=sw value="'.$this->labels['Hide'].'">'; |
echo '<input type=submit name=sw value="'.$this->labels['Clear'].'"><br>'; |
echo '<input type=submit name=sw value="'.$this->labels['Clear'].'">'; |
//echo '<input type=submit name=filter value="'.$this->labels['Query'].'">'; |
|
} else { |
} else { |
echo '<input type=submit name=sw value="'.$this->labels['Search'].'">'; |
echo '<input type=submit name=sw value="'.$this->labels['Search'].'">'; |
} |
} |
Line 1664 function form_control(theForm) |
|
Line 1663 function form_control(theForm) |
|
$this->fdd[$field]['expression'] && $sort_field_w .= ' (expression)'; |
$this->fdd[$field]['expression'] && $sort_field_w .= ' (expression)'; |
if ($desc) { |
if ($desc) { |
$sort_field .= ' DESC'; |
$sort_field .= ' DESC'; |
$sort_field_w .= ' descending'; |
$sort_field_w .= ' '.$this->labels['descending']; |
|
} else { |
|
$sort_field_w .= ' '.$this->labels['ascending']; |
} |
} |
//$raw_sort_fields[] = $raw_sort_field; |
//$raw_sort_fields[] = $raw_sort_field; |
$sort_fields[] = $sort_field; |
$sort_fields[] = $sort_field; |
Line 1681 function form_control(theForm) |
|
Line 1682 function form_control(theForm) |
|
$qparts['limit'] = $this->fm.','.$this->inc; |
$qparts['limit'] = $this->fm.','.$this->inc; |
} |
} |
|
|
if ($qparts['orderby'] && $this->display['sort']) { |
|
// XXX this doesn't preserve filters |
|
echo '<tr>'; |
|
if (isset($this->sfn)) { |
|
$cgi_persist = $this->cgi['persist']; |
|
$cgi_persist != '' && $cgi_persist[0] = '?'; |
|
echo '<td align="center">' |
|
.'<a class="pme_a_t" href="'.$PHP_SELF.$cgi_persist,'">' |
|
.$this->labels['Clear'].'</a>'.'</td>'; |
|
echo '<td colspan="'.($this->num_fields_displayed + $sys_cols - 1).'">Sorted By: '; |
|
} else { |
|
echo '<td colspan="'.($this->num_fields_displayed + $sys_cols).'">Default Sort Order: '; |
|
} |
|
echo join(', ',$sort_fields_w); |
|
echo '</td></tr>'."\n"; |
|
} |
|
|
|
/* |
/* |
* Main list_table() query |
* Main list_table() query |
* |
* |
Line 1720 function form_control(theForm) |
|
Line 1704 function form_control(theForm) |
|
echo '<tr>'; |
echo '<tr>'; |
echo '<td colspan='.$sys_cols.' align="center">'; |
echo '<td colspan='.$sys_cols.' align="center">'; |
echo '<input type="submit" name="filter" value="' |
echo '<input type="submit" name="filter" value="' |
.$this->labels['Query'].'" /></td>'."\n"; |
.$this->labels['Query'].'"></td>'."\n"; |
|
|
/* Variable $fields is used to get index of particular field in |
/* Variable $fields is used to get index of particular field in |
result. That index can be passed in example to mysql_field_len() |
result. That index can be passed in example to mysql_field_len() |
Line 1784 function form_control(theForm) |
|
Line 1768 function form_control(theForm) |
|
if ($this->col_is_string($k)) { |
if ($this->col_is_string($k)) { |
// it's treated as a string |
// it's treated as a string |
echo '<input type="text" name="qf'.$k.'"'; |
echo '<input type="text" name="qf'.$k.'"'; |
echo ' value="'.stripslashes($m).'"'.$size_ml_props.'>'; |
echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
} elseif ($this->col_is_date($k)) { |
} elseif ($this->col_is_date($k)) { |
// it's a date |
// it's a date |
//echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc); |
//echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc); |
Line 1802 function form_control(theForm) |
|
Line 1786 function form_control(theForm) |
|
//} |
//} |
// it's treated as a string |
// it's treated as a string |
echo '<input type="text" name="qf'.$k.'"'; |
echo '<input type="text" name="qf'.$k.'"'; |
echo ' value="'.stripslashes($m).'"'.$size_ml_props.'>'; |
echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
} elseif ($this->col_is_number($k)) { |
} elseif ($this->col_is_number($k)) { |
// it's a number |
// it's a number |
echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc); |
echo $this->htmlSelect($l.'_comp',$comp_ops,$$lc); |
// it's treated as a string |
// it's treated as a string |
echo '<input type="text" name="qf'.$k.'"' |
echo '<input type="text" name="qf'.$k.'"' |
.' value="'.$m.'"'.$size_ml_props.'>'; |
.' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
} else { |
} else { |
// type is 'unknown' or not set, it's treated as a string |
// type is 'unknown' or not set, it's treated as a string |
echo '<input type="text" name="qf'.$k.'"'; |
echo '<input type="text" name="qf'.$k.'"'; |
echo ' value="'.stripslashes($m).'"'.$size_ml_props.'>'; |
echo ' value="'.htmlspecialchars($m).'"'.$size_ml_props.'>'; |
} |
} |
} else { |
} else { |
echo " "; |
echo ' '; |
} |
} |
|
|
// if it's int or real and if not password or hidden, display aggr options |
// if it's int or real and if not password or hidden, display aggr options |
Line 1850 function form_control(theForm) |
|
Line 1834 function form_control(theForm) |
|
} // for |
} // for |
echo '</tr>'."\n"; |
echo '</tr>'."\n"; |
} |
} |
|
|
|
/* |
|
* Display sorting sequence |
|
*/ |
|
|
|
if ($qparts['orderby'] && $this->display['sort']) { |
|
$cgi_persist = $this->cgi['persist']; |
|
$cgi_persist != '' && $cgi_persist[0] = '?'; |
|
echo '<tr><td colspan='.$sys_cols.' align="center">' |
|
.'<a class="pme_a_t" href="'.$PHP_SELF.$cgi_persist,'">' |
|
.$this->labels['Clear'].'</a></td>'; |
|
echo '<td colspan="'.$this->num_fields_displayed.'">' |
|
.$this->labels['Sorted By'].': <i>' |
|
.join(', ', $sort_fields_w).'</i></td></tr>'."\n"; |
|
} |
|
|
/* |
/* |
* Display the current query |
* Display the current query |
*/ |
*/ |
|
|
$text_query = $this->make_text_where_from_query_opts(); |
$text_query = $this->make_text_where_from_query_opts(); |
if ($text_query != '' && $this->display['query']) { |
if ($text_query != '' && $this->display['query']) { |
echo '<tr><td colspan='.$sys_cols.' align="center">' |
echo '<tr><td colspan='.$sys_cols.' align="center">' |
.'<a class="pme_a_t" href="'.$PHP_SELF; |
.'<a class="pme_a_t" href="'.$PHP_SELF |
echo '?sfn='.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm; |
.'?sfn='.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm |
echo $this->cgi['persist'].'">'.$this->labels['Clear'].'</a></td>'; |
.$this->cgi['persist'].'">'.$this->labels['Clear'].'</a></td>'; |
echo '<td colspan="'.$this->num_fields_displayed.'">Current Query: ' |
echo '<td colspan="'.$this->num_fields_displayed.'">' |
.htmlspecialchars(stripslashes(stripslashes(stripslashes($text_query)))) |
.$this->labels['Current Query'].': <i>' |
.'</td></tr>'."\n"; |
.htmlspecialchars($text_query).'</i></td></tr>'."\n"; |
} |
} |
|
|
if ($this->nav_text_links() || $this->nav_graphic_links()) { |
if ($this->nav_text_links() || $this->nav_graphic_links()) { |
Line 2015 function form_control(theForm) |
|
Line 2015 function form_control(theForm) |
|
.'&qfn='.$this->qfn; |
.'&qfn='.$this->qfn; |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
$fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
if ($this->hidden($k) || $this->password($k)) { |
if (! $this->displayed[$k]) { |
continue; |
continue; |
} elseif (! $this->displayed[$k]) { |
} |
|
if ($this->hidden($k) || $this->password($k)) { |
|
echo '<td><i>'.$this->labels['hidden'].'</i></td>'."\n"; |
continue; |
continue; |
} |
} |
// XXX: echo 'displayed: '.$k.'-'.$fd; |
// XXX: echo 'displayed: '.$k.'-'.$fd; |
Line 2025 function form_control(theForm) |
|
Line 2027 function form_control(theForm) |
|
/* TODO: what's this?! |
/* TODO: what's this?! |
|
|
if ((trim($row[$k]) == '') or ($row[$k] == 'NULL')) { |
if ((trim($row[$k]) == '') or ($row[$k] == 'NULL')) { |
echo ' <td> </td>'."\n"; |
echo '<td> </td>'."\n"; |
} else { */ |
} else { */ |
|
|
// display the contents |
// display the contents |
Line 2037 function form_control(theForm) |
|
Line 2039 function form_control(theForm) |
|
if (isset($this->fdd[$fd]['width'])) { |
if (isset($this->fdd[$fd]['width'])) { |
$colattrs .= ' width="'.$this->fdd[$fd]['width'].'"'; |
$colattrs .= ' width="'.$this->fdd[$fd]['width'].'"'; |
} |
} |
echo ' <td'.$colattrs.'>'; |
echo '<td'.$colattrs.'>'; |
if (! $this->hidden($k) && ! $this->password($k)) { |
// displayable |
// displayable |
if (isset($this->fdd[$k]['URL']) |
if (isset($this->fdd[$k]['URL']) |
|| isset($this->fdd[$k]['URLprefix']) |
|| isset($this->fdd[$k]['URLprefix']) |
|| isset($this->fdd[$k]['URLpostfix'])) { |
|| isset($this->fdd[$k]['URLpostfix'])) { |
/* It's an URL |
/* It's an URL |
Put some conveniences in the namespace for the user |
Put some conveniences in the namespace for the user |
to be able to use in the URL string. */ |
to be able to use in the URL string. */ |
$key = $key_rec; |
$key = $key_rec; |
$name = $this->fds[$k]; |
$name = $this->fds[$k]; |
$value = $row["qf$k"]; |
$value = $row["qf$k"]; |
$page = $this->page_name; |
$page = $this->page_name; |
$urlstr = $urlqueryproto.'&rec='.$key.$this->cgi['persist']; |
$urlstr = $urlqueryproto.'&rec='.$key.$this->cgi['persist']; |
$urllink = isset($this->fdd[$k]['URL']) |
$urllink = isset($this->fdd[$k]['URL']) |
? eval('return "'.$this->fdd[$k]['URL'].'";') |
? eval('return "'.$this->fdd[$k]['URL'].'";') |
: $value; |
: $value; |
$urldisp = isset($this->fdd[$k]['URLdisp']) |
$urldisp = isset($this->fdd[$k]['URLdisp']) |
? eval('return "'.$this->fdd[$k]['URLdisp'].'";') |
? eval('return "'.$this->fdd[$k]['URLdisp'].'";') |
: $value; |
: $value; |
$target = isset($this->fdd[$k]['URLtarget']) |
$target = isset($this->fdd[$k]['URLtarget']) |
? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" ' |
? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" ' |
: ''; |
: ''; |
isset($this->fdd[$k]['URLprefix']) && $urllink = $this->fdd[$k]['URLprefix'].$urllink; |
isset($this->fdd[$k]['URLprefix']) && $urllink = $this->fdd[$k]['URLprefix'].$urllink; |
isset($this->fdd[$k]['URLpostfix']) && $urllink .= $this->fdd[$k]['URLpostfix']; |
isset($this->fdd[$k]['URLpostfix']) && $urllink .= $this->fdd[$k]['URLpostfix']; |
if (strlen($urllink) <= 0 || strlen($urldisp) <= 0) { |
if (strlen($urllink) <= 0 || strlen($urldisp) <= 0) { |
echo ' '; |
echo ' '; |
} else { |
} else { |
$urllink = htmlspecialchars($urllink); |
$urllink = htmlspecialchars($urllink); |
$urldisp = htmlspecialchars($urldisp); |
$urldisp = htmlspecialchars($urldisp); |
echo '<a '.$target.'class="pme_a_u" href="'.$urllink.'">'.$urldisp.'</a>'; |
echo '<a '.$target.'class="pme_a_u" href="'.$urllink.'">'.$urldisp.'</a>'; |
} |
} |
} elseif (isset($this->fdd[$k]['datemask'])) { |
} elseif (isset($this->fdd[$k]['datemask'])) { |
// display date according to a mask if any |
// display date according to a mask if any |
//echo $this->mdate_set($row[$k],$this->fdd[$k]['type'],$this->fdd[$k]['datemask']); |
//echo $this->mdate_set($row[$k],$this->fdd[$k]['type'],$this->fdd[$k]['datemask']); |
//echo |
//echo |
// $this->mdate_displayPlain( |
// $this->mdate_displayPlain( |
// $this->mdate_from_mysql( |
// $this->mdate_from_mysql( |
// $row[$k]), |
// $row[$k]), |
// ( |
// ( |
// $this->fdd[$k]['datemask']? |
// $this->fdd[$k]['datemask']? |
// $this->fdd[$k]['datemask'] |
// $this->fdd[$k]['datemask'] |
// : |
// : |
// $this->mdate_masks[$this->fdd[$k]['type']] |
// $this->mdate_masks[$this->fdd[$k]['type']] |
// ) |
// ) |
// ); |
// ); |
//echo $row[$k]; |
//echo $row[$k]; |
// it's a normal field |
// it's a normal field |
$shortdisp = $row["qf$k"]; |
|
if ($this->fdd[$k]['strip_tags']) { |
|
$shortdisp = strip_tags($shortdisp); |
|
} |
|
if (isset($this->fdd[$k]['trimlen']) |
|
&& strlen($shortdisp) > $this->fdd[$k]['trimlen']) { |
|
$shortdisp = ereg_replace("[\r\n\t ]+", ' ', $shortdisp); |
|
$shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...'; |
|
} |
|
echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp)); |
|
} else { |
|
// it's a normal field |
|
if ($this->is_values2($k, $row["qf$k"])) { |
|
$escape_flag = false; |
|
$shortdisp = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']]; |
|
} else { |
|
$escape_flag = true; |
$shortdisp = $row["qf$k"]; |
$shortdisp = $row["qf$k"]; |
if ($this->fdd[$k]['strip_tags']) { |
if ($this->fdd[$k]['strip_tags']) { |
$shortdisp = strip_tags($shortdisp); |
$shortdisp = strip_tags($shortdisp); |
} |
} |
if (isset($this->fdd[$k]['trimlen']) |
if (isset($this->fdd[$k]['trimlen']) |
&& strlen($shortdisp) > $this->fdd[$k]['trimlen']) { |
&& strlen($shortdisp) > $this->fdd[$k]['trimlen']) { |
$shortdisp = ereg_replace("[\r\n\t ]+", ' ', $shortdisp); |
$shortdisp = ereg_replace("[\r\n\t ]+",' ',$shortdisp); |
$shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...'; |
$shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...'; |
} |
} |
echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp)); |
|
} else { |
|
// it's a normal field |
|
if ($this->is_values2($k, $row["qf$k"])) { |
|
$escape_flag = false; |
|
$shortdisp = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']]; |
|
} else { |
|
$escape_flag = true; |
|
$shortdisp = $row["qf$k"]; |
|
if ($this->fdd[$k]['strip_tags']) { |
|
$shortdisp = strip_tags($shortdisp); |
|
} |
|
if (isset($this->fdd[$k]['trimlen']) |
|
&& strlen($shortdisp) > $this->fdd[$k]['trimlen']) { |
|
$shortdisp = ereg_replace("[\r\n\t ]+",' ',$shortdisp); |
|
$shortdisp = substr($shortdisp,0,$this->fdd[$k]['trimlen']-3).'...'; |
|
} |
|
} |
|
echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp, |
|
true, true, true, $escape_flag)); |
|
} |
} |
} else { |
echo nl2br($this->htmlDisplay($this->fdd[$k], $shortdisp, |
// it's hidden or a password |
true, true, true, $escape_flag)); |
echo '<i>hidden</i>'; |
|
} |
} |
echo '</td>'."\n"; |
echo '</td>'."\n"; |
} // for |
} // for |
|
|
echo ' </tr>'."\n"; |
echo '</tr>'."\n"; |
} // while |
} // while |
|
|
|
|
Line 2172 function form_control(theForm) |
|
Line 2169 function form_control(theForm) |
|
} |
} |
|
|
|
|
echo ' </table>'."\n"; // end of table rows listing |
echo '</table>'."\n"; // end of table rows listing |
|
|
|
|
if ($this->nav_down()) { |
if ($this->nav_down()) { |
Line 2214 function form_control(theForm) |
|
Line 2211 function form_control(theForm) |
|
echo $this->get_qf_hidden_fields(); |
echo $this->get_qf_hidden_fields(); |
echo '<input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'">'."\n"; |
echo '<input type="hidden" name="qfn" value="'.htmlspecialchars($this->qfn).'">'."\n"; |
|
|
/* |
|
$this->qfn = ''; |
|
for ($k = 0; $k < $this->num_fds; $k++) { |
|
$l = 'qf'.$k; |
|
$lc = 'qf'.$k.'_comp'; |
|
$$l = $this->get_cgi_var($l); |
|
$$lc = $this->get_cgi_var($lc); |
|
$m = $this->web2plain($$l); // get the field name and value |
|
$mc = $this->web2plain($$lc); // get the comparison operator for numeric/date types |
|
if (! isset($m)) { |
|
continue; |
|
} |
|
if (is_array($m)) { // multiple selection has been used |
|
if (!in_array('*',$m)) { // one '*' in a multiple selection is all you need |
|
for ($n=0; $n<count($m); $n++) { |
|
if ($this->plain2web($m[$n]) != '') { |
|
$this->qfn = $this->qfn.'&qf'.$k.'['.$n.']=' |
|
.$this->plain2web($m[$n]); } |
|
echo '<input type="hidden" name="qf'.$k.'['.$n.']" value="' |
|
.$this->plain2web($m[$n]).'">'."\n"; |
|
} |
|
} |
|
} |
|
} else { |
|
if ($this->plain2web($m) != '') { |
|
$this->qfn = $this->qfn.'&qf'.$k.'='.$m; |
|
echo '<input type="hidden" name="qf'.$k.'" value="'.$this->plain2web($m).'">'."\n"; |
|
} |
|
} |
|
} |
|
*/ |
|
|
|
if ($this->nav_up()) { |
if ($this->nav_up()) { |
$this->display_record_buttons(); |
$this->display_record_buttons(); |
echo '<hr>'."\n"; |
echo '<hr>'."\n"; |
Line 2275 function form_control(theForm) |
|
Line 2240 function form_control(theForm) |
|
$tib = true; |
$tib = true; |
// check for a before-add trigger |
// check for a before-add trigger |
if (isset($this->triggers['insert']['before'])) { |
if (isset($this->triggers['insert']['before'])) { |
$tib = include($this->triggers['insert']['before']); |
$tib = @include($this->triggers['insert']['before']); |
} |
} |
if ($tib) { |
if ($tib) { |
// before trigger returned good status let's do the main operation |
// before trigger returned good status let's do the main operation |
Line 2288 function form_control(theForm) |
|
Line 2253 function form_control(theForm) |
|
$key_col_val = addslashes($this->encode($this->fdd[$k],$fn)); |
$key_col_val = addslashes($this->encode($this->fdd[$k],$fn)); |
} |
} |
if ($qry == '') { |
if ($qry == '') { |
$qry = 'INSERT INTO '.$this->tb.' (`'.$fd.'`'; |
$qry = 'INSERT INTO '.$this->tb.' ('.$fd; // ) |
} else { |
} else { |
$qry = $qry.',`'.$fd.'`'; |
$qry .= ','.$fd; |
} |
} |
} |
} |
} |
} |
$tim = false; |
$tim = false; |
// do the main operation |
// do the main operation |
$val = ') VALUES ('; |
$vals = array(); |
$vals = array(); |
$vals_ori = array(); |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
$type = $this->fdd[$k]['type']; |
|
if ($this->processed($k)) { |
if ($this->processed($k)) { |
$fd = $this->fds[$k]; |
if ($this->readonly($k)) { |
$fn = $this->get_cgi_var($fd); |
$fn = (string) @$this->fdd[$k]['default']; |
/* |
|
if ($this->col_is_date($k)) |
|
{ |
|
//$vals[$k] = '"'.$this->mdate_set($this->mdate_getFromPost($k),$type,$this->fds[$k]['type']).'"'; |
|
if ($type == 'time') |
|
$vals[$k] = 'date_format(from_unixtime('.$this->mdate_getFromPost($k).'),"%H%i%s")'; |
|
elseif ($type == 'year') |
|
$vals[$k] = 'date_format(from_unixtime('.$this->mdate_getFromPost($k).'),"%Y")'; |
|
else |
|
$vals[$k] = 'from_unixtime('.$this->mdate_getFromPost($k).')'; |
|
} else // continued on next line |
|
*/ |
|
/* Old Jim code: $this->col_is_set($k) && $fn != ''*/ |
|
if (is_array($fn)) { |
|
$vals[$k] = "'".addslashes($this->encode($this->fdd[$k],join(',',$fn)))."'"; |
|
} else { |
} else { |
$vals[$k] = "'".addslashes($this->encode($this->fdd[$k],$fn))."'"; |
$fn = $this->get_cgi_var($this->fds[$k]); |
} |
} |
|
/* Old Jim code: $this->col_is_set($k) && $fn != ''*/ |
|
$vals_ori[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
|
$vals[$k] = "'".addslashes($this->encode($this->fdd[$k],$vals_ori[$this->fds[$k]]))."'"; |
} |
} |
} |
} |
$qry = $qry.$val.join(',',$vals).')'; |
$qry .= ') VALUES ('.join(',',$vals).')'; // ) |
$res = $this->myquery($qry,__LINE__); |
$res = $this->myquery($qry,__LINE__); |
if ($res) { |
if ($res) { |
$tim = true; |
$tim = true; |
} |
} |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added']; |
} |
} |
if ( |
if ($tib && $tim && isset($this->triggers['insert']['after'])) { |
$tib && |
|
isset($this->triggers['insert']['after']) && |
|
$tim |
|
) { |
|
// before executed ok |
// before executed ok |
// main op executed ok |
// main op executed ok |
// let's do the after trigger |
// let's do the after trigger |
$tia = include($this->triggers['insert']['after']); |
$tia = @include($this->triggers['insert']['after']); |
} |
} |
// notify list |
// Notify list |
$kv = array(); |
if (@$this->notify['insert'] || @$this->notify['all']) { |
if (($this->notify['insert'])) { |
$this->email_notify(false, $vals_ori); |
$user = $REMOTE_USER; |
|
if (! $user) |
|
$user = $REMOTE_ADDR; |
|
$body = 'A new item was added to '.$this->page_name." by ".$user." with the following fields:\n"; |
|
for ($k=0;$k<$this->num_fds;$k++) { |
|
if ($this->processed($k)) { |
|
$body .= $this->fdd[$k]['name'].': '.$vals[$k]."\n"; |
|
$kv[$this->fds[$k]] = $vals[$k]; |
|
} |
|
} |
|
// mail it |
|
mail($this->notify['insert'],'Record Added to '.$this->tb,$body); |
|
} |
} |
// note change in log table |
// Note change in log table |
if ($this->logtable) { |
if ($this->logtable) { |
$this->myquery( |
$qry = sprintf('INSERT INTO %s' |
"INSERT INTO ".$this->logtable." VALUES (". |
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)' |
"NOW(),". |
.' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")', |
"'".$REMOTE_USER."',". |
$this->logtable, addslashes($REMOTE_USER), addslashes($REMOTE_ADDR), |
"'".$REMOTE_ADDR."',". |
addslashes($this->tb), addslashes($key_col_val), |
"'insert','". |
addslashes(serialize($vals_ori))); |
$this->tb."',". |
$this->myquery($qry, __LINE__); |
"'".$key_col_val."','','','". |
|
addslashes(serialize($kv))."')" |
|
,__LINE__); |
|
} |
} |
} /* }}} */ |
} /* }}} */ |
|
|
Line 2379 function form_control(theForm) |
|
Line 2312 function form_control(theForm) |
|
$tub = true; |
$tub = true; |
// check for a before-add trigger |
// check for a before-add trigger |
if (isset($this->triggers['update']['before'])) { |
if (isset($this->triggers['update']['before'])) { |
$tub = include($this->triggers['update']['before']); |
$tub = @include($this->triggers['update']['before']); |
} |
} |
$tum = false; |
$tum = false; |
if ($tub) { |
if ($tub) { |
Line 2388 function form_control(theForm) |
|
Line 2321 function form_control(theForm) |
|
$qry = ''; |
$qry = ''; |
$qry_old_rec = ''; |
$qry_old_rec = ''; |
for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
$type = $this->fdd[$k]['type']; |
if ($this->processed($k) && !$this->readonly($k)) { |
if ($this->processed($k) && ! $this->readonly($k)) { |
|
$fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
if ($fd == $this->key) { |
if ($fd == $this->key) { |
$key_col_val = addslashes($this->get_cgi_var($fd)); |
$key_col_val = addslashes($this->get_cgi_var($fd)); |
} |
} |
$fn = $this->get_cgi_var($fd); |
$fn = $this->get_cgi_var($fd); |
/* |
|
if ($this->col_is_date($k)) |
|
{ |
|
$fn = date(str_replace('%','',$this->mdate_masks[$type]),$this->mdate_getFromPost($k)); |
|
} |
|
*/ |
|
/* Old Jim code: $this->col_is_set($k) && $fn != ''*/ |
/* Old Jim code: $this->col_is_set($k) && $fn != ''*/ |
if (is_array($fn)) { |
if (is_array($fn)) { |
$newValue = addslashes($this->encode($this->fdd[$k],join(',',$fn))); |
$newValue = addslashes($this->encode($this->fdd[$k],join(',',$fn))); |
Line 2408 function form_control(theForm) |
|
Line 2334 function form_control(theForm) |
|
$newValue = addslashes($this->encode($this->fdd[$k],$fn)); |
$newValue = addslashes($this->encode($this->fdd[$k],$fn)); |
} |
} |
if ($qry == '') { |
if ($qry == '') { |
$qry = 'UPDATE '.$this->tb.' SET `'.$fd.'`=\''.$newValue.'\''; |
$qry = 'UPDATE '.$this->tb.' SET '.$fd.'=\''.$newValue.'\''; |
$qry_old_rec = 'SELECT `'.$fd.'`'; |
$qry_old_rec = 'SELECT `'.$fd.'`'; |
} else { |
} else { |
$qry = $qry.',`'.$fd.'`=\''.$newValue.'\''; |
$qry .= ','.$fd.'=\''.$newValue.'\''; |
$qry_old_rec .= ',`'.$fd.'`'; |
$qry_old_rec .= ',`'.$fd.'`'; |
} |
} |
$newvalues[$this->fds[$k]] = addslashes($fn); |
$newvalues[$this->fds[$k]] = $fn; |
} elseif ($this->hidden($k)) { |
} elseif ($this->hidden($k)) { |
// XXX do something |
// XXX do something |
} |
} |
} |
} |
$qry = $qry.' WHERE ('.$this->key.' = '.$this->key_delim.$this->rec.$this->key_delim.')'; |
$where = " WHERE (".$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')'; |
$qry_old_rec .= ' FROM '.$this->tb.' WHERE ('.$this->key.' = '.$this->key_delim.$this->rec.$this->key_delim.')'; |
$qry .= $where; |
// get the old data |
$qry_old_rec .= ' FROM '.$this->tb.$where; |
|
// Get the old data |
$res_old = $this->myquery($qry_old_rec, __LINE__); |
$res_old = $this->myquery($qry_old_rec, __LINE__); |
$oldvalues = @mysql_fetch_array($res_old); |
$oldvalues = @mysql_fetch_array($res_old, MYSQL_ASSOC); |
// update the data |
// Update the data |
//echo "\n<h4>$qry</h4>\n"; |
$res = $this->myquery($qry, __LINE__); |
$res = $this->myquery($qry,__LINE__); |
// Find and accumulate the changes |
// find and accumulate the changes |
for ($k = 0; $k < $this->num_fds; $k++) { |
$changes=array(); |
if ($this->processed($k) && !$this->readonly($k)) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
if ($oldvalues[$this->fds[$k]] == $newvalues[$this->fds[$k]]) { |
if ($this->processed($k)) { |
// Removing the same values |
if ($oldvalues[$this->fds[$k]] != stripslashes($newvalues[$this->fds[$k]])) { |
unset($oldvalues[$this->fds[$k]]); |
$changes[$this->fds[$k]] = array(); |
unset($newvalues[$this->fds[$k]]); |
$changes[$this->fds[$k]]['was'] = $oldvalues[$this->fds[$k]]; |
} |
$changes[$this->fds[$k]]['is' ] = $newvalues[$this->fds[$k]]; |
} |
} |
|
} |
|
} |
} |
if ($res) { |
if ($res) { |
$tum = true; |
$tum = true; |
} |
} |
|
|
/* |
|
echo '<h3>Was:</h3>'."\n"; |
|
echo '<pre>'; |
|
print_r($oldvalues); |
|
echo '</pre>'."\n"; |
|
|
|
echo '<h3>Is:</h3>'."\n"; |
|
echo '<pre>'; |
|
print_r($newvalues); |
|
echo '</pre>'."\n"; |
|
|
|
echo '<h3>Changes to be sent in e-mail:</h3>'."\n"; |
|
echo '<pre>'; |
|
print_r($changes); |
|
echo '</pre>'."\n"; |
|
echo '<h5>'.@mysql_affected_rows($this->dbh).' '.$this->labels['Change'].'</h5>'."\n"; |
|
*/ |
|
|
|
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed']; |
} |
} |
if ( |
if ($tub && $tum && isset($this->triggers['update']['after'])) { |
$tub && |
|
isset($this->triggers['update']['after']) && |
|
$tum |
|
) { |
|
// before executed ok |
// before executed ok |
// main op executed ok |
// main op executed ok |
// let's do the after trigger |
// let's do the after trigger |
$tua = include($this->triggers['update']['after']); |
$tua = @include($this->triggers['update']['after']); |
} |
} |
// notify list |
// Notify list |
if (($this->notify['update'])) { |
if (@$this->notify['update'] || @$this->notify['all']) { |
if (count($changes) > 0) { |
$this->email_notify($oldvalues, $newvalues); |
$user = $REMOTE_USER; |
|
if (! $user) |
|
$user = $REMOTE_ADDR; |
|
$body = 'An item with ' |
|
.$this->fdd[$this->key]['name'] |
|
.'=' |
|
.$this->key_delim.$this->rec.$this->key_delim |
|
.' was updated by '.$user.' in '.$this->page_name." with the following fields:\n"; |
|
foreach ($changes as $key=>$vals) { |
|
if ($this->processed($k)) { |
|
$fieldName = $this->fdd[$key]['name']; |
|
$body .= |
|
$fieldName.":\n". |
|
"was:\t\"".$vals['was']."\"\n". |
|
"is:\t\"".$vals['is']."\"\n"; |
|
} |
|
} |
|
// mail it |
|
mail($this->notify['update'],'Record Updated in '.$this->tb,$body); |
|
} |
|
} |
} |
|
// Note change in log table |
// note change in log table |
|
if ($this->logtable) { |
if ($this->logtable) { |
foreach ($changes as $key=>$vals) { |
foreach (array_keys($newvalues) as $key) { |
$qry = "INSERT INTO ".$this->logtable." VALUES (". |
$qry = sprintf('INSERT INTO %s' |
"NOW(),'".$REMOTE_USER."','".$REMOTE_ADDR."','update','". |
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)' |
$this->tb."','".$key_col_val."','".$key."','". |
.' VALUES (NOW(), "%s", "%s", "update", "%s", "%s", "%s", "%s", "%s")', |
addslashes($vals['was'])."','". |
$this->logtable, addslashes($REMOTE_USER), addslashes($REMOTE_ADDR), |
addslashes($vals['is'])."')"; |
addslashes($this->tb), addslashes($key_col_val), addslashes($key), |
$this->myquery($qry,__LINE__); |
addslashes($oldvalues[$key]), addslashes($newvalues[$key])); |
|
$this->myquery($qry, __LINE__); |
} |
} |
} |
} |
} /* }}} */ |
} /* }}} */ |
Line 2537 echo '<h5>'.@mysql_affected_rows($this-> |
|
Line 2419 echo '<h5>'.@mysql_affected_rows($this-> |
|
|
|
if ($this->logtable) { |
if ($this->logtable) { |
$res = $this->myquery( |
$res = $this->myquery( |
'select * from '.$this->tb.' where (`'.$this->key.'` = '.$this->key_delim.$this->rec.$this->key_delim.')' |
'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = ' |
,__LINE__); |
.$this->key_delim.$this->rec.$this->key_delim.')' // ) |
$oldrow = mysql_fetch_array($res); |
,__LINE__); |
|
$oldrow = mysql_fetch_array($res, MYSQL_ASSOC); |
} |
} |
$qry = 'DELETE FROM '.$this->tb.' WHERE (`'.$this->key.'` = '.$this->key_delim.$this->rec.$this->key_delim.')'; |
$qry = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = ' |
|
.$this->key_delim.$this->rec.$this->key_delim.')'; // ) |
$res = $this->myquery($qry,__LINE__); |
$res = $this->myquery($qry,__LINE__); |
if ($res) { |
if ($res) { |
$tdm = true; |
$tdm = true; |
} |
} |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted']; |
} |
} |
if ( |
if ($tdb && $tdm && isset($this->triggers['delete']['after'])) { |
$tdb && |
|
isset($this->triggers['delete']['after']) && |
|
$tdm |
|
) { |
|
// before executed ok |
// before executed ok |
// main op executed ok |
// main op executed ok |
// let's do the after trigger |
// let's do the after trigger |
$tda = include($this->triggers['delete']['after']); |
$tda = include($this->triggers['delete']['after']); |
} |
} |
|
// Notify list |
|
if (@$this->notify['delete'] || @$this->notify['all']) { |
|
$this->email_notify($oldrow, false); |
|
} |
|
// Note change in log table |
|
if ($this->logtable) { |
|
$qry = sprintf('INSERT INTO %s' |
|
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)' |
|
.' VALUES (NOW(), "%s", "%s", "delete", "%s", "%s", "%s", "%s", "")', |
|
$this->logtable, addslashes($REMOTE_USER), addslashes($REMOTE_ADDR), |
|
addslashes($this->tb), addslashes($key_col_val), addslashes($key), |
|
addslashes(serialize($oldrow))); |
|
$this->myquery($qry, __LINE__); |
|
} |
|
} /* }}} */ |
|
|
// notify list |
function email_notify($old_vals, $new_vals) /* {{{ */ |
if (($this->notify['delete'])) { |
{ |
$user = $REMOTE_USER; |
global $HTTP_SERVER_VARS; |
if (! $user) |
$REMOTE_USER = $HTTP_SERVER_VARS['REMOTE_USER']; |
$user = $REMOTE_ADDR; |
$REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR']; |
$body = 'An item was deleted by '.$user.' from '.$this->page_name."\n"; |
$user = $REMOTE_ADDR; |
foreach ($oldrow as $key=>$val) { |
strlen($REMOTE_USER) > 0 && $user = $REMOTE_USER.$user; |
if (is_string($key)) { |
if ($old_vals != false && $new_vals != false) { |
$body .= $this->fdd[$key]['name'].":\t".$val."\n"; |
$action = 'update'; |
} |
$subject = 'Record updated in'; |
|
$body = 'An item with '.$this->fdd[$this->key]['name'].' = ' |
|
.$this->key_delim.$this->rec.$this->key_delim .' was updated in'; |
|
} elseif ($new_vals != false) { |
|
$action = 'insert'; |
|
$subject = 'Record added to'; |
|
$body = 'A new item was added into'; |
|
$vals = $new_vals; |
|
} elseif ($old_vals != false) { |
|
$action = 'delete'; |
|
$subject = 'Record deleted from'; |
|
$body = 'An item was deleted from'; |
|
$vals = $old_vals; |
|
} else { |
|
return false; |
|
} |
|
|
|
$body = 'This notification e-mail is automatically generated by phpMyEdit.'."\n\n".$body; |
|
$body .= ' table '.$this->tb.' in MySQL database '.$this->db.' on '.$this->page_name; |
|
$body .= ' by '.$user.' at '.date('d/M/Y H:i').' with the following fields:'."\n\n"; |
|
$i = 1; |
|
if ($action == 'update') { |
|
foreach (array_keys($new_vals) as $k) { |
|
$body .= sprintf("[%02s] %s (%s)\n WAS: %s\n IS: %s\n", |
|
$i, $this->fdd[$k]['name'], $k, $old_vals[$k], $new_vals[$k]); |
|
$i++; |
|
} |
|
} else { |
|
foreach ($vals as $k => $text) { |
|
$body .= sprintf('[%02s] %s (%s): %s'."\n", |
|
$i, $this->fdd[$k]['name'], $k, $text); |
|
$i++; |
} |
} |
// mail it |
|
mail($this->notify['delete'],'Record Deleted in '.$this->tb,$body); |
|
} |
} |
// note change in log table |
$body .= "\n--\n"; |
if ($this->logtable) { |
$body .= "phpMyEdit - MySQL table editor\n"; |
$this->myquery( |
$body .= "http://www.platon.sk/projects/phpMyEdit/\n"; |
"INSERT INTO ".$this->logtable." VALUES (". |
$subject = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb; |
"SYSDATE(),". |
$emails = (array) $this->notify[$action] + (array) $this->notify['all']; |
"'".$REMOTE_USER."',". |
foreach ($emails as $email) { |
"'".$REMOTE_ADDR."',". |
if (! empty($email)) { |
"'delete','". |
mail($email, $subject, wordwrap($body)); |
$this->tb."',". |
} |
"'".$key_col_val."',". |
|
"'".$key."','". |
|
addslashes(serialize($oldrow))."','')" |
|
,__LINE__); |
|
} |
} |
|
return true; |
} /* }}} */ |
} /* }}} */ |
|
|
/* |
/* |
Line 2886 echo '<h5>'.@mysql_affected_rows($this-> |
|
Line 2807 echo '<h5>'.@mysql_affected_rows($this-> |
|
$this->fdd = $opts['fdd']; |
$this->fdd = $opts['fdd']; |
$this->multiple = intval($opts['multiple']); |
$this->multiple = intval($opts['multiple']); |
$this->multiple <= 0 && $this->multiple = 2; |
$this->multiple <= 0 && $this->multiple = 2; |
$this->display = $opts['display']; |
$this->display = @$opts['display']; |
$this->filters = $opts['filters']; |
$this->filters = @$opts['filters']; |
$this->triggers = $opts['triggers']; |
$this->triggers = @$opts['triggers']; |
$this->logtable = $opts['logtable']; |
$this->notify = @$opts['notify']; |
|
$this->logtable = @$opts['logtable']; |
$this->page_name = $this->tb; |
$this->page_name = $this->tb; |
$opts['page_name'] && $this->page_name = $opts['page_name']; |
$opts['page_name'] && $this->page_name = $opts['page_name']; |
// REMOVE ME! |
|
//$this->default_sort_columns = $opts['default_sort_columns']; |
|
|
|
// alternate row background colors |
// alternate row background colors |
/* What's this?! |
/* What's this?! |
Line 2910 echo '<h5>'.@mysql_affected_rows($this-> |
|
Line 2830 echo '<h5>'.@mysql_affected_rows($this-> |
|
} |
} |
*/ |
*/ |
|
|
// e-mail notification |
|
if (isset($opts['notify'])) { |
|
$this->notify = $opts['notify']; |
|
} |
|
|
|
// navigation |
// navigation |
$this->navigation = $opts['navigation']; |
$this->navigation = @$opts['navigation']; |
if (! $this->nav_buttons() && ! $this->nav_text_links() && ! $this->nav_graphic_links()) { |
if (! $this->nav_buttons() && ! $this->nav_text_links() && ! $this->nav_graphic_links()) { |
$this->navigation .= 'B'; // buttons are default |
$this->navigation .= 'B'; // buttons are default |
} |
} |