Page 1 of 4

Email on Birthday 1.0.1b

PostPosted: Sun Sep 23, 2007 5:29 pm
by lefty
Modification name: Email on Birthday
Author: lefty74
Modification description: If Birthdays are enabled this will send an email to the members on their birthday, can be turned off via ACP
Modification version: 1.0.1b
Tested on phpBB version: 3.0.6

MOD Download: Email on Birthday

Demo Board: Demoboard
Demo Username: test
Demo Password: testtest

Credits: Many thanks to terrafrost as he was the one that created this feature for me on phpbb2 in the first place :)

Re: Email on Birthday 1.0.0

PostPosted: Sat Mar 15, 2008 1:59 pm
by lefty
validated and approved to phpbb.com MODDB

Re: Email on Birthday 1.0.0

PostPosted: Wed May 14, 2008 12:17 am
by Evil20071
Small problem I'm having with this. I had it installed before (First time went with NO problems, and works GREAT!!)

My forum crashed (FTP transfer goofed and files were totally lost) so I had to re-install it from scratch. Now, I can't find the mod ANYWHERE in the ACP. Not even in the mods control section under system. I've followed the same instructions both times, from the SQL Injection at the beginning, to all of the php edits, but still nothing. What should I do?

Re: Email on Birthday 1.0.0

PostPosted: Wed May 14, 2008 11:12 am
by lefty
at the end of the instructions it says to clear your cache and refresh your templates.

did you do that as well?

You should see in the ACP under Board features:

Code: Select all
Send Birthday email:                                             Yes No
Sends a birthday email on the users birthday     

Re: Email on Birthday 1.0.0

PostPosted: Wed May 14, 2008 4:36 pm
by Evil20071
That wasn't showing. I went back in and re-did the SQL insert and it worked. Apparently my hosts database manager didn't get it done the first time.

Re: Email on Birthday 1.0.0

PostPosted: Sun Nov 30, 2008 12:31 am
by redspider
Hi Lefty!
I´ve just installed this mod on my forum, but I think it is not working. I´m in a hurry becaus I´m going to star the forum tomorrow, so I hope you can help me.

After installation I can see the option in the ACP and I´ve activated it, but nobody receives the mail.

I have a doubt in the installation process.In the instructions you say:

Comments
around line 94
Find
Tip: This may be a partial find and not the whole line.

Code: Select All
}
$db->sql_freeresult($result);


I´m not sure if I put the code in the right place. I put it after this lines replacing the line:
}
$db->sql_freeresult($result);

as you say.

if ($age = (int) substr($row['user_birthday'], -4))
{
$birthday_list .= ' (' . ($now['year'] - $age) . ')';
}



Is it correct?

Any idea about this problem?.

I´m waiting 24 hours for the mails, but nothing.

Many thanks and regards.

Re: Email on Birthday 1.0.0

PostPosted: Sun Nov 30, 2008 1:59 am
by lefty
hi, this is what the part in my index.php looks like

Code: Select all
// Generate birthday list if required ...
$birthday_list = '';
$bd_list_ary = array();
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
    $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
    $sql = 'SELECT user_id, username, user_colour, user_birthday, user_email, user_lang,user_notify_type, user_jabber 
        FROM '
 . USERS_TABLE . "
        WHERE user_birthday LIKE '"
 . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
            AND user_type IN ("
 . USER_NORMAL . ', ' . USER_FOUNDER . ')';
    $result = $db->sql_query($sql);

    while ($row = $db->sql_fetchrow($result))
    {
        $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

        if ($age = (int) substr($row['user_birthday'], -4))
        {
            $birthday_list .= ' (' . ($now['year'] - $age) . ')';
        }
        if (trim($row['user_email']) && $config['birthday_emails'])
        {
            $bd_list_ary[] = array(
                'method'    => $row['user_notify_type'],
                'email'        => $row['user_email'],
                'jabber'    => $row['user_jabber'],
                'name'        => $row['username'],
                'lang'        => $row['user_lang']
            );
        }
    }
    $db->sql_freeresult($result);

    $nowvar = getdate(time() + ($config['board_timezone'] + $config['board_dst'])*3600 - date('Z'));

    if ( sizeof($bd_list_ary) && $config['birthday_run'] < mktime(0, 0, 0, $nowvar['mon'], $nowvar['mday'], $nowvar['year']) && $config['birthday_emails'] )
   {
   set_config('birthday_run', mktime(0, 0, 0, $nowvar['mon'], $nowvar['mday'], $nowvar['year']));

   include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
    $messenger = new messenger();

    foreach ($bd_list_ary as $pos => $addr)
    {
        $messenger->template('birthday_email', $addr['lang']);

        $messenger->to($addr['email'], $addr['name']);
        $messenger->im($addr['jabber'], $addr['name']);

        $messenger->assign_vars(array(
            'USERNAME'        => htmlspecialchars_decode($addr['name'])
        ));

        $messenger->send($addr['method']);
    }
    unset($bd_list_ary);

    $messenger->save_queue();
    unset($messenger);
    }
    $cache->destroy('config');
}
 


btw, emails are only sent once a day, if you have chosen ur birthday after the emails were sent, it won't send it again.

Re: Email on Birthday 1.0.0

PostPosted: Sun Nov 30, 2008 1:24 pm
by redspider
Hey Lefty! Many thanks.The problem was in one line.

It´s working fine now.

Regards.

Re: Email on Birthday 1.0.0

PostPosted: Sun Nov 30, 2008 1:56 pm
by lefty
excellent :cheer:

Re: Email on Birthday 1.0.0

PostPosted: Mon Jun 01, 2009 1:24 am
by bigbrotherbiggs
Sorry Lefty I am new to php let alone phpBB this is the second mod I have installed and I am stumped right at the beginning and at the end. In that i have no idea how to do the SQL bit nor how to purge the cache and refresh templates. Could you teach me how to do this? Thanks

Re: Email on Birthday 1.0.0

PostPosted: Mon Jun 01, 2009 9:40 am
by lefty
hi bbb,

first, check what your prefix is. in your config.php file you will find what prefix you are using:
like here:
Code: Select all
<?php
// phpBB 3.0.x auto-generated configuration file
// Do not change anything in this file!
...
$table_prefix = 'phpbb_';
....
?>


if it is anything other than phpbb_ you will need to amend the sql script and change phpbb_ to whatever your prefix would be, e.g. if your prefix were phpbb3 the sql would need to be changed from
Code: Select all
INSERT INTO phpbb_config (config_name, config_value) VALUES ('birthday_emails', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('birthday_run', '');

TO
Code: Select all
INSERT INTO phpbb3config (config_name, config_value) VALUES ('birthday_emails', '0');
INSERT INTO phpbb3config (config_name, config_value) VALUES ('birthday_run', '');


once that is sorted, what you basically do is open you phpMyAdmin, then go to the database of your phpbb3 board.
next, there should be a tab called SQL. Click on that file, paste the SQL script into the input box and run the script by clicking run/go/ok (Not sure what it is called atm).
and that should be it.

more information on how to install mods (incl. sql's) can be found here.

Re: Email on Birthday 1.0.0

PostPosted: Tue Dec 01, 2009 10:27 pm
by AirWarrior
Maby a dumb question.
Is this working on 3.0.6 too or needed to be update firtst?

Re: Email on Birthday 1.0.0

PostPosted: Wed Dec 02, 2009 12:17 am
by lefty
this one does not work on 3.0.6.

i am working on the changes.

Re: Email on Birthday 1.0.1

PostPosted: Wed Dec 02, 2009 11:52 pm
by lefty
2009-12-02 - Version 1.0.1
  • updated to work with 3.0.6
  • added logging in ACP for emails sent

Re: Email on Birthday 1.0.1

PostPosted: Thu Dec 03, 2009 5:02 pm
by kids
lefty wrote:
2009-12-02 - Version 1.0.1
  • updated to work with 3.0.6
  • added logging in ACP for emails sent


Thank you :tigs:
This is a very good mod, I have installed, but have a small problem,
Can only be sent to the first user?

Re: Email on Birthday 1.0.1

PostPosted: Thu Dec 03, 2009 5:15 pm
by AirWarrior
thx, keep it going :cheer:

Re: Email on Birthday 1.0.1

PostPosted: Thu Dec 03, 2009 7:08 pm
by lefty
kids wrote:
lefty wrote:
2009-12-02 - Version 1.0.1
  • updated to work with 3.0.6
  • added logging in ACP for emails sent


Thank you :tigs:
This is a very good mod, I have installed, but have a small problem,
Can only be sent to the first user?

when i tested it, it worked for more than one. please note that the script is only run once a day, i.e. if a user registers whose birthday it is that day he won't get an email until the next birthday.

Re: Email on Birthday 1.0.1

PostPosted: Thu Dec 03, 2009 9:27 pm
by lefty
argh, i forgot to look at thhis: http://www.phpbb.com/community/viewtopi ... 5#p5555715

update will follow soonest!

Re: Email on Birthday 1.0.1

PostPosted: Fri Dec 04, 2009 4:21 am
by kids
wow, to understand
Yesterday, I was tried a user, and then try again, so an error :happysmerk:

But, :shifty:
This mod must have a user login,
In order to send email
There are ways to give this mod automatically sent whitdout login.

Thank you for your information

Re: Email on Birthday 1.0.1

PostPosted: Fri Dec 04, 2009 8:59 pm
by lefty
you dont need to be logged in to run the script. hopefully, i will get round to get the new version out today, cant guarantee tho.

Re: Email on Birthday 1.0.1a

PostPosted: Sat Dec 05, 2009 12:28 am
by lefty
Code: Select all
2009-12-03 - Version 1.0.1a
forgot to look at this http://www.phpbb.com/community/viewtopic.php?p=5555715#p5555715

Re: Email on Birthday 1.0.1b

PostPosted: Sun Dec 27, 2009 12:03 pm
by lefty
updated to 1.0.1b.
bugfix - it was possible that the script was called (again) if a user was on different time settings than the board settings

Re: Email on Birthday 1.0.1b

PostPosted: Sat Feb 06, 2010 4:55 pm
by AirWarrior
When i follow the steps in install.xml it go's wrong in the last step.
Open: language/en/acp/common.php
Find:
Code: Select all
?>


Add before
Code: Select all
// Log Entry email on birthday mod from lefty74
$lang = array_merge($lang, array(
   'LOG_BIRTHDAY_EMAIL_SENT'      => '<strong>Birthday email sent to</strong><br />» %s',
));


Then when i save the file i get white pages.

Re: Email on Birthday 1.0.1b

PostPosted: Sat Feb 13, 2010 5:01 pm
by AirWarrior
Anybody :rant2:

Re: Email on Birthday 1.0.1b

PostPosted: Fri Feb 19, 2010 4:40 pm
by lefty
AirWarrior wrote:When i follow the steps in install.xml it go's wrong in the last step.
Open: language/en/acp/common.php
Find:
Code: Select all
?>


Add before
Code: Select all
// Log Entry email on birthday mod from lefty74
$lang = array_merge($lang, array(
   'LOG_BIRTHDAY_EMAIL_SENT'      => '<strong>Birthday email sent to</strong><br />» %s',
));


Then when i save the file i get white pages.

white pages normally show up when you have suppressed errors. do you have an error log on your server that displays the error?

Can you confirm that you saved the edited file in UTF8 without BOM format?
AirWarrior wrote:Anybody :rant2:
was offline for two weeks until now so this is the first time i coudl reply :fluester: