X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_refs.php;h=f9fd9e142dda1365a93da9569c632fcedb46144f;hb=2142149f3f72f1a2476f95a87937c044d63bbaf2;hp=acfc839872e7536b12e31cd6bbf07c2baafccf37;hpb=a1ef1533f17e1ca5db81a9912632491e72626694;p=mailer.git
diff --git a/inc/modules/admin/what-list_refs.php b/inc/modules/admin/what-list_refs.php
index acfc839872..f9fd9e142d 100644
--- a/inc/modules/admin/what-list_refs.php
+++ b/inc/modules/admin/what-list_refs.php
@@ -6,7 +6,7 @@
* -------------------------------------------------------------------- *
* File : what-list_refs.php *
* -------------------------------------------------------------------- *
- * Short description : Show all referrals made by a member *
+ * Short description : Show all referals made by a member *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Alle generierten Refs eines Mitgliedes anzeigen *
* -------------------------------------------------------------------- *
@@ -38,104 +38,215 @@
************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
+if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ require($INC);
}
// Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+ADD_DESCR("admin", __FILE__);
+
+if (!empty($_GET['u_id'])) {
+ // Secure userid
+ $uid = bigintval($_GET['u_id']);
-OPEN_TABLE("100%", "admin_content admin_content_align", "");
-if (!empty($_GET['u_id']))
-{
// Check if the user already exists
- $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
- array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
- // Free memory
- SQL_FREERESULT($result);
-
- // Loads surname, family's name and the email address
- $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s",
- array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
- $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s AND status != 'CONFIRMED' ORDER BY userid",
- array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
- $menge = SQL_RESULT($result , 0, 0);
- $menge_lck = SQL_RESULT($result_lck, 0, 0);
-
- // Free memory
- SQL_FREERESULT($result);
- SQL_FREERESULT($result_lck);
-
- $result = SQL_QUERY_ESC("SELECT userid, sex, surname, family, email, status, joined FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s ORDER BY userid",
- array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
-
- OUTPUT_HTML(ADMIN_TOTAL_REFS_1."".ADMIN_USER_PROFILE_LINK($_GET['u_id'])."".ADMIN_TOTAL_REFS_2.$menge.ADMIN_TOTAL_REFS_3.$menge_lck.ADMIN_TOTAL_REFS_4."
");
- if ($result)
- {
- $rows = SQL_NUMROWS($result);
- if ($rows > 0)
- {
- // Load all referrals
- $SW = "2"; $OUT = "";
- while ($row = SQL_FETCHROW($result))
- {
- // Check for referrals
+ $result_user = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
+ array($uid), __FILE__, __LINE__);
+
+ // User found?
+ if (SQL_NUMROWS($result_user) == 1) {
+ // Is the refback extension installed?
+ if (EXT_IS_ACTIVE("refback")) {
+ // Load all referal levels
+ $result_levels = SQL_QUERY("SELECT level, percents
+FROM "._MYSQL_PREFIX."_refdepths
+WHERE level > 0
+ORDER BY level ASC", __FILE__, __LINE__);
+ } else {
+ // Loads surname, family's name and the email address
+ $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s",
+ array($uid), __FILE__, __LINE__);
+ $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s AND status != 'CONFIRMED' ORDER BY userid",
+ array($uid), __FILE__, __LINE__);
+ $menge = SQL_RESULT($result , 0, 0);
+ $menge_lck = SQL_RESULT($result_lck, 0, 0);
+
+ // Free memory
+ SQL_FREERESULT($result);
+ SQL_FREERESULT($result_lck);
+
+ // Query for refs
+ $result_levels = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email, status, joined FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s ORDER BY userid ASC",
+ array($uid), __FILE__, __LINE__);
+
+ // Output info message
+ OUTPUT_HTML(ADMIN_TOTAL_REFS_1."".ADMIN_USER_PROFILE_LINK($_GET['u_id'])."".ADMIN_TOTAL_REFS_2.$menge.ADMIN_TOTAL_REFS_3.$menge_lck.ADMIN_TOTAL_REFS_4."
");
+ }
+
+ // Are there some levels (VERY BAD IF NONE!)
+ if (SQL_NUMROWS($result_levels) > 0) {
+ // List all ref levels or entries if no refback is installed
+ $OUT = ""; $SW = 2;
+ while ($levels = SQL_FETCHARRAY($result_levels)) {
+ // Insert more data
+ $levels['sw'] = $SW;
+
+ // Is the refback still active? ;-)
+ if (EXT_IS_ACTIVE("refback")) {
+ // Load all refs of this user
+ $result_refs = SQL_QUERY_ESC("SELECT refid FROM "._MYSQL_PREFIX."_user_refs WHERE userid=%s AND level='%s' ORDER BY refid ASC",
+ array($uid, $levels['level']), __FILE__, __LINE__);
+ //* DEBUG: */ echo $uid."/".$levels['level']."/".SQL_NUMROWS($result_refs)."
\n";
+
+ // Do we have levels?
+ if (SQL_NUMROWS($result_refs) > 0) {
+ // Loads surname, family's name and the email address
+ $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s",
+ array($uid), __FILE__, __LINE__);
+ $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s AND status != 'CONFIRMED' ORDER BY userid",
+ array($uid), __FILE__, __LINE__);
+ $menge = SQL_RESULT($result , 0, 0);
+ $menge_lck = SQL_RESULT($result_lck, 0, 0);
+
+ // Free memory
+ SQL_FREERESULT($result);
+ SQL_FREERESULT($result_lck);
+
+ // Output info message
+ $levels['info'] = ADMIN_TOTAL_REFS_1."".ADMIN_USER_PROFILE_LINK($uid)."".ADMIN_TOTAL_REFS_2.$menge.ADMIN_TOTAL_REFS_3.$menge_lck.ADMIN_TOTAL_REFS_4;
+
+ // Load all refs
+ $OUT_REFS = ""; $SW = 2;
+ while (list($refid) = SQL_FETCHROW($result_refs)) {
+ // Query for data
+ $result_user = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email, status, joined FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
+ array($refid), __FILE__, __LINE__);
+
+ // Is the data there?
+ if (SQL_NUMROWS($result_user) == 1) {
+ // Load data
+ $data = SQL_FETCHARRAY($result_user);
+
+ // Check for referals
+ $result_cnt = SQL_QUERY_ESC("SELECT COUNT(userid) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s",
+ array($refid), __FILE__, __LINE__);
+
+ // Load refs
+ $refs_cnt = SQL_RESULT($result_cnt, 0, 0);
+
+ // Free result
+ SQL_FREERESULT($result_cnt);
+
+ // Prepare data for the template
+ $content = array(
+ 'sw' => $SW,
+ 'u_link' => ADMIN_USER_PROFILE_LINK($data['userid']),
+ 'gender' => TRANSLATE_GENDER($data['gender']),
+ 'refs_link' => "0",
+ 'surname' => $data['surname'],
+ 'family' => $data['family'],
+ 'email' => "[".$data['email']."]",
+ 'status' => TRANSLATE_STATUS($data['status']),
+ 'registered' => MAKE_DATETIME($data['joined'], "3"),
+ );
+
+ // Check if referal count is larger 0 and update link
+ if ($refs_cnt > 0) $content['refs_link'] = ADMIN_USER_PROFILE_LINK($data['userid'], $refs_cnt, "list_refs");
+
+ // Load template for level one
+ $OUT_REFS .= LOAD_TEMPLATE("admin_list_refs_row", true, $content);
+ } else {
+ // No refs found
+ $OUT_REFS = LOAD_TEMPLATE("admin_list_refs_nodata", true, $refid);
+ }
+
+ // Free result
+ SQL_FREERESULT($result_user);
+
+ // Add content
+ $levels['rows'] = $OUT_REFS;
+
+ // Switch colors
+ $SW = 3 - $SW;
+ } // END - while
+ } else {
+ // Output info message
+ $levels['info'] = ADMIN_TOTAL_REFS_1."".ADMIN_USER_PROFILE_LINK($uid)."".ADMIN_TOTAL_REFS_2."0".ADMIN_TOTAL_REFS_3."0".ADMIN_TOTAL_REFS_4;
+
+ // No refs found
+ $levels['rows'] = LOAD_TEMPLATE("admin_list_refs_norefs", true, array('uid' => $uid));
+ }
+
+ // Free result
+ SQL_FREERESULT($result_refs);
+
+ // Load level template
+ $OUT .= LOAD_TEMPLATE("admin_list_refs_level", true, $levels);
+ } else {
+ // Check for referals
$result_refs = SQL_QUERY_ESC("SELECT COUNT(userid) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s",
- array(bigintval($row[0])), __FILE__, __LINE__);
+ array(bigintval($levels['userid'])), __FILE__, __LINE__);
$refs_cnt = SQL_RESULT($result_refs, 0, 0);
SQL_FREERESULT($result_refs);
// Prepare data for the template
$content = array(
'sw' => $SW,
- 'u_link' => ADMIN_USER_PROFILE_LINK($row[0]),
- 'salut' => TRANSLATE_SEX($row[1]),
+ 'u_link' => ADMIN_USER_PROFILE_LINK($levels['userid']),
+ 'gender' => TRANSLATE_GENDER($levels['gender']),
'refs_link' => "0",
- 'surname' => $row[2],
- 'family' => $row[3],
- 'email' => "".$row[4]."",
- 'status' => TRANSLATE_STATUS($row[5]),
- 'registered' => MAKE_DATETIME($row[6], "3"),
+ 'surname' => $levels['surname'],
+ 'family' => $levels['family'],
+ 'email' => "[".$levels['email']."]",
+ 'status' => TRANSLATE_STATUS($levels['status']),
+ 'registered' => MAKE_DATETIME($levels['joined'], "3"),
);
- // Check if referral count is larger 0 and update link
- if ($refs_cnt > 0) $content['refs_link'] = ADMIN_USER_PROFILE_LINK($row[0], $refs_cnt, "list_refs");
+ // Check if referal count is larger 0 and update link
+ if ($refs_cnt > 0) $content['refs_link'] = ADMIN_USER_PROFILE_LINK($levels['userid'], $refs_cnt, "list_refs");
- // Load row template and switch color
+ // Load template for level one
$OUT .= LOAD_TEMPLATE("admin_list_refs_row", true, $content);
+
+ // Switch colors
$SW = 3 - $SW;
}
+ } // END - while
- // Free memory
- SQL_FREERESULT($result);
- define('__REF_ROWS', $OUT);
+ // Prepare content
+ $content = array(
+ 'rows' => $OUT,
+ 'uid' => ADMIN_USER_PROFILE_LINK($_GET['u_id'])
+ );
- // Load main template
- LOAD_TEMPLATE("admin_list_refs");
+ // Load main template
+ if (EXT_IS_ACTIVE("refback")) {
+ LOAD_TEMPLATE("admin_list_refs2", false, $content);
+ } else {
+ LOAD_TEMPLATE("admin_list_refs", false, $content);
}
+ } elseif (EXT_IS_ACTIVE("refback")) {
+ // No levels found, very bad!
+ LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_REF_LEVELS);
+ } else {
+ // No refs made so far
+ LOAD_TEMPLATE("admin_settings_saved", false, USER_REF_404);
}
- else
- {
- // No referrals made so far
- LOAD_TEMPLATE("admin_settings_saved", false, USER_REF_404);
- }
- }
- else
- {
+
+ // Free result
+ SQL_FREERESULT($result_levels);
+ } else {
// User not found
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2);
+ LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_MEMBER_404, $_GET['u_id']));
}
-}
- else
-{
+
+ // Free memory
+ SQL_FREERESULT($result_user);
+} else {
// Output selection form with all confirmed user accounts listed
ADD_MEMBER_SELECTION_BOX();
}
-CLOSE_TABLE();
//
?>