X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmysql-manager.php;h=e4bcad187cb98d9505a358ec57139a435f9ef9a2;hb=dff82554761a7fe1a34d3ce2d4922b4b1f3cd6b9;hp=46154a41084d7508073acf6f18619de9225ccf75;hpb=feebd0199748544fe8c930b70e97452001a13f76;p=mailer.git diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 46154a4108..e4bcad187c 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -39,12 +39,12 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) } // -function ADD_MODULE_TITLE($mod) -{ +function ADD_MODULE_TITLE($mod) { global $cacheArray, $_CONFIG; $name = ""; $result = false; - // Load title - if (!isBooleanConstantAndTrue('mxchange_installed')) { + + // Is the script installed? + if (isBooleanConstantAndTrue('mxchange_installed')) { if ((GET_EXT_VERSION("cache") >= "0.1.2") && (isset($cacheArray['modules']['module'])) && (is_array($cacheArray['modules']['module'])) && (isset($cacheArray['modules']['module'][$mod]))) { // Load from cache $name = $cacheArray['modules']['title'][$mod]; @@ -270,6 +270,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true) if (($type == "what") || (($type == "action") && (!isset($_GET['what'])) && ($GLOBALS['what'] != "welcome"))) { //* DEBUG: */ echo __LINE__."+".$type."+
\n"; $OUT .= "
\n"; + $DEPTH="0"; } } } @@ -1035,21 +1036,17 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock global $DEPTH, $_CONFIG, $DATA, $link; // When $uid = 0 add points to jackpot - if ($uid == "0") - { + if ($uid == "0") { // Add points to jackpot ADD_JACKPOT($points); return; } // Count up referral depth - if (empty($DEPTH)) - { + if (empty($DEPTH)) { // Initialialize referral system $DEPTH = "0"; - } - else - { + } else { // Increase referral level $DEPTH++; } @@ -1059,49 +1056,57 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock $result_user = SQL_QUERY_ESC("SELECT refid, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d AND status='CONFIRMED' LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__); - if (SQL_NUMROWS($result_user) == 1) - { + //* DEBUG */ echo "+".SQL_NUMROWS($result_user).":".$points."+
\n"; + if (SQL_NUMROWS($result_user) == 1) { // This is the user and his ref list ($ref, $email) = SQL_FETCHROW($result_user); SQL_FREERESULT($result_user); + $result = SQL_QUERY_ESC("SELECT percents FROM "._MYSQL_PREFIX."_refdepths WHERE level='%s' LIMIT 1", array(bigintval($DEPTH)), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { + //* DEBUG */ echo "DEPTH:".$DEPTH."
\n"; + if (SQL_NUMROWS($result) == 1) { list($per) = SQL_FETCHROW($result); SQL_FREERESULT($result); $P = $points * $per / 100; + //* DEBUG */ echo "ADD:".$P."
\n"; // Update points... $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET %s=%s+%s WHERE userid=%d AND ref_depth=%d LIMIT 1", array($data, $data, $P, bigintval($uid), bigintval($DEPTH)), __FILE__, __LINE__); - if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 0) - { + if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 0) { // First ref in this level! :-) $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_points (userid, ref_depth, %s) VALUES (%d, %d, %s)", array($data, bigintval($uid), bigintval($DEPTH), $P), __FILE__, __LINE__); } // Update mediadata as well - if (GET_EXT_VERSION("mediadata") >= "0.0.4") - { + if (GET_EXT_VERSION("mediadata") >= "0.0.4") { // Update database MEDIA_UPDATE_ENTRY(array("total_points"), "add", $P); } // Points updated, maybe I shall send him an email? - if (($send_notify) && ($ref > 0) && (!$locked)) - { + if (($send_notify) && ($ref > 0) && (!$locked)) { // 0 1 2 3 $DATA = array($per, bigintval($DEPTH), $P, bigintval($ref)); $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", "", bigintval($uid)); SEND_EMAIL($email, THANX_REFERRAL_ONE, $msg); + } elseif (($send_notify) && ($ref == 0) && (!$locked) && ($add_mode == "direct") && (!defined('__POINTS_VALUE'))) { + // Direct payment shall be notified about + define('__POINTS_VALUE', $P); + + // Load message + $msg = LOAD_EMAIL_TEMPLATE("add-points", REASON_DIRECT_PAYMENT, $uid); + + // And sent it away + SEND_EMAIL($email, SUBJECT_DIRECT_PAYMENT, $msg); + LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_POINTS_ADDED); } // Maybe there's another ref? - if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) - { + if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) { // Then let's credit him here... ADD_POINTS_REFSYSTEM($ref, $points, $send_notify, $ref, $locked); }