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

📄 lib.inc.php3

📁 Mysql数据库的web管理工具
💻 PHP3
📖 第 1 页 / 共 2 页
字号:
    <table border="<?php echo $cfgBorder;?>">    <tr>    <?php    while($field = mysql_fetch_field($dt_result))    {        if(@mysql_num_rows($dt_result)>1)        {            $sort_order=urlencode(" order by $field->name $cfgOrder");            echo "<th>";            if(!eregi("SHOW VARIABLES|SHOW PROCESSLIST|SHOW STATUS", $sql_query))                echo "<A HREF=\"sql.php3?server=$server&db=$db&pos=$pos&sql_query=".urlencode($sql_query)."&sql_order=$sort_order&table=$table\">";            echo $field->name;            if(!eregi("SHOW VARIABLES|SHOW PROCESSLIST|SHOW STATUS", $sql_query))                echo "</a>";            echo "</th>\n";        }        else        {            echo "<th>$field->name</th>";        }        $table = $field->table;    }    echo "</tr>\n";    $foo = 0;    while($row = mysql_fetch_row($dt_result))    {        $primary_key = "";        //begin correction uva 19991216 ---------------------------        //previous code assumed that all tables have keys, specifically        //that only the phpMyAdmin GUI should support row delete/edit        //only for such tables.  although always using keys is arguably        //the prescribed way of defining a relational table, it is not        //required.  this will in particular be violated by the novice.  we        //want to encourage phpMyAdmin usage by such novices.  so the code        //below has been changed to conditionally work as before when the        //table being displayed has one or more keys; but to display delete/edit        //options correctly for tables without keys.        //begin correction uva 19991216 pt. 1 ---------------------------        $uva_nonprimary_condition = "";        //end correction uva 19991216 pt. 1 -----------------------------        $bgcolor = $cfgBgcolorOne;        $foo % 2  ? 0: $bgcolor = $cfgBgcolorTwo;        echo "<tr bgcolor=$bgcolor>";        for($i=0; $i<mysql_num_fields($dt_result); $i++)        {            if(!isset($row[$i])) $row[$i] = '';                $primary = mysql_fetch_field($dt_result,$i);            if($primary->numeric == 1)            {                echo "<td align=right>&nbsp;$row[$i]&nbsp;</td>\n";                if($sql_query == "SHOW PROCESSLIST")                    $Id = $row[$i];            }            elseif($cfgShowBlob == false && eregi("BLOB", $primary->type))            {                echo "<td align=right>&nbsp;[BLOB]&nbsp;</td>\n";            }            else            {                echo "<td>&nbsp;".htmlspecialchars($row[$i])."&nbsp;</td>\n";            }            if($primary->primary_key > 0)                $primary_key .= " $primary->name = '".addslashes($row[$i])."' AND";            //begin correction uva 19991216 pt. 2 ---------------------------            //see pt. 1, above, for description of change            $uva_nonprimary_condition .= " $primary->name = '".addslashes($row[$i])."' AND";            //end correction uva 19991216 pt. 2 -----------------------------        }        //begin correction uva 19991216 pt. 3 ---------------------------        //see pt. 1, above, for description of change        //prefer primary keys for condition, but use conjunction of all values if no primary key        if($primary_key) //use differently and include else            $uva_condition = $primary_key;        else            $uva_condition = $uva_nonprimary_condition;        //   { code no longer conditional on $primary_key        //   $primary_key replaced with $uva_condition below        $uva_condition = urlencode(ereg_replace("AND$", "", $uva_condition));        $query = "server=$server&db=$db&table=$table&pos=$pos";        $goto = (isset($goto) && !empty($goto) && empty($GLOBALS["QUERY_STRING"])) ? $goto : "sql.php3";        echo "<td><a href=\"tbl_change.php3?primary_key=$uva_condition&$query&sql_query=".urlencode($sql_query)."&goto=$goto\">".$strEdit."</a></td>";        echo "<td><a href=\"sql.php3?sql_query=".urlencode("DELETE FROM $table WHERE ").$uva_condition."&$query&goto=sql.php3".urlencode("?$query&sql_query=$sql_query")."zero_rows=".urlencode($strDeleted)."&goto=db_details.php3\">".$strDelete."</a></td>";        //   } code no longer condition on $primary_key        //end correction uva 19991216 pt. 3 -----------------------------        if($sql_query == "SHOW PROCESSLIST")            echo "<td align=right><a href='sql.php3?db=mysql&sql_query=".urlencode("KILL $Id")."&goto=main.php3'>KILL</a></td>\n";        echo "</tr>\n";        $foo++;    }    echo "</table>\n";    show_table_navigation($pos_next, $pos_prev, $dt_result);}//display_table// Return $table's CREATE definition// Returns a string containing the CREATE statement on successfunction get_table_def($db, $table, $crlf){    global $drop;    $schema_create = "";    if(!empty($drop))        $schema_create .= "DROP TABLE IF EXISTS $table;$crlf";    $schema_create .= "CREATE TABLE $table ($crlf";    $result = mysql_db_query($db, "SHOW FIELDS FROM $table") or mysql_die();    while($row = mysql_fetch_array($result))    {        $schema_create .= "   $row[Field] $row[Type]";        if(isset($row["Default"]) && (!empty($row["Default"]) || $row["Default"] == "0"))            $schema_create .= " DEFAULT '$row[Default]'";        if($row["Null"] != "YES")            $schema_create .= " NOT NULL";        if($row["Extra"] != "")            $schema_create .= " $row[Extra]";        $schema_create .= ",$crlf";    }    $schema_create = ereg_replace(",".$crlf."$", "", $schema_create);    $result = mysql_db_query($db, "SHOW KEYS FROM $table") or mysql_die();    while($row = mysql_fetch_array($result))    {        $kname=$row['Key_name'];        if(($kname != "PRIMARY") && ($row['Non_unique'] == 0))            $kname="UNIQUE|$kname";         if(!isset($index[$kname]))             $index[$kname] = array();         $index[$kname][] = $row['Column_name'];    }    while(list($x, $columns) = @each($index))    {         $schema_create .= ",$crlf";         if($x == "PRIMARY")             $schema_create .= "   PRIMARY KEY (" . implode($columns, ", ") . ")";         elseif (substr($x,0,6) == "UNIQUE")            $schema_create .= "   UNIQUE ".substr($x,7)." (" . implode($columns, ", ") . ")";         else            $schema_create .= "   KEY $x (" . implode($columns, ", ") . ")";    }    $schema_create .= "$crlf)";    return (stripslashes($schema_create));}// Get the content of $table as a series of INSERT statements.// After every row, a custom callback function $handler gets called.// $handler must accept one parameter ($sql_insert);function get_table_content($db, $table, $handler){    $result = mysql_db_query($db, "SELECT * FROM $table") or mysql_die();    $i = 0;    while($row = mysql_fetch_row($result))    {        set_time_limit(60); // HaRa        $table_list = "(";        for($j=0; $j<mysql_num_fields($result);$j++)            $table_list .= mysql_field_name($result,$j).", ";        $table_list = substr($table_list,0,-2);        $table_list .= ")";        if(isset($GLOBALS["showcolumns"]))            $schema_insert = "INSERT INTO $table $table_list VALUES (";        else            $schema_insert = "INSERT INTO $table VALUES (";        for($j=0; $j<mysql_num_fields($result);$j++)        {            if(!isset($row[$j]))                $schema_insert .= " NULL,";            elseif($row[$j] != "")                $schema_insert .= " '".addslashes($row[$j])."',";            else                $schema_insert .= " '',";        }        $schema_insert = ereg_replace(",$", "", $schema_insert);        $schema_insert .= ")";        $handler(trim($schema_insert));        $i++;    }    return (true);}function count_records ($db,$table){    $result = mysql_db_query($db, "select count(*) as num from $table");    $num = mysql_result($result,0,"num");    echo $num;}// Get the content of $table as a CSV output.// $sep contains the separation string.// After every row, a custom callback function $handler gets called.// $handler must accept one parameter ($sql_insert);function get_table_csv($db, $table, $sep, $handler){    $result = mysql_db_query($db, "SELECT * FROM $table") or mysql_die();    $i = 0;    while($row = mysql_fetch_row($result))    {        set_time_limit(60); // HaRa        $schema_insert = "";        for($j=0; $j<mysql_num_fields($result);$j++)        {            if(!isset($row[$j]))                $schema_insert .= "NULL".$sep;            elseif ($row[$j] != "")                $schema_insert .= "$row[$j]".$sep;            else                $schema_insert .= "".$sep;        }        $schema_insert = str_replace($sep."$", "", $schema_insert);        $handler(trim($schema_insert));        $i++;    }    return (true);}function show_docu($link){    global $cfgManualBase, $strDocu;    if(!empty($cfgManualBase))        return("[<a href=\"$cfgManualBase/$link\">$strDocu</a>]");}function show_message($message){    if(!empty($GLOBALS['reload']) && ($GLOBALS['reload'] == "true"))    {        // Reload the navigation frame via JavaScript        ?>        <script language="JavaScript1.2">        parent.frames.nav.location.reload();        </script>        <?php    }    ?>    <div align="left">     <table border="<?php echo $GLOBALS['cfgBorder'];?>">      <tr>       <td bgcolor="<?php echo $GLOBALS['cfgThBgcolor'];?>">       <b><?php echo $message;?><b><br>       </td>      </tr>    <?php    if($GLOBALS['cfgShowSQL'] == true && !empty($GLOBALS['sql_query']))    {        ?>        <tr>        <td bgcolor="<?php echo $GLOBALS['cfgBgcolorOne'];?>">        <?php echo $GLOBALS['strSQLQuery'].":\n<br>", nl2br($GLOBALS['sql_query']);        if (isset($GLOBALS["sql_order"])) echo " $GLOBALS[sql_order]";        if (isset($GLOBALS["pos"])) echo " LIMIT $GLOBALS[pos], $GLOBALS[cfgMaxRows]";?>        </td>        </tr>        <?php    }    ?>    </table>    </div>    <?php}function split_string($sql, $delimiter){    $sql = trim($sql);    $buffer = array();    $ret = array();    $in_string = false;    for($i=0; $i<strlen($sql); $i++)    {        if($sql[$i] == $delimiter && !$in_string)        {            $ret[] = substr($sql, 0, $i);            $sql = substr($sql, $i + 1);            $i = 0;        }        if($in_string && ($sql[$i] == $in_string) && $buffer[0] != "\\")        {             $in_string = false;        }        elseif(!$in_string && ($sql[$i] == "\"" || $sql[$i] == "'") && (!isset($buffer[0]) || $buffer[0] != "\\"))        {             $in_string = $sql[$i];        }        if(isset($buffer[1]))            $buffer[0] = $buffer[1];        $buffer[1] = $sql[$i];     }    if (!empty($sql))    {        $ret[] = $sql;    }    return($ret);}// -----------------------------------------------------------------?>

⌨️ 快捷键说明

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