X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-connect.php;h=d75d6dacc86234e82eeb9cb376a3c5c14f93ad67;hp=ee79d2ebb96a1d16c29bb0b86bd713371e922ba4;hb=94105795f6c6195c2630c09303c0aeb4ffbe15de;hpb=8a2ab6a6beb399e024ec5a56b487b03c4f65551c;ds=sidebyside diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index ee79d2ebb9..d75d6dacc8 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -88,15 +88,17 @@ if ((!mxchange_installing) && (mxchange_installed)) require_once(PATH."inc/functions.php"); // Non-database functions require_once(PATH."inc/databases.php"); // Several hard-coded databases (arrays, constants) - if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) - { + if ((!empty($MySQL['host'])) && (!empty($MySQL['login'])) && (!empty($MySQL['password'])) && (!empty($MySQL['dbase']))) { // Connect to DB $link = SQL_CONNECT($MySQL['host'], $MySQL['login'], $MySQL['password'], __FILE__, __LINE__); - if ($link !== false) - { + + // Is the link valid? + if (is_resource($link)) { + // Choose the database $db = SQL_SELECT_DB($MySQL['dbase'], $link, __FILE__, __LINE__); - if ($db !== false) - { + + // Is it a valid resource? + if ($db === true) { // Load configuration stuff $result = SQL_QUERY("SELECT pass_len, points_register, points_ref, least_cats, check_double_email, check_double_pass, admin_notify, url_tlock, test_text, max_tlength, test_subj, autosend_active, max_send, url_blacklist, auto_purge, auto_purge_active, last_update, unconfirmed, profile_lock, online_timeout, mad_timestamp, mad_count, profile_update, send_prof_update, resend_profile_update, code_length, patch_level, patch_ctime, guest_stats, ref_payout, activate_xchange, order_multi_page, display_refid, ip_timeout, allow_direct_pay, config FROM "._MYSQL_PREFIX."_config WHERE config='0' LIMIT 1", __FILE__, __LINE__); @@ -118,8 +120,7 @@ if ((!mxchange_installing) && (mxchange_installed)) require_once(PATH."inc/mysql-manager.php"); // Functions which interact with the database // Run daily reset - if ((date("d", $CONFIG['last_update']) != date("d", time()) || (DEBUG_MODE == true)) && (!mxchange_installing) && (mxchange_installed) && (admin_registered) && (!isset($_GET['register'])) && ($CSS != 1)) - { + if ((date("d", $CONFIG['last_update']) != date("d", time()) || (DEBUG_MODE == true)) && (!mxchange_installing) && (mxchange_installed) && (admin_registered) && (!isset($_GET['register'])) && ($CSS != 1)) { // Do daily things in external PHP file but only when script is completely setup $INC_POOL[] = PATH."inc/reset/reset_daily.php"; @@ -140,21 +141,17 @@ if ((!mxchange_installing) && (mxchange_installed)) require_once(PATH."inc/session.php"); // Load admin include file if he is admin - if (IS_ADMIN()) - { + if (IS_ADMIN()) { // Administrative functions require_once(PATH."inc/modules/admin/admin-inc.php"); } // Get all values - if (($CSS != 1) && ($CSS != -1)) - { + if (($CSS != 1) && ($CSS != -1)) { if (empty($GLOBALS['module'])) $GLOBALS['module'] = "empty"; if (empty($GLOBALS['what'])) $GLOBALS['what'] = GET_WHAT($GLOBALS['module']); if (empty($GLOBALS['action'])) $GLOBALS['action'] = GET_ACTION($GLOBALS['module'], $GLOBALS['what']); - } - else - { + } else { // Set action/what to empty $GLOBALS['action'] = ""; $GLOBALS['what'] = ""; @@ -174,21 +171,15 @@ if ((!mxchange_installing) && (mxchange_installed)) // Set default 'what' value //* DEBUG */ echo "-".$GLOBALS['module']."/".$GLOBALS['what']."-
\n"; - if ((empty($GLOBALS['what'])) && (empty($GLOBALS['action'])) && ($CSS != 1) && ($CSS != -1)) - { - if ($GLOBALS['module'] == "admin") - { + if ((empty($GLOBALS['what'])) && (empty($GLOBALS['action'])) && ($CSS != 1) && ($CSS != -1)) { + if ($GLOBALS['module'] == "admin") { // Set 'action' value to 'login' in admin menu $GLOBALS['action'] = GET_ACTION($GLOBALS['module'], $GLOBALS['what']); - } - elseif (($GLOBALS['module'] == "index") || ($GLOBALS['module'] == "login")) - { + } elseif (($GLOBALS['module'] == "index") || ($GLOBALS['module'] == "login")) { // Set 'what' value to 'welcome' in guest and member menu $GLOBALS['what'] = "welcome"; if (!empty($CONFIG['index_home'])) $GLOBALS['what'] = $CONFIG['index_home']; - } - else - { + } else { // Anything else like begging link $GLOBALS['what'] = ""; } @@ -203,9 +194,7 @@ if ((!mxchange_installing) && (mxchange_installed)) if ($dummy == "done") COUNT_MODULE($GLOBALS['module']); unset($dummy); if ($CONFIG['activate_xchange'] > 0) activateExchange(); - } - else - { + } else { // If you will read following error message you probably need to contact me (webmaster@mxchange.org) // and download the sql-upgrades extension from my server. Please ask me which SQL file(s) you need to // import *BEFORE* you import them! @@ -214,28 +203,20 @@ if ((!mxchange_installing) && (mxchange_installed)) // Free memory SQL_FREERESULT($result); - } - else - { + } else { // Wrong database? ADD_FATAL(WRONG_DB_SELECTED); } - } - else - { + } else { // No link to database! ADD_FATAL(NO_DB_LINK); $db = false; } - } - else - { + } else { // Maybe you forgot to enter your MySQL data? ADD_FATAL(MYSQL_DATA_MISSING); } -} - else -{ +} else { /////////////////////////////////////////////////// // Include neccessary functions for installation // ///////////////////////////////////////////////////