2009-07-03 05:16:39 +00:00
< ? php
2020-12-09 14:09:28 +00:00
function adminer_errors ( $errno , $errstr ) {
return !! preg_match ( '~^(Trying to access array offset on value of type null|Undefined array key)~' , $errstr );
}
error_reporting ( 6135 ); // errors and warnings
2021-02-23 11:42:11 +00:00
set_error_handler ( 'adminer_errors' , E_WARNING );
2009-07-03 05:16:39 +00:00
2009-07-24 15:50:35 +00:00
include " ../adminer/include/coverage.inc.php " ;
2009-07-03 05:16:39 +00:00
// disable filter.default
2013-07-24 23:26:41 +00:00
$filter = ! preg_match ( '~^(unsafe_raw)?$~' , ini_get ( " filter.default " ));
2011-07-22 11:37:01 +00:00
if ( $filter || ini_get ( " filter.default_flags " )) {
2009-07-03 10:10:40 +00:00
foreach ( array ( '_GET' , '_POST' , '_COOKIE' , '_SERVER' ) as $val ) {
$unsafe = filter_input_array ( constant ( " INPUT $val " ), FILTER_UNSAFE_RAW );
if ( $unsafe ) {
$$val = $unsafe ;
}
}
2009-07-03 05:16:39 +00:00
}
2013-01-10 06:41:46 +00:00
if ( function_exists ( " mb_internal_encoding " )) {
mb_internal_encoding ( " 8bit " );
}
2012-12-01 23:57:04 +00:00
2018-02-19 22:48:51 +00:00
include " ../adminer/include/functions.inc.php " ;
2009-07-03 05:16:39 +00:00
// used only in compiled file
if ( isset ( $_GET [ " file " ])) {
2010-04-23 20:18:00 +00:00
include " ../adminer/file.inc.php " ;
2009-07-03 05:16:39 +00:00
}
2018-02-19 22:02:39 +00:00
if ( $_GET [ " script " ] == " version " ) {
$fp = file_open_lock ( get_temp_dir () . " /adminer.version " );
if ( $fp ) {
file_write_unlock ( $fp , serialize ( array ( " signature " => $_POST [ " signature " ], " version " => $_POST [ " version " ])));
}
exit ;
}
2018-02-25 11:53:25 +00:00
global $adminer , $connection , $driver , $drivers , $edit_functions , $enum_length , $error , $functions , $grouping , $HTTPS , $inout , $jush , $LANG , $langs , $on_actions , $permanent , $structured_types , $has_token , $token , $translations , $types , $unsigned , $VERSION ; // allows including Adminer inside a function
2012-08-20 00:12:19 +00:00
2011-09-08 21:48:34 +00:00
if ( ! $_SERVER [ " REQUEST_URI " ]) { // IIS 5 compatibility
2013-05-08 18:29:19 +00:00
$_SERVER [ " REQUEST_URI " ] = $_SERVER [ " ORIG_PATH_INFO " ];
2011-09-08 21:48:34 +00:00
}
if ( ! strpos ( $_SERVER [ " REQUEST_URI " ], '?' ) && $_SERVER [ " QUERY_STRING " ] != " " ) { // IIS 7 compatibility
$_SERVER [ " REQUEST_URI " ] .= " ? $_SERVER[QUERY_STRING] " ;
2009-07-30 08:12:54 +00:00
}
2018-01-31 17:11:03 +00:00
if ( $_SERVER [ " HTTP_X_FORWARDED_PREFIX " ]) {
$_SERVER [ " REQUEST_URI " ] = $_SERVER [ " HTTP_X_FORWARDED_PREFIX " ] . $_SERVER [ " REQUEST_URI " ];
}
2018-04-08 13:57:05 +00:00
$HTTPS = ( $_SERVER [ " HTTPS " ] && strcasecmp ( $_SERVER [ " HTTPS " ], " off " )) || ini_bool ( " session.cookie_secure " ); // session.cookie_secure could be set on HTTP if we are behind a reverse proxy
2009-07-30 08:12:54 +00:00
2009-11-02 21:10:27 +00:00
@ ini_set ( " session.use_trans_sid " , false ); // protect links in export, @ - may be disabled
2010-10-09 13:39:57 +00:00
if ( ! defined ( " SID " )) {
2018-01-16 15:56:14 +00:00
session_cache_limiter ( " " ); // to allow restarting session
2010-04-02 13:25:49 +00:00
session_name ( " adminer_sid " ); // use specific session name to get own namespace
2018-02-20 15:27:40 +00:00
$params = array ( 0 , preg_replace ( '~\?.*~' , '' , $_SERVER [ " REQUEST_URI " ]), " " , $HTTPS );
2010-04-02 13:25:49 +00:00
if ( version_compare ( PHP_VERSION , '5.2.0' ) >= 0 ) {
$params [] = true ; // HttpOnly
}
call_user_func_array ( 'session_set_cookie_params' , $params ); // ini_set() may be disabled
session_start ();
2009-07-03 05:16:39 +00:00
}
// disable magic quotes to be able to use database escaping function
2011-07-22 11:37:01 +00:00
remove_slashes ( array ( & $_GET , & $_POST , & $_COOKIE ), $filter );
2020-10-20 19:04:33 +00:00
if ( function_exists ( " get_magic_quotes_runtime " ) && get_magic_quotes_runtime ()) {
2009-09-14 15:12:51 +00:00
set_magic_quotes_runtime ( false );
}
2009-08-25 12:11:12 +00:00
@ set_time_limit ( 0 ); // @ - can be disabled
2010-10-18 21:09:26 +00:00
@ ini_set ( " zend.ze1_compatibility_mode " , false ); // @ - deprecated
2018-02-08 22:57:11 +00:00
@ ini_set ( " precision " , 15 ); // @ - can be disabled, 15 - internal PHP precision
2009-07-03 06:26:01 +00:00
2010-04-21 12:01:32 +00:00
include " ../adminer/include/lang.inc.php " ;
include " ../adminer/lang/ $LANG .inc.php " ;
include " ../adminer/include/pdo.inc.php " ;
2013-07-05 16:04:06 +00:00
include " ../adminer/include/driver.inc.php " ;
2010-04-21 12:01:32 +00:00
include " ../adminer/drivers/sqlite.inc.php " ;
include " ../adminer/drivers/pgsql.inc.php " ;
2010-05-14 16:37:06 +00:00
include " ../adminer/drivers/oracle.inc.php " ;
2010-04-21 12:01:32 +00:00
include " ../adminer/drivers/mssql.inc.php " ;
2013-08-08 20:24:20 +00:00
include " ../adminer/drivers/mongo.inc.php " ;
2013-07-10 00:38:13 +00:00
include " ../adminer/drivers/elastic.inc.php " ;
2021-02-08 18:56:15 +00:00
include " ./include/adminer.inc.php " ;
2021-02-09 09:19:05 +00:00
$adminer = ( function_exists ( 'adminer_object' ) ? adminer_object () : new Adminer );
2010-04-21 12:01:32 +00:00
include " ../adminer/drivers/mysql.inc.php " ; // must be included as last driver
2010-02-24 12:00:31 +00:00
2021-02-08 17:36:05 +00:00
$config = driver_config ();
$possible_drivers = $config [ 'possible_drivers' ];
$jush = $config [ 'jush' ];
$types = $config [ 'types' ];
$structured_types = $config [ 'structured_types' ];
$unsigned = $config [ 'unsigned' ];
$operators = $config [ 'operators' ];
2023-05-22 02:47:33 +00:00
$operator_regexp = isset ( $config [ 'operator_regexp' ]) && in_array ( $config [ 'operator_regexp' ], $operators ) ? $config [ 'operator_regexp' ] : null ;
2021-02-08 17:36:05 +00:00
$functions = $config [ 'functions' ];
$grouping = $config [ 'grouping' ];
$edit_functions = $config [ 'edit_functions' ];
2021-02-09 09:19:05 +00:00
if ( $adminer -> operators === null ) {
$adminer -> operators = $operators ;
2023-05-22 02:47:33 +00:00
$adminer -> operator_regexp = $operator_regexp ;
2021-02-09 09:19:05 +00:00
}
2021-02-08 17:36:05 +00:00
2010-04-21 12:01:32 +00:00
define ( " SERVER " , $_GET [ DRIVER ]); // read from pgsql=localhost
2009-08-29 13:54:25 +00:00
define ( " DB " , $_GET [ " db " ]); // for the sake of speed and size
2020-05-11 10:35:19 +00:00
define ( " ME " , preg_replace ( '~\?.*~' , '' , relative_uri ()) . '?'
2010-12-20 17:09:13 +00:00
. ( sid () ? SID . '&' : '' )
2010-04-21 12:01:32 +00:00
. ( SERVER !== null ? DRIVER . " = " . urlencode ( SERVER ) . '&' : '' )
. ( isset ( $_GET [ " username " ]) ? " username= " . urlencode ( $_GET [ " username " ]) . '&' : '' )
2010-05-05 16:30:55 +00:00
. ( DB != " " ? 'db=' . urlencode ( DB ) . '&' . ( isset ( $_GET [ " ns " ]) ? " ns= " . urlencode ( $_GET [ " ns " ]) . " & " : " " ) : '' )
2010-04-21 12:01:32 +00:00
);
2009-07-11 19:45:57 +00:00
2010-04-21 12:01:32 +00:00
include " ../adminer/include/version.inc.php " ;
2009-07-11 19:45:57 +00:00
include " ../adminer/include/design.inc.php " ;
2010-01-08 17:12:03 +00:00
include " ../adminer/include/xxtea.inc.php " ;
2009-07-21 12:19:25 +00:00
include " ../adminer/include/auth.inc.php " ;
2012-08-20 00:12:19 +00:00
include " ./include/editing.inc.php " ;
2014-03-01 19:38:38 +00:00
include " ./include/connect.inc.php " ;
2012-08-20 00:12:19 +00:00
2011-08-29 11:32:06 +00:00
$on_actions = " RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT " ; ///< @var string used in foreign_keys()