コード例 #1
0
function cash_pm(&$targetdata, $privmsg_subject, &$message)
{
    global $db, $cache, $config, $user, $lang, $bbcode, $html_entities_match, $html_entities_replace;
    //
    // It looks like we're sending a PM!
    // NOTE: most of the following code is shamelessly "reproduced" from privmsg.php
    //
    include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
    include_once IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT;
    $attach_sig = $user->data['user_attachsig'];
    $bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? true : false;
    $bbcode->allow_bbcode = true;
    $bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? true : false;
    $html_status = $bbcode->allow_html;
    $bbcode_status = $bbcode->allow_bbcode;
    $smilies_status = $bbcode->allow_smilies;
    $acro_auto_status = false;
    include_once IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT;
    $privmsg_message = prepare_message($message, $html_status, $bbcode_status, $smilies_status);
    $privmsg_sender = $user->data['user_id'];
    $privmsg_recipient = $targetdata['user_id'];
    $privmsg = new class_pm();
    if ($user->data['user_level'] != ADMIN && $privmsg->is_flood()) {
        message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
    }
    $privmsg->delete_older_message('PM_INBOX', $privmsg_recipient);
    $privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message, $attach_sig, $html_status, $bbcode_status, $smilies_status, $acro_auto_status);
    if ($targetdata['user_notify_pm'] && !empty($targetdata['user_email']) && $targetdata['user_active']) {
        //HTML Message
        $clean_tags = $config['html_email'] ? false : true;
        $bbcode->allow_bbcode = $config['allow_bbcode'] ? $config['allow_bbcode'] : false;
        $bbcode->allow_html = $config['allow_html'] ? $config['allow_html'] : false;
        $bbcode->allow_smilies = $config['allow_smilies'] ? $config['allow_smilies'] : false;
        $message = $bbcode->parse($privmsg_message, '', false, $clean_tags);
        $message = stripslashes($message);
        //HTML Message
        $privmsg->notification($privmsg_sender, $privmsg_recipient, $targetdata['user_email'], $lang['Notification_subject'], $message, false, $privmsg_subject, $targetdata['username'], $targetdata['user_lang'], false);
    }
    unset($privmsg);
}
コード例 #2
0
/**
* Sends a birthday PM
*/
function birthday_pm_send()
{
    global $db, $cache, $config, $user, $lang;
    // Birthday - BEGIN
    // Check if the user has or have had birthday, also see if greetings are enabled
    if ($user->data['user_birthday'] != 999999 && !empty($config['birthday_greeting']) && create_date('Ymd', time(), $config['board_timezone']) >= $user->data['user_next_birthday_greeting'] . realdate('md', $user->data['user_birthday'])) {
        // If a user had a birthday more than one week before we will not send the PM...
        if (time() - gmmktime(0, 0, 0, $user->data['user_birthday_m'], $user->data['user_birthday_d'], $user->data['user_next_birthday_greeting']) <= 86400 * 8) {
            // Birthday PM - BEGIN
            $pm_subject = $lang['Greeting_Messaging'];
            $pm_date = gmdate('U');
            $year = create_date('Y', time(), $config['board_timezone']);
            $date_today = create_date('Ymd', time(), $config['board_timezone']);
            $user_birthday = realdate('md', $user->data['user_birthday']);
            $user_birthday2 = ($year . $user_birthday < $date_today ? $year + 1 : $year) . $user_birthday;
            $user_age = create_date('Y', time(), $config['board_timezone']) - realdate('Y', $user->data['user_birthday']);
            if (create_date('md', time(), $config['board_timezone']) < realdate('md', $user->data['user_birthday'])) {
                $user_age--;
            }
            $pm_text = $user_birthday2 == $date_today ? sprintf($lang['Birthday_greeting_today'], $user_age) : sprintf($lang['Birthday_greeting_prev'], $user_age, realdate(str_replace('Y', '', $lang['DATE_FORMAT_BIRTHDAY']), $user->data['user_birthday']) . (!empty($user->data['user_next_birthday_greeting']) ? $user->data['user_next_birthday_greeting'] : ''));
            $founder_id = defined('FOUNDER_ID') ? FOUNDER_ID : get_founder_id();
            include_once IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT;
            $privmsg_subject = sprintf($pm_subject, $config['sitename']);
            $privmsg_message = sprintf($pm_text, $config['sitename'], $config['sitename']);
            $privmsg_sender = $founder_id;
            $privmsg_recipient = $user->data['user_id'];
            $privmsg = new class_pm();
            $privmsg->delete_older_message('PM_INBOX', $privmsg_recipient);
            $privmsg->send($privmsg_sender, $privmsg_recipient, $privmsg_subject, $privmsg_message);
            unset($privmsg);
            // Birthday PM - END
        }
        // Update next greetings year
        $sql = "UPDATE " . USERS_TABLE . "\n\t\t\tSET user_next_birthday_greeting = " . (create_date('Y', time(), $config['board_timezone']) + 1) . "\n\t\t\tWHERE user_id = " . $user->data['user_id'];
        $status = $db->sql_query($sql);
    }
    //Sorry user shall not have a greeting this year
    // Birthday - END
}