X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=e8e897fed4da668fb3a47a546982e05d884e1284;hb=9fa8a3a6f619820548a44d571e3ed96672a62da6;hp=8a8e3107097c2312264d057065bb92556227670c;hpb=6a8deec242fcd1b28090ad693e0cef67a1d0a818;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 8a8e310709..e8e897fed4 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -279,7 +279,7 @@ ORDER BY } } else { // Not found - open - $OUT .= ''; + $OUT .= ''; } // Menu title @@ -294,7 +294,7 @@ ORDER BY } // END - if } else { // Not found - close - $OUT .= ''; + $OUT .= ''; } // Cunt it up @@ -340,16 +340,16 @@ ORDER BY //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'main_cnt=' . $main_cnt . ',getWhat()=' . getWhat()); if (SQL_NUMROWS($result_main) > $main_cnt) { - // Add seperator - $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode); + // Add separator + $GLOBALS['rows'] .= loadTemplate('menu_separator', true, $mode); // Should we display adverts in this menu? if ((isExtensionInstalledAndNewer('menu', '0.0.1')) && (getConfig($mode . '_menu_advert_enabled') == 'Y') && ($action != 'admin')) { // Display advert template $GLOBALS['rows'] .= loadTemplate('menu_' . $mode . '_advert_' . $action, true); - // Add seperator again - $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode); + // Add separator again + $GLOBALS['rows'] .= loadTemplate('menu_separator', true, $mode); } // END - if } // END - if } // END - while @@ -359,8 +359,8 @@ ORDER BY // Should we display adverts in this menu? if ((isExtensionInstalledAndNewer('menu', '0.0.1')) && (getConfig($mode . '_menu_advert_enabled') == 'Y')) { - // Add seperator again - $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode); + // Add separator again + $GLOBALS['rows'] .= loadTemplate('menu_separator', true, $mode); // Display advert template $GLOBALS['rows'] .= loadTemplate('menu_' . $mode . '_advert_end', true); @@ -368,8 +368,8 @@ ORDER BY // Prepare data $content = array( - 'rows' => $GLOBALS['rows'], - 'mode' => $mode + 'rows' => $GLOBALS['rows'], + 'menu_mode' => $mode ); // Load main template @@ -660,25 +660,44 @@ function addMaxReceiveList ($mode, $default = '', $return = false) { // Checks wether the given email address is used. function isEmailTaken ($email) { + // Default is no userid + $useridSql = ' IS NOT NULL'; + + // Is a member logged in? + if (isMember()) { + // Get userid + $useridSql = '!= ' . bigintval(getMemberId()); + } // END - if + // Replace dot with {DOT} $email = str_replace('.', '{DOT}', $email); // Query the database - $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email` LIKE '%%%s%%' LIMIT 1", - array($email), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT + COUNT(`userid`) AS `cnt` +FROM + `{?_MYSQL_PREFIX?}_user_data` +WHERE + '%s' REGEXP `email` AND + `userid` %s +LIMIT 1", + array( + $email, + $useridSql + ), __FUNCTION__, __LINE__); // Is the email there? - $isTaken = (SQL_NUMROWS($result) == 1); + list($count) = SQL_FETCHROW($result); // Free the result SQL_FREERESULT($result); // Return result - return $isTaken; + return ($count == 1); } // Validate the given menu action -function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { +function isMenuActionValid ($mode, $action, $what, $updateEntry = false) { // Is the cache entry there and we shall not update? if ((isset($GLOBALS['action_valid'][$mode][$action][$what])) && ($updateEntry === false)) { // Count cache hit @@ -897,7 +916,7 @@ function getPaymentPoints ($pid, $lookFor = 'price') { } // Remove a receiver's id from $receivers and add a link for him to confirm -function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $isBonusMail = false) { +function removeReceiver (&$receivers, $key, $userid, $poolId, $statsId = 0, $isBonusMail = false) { // Default is not removed $ret = 'failed'; @@ -907,7 +926,7 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $i unset($receivers[$key]); // Is there already a line for this user available? - if ($stats_id > 0) { + if ($statsId > 0) { // Default is 'normal' mail $type = 'NORMAL'; $rowName = 'stats_id'; @@ -919,20 +938,30 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $i } // END - if // Try to look the entry up - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE %s='%s' AND `userid`=%s AND link_type='%s' LIMIT 1", - array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s AND `userid`=%s AND link_type='%s' LIMIT 1", + array( + $rowName, + bigintval($statsId), + bigintval($userid), + $type + ), __FUNCTION__, __LINE__); // Was it *not* found? if (SQL_HASZERONUMS($result)) { // So we add one! SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`,`userid`,`link_type`) VALUES ('%s','%s','%s')", - array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__); + array( + $rowName, + bigintval($statsId), + bigintval($userid), + $type + ), __FUNCTION__, __LINE__); // Update 'mails_sent' if sql_patches is updated if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) { // Update the pool SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1", - array(bigintval($pool_id)), __FUNCTION__, __LINE__); + array(bigintval($poolId)), __FUNCTION__, __LINE__); } // END - if $ret = 'done'; } else { @@ -959,14 +988,14 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen // Count or sum whole table? if ($countRows === true) { // Count whole table - $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add, + $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1', array( $lookFor, $tableName ), __FUNCTION__, __LINE__); } else { // Sum whole table - $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add, + $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`" . $add . ' LIMIT 1', array( $lookFor, $tableName @@ -975,7 +1004,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen } elseif (($countRows === true) || ($lookFor == 'userid')) { // Count rows //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'COUNT!'); - $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add, + $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1', array( $lookFor, $tableName, @@ -986,7 +1015,7 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen } else { // Add all rows //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SUM!'); - $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add, + $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'" . $add . ' LIMIT 1', array( $lookFor, $tableName, @@ -1292,9 +1321,9 @@ function generateOptionList ($table, $id, $name, $default = '', $special = '', $ } } else { // Data from database - $SPEC = ', `' . $id . '`'; + $SPEC = ',`' . $id . '`'; if (!empty($special)) { - $SPEC = ', `' . $special . '` AS `special`'; + $SPEC = ',`' . $special . '` AS `special`'; } // END - if // Query the database @@ -1513,7 +1542,7 @@ function generateCategoryOptionsList ($mode) { } // END - foreach } else { // No cateogries are defined yet - $OUT = ''; + $OUT = ''; } // Return HTML code @@ -1691,12 +1720,12 @@ function reduceRecipientReceivedMails ($column, $id, $count) { } // Creates a new task -function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = '0', $strip = true) { +function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = NULL, $strip = true) { // Insert the task data into the database SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`,`userid`,`status`,`task_type`,`subject`,`text`,`task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())", array( - $adminId, - $userid, + makeZeroToNull($adminId), + makeZeroToNull($userid), $taskType, $subject, $notes