Solved

Increase admin invites in SocialEngine networking system

Posted on 2009-07-05
7
1,161 Views
Last Modified: 2013-12-13
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

0
Comment
Question by:lherrou
  • 4
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
kevin_u earned 300 total points
ID: 24780854
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
 
LVL 38

Author Comment

by:lherrou
ID: 24780891
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
 
LVL 38

Author Comment

by:lherrou
ID: 24781036
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 24781114
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
 
LVL 38

Author Comment

by:lherrou
ID: 24781472
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
 
LVL 38

Author Comment

by:lherrou
ID: 24781592
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
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 24784510
Hmm... Maybe a cache or cookie-related issue?  Anyway, I am glad you've got it working.  Best regards, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now