⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phpmyedit.inc

📁 一款linux下的PHP编制器 十分实用
💻 INC
📖 第 1 页 / 共 3 页
字号:

    } /* if elseif else */
  }

  function display_delete_field ($row, $k)
  {
    if ($row[$k] == '') {
      echo '    <td>&nbsp;</td>'."\n";
    } else {
      echo '    <td>'.nl2br(htmlentities($row[$k])).'</td>'."\n";
    }
  }

	function web2plain($x)
	{
	  if (isset($x))
    {
		  if (is_array($x))
				{
			   for ($n=0; $n<count($x); $n++)
			    { $x[$n] = $this->web2plain($x[$n]); }
				} else {
				  $x = rawurldecode($x);
				}
		}
		return $x;
	}
	
	function plain2web($x)
	{
	  if (isset($x))
    {
		  if (is_array($x))
				{
			   for ($n=0; $n<count($x); $n++)
   			   { $x[$n] = $this->plain2web($x[$n]); }
				} else {
				  $x = rawurlencode($x);
				}
		}
		return $x;
	}
	
  function get_http_get_var_by_name ($name)
  {
    global $HTTP_GET_VARS;

    if (is_array($HTTP_GET_VARS))
      $v = $HTTP_GET_VARS[$name];
    /* $v could be an array if we allowed bidimensional form fields */
    return $v;
  }

  function get_http_post_var_by_name ($name)
  {
    global $HTTP_POST_VARS;

    if (is_array($HTTP_POST_VARS))
      $v = $HTTP_POST_VARS[$name];
    /* $v could be an array if we allowed bidimensional form fields */
    return $v;
  }

  function print_get_vars ($miss = "No GET variables found") /*debug only*/
  {
    global $HTTP_GET_VARS;

    /* we parse form GET variables */
    if (is_array($HTTP_GET_VARS)) {
      echo "<p> Variables per GET ";
      foreach ($HTTP_GET_VARS as $k => $v) {
        if (is_array($v)) {
          foreach ($v as $akey => $aval) {
            // $HTTP_GET_VARS[$k][$akey] = strip_tags($aval);
            // $$k[$akey] = strip_tags($aval);
            echo "$k\[$akey\]=$aval   ";
          }
        } else {
          // $HTTP_GET_VARS[$k] = strip_tags($val);
          // $$k = strip_tags($val);
          echo "$k=$v   ";
        }
      }
      echo "</p>";
    } else {
      echo "<p>";
      echo "$miss";
      echo "</p>";
    }
  }

  function print_post_vars($miss = "No POST variables found")  /*debug only*/
  {
    global $HTTP_POST_VARS;
    /* we parse form POST variables */
    if (is_array($HTTP_POST_VARS)) {
      echo "<p>Variables per POST ";
      foreach ($HTTP_POST_VARS as $k => $v) {
        if (is_array($v)) {
          foreach ($v as $akey => $aval) {
            // $HTTP_POST_VARS[$k][$akey] = strip_tags($aval);
            // $$k[$akey] = strip_tags($aval);
            echo "$k\[$akey\]=$aval   ";
          }
        } else {
          // $HTTP_POST_VARS[$k] = strip_tags($val);
          // $$k = strip_tags($val);
          echo "$k=$v   ";
        }
      }
      echo "</p>";
    } else {
      echo "<p>";
      echo "$miss";
      echo "</p>";
    }
  }

  function print_vars ($miss = "Current instance variables")  /*debug only*/
  {
    echo "$miss   ";
    echo "page_name=".$this->page_name."   ";
    echo "hn=".$this->hn."   ";
    echo "un=".$this->un."   ";
    echo "pw=".$this->pw."   ";
    echo "db=".$this->db."   ";
    echo "tb=".$this->tb."   ";
    echo "key=".$this->key."   ";
    echo "key_type=".$this->key_type."   ";
    echo "inc=".$this->inc."   ";
    echo "options=".$this->options."   ";
    echo "fdd=".$this->fdd."   ";
    echo "fl=".$this->fl."   ";
    echo "fm=".$this->fm."   ";
    echo "sfn=".$this->sfn."   ";
    echo "qfn=".$this->qfn."   ";
    echo "sw=".$this->sw."   ";
    echo "rec=".$this->rec."   ";
    echo "prev=".$this->prev."   ";
    echo "next=".$this->next."   ";
    echo "saveadd=".$this->saveadd."   ";
    echo "moreadd=".$this->moreadd."   ";
    echo "savechange=".$this->savechange."   ";
    echo "savedelete=".$this->savedelete."   ";
    echo "operation=".$this->operation."   ";
    echo "\n";
  }

  function list_table ()
  {
    /* Process any navigation buttons */

    if (!isset ($this->fm)) {
      $this->fm = 0;
    }
    if ($this->prev == $this->labels[0]) {             /*Prev*/
      $this->fm = $this->fm - $this->inc;
      if ($this->fm < 0) {
        $this->fm = 0;
      }
    }
    if ($this->next == $this->labels[4]) {             /*Next*/
      $this->fm = $this->fm + $this->inc;
    }

    /* Process filters */

    if (!isset ($this->fl)) {
      $this->fl = 0;
    }  /* by default, no filters */

    /* filter switch has been pressed */
    if (isset ($this->sw)) {
      if ($this->sw == 'v') {
        $this->fl = 1;
      }
      if ($this->sw == '^') {
        $this->fl = 0;
      }
    }
/*
    If user is allowed to Change/Delete records, we need an extra column
    to allow users to select a record
*/
    $select_recs = (($this->change_enabled () or $this->delete_enabled ()) and ($this->key != ''));

    /* Default is to sort on first field */
    if ($this->sfn == '' and ! ($this->initial_sort_suppressed()) ) {
      $this->sfn = 0;
    }
/* 
    Display the MySQL table in an HTML table 
*/
    echo '<form action="'.$this->page_name.'" method="POST">'."\n";
    echo '  <input type="hidden" name="sfn" value="'.$this->sfn.'" />'."\n";
    echo '  <input type="hidden" name="fl" value="'.$this->fl.'" />'."\n";
    /* if the filter input boxes are not displayed, we need to preserve the filter */
    if (!$this->fl) {
      for ($k = 0; $k < $this->num_fds; $k++) {
        $l = 'qf'.$k;
        global $$l;
  						$m = $this->web2plain($$l);
        if (isset ($m)) 
		  		{
          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]) != '')
                {  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.'='.$this->plain2web($m);
               echo '  <input type="hidden" name="qf'.$k.'" value="'.$this->plain2web($m).'">'."\n"; 
										}
						  }
        }
      }
    }
/*
    Set up the URLs which allow sorting by clicking on column headings
*/
    $prev_qfn = $this->qfn;
    $this->qfn = '';
    for ($k = 0; $k < $this->num_fds; $k++) {
      $l = 'qf'.$k;
      global $$l;
				$m = $this->web2plain($$l);
      if (isset ($m)) 
				{
        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]); }
            }
								}
						} else {
						  if ($this->plain2web($m)!='')
           { $this->qfn = $this->qfn.'&qf'.$k.'='.$this->plain2web($m); }
						}
      }
    }
    echo '  <input type="hidden" name="qfn" value="'.$this->qfn.'" />'."\n";

    /* if sort sequence has changed, restart listing */
    if ($this->qfn != $prev_qfn) {
      $this->fm = 0;
    }

    /* descending sort order is flagged by a minus sign */
    if (isset ($this->sfn)) {
      $sort_asc = (substr ($this->sfn, 0, 1) != '-');
      if (!$sort_asc) {
        $this->sfn = substr ($this->sfn, 1);
      }
    }

    echo '  <input type="hidden" name="fm" value="'.$this->fm.'" />'."\n";
    echo '  <table border="1" cellpadding="1" cellspacing="0" summary="'.$this->tb.'">'."\n";
    echo '    <tr>'."\n";
/*
    we need an initial column if we have filters,
    or Changes or Deletes enabled
*/
    if ($this->filter_enabled () or $select_recs) {
      if ($this->filter_enabled ()) {
        if ($this->fl) {
          echo '      <th align="center"><input type="submit" name="sw" value="^" /></th>'."\n";
        } else {
          echo '      <th align="center"><input type="submit" name="sw" value="v" /></th>'."\n";
        }
      } else {
        echo '      <th align="center">&nbsp;</th>'."\n";
      }
    }

    for ($k = 0; $k < $this->num_fds; $k++) 
		{
      $fd = $this->fds[$k];

      if (stristr($this->fdd[$fd]['options'],'L') or !isset ($this->fdd[$fd]['options'])) {
        $fdn = $this->fdd[$fd]['name'];
        if (isset ($this->fdd[$fd]['width'])) {
          $w = ' width="'.$this->fdd[$fd]['width'].'"';
        } else {
          $w = '';
        }
        if ($this->fdd[$fd]['sort']) {
          /* clicking on the current sort field reverses the sort order */
          if (($k == $this->sfn) and ($sort_asc)) {
            echo '      <th'.$w.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl.'&sfn=-'.$k.$this->qfn.'">'.$fdn.'</a></th>'."\n";;
          } else {
            echo '      <th'.$w.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl.'&sfn='.$k.$this->qfn.'">'.$fdn.'</a></th>'."\n";;
          }
        } else {
          echo '      <th'.$w.'>'.$fdn.'</th>'."\n";
        }
      } /* if */
    } /* for */

    echo '    </tr>'."\n";
/* 
    Prepare the SQL Query from the data definition file 
*/
    $qry = $this->create_column_list ($this->tb, $this->fdd);

    /* Even if the key field isn't displayed, we still need its value */
    if ($select_recs) {
      if (!in_array ($this->key, $this->fds)) {
        $qry = $qry.','.$this->fully_qualified_name($this->tb, $this->fdd, $this->key);
      };
    }

    $qry = $qry.$this->create_from_clause ($this->tb, $this->fdd);

    $qry_select = $this->create_where_clause ($this->tb, $this->fdd);
    if ($qry_select == '') {
      $kwd = ' WHERE ';
    } else {
      $kwd = ' AND ';
    }

    for ($k = 0; $k < $this->num_fds; $k++) {
      $l = 'qf'.$k;
      global $$l;
				$m = $this->web2plain($$l);
      if (isset ($m)) 
				{
        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 ($n==0) 
		  						  { 
						 						  $afilter=" IN ('".addslashes($m[$n])."'"; 
					  			  } else {
						        $afilter=$afilter.",'".addslashes($m[$n])."'"; 
									  	}
								  }
								  $afilter = $afilter.')';
            $qry_select = $qry_select.$kwd.' ('.$this->fully_qualified_name($this->tb,$this->fdd,$this->fds[$k]).$afilter.') ';
            $kwd = ' AND ';
								}		
						} else {
          $afilter = $m;
          if (($afilter != '') AND ($afilter != '*')) 
 		 					{
            if (strstr ($afilter, '*')) 
			  					{
              $afilter = str_replace ('*', '%', $afilter);
              $qry_select = $qry_select.$kwd.' ('.$this->fully_qualified_name($this->tb,$this->fdd,$this->fds[$k]).' like \''.$afilter.'\') ';
            } else {
              $qry_select = $qry_select.$kwd.' ('.$this->fully_qualified_name($this->tb,$this->fdd,$this->fds[$k]).' = \''.$afilter.'\') ';
            }
            $kwd = ' AND ';
          }
						}
      } /* if */
    } /* for */

    $qry = $qry.$qry_select;
    if (isset ($this->sfn)) {
      $qry = $qry.' ORDER BY '.$this->fully_qualified_name ($this->tb, $this->fdd, $this->fds[$this->sfn]);
      if (!$sort_asc) {
        $qry = $qry.' DESC';
      }
    }
    $to = $this->fm + $this->inc;
    $qry = $qry.' LIMIT '.$this->fm.','.$this->inc;
/* 
    Each row of the HTML table is one record from the SQL Query 
*/
//  echo '<tr><td>'.$qry.'</td></tr>'."\n";
    $res = mysql_db_query ($this->db, $qry);
    $first = true;
    $eot = $this->inc;
    while ($row = mysql_fetch_array ($res)) {
      echo '    <tr>'."\n";
/*
      Draw the filter and fill it with any data typed in last pass and stored
      in the array parameter keyword 'filter'. Prepare the SQL WHERE clause.
*/
      if ($first AND $this->fl) {
        echo '      <td align="center"><input type="submit" name="filter" value="&gt;" /></td>'."\n";
        for ($k = 0; $k < $this->num_fds; $k++) {
          $fd = $this->fds[$k];
          $l = 'qf'.$k;
          global $$l;
          $m = $this->web2plain($$l);
          if (stristr($this->fdd[$fd]['options'],'L') or !isset ($this->fdd[$fd]['options'])) {
            if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') {
              if (isset ($this->fdd[$this->fds[$k]]['values']['table'])
                and isset ($this->fdd[$this->fds[$k]]['values']['column'])
                and isset ($this->fdd[$this->fds[$k]]['values']['description'])) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -