X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=58ea2ccaf1690966fa1eaf0c2ddbe9037fad8ed1;hp=bf1a9baec9951c6dd7b5528255c0501bcaa1cf7e;hb=317ccb4b7ab8f37a0ab003e474a9bc1fd5e3f3ad;hpb=6810caae47787689d6f316c5bdd62e3722b363bb diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index bf1a9baec9..58ea2ccaf1 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * + * Copyright (c) 2009 - 2011 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -205,7 +205,7 @@ ORDER BY `sort` ASC", array($mode), __FUNCTION__, __LINE__); - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . ':' . getWhat() . '*'); if (!SQL_HASZERONUMS($result_main)) { // There are menus available, so we simply display them... :) $GLOBALS['rows'] = ''; @@ -259,8 +259,8 @@ ORDER BY // Navigation link $OUT .= ''; } else { - // Not found! - open - $OUT .= ''; + // Not found - open + $OUT .= ''; } // Menu title @@ -274,7 +274,7 @@ ORDER BY $OUT .= ''; } // END - if } else { - // Not found! - close + // Not found - close $OUT .= ''; } @@ -305,12 +305,12 @@ ORDER BY if (isFileReadable($INC)) { // Load include file if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_begin', true, $mode); - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . getWhat().'*'); loadInclude($INC); - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . getWhat() . '*'); if ((!isExtensionActive($content['action'])) || ($content['action'] == 'online')) $GLOBALS['rows'] .= loadTemplate('menu_what_end', true, $mode); } - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . $content['sub_what'] . ':' . getWhat() . '*'); } // Free result @@ -319,7 +319,7 @@ ORDER BY // Count one up $main_cnt++; - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . ':' . getWhat() . '*'); if (SQL_NUMROWS($result_main) > $main_cnt) { // Add seperator $GLOBALS['rows'] .= loadTemplate('menu_seperator', true, $mode); @@ -354,7 +354,7 @@ ORDER BY ); // Load main template - //* DEBUG: */ debugOutput(__LINE__.'/'.$main_cnt.'/'.$content['action'].'/'.$content['sub_what'].':'.getWhat().'*'); + //* DEBUG: */ debugOutput(__LINE__ . '/' . $main_cnt . '/' . $content['action'] . '/' . $content['sub_what'] . ':' . getWhat() . '*'); loadTemplate('menu_table', false, $content); } // END - if } @@ -366,7 +366,9 @@ function isMember () { // Fix missing 'last_online' array, damn stupid code :((( // @TODO Try to rewrite this to one or more functions - if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) $GLOBALS['last_online'] = array(); + if ((!isset($GLOBALS['last_online'])) || (!is_array($GLOBALS['last_online']))) { + $GLOBALS['last_online'] = array(); + } // END - if // Is the cache entry there? if (isset($GLOBALS[__FUNCTION__])) { @@ -425,19 +427,19 @@ function isMember () { } // Fetch user data for given user id -function fetchUserData ($userid, $column = 'userid') { +function fetchUserData ($value, $column = 'userid') { // If we should look for userid secure&set it here if (substr($column, -2, 2) == 'id') { // Secure userid - $userid = bigintval($userid); + $value = bigintval($value); // Set it here - setCurrentUserId($userid); + setCurrentUserId($value); // Don't look for invalid userids... - if (!isValidUserId($userid)) { + if (!isValidUserId($value)) { // Invalid, so abort here - debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $userid . ' is invalid.'); + debug_report_bug(__FUNCTION__, __LINE__, 'User id ' . $value . ' is invalid.'); } elseif (isUserDataValid()) { // Use cache, so it is fine return true; @@ -452,11 +454,13 @@ function fetchUserData ($userid, $column = 'userid') { // Extra statements $ADD = ''; - if (isExtensionInstalledAndNewer('user', '0.3.5')) $ADD = ', UNIX_TIMESTAMP(`lock_timestamp`) AS `lock_timestamp`'; + if (isExtensionInstalledAndNewer('user', '0.3.5')) { + $ADD = ', UNIX_TIMESTAMP(`lock_timestamp`) AS `lock_timestamp`'; + } // END - if // Query for the user $result = SQL_QUERY_ESC("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `%s`='%s' LIMIT 1", - array($column, $userid), __FUNCTION__, __LINE__); + array($column, $value), __FUNCTION__, __LINE__); // Do we have a record? if (SQL_NUMROWS($result) == 1) { @@ -465,6 +469,8 @@ function fetchUserData ($userid, $column = 'userid') { // Set the userid for later use setCurrentUserId($data['userid']); + + // And cache the data for this userid $GLOBALS['user_data'][getCurrentUserId()] = $data; // Rewrite 'last_failure' if found and ext-user has version >= 0.3.7 @@ -656,7 +662,7 @@ function isMenuActionValid ($mode, $action, $what, $updateEntry=false) { $add = ''; if ((!isAdmin()) && ($mode != 'admin')) $add = " AND `locked`='N'"; - //* DEBUG: */ debugOutput(__LINE__.':'.$mode.'/'.$action.'/'.$what.'*'); + //* DEBUG: */ debugOutput(__LINE__ . ':' . $mode . '/' . $action . '/' . $what . '*'); if (($mode != 'admin') && ($updateEntry === true)) { // Update guest or member menu $sql = SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_%s_menu` SET counter=counter+1 WHERE `action`='%s' AND `what`='%s'".$add." LIMIT 1", @@ -809,6 +815,8 @@ function getPaymentTitlePrice ($pid, $full=false) { // Load payment data $result = SQL_QUERY_ESC("SELECT `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1", array(bigintval($pid)), __FUNCTION__, __LINE__); + + // Do we have an entry? if (SQL_NUMROWS($result) == 1) { // Payment type found... :-) $data = SQL_FETCHARRAY($result); @@ -819,7 +827,7 @@ function getPaymentTitlePrice ($pid, $full=false) { } else { $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}'; } - } + } // END - if // Free result SQL_FREERESULT($result); @@ -851,7 +859,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 = '', $bonus = false) { +function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $isBonusMail = false) { // Default is not removed $ret = 'failed'; @@ -862,9 +870,12 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ // Is there already a line for this user available? if ($stats_id > 0) { + // Default is 'normal' mail + $type = 'NORMAL'; + $rowName = 'stats_id'; + // Only when we got a real stats id continue searching for the entry - $type = 'NORMAL'; $rowName = 'stats_id'; - if ($bonus) { + if ($isBonusMail === true) { $type = 'BONUS'; $rowName = 'bonus_id'; } // END - if @@ -878,6 +889,13 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $ // 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__); + + // 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__); + } // END - if $ret = 'done'; } else { // Already found @@ -951,7 +969,7 @@ function getReferalLevelPercents ($level) { // First look for level $key = array_search($level, $GLOBALS['cache_array']['refdepths']['level']); if ($key !== false) { - // Entry found! + // Entry found $data['percents'] = $GLOBALS['cache_array']['refdepths']['percents'][$key]; // Count cache hit @@ -978,7 +996,7 @@ function getReferalLevelPercents ($level) { /** * - * Dynamic referal system, can also send mails! + * Dynamic referal and points system, can also send mails! * * subject = Subject line, write in lower-case letters and underscore is allowed * userid = Referal id wich should receive... @@ -989,19 +1007,18 @@ function getReferalLevelPercents ($level) { * add_mode = Add points only to $userid or also refs? (WARNING! Changing 'ref' to 'direct' * for default value will cause no referal will get points ever!!!) */ -function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $add_mode = 'ref') { +function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify = false, $refid = '0', $addMode = 'ref') { // By default nothing has been added $added = false; //* DEBUG: */ debugOutput('----------------------- ' . __FUNCTION__ . ' - ENTRY ------------------------