From 459e929311d8806f604c0b914ba4b37aa731fbfc Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 8 Jan 2024 21:09:05 +0000 Subject: Migrated to mysqli --- includes/db.php | 4 +- includes/fix_mysql.inc.php | 257 --------------------------------------------- includes/functions.php | 24 +++-- includes/update.php | 26 ++--- 4 files changed, 30 insertions(+), 281 deletions(-) delete mode 100755 includes/fix_mysql.inc.php (limited to 'includes') diff --git a/includes/db.php b/includes/db.php index 6554b8a..e2d67ee 100755 --- a/includes/db.php +++ b/includes/db.php @@ -1,9 +1,7 @@ diff --git a/includes/fix_mysql.inc.php b/includes/fix_mysql.inc.php deleted file mode 100755 index 8ff45bf..0000000 --- a/includes/fix_mysql.inc.php +++ /dev/null @@ -1,257 +0,0 @@ -= 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); } -} diff --git a/includes/functions.php b/includes/functions.php index edb666b..e0a5ab8 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -2,9 +2,12 @@ function has_meta($id, $name) { - $getmeta = "SELECT * FROM meta WHERE comic_id = " . $id . " AND name = \"" . $name . "\""; - $getmeta2 = mysql_query($getmeta); - $getmeta3 = mysql_fetch_array($getmeta2); + global $mysql_conn; + $getmeta = $mysql_conn->prepare("SELECT * FROM meta WHERE comic_id = ? AND name = ?"); + $getmeta->bind_param("is", $id, $name); + $getmeta->execute(); + $getmeta2 = $getmeta->get_result(); + $getmeta3 = $getmeta2->fetch_assoc(); if ($getmeta3['name'] == $name) { @@ -16,18 +19,21 @@ function has_meta($id, $name) function get_meta($id, $name) { - $getmeta = "SELECT * FROM meta WHERE comic_id = " . $id . " AND name = \"" . $name . "\""; - $getmeta2 = mysql_query($getmeta); - $getmeta3 = mysql_fetch_array($getmeta2); + global $mysql_conn; + $getmeta = $mysql_conn->prepare("SELECT * FROM meta WHERE comic_id = ? AND name = ?"); + $getmeta->bind_param("is", $id, $name); + $getmeta->execute(); + $getmeta2 = $getmeta->get_result(); + $getmeta3 = $getmeta2->fetch_assoc(); return $getmeta3['value']; } function next_comic_id() { - $getcomic = "SELECT * FROM comics WHERE status = \"publish\" ORDER BY comic_id DESC LIMIT 0,1"; - $getcomic2 = mysql_query($getcomic); - $getcomic3 = mysql_fetch_array($getcomic2); + global $mysql_conn; + $getcomic = $mysql_conn->query("SELECT * FROM comics WHERE status = \"publish\" ORDER BY comic_id DESC LIMIT 0,1"); + $getcomic3 = $getcomic->fetch_assoc(); return ($getcomic3['comic_id']+1); } diff --git a/includes/update.php b/includes/update.php index 6c8d9ff..3f2fae1 100755 --- a/includes/update.php +++ b/includes/update.php @@ -1,27 +1,29 @@ query("SELECT * FROM config WHERE name = \"lastUpdated\""); +$getlast3 = $getlast->fetch_assoc(); $last = $getlast3['value']; if ($last != date('md')) { - $getpending = "SELECT * FROM comics WHERE status = \"pending\" ORDER BY id ASC LIMIT 0,1"; - $getpending2 = mysql_query($getpending); - $getpending3 = mysql_fetch_array($getpending2); + $getpending = $mysql_conn->query("SELECT * FROM comics WHERE status = \"pending\" ORDER BY id ASC LIMIT 0,1"); + $getpending3 = $getpending->fetch_assoc(); if (!empty($getpending3)) { $id = next_comic_id(); - $setcomic = "UPDATE comics SET status = \"publish\", comic_id = " . $id . " WHERE id = " . $getpending3['id']; - $setcomic2 = mysql_query($setcomic) or die($setcomic); + $setcomic = $mysql_conn->prepare("UPDATE comics SET status = \"publish\", comic_id = ? WHERE id = ?"); + $setcomic->bind_param("ii", $id, $getpending3['id']); + $setcomic->execute() or die($setcomic); - $insmeta = "INSERT INTO meta (comic_id,name,value) VALUES (" . $getpending3['id'] . ",\"pubDate\",\"" . date('Y-m-d H:i:s') . "\")"; - $insmeta2 = mysql_query($insmeta) or die($insmeta); + $insmeta = $mysql_conn->prepare("INSERT INTO meta (comic_id,name,value) VALUES (?,\"pubDate\",\"" . date('Y-m-d H:i:s') . "\")"); + $insmeta->bind_param("i", $getpending3['id']); + $insmeta->execute() or die($insmeta); - $setconfig = "UPDATE config SET value = \"" . date('md') . "\" WHERE name = \"lastUpdated\""; - $setconfig2 = mysql_query($setconfig); + $setconfig = $mysql_conn->prepare("UPDATE config SET value = ? WHERE name = \"lastUpdated\""); + $newdate = date('md'); + $setconfig->bind_param("s", $newdate); + $setconfig->execute(); } } -- cgit 1.4.1