Jump to content

PHP Newbie, modifying a simple function


kennyw1000

Recommended Posts

Hello everyone,

 

I am still learning PHP, and have been tasked with modifying a script. There is a function in the script that checks to see how many times a user has sent an email within a certain period of time. I need to add a little piece that allows one user (the admin) to send an unlimited amount of emails. I thought the best way to do this was to put in a piece that basically says: with this user, skip the email count. Below is the function:

 

////////////////////////////////////////////////

public function checkUserEmailCount($uid){

 

$q = "SELECT DATE_FORMAT('last_email', '%Y %c') AS last_email, email_count FROM user WHERE id=".$this->quote_smart($uid);

 

$result = $this->query($q);

$row = mysql_fetch_assoc($result);

 

$today = (int) date('Ym');

$last_email = (int) $row['last_email'];

 

if ($last_email < $today){

$q = "UPDATE user SET email_count=0 where id=".$this->quote_smart($uid);

$result = $this->query($q);

return true;

} else if($row['email_count'] < MAX_FLYERS){

return true;

} else {

return false;

}

}

///////////////////////////////////////////////////

 

I'm not sure how to do this, but I thought about adding something like this:

 

If user ID = 285 then skip email count

 

      } else if($last_email < $today){

$q = "UPDATE user SET email_count=0 where id=".$this->quote_smart($uid);

$result = $this->query($q);

return true;

} else if($row['email_count'] < MAX_FLYERS){

return true;

} else {

return false;

}

 

Any help on this would be appreciated.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/86504-php-newbie-modifying-a-simple-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.