X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Flibs%2Frefback_functions.php;h=8da7941e98923c82468b942db8e24d74ad0be1c2;hb=e1d636846bafc8ae71855595a2a2843463025e26;hp=6f45e9307e30ab8ed00e912a907af81d85c5dfc9;hpb=b8c86fa12322603c24a88ea2b0fd3dbeba612752;p=mailer.git
diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php
index 6f45e9307e..8da7941e98 100644
--- a/inc/libs/refback_functions.php
+++ b/inc/libs/refback_functions.php
@@ -10,7 +10,12 @@
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Funktionen fuer Refback-Erweiterung *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2008 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
@@ -33,7 +38,7 @@
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
require($INC);
}
@@ -41,22 +46,23 @@ if (!defined('__SECURITY')) {
function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
//* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------
- \n";
// Back ref depths
- $GLOBALS['cache_array']['depth'][$uid][$ref] = $GLOBALS['ref_level'];
+ $GLOBALS['cache_array']['depth'][$uid][$ref] = $GLOBALS['ref_level'];
// Init points
$return = $points;
// Get all ref levels
- $result_refs = SQL_QUERY("SELECT level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level > 0 ORDER BY level ASC", __FUNCTION__, __LINE__);
+ $result_refs = SQL_QUERY("SELECT level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level > 0 ORDER BY level ASC",
+ __FUNCTION__, __LINE__);
// "Walk" through all level
- while (list($level, $perc) = SQL_FETCHROW($result_refs)) {
+ while ($content = SQL_FETCHARRAY($result_refs)) {
// Reset ref depths
unset($GLOBALS['ref_level']);
// "Walk" through all refids
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},ref={$ref},level={$level},points={$points}
\n";
- foreach (GET_REFBACK_USERID_ARRAY($uid, $level) as $refid) {
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},ref={$ref},level={$content['level']},points={$points}
\n";
+ foreach (GET_REFBACK_USERID_ARRAY($uid, $content['level']) as $refid) {
// Skip level zero or if both are the same
if ($uid == $refid) continue;
@@ -66,23 +72,23 @@ function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
// Some percents given?
if ($percents > 0) {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):points={$points},perc={$perc},percents={$percents},level={$level}
\n";
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."):points={$points},perc={$content['percents']},percents={$percents},level={$content['level']}
\n";
// Calculate points for refback
- $refback = $points * ($perc / 100) * ($percents / 100);
+ $refback = $points * ($content['percents'] / 100) * ($percents / 100);
// Update refback table ("refid" and "uid" must be exchanged!)
SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_refs` SET points=points+%s WHERE userid=%s AND refid=%s LIMIT 1",
- array($refback, $refid, $uid), __FUNCTION__, __LINE__);
+ array($refback, $refid, $uid), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):refback={$refback},uid={$uid},refid={$refid} - UPDATE! (".SQL_AFFECTEDROWS().")
\n";
// Add points again, but only directly
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):refback={$refback}
\n";
- ADD_POINTS_REFSYSTEM(sprintf("refback:%s", $refid), $uid, $refback, false, "0", false, "direct");
+ ADD_POINTS_REFSYSTEM_DIRECT(sprintf("refback:%s", $refid), $uid, $refback);
// Reduce points if refid is found
if ($refid == $ref) {
// Reduce points here!
- $return = $points * ($perc / 100) - $refback;
+ $return = $points * ($content['percents'] / 100) - $refback;
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):points={$return} - REDUCED
\n";
} // END - if
} // END - if
@@ -112,7 +118,7 @@ function GET_REFBACK_PERCENTS ($uid, $ref) {
// Get percents from database
$result = SQL_QUERY_ESC("SELECT refback FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND refid=%s LIMIT 1",
- array($ref, $uid), __FUNCTION__, __LINE__);
+ array($ref, $uid), __FUNCTION__, __LINE__);
// Entry found? (Should be!)
if (SQL_NUMROWS($result) == 1) {
@@ -145,15 +151,15 @@ function GET_REFBACK_USERID_ARRAY ($rid, $level) {
FROM `{!_MYSQL_PREFIX!}_user_refs`
WHERE refid=%s AND level=%s
ORDER BY userid ASC",
- array($rid,$level), __FUNCTION__, __LINE__);
+ array($rid,$level), __FUNCTION__, __LINE__);
// Entries found?
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result)."
\n";
if (SQL_NUMROWS($result) > 0) {
// Add all
- while (list($userid) = SQL_FETCHROW($result)) {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):rid={$rid},level={$level},userid={$userid}
\n";
- $userIds[] = $userid;
+ while ($content = SQL_FETCHARRAY($result)) {
+ //* DEBUG: */ print __FUNCTION__."(".__LINE__."):rid={$rid},level={$level},userid={$content['userid']}
\n";
+ $userIds[] = $content['userid'];
} // END - while
} // END - if
@@ -167,7 +173,7 @@ ORDER BY userid ASC",
}
// Update "refback table"
-function UPDATE_REFBACK_TABLE($uid) {
+function updateRefbackTable ($uid) {
//* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------- \n";
// Make it sure referal level zero (member him-/herself) is at least selected
if (empty($GLOBALS['cache_array']['back_level'])) $GLOBALS['cache_array']['back_level'] = 1;
@@ -179,7 +185,7 @@ function UPDATE_REFBACK_TABLE($uid) {
// Check for his referal
$result_refid = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s ORDER BY userid ASC",
- array(bigintval($uid)), __FUNCTION__, __LINE__);
+ array(bigintval($uid)), __FUNCTION__, __LINE__);
// When no entry was updated then we have to create it here
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):found=".SQL_NUMROWS($result_refid)."
\n";
@@ -202,8 +208,8 @@ function UPDATE_REFBACK_TABLE($uid) {
} // END - if
// Check existence
- $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' AND refid=%s LIMIT 1",
- array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' AND refid=%s LIMIT 1",
+ array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
// Do we have no entry?
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},level={$GLOBALS['cache_array']['back_level']},ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]},minus={$minus},numRows=".SQL_NUMROWS($result)." - FOUND!
\n";
@@ -211,10 +217,10 @@ function UPDATE_REFBACK_TABLE($uid) {
// Insert this level
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},level={$GLOBALS['cache_array']['back_level']},ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]} - ADD!
\n";
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_refs` (userid,level,refid) VALUES (%s,%s,%s)",
- array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
// Move to next referal level and count his counter one up!
- $GLOBALS['cache_array']['back_level']++; UPDATE_REFBACK_TABLE($GLOBALS['cache_array']['up_refid'][($GLOBALS['cache_array']['back_level'] - 1)]);
+ $GLOBALS['cache_array']['back_level']++; updateRefbackTable($GLOBALS['cache_array']['up_refid'][($GLOBALS['cache_array']['back_level'] - 1)]);
} // END - if
// Do we have another level here?
@@ -223,15 +229,15 @@ function UPDATE_REFBACK_TABLE($uid) {
$uid = $old;
// Shall we add this as well?
- $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' AND refid=%s LIMIT 1",
- array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' AND refid=%s LIMIT 1",
+ array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
// Do we have no entry?
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},level=".($GLOBALS['cache_array']['back_level']-$minus).",ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]},numRows=".SQL_NUMROWS($result)." - BACK!
\n";
if (SQL_NUMROWS($result) == 0) {
// Insert this level
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_refs` (userid,level,refid) VALUES (%s,%s,%s)",
- array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},level=".($GLOBALS['cache_array']['back_level']-$minus).",ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]} - RETURNED!
\n";
} // END - if
} // END - if
@@ -243,10 +249,10 @@ function UPDATE_REFBACK_TABLE($uid) {
} // END - if
// When he has a referal...
- if ((($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']] == $uid) || ($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']] == 0)) && (GET_EXT_VERSION("cache") >= "0.1.2") && (!isset($GLOBALS['cache_array']['back_cached']))) {
+ if ((($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']] == $uid) || ($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']] == 0)) && (GET_EXT_VERSION('cache') >= '0.1.2') && (!isset($GLOBALS['cache_array']['back_cached']))) {
// Remove cache here
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):uid={$uid},ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]} - CACHE!
\n";
- if ($GLOBALS['cache_instance']->loadCacheFile("refback")) $GLOBALS['cache_instance']->destroyCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile('refback')) $GLOBALS['cache_instance']->destroyCacheFile();
$GLOBALS['cache_array']['back_cached'] = 1;
} // END - if
@@ -264,22 +270,22 @@ function UPDATE_REFBACK_TABLE($uid) {
function GET_USER_REFS ($uid, $level) {
//* DEBUG: */ print "----------------------- ".__FUNCTION__." - ENTRY ------------------------- \n";
// Default is no refs and no nickname
- $ADD = "";
+ $add = '';
$refs = array();
// Do we have nickname extension installed?
- if (EXT_IS_ACTIVE("nickname")) {
- $ADD = ", d.nickname";
+ if (EXT_IS_ACTIVE('nickname')) {
+ $add = ", d.nickname";
} // END - if
// Get refs from database
- $result = SQL_QUERY_ESC("SELECT r.id, r.refid, r.refback, r.points, d.status".$ADD."
+ $result = SQL_QUERY_ESC("SELECT r.id, r.refid, r.refback, r.points, d.status".$add."
FROM `{!_MYSQL_PREFIX!}_user_refs` AS r
LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
ON r.refid=d.userid
WHERE r.userid=%s AND r.level=%s
ORDER BY r.refid ASC",
- array(bigintval($uid), bigintval($level)), __FUNCTION__, __LINE__);
+ array(bigintval($uid), bigintval($level)), __FUNCTION__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) > 0) {
@@ -308,8 +314,8 @@ function GET_USER_REF_ENTRY ($id) {
$id = bigintval($id);
// Get entry from database
- $result = SQL_QUERY_ESC("SELECT id, refid, refback, level FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE id=%s AND userid=%s LIMIT 1",
- array($id, $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT id, refid, refback, level FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
+ array($id, getUserId()), __FUNCTION__, __LINE__);
// Is there an entry?
if (SQL_NUMROWS($result) == 1) {
@@ -336,7 +342,7 @@ function REFBACK_CHANGE_MEMBER_PERCENTS ($id, $percents) {
// No member!
$status['message'] = getMessage('MEMBER_REFBACK_ERROR_NO_MEMBER');
return $status;
- } elseif ("".$id."" != "".($id + 0)."") {
+ } elseif ("".$id."" != ''.($id + 0)."") {
// No number!
$status['message'] = getMessage('MEMBER_REFBACK_ERROR_INVALID_ID_NUMBER');
return $status;
@@ -357,11 +363,11 @@ function REFBACK_CHANGE_MEMBER_PERCENTS ($id, $percents) {
} // END - if
// Revert german commata
- $percents = REVERT_COMMA($percents);
+ $percents = convertCommaToDot($percents);
// Update entry
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_refs` SET refback='%s' WHERE id=%s AND userid=%s LIMIT 1",
- array($percents, $id, $GLOBALS['userid']), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_refs` SET refback='%s' WHERE `id`=%s AND `userid`=%s LIMIT 1",
+ array($percents, $id, getUserId()), __FUNCTION__, __LINE__);
// Entry updated?
if (SQL_AFFECTEDROWS() < 1) {
@@ -372,19 +378,19 @@ function REFBACK_CHANGE_MEMBER_PERCENTS ($id, $percents) {
// Prepare email content
$content = array(
- 'percents' => TRANSLATE_COMMA($percents),
+ 'percents' => translateComma($percents),
'refid' => $dummy['refid'],
'level' => $dummy['level']
);
// Load member email template
- $mail = LOAD_EMAIL_TEMPLATE("member_refback", $content, $GLOBALS['userid']);
+ $mail = LOAD_EMAIL_TEMPLATE("member_refback", $content, getUserId());
// Send email to user
- SEND_EMAIL($dummy['refid'], getMessage('MEMBER_REFBACK_SUBJECT'), $mail);
+ sendEmail($dummy['refid'], getMessage('MEMBER_REFBACK_SUBJECT'), $mail);
// Send admin notification
- SEND_ADMIN_NOTIFICATION(getMessage('ADMIN_REFBACK_SUBJECT'), "admin_refback", $content, $GLOBALS['userid']);
+ sendAdminNotification(getMessage('ADMIN_REFBACK_SUBJECT'), "admin_refback", $content, getUserId());
// All fine!
$status['ok'] = true;