Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Increase admin invites in SocialEngine networking system

Posted on 2009-07-05
7
Medium Priority
?
1,193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
kevin_u earned 1200 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 800 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 111

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

610 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