\n"; echo "\n"; echo "MySQL Web Interface\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "

MySQL Web Interface

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Username
Password

\n"; echo "\n"; echo "
\n"; echo "

\n"; echo "
\n"; echo "
\n"; echo "


\n"; echo "\n"; echo "Copyleft © since 1999,\n"; echo "SooMin Kim
\n"; echo "Hompage is available
"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; } function logon_submit() { global $username, $password, $PHP_SELF; $dbname = 'dbÀ̸§'; // ÀÌ°Å ¾Æ´Ï¸é ¹Ù²ã ¾²¼¼¿ä. setcookie( "mysql_web_admin_username", $username ); setcookie( "mysql_web_admin_password", $password ); echo ""; echo ""; echo ""; echo ""; echo ""; } function echoQueryResult() { global $queryStr, $errMsg; if( $errMsg == "" ) $errMsg = "Success"; if( $queryStr != "" ) { echo "\n"; echo "\n"; echo "\n"; echo "
Query$queryStr
Result$errMsg

\n"; } } function listDatabases() { global $mysqlHandle, $PHP_SELF; echo "

Database List

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; $pDB = mysql_list_dbs( $mysqlHandle ); $num = mysql_num_rows( $pDB ); for( $i = 0; $i < $num; $i++ ) { $dbname = mysql_dbname( $pDB, $i ); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
$dbnameTableDropDump
\n"; } function createDatabase() { global $mysqlHandle, $dbname, $PHP_SELF; mysql_create_db( $dbname, $mysqlHandle ); listDatabases(); } /*********************************** **********************************/ function dump() { global $mysqlHandle, $PHP_SELF, $USERNAME, $PASSWORD, $action, $dbname, $tablename; if( $action == "dumpTable" ) { DumpHD($tablename); $tablee = $tablename; DumpTB($tablee); exit(); } else { DumpHD($dbname); $tables = mysql_query("SHOW TABLES FROM {$dbname}", $mysqlHandle); while($tbles = mysql_fetch_row($tables)) { $tablee = $tbles[0]; DumpTB($tablee); } } exit(); echo ""; } function DumpHD($file) { header("Content-disposition: filename={$file}_".date("Ymd").".sql"); header("Content-type: application/octetstream"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Pragma: no-cache"); header("Expires: 0"); } function DumpTB($tablee) { global $mysqlHandle, $PHP_SELF, $USERNAME, $PASSWORD, $action, $dbname, $tablename; echo "\r\n\r\n\r\nDROP TABLE IF EXISTS `{$tablee}`;\r\nCREATE TABLE `{$tablee}` ( \r\n"; $result = mysql_db_query( $dbname, "SHOW COLUMNS FROM {$tablee}", $mysqlHandle); $push = ""; while ($row = mysql_fetch_array($result)) { $push .= " `{$row[0]}` "; $push .= "{$row[1]} "; if($row[2]) $push .= "null "; else $push .= "not null "; if($row[3] == "PRI") $pkey = "PRIMARY KEY (`{$row[0]}`)"; else if($row[3] == "MUL") $key .= ", \r\nKEY `{$row[0]}` (`{$row[0]}`)"; if($row[4]) $push .= "default '{$row[4]}' "; $push .= "{$row[5]} ,\r\n"; } if($pkey == '' && $key == '') $push = substr($push, 0, -3); echo $push; echo $pkey.$key."\r\n) TYPE=MyISAM; \r\n"; $key = ""; $tata = mysql_db_query( $dbname, "select * from {$tablee}", $mysqlHandle); $roxw = mysql_num_fields($tata); while($rw = mysql_fetch_array($tata)) { echo "\r\nINSERT INTO `{$tablee}` VALUES ( '{$rw[0]}"; for($i = 1; $i < $roxw ;$i++) { echo "', '".str_replace("\r", "", str_replace("\n", "\\n", addslashes(stripslashes($rw[$i])))); } echo "' );"; } flush(); } function addsqlfile( $filename ) { global $mysqlHandle, $PHP_SELF, $USERNAME, $PASSWORD, $action, $dbname; mysql_select_db( $dbname, $mysqlHandle ); $dest1 = "./" . basename($_FILES['filename']['name']); move_uploaded_file($_FILES['filename']['tmp_name'], $dest1); $filesql = $_FILES['filename']['name']; $fp = fopen($filesql, "r"); while(!feof($fp)){ $data = trim(fgets($fp)); if(substr($data, 0, 1) != '#' && substr($data, 0, 2) != '--'){ $data = $rest.$data; if(substr($data, -1) == ';') { $rest = ''; mysql_query( $data, $mysqlHandle ); } else $rest = $data; $data = ''; } } fclose($fp); unlink($filesql); echo ""; } /*********************************** **********************************/ function dropDatabase() { global $mysqlHandle, $dbname, $PHP_SELF; mysql_drop_db( $dbname, $mysqlHandle ); listDatabases(); } function listTables() { global $mysqlHandle, $dbname, $PHP_SELF; echo "

Table List

\n"; echo "

$dbname

\n"; echoQueryResult(); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "
\n"; $pTable = mysql_list_tables( $dbname ); if( $pTable == 0 ) { $msg = mysql_error(); echo "

Error : $msg

\n"; return; } $num = mysql_num_rows( $pTable ); echo "\n"; for( $i = 0; $i < $num; $i++ ) { $tablename = mysql_tablename( $pTable, $i ); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
\n"; echo "$tablename\n"; echo "\n"; echo "Schema\n"; echo "\n"; echo "Data\n"; echo "\n"; echo "Drop\n"; echo "\n"; echo "Truncate\n"; echo "\n"; echo "Dump\n"; echo "
"; } function createTable() { global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg; $queryStr = "CREATE TABLE `$tablename` ( no INT )"; mysql_select_db( $dbname, $mysqlHandle ); mysql_query( $queryStr, $mysqlHandle ); $errMsg = mysql_error(); listTables(); } function dropTable() { global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg; $queryStr = "DROP TABLE `$tablename`"; mysql_select_db( $dbname, $mysqlHandle ); mysql_query( $queryStr, $mysqlHandle ); $errMsg = mysql_error(); listTables(); } function truncateTable() { global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg; $queryStr = "truncate `$tablename`"; mysql_select_db( $dbname, $mysqlHandle ); mysql_query( $queryStr, $mysqlHandle ); $errMsg = mysql_error(); listTables(); } function viewSchema() { global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $queryStr, $errMsg; echo "

Table Schema

\n"; echo "

$dbname > $tablename

\n"; echoQueryResult(); echo "
\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "
\n"; echo "
\n"; echo "Add Field | \n"; echo "View Data\n"; echo "
\n"; $pResult = mysql_db_query( $dbname, "SHOW fields FROM `$tablename`" ); $num = mysql_num_rows( $pResult ); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; for( $i = 0; $i < $num; $i++ ) { $field = mysql_fetch_array( $pResult ); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $fieldname = $field["Field"]; echo "\n"; echo "\n"; echo "\n"; } echo "
FieldTypeNullKeyDefaultExtraAction
".$field["Field"]."".$field["Type"]."".$field["Null"]."".$field["Key"]."".$field["Default"]."".$field["Extra"]."EditDrop
\n"; } function manageField( $cmd ) { global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF; if( $cmd == "add" ) echo "

Add Field

\n"; else if( $cmd == "edit" ) { echo "

Edit Field

\n"; $pResult = mysql_db_query( $dbname, "SHOW fields FROM `$tablename`" ); $num = mysql_num_rows( $pResult ); for( $i = 0; $i < $num; $i++ ) { $field = mysql_fetch_array( $pResult ); if( $field["Field"] == $fieldname ) { $fieldtype = $field["Type"]; $fieldkey = $field["Key"]; $fieldextra = $field["Extra"]; $fieldnull = $field["Null"]; $fielddefault = $field["Default"]; break; } } $type = strtok( $fieldtype, " (,)\n" ); if( strpos( $fieldtype, "(" ) ) { if( $type == "enum" | $type == "set" ) { $valuelist = strtok( " ()\n" ); } else { $M = strtok( " (,)\n" ); if( strpos( $fieldtype, "," ) ) $D = strtok( " (,)\n" ); } } } echo "

$dbname > $tablename

\n"; echo "
\n"; if( $cmd == "add" ) echo "\n"; else if( $cmd == "edit" ) { echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "

Name

\n"; echo "

\n"; ?>

Type

* `M' indicates the maximum display size.
* `D' applies to floating-point types and indicates the number of digits following the decimal point.
Type M  D unsignedzerofillbinary
>TINYINT (-128 ~ 127) O   O O  
>SMALLINT (-32768 ~ 32767) O   O O  
>MEDIUMINT (-8388608 ~ 8388607) O   O O  
>INT (-2147483648 ~ 2147483647) O   O O  
>BIGINT (-9223372036854775808 ~ 9223372036854775807) O   O O  
>FLOAT O O   O  
>DOUBLE O O   O  
>DECIMAL(NUMERIC) O O   O  
>DATE (1000-01-01 ~ 9999-12-31, YYYY-MM-DD)          
>DATETIME (1000-01-01 00:00:00 ~ 9999-12-31 23:59:59, YYYY-MM-DD HH:MM:SS)          
>TIMESTAMP (1970-01-01 00:00:00 ~ 2106..., YYYYMMDD[HH[MM[SS]]]) O        
>TIME (-838:59:59 ~ 838:59:59, HH:MM:SS)          
>YEAR (1901 ~ 2155, 0000, YYYY)          
>CHAR O       O
>VARCHAR O       O
>TINYTEXT (0 ~ 255)          
>TEXT (0 ~ 65535)          
>MEDIUMTEXT (0 ~ 16777215)          
>LONGTEXT (0 ~ 4294967295)          
>TINYBLOB (0 ~ 255)          
>BLOB (0 ~ 65535)          
>MEDIUMBLOB (0 ~ 16777215)          
>LONGBLOB (0 ~ 4294967295)          
>ENUM
value list
>SET
value list
MDunsignedzerofillbinaryvalue list (ex: 'apple', 'orange', 'banana')
> > > > > >

Flags

not nulldefault valueauto incrementprimary keykey
> > > > >

\n"; else if( $cmd == "edit" ) echo "\n"; echo "\n"; echo "

\n"; } function manageField_submit( $cmd ) { global $mysqlHandle, $dbname, $tablename, $old_name, $name, $type, $PHP_SELF, $queryStr, $errMsg, $M, $D, $unsigned, $zerofill, $binary, $not_null, $default_value, $auto_increment, $primary_key, $key, $valuelist; if( $cmd == "add" ) $queryStr = "ALTER TABLE `$tablename` ADD `$name` "; else if( $cmd == "edit" ) $queryStr = "ALTER TABLE `$tablename` CHANGE `$old_name` `$name` "; if( $M != "" ) if( $D != "" ) $queryStr .= "$type($M,$D) "; else $queryStr .= "$type($M) "; else if( $valuelist != "" ) { $valuelist = stripslashes( $valuelist ); $queryStr .= "$type($valuelist) "; } else $queryStr .= "$type "; $queryStr .= "$unsigned $zerofill $binary "; if( $default_value != "" ) $queryStr .= "DEFAULT '$default_value' "; $queryStr .= "$not_null $auto_increment"; mysql_select_db( $dbname, $mysqlHandle ); mysql_query( $queryStr, $mysqlHandle ); $errMsg = mysql_error(); // key change $keyChange = false; $keyange = false; $result = mysql_query( "SHOW KEYS FROM `$tablename`" ); $primary = ""; while( $row = mysql_fetch_array($result) ) if( $row["Key_name"] == "PRIMARY" ) { if( $row[Column_name] == $name ) $keyChange = true; else $primary .= ", $row[Column_name]"; } if( $row["Key_name"] == $name ) { $keyange = true; } else { $keyange = false; } if( $primary_key == "PRIMARY KEY" ) { $primary .= ", $name"; $keyChange = !$keyChange; } $primary = substr( $primary, 2 ); if( $keyChange == true ) { $q = "ALTER TABLE `$tablename` DROP PRIMARY KEY"; mysql_query( $q ); $queryStr .= "
\n" . $q; $errMsg .= "
\n" . mysql_error(); $q = "ALTER TABLE `$tablename` ADD PRIMARY KEY( `$primary` )"; mysql_query( $q ); $queryStr .= "
\n" . $q; $errMsg .= "
\n" . mysql_error(); } if( $key == "MUL" ) { $keyange = !$keyange; } if( $keyange == false ) { $q = "ALTER TABLE `$tablename` DROP INDEX `$name`"; mysql_query( $q ); $queryStr .= "
\n" . $q; $errMsg .= "
\n" . mysql_error(); } else { $q = "ALTER TABLE `$tablename` ADD INDEX ( `$name` )"; mysql_query( $q ); $queryStr .= "
\n" . $q; $errMsg .= "
\n" . mysql_error(); } viewSchema(); } function dropField() { global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg; $queryStr = "ALTER TABLE `$tablename` DROP COLUMN `$fieldname`"; mysql_select_db( $dbname, $mysqlHandle ); mysql_query( $queryStr , $mysqlHandle ); $errMsg = mysql_error(); viewSchema(); } function addmfile( $queryStr ) { global $mysqlHandle, $tablename, $queryStr, $PHP_SELF, $dbname, $HOSTNAME, $USERNAME, $PASSWORD; $queryStr = ""; $queryStr = stripslashes($queryStr); $file = "temp.php"; $fp = fopen($file, "w"); fwrite($fp, $queryStr); fclose($fp); echo ""; echo ""; } function viewData( $queryStr ) { global $mysqlHandle, $dbname, $tablename, $PHP_SELF, $errMsg, $page, $rowperpage, $orderby; #print_r($GLOBALS); echo "

Data in Table

\n"; if( $tablename != "" ) echo "

$dbname > $tablename

\n"; else echo "

$dbname

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; if($_POST[queryStr]) $queryStr = $_POST[queryStr]; $queryStr = stripslashes( $queryStr ); if($queryStr) echo ""; else echo ""; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "
\n"; $queryStr = preg_replace("/[\r\n]+#[\s]?[\r\n]+/i", "\r\n", $queryStr); $queryStr = preg_replace("/^#.+$/im", "", $queryStr); $queryStr = preg_replace("/[\r\n]+--[\s]?[\r\n]+/i", "\r\n", $queryStr); $queryStr = preg_replace("/^--.+$/im", "", $queryStr); $queryStr = preg_replace("/[\r\n]+/i", "\r\n", $queryStr); $querySS = preg_split("/;[\s]*$/im", $queryStr); $queryStrnum = count($querySS); if($queryStrnum > 1 && strlen($querySS[1]) > 10) { for($i = 0;$i < $queryStrnum;$i++) { $pResult = mysql_db_query( $dbname, $querySS[$i] ); $errMsg = mysql_error(); } } else { if( $queryStr == "" ) { $queryStr = "SELECT * FROM `$tablename`"; if( $orderby != "" ) $queryStr .= " ORDER BY $orderby"; echo "Add Data | \n"; echo "Schema\n"; } $pResult = mysql_db_query( $dbname, $queryStr ); $errMsg = mysql_error(); $GLOBALS[queryStr] = $queryStr; if( $pResult == false ) { echoQueryResult(); return; } if( $pResult == 1 ) { $errMsg = "Success"; echoQueryResult(); return; } echo "
\n"; $row = mysql_num_rows( $pResult ); $col = mysql_num_fields( $pResult ); if( $row == 0 ) { echo "No Data Exist!"; return; } if( $rowperpage == "" ) $rowperpage = 50; if( $page == "" ) $page = 0; else $page--; mysql_data_seek( $pResult, $page * $rowperpage ); echo "\n"; echo "\n"; for( $i = 0; $i < $col; $i++ ) { $field = mysql_fetch_field( $pResult, $i ); echo "\n"; } echo "\n"; echo "\n"; for( $i = 0; $i < $rowperpage; $i++ ) { $rowArray = mysql_fetch_row( $pResult ); if( $rowArray == false ) break; echo "\n"; $key = ""; for( $j = 0; $j < $col; $j++ ) { $data = $rowArray[$j]; $field = mysql_fetch_field( $pResult, $j ); if( $field->primary_key == 1 ) $key .= "&" . $field->name . "=" . $data; if( strlen( $data ) > 20 ) $data = substr( $data, 0, 20 ) . "..."; $data = htmlspecialchars( $data ); echo "\n"; } if( $key == "" ) echo "\n"; else { #echo $tablename; echo "\n"; echo "\n"; } echo "\n"; } echo "
"; echo "".$field->name."\n"; echo "Action
\n"; echo "$data\n"; echo "no KeyEditDelete
\n"; echo "\n"; if( $_GET[queryStr] ||$_GET[queryStr] = $_POST[queryStr]) { echo "\n"; } else { echo "\n"; } echo "\n"; $lastrowpage = (int)($row/$rowperpage+1); echo ($page+1)."/".$lastrowpage." page"; echo "\n"; echo " | "; if( $page > 0 ) { if( $_GET[queryStr] ||$_GET[queryStr] = $_POST[queryStr]) { echo "Prev\n"; } else echo "Prev"; echo " | "; if( $page < ($row/$rowperpage)-1 ) { if( $_GET[queryStr] ) { echo "Next\n"; } else echo "Next"; echo " | "; if( $row > $rowperpage ) { if( $_GET[queryStr] ||$_GET[queryStr] = $_POST[queryStr]) { $pagegogo = "$PHP_SELF?action=query&dbname=$dbname&queryStr=$_GET[queryStr]&page="; } else { $pagegogo = "$PHP_SELF?action=viewData&dbname=$dbname&tablename=$tablename&page="; } $pagegogo .= ""; echo "\n"; echo "\n"; } echo "\n"; echo "
\n"; } } function manageData( $cmd ) { global $mysqlHandle, $dbname, $tablename, $PHP_SELF; if( $cmd == "add" ) echo "

Add Data

\n"; else if( $cmd == "edit" ) { echo "

Edit Data

\n"; $pResult = mysql_list_fields( $dbname, $tablename ); $num = mysql_num_fields( $pResult ); $key = ""; for( $i = 0; $i < $num; $i++ ) { $field = mysql_fetch_field( $pResult, $i ); if( $field->primary_key == 1 ) if( $field->numeric == 1 ) $key .= $field->name . "=" . $GLOBALS[$field->name] . " AND "; else $key .= $field->name . "='" . $GLOBALS[$field->name] . "' AND "; } $key = substr( $key, 0, strlen($key)-4 ); mysql_select_db( $dbname, $mysqlHandle ); $pResult = mysql_query( $queryStr = "SELECT * FROM `$tablename` WHERE $key", $mysqlHandle ); $data = mysql_fetch_array( $pResult ); } echo "

$dbname > $tablename

\n"; echo "
\n"; if( $cmd == "add" ) echo "\n"; else if( $cmd == "edit" ) echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $pResult = mysql_db_query( $dbname, "SHOW fields FROM `$tablename`" ); $num = mysql_num_rows( $pResult ); $pResultLen = mysql_list_fields( $dbname, $tablename ); for( $i = 0; $i < $num; $i++ ) { $field = mysql_fetch_array( $pResult ); $fieldname = $field["Field"]; $fieldtype = $field["Type"]; $len = mysql_field_len( $pResultLen, $i ); echo ""; echo ""; echo ""; echo "\n"; $value = htmlspecialchars($data[$i]); if( $cmd == "add" ) { $type = strtok( $fieldtype, " (,)\n" ); if( $type == "enum" || $type == "set" ) { echo "\n"; } else { if( $len < 40 ) echo "\n"; else echo "\n"; } else { if( $len < 40 ) echo "\n"; else echo ""; } echo "
NameTypeFunctionData
$fieldname".$field["Type"]."\n"; echo "\n"; echo "\n"; if( $type == "enum" ) echo "\n"; echo strtok( "'" ); while( $str = strtok( "'" ) ) { echo "\n"; } } else if( $cmd == "edit" ) { $type = strtok( $fieldtype, " (,)\n" ); if( $type == "enum" || $type == "set" ) { echo "\n"; if( $type == "enum" ) echo "\n"; echo strtok( "'" ); while( $str = strtok( "'" ) ) { if( $value == $str ) echo "\n"; } } echo "

\n"; if( $cmd == "add" ) echo "\n"; else if( $cmd == "edit" ) echo "\n"; echo "\n"; echo "

\n"; } function manageData_submit( $cmd ) { global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg; $pResult = mysql_list_fields( $dbname, $tablename ); $num = mysql_num_fields( $pResult ); mysql_select_db( $dbname, $mysqlHandle ); if( $cmd == "add" ) $queryStr = "INSERT INTO `$tablename` VALUES ("; else if( $cmd == "edit" ) $queryStr = "REPLACE INTO `$tablename` VALUES ("; for( $i = 0; $i < $num-1; $i++ ) { $field = mysql_fetch_field( $pResult ); $func = $GLOBALS[$field->name."_function"]; if( $func != "" ) $queryStr .= " $func("; if( $field->numeric == 1 ) { $queryStr .= $GLOBALS[$field->name]; if( $func != "" ) $queryStr .= "),"; else $queryStr .= ","; } else { $queryStr .= "'" . $GLOBALS[$field->name]; if( $func != "" ) $queryStr .= "'),"; else $queryStr .= "',"; } } $field = mysql_fetch_field( $pResult ); if( $field->numeric == 1 ) $queryStr .= $GLOBALS[$field->name] . ")"; else $queryStr .= "'" . $GLOBALS[$field->name] . "')"; mysql_query( $queryStr , $mysqlHandle ); $errMsg = mysql_error(); viewData( "" ); } function deleteData() { global $mysqlHandle, $dbname, $tablename, $fieldname, $PHP_SELF, $queryStr, $errMsg; $pResult = mysql_list_fields( $dbname, $tablename ); $num = mysql_num_fields( $pResult ); $key = ""; for( $i = 0; $i < $num; $i++ ) { $field = mysql_fetch_field( $pResult, $i ); if( $field->primary_key == 1 ) if( $field->numeric == 1 ) $key .= $field->name . "=" . $GLOBALS[$field->name] . " AND "; else $key .= $field->name . "='" . $GLOBALS[$field->name] . "' AND "; } $key = substr( $key, 0, strlen($key)-4 ); mysql_select_db( $dbname, $mysqlHandle ); $queryStr = "DELETE FROM `$tablename` WHERE $key"; mysql_query( $queryStr, $mysqlHandle ); $errMsg = mysql_error(); viewData( "" ); } function utils() { global $PHP_SELF, $command; echo "

Utilities

\n"; if( $command == "" || substr( $command, 0, 5 ) == "flush" ) { echo "
\n"; echo "Show\n"; echo "\n"; echo "Flush\n"; echo "\n"; } else { $queryStr = ereg_replace( "_", " ", $command ); $pResult = mysql_query( $queryStr ); if( $pResult == false ) { echo "Fail"; return; } $col = mysql_num_fields( $pResult ); echo "

$queryStr

\n"; echo "
\n"; echo "\n"; echo "\n"; for( $i = 0; $i < $col; $i++ ) { $field = mysql_fetch_field( $pResult, $i ); echo "\n"; } echo "\n"; while( 1 ) { $rowArray = mysql_fetch_row( $pResult ); if( $rowArray == false ) break; echo "\n"; for( $j = 0; $j < $col; $j++ ) echo "\n"; echo "\n"; } echo "
".$field->name."
".htmlspecialchars( $rowArray[$j] )."
\n"; } } function header_html() { global $PHP_SELF; ?> MySQL Web Interface \n"; echo "\n"; echo "[$USERNAME] - \n"; echo "Table List | "; echo "Utils |\n"; echo "Logout | \n"; echo "Database List\n"; echo "\n"; echo "\n"; echo "\n"; } //------------------------------------------------------ MAIN if( $action == "logon" || $action == "" || $action == "logout" ) logon(); else if( $action == "logon_submit" ) logon_submit(); else if( $action == "dumpTable" || $action == "dumpDB" ) { while( list($var, $value) = each($HTTP_COOKIE_VARS) ) { if( $var == "mysql_web_admin_username" ) $USERNAME = $value; if( $var == "mysql_web_admin_password" ) $PASSWORD = $value; } $mysqlHandle = mysql_pconnect( $HOSTNAME, $USERNAME, $PASSWORD ); dump(); } else { while( list($var, $value) = each($HTTP_COOKIE_VARS) ) { if( $var == "mysql_web_admin_username" ) $USERNAME = $value; if( $var == "mysql_web_admin_password" ) $PASSWORD = $value; } echo ""; if( $mysqlHandle == false ) { echo "\n"; echo "\n"; echo "MySQL Web Interface\n"; echo "\n"; echo "\n"; echo "
\n"; echo "

Wrong Password!

\n"; echo "Logon\n"; echo "
\n"; echo "\n"; echo "\n"; } else { header_html(); if( $action == "listDBs" ) listDatabases(); else if( $action == "createDB" ) createDatabase(); else if( $action == "dropDB" ) dropDatabase(); else if( $action == "listTables" ) listTables(); else if( $action == "createTable" ) createTable(); else if( $action == "truncate" ) truncateTable(); else if( $action == "dropTable" ) dropTable(); else if( $action == "viewSchema" ) viewSchema(); else if( $action == "query" ) viewData( $queryStr ); else if( $action == "addsql" ) addsqlfile( "filename" ); else if( $action == "kuery" ) addmfile( $queryStr ); else if( $action == "addField" ) manageField( "add" ); else if( $action == "addField_submit" ) manageField_submit( "add" ); else if( $action == "editField" ) manageField( "edit" ); else if( $action == "editField_submit" ) manageField_submit( "edit" ); else if( $action == "dropField" ) dropField(); else if( $action == "viewData" ) viewData( "" ); else if( $action == "addData" ) manageData( "add" ); else if( $action == "addData_submit" ) manageData_submit( "add" ); else if( $action == "editData" ) manageData( "edit" ); else if( $action == "editData_submit" ) manageData_submit( "edit" ); else if( $action == "deleteData" ) deleteData(); else if( $action == "utils" ) utils(); mysql_close( $mysqlHandle); footer_html(); } } ?>