toDB($_POST['userip']));
exit;
}
if (isset($_POST['useraction']) && $_POST['useraction'] == 'usersettings')
{
header('location:'.e_BASE."usersettings.php?".$tp -> toDB($_POST['userid']));
exit;
}
if (isset($_POST['useraction']) && $_POST['useraction'] == 'userclass')
{
header('location:'.e_ADMIN."userclass.php?".$tp -> toDB($_POST['userid'].".".e_QUERY));
exit;
}
$e_sub_cat = 'users';
$user = new users;
require_once("auth.php");
require_once(e_HANDLER."form_handler.php");
require_once(e_HANDLER."userclass_class.php");
require_once(e_HANDLER.'user_handler.php');
$user_info = new UserHandler;
$user_data = array();
$rs = new form;
if (e_QUERY)
{
$tmp = explode(".", e_QUERY);
$action = $tmp[0];
$sub_action = varset($tmp[1],'');
$id = varset($tmp[2],0);
$from = varset($tmp[3],0);
unset($tmp);
}
$from = varset($from, 0);
$amount = 30;
// ------- Check for Bounces --------------
$bounce_act = '';
if (isset($_POST['check_bounces'])) $bounce_act = 'first_check';
if (isset($_POST['delnonbouncesubmit'])) $bounce_act = 'delnonbounce';
if (isset($_POST['clearemailbouncesubmit'])) $bounce_act = 'clearemailbounce';
if (isset($_POST['delcheckedsubmit'])) $bounce_act = 'delchecked';
if (isset($_POST['delallsubmit'])) $bounce_act = 'delall';
if ($bounce_act)
{
$user->check_bounces($bounce_act, implode(',',$_POST['delete_email']));
require_once("footer.php");
exit;
}
// ------- Resend Email. --------------
if (isset($_POST['resend_mail']))
{
$user->resend($_POST['resend_id'],$_POST['resend_key'],$_POST['resend_name'],$_POST['resend_email']);
}
// ------- Resend Email. --------------
if(isset($_POST['resend_to_all']))
{
$user->resend_to_all();
}
// ------- Test Email. --------------
if (isset($_POST['test_mail']))
{
require_once(e_HANDLER."mail_validation_class.php");
list($adminuser,$adminhost) = split ("@", SITEADMINEMAIL);
$validator = new email_validation_class;
$validator->localuser= $adminuser;
$validator->localhost= $adminhost;
$validator->timeout=5;
$validator->debug=1;
$validator->html_debug=1;
$text = "
";
ob_start();
$email_status = $validator->ValidateEmailBox($_POST['test_email']);
$text .= ob_get_contents();
ob_end_clean();
$text .= "
";
$caption = $_POST['test_email']." - ";
$caption .= ($email_status == 1)? "Valid": "Invalid";
if($email_status == 1){
$text .= "";
}
$ns->tablerender($caption, $text);
unset($id, $action, $sub_cation);
}
// ------- Update Options. --------------
if (isset($_POST['update_options']))
{
$pref['avatar_upload'] = (FILE_UPLOADS ? $_POST['avatar_upload'] : 0);
$pref['im_width'] = $_POST['im_width'];
$pref['im_height'] = $_POST['im_height'];
$pref['photo_upload'] = (FILE_UPLOADS ? $_POST['photo_upload'] : 0);
$pref['del_unv'] = $_POST['del_unv'];
$pref['profile_rate'] = $_POST['profile_rate'];
$pref['profile_comments'] = $_POST['profile_comments'];
$pref['track_online'] = $_POST['track_online'];
$pref['force_userupdate'] = $_POST['force_userupdate'];
$pref['memberlist_access'] = $_POST['memberlist_access'];
save_prefs();
unset($_POST['update_options']); // So we don't log it
$admin_log->log_event('USET_03',$tp->toDB(implode('; ',$_POST)),E_LOG_INFORMATIVE);
$user->show_message(USRLAN_1);
}
// ------- Prune Users. --------------
if (isset($_POST['prune']))
{
$e107cache->clear("online_menu_member_total");
$e107cache->clear("online_menu_member_newest");
$text = USRLAN_56." ";
$bantype = $_POST['prune_type'];
if ($sql->db_Select("user", "user_id, user_name", "user_ban= {$bantype}"))
{
$uList = $sql->db_getList();
foreach($uList as $u)
{
$text .= $u['user_name']." ";
$sql->db_Delete("user", "user_id='{$u['user_id']}' ");
$sql->db_Delete("user_extended", "user_extended_id='{$u['user_id']}' ");
}
$admin_log->log_event('USET_04',str_replace(array('--COUNT--','--TYPE--'),array(count($uList),$bantype),USRLAN_160),E_LOG_INFORMATIVE);
}
$ns->tablerender(USRLAN_57, "
".$text."
");
unset($text);
}
// ------- Quick Add User --------------
if (isset($_POST['adduser']))
{
$e107cache->clear("online_menu_member_total");
$e107cache->clear("online_menu_member_newest");
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
{
exit;
}
$user_data = array(); // Assemble the data into an array
require_once(e_HANDLER."message_handler.php");
$displayname = strip_tags($_POST['name']);
if (($displayname != strip_tags($_POST['name'])) || (strstr($_POST['name'], "#") || strstr($_POST['name'], "=")))
{
message_handler("P_ALERT", USRLAN_92);
$error = TRUE;
}
$displayname = trim(str_replace(" ", "", $displayname));
if ($displayname == "Anonymous")
{
message_handler("P_ALERT", USRLAN_65);
$error = TRUE;
}
if ((strlen($displayname) > varset($pref['displayname_maxlength'],15)) || (strlen($displayname) < 2))
{
message_handler('P_ALERT',USRLAN_154);
$error = TRUE;
}
if ($sql->db_Count("user", "(*)", "WHERE user_name='".$displayname."' "))
{
message_handler("P_ALERT", USRLAN_66);
$error = TRUE;
}
if (isset($_POST['generateloginname']))
{
$loginname = $user_info->generateUserLogin($pref['predefinedLoginName']);
}
else
{
$loginname = trim(preg_replace('/ |\#|\=|\$/', "", strip_tags($_POST['loginname'])));
if ($loginname != $_POST['loginname'])
{
message_handler('P_ALERT',USRLAN_152);
$error = TRUE;
}
}
if ((strlen($loginname) > varset($pref['loginname_maxlength'],30)) || (strlen($loginname) < 3))
{
message_handler('P_ALERT',USRLAN_154);
$error = TRUE;
}
if ($sql->db_Count("user", "(*)", "WHERE user_loginname='".$loginname."' "))
{
message_handler("P_ALERT", USRLAN_153);
$error = TRUE;
}
if (isset($_POST['generatepassword']))
{
$_POST['password1'] = $user_info->generateRandomString('**********'); // 10-char password should be enough
}
else
{
if ($_POST['password1'] != $_POST['password2'])
{
message_handler("P_ALERT", USRLAN_67);
$error = TRUE;
}
}
if ($_POST['name'] == "" || $_POST['password1'] == "" || $_POST['password2'] = "")
{
message_handler("P_ALERT", USRLAN_68);
$error = TRUE;
}
if (!check_email($_POST['email']))
{
message_handler("P_ALERT", USRLAN_69);
$error = TRUE;
}
if ($sql->db_Count("user", "(*)", "WHERE user_email='".$_POST['email']."' AND user_ban='1' "))
{
message_handler("P_ALERT", USRLAN_147);
$error = TRUE;
}
if ($sql->db_Count("banlist", "(*)", "WHERE banlist_ip='".$_POST['email']."'"))
{
message_handler("P_ALERT", USRLAN_148);
$error = TRUE;
}
// Always save some of the entered data - then we can redisplay on error
$user_data['user_name'] = $displayname;
$user_data['user_loginname'] = $loginname;
$user_data['user_class'] = implode(",", $_POST['userclass']);
$user_data['user_email'] = $tp->toDB($_POST['email']);
$user_data['user_hideemail'] = 1;
$user_data['user_login'] = $tp->toDB($_POST['realname']);
if (!$error)
{
$user_data['user_password'] = $user_info->HashPassword($_POST['password1'],$loginname);
$user_data['user_join'] = time();
$user_data['user_lastvisit'] = 0;
$user_data['user_currentvisit'] = 0;
$user_data['user_pwchange'] = 0;
if (admin_update($sql -> db_Insert("user", $user_data), 'insert', USRLAN_70))
{
// Add to admin log
$admin_log->log_event('USET_02',"UName: {$user_data['user_name']}; Email: {$user_data['user_email']}",E_LOG_INFORMATIVE);
// Add to user audit trail
$admin_log->user_audit(USER_AUDIT_ADD_ADMIN,$user_data, 0,$user_data['user_loginname']);
if (isset($_POST['sendconfemail']))
{ // Send confirmation email to user
require_once(e_HANDLER.'mail.php');
$e_message = str_replace(array('--SITE--','--LOGIN--','--PASSWORD--'),array(SITEURL,$loginname,$_POST['password1']),USRLAN_185).USRLAN_186;
if (sendemail($user_data['user_email'],USRLAN_187.SITEURL,$e_message,$user_data['user_login'],'',''))
{
$message = USRLAN_188;
}
else
{
$message = USRLAN_189;
}
}
if (isset($_POST['generateloginname'])) $message .= '
'.USRLAN_173.': '.$loginname;
if (isset($_POST['generatepassword'])) $message .= '
'.USRLAN_172.': '.$_POST['password1'];
}
}
if (isset($message)) $user->show_message($message);
}
// ------- Bounce --> Unverified --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == "reqverify")
{
$sql->db_Select("user", "*", "user_id='".$_POST['userid']."'");
$row = $sql->db_Fetch();
extract($row);
$sql->db_Update("user", "user_ban='2' WHERE user_id='".$_POST['userid']."' ");
$user->show_message("User now has to verify");
$action = "main";
if(!$sub_action) {$sub_action = "user_id"; }
}
// ------- Ban User. --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == "ban")
{
// $sub_action = $_POST['userid'];
$sql->db_Select("user", "*", "user_id='".$_POST['userid']."'");
$row = $sql->db_Fetch();
if (($row['user_perms'] == "0") || ($row['user_perms'] == "0."))
{
$user->show_message(USRLAN_7);
}
else
{
if($sql->db_Update("user", "user_ban='1' WHERE user_id='".$_POST['userid']."' "))
{
$admin_log->log_event('USET_05',str_replace(array('--UID--','--NAME--'),array($row['user_id'],$row['user_name']),USRLAN_161),E_LOG_INFORMATIVE);
$user->show_message(USRLAN_8);
}
if(trim($row['user_ip']) == "")
{
$user->show_message(USRLAN_135);
}
else
{
if($sql->db_Count("user", "(*)", "WHERE user_ip = '{$row['user_ip']}'") > 1)
{ // Multiple users have same IP address
$user->show_message(str_replace("{IP}", $row['user_ip'], USRLAN_136));
}
else
{
if ($e107->add_ban(6,USRLAN_149.$row['user_name'].'/'.$row['user_loginname'],$row['user_ip'],USERID))
{ // Successful IP ban
$user->show_message(str_replace("{IP}", $row['user_ip'], USRLAN_137));
}
else
{ // IP address on whitelist
$user->show_message(str_replace("{IP}", $row['user_ip'], USRLAN_150));
}
}
}
}
$action = "main";
if(!$sub_action){$sub_action = "user_id"; }
}
// ------- Unban User --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == "unban")
{
$sql->db_Select("user", "user_name,user_ip", "user_id='".$_POST['userid']."'");
$row = $sql->db_Fetch();
$sql->db_Update("user", "user_ban='0' WHERE user_id='".$_POST['userid']."' ");
$sql -> db_Delete("banlist", " banlist_ip='{$row['user_ip']}' ");
$admin_log->log_event('USET_06',str_replace(array('--UID--','--NAME--'),array($_POST['userid'],$row['user_name']),USRLAN_162),E_LOG_INFORMATIVE);
$user->show_message(USRLAN_9);
$action = "main";
if(!$sub_action){$sub_action = "user_id"; }
}
// ------- Resend Email Confirmation. --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == 'resend')
{
$qry = (e_QUERY) ? "?".e_QUERY : "";
if ($sql->db_Select("user", "*", "user_id='".$_POST['userid']."' ")) {
$resend = $sql->db_Fetch();
$text .= "
\n";
$caption = USRLAN_112;
$ns->tablerender($caption, $text);
require_once("footer.php");
exit;
}
}
// ------- TEst Email confirmation. --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == 'test')
{
$qry = (e_QUERY) ? "?".e_QUERY : "";
if ($sql->db_Select("user", "*", "user_id='".$_POST['userid']."' ")) {
$test = $sql->db_Fetch();
$text .= "
\n";
$caption = USRLAN_118;
$ns->tablerender($caption, $text);
require_once("footer.php");
exit;
}
}
// ------- Delete User --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == 'deluser')
{
if ($_POST['confirm'])
{
if ($sql->db_Delete("user", "user_id='".$_POST['userid']."' AND user_perms != '0' AND user_perms != '0.'"))
{
$sql->db_Delete("user_extended", "user_extended_id='".$_POST['userid']."' ");
$admin_log->log_event('USET_07',str_replace('--UID--',$_POST['userid'],USRLAN_163),E_LOG_INFORMATIVE);
$user->show_message(USRLAN_10);
}
if(!$sub_action){ $sub_action = "user_id"; }
if(!$id){ $id = "DESC"; }
}
else
{ // Put up confirmation
if ($sql->db_Select("user", "*", "user_id='".$_POST['userid']."' ")) {
$row = $sql->db_Fetch();
$qry = (e_QUERY) ? "?".e_QUERY : "";
$text .= "
";
$ns->tablerender(USRLAN_16, $text);
require_once("footer.php");
exit;
}
}
}
// ------- Make Admin --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == "admin" && getperms('3'))
{
$sql->db_Select("user", "user_id, user_name", "user_id='".$_POST['userid']."'");
$row = $sql->db_Fetch();
$sql->db_Update("user", "user_admin='1' WHERE user_id='".$_POST['userid']."' ");
$admin_log->log_event('USET_08',str_replace(array('--UID--','--NAME--'),array($row['user_id'],$row['user_name']),USRLAN_164),E_LOG_INFORMATIVE);
$user->show_message($row['user_name']." ".USRLAN_3."
".USRLAN_4."");
$action = "main";
if(!$sub_action){ $sub_action = "user_id"; }
if(!$id){ $id = "DESC"; }
}
// ------- Remove Admin --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == "unadmin" && getperms('3'))
{
$sql->db_Select("user", "*", "user_id='".$_POST['userid']."'");
$row = $sql->db_Fetch();
extract($row);
if ($user_perms == "0")
{
$user->show_message(USRLAN_5);
}
else
{
$sql->db_Update("user", "user_admin='0', user_perms='' WHERE user_id='".$_POST['userid']."'");
$admin_log->log_event('USET_09',str_replace(array('--UID--','--NAME--'),array($row['user_id'],$row['user_name']),USRLAN_165),E_LOG_INFORMATIVE);
$user->show_message($user_name." ".USRLAN_6);
$action = "main";
if(!$sub_action){ $sub_action = "user_id"; }
if(!$id){ $id = "DESC"; }
}
}
// ------- Approve User. --------------
if (isset($_POST['useraction']) && $_POST['useraction'] == "verify")
{
$uid = intval($_POST['userid']);
if ($sql->db_Select("user", "*", "user_id='".$uid."' "))
{
if ($row = $sql->db_Fetch())
{
// Add in the initial classes, if this is the time
$init_classes = '';
if ($pref['init_class_stage'] == '2')
{
$init_classes = explode(',',varset($pref['initial_user_classes'],''));
if ($init_classes)
{ // Update the user classes
$row['user_class'] = $tp->toDB(implode(',',array_unique(array_merge($init_classes, explode(',',$row['user_class'])))));
$init_classes = ", user_class='".$row['user_class']."' ";
}
}
$sql->db_Update("user", "user_ban='0'{$init_classes} WHERE user_id='".$uid."' ");
$admin_log->log_event('USET_10',str_replace(array('--UID--','--NAME--'),array($row['user_id'],$row['user_name']),USRLAN_166),E_LOG_INFORMATIVE);
// $e_event->trigger("userveri", $row); // We do this from signup.php - should we do it here?
$user->show_message(USRLAN_86);
if(!$action){ $action = "main"; }
if(!$sub_action){ $sub_action = "user_id"; }
if(!$id){ $id = "DESC"; }
if($pref['user_reg_veri'] == 2)
{
if($sql->db_Select("user", "user_email, user_name", "user_id = '{$uid}'"))
{
$row = $sql->db_Fetch();
$message = USRLAN_114." ".$row['user_name'].",\n\n".USRLAN_122." ".SITENAME.".\n\n".USRLAN_123."\n\n";
$message .= str_replace("{SITEURL}", SITEURL, USRLAN_139);
require_once(e_HANDLER."mail.php");
if(sendemail($row['user_email'], USRLAN_113." ".SITENAME, $message))
{
// echo str_replace("\n","
",$message);
$user->show_message("Email sent to: ".$row['user_name']);
}
else
{
$user->show_message("Failed to send to: ".$row['user_name']);
}
}
}
}
}
}
if (isset($action) && $action == "uset")
{
$user->show_message(USRLAN_87);
$action = "main";
}
if (isset($action) && $action == "cu")
{
$user->show_message(USRLAN_88);
$action = "main";
// $sub_action = "user_id";
}
/*
echo "action= ".$action."
";
echo "subaction= ".$sub_action."
";
echo "id= ".$id."
";
echo "from= ".$from."
";
echo "amount= ".$amount."
";
*/
$unverified = $sql -> db_Count("user", "(*)", "WHERE user_ban = 2");
if (!e_QUERY) $action = "main";
switch ($action)
{
case "unverified" :
$user->show_existing_users($action, $sub_action, $id, $from, $amount);
break;
case "options" :
$user->show_prefs();
break;
case "prune" :
$user->show_prune();
break;
case "create" :
$user->add_user($user_data);
break;
default :
$user->show_existing_users($action, $sub_action, $id, $from, $amount);
}
require_once("footer.php");
class users
{
function show_existing_users($action, $sub_action, $id, $from, $amount)
{
global $sql, $rs, $ns, $tp, $mySQLdefaultdb,$pref,$unverified;
// save the display choices.
if(isset($_POST['searchdisp']))
{
$pref['admin_user_disp'] = implode("|",$_POST['searchdisp']);
save_prefs();
}
if(!$pref['admin_user_disp'])
{
$search_display = array("user_name","user_class");
}
else
{
$search_display = explode("|",$pref['admin_user_disp']);
}
if ($sql->db_Select("userclass_classes")) {
while ($row = $sql->db_Fetch())
{
$class[$row['userclass_id']] = $tp->toHTML($row['userclass_name'],"","defs,emotes_off, no_make_clickable");
}
}
$text = "
";
if (isset($_POST['searchquery']) && $_POST['searchquery'] != "")
{
$_POST['searchquery'] = $tp->toDB(trim($_POST['searchquery']));
$query = "WHERE ".
$query .= (strpos($_POST['searchquery'], "@") !== FALSE) ? "user_email REGEXP('".$_POST['searchquery']."') OR ": "";
$query .= (strpos($_POST['searchquery'], ".") !== FALSE) ? "user_ip REGEXP('".$_POST['searchquery']."') OR ": "";
foreach($search_display as $disp)
{
$query .= "$disp REGEXP('".$_POST['searchquery']."') OR ";
}
$query .= "user_login REGEXP('".$_POST['searchquery']."') OR ";
$query .= "user_name REGEXP('".$_POST['searchquery']."') ";
if($action == 'unverified')
{
$query .= " AND user_ban = 2 ";
}
$query .= " ORDER BY user_id";
} else {
$query = "";
if($action == 'unverified')
{
$query = "WHERE user_ban = 2 ";
}
$query .= "ORDER BY ".($sub_action ? $sub_action : "user_id")." ".($id ? $id : "DESC")." LIMIT $from, $amount";
}
// $user_total = db_Count($table, $fields = '(*)',
$qry_insert = "SELECT u.*, ue.* FROM #user AS u LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id ";
if ($user_total = $sql->db_Select_gen($qry_insert. $query)) {
$text .= "
ID |
".USRLAN_79." | ";
// Search Display Column header.
$display_lan = array(
'user_id' => DUSRLAN_1,
'user_name' => DUSRLAN_2,
'user_loginname' => DUSRLAN_3,
'user_customtitle' => DUSRLAN_4,
'user_password' => DUSRLAN_5,
'user_sess' => DUSRLAN_6,
'user_email' => DUSRLAN_7,
'user_homepage' => DUSRLAN_8,
'user_icq' => DUSRLAN_9,
'user_aim' => DUSRLAN_10,
'user_msn' => DUSRLAN_11,
'user_location' => DUSRLAN_12,
'user_birthday' => DUSRLAN_13,
'user_signature' => DUSRLAN_14,
'user_image' => DUSRLAN_15,
'user_timezone' => DUSRLAN_16,
'user_hideemail' => DUSRLAN_17,
'user_join' => DUSRLAN_18,
'user_lastvisit' => DUSRLAN_19,
'user_currentvisit' => DUSRLAN_20,
'user_lastpost' => DUSRLAN_21,
'user_chats' => DUSRLAN_22,
'user_comments' => DUSRLAN_23,
'user_forums' => DUSRLAN_24,
'user_ip' => DUSRLAN_25,
'user_ban' => DUSRLAN_26,
'user_prefs' => DUSRLAN_27,
'user_new' => DUSRLAN_28,
'user_viewed' => DUSRLAN_29,
'user_visits' => DUSRLAN_30,
'user_admin' => DUSRLAN_31,
'user_login' => DUSRLAN_32,
'user_class' => DUSRLAN_33,
'user_perms' => DUSRLAN_34,
'user_realm' => DUSRLAN_35,
'user_pwchange' => DUSRLAN_36,
'user_xup' => DUSRLAN_37
);
foreach($search_display as $disp){
if (isset($display_lan[$disp])) {
$text .= "".$display_lan[$disp]." | ";
} else {
$text .= "".ucwords(str_replace("_"," ",$disp))." | ";
}
}
// ------------------------------
$text .= " ".LAN_OPTIONS." |
";
while ($row = $sql->db_Fetch()) {
extract($row);
$text .= "
";
// Display Chosen options -------------------------------------
$datefields = array("user_lastpost","user_lastvisit","user_join","user_currentvisit");
$boleanfields = array("user_admin","user_hideemail","user_ban");
foreach($search_display as $disp)
{
$text .= "";
$prev[$disp] = $row[$disp];
}
// -------------------------------------------------------------
$qry = (e_QUERY) ? "?".e_QUERY : "";
$text .= "
";
}
$text .= "
";
}
if($action == "unverified"){
$text .= "
";
}
$users = (e_QUERY != "unverified") ? $sql->db_Count("user"): $unverified;
if ($users > $amount && !$_POST['searchquery']) {
$parms = "{$users},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.user_id.desc.")."[FROM]";
$text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}");
}
// Search - display options etc. .
$text .= "
\n
";
// ======================
$total_cap = (isset($_POST['searchquery'])) ? $user_total : $users;
$caption = USRLAN_77 ." (total: $total_cap)";
$ns->tablerender($caption, $text);
}
function show_options($action)
{
global $unverified;
// ##### Display options
if ($action == "")
{
$action = "main";
}
// ##### Display options
$var['main']['text'] = USRLAN_71;
$var['main']['link'] = e_SELF;
$var['create']['text'] = USRLAN_72;
$var['create']['link'] = e_SELF."?create";
$var['prune']['text'] = USRLAN_73;
$var['prune']['link'] = e_SELF."?prune";
$var['options']['text'] = LAN_OPTIONS;
$var['options']['link'] = e_SELF."?options";
if($unverified)
{
$var['unveri']['text'] = USRLAN_138." ($unverified)";
$var['unveri']['link'] = e_SELF."?unverified";
}
// $var['mailing']['text']= USRLAN_121;
// $var['mailing']['link']="mailout.php";
show_admin_menu(USRLAN_76, $action, $var);
}
function show_prefs()
{
global $ns, $pref, $e_userclass;
if (!is_object($e_userclass)) $e_userclass = new user_class;
$pref['memberlist_access'] = varset($pref['memberlist_access'], e_UC_MEMBER);
$text = "
";
$ns->tablerender(USRLAN_52, $text);
}
function show_message($message)
{
global $ns;
$ns->tablerender("", "
".$message."
");
}
function show_prune()
{
global $ns, $sql;
$unactive = $sql->db_Count("user", "(*)", "WHERE user_ban=2");
$bounced = $sql->db_Count("user", "(*)", "WHERE user_ban=3");
$text = "
";
$ns->tablerender(USRLAN_55, $text);
}
// Add a new user - may be passed existing data if there was an entry error on first pass
function add_user($user_data)
{
global $rs, $ns, $pref, $e_userclass;
if (!is_object($e_userclass)) $e_userclass = new user_class;
$text = "
". $rs->form_open("post", e_SELF.(e_QUERY ? '?'.e_QUERY : ''), "adduserform")."
\n";
if (!isset($user_data['user_class'])) $user_data['user_class'] = varset($pref['initial_user_classes'],'');
$temp = $e_userclass->vetted_tree('userclass',array($e_userclass,'checkbox_desc'), $user_data['user_class'], 'classes');
if ($temp)
{
$text .= "
\n";
}
$text .= "
";
$ns->tablerender(USRLAN_59, $text);
}
function resend($id,$key,$name,$email,$lfile='')
{
global $sql,$mailheader_e107id, $admin_log;
// Check for a Language field, and if present, send the email in the user's language.
if($lfile == "")
{
if($sql -> db_Select("user_extended", "user_language", "user_extended_id = '$id'"))
{
$row = $sql -> db_Fetch();
$lfile = e_LANGUAGEDIR.$row['user_language']."/lan_signup.php";
}
}
if(is_readable($lfile))
{
require_once($lfile);
}
else
{
$row['user_language'] = e_LANGUAGE;
require_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_signup.php");
}
$return_address = (substr(SITEURL, -1) == "/") ? SITEURL."signup.php?activate.".$id.".".$key : SITEURL."/signup.php?activate.".$id.".".$key;
$message = LAN_EMAIL_01." ".$name."\n\n".LAN_SIGNUP_24." ".SITENAME.".\n".LAN_SIGNUP_21."...\n\n";
$message .= $return_address . "\n\n".SITENAME."\n".SITEURL;
$mailheader_e107id = $id;
require_once(e_HANDLER."mail.php");
if(sendemail($email, LAN_404." ".SITENAME, $message))
{
// echo str_replace("\n","
",$message);
$admin_log->log_event('USET_11',str_replace(array('--ID--','--NAME--','--EMAIL--'),array($id,$name,$email),USRLAN_167),E_LOG_INFORMATIVE);
$this->show_message(USRLAN_140.":
".$name." (".$row['user_language'].") ");
}
else
{
$this->show_message(USRLAN_141.": ".$name);
}
}
function resend_to_all()
{
global $sql,$pref,$sql3, $admin_log;
$count = 0;
$pause_count = 1;
$pause_amount = ($pref['mail_pause']) ? $pref['mail_pause'] : 10;
$pause_time = ($pref['mail_pausetime']) ? $pref['mail_pausetime'] : 1;
if($sql -> db_Select_gen("SELECT user_language FROM #user_extended LIMIT 1"))
{
$query = "SELECT u.*, ue.* FROM #user AS u LEFT JOIN #user_extended AS ue ON ue.user_extended_id = u.user_id WHERE u.user_ban = 2 ORDER BY u.user_id DESC";
}
else
{
$query = "SELECT * FROM #user WHERE user_ban='2'";
}
if(!is_object($sql3))
{
$sql3 = new db;
}
$sql3 -> db_Select_gen($query);
while($row = $sql3-> db_Fetch())
{
echo $row['user_id']." ".$row['user_sess']." ".$row['user_name']." ".$row['user_email']."
";
$this->resend($row['user_id'],$row['user_sess'],$row['user_name'],$row['user_email'],$row['user_language']);
if($pause_count > $pause_amount)
{
sleep($pause_time);
$pause_count = 1;
}
sleep(1);
$pause_count++;
$count++;
}
if ($count)
{
$admin_log->log_event('USET_12',str_replace('--COUNT--',$count,USRLAN_168),E_LOG_INFORMATIVE);
}
}
// ---------------------------------------------------------------------
// Bounce handling
// ---------------------------------------------------------------------
// $bounce_act has the task to perform:
// 'first_check' - initial read of list of bounces
// 'delnonbounce' - delete any emails that aren't bounces
// 'clearemailbounce' - delete email address for any user whose emails bounced
// 'delchecked' - delete the emails whose comma-separated IDs are in $bounce_arr
// 'delall' - delete all bounced emails
function check_bounces($bounce_act='first_check', $bounce_arr = '')
{
global $sql,$pref;
include(e_HANDLER."pop3_class.php");
if (!trim($bounce_act)) $bounce_act='first_check';
// echo "Check bounces. Action: {$bounce_act}; Entries: {$bounce_arr}
";
$obj= new receiveMail($pref['mail_bounce_user'],$pref['mail_bounce_pass'],$pref['mail_bounce_email'],$pref['mail_bounce_pop3'],varset($pref['mail_bounce_type'],'pop3'));
$del_count = 0;
if ($bounce_act !='first_check')
{ // Must do some deleting
$obj->connect();
$tot=$obj->getTotalMails();
$del_array = explode(',',$bounce_arr);
for($i=1;$i<=$tot;$i++)
{ // Scan all emails; delete current one if meets the criteria
$dodel = FALSE;
switch ($bounce_act)
{
case 'delnonbounce' :
$head=$obj->getHeaders($i);
$dodel = (!$head['bounce']);
break;
case 'clearemailbounce' :
if (!in_array($i, $del_array)) break;
$head=$obj->getHeaders($i);
if($head['bounce'])
{
if (preg_match("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $obj->getBody($i), $result)) $usr_email = trim($result[0]);
if ($sql->db_Select('user','user_id, user_name, user_email',"user_email='".$usr_email."' "))
{
$row = $sql->db_Fetch();
if ($sql->db_Update('user',"`user_email`='' WHERE `user_id` = '".$row['user_id']."' ") !== FALSE)
{
// echo "Deleting user email {$row['user_email']} for user {$row['user_name']}, id={$row['user_id']}
";
$dodel = TRUE;
}
}
}
break;
case 'delall' :
$dodel = TRUE;
break;
case 'delchecked' :
$dodel = in_array($i, $del_array);
break;
}
if ($dodel)
{
// echo "Delete email ID {$i}
";
$obj->deleteMails($i);
$del_count++; // Keep track of number of emails deleted
}
} // End - Delete one email
$obj->close_mailbox(); // This actually deletes the emails
} // End of email deletion
// Now list the emails that are left
$obj->connect();
$tot=$obj->getTotalMails();
$found = FALSE;
$DEL = ($pref['mail_bounce_delete']) ? TRUE : FALSE;
$text = "
";
array_unique($id);
array_unique($emails);
$all_ids = implode(",",$id);
$all_emails = implode(",",$emails);
$obj->close_mailbox(); // This will actually delete emails
// $tot has total number of emails in the mailbox
$found = count($emails); // $found - Number of bounce emails found
// $del_count has number of emails deleted
// Update bounce status for users
$ed = $sql -> db_Update("user", "user_ban=3 WHERE (`user_id` IN (".$all_ids.") OR `user_email` IN (".$all_emails.")) AND user_sess !='' ");
if (!$ed) $ed = '0';
$this->show_message(str_replace(array('{TOTAL}','{DELCOUNT}','{DELUSER}','{FOUND}'),
array($tot,$del_count,$ed,$found),USRLAN_155).$text);
}
} // End class users
function users_adminmenu()
{
global $user;
global $action;
$user->show_options($action);
}
?>