}
//
-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];
if (($type == "what") || (($type == "action") && (!isset($_GET['what'])) && ($GLOBALS['what'] != "welcome"))) {
//* DEBUG: */ echo __LINE__."+".$type."+<br />\n";
$OUT .= "</DIV><br />\n";
+ $DEPTH="0";
}
}
}
}
}
// This patched function will reduce many SELECT queries for the specified or current admin login
-function IS_ADMIN ($admin="")
+function IS_ADMIN($admin="")
{
global $cacheArray, $_CONFIG;
$ret = false; $passCookie = ""; $valPass = "";
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++;
}
$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."+<br />\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."<br />\n";
+ if (SQL_NUMROWS($result) == 1) {
list($per) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
$P = $points * $per / 100;
+ //* DEBUG */ echo "ADD:".$P."<br />\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);
}