From 5b892eafafb1f41bab1a20f1524cef144042e3e1 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 8 Jan 2024 20:31:32 +0000 Subject: sql injection prevention --- includes/fix_mysql.inc.php | 257 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100755 includes/fix_mysql.inc.php (limited to 'includes/fix_mysql.inc.php') diff --git a/includes/fix_mysql.inc.php b/includes/fix_mysql.inc.php new file mode 100755 index 0000000..8ff45bf --- /dev/null +++ b/includes/fix_mysql.inc.php @@ -0,0 +1,257 @@ += 0){ + mysqli_data_seek($result, $row); + $resultrow = (is_numeric($col)) ? mysqli_fetch_row($result) : mysqli_fetch_assoc($result); + if (isset($resultrow[$col])){ + return $resultrow[$col]; + } + } + return false; + } + + function mysql_escape_string($s, $link_identifier = null){ + global $global_link_identifier; + if($link_identifier == null) { + $link_identifier = $global_link_identifier; + } + return mysqli_real_escape_string($link_identifier, $s); + } + + function mysql_fetch_field($result, $i = null) { + if ($i === null) { + return mysqli_fetch_field($result); + } + return mysqli_fetch_field_direct($result, $i); + } + + function mysql_field_name($result, $i) { + return mysqli_fetch_field_direct($result, $i)->name; + } + + function mysql_field_type($result, $i){ + return mysqli_fetch_field_direct($result, $i)->type; + } + + function mysql_field_len($result, $i){ + return mysqli_fetch_field_direct($result, $i)->length; + } + + function mysql_num_fields($result){ + return mysqli_num_fields($result); + } + + function mysql_free_result($result) { + return mysqli_free_result($result); + } + + function mysql_get_server_info($link_identifier = null){ + global $global_link_identifier; + if($link_identifier == null) { + $link_identifier = $global_link_identifier; + } + return mysqli_get_server_info($link_identifier); + } + + function mysql_set_charset($csname, $link_identifier = null){ + global $global_link_identifier; + if($link_identifier == null) { + $link_identifier = $global_link_identifier; + } + return mysqli_set_charset($link_identifier, $csname); + } + + // aliases + function mysql(...$args){ return mysql_db_query(...$args); } + function mysql_createdb(...$args){ return mysql_create_db(...$args); } + function mysql_db_name(...$args){ return mysql_result(...$args); } + function mysql_dbname(...$args){ return mysql_result(...$args); } + function mysql_dropdb(...$args){ return mysql_drop_db(...$args); } + function mysql_fieldflags(...$args){ return mysql_field_flags(...$args); } + function mysql_fieldlen(...$args){ return mysql_field_len(...$args); } + function mysql_fieldname(...$args){ return mysql_field_name(...$args); } + function mysql_fieldtable(...$args){ return mysql_field_table(...$args); } + function mysql_fieldtype(...$args){ return mysql_field_type(...$args); } + function mysql_freeresult(...$args){ return mysql_free_result(...$args); } + function mysql_listdbs(...$args){ return mysql_list_dbs(...$args); } + function mysql_listfields(...$args){ return mysql_list_fields(...$args); } + function mysql_listtables(...$args){ return mysql_list_tables(...$args); } + function mysql_numfields(...$args){ return mysql_num_fields(...$args); } + function mysql_numrows(...$args){ return mysql_num_rows(...$args); } + function mysql_selectdb(...$args){ return mysql_select_db(...$args); } + + // TODO: those functions are not defined yet: + function mysql_client_encoding(){ trigger_error("mysql_client_encoding is not defined yet", E_USER_ERROR); } + function mysql_create_db(){ trigger_error("mysql_create_db is not defined yet", E_USER_ERROR); } + function mysql_drop_db(){ trigger_error("mysql_drop_db is not defined yet", E_USER_ERROR); } + function mysql_fetch_lengths(){ trigger_error("mysql_fetch_lengths is not defined yet", E_USER_ERROR); } + function mysql_field_flags(){ trigger_error("mysql_field_flags is not defined yet", E_USER_ERROR); } + function mysql_field_seek(){ trigger_error("mysql_field_seek is not defined yet", E_USER_ERROR); } + function mysql_field_table(){ trigger_error("mysql_field_table is not defined yet", E_USER_ERROR); } + function mysql_get_client_info(){ trigger_error("mysql_get_client_info is not defined yet", E_USER_ERROR); } + function mysql_get_host_info(){ trigger_error("mysql_get_host_info is not defined yet", E_USER_ERROR); } + function mysql_get_proto_info(){ trigger_error("mysql_get_proto_info is not defined yet", E_USER_ERROR); } + function mysql_info(){ trigger_error("mysql_info is not defined yet", E_USER_ERROR); } + function mysql_list_dbs(){ trigger_error("mysql_list_dbs is not defined yet", E_USER_ERROR); } + function mysql_list_fields(){ trigger_error("mysql_list_fields is not defined yet", E_USER_ERROR); } + function mysql_list_processes(){ trigger_error("mysql_list_processes is not defined yet", E_USER_ERROR); } + function mysql_tablename(){ trigger_error("mysql_tablename is not defined yet", E_USER_ERROR); } + function mysql_stat(){ trigger_error("mysql_stat is not defined yet", E_USER_ERROR); } + function mysql_thread_id(){ trigger_error("mysql_thread_id is not defined yet", E_USER_ERROR); } + function mysql_unbuffered_query(){ trigger_error("mysql_unbuffered_query is not defined yet", E_USER_ERROR); } +} -- cgit 1.4.1