|
|
phpBB2 by Przemo
Support forów phpBB2 modified by Przemo
|
|
Urodziny, skrypt sprawdzaj?cy kto je dzi? obchodzi |
Autor |
Wiadomość |
saper82
Posty: 12
|
Wysłany: 31-08-2015, 19:40 Urodziny, skrypt sprawdzający kto je dziś obchodzi
|
|
|
Witam
Gdzie znajdę kod odpowiadający za sprawdzanie kto ma dziś urodziny na forum?
Chce napisać skrypt wysyłający maile z życzeniami urodzinowymi, a nie wiem jak dobrze
napisać skrypt co by wyszukiwał jubilatów, skopiował bym sobie go, resztę już mam. |
|
|
|
 |
Gadatliwa Kasia
|
|
|
|
thestig
Pomógł: 1 raz Posty: 1
|
Wysłany: 31-08-2015, 21:27
|
|
|
index.php
Kod: | if($board_config['cbirth'] && $userdata['cbirth'] && get_vars('mode') == 'congratulations') {
if(!$userdata['session_logged_in']) {
redirect(append_sid("login.$phpEx?redirect=index.$phpEx", true));
}
$bmsg = get_vars('bmsg', '', 'POST', false);
$send_mode = get_vars('send_mode', '', 'GET,POST', false);
$user = get_vars('user', '', 'GET,POST', true);
if(!$user || $user == $userdata['user_id']){
message_die(GENERAL_MESSAGE, $lang['congratulations_error']);
}
$user_row = get_userdata($user, false, 'username, user_lang, user_email, user_birthday');
if(empty($user_row)) message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
$current_year = create_date('Y', CR_TIME, $board_config['board_timezone'], true);
$current_month = create_date('m', CR_TIME, $board_config['board_timezone'], true);
$current_day = create_date('d', CR_TIME, $board_config['board_timezone'], true);
$user_age = $current_year - realdate('Y', $user_row['user_birthday']);
$birthday_month = realdate('m', $user_row['user_birthday']);
$birthday_day = realdate('d', $user_row['user_birthday']);
if($user_age <= $board_config['min_user_age'] || $user_age >= $board_config['max_user_age']){
message_die(GENERAL_MESSAGE, $lang['congratulations_error']);
}
if($birthday_month != $current_month || $birthday_day != $current_day){
message_die(GENERAL_MESSAGE, $lang['congratulations_no']);
}
if(!$send_mode) {
$fp_message = '<b>' . $lang['choose_congratulations_format'] . '</b><br /><br /><a href="' . append_sid("index.$phpEx?mode=congratulations&send_mode=sending&user=$user") . '">' . $lang['congratulations_format_standart'] . '</a><br /><span class="gensmall">' . $lang['congratulations_format_standart_e'] . '</span><br /><br /><a href="' . append_sid("index.$phpEx?mode=congratulations&send_mode=custom&user=$user") . '">' . $lang['congratulations_format_custom'] . '</a><br /><span class="gensmall">' . $lang['congratulations_format_custom_e'] . '</span>';
message_die(GENERAL_MESSAGE, $fp_message);
}
if($send_mode == 'custom') {
$fp_message = '<form action="' . append_sid("index.$phpEx") . '" method="post">' . $lang['gg_mes'] . '<br /><textarea name="bmsg" rows="9" cols="90" value="" class="post"></textarea><br /><input type="hidden" name="mode" value="congratulations" /><input type="hidden" name="send_mode" value="custom_sending" /><input type="hidden" name="user" value="' . $user . '" /><br /><input type="submit" name="send_custom_congratulations" class="mainoption" value="' . $lang['Submit'] . '" /></form>';
message_die(GENERAL_MESSAGE, $fp_message);
}
if($send_mode == 'sending' || $send_mode == 'custom_sending') {
if($send_mode == 'custom_sending' && empty($bmsg)) {
$fp_message = $lang['Empty_message'] . '<br /><br />' . sprintf($lang['Click_return_custom_sending'], '<a href="' . append_sid("index.$phpEx?mode=congratulations&send_mode=custom&user=$user") . '">', '</a>');
message_die(GENERAL_MESSAGE, $fp_message);
}
$sql = "INSERT INTO " . BIRTHDAY_TABLE . " (user_id, send_user_id, send_year)
VALUES ('" . $userdata['user_id'] . "', '$user', '$current_year')";
if(!$result = $db->sql_query($sql)) {
$fp_message = $lang['congratulations_send_no'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
message_die(GENERAL_MESSAGE, $fp_message);
} else {
$sender_email = $userdata['user_email'];
include($phpbb_root_path . 'includes/emailer.' . $phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$emailer->from($sender_email);
$emailer->replyto($sender_email);
$custom = ($send_mode == 'custom_sending') ? '_custom' : '';
$emailer->use_template('birthday_congratulations' . $custom, $user_row['user_lang']);
$emailer->email_address($user_row['user_email']);
$emailer->set_subject(sprintf($lang['Birthday_subject'], $user_age));
$emailer->assign_vars(array(
'USER_AGE' => $user_age,
'POSTER_USERNAME' => $userdata['username'],
'MESSAGE' => $bmsg,
'SITE_URL' => $server_protocol . $server_name . $server_port . $script_name,
'SITENAME' => $board_config['sitename'],
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '')
);
$emailer->send();
$emailer->reset();
$fp_message = $lang['congratulations_send'] . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
message_die(GENERAL_MESSAGE, $fp_message);
}
}
} |
|
|
|
|
 |
saper82
Posty: 12
|
Wysłany: 31-08-2015, 21:39
|
|
|
Dzięki, już widzę które elementu kodu są za to odpowiedzialne |
|
|
|
 |
|
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum
|
Dodaj temat do Ulubionych Wersja do druku
|
Kopiowanie wszelkich treści zawartych na forum, modyfikacji oraz instrukcji bez zgody administracji i autorów tematów/postów zabronione!
Powered by phpBB modified by Przemo © 2003 phpBB
| Strona wygenerowana w 0,27 sekundy. Zapytań do SQL: 13 | |
 |
|