diff --git a/cron/calendar_reminders.php b/cron/calendar_reminders.php index eaa9d5f8..cfe12b39 100644 --- a/cron/calendar_reminders.php +++ b/cron/calendar_reminders.php @@ -23,7 +23,7 @@ if (hesk_check_maintenance(false)) { die($message); } -hesk_load_internal_api_database_functions(); +hesk_load_cron_database_functions(); hesk_dbConnect(); if ($hesk_settings['debug_mode']) { diff --git a/cron/core/database.inc.php b/cron/core/database.inc.php new file mode 100755 index 00000000..52a81271 --- /dev/null +++ b/cron/core/database.inc.php @@ -0,0 +1,248 @@ +EXPLAIN $query

\n"; + + if ($res = @mysqli_query($hesk_db_link, $query)) + { + return $res; + } + elseif ($hesk_settings['debug_mode']) + { + $message = 'Error executing SQL: ' . $query . '; ' . $hesklang['mysql_said'] . ': ' . mysqli_error($hesk_db_link); + } + else + { + $message = $hesklang['contact_webmaster'] . $hesk_settings['webmaster_email']; + } + mfh_log_error($_SERVER['HTTP_REFERER'], $message, $_SESSION['id']); + echo $hesklang['cant_sql'] . ': ' . $message; + die(); +} // END hesk_dbQuery() + + +function hesk_dbFetchAssoc($res) +{ + + return @mysqli_fetch_assoc($res); + +} // END hesk_FetchAssoc() + + +function hesk_dbFetchRow($res) +{ + + return @mysqli_fetch_row($res); + +} // END hesk_FetchRow() + + +function hesk_dbResult($res, $row = 0, $column = 0) +{ + $i=0; + $res->data_seek(0); + + while ($tmp = @mysqli_fetch_array($res, MYSQLI_NUM)) + { + if ($i==$row) + { + return $tmp[$column]; + } + $i++; + } + + return ''; + +} // END hesk_dbResult() + + +function hesk_dbInsertID() +{ + global $hesk_db_link; + + if ($lastid = @mysqli_insert_id($hesk_db_link)) + { + return $lastid; + } + +} // END hesk_dbInsertID() + + +function hesk_dbFreeResult($res) +{ + + return @mysqli_free_result($res); + +} // END hesk_dbFreeResult() + + +function hesk_dbNumRows($res) +{ + + return @mysqli_num_rows($res); + +} // END hesk_dbNumRows() + + +function hesk_dbAffectedRows() +{ + global $hesk_db_link; + + return @mysqli_affected_rows($hesk_db_link); + +} // END hesk_dbAffectedRows() diff --git a/inc/common.inc.php b/inc/common.inc.php index b6f4de9a..719a1f72 100644 --- a/inc/common.inc.php +++ b/inc/common.inc.php @@ -179,6 +179,16 @@ function hesk_load_internal_api_database_functions() } } // END hesk_load_database_functions() +function hesk_load_cron_database_functions() +{ + if (function_exists('mysqli_connect')) { + require(HESK_PATH . 'cron/core/database_mysqli.inc.php'); + } // Default to MySQL + else { + require(HESK_PATH . 'cron/core/database.inc.php'); + } +} // END hesk_load_cron_database_functions() + function hesk_unlink($file, $older_than = 0) { return (is_file($file) && (!$older_than || (time() - filectime($file)) > $older_than) && @unlink($file)) ? true : false;