X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=d41930089f6bdf7d40a73bd10073d351fbbc64bf;hp=a242cd01c9238c28fa06393ffd5a767d3ce6cf41;hb=4da10ba9e4a47d9b4eee4609a185fc7266fab031;hpb=ca256746fe0757a23df4064824c8fe2087ad5634 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index a242cd01c9..d41930089f 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -10,13 +10,8 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Alle datenbank-relevanten Funktionen * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2016 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -61,7 +56,7 @@ function getTitleFromMenu ($mode, $what, $column = 'what', $ADD = '') { $data['title'] = '??? (' . $what . ')'; // Look for title - $result = SQL_QUERY_ESC("SELECT `title` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `%s`='%s'" . $ADD . " LIMIT 1", + $result = sqlQueryEscaped("SELECT `title` FROM `{?_MYSQL_PREFIX?}_%s_menu` WHERE `%s`='%s'" . $ADD . " LIMIT 1", array( $mode, $column, @@ -69,13 +64,13 @@ function getTitleFromMenu ($mode, $what, $column = 'what', $ADD = '') { ), __FUNCTION__, __LINE__); // Is there an entry? - if (SQL_NUMROWS($result) == 1) { + if (sqlNumRows($result) == 1) { // Fetch the title - $data = SQL_FETCHARRAY($result); + $data = sqlFetchArray($result); } // END - if // Free result - SQL_FREERESULT($result); + sqlFreeResult($result); // Return it return $data['title']; @@ -211,7 +206,7 @@ function addMenu ($mode, $action, $what) { } // END - if // Load SQL data and add the menu to the output stream... - $result_main = SQL_QUERY_ESC("SELECT + $result_main = sqlQueryEscaped("SELECT `title`, `what`, `action`, @@ -227,10 +222,10 @@ ORDER BY array($mode), __FUNCTION__, __LINE__); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat()); - if (!SQL_HASZERONUMS($result_main)) { + if (!ifSqlHasZeroNumRows($result_main)) { // There are menus available, so we simply display them... :) $GLOBALS['rows'] = ''; - while ($content = SQL_FETCHARRAY($result_main)) { + while ($content = sqlFetchArray($result_main)) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',action=' . $content['action'] . ',getWhat()=' . getWhat()); // Disable the block-mode enableBlockMode(FALSE); @@ -239,7 +234,7 @@ ORDER BY $GLOBALS['rows'] .= loadTemplate($mode . '_menu_title', TRUE, $content); // Sub menu - $result_sub = SQL_QUERY_ESC("SELECT + $result_sub = sqlQueryEscaped("SELECT `title` AS `sub_title`, `what` AS `sub_what`, `visible` AS `sub_visible`, @@ -259,12 +254,12 @@ ORDER BY ), __FUNCTION__, __LINE__); // Are there some entries? - if (!SQL_HASZERONUMS($result_sub)) { + if (!ifSqlHasZeroNumRows($result_sub)) { // Init counter $count = '0'; // Load all sub menus - while ($content2 = SQL_FETCHARRAY($result_sub)) { + while ($content2 = sqlFetchArray($result_sub)) { // Merge both arrays in one $content = merge_array($content, $content2); @@ -273,7 +268,7 @@ ORDER BY // Full file name for checking menu //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sub_what=' . $content['sub_what']); - $inc = sprintf("inc/modules/%s/what-%s.php", $mode, $content['sub_what']); + $inc = sprintf('inc/modules/%s/what-%s.php', $mode, $content['sub_what']); if (isIncludeReadable($inc)) { // Mark currently selected menu - open if ((!empty($what)) && (($what == $content['sub_what']))) { @@ -320,7 +315,7 @@ ORDER BY ); // Add regular menu row or bottom row? - if ($count < SQL_NUMROWS($result_sub)) { + if ($count < sqlNumRows($result_sub)) { $GLOBALS['rows'] .= loadTemplate($mode . '_menu_row', TRUE, $content); } else { $GLOBALS['rows'] .= loadTemplate($mode . '_menu_bottom', TRUE, $content); @@ -331,7 +326,7 @@ ORDER BY enableBlockMode(); // Load menu block - $INC = sprintf("inc/modules/%s/action-%s.php", $mode, $content['action']); + $INC = sprintf('inc/modules/%s/action-%s.php', $mode, $content['action']); if (isFileReadable($INC)) { // Load include file if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_begin', TRUE, $mode); @@ -344,13 +339,13 @@ ORDER BY } // Free result - SQL_FREERESULT($result_sub); + sqlFreeResult($result_sub); // Count one up $main_cnt++; //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat()); - if (SQL_NUMROWS($result_main) > $main_cnt) { + if (sqlNumRows($result_main) > $main_cnt) { // Add separator $GLOBALS['rows'] .= loadTemplate('menu_separator', TRUE, $mode); @@ -371,7 +366,7 @@ ORDER BY } // END - while // Free memory - SQL_FREERESULT($result_main); + sqlFreeResult($result_main); // Prepare filter data array $filterData = array( @@ -492,12 +487,12 @@ function fetchUserData ($value, $column = 'userid') { if ((isCurrentUserIdSet()) && (getCurrentUserId() != $value)) { // Unset it unsetCurrentUserId(); - } elseif (isUserDataValid()) { + } elseif (isValidUserData()) { // Use cache, so it is fine //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #1'); return TRUE; } // END - if - } elseif (isUserDataValid()) { + } elseif (isValidUserData()) { // Using cache is fine //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $value . ' is valid, using cache #2'); return TRUE; @@ -510,16 +505,16 @@ function fetchUserData ($value, $column = 'userid') { $ADD = runFilterChain('convert_user_data_columns', ' '); // Query for the user - $result = SQL_QUERY_ESC("SELECT *" . $ADD . " FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1", + $result = sqlQueryEscaped("SELECT *" . $ADD . " FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1", array( $column, $value ), __FUNCTION__, __LINE__); // Is there a record? - if (SQL_NUMROWS($result) == 1) { + if (sqlNumRows($result) == 1) { // Load data from cookies - $data = SQL_FETCHARRAY($result); + $data = sqlFetchArray($result); // Set the userid for later use setCurrentUserId($data['userid']); @@ -555,11 +550,11 @@ function fetchUserData ($value, $column = 'userid') { } // END - if // Found, but valid? - $found = isUserDataValid(); + $found = isValidUserData(); } // END - if // Free memory - SQL_FREERESULT($result); + sqlFreeResult($result); // Return result return $found; @@ -572,16 +567,20 @@ function fetchUserData ($value, $column = 'userid') { * login. */ function isAdmin () { + //* DIE: */ reportBug(__FUNCTION__, __LINE__, 'CALLED!'); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'CALLED!'); + // Is there cache? if (isset($GLOBALS[__FUNCTION__])) { // Return it - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isAdmin()=' . intval($GLOBALS[__FUNCTION__])); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isAdmin()=' . intval($GLOBALS[__FUNCTION__]) . ' - CACHED!'); return $GLOBALS[__FUNCTION__]; } // END - if - // No admin in installation phase! - if ((isInstallationPhase()) || (!isAdminRegistered())) { + if ((isInstaller()) || (!isAdminRegistered())) { + // No admin in installation phase! $GLOBALS[__FUNCTION__] = FALSE; + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isAdmin()=' . intval($GLOBALS[__FUNCTION__]) . ' - INSTALLER!'); return FALSE; } // END - if @@ -589,15 +588,18 @@ function isAdmin () { $ret = FALSE; $adminId = '0'; $passwordFromCookie = ''; - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId); // If admin login is not given take current from cookies... + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isSessionVariableSet(admin_id)=' . intval(isSessionVariableSet('admin_id')) . ',isSessionVariableSet(admin_md5)=' . intval(isSessionVariableSet('admin_md5'))); if ((isSessionVariableSet('admin_id')) && (isSessionVariableSet('admin_md5'))) { + // Debug message + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Getting admin data from session ...'); + // Get admin login and password from session/cookies $adminId = getCurrentAdminId(); $passwordFromCookie = getAdminMd5(); } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId . ',passwordFromCookie=' . $passwordFromCookie); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId . ',passwordFromCookie=' . $passwordFromCookie); // Abort if admin id is zero if (($adminId == '0') || (empty($passwordFromCookie))) { @@ -615,26 +617,26 @@ function isAdmin () { // Search in array for entry if (isset($GLOBALS['admin_hash'])) { // Use cached string - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using admin_hash=' . $GLOBALS['admin_hash'] . ' from cache'); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using admin_hash=' . $GLOBALS['admin_hash'] . ' from cache'); } elseif ((!empty($adminId)) && (!empty($passwordFromCookie)) && (isAdminHashSet($adminId) === TRUE)) { // Get admin hash and hash it $GLOBALS['admin_hash'] = encodeHashForCookie(getAdminHash($adminId)); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valPass=' . $GLOBALS['admin_hash']); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valPass=' . $GLOBALS['admin_hash']); // Count cache hits incrementStatsEntry('cache_hits'); } elseif ((!empty($adminId)) && ((!isExtensionActive('cache')) || (isAdminHashSet($adminId) === FALSE))) { // Get admin hash and hash it $GLOBALS['admin_hash'] = encodeHashForCookie(getAdminHash($adminId)); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valPass=' . $GLOBALS['admin_hash']); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'valPass=' . $GLOBALS['admin_hash']); } // Check if password is valid - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '(' . $GLOBALS['admin_hash'] . '==' . $passwordFromCookie . ')='.intval($GLOBALS['admin_hash'] == $passwordFromCookie)); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '(' . $GLOBALS['admin_hash'] . '==' . $passwordFromCookie . ')='.intval($GLOBALS['admin_hash'] == $passwordFromCookie)); $GLOBALS[__FUNCTION__] = ((!empty($GLOBALS['admin_hash'])) && ($GLOBALS['admin_hash'] == $passwordFromCookie)); // Return result of comparision - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isAdmin()=' . intval($GLOBALS[__FUNCTION__])); + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isAdmin()=' . intval($GLOBALS[__FUNCTION__])); return $GLOBALS[__FUNCTION__]; } @@ -646,26 +648,26 @@ function addMaxReceiveList ($mode, $default = '') { switch ($mode) { case 'guest': // Guests (in the registration form) are not allowed to select 0 mails per day. - $result = SQL_QUERY('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value` > 0 ORDER BY `value` ASC', + $result = sqlQuery('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` WHERE `value` > 0 ORDER BY `value` ASC', __FUNCTION__, __LINE__); break; case 'admin': case 'member': // Members are allowed to set to zero mails per day (we will change this soon!) - $result = SQL_QUERY('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC', + $result = sqlQuery('SELECT `value`, `comment` FROM `{?_MYSQL_PREFIX?}_max_receive` ORDER BY `value` ASC', __FUNCTION__, __LINE__); break; default: // Invalid! - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid mode %s detected.", $mode)); + logDebugMessage(__FUNCTION__, __LINE__, sprintf('Invalid mode %s detected.', $mode)); break; } // Some entries are found? - if (!SQL_HASZERONUMS($result)) { + if (!ifSqlHasZeroNumRows($result)) { $OUT = ''; - while ($content = SQL_FETCHARRAY($result)) { + while ($content = sqlFetchArray($result)) { $OUT .= '