Beispiel #1
0
 protected static function decode_php($text)
 {
     global $bb_codes;
     $text = str_replace("\r\n", "\n", substr($text, 5, -6));
     # Windows
     $text = str_replace("\r", "\n", $text);
     # Mac
     $text = str_replace("\t", '/*t*/', $text);
     # Temporary tab fix
     $text = htmlunprepare($text, true);
     $added = FALSE;
     if (preg_match('/^<\\?.*/', $text) <= 0) {
         $text = "<?php\n{$text}";
         $added = TRUE;
     }
     $text = highlight_string($text, TRUE);
     if ($added == TRUE) {
         $text = preg_replace('/^(.*)\\n.*php<br \\/><\\/span>/i', "\\1\n", $text, 1);
         $text = preg_replace('/^(.*)\\n(.*)>.*php<br \\/>/i', "\\1\n\\2>", $text, 1);
     }
     $text = str_replace('[', '&#91;', $text);
     $text = str_replace("\n", '', $text);
     $text = str_replace('&nbsp;', ' ', $text);
     $text = str_replace('/*t*/', "\t", $text);
     $text = preg_replace('#<span style="color: \\#[A-F0-9]{6}">([\\t]+)</span>#', '\\1', $text);
     return $bb_codes['php_start'] . "<pre>{$text}</pre>" . $bb_codes['php_end'];
 }
Beispiel #2
0
    }
    $message = htmlprepare($message);
} else {
    //
    // User default entry point
    //
    if ($mode == 'newtopic') {
        $user_sig = $userdata['user_sig'] != '' ? $userdata['user_sig'] : '';
        $username = is_user() ? $userdata['username'] : '';
        $poll_title = $poll_length = $subject = $message = '';
    } else {
        if ($mode == 'reply') {
            $user_sig = $userdata['user_sig'] != '' ? $userdata['user_sig'] : '';
            $username = is_user() ? $userdata['username'] : '';
            // begin Automatic Subject on Reply mod
            $subject = htmlunprepare($post_info['topic_title']);
            if (!preg_match('/^Re:/', $subject) && strlen($subject) > 0) {
                $subject = substr('Re: ' . $subject, 0, 60);
            }
            $subject = htmlprepare($subject);
            // end Automatic Subject on Reply mod
            $message = '';
        } else {
            if ($mode == 'quote' || $mode == 'editpost') {
                $subject = $post_data['first_post'] ? $post_info['topic_title'] : $post_info['post_subject'];
                $message = $post_info['post_text'];
                if ($mode == 'editpost') {
                    $attach_sig = $post_info['enable_sig'] && $post_info['user_sig'] != '' ? TRUE : 0;
                    $user_sig = $post_info['user_sig'];
                    $html_on = $post_info['enable_html'] ? true : false;
                    $bbcode_on = $post_info['enable_bbcode'] ? true : false;
Beispiel #3
0
 for ($i = 0; $i < count($attachments); $i++) {
     $row_color = !($i % 2) ? $bgcolor2 : $bgcolor1;
     $row_class = !($i % 2) ? 'row1' : 'row2';
     //
     // Is the Attachment assigned to more than one post ?
     // If it's not assigned to any post, it's an private message thingy. ;)
     //
     $post_titles = array();
     $result = $db->sql_query("SELECT * FROM " . ATTACHMENTS_TABLE . " WHERE attach_id = " . $attachments[$i]['attach_id']);
     $ids = $db->sql_fetchrowset($result);
     $num_ids = $db->sql_numrows($result);
     for ($j = 0; $j < $num_ids; $j++) {
         if ($ids[$j]['post_id'] != 0) {
             $result = $db->sql_query("SELECT t.topic_title FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p\n\t\t\t\tWHERE p.post_id = " . $ids[$j]['post_id'] . " AND p.topic_id = t.topic_id\n\t\t\t\tGROUP BY t.topic_id, t.topic_title");
             $row = $db->sql_fetchrow($result);
             $post_title = htmlunprepare($row['topic_title']);
             if (strlen($post_title) > 32) {
                 $post_title = substr($post_title, 0, 30) . '...';
             }
             $view_topic = URL::index('&amp;file=viewtopic&amp;' . POST_POST_URL . '=' . $ids[$j]['post_id']) . '#' . $ids[$j]['post_id'];
             $post_titles[] = '<a href="' . $view_topic . '" class="gen" target="_blank">' . htmlprepare($post_title) . '</a>';
         } else {
             $desc = '';
             $result = $db->sql_query("SELECT privmsgs_type, privmsgs_to_userid, privmsgs_from_userid\n\t\t\t\tFROM " . PRIVMSGS_TABLE . "\n\t\t\t\tWHERE privmsgs_id = " . $ids[$j]['privmsgs_id']);
             if ($db->sql_numrows($result) != 0) {
                 $row = $db->sql_fetchrow($result);
                 $privmsgs_type = $row['privmsgs_type'];
                 if ($privmsgs_type == PRIVMSGS_READ_MAIL || $privmsgs_type == PRIVMSGS_NEW_MAIL || $privmsgs_type == PRIVMSGS_UNREAD_MAIL) {
                     if ($row['privmsgs_to_userid'] == $profiledata['user_id']) {
                         $desc = $lang['Private_Message'] . ' (' . $lang['Inbox'] . ')';
                     }
Beispiel #4
0
function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
{
    global $board_config, $lang, $db, $phpbb_root_path, $MAIN_CFG;
    global $userdata;
    $current_time = time();
    if ($mode == 'delete') {
        $delete_sql = !$post_data['first_post'] && !$post_data['last_post'] ? " AND user_id = " . $userdata['user_id'] : '';
        $db->sql_query("DELETE FROM " . TOPICS_WATCH_TABLE . " WHERE topic_id = {$topic_id}" . $delete_sql);
    } else {
        if ($mode == 'reply') {
            $result = $db->sql_query('SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_level<1');
            $user_id_sql = '';
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_sql .= ', ' . $row['user_id'];
            }
            $sql = "SELECT u.user_id, u.user_email, u.user_lang\n\t\t\t\tFROM " . TOPICS_WATCH_TABLE . " tw, " . USERS_TABLE . " u\n\t\t\t\tWHERE tw.topic_id = {$topic_id}\n\t\t\t\t\tAND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")\n\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = tw.user_id";
            $result = $db->sql_query($sql);
            $update_watched_sql = '';
            $bcc_list_ary = array();
            if ($row = $db->sql_fetchrow($result)) {
                // Sixty second limit
                set_time_limit(0);
                do {
                    if ($row['user_email'] != '') {
                        $bcc_list_ary[$row['user_lang']][] = $row['user_email'];
                    }
                    $update_watched_sql .= $update_watched_sql != '' ? ', ' . $row['user_id'] : $row['user_id'];
                } while ($row = $db->sql_fetchrow($result));
                if (sizeof($bcc_list_ary)) {
                    include "includes/phpBB/emailer.php";
                    $emailer = new emailer();
                    $orig_word = array();
                    $replacement_word = array();
                    obtain_word_list($orig_word, $replacement_word);
                    $emailer->from($board_config['board_email']);
                    $emailer->replyto($board_config['board_email']);
                    $topic_title = count($orig_word) ? preg_replace($orig_word, $replacement_word, htmlunprepare($topic_title)) : htmlunprepare($topic_title);
                    reset($bcc_list_ary);
                    while (list($user_lang, $bcc_list) = each($bcc_list_ary)) {
                        $emailer->use_template('topic_notify', $user_lang);
                        for ($i = 0; $i < count($bcc_list); $i++) {
                            $emailer->bcc($bcc_list[$i]);
                        }
                        // The Topic_reply_notification lang string below will be used
                        // if for some reason the mail template subject cannot be read
                        // ... note it will not necessarily be in the posters own language!
                        $emailer->set_subject($lang['Topic_reply_notification']);
                        $emailer->assign_vars(array('EMAIL_SIG' => !empty($board_config['board_email_sig']) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '', 'SITENAME' => $board_config['sitename'], 'TOPIC_TITLE' => $topic_title, 'U_TOPIC' => URL::index('&file=viewtopic&' . POST_POST_URL . "={$post_id}", true, true) . "#{$post_id}", 'U_STOP_WATCHING_TOPIC' => URL::index('&file=viewtopic&' . POST_TOPIC_URL . "={$topic_id}&unwatch=topic", true, true)));
                        $emailer->send();
                        $emailer->reset();
                        //send_mail($error, $message, false, $lang['Topic_reply_notification'], $to='', $to_name='')
                    }
                }
            }
            $db->sql_freeresult($result);
            if ($update_watched_sql != '') {
                $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\n\t\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\t\tWHERE topic_id = {$topic_id} AND user_id IN ({$update_watched_sql})";
                $db->sql_query($sql);
            }
        }
        $sql = "SELECT topic_id FROM " . TOPICS_WATCH_TABLE . "\n\t\t\tWHERE topic_id = {$topic_id} AND user_id = " . $userdata['user_id'];
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        if (!$notify_user && !empty($row['topic_id'])) {
            $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\n\t\t\t\t\tWHERE topic_id = {$topic_id} AND user_id = " . $userdata['user_id'];
            $db->sql_query($sql);
        } else {
            if ($notify_user && empty($row['topic_id'])) {
                $sql = "INSERT INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)\n\t\t\t\t\tVALUES (" . $userdata['user_id'] . ", {$topic_id}, 0)";
                $db->sql_query($sql);
            }
        }
    }
}