2007-07-02 05:51:26 +00:00
< ? php
2007-07-09 14:48:46 +00:00
// Copyright 2007 Jakub Vrana http://phpminadmin.sourceforge.net, licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License.
2007-07-05 10:34:19 +00:00
2007-07-02 05:51:26 +00:00
session_start ();
error_reporting ( E_ALL & ~ E_NOTICE );
2007-07-02 20:21:30 +00:00
$SELF = preg_replace ( '~^[^?]*/([^?]*).*~' , '\\1?' , $_SERVER [ " REQUEST_URI " ]) . ( strlen ( $_GET [ " server " ]) ? 'server=' . urlencode ( $_GET [ " server " ]) . '&' : '' ) . ( strlen ( $_GET [ " db " ]) ? 'db=' . urlencode ( $_GET [ " db " ]) . '&' : '' );
2007-07-10 13:51:37 +00:00
$TOKENS = & $_SESSION [ " tokens " ][ $_GET [ " server " ]][ $_SERVER [ " REQUEST_URI " ]];
2007-07-02 05:51:26 +00:00
include " ./functions.inc.php " ;
2007-07-10 06:30:04 +00:00
include " ./lang.inc.php " ;
2007-07-26 16:47:28 +00:00
include " ./lang/ $LANG .inc.php " ;
2007-07-02 05:51:26 +00:00
include " ./design.inc.php " ;
2007-07-10 13:30:42 +00:00
include " ./abstraction.inc.php " ;
2007-07-02 05:51:26 +00:00
include " ./auth.inc.php " ;
include " ./connect.inc.php " ;
2007-07-05 10:45:23 +00:00
if ( isset ( $_GET [ " dump " ])) {
2007-07-02 05:51:26 +00:00
include " ./dump.inc.php " ;
2007-07-09 06:12:22 +00:00
} elseif ( isset ( $_GET [ " download " ])) {
include " ./download.inc.php " ;
2007-07-16 11:41:25 +00:00
} else { // outputs footer
2007-07-13 13:37:07 +00:00
$on_actions = array ( " RESTRICT " , " CASCADE " , " SET NULL " , " NO ACTION " );
2007-07-15 10:48:22 +00:00
$types = array (
" tinyint " => 3 , " smallint " => 5 , " mediumint " => 8 , " int " => 10 , " bigint " => 20 ,
" float " => 12 , " double " => 21 , " decimal " => 66 ,
" date " => 10 , " datetime " => 19 , " timestamp " => 19 , " time " => 10 , " year " => 4 ,
" char " => 255 , " varchar " => 65535 ,
" binary " => 255 , " varbinary " => 65535 ,
" tinytext " => 255 , " text " => 65535 , " mediumtext " => 16777215 , " longtext " => 4294967295 ,
" tinyblob " => 255 , " blob " => 65535 , " mediumblob " => 16777215 , " longblob " => 4294967295 ,
" enum " => 65535 , " set " => 64 ,
);
$unsigned = array ( " " , " unsigned " , " zerofill " , " unsigned zerofill " );
2007-07-16 13:38:45 +00:00
$enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"' ;
2007-07-16 13:56:34 +00:00
$inout = array ( " IN " , " OUT " , " INOUT " );
2007-07-15 10:48:22 +00:00
2007-07-06 18:08:17 +00:00
if ( isset ( $_GET [ " table " ])) {
2007-07-05 10:45:23 +00:00
include " ./table.inc.php " ;
} elseif ( isset ( $_GET [ " select " ])) {
include " ./select.inc.php " ;
} elseif ( isset ( $_GET [ " view " ])) {
include " ./view.inc.php " ;
2007-07-17 07:23:17 +00:00
} elseif ( isset ( $_GET [ " schema " ])) {
include " ./schema.inc.php " ;
2007-07-16 11:41:25 +00:00
} else { // uses CSRF token
2007-07-16 22:40:55 +00:00
include " ./editing.inc.php " ;
2007-07-06 18:08:17 +00:00
if ( $_POST ) {
2007-07-09 06:12:22 +00:00
$error = ( in_array ( $_POST [ " token " ], ( array ) $TOKENS ) ? " " : lang ( 'Invalid CSRF token. Send the form again.' ));
2007-07-06 18:08:17 +00:00
}
2007-07-09 06:12:22 +00:00
$token = ( $_POST && ! $error ? $_POST [ " token " ] : token ());
2007-07-09 14:48:46 +00:00
if ( isset ( $_GET [ " default " ])) {
$_GET [ " edit " ] = $_GET [ " default " ];
}
if ( isset ( $_GET [ " callf " ])) {
$_GET [ " call " ] = $_GET [ " callf " ];
}
2007-07-16 22:40:55 +00:00
if ( isset ( $_GET [ " function " ])) {
$_GET [ " procedure " ] = $_GET [ " function " ];
2007-07-16 14:28:32 +00:00
}
2007-07-06 18:08:17 +00:00
if ( isset ( $_GET [ " sql " ])) {
include " ./sql.inc.php " ;
} elseif ( isset ( $_GET [ " edit " ])) {
include " ./edit.inc.php " ;
} elseif ( isset ( $_GET [ " create " ])) {
include " ./create.inc.php " ;
} elseif ( isset ( $_GET [ " indexes " ])) {
include " ./indexes.inc.php " ;
} elseif ( isset ( $_GET [ " database " ])) {
include " ./database.inc.php " ;
2007-07-09 07:29:02 +00:00
} elseif ( isset ( $_GET [ " call " ])) {
include " ./call.inc.php " ;
2007-07-11 16:02:57 +00:00
} elseif ( isset ( $_GET [ " foreign " ])) {
include " ./foreign.inc.php " ;
2007-07-16 12:17:16 +00:00
} elseif ( isset ( $_GET [ " createv " ])) {
include " ./createv.inc.php " ;
2007-07-16 22:40:55 +00:00
} elseif ( isset ( $_GET [ " procedure " ])) {
include " ./procedure.inc.php " ;
2007-07-23 15:23:42 +00:00
} elseif ( isset ( $_GET [ " trigger " ])) {
include " ./trigger.inc.php " ;
2007-07-16 13:26:37 +00:00
} elseif ( isset ( $_GET [ " processlist " ])) {
include " ./processlist.inc.php " ;
2007-07-06 18:08:17 +00:00
} else {
2007-07-09 06:12:22 +00:00
$TOKENS = array ();
2007-07-26 10:45:49 +00:00
page_header ( lang ( 'Database' ) . " : " . htmlspecialchars ( $_GET [ " db " ]), false );
2007-07-06 18:08:17 +00:00
echo '<p><a href="' . htmlspecialchars ( $SELF ) . 'database=">' . lang ( 'Alter database' ) . " </a></p> \n " ;
2007-07-17 07:23:17 +00:00
echo '<p><a href="' . htmlspecialchars ( $SELF ) . 'schema=">' . lang ( 'Database schema' ) . " </a></p> \n " ;
2007-07-10 13:30:42 +00:00
if ( $mysql -> server_info >= 5 ) {
2007-07-26 10:45:49 +00:00
echo '<p><a href="' . htmlspecialchars ( $SELF ) . 'createv=">' . lang ( 'Create view' ) . " </a></p> \n " ;
2007-07-17 07:23:17 +00:00
echo " <h3> " . lang ( 'Routines' ) . " </h3> \n " ;
2007-07-10 14:16:44 +00:00
$result = $mysql -> query ( " SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = ' " . $mysql -> escape_string ( $_GET [ " db " ]) . " ' " );
2007-07-10 13:30:42 +00:00
if ( $result -> num_rows ) {
2007-07-06 18:08:17 +00:00
echo " <table border='0' cellspacing='0' cellpadding='2'> \n " ;
2007-07-10 13:30:42 +00:00
while ( $row = $result -> fetch_assoc ()) {
2007-07-16 14:28:32 +00:00
echo " <tr> " ;
2007-07-06 18:08:17 +00:00
echo " <th> " . htmlspecialchars ( $row [ " ROUTINE_TYPE " ]) . " </th> " ;
2007-07-09 14:48:46 +00:00
echo '<td><a href="' . htmlspecialchars ( $SELF ) . ( $row [ " ROUTINE_TYPE " ] == " FUNCTION " ? 'callf' : 'call' ) . '=' . urlencode ( $row [ " ROUTINE_NAME " ]) . '">' . htmlspecialchars ( $row [ " ROUTINE_NAME " ]) . '</a></td>' ;
2007-07-16 22:40:55 +00:00
echo '<td><a href="' . htmlspecialchars ( $SELF ) . ( $row [ " ROUTINE_TYPE " ] == " FUNCTION " ? 'function' : 'procedure' ) . '=' . urlencode ( $row [ " ROUTINE_NAME " ]) . '">' . lang ( 'Alter' ) . " </a></td> \n " ;
2007-07-06 18:08:17 +00:00
echo " </tr> \n " ;
}
echo " </table> \n " ;
2007-07-06 09:55:51 +00:00
}
2007-07-10 13:30:42 +00:00
$result -> free ();
2007-07-17 09:12:15 +00:00
echo '<p><a href="' . htmlspecialchars ( $SELF ) . 'procedure=">' . lang ( 'Create procedure' ) . '</a> <a href="' . htmlspecialchars ( $SELF ) . 'function=">' . lang ( 'Create function' ) . " </a></p> \n " ;
2007-07-05 10:45:23 +00:00
}
2007-07-02 05:51:26 +00:00
}
}
2007-07-05 10:45:23 +00:00
page_footer ();
2007-07-02 05:51:26 +00:00
}