X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Fuser_functions.php;h=75cf35e9972a3bfa42064ed2895e5c0b9b651523;hp=533dded2603b1c82f61b5a379ed236919d74ac4f;hb=5f8c1a333627cd0145f778a6eebdb251f5bb40b6;hpb=60494e212a67fe360bfbb481eb4928480a6f379b diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 533dded260..75cf35e997 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -32,21 +32,21 @@ ************************************************************************/ // Some security stuff... -if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) -{ +if (!defined('__SECURITY')) { $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; require($INC); } +// Add links for selecting some users function alpha($sortby, $colspan, $return=false) { global $_CONFIG; - if (empty($_GET['offset'])) $_GET['offset'] = "0"; + if (empty($_GET['offset'])) $_GET['offset'] = 0; $ADD = "&page=".$_GET['page']."&offset=".$_GET['offset']; if (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']); /* Creates the list of letters and makes them a link. */ - $alphabet = array(_ALL2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", 'N', "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", 'Y', "Z", _OTHERS); + $alphabet = array(_ALL2,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",_OTHERS); $num = count($alphabet) - 1; $OUT = ""; while (list($counter, $ltr) = each($alphabet)) @@ -87,11 +87,12 @@ function alpha($sortby, $colspan, $return=false) OUTPUT_HTML($OUT); } } -// + +// Add links for sorting function SortLinks($letter, $sortby, $colspan, $return=false) { $OUT = ""; - if (empty($_GET['offset'])) $_GET['offset'] = "0"; + if (empty($_GET['offset'])) $_GET['offset'] = 0; $ADD = "&page=".$_GET['page']."&offset=".$_GET['offset']; if (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']); @@ -111,7 +112,7 @@ function SortLinks($letter, $sortby, $colspan, $return=false) $list['nickname'] = NICKNAME; } - foreach ($list as $sort=>$title) { + foreach ($list as $sort => $title) { if ($sortby == $sort) { $OUT .= "".$title." | "; } else { @@ -133,7 +134,8 @@ function SortLinks($letter, $sortby, $colspan, $return=false) OUTPUT_HTML($OUT); } } -// + +// Add page navigation function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false) { if (!$show_form) @@ -198,6 +200,7 @@ function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false) OUTPUT_HTML($OUT); } } + // Create email link to user's account function USER_CREATE_EMAIL_LINK($email, $mod="admin") { @@ -222,5 +225,42 @@ WHERE email='%s'".$locked." LIMIT 1", // Return rewritten (?) email address return $email; } -// + +// Selects a random user id as the new referal id if they have at least X confirmed mails in this run +function SELECT_RANDOM_REFID () { + global $_CONFIG; + + // Default is zero refid + $refid = 0; + + // Is the extension version fine? + if (GET_EXT_VERSION("user") >= "0.3.4") { + // Get all user ids + $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true, " AND `rand_confirmed` >= ".$_CONFIG['user_min_confirmed'].""); + + // Do we have at least one? + if ($totalUsers > 0) { + // Then choose random number + $randNum = mt_rand(0, ($totalUsers - 1)); + + // Look for random user + $result = SQL_QUERY_ESC("SELECT `userid` FROM `"._MYSQL_PREFIX."_user_data` WHERE `status`='CONFIRMED' AND `rand_confirmed` >= %s ORDER BY `rand_confirmed` DESC LIMIT %s, 1", + array($_CONFIG['user_min_confirmed'], $randNum), __FILE__, __LINE__); + + // Do we have one entry there? + if (SQL_NUMROWS($result) == 1) { + // Use that userid as new referal id + list($refid) = SQL_FETCHROW($result); + } // END - if + + // Free result + SQL_FREERESULT($result); + } // END - if + } // END - if + + // Return result + return $refid; +} + +// [EOF] ?>