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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.