Increase admin invites in SocialEngine networking system

I'm running an installation of the Social Engine social networking system (http://www.socialengine.net).  

I am running it as an invite only system, so no individual users can issue invites, only an Admin can. However, the admin invite function is capped at 10, and I have about 800 to send. I'd like to be able to send them in blocks of 100, but I cannot seem to find a way around this.

There is a section in admin_invite.php that breaks the emails into an array:
array_slice(explode(",", $_POST['invite_emails']), 0, 10));

(see full code of admin_invite.php below)

I tried increasing the 10 to 100, but for some reason that doesn't seem to change anything. The sending loop seems to rely on a count of the array - so, it seemed that increasing the array_slice would increase the overall array, but it does not seem to effect it. If I put 11 emails in the box, the system only sends 10 - so that doesn't appear to be the limiting factor either, anyone have any ideas or have a work-around for this?

LHerrou

p.s. I am NOT a php programmer... in case you hadn't figured that out yet.
<?php
 
/* $Id: admin_invite.php 8 2009-01-11 06:02:53Z john $ */
 
$page = "admin_invite";
include "admin_header.php";
 
if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "main"; }
 
 
// SET RESULT VARIABLE
$result = 0;
 
 
// SAVE CHANGES
if($task == "doinvite") {
  $invite_emails = implode(",", array_slice(explode(",", $_POST['invite_emails']), 0, 10));
 
  // NO INVITE CODE REQUIRED
  if($setting[setting_signup_invite] == 0) {
    send_systememail('invite', $invite_emails, Array($setting[setting_email_fromname], $setting[setting_email_fromemail], "", "<a href=\"".$url->url_base."signup.php\">".$url->url_base."signup.php</a>"), TRUE);
 
  // INVITE CODE NECESSARY
  } else {
 
    // LOOP OVER EMAILS
    $invite_emails_array = explode(",", $invite_emails);
    for($e=0;$e<count($invite_emails_array);$e++) {
      $email = trim($invite_emails_array[$e]);
      if($email != "") {
 
        // CREATE CODE, INSERT INTO DATABASE, AND SEND EMAIL
	$invite_code = randomcode();
	$database->database_query("INSERT INTO se_invites (invite_user_id, invite_date, invite_email, invite_code) VALUES ('0', '".time()."', '$email', '$invite_code')");
        send_systememail('invitecode', $email, Array($setting[setting_email_fromname], $setting[setting_email_fromemail], "", $invite_code, "<a href=\"".$url->url_base."signup.php?signup_email=$email&signup_invite=$invite_code\">".$url->url_base."signup.php?signup_email=$email&signup_invite=$invite_code</a>"));
      }
    }
  }
  
  $result = 1;
}
 
 
 
// ASSIGN VARIABLES AND SHOW BANNING PAGE
$smarty->assign('result', $result);
include "admin_footer.php";
?>

Open in new window

LVL 38
lherrouAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kevin_uCommented:
The change you made will remove the 10 limit and replace it with a 100 limit.

There are two possibilites left:

1) that section of code is not actually doing the invites, but some other section.

2) the updated php script is not actually being executed.

To find out if it is acutally being executed, put a syntax error in there somehwere, to verify that the script that you are changing is actually being executed.  If you get a blank page, when submitting your invites (or other activities that involve that script), then you know that you have the right script (eliminates item 2 above).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lherrouAuthor Commented:
Ok, I changed explode() to explode1() in the script and got the following:
Fatal error: Call to undefined function explode1() in /home/content/d/e/l/delnetwork/html/admin/admin_invite.php on line 17
0
lherrouAuthor Commented:
And, I tried adding the word "test" into the section that sends the text of the invite emails, and when I received the resulting invite, it contained the word "test" where I had inserted it.

Any other thoughts?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Ray PaseurCommented:
This may be a data dependent issue.  Can you find a PHP programmer nearby?

You might want to add some code to check if this is TRUE at line 20:

 if($setting[setting_signup_invite] == 0)

That line will send you through a different algorithm and it is possible that the function named, "send_systememail" makes an assumption about only ten emails at a time.

You can use var_dump($setting) and var_dump($_POST) to give you some visibility into the contents of those arrays.
0
lherrouAuthor Commented:
Well, I have attached the code of functions_email.php, which includes send_systememail. I don't see anything there that looks like it could be throttling the emails sent.
<?php
 
/* $Id: functions_email.php 44 2009-01-30 03:45:23Z john $ */
 
 
//  THIS FILE CONTAINS EMAIL-RELATED FUNCTIONS
//  FUNCTIONS IN THIS CLASS:
//    send_generic()
//    send_systememail()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
// THIS FUNCTION SENDS A CUSTOM EMAIL
// INPUT: $recipient REPRESENTING THE RECIPIENT'S EMAIL
//	  $sender REPRESENTING THE SENDER'S NAME/EMAIL
//	  $subject REPRESENTING THE EMAIL SUBJECT
//	  $message REPRESENTING THE EMAIL MESSAGE
//	  $search REPRESENTING THE ARRAY OF STRINGS TO SEARCH FOR
//	  $replace REPRESENTING THE ARRAY OF STRINGS TO REPLACE $search WITH
//	  $bcc (OPTIONAL) REPRESENTING WHETHER TO BCC ALL RECIPIENTS
// OUTPUT: 
 
function send_generic($recipient, $sender, $subject, $message, $search, $replace, $bcc = FALSE)
{
	// DECODE SUBJECT AND EMAIL FOR SENDING
	$subject = htmlspecialchars_decode($subject, ENT_QUOTES);
	$message = htmlspecialchars_decode($message, ENT_QUOTES);
 
	// REPLACE VARIABLES IN SUBJECT AND MESSAGE
	$subject = str_replace($search, $replace, $subject);
	$message = str_replace($search, $replace, $message);
 
	// ENCODE SUBJECT FOR UTF8
	$subject="=?UTF-8?B?".base64_encode($subject)."?=";
 
	// REPLACE CARRIAGE RETURNS WITH BREAKS
	$message = str_replace("\n", "<br>", $message);
 
	// SET HEADERS
	$headers = "MIME-Version: 1.0"."\n";
	$headers .= "Content-type: text/html; charset=utf-8"."\n";
	$headers .= "Content-Transfer-Encoding: 8bit"."\n";
	$headers .= "From: $sender"."\n";
	$headers .= "Return-Path: $sender"."\n";
	$headers .= "Reply-To: $sender\n";
 
	// IF BCC, SET TO AND BCC
	if($bcc) {
	  $headers .= "Bcc: $recipient\n";
	  $recipient = "noreply@domain.com";
	}
 
	// SEND MAIL
	mail($recipient, $subject, $message, $headers);
 
	return true;
}
 
// END send_generic() FUNCTION
 
 
 
 
 
 
 
 
 
 
 
 
 
// THIS FUNCTION SENDS A CUSTOM EMAIL
// INPUT: $systememail REPRESENTING THE SYSTEM EMAIL TO SEND
//	  $recipient_email REPRESENTING THE EMAIL(S) OF THE RECIPIENT
//	  $replace (OPTIONAL) REPRESENTING THE VARIABLES TO BE INSERTED
//	  $bcc (OPTIONAL) REPRESENTING WHETHER TO BCC ALL RECIPIENTS
// OUTPUT: 
 
function send_systememail($systememail, $recipient_email, $replace = Array(), $bcc = FALSE)
{
	global $setting, $database;
 
	// RETRIEVE EMAIL INFO
	$email = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_systememails WHERE systememail_name='{$systememail}' LIMIT 1"));
 
	SE_Language::_preload_multi($email['systememail_subject'], $email['systememail_body']);
	SE_Language::load();
 
	// GET/DECODE SUBJECT AND MESSAGE 
	$subject = htmlspecialchars_decode(SE_Language::_get($email['systememail_subject']), ENT_QUOTES);
	$message = htmlspecialchars_decode(SE_Language::_get($email['systememail_body']), ENT_QUOTES);
 
	// REPLACE VARIABLES IN SUBJECT AND MESSAGE
	$subject = vsprintf($subject, $replace);
	$message = vsprintf($message, $replace);
 
	// ENCODE SUBJECT FOR UTF8
	$subject="=?UTF-8?B?".base64_encode($subject)."?=";
 
	// REPLACE CARRIAGE RETURNS WITH BREAKS
	$message = str_replace("\n", "<br>", $message);
 
	// SET HEADERS
	$sender = "{$setting['setting_email_fromname']} <{$setting['setting_email_fromemail']}>";
	$headers = "MIME-Version: 1.0"."\n";
	$headers .= "Content-type: text/html; charset=utf-8"."\n";
	$headers .= "Content-Transfer-Encoding: 8bit"."\n";
	$headers .= "From: $sender"."\n";
	$headers .= "Return-Path: $sender"."\n";
	$headers .= "Reply-To: $sender\n";
 
	// IF BCC, SET TO AND BCC
	if( $bcc )
  {
	  $headers .= "Bcc: $recipient_email\n";
	  $recipient_email = "noreply@domain.com";
	}
 
	// SEND MAIL
	mail($recipient_email, $subject, $message, $headers);
 
	return true;
}
 
// END send_systememail() FUNCTION
 
 
?>

Open in new window

0
lherrouAuthor Commented:
OK. Oddly enough, it seems to be working now - I tested it extensively earlier in the day and also a week or more ago, with no success, but now it seems to be doing larger blocks than 10.
0
Ray PaseurCommented:
Hmm... Maybe a cache or cookie-related issue?  Anyway, I am glad you've got it working.  Best regards, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.