diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php
index 12711658f..5ef52ddad 100644
--- a/e107_admin/mailout.php
+++ b/e107_admin/mailout.php
@@ -76,6 +76,7 @@ if (!getperms('W'))
}
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_users.php');
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_mailout.php');
+ e107::lan('core','signup');
require_once(e_HANDLER.'ren_help.php');
@@ -133,6 +134,11 @@ function sendProgress($id)
}
+ if(!empty($_GET['iframe']))
+ {
+ define('e_IFRAME', true);
+ }
+
if(e_AJAX_REQUEST)
{
$id = intval($_GET['mode']);
@@ -353,14 +359,26 @@ class mailout_main_ui extends e_admin_ui
'mail_body_alt' , // If non-empty, use for alternate email text (generally the 'plain text' alternative)
'mail_overrides'
);
-
+
+
+ function afterDelete($del_data,$id)
+ {
+ $result = e107::getDb()->delete('mail_recipients', 'mail_detail_id = '.intval($id));
+ // $this->getModel()->addMessageDebug("Deleted ".$result." recipients from the deleted email #".$id);
+ // e107::getMessage()->addDebug("Deleted ".$result." recipients from the deleted email #".$id, 'default', true);
+
+ }
+
function init()
{
$action = varset($_GET['mode'], 'main');
$this->mailAdmin = new mailoutAdminClass($action);
-
+
+
+
+
if($_GET['action'] == 'preview')
{
echo $this->previewPage($_GET['id'], $_GET['user']);
@@ -470,8 +488,7 @@ class mailout_main_ui extends e_admin_ui
}
else
{
- $mailheader_e107id = USERID;
-
+
$add = ($pref['mailer']) ? " (".strtoupper($pref['mailer']).")" : ' (PHP)';
$sendto = trim($_POST['testaddress']);
@@ -674,7 +691,15 @@ class mailout_main_ui extends e_admin_ui
{
$mailData = e107::getDb()->retrieve('mail_content','*','mail_source_id='.intval($id)." LIMIT 1");
- $shortcodes = array('USERNAME'=>'John Example', 'DISPLAYNAME'=> 'John Example', 'USERID'=>'555', 'MAILREF'=>$_GET['id'], 'NEWSLETTER'=>SITEURL."newsletter/?id=example1234567", 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567");
+ $shortcodes = array(
+ 'USERNAME'=>'John Example',
+ 'DISPLAYNAME'=> 'John Example',
+ 'USERID'=>'555', 'MAILREF'=>$_GET['id'],
+ 'LOGINNAME' => 'johnE',
+ 'ACTIVATION_LINK' => SITEURL.'signup.php?testing-activation',
+ 'PASSWORD' => 'MyPass123',
+ 'NEWSLETTER'=>SITEURL."newsletter/?id=example1234567",
+ 'UNSUBSCRIBE'=>SITEURL."unsubscribe/?id=example1234567");
if(!empty($user))
{
@@ -1504,10 +1529,11 @@ class mailout_admin_form_ui extends e_admin_form_ui
if($mode == 'sent' || $mode == 'pending' || $mode == 'held')
{
$user = $this->getController()->getModel()->get('mail_recipient_id');
- $link = e_SELF."?searchquery=&filter_options=mail_detail_id__".$id."&mode=recipients&action=list";
+ $link = e_SELF."?searchquery=&filter_options=mail_detail_id__".$id."&mode=recipients&action=list&iframe=1";
$preview = e_SELF."?mode=main&action=preview&id=".$id.'&user='.$user;
- $text .= "".E_32_USER."";
- $text .= "".E_32_SEARCH."";
+
+ $text = "".E_32_USER."";
+ $text .= "".E_32_SEARCH."";
$att['readParms']['editClass'] = e_UC_NOBODY;
$text .= $this->renderValue('options',$value,$att,$id);
@@ -1674,7 +1700,7 @@ class mailout_recipients_form_ui extends e_admin_form_ui
$eid = $this->getController()->getListModel()->get('mail_detail_id');
$preview = e_SELF."?mode=main&action=preview&id=".$eid.'&user='.$user;
- $text .= "".E_32_SEARCH."";
+ $text = "".E_32_SEARCH."";
$att['readParms']['editClass'] = e_UC_NOBODY;
$text .= $this->renderValue('options',$value,$att,$id);
diff --git a/e107_admin/users.php b/e107_admin/users.php
index 01c09e9a8..e7940a4bd 100644
--- a/e107_admin/users.php
+++ b/e107_admin/users.php
@@ -52,6 +52,7 @@ class users_admin extends e_admin_dispatcher
'main/add' => array('caption'=> LAN_USER_QUICKADD, 'perm' => '4|U0|U1'),
'main/prefs' => array('caption'=> LAN_OPTIONS, 'perm' => '4|U2'),
'main/ranks' => array('caption'=> LAN_USER_RANKS, 'perm' => '4|U3'),
+ 'main/maintenance' => array('caption'=>'Maintenance', 'perms'=>'4')
// 'ranks/list' => array('caption'=> LAN_USER_RANKS, 'perm' => '4|U3')
);
@@ -294,6 +295,14 @@ class users_admin_ui extends e_admin_ui
$sql = e107::getDb();
$tp = e107::getParser();
+
+
+ if(!empty($_POST['resendToAll']))
+ {
+ $resetPasswords = !empty($_POST['resetPasswords']);
+ $this->resend_to_all($resetPasswords);
+ }
+
if($this->getAction() == 'edit')
{
@@ -1813,43 +1822,153 @@ class users_admin_ui extends e_admin_ui
$ns->tablerender(USFLAN_7, $text);
}
- // It might be used in the future - batch options
- function resend_to_all()
+
+
+
+ function maintenancePage()
{
- 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';
- }
+ $frm = e107::getForm();
+ $ns = e107::getRender();
+ $sql = e107::getDb();
+ $tp = e107::getParser();
- $sql3 = e107::getDb('sql3');
+ $age = strtotime('24 hours ago');
- $sql3->db_Select_gen($query);
- while ($row = $sql3->db_Fetch())
+ $count = $sql->count('user','(*)',"user_ban = 2 AND user_join < ".$age);
+ $caption = $tp->lanVars('Resend account activation email to [x] users who are older than 24 hours.',$count);
+
+ $text = $frm->open('userMaintenance','post');
+
+ $text .= "
+
";
+
+ $text .= $frm->close();
+
+ return $text;
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ // It might be used in the future - batch options
+ function resend_to_all($resetPasswords=false)
+ {
+ global $sql,$pref;
+ $tp = e107::getParser();
+ $sql = e107::getDb();
+ $sql2 = e107::getDb('toall');
+
+ $emailLogin = e107::getPref('allowEmailLogin');
+
+ e107::lan('core','signup');
+
+ $age = strtotime('24 hours ago');
+
+ $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 AND u.user_join < ".$age." ORDER BY u.user_id DESC";
+
+ $sql->gen($query);
+
+ $recipients = array();
+
+ $usr = e107::getUserSession();
+
+ while ($row = $sql->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)
+
+ if($resetPasswords === true)
{
- sleep($pause_time);
- $pause_count = 1;
+ $rawPassword = $usr->generateRandomString('********');
+ $sessKey = e_user_model::randomKey();
+
+ $updateQry = array(
+ 'user_sess' => $sessKey,
+ 'user_password' => $usr->HashPassword($rawPassword, $row['user_loginname']),
+ 'WHERE' => 'user_id = '.$row['user_id']." LIMIT 1"
+ );
+
+ if(!$sql2->update('user',$updateQry))
+ {
+ echo "error updating user's password";
+ print_a($updateQry);
+ break;
+ }
+
+ $row['user_sess'] = $sessKey;
+
}
- sleep(1);
- $pause_count++;
- $count++;
- }
- if ($count)
- {
- e107::getLog()->add('USET_12',str_replace('--COUNT--',$count,USRLAN_168),E_LOG_INFORMATIVE);
+ else
+ {
+ $rawPassword = '(*** hidden ***)';
+ }
+
+
+ $recipients[] = array(
+ 'mail_recipient_id' => $row['user_id'],
+ 'mail_recipient_name' => $row['user_name'], // Should this use realname?
+ 'mail_recipient_email' => $row['user_email'],
+ 'mail_target_info' => array(
+ 'USERID' => $row['user_id'],
+ 'LOGINNAME' => (intval($emailLogin) === 1) ? $row['user_email'] : $row['user_loginname'],
+ 'PASSWORD' => $rawPassword,
+ 'DISPLAYNAME' => $row['user_name'],
+ 'SUBJECT' => LAN_SIGNUP_98,
+ 'USERNAME' => $row['user_name'],
+ 'USERLASTVISIT' => $row['user_lastvisit'],
+ 'ACTIVATION_LINK' => SITEURL."signup.php?activate.".$row['user_id'].".".$row['user_sess'],
+ 'DATE_SHORT' => $tp->toDate(time(),'short'),
+ 'DATE_LONG' => $tp->toDate(time(),'long'),
+ )
+ );
+
+ // echo $row['user_id']." ".$row['user_sess']." ".$row['user_name']." ".$row['user_email']."
";
+
}
+
+ $siteadminemail = e107::getPref('siteadminemail');
+ $siteadmin = e107::getPref('siteadmin');
+
+ $mailer = e107::getBulkEmail();
+
+ // Create the mail body
+ $mailData = array(
+ 'mail_total_count' => count($recipients),
+ 'mail_content_status' => MAIL_STATUS_TEMP,
+ 'mail_create_app' => 'core',
+ 'mail_title' => 'RESEND ACTIVATION',
+ 'mail_subject' => LAN_SIGNUP_98,
+ 'mail_sender_email' => e107::getPref('replyto_email',$siteadminemail),
+ 'mail_sender_name' => e107::getPref('replyto_name',$siteadmin),
+ 'mail_notify_complete' => 0, // NEVER notify when this email sent!!!!!
+ 'mail_body' => 'null',
+ 'template' => 'signup',
+ 'mail_send_style' => 'signup'
+ );
+
+
+
+ $result = $mailer->sendEmails('signup', $mailData, $recipients);
+
}
// ---------------------------------------------------------------------
diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php
index f15802070..2e3473dbb 100755
--- a/e107_core/shortcodes/batch/signup_shortcodes.php
+++ b/e107_core/shortcodes/batch/signup_shortcodes.php
@@ -503,6 +503,40 @@ class signup_shortcodes extends e_shortcode
return " *";
}
+
+ // allow main admin to view signup page for design/testing.
+ function sc_signup_adminoptions()
+ {
+
+ if(getperms('0'))
+ {
+ $pref = e107::getPref();
+ $frm = e107::getForm();
+ $adminMsg = "".LAN_SIGNUP_112."
";
+
+ if(intval($pref['user_reg']) !== 1)
+ {
+ $adminMsg .= "User registration is currently disabled.
";
+ }
+
+ $adminMsg .= "
+ ";
+
+ $adminMsg .= $frm->checkbox('simulation',1, false, "Don't send email");
+
+ return "".$adminMsg."
";
+
+ }
+
+
+ return false;
+
+ }
+
}
?>
\ No newline at end of file
diff --git a/e107_core/templates/signup_template.php b/e107_core/templates/signup_template.php
index 6917ea200..d3b000080 100755
--- a/e107_core/templates/signup_template.php
+++ b/e107_core/templates/signup_template.php
@@ -209,7 +209,7 @@ if(!defined($COPPA_FAIL))
if(!defined($SIGNUP_BEGIN))
{
$SIGNUP_BEGIN = "
- {SIGNUP_FORM_OPEN} {SIGNUP_SIGNUP_TEXT}";
+ {SIGNUP_FORM_OPEN} {SIGNUP_ADMINOPTIONS} {SIGNUP_SIGNUP_TEXT}";
}
if(!defined($SIGNUP_BODY))
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index 3b4855bdd..accff6b8c 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -212,6 +212,7 @@ class e107
'userlogin' => '{e_HANDLER}login.php',
'validatorClass' => '{e_HANDLER}validator_class.php',
'xmlClass' => '{e_HANDLER}xml_class.php',
+ 'e107MailManager' => '{e_HANDLER}mail_manager_class.php'
);
/**
@@ -1206,6 +1207,17 @@ class e107
return self::getSingleton('e107Email', true);
}
+
+ /**
+ * Retrieve e107Email mail mailer object.
+ *
+ * @return e107MailManager
+ */
+ public static function getBulkEmail()
+ {
+ return self::getSingleton('e107MailManager', true);
+ }
+
/**
* Retrieve event singleton object
*
diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php
index af9201bed..8541732d5 100644
--- a/e107_handlers/mail_manager_class.php
+++ b/e107_handlers/mail_manager_class.php
@@ -884,7 +884,9 @@ class e107MailManager
//'wordwrap' - Set wordwrap value
//'split' - If true, sends an individual email to each recipient
'template' => 'mail_send_style', // required
- 'shortcodes' => 'mail_target_info' // required
+ 'shortcodes' => 'mail_target_info', // required
+ 'e107_header' => 'mail_recipient_id'
+
);
@@ -1725,9 +1727,9 @@ class e107MailManager
public function sendEmails($templateName, $emailData, $recipientData, $extra = FALSE)
{
$log = e107::getAdminLog();
- $log->addDebug(print_a($emailData, true),true);
- $log->addDebug(print_a($recipientData, true),true);
- $log->toFile('mail_manager','Mail Manager Log',true);
+ $log->addDebug(print_r($emailData, true),true);
+ $log->addDebug(print_r($recipientData, true),true);
+ $log->toFile('mail_manager','Mail Manager Log', true);
if (!is_array($emailData))
diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php
index 3d435cd85..7b83b9c10 100644
--- a/e107_handlers/user_model.php
+++ b/e107_handlers/user_model.php
@@ -1144,6 +1144,15 @@ class e_system_user extends e_user_model
$eml['e107_header'] = $userInfo['user_id'];
// $mailer->AddCustomHeader("X-e107-id: {$userInfo['user_id']}");
}
+
+
+ if(getperms('0') && E107_DEBUG_LEVEL > 0)
+ {
+ e107::getMessage()->addDebug("Email Debugger active. Simulation Only!");
+ e107::getMessage()->addDebug($mailer->preview($eml));
+ return true;
+ }
+
return $mailer->sendEmail($userInfo['user_email'], $userInfo['user_name'], $eml, false);
}
diff --git a/signup.php b/signup.php
index aa6ddd1a8..d4601c142 100644
--- a/signup.php
+++ b/signup.php
@@ -50,142 +50,6 @@ $text = '';
$extraErrors = array();
$error = FALSE;
-//-------------------------------
-// Resend Activation Email
-//-------------------------------
-/*
-if((e_QUERY == 'resend') && !USER && ($pref['user_reg_veri'] == 1))
-{
- require_once(HEADERF);
-
- $clean_email = $tp->toDB($_POST['resend_email']);
- if(!check_email($clean_email))
- {
- $clean_email = "xxx";
- }
-
- $new_email = $tp->toDB(varset($_POST['resend_newemail'], ''));
- if(!check_email($new_email ))
- {
- $new_email = FALSE;
- }
-
- if($_POST['submit_resend'])
- { // Action user's submitted information
- // 'resend_email' - user name or email address actually used to sign up
- // 'resend_newemail' - corrected email address
- // 'resend_password' - password (required if changing email address)
-
- if($_POST['resend_email'] && !$new_email && $clean_email && $sql->gen("SELECT * FROM #user WHERE user_ban=0 AND user_sess='' AND (`user_loginname`= '".$clean_email."' OR `user_name` = '".$clean_email."' OR `user_email` = '".$clean_email."' ) "))
- { // Account already activated
- $ns->tablerender(LAN_SIGNUP_40,LAN_SIGNUP_41."
");
- require_once(FOOTERF);
- exit();
- }
-
-
- // Start by looking up the user
- if(!$sql->select("user", "*", "(`user_loginname` = '".$clean_email."' OR `user_name` = '".$clean_email."' OR `user_email` = '".$clean_email."' ) AND `user_ban`=".USER_REGISTERED_NOT_VALIDATED." AND `user_sess` !='' LIMIT 1"))
- {
- message_handler("ALERT",LAN_SIGNUP_64.': '.$clean_email); // email (or other info) not valid.
- require_once(FOOTERF);
- exit();
- }
- $row = $sql -> fetch();
- // We should have a user record here
-
- if(trim($_POST['resend_password']) !="" && $new_email)
- { // Need to change the email address - check password to make sure
- if ($userMethods->CheckPassword($_POST['resend_password'], $row['user_loginname'], $row['user_password']) === TRUE)
- {
- if ($sql->select('user', 'user_id, user_email', "user_email='".$new_email."'"))
- { // Email address already used by someone
- message_handler("ALERT",LAN_SIGNUP_106); // Duplicate email
- require_once(FOOTERF);
- exit();
- }
- if($sql->update("user", "user_email='".$new_email."' WHERE user_id = '".$row['user_id']."' LIMIT 1 "))
- {
- $row['user_email'] = $new_email;
- }
- }
- else
- {
- message_handler("ALERT",LAN_SIGNUP_52); // Incorrect Password.
- require_once(FOOTERF);
- exit();
- }
- }
-
- // Now send the email - got some valid info
- $row['user_password'] = 'xxxxxxx'; // Don't know the real one
- $eml = render_email($row);
- $eml['e107_header'] = $row['user_id'];
- require_once(e_HANDLER.'mail.php');
- $mailer = new e107Email();
-
- if(!$mailer->sendEmail(USEREMAIL, USERNAME, $eml, FALSE))
-
- $do_log['signup_action'] = LAN_SIGNUP_63;
-
- if(!sendemail($row['user_email'], $eml['subject'], $eml['message'], $row['user_name'], "", "", $eml['attachments'], $eml['cc'], $eml['bcc'], $returnpath, $returnreceipt,$eml['inline-images']))
- {
- $ns->tablerender(LAN_ERROR,LAN_SIGNUP_42);
- $do_log['signup_result'] = LAN_SIGNUP_62;
- }
- else
- {
- $ns->tablerender(LAN_SIGNUP_43,LAN_SIGNUP_44." ".$row['user_email']." - ".LAN_SIGNUP_45."
");
- $do_log['signup_result'] = LAN_SIGNUP_61;
- }
- // Now log this (log will ignore if its disabled)
- $admin_log->user_audit(USER_AUDIT_PW_RES,$do_log,$row['user_id'],$row['user_name']);
- require_once(FOOTERF);
- exit;
- }
- elseif(!$_POST['submit_resend'])
- {
- // Display form to get info from user
- $text .= "";
-
- $ns->tablerender(LAN_SIGNUP_47, $text);
- require_once(FOOTERF);
- exit;
- }
- exit;
-}*/
-
// ------------------------------------------------------------------
if(!$_POST)
@@ -230,29 +94,6 @@ if ((USER || (intval($pref['user_reg']) !== 1) || (vartrue($pref['auth_method'],
}
-if(getperms('0')) // allow main admin to view signup page for design/testing.
-{
- //$mes = e107::getMessage();
- //$mes->debug("You are currently logged in.");
-
- $adminMsg = "".LAN_SIGNUP_112."
";
-
- if(intval($pref['user_reg']) !== 1)
- {
- $adminMsg .= "User registration is currently disabled.
";
- }
-
- $adminMsg .= "
- ";
-
- $SIGNUP_BEGIN = "".$adminMsg."
". $SIGNUP_BEGIN;
- unset($adminMsg);
-}
-
//----------------------------------------
// After clicking the activation link
@@ -660,7 +501,7 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1)
$noPasswordInput = e107::getPref('signup_option_password', 2); //0 = generate it.
if(empty($noPasswordInput) && !isset($_POST['password1']) && intval($pref['user_reg_veri'])===1)
{
- $_POST['password1'] = $userMethods->generateRandomString("#???????!????*#");
+ $_POST['password1'] = $userMethods->generateRandomString("#*******#");
$_POST['password2'] = $_POST['password1'];
}
@@ -908,8 +749,19 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1)
if(!vartrue($allData['data']['user_name'])) $allData['data']['user_name'] = $allData['data']['user_login'];
// prefered way to send user emails
- // if(!getperms('0')) // Alow logged in main-admin to test signup procedure.
- // {
+
+ if(getperms('0') && !empty($_POST['simulation']))
+ {
+ $simulation = true;
+ $check = true; //removes error message below.
+ }
+ else
+ {
+ $simulation = false;
+ }
+
+ if($simulation !== true) // Alow logged in main-admin to test signup procedure.
+ {
$sysuser = e107::getSystemUser(false, false);
$sysuser->setData($allData['data']);
$sysuser->setId($nid);
@@ -917,7 +769,7 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1)
'user_id' => $nid,
'user_password' => $savePassword, // for security reasons - password passed ONLY through options
));
- // }
+ }
if(getperms('0'))
{
@@ -925,7 +777,6 @@ if (isset($_POST['register']) && intval($pref['user_reg']) === 1)
e107::getMessage()->addDebug("Password: ".$savePassword."");
}
-
/*
$eml = render_email($allData['data']);
$eml['e107_header'] = $eml['userid'];