Example #1
0
/**
* Process Digests
*/
function process_digests()
{
    global $db, $cache, $config, $auth, $user, $lang, $bbcode;
    global $template, $images, $theme, $table_prefix;
    // Digests - BEGIN
    if (!defined('DIGEST_SITE_URL')) {
        $digest_server_url = create_server_url();
        define('DIGEST_SITE_URL', $digest_server_url);
    }
    if (!empty($config['cron_digests_interval']) && $config['cron_digests_interval'] > 0) {
        // MG PHP Cron Emulation For Digests - BEGIN
        $page_url = pathinfo($_SERVER['SCRIPT_NAME']);
        $digests_pages_array = array(CMS_PAGE_PROFILE, CMS_PAGE_POSTING);
        if (empty($config['cron_lock_hour']) && !in_array($page_url['basename'], $digests_pages_array)) {
            if (time() - $config['cron_digests_last_run'] > CRON_REFRESH) {
                $config['cron_digests_last_run'] = empty($config['cron_digests_last_run']) ? time() - 3600 : $config['cron_digests_last_run'];
                $last_send_time = @getdate($config['cron_digests_last_run']);
                $cur_time = @getdate();
                if (!empty($config['cron_digests_interval']) && $config['cron_digests_interval'] > 0 && $cur_time['hours'] != $last_send_time['hours']) {
                    $cron_lock_hour_id = defined('CRON_ID') ? CRON_ID : 1;
                    set_config('cron_lock_hour', $cron_lock_hour_id);
                    define('PHP_DIGESTS_CRON', true);
                    define('PHP_DIGESTS_FUNCTIONS_CRON', true);
                    include_once IP_ROOT_PATH . 'mail_digests.' . PHP_EXT;
                }
            }
        }
        // MG PHP Cron Emulation For Digests - END
    }
    // Digests - END
    if (CRON_DEBUG == false) {
        set_config('cron_digests_last_run', time());
    }
}
Example #2
0
 function build_captcha()
 {
     global $db, $cache, $config, $template, $user, $lang;
     // Clean old sessions and old confirm codes
     $user->confirm_gc();
     // Generate the required confirmation code
     $confirm_image = '';
     $code = unique_id();
     // 0 (zero) could get confused with O (the letter) so we change it
     //$code = substr(str_replace(array('0'), array('Z'), strtoupper(base_convert($code, 16, 35))), 2, 6);
     // Easiest to read charset... some letters and numbers may be ambiguous
     $code = substr(str_replace(array('0', '1', '2', '5', 'O', 'I', 'Z', 'S'), array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'), strtoupper(base_convert($code, 16, 35))), 2, $this->code_length);
     $confirm_id = md5(uniqid($user->ip));
     $sql = "INSERT INTO " . CONFIRM_TABLE . " (confirm_id, session_id, code)\n\t\t\tVALUES ('" . $db->sql_escape($confirm_id) . "', '" . $db->sql_escape($user->data['session_id']) . "', '" . $db->sql_escape($code) . "')";
     $result = $db->sql_query($sql);
     unset($code);
     $server_url = create_server_url();
     $confirm_image = '<img src="' . append_sid($server_url . CMS_PAGE_PROFILE . '?mode=confirm&amp;confirm_id=' . $confirm_id) . '" alt="" title="" />';
     $template->assign_vars(array('S_CAPTCHA' => true, 'CONFIRM_IMG' => $confirm_image, 'CAPTCHA_HIDDEN' => '<input type="hidden" name="confirm_id" value="' . $confirm_id . '" />', 'CAPTCHA_CODE_LENGTH' => $this->code_length, 'L_CONFIRM_CODE_IMPAIRED' => sprintf($lang['CONFIRM_CODE_IMPAIRED'], '<a href="mailto:' . $config['board_email'] . '">', '</a>')));
     $return_array = array('confirm_id' => $confirm_id, 'confirm_image' => $confirm_image);
     return $return_array;
 }
Example #3
0
 function notification($sender_id, $recipient_id, $recipient_email, $email_subject, $email_text, $use_bcc = false, $pm_subject = '', $recipient_username = '', $recipient_lang = '', $emty_email_template = false)
 {
     global $db, $config, $user, $lang;
     require IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
     $recipient_lang = empty($recipient_lang) ? $config['default_lang'] : $recipient_lang;
     // Let's do some checking to make sure that mass mail functions are working in win32 versions of php.
     if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) {
         // We are running on windows, force delivery to use our smtp functions since php's are broken by default
         $config['smtp_delivery'] = 1;
         $config['smtp_host'] = @ini_get('SMTP');
     }
     $emailer = new emailer();
     $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
     $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
     $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']);
     $emailer->headers('X-AntiAbuse: User IP - ' . $user->ip);
     if ($use_bcc) {
         $emailer->to($config['board_email']);
         $emailer->bcc($recipient_email);
     } else {
         $emailer->to($recipient_email);
     }
     $emailer->set_subject($email_subject);
     if ($emty_email_template) {
         $emailer->use_template('admin_send_email', $recipient_lang);
         $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'MESSAGE' => $email_text));
     } else {
         $server_url = create_server_url();
         $privmsg_url = $server_url . CMS_PAGE_PRIVMSG;
         $recipient_username = empty($recipient_username) ? $lang['User'] : $recipient_username;
         $email_sig = create_signature($config['board_email_sig']);
         $emailer->use_template('privmsg_notify', $recipient_lang);
         $emailer->assign_vars(array('USERNAME' => $recipient_username, 'SITENAME' => $config['sitename'], 'EMAIL_SIG' => $email_sig, 'FROM' => $user->data['username'], 'DATE' => create_date($config['default_dateformat'], time(), $config['board_timezone']), 'SUBJECT' => $pm_subject, 'PRIV_MSG_TEXT' => $email_text, 'FROM_USERNAME' => $user->data['username'], 'U_INBOX' => $privmsg_url . '?folder=inbox'));
     }
     $emailer->send();
     $emailer->reset();
     return true;
 }
 $user_info = array();
 $user_info = generate_user_info($thispic);
 foreach ($user_info as $k => $v) {
     ${$k} = $v;
 }
 $poster_avatar = $user_info['avatar'];
 $template->assign_vars(array('CAT_TITLE' => $thispic['cat_title'], 'U_VIEW_CAT' => append_sid(album_append_uid('album_cat.' . PHP_EXT . '?cat_id=' . $cat_id)), 'ALBUM_NAVIGATION_ARROW' => ALBUM_NAV_ARROW, 'NAV_CAT_DESC' => $album_nav_cat_desc, 'EDIT' => $auth_data['moderator'] || $user->data['user_id'] == $thispic['pic_user_id'] ? '<a href="' . append_sid(album_append_uid('album_edit.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'])) . '">' . $edit_link_content . '</a>' : '', 'DELETE' => $auth_data['moderator'] || $user->data['user_id'] == $thispic['pic_user_id'] ? '<a href="' . append_sid(album_append_uid('album_delete.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'])) . '">' . $delete_link_content . '</a>' : '', 'LOCK' => $auth_data['moderator'] ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=' . ($thispic['pic_lock'] == 0 ? 'lock' : 'unlock') . '&amp;pic_id=' . $thispic['pic_id'])) . '">' . $lock_link_content . '</a>' : '', 'MOVE' => $auth_data['moderator'] ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=move&amp;pic_id=' . $thispic['pic_id'])) . '">' . $move_link_content . '</a>' : '', 'COPY' => $auth_data['moderator'] ? '<a href="' . append_sid(album_append_uid('album_modcp.' . PHP_EXT . '?mode=copy&amp;pic_id=' . $thispic['pic_id'])) . '">' . $copy_link_content . '</a>' : '', 'U_PIC_FULL_URL' => $server_url . $pic_fullpath, 'U_PIC' => $pic_link, 'U_PIC_SP' => $pic_sp_link, 'U_PIC_DL' => $pic_dl_link, 'U_PIC_L1' => $pic_full_set ? '' : '<a href="' . append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?full=true&amp;pic_id=' . $pic_id . $sort_append . $nuffimage_vars)) . '">', 'U_PIC_L2' => $pic_full_set ? '' : '</a>', 'U_PIC_CLICK' => $pic_full_set ? '' : $lang['Click_enlarge'], 'U_PIC_THUMB' => append_sid(album_append_uid('album_thumbnail.' . PHP_EXT . '?pic_id=' . $pic_id . $sort_append)), 'U_SMILEY_CREATOR' => append_sid('smiley_creator.' . PHP_EXT . '?mode=text2shield'), 'PIC_COUNT' => sprintf($lang['Pics_Counter'], $new_pic_array_id + 1, $total_pic_count), 'NEXT_PIC' => $next_pic, 'PREV_PIC' => $prev_pic, 'L_PIC_DETAILS' => $lang['Pic_Details'], 'L_PIC_SIZE' => $lang['Pic_Size'], 'L_PIC_TYPE' => $lang['Pic_Type'], 'PIC_HEIGHT' => $pic_full_set ? $pic_height : $album_config['midthumb_height'], 'PIC_WIDTH' => $pic_full_set ? $pic_width : $album_config['midthumb_width'], 'PIC_SIZE' => $pic_width . ' x ' . $pic_height . ' (' . intval($pic_filesize / 1024) . 'KB)', 'PIC_TYPE' => strtoupper(substr($thispic['pic_filename'], strlen($thispic['pic_filename']) - 3, 3)), 'PIC_ID' => $pic_id, 'PIC_BBCODE' => '[albumimg]' . $pic_id . '[/albumimg]', 'PIC_TITLE' => $thispic['pic_title'], 'PIC_DESC' => $pic_desc, 'S_THUMBNAIL_SIZE' => $album_config['thumbnail_size'], 'POSTER' => $poster, 'POSTER_AVATAR' => $poster_avatar, 'PIC_TIME' => create_date_ip($config['default_dateformat'], $thispic['pic_time'], $config['board_timezone']), 'PIC_VIEW' => $thispic['pic_view_count'], 'PIC_COMMENTS' => $total_comments, 'TARGET_BLANK' => $album_config['fullpic_popup'] ? 'target="_blank"' : '', 'L_PIC_ID' => $lang['Pic_ID'], 'L_PIC_BBCODE' => $lang['Pic_BBCode'], 'L_PIC_TITLE' => $lang['Pic_Image'], 'L_PIC_DESC' => $lang['Pic_Desc'], 'L_POSTER' => $lang['Pic_Poster'], 'L_POSTED' => $lang['Posted'], 'L_VIEW' => $lang['Views'], 'L_COMMENTS' => $lang['Comments'], 'L_RATING' => $lang['Rating'], 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'], 'L_USER_WWW' => $lang['Website'], 'L_USER_EMAIL' => $lang['Send_Email'], 'L_USER_PROFILE' => $lang['Profile'], 'L_ONLINE_STATUS' => $lang['Online_status'], 'L_PM' => $lang['Private_Message'], 'L_POST_YOUR_COMMENT' => $lang['Post_your_comment'], 'L_MESSAGE' => $lang['Message'], 'L_USERNAME' => $lang['Username'], 'L_COMMENT_NO_TEXT' => $lang['Comment_no_text'], 'L_COMMENT_TOO_LONG' => $lang['Comment_too_long'], 'L_MAX_LENGTH' => $lang['Max_length'], 'S_MAX_LENGTH' => $album_config['desc_length'], 'L_ORDER' => $lang['Order'], 'L_SORT' => $lang['Sort'], 'L_ASC' => $lang['Sort_Ascending'], 'L_DESC' => $lang['Sort_Descending'], 'L_BACK_TO_TOP' => $lang['Back_to_top'], 'L_COMMENT_WATCH' => $lang['Pic_comment_notification'], 'SORT_ASC' => $sort_order == 'ASC' ? 'selected="selected"' : '', 'SORT_DESC' => $sort_order == 'DESC' ? 'selected="selected"' : '', 'L_SUBMIT' => $lang['Submit'], 'S_ALBUM_ACTION' => append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id)), 'U_COMMENT_WATCH_LINK' => $is_watching_comments ? '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;unwatch=comment') . '">' . $lang['Unwatch_pic'] . '</a>' : ($user->data['session_logged_in'] ? '<a href="' . append_sid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;watch=comment') . '">' . $lang['Watch_pic'] . '</a>' : ''), 'S_RATE_MSG' => !$user->data['session_logged_in'] && $auth_data['rate'] == 0 ? $lang['Login_To_Vote'] : ($own_pic_rate == true && $user->data['user_level'] != ADMIN ? $lang['Own_Pic_Rate'] : ($already_rated == true && $user->data['user_level'] != ADMIN ? $lang['Already_rated'] : $lang['Please_Rate_It'])), 'PIC_RATING' => $image_rating . ($own_pic_rate == true && $user->data['user_level'] != ADMIN ? '&nbsp;(' . $lang['Own_Pic_Rate'] . ')' : ($already_rated == true && $user->data['user_level'] != ADMIN ? '&nbsp;(' . $lang['Already_rated'] . ')' : '')), 'L_CURRENT_RATING' => $lang['Current_Rating'], 'L_PLEASE_RATE_IT' => $lang['Please_Rate_It']));
 // Social Bookmarks
 if ($config['show_social_bookmarks'] == true) {
     $template->assign_block_vars('social_bookmarks', array());
 }
 $topic_title_enc = urlencode(ip_utf8_decode($thispic['pic_title']));
 $topic_title_enc_utf8 = urlencode($thispic['pic_title']);
 $topic_link = 'album_showpage.' . PHP_EXT . '?pic_id=' . $thispic['pic_id'] . $full_size_param . $nuffimage_vars . $sort_append;
 $topic_url_enc = urlencode(ip_utf8_decode(create_server_url() . $topic_link));
 $topic_url_enc_utf8 = urlencode(create_server_url() . $topic_link);
 $template->assign_vars(array('TOPIC_TITLE_ENC' => $topic_title_enc, 'TOPIC_TITLE_ENC_UTF8' => $topic_title_enc_utf8, 'TOPIC_URL_ENC' => $topic_url_enc, 'TOPIC_URL_ENC_UTF8' => $topic_url_enc_utf8, 'U_TELL' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . $topic_title_enc . '&amp;topic_url=' . urlencode(ip_utf8_decode(str_replace('&amp;', '&', $topic_link)))), 'L_SHARE_TOPIC' => $lang['ShareThisTopic']));
 // BBCBMG - BEGIN
 include IP_ROOT_PATH . 'includes/bbcb_mg.' . PHP_EXT;
 $template->assign_var_from_handle('BBCB_MG', 'bbcb_mg');
 // BBCBMG - END
 // BBCBMG SMILEYS - BEGIN
 generate_smilies('inline');
 include IP_ROOT_PATH . 'includes/bbcb_smileys_mg.' . PHP_EXT;
 $template->assign_var_from_handle('BBCB_SMILEYS_MG', 'bbcb_smileys_mg');
 // BBCBMG SMILEYS - END
 if ($album_config['comment'] == 1 && $total_comments > 0) {
     $template->assign_vars(array('PAGINATION' => generate_pagination(append_sid(album_append_uid('album_showpage.' . PHP_EXT . '?pic_id=' . $pic_id . '&amp;sort_order=' . $sort_order)), $total_comments, $comments_per_page, $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $comments_per_page) + 1, ceil($total_comments / $comments_per_page))));
     $template->assign_block_vars('switch_comment', array());
     $template->assign_block_vars('comment_switcharo_bottom', array());
 }
 function obtain_smileys($from_cache = false)
 {
     global $db, $config;
     if (($smileys = $this->get('_smileys')) === false) {
         $smileys = array();
         $smileys_path = create_server_url() . $config['smilies_path'] . '/';
         $sql = "SELECT code, smile_url FROM " . SMILIES_TABLE . " ORDER BY smilies_order";
         $result = $from_cache ? $db->sql_query($sql, 0, 'smileys_') : $db->sql_query($sql);
         while ($row = $db->sql_fetchrow($result)) {
             $smileys[] = array('code' => $row['code'], 'replace' => '<img src="' . $smileys_path . $row['smile_url'] . '" alt="" />');
         }
         $db->sql_freeresult($result);
         $this->put('_smileys', $smileys);
     }
     return $smileys;
 }
Example #6
0
}

$topic_title = $post_data['topic_title'];
$topic_title_enc = urlencode(ip_utf8_decode($topic_title));
$topic_title_enc_utf8 = urlencode($topic_title);

// URL Rewrite - BEGIN
// Rewrite Social Bookmars URLs if any of URL Rewrite rules has been enabled
// Forum ID and KB Mode removed from topic_url_enc to avoid compatibility problems with redirects in tell a friend
if (($config['url_rw'] == true) || ($config['url_rw_guests'] == true))
{
	$topic_url = create_server_url() . make_url_friendly($topic_title) . (empty($link_topic) ? ('-vp' . $post_id . '.html' . $post_id_append_url) : ('-vt' . $topic_id . '.html'));
}
else
{
	$topic_url = create_server_url() . ip_build_url(CMS_PAGE_VIEWTOPIC, array($topic_id_append, $post_id_append), false) . $post_id_append_url;
}
$topic_url_ltt = htmlspecialchars($topic_url);
$topic_url_enc = urlencode(ip_utf8_decode($topic_url));
$topic_url_enc_utf8 = urlencode($topic_url);
// URL Rewrite - END

// Convert and clean special chars!
$topic_title = htmlspecialchars_clean($topic_title);
$template->assign_vars(array(
	'FORUM_ID' => $forum_id,
	'TOPIC_ID' => $topic_id,
	'POST_ID' => $post_id,
	'TOPIC_TITLE' => $topic_title,
	'TOPIC_TITLE_SHORT' => ((strlen($topic_title) > 80) ? substr($topic_title, 0, 75) . '...' : $topic_title),
	'TOPIC_TITLE_ENC' => $topic_title_enc,
Example #7
0
/**
* Sends a birthday Email
*/
function birthday_email_send()
{
    global $db, $cache, $config, $lang;
    if (!class_exists('emailer')) {
        @(include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
    }
    $server_url = create_server_url();
    $birthdays_list = get_birthdays_list_email();
    foreach ($birthdays_list as $k => $v) {
        // Birthday - BEGIN
        // Check if the user has or have had birthday, also see if greetings are enabled
        if (!empty($config['birthday_greeting'])) {
            // Birthday Email - BEGIN
            setup_extra_lang(array('lang_cron_vars'), '', $v['user_lang']);
            $year = create_date('Y', time(), $v['user_timezone']);
            $date_today = create_date('Ymd', time(), $v['user_timezone']);
            $user_birthday = realdate('md', $v['user_birthday']);
            $user_birthday2 = ($year . $user_birthday < $date_today ? $year + 1 : $year) . $user_birthday;
            $user_age = create_date('Y', time(), $v['user_timezone']) - realdate('Y', $v['user_birthday']);
            if (create_date('md', time(), $v['user_timezone']) < realdate('md', $v['user_birthday'])) {
                $user_age--;
            }
            $email_subject = sprintf($lang['BIRTHDAY_GREETING_EMAIL_SUBJECT'], $config['sitename']);
            //$email_text = sprintf($lang['BIRTHDAY_GREETING_EMAIL_CONTENT_AGE'], $user_age);
            $email_text = sprintf($lang['BIRTHDAY_GREETING_EMAIL_CONTENT'], $config['sitename']);
            // Send the email!
            $emailer = new emailer();
            $emailer->use_template('birthday_greeting', $v['user_lang']);
            $emailer->to($v['user_email']);
            // 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($email_subject);
            $v['username'] = !empty($v['user_first_name']) ? $v['user_first_name'] : $v['username'];
            // This is a nasty kludge to remove the username var ... till (if?) translators update their templates
            $emailer->msg = preg_replace('#[ ]?{USERNAME}#', $v['username'], $emailer->msg);
            $email_sig = create_signature($config['board_email_sig']);
            $emailer->assign_vars(array('USERNAME' => !empty($config['html_email']) ? htmlspecialchars($v['username']) : $v['username'], 'USER_AGE' => $user_age, 'EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'SITE_URL' => $server_url));
            $emailer->send();
            $emailer->reset();
            // Birthday Email - END
            $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\tSET user_next_birthday_greeting = " . (create_date('Y', time(), $v['user_timezone']) + 1) . "\n\t\t\t\tWHERE user_id = " . $v['user_id'];
            $status = $db->sql_query($sql);
        }
        // Birthday - END
    }
    // We reset the lang again for default lang...
    setup_extra_lang(array('lang_cron_vars'));
}
if (!empty($setmodules)) {
    $file = basename(__FILE__);
    $module['2000_Downloads']['130_Fchecker'] = $file;
    return;
}
if (!defined('IP_ROOT_PATH')) {
    define('IP_ROOT_PATH', './../');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
require 'pagestart.' . PHP_EXT;
setup_extra_lang(array('lang_admin_pafiledb'));
include IP_ROOT_PATH . 'includes/pafiledb_common.' . PHP_EXT;
$this_dir = IP_ROOT_PATH . DOWNLOADS_PATH;
$html_path = create_server_url() . DOWNLOADS_PATH;
$safety = request_var('safety', 0);
$template->set_filenames(array('admin' => ADM_TPL . 'pa_admin_file_checker.tpl'));
$template->assign_vars(array('L_FILE_CHECKER' => $lang['File_checker'], 'L_FCHECKER_EXPLAIN' => $lang['File_checker_explain']));
if ($safety == 1) {
    $saved = 0;
    $template->assign_block_vars("check", array());
    $template->assign_vars(array('L_FILE_CHECKER_SP1' => $lang['Checker_sp1']));
    $sql = "SELECT * FROM " . PA_FILES_TABLE;
    $overall_result = $db->sql_query($sql);
    while ($temp = $db->sql_fetchrow($overall_result)) {
        $temp_dlurl = $temp['file_dlurl'];
        if (substr($temp_dlurl, 0, strlen($html_path)) !== $html_path) {
            continue;
        }
        if (!is_file($this_dir . '/' . str_replace($html_path, '', $temp_dlurl))) {
Example #9
0
include IP_ROOT_PATH . 'common.' . PHP_EXT;
// Options - BEGIN
// Number of items
$news_items = 10;
// Items type: 'news' or 'topics'
$news_type = 'news';
// Recent: true or false (if set to false then random items will be selected)
$news_recent = true;
// Cache: select true only if you want to use cached version of selected items
$news_cache = false;
// Cache file
$news_cache_file = MAIN_CACHE_FOLDER . 'flash_news_data.xml';
// Cache frequency
$news_cache_freq = 86400;
// Base address
$news_base_address = create_server_url();
// Viewtopic address
$news_base_url = CMS_PAGE_VIEWTOPIC;
// Options - END
/*
* Build_allowed_forums_list: needed to build a list of forum with read access
*/
function flash_build_allowed_forums_list()
{
    $allowed_forums = '';
    $forum_types = array(FORUM_POST);
    $forums_array = get_forums_ids($forum_types, true, false, true, true);
    foreach ($forums_array as $forum) {
        $allowed_forums .= (empty($allowed_forums) ? '' : ',') . $forum['forum_id'];
    }
    return $allowed_forums;
Example #10
0
    function main($action)
    {
        global $db, $config, $template, $images, $user, $lang;
        global $pafiledb_config, $debug;
        $file_id = request_var('file_id', 0);
        if (empty($file_id)) {
            message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
        }
        $sql = 'SELECT file_catid, file_name
			FROM ' . PA_FILES_TABLE . "\n\t\t\tWHERE file_id = {$file_id}";
        $result = $db->sql_query($sql);
        if (!($file_data = $db->sql_fetchrow($result))) {
            message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
        }
        $db->sql_freeresult($result);
        if (!$this->auth[$file_data['file_catid']]['auth_email']) {
            if (!$user->data['session_logged_in']) {
                redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=email&file_id=' . $file_id, true));
            }
            $message = sprintf($lang['Sorry_auth_email'], $this->auth[$file_data['file_catid']]['auth_email_type']);
            message_die(GENERAL_MESSAGE, $message);
        }
        if (isset($_POST['submit'])) {
            // session id check
            $sid = request_post_var('sid', '');
            if (empty($sid) || $sid != $user->data['session_id']) {
                message_die(GENERAL_ERROR, 'INVALID_SESSION');
            }
            $error = false;
            $femail = request_var('femail', '');
            if (!empty($femail) && preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $femail)) {
                $user_email = $femail;
            } else {
                $error = true;
                $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Email_invalid'] : $lang['Email_invalid'];
            }
            $username = request_var('fname', '', true);
            $sender_name = request_var('sname', '', true);
            //if (!$user->data['session_logged_in'] || ($user->data['session_logged_in'] && ($sender_name != $user->data['username'])))
            if (!$user->data['session_logged_in']) {
                // Mighty Gorgon: is this really needed?
                /*
                include(IP_ROOT_PATH . 'includes/functions_validate.' . PHP_EXT);
                $result = validate_username($sender_name);
                if ($result['error'])
                {
                	$error = true;
                	$error_msg .= (!empty($error_msg)) ? '<br />' . $result['error_msg'] : $result['error_msg'];
                }
                */
            } else {
                $sender_name = $user->data['username'];
            }
            if (!$user->data['session_logged_in']) {
                $semail = request_var('semail', '');
                if (!empty($semail) && preg_match('/^[a-z0-9\\.\\-_\\+]+@[a-z0-9\\-_]+\\.([a-z0-9\\-_]+\\.)*?[a-z]+$/is', $femail)) {
                    $sender_email = $semail;
                } else {
                    $error = true;
                    $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Email_invalid'] : $lang['Email_invalid'];
                }
            } else {
                $sender_email = $user->data['user_email'];
            }
            $subject = request_var('subject', '', true);
            $subject = htmlspecialchars_decode($subject, ENT_COMPAT);
            if (empty($subject)) {
                $error = true;
                $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_subject_email'] : $lang['Empty_subject_email'];
            }
            $message = request_var('message', '', true);
            // We need to check if HTML emails are enabled so we can correctly escape content and linebreaks
            $message = !empty($config['html_email']) ? nl2br($message) : htmlspecialchars_decode($message, ENT_COMPAT);
            if (empty($message)) {
                $error = true;
                $error_msg = !empty($error_msg) ? $error_msg . '<br />' . $lang['Empty_message_email'] : $lang['Empty_message_email'];
            }
            if (!$error) {
                include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
                $emailer = new emailer();
                $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
                $emailer->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                $emailer->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                $emailer->headers('X-AntiAbuse: User IP - ' . $user_ip);
                $emailer->use_template('profile_send_email', $user_lang);
                $emailer->to($user_email);
                $emailer->from($sender_email);
                $emailer->replyto($sender_email);
                $emailer->set_subject($subject);
                $emailer->assign_vars(array('SITENAME' => $config['sitename'], 'BOARD_EMAIL' => $config['board_email'], 'FROM_USERNAME' => $sender_name, 'TO_USERNAME' => $username, 'MESSAGE' => $message));
                $emailer->send();
                $emailer->reset();
                $message = $lang['Econf'] . '<br /><br />' . sprintf($lang['Click_return'], '<a href="' . append_sid('dload.' . PHP_EXT . '?action=file&amp;file_id=' . $file_id) . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_HOME) . '">', '</a>');
                message_die(GENERAL_MESSAGE, $message);
            }
            if ($error) {
                message_die(GENERAL_MESSAGE, $error_msg);
            }
        }
        $this->generate_category_nav($file_data['file_catid']);
        $template->assign_vars(array('USER_LOGGED' => !$user->data['session_logged_in'] ? true : false, 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'S_EMAIL_ACTION' => append_sid('dload.' . PHP_EXT), 'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $user->data['session_id'] . '" />', 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_EMAIL' => $lang['Semail'], 'L_EMAIL' => $lang['Emailfile'], 'L_EMAILINFO' => $lang['Emailinfo'], 'L_YNAME' => $lang['Yname'], 'L_YEMAIL' => $lang['Yemail'], 'L_FNAME' => $lang['Fname'], 'L_FEMAIL' => $lang['Femail'], 'L_ETEXT' => $lang['Etext'], 'L_DEFAULTMAIL' => $lang['Defaultmail'], 'L_SEMAIL' => $lang['Semail'], 'L_ESUB' => $lang['Esub'], 'L_EMPTY_SUBJECT_EMAIL' => $lang['Empty_subject_email'], 'L_EMPTY_MESSAGE_EMAIL' => $lang['Empty_message_email'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD_HOME' => append_sid('dload.' . PHP_EXT), 'U_FILE_NAME' => append_sid('dload.' . PHP_EXT . '?action=file&amp;file_id=' . $file_id), 'FILE_NAME' => $file_data['file_name'], 'SNAME' => $user->data['username'], 'SEMAIL' => $user->data['user_email'], 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'FILE_URL' => create_server_url() . 'dload.' . PHP_EXT . '?action=file&amp;file_id=' . $file_id, 'ID' => $file_id));
        $this->display($lang['Download'], 'pa_email_body.tpl');
    }
Example #11
0
 function get_file_size($file_id, $file_data = '')
 {
     global $db, $lang, $pafiledb_config;
     $directory = IP_ROOT_PATH . $pafiledb_config['upload_dir'];
     if (empty($file_data)) {
         $sql = "SELECT file_dlurl, file_size, unique_name, file_dir\n\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\tWHERE file_id = '" . $file_id . "'";
         $result = $db->sql_query($sql);
         $file_data = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
     }
     $file_url = $file_data['file_dlurl'];
     $file_size = $file_data['file_size'];
     $html_path = create_server_url() . $directory;
     $update_filesize = false;
     if ((substr($file_url, 0, strlen($html_path)) == $html_path || !empty($file_data['unique_name'])) && empty($file_size)) {
         $file_url = basename($file_url);
         $file_name = basename($file_url);
         if (!empty($file_data['unique_name']) && !file_exists(IP_ROOT_PATH . $file_data['file_dir'] . $file_data['unique_name'])) {
             return $lang['Not_available'];
         }
         if (empty($file_data['unique_name'])) {
             $file_size = @filesize($directory . $file_name);
         } else {
             $file_size = @filesize(IP_ROOT_PATH . $file_data['file_dir'] . $file_data['unique_name']);
         }
         $update_filesize = true;
     } elseif (empty($file_size) && (!(substr($file_url, 0, strlen($html_path)) == $html_path) || empty($file_data['unique_name']))) {
         $ourhead = "";
         $url = parse_url($file_url);
         $host = $url['host'];
         $path = $url['path'];
         $port = !empty($url['port']) ? $url['port'] : 80;
         $fp = @fsockopen($host, $port, $errno, $errstr, 20);
         if (!$fp) {
             return $lang['Not_available'];
         } else {
             fwrite($fp, "HEAD {$file_url} HTTP/1.1\r\n");
             fwrite($fp, "HOST: {$host}\r\n");
             fwrite($fp, "Connection: close\r\n\r\n");
             while (!feof($fp)) {
                 $ourhead = sprintf('%s%s', $ourhead, fgets($fp, 128));
             }
         }
         @fclose($fp);
         $split_head = explode('Content-Length: ', $ourhead);
         $file_size = round(abs($split_head[1]));
         $update_filesize = true;
     }
     if ($update_filesize) {
         $sql = 'UPDATE ' . PA_FILES_TABLE . "\n\t\t\t\tSET file_size = '{$file_size}'\n\t\t\t\tWHERE file_id = '{$file_id}'";
         $db->sql_query($sql);
     }
     if ($file_size < 1024) {
         $file_size_out = intval($file_size) . ' ' . $lang['Bytes'];
     }
     if ($file_size >= 1025) {
         $file_size_out = round(intval($file_size) / 1024 * 100) / 100 . ' ' . $lang['KB'];
     }
     if ($file_size >= 1048575) {
         $file_size_out = round(intval($file_size) / 1048576 * 100) / 100 . ' ' . $lang['MB'];
     }
     return $file_size_out;
 }
Example #12
0
}
include IP_ROOT_PATH . 'common.' . PHP_EXT;
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
// Get general album information
include ALBUM_MOD_PATH . 'album_common.' . PHP_EXT;
// XML and nocaching headers
// header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Type: text/xml');
// Create main site url
$fap_full_url = create_server_url();
$index_site = $fap_full_url . 'album.' . PHP_EXT;
$index_url = $fap_full_url . 'album_showpage.' . PHP_EXT;
$thumb_url = $fap_full_url . 'album_thumbnail.' . PHP_EXT;
// If not set, set the output count to 25
$count = request_var('np', 25);
$count = $count <= 0 ? 25 : $count;
// BEGIN Recent Photos
// Start check permissions
$sql_allowed_cat = '';
$check_sel = $admin_mode ? 0 : 1;
if ($user->data['user_level'] != ADMIN) {
    $album_user_access = personal_gallery_access(true, false);
    $not_allowed_cat = $album_user_access['view'] == 1 ? '' : '0';
    $sql = "SELECT c.*\n\t\tFROM " . ALBUM_CAT_TABLE . " AS c\n\t\tWHERE cat_id <> 0";
    $result = $db->sql_query($sql);
Example #13
0
            $resultat = $db->sql_query($sql);
            $show = $db->sql_numrows($resultat) ? true : false;
        }
    }
    if (!$show && preg_match('/\\[hide/i', $message)) {
        $search = array("/\\[hide\\](.*?)\\[\\/hide\\]/");
        $replace = array($lang['xs_bbc_hide_message'] . ':' . $break . $lang['xs_bbc_hide_message_explain'] . $break);
        $message = preg_replace($search, $replace, $message);
    }
    $message = unprepare_message($message);
    $search = array('/&#40;/', '/&#41;/', '/&#58;/', '/&#91;/', '/&#93;/', '/&#123;/', '/&#125;/');
    $replace = array('(', ')', ':', '[', ']', '{', '}');
    $message = preg_replace($search, $replace, $message);
    $post_subject = censor_text($post_subject);
    $message = censor_text($message);
    $download_file .= $line . $break . $poster . $break . $post_date . $break . $break . $post_subject . $break . $line . $break . $message . $break . $break . $break;
}
$db->sql_freeresult($result);
$disp_folder = $download == -1 ? 'topic_' . $topic_id : 'post_' . $download;
$this_download_src = create_server_url() . (CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append . ($download > 0 ? '&' . POST_POST_URL . '=' . $download . '#p' . $download : ''));
$download_file = $this_download_src . $break . $download_file;
if (!$is_auth_read['auth_read']) {
    $download_file = sprintf($lang['Sorry_auth_read'], $is_auth_read['auth_read_type']);
    $disp_folder = 'Download';
}
$filename = ip_clean_string($config['sitename'], $lang['ENCODING']) . '_' . ip_clean_string($post_subject, $lang['ENCODING']) . '_' . $disp_folder . '_' . gmdate('Ymd') . '.txt';
header('Content-Type: text/x-delimtext; name="' . $filename . '"');
header('Content-Disposition: attachment;filename="' . $filename . '"');
header('Content-Transfer-Encoding: plain/text');
header('Content-Length: ' . strlen($download_file));
print $download_file;
Example #14
0
	$template->assign_var('S_FEATURED_IMAGE', true);
}

$topic_title_enc = urlencode(ip_utf8_decode($topic_title));
$topic_title_enc_utf8 = urlencode($topic_title);

// URL Rewrite - BEGIN
// Rewrite Social Bookmars URLs if any of URL Rewrite rules has been enabled
// Forum ID and KB Mode removed from topic_url_enc to avoid compatibility problems with redirects in tell a friend
if (($config['url_rw'] == true) || ($config['url_rw_guests'] == true))
{
	$topic_url = create_server_url() . make_url_friendly($topic_title) . '-vt' . $topic_id . '.html' . ($kb_mode ? ('?' . $kb_mode_append) : '');
}
else
{
	$topic_url = create_server_url() . ip_build_url(CMS_PAGE_VIEWTOPIC, array($forum_id_append, $topic_id_append), false) . $kb_mode_append_red;
}
$topic_url_ltt = htmlspecialchars($topic_url);
$topic_url_enc = urlencode(ip_utf8_decode($topic_url));
$topic_url_enc_utf8 = urlencode($topic_url);
// URL Rewrite - END

// Convert and clean special chars!
$topic_title = htmlspecialchars_clean($topic_title);
$template->assign_vars(array(
	'FORUM_ID' => $forum_id,
	'FORUM_ID_FULL' => POST_FORUM_URL . $forum_id,
	'FORUM_NAME' => $forum_name,
	'FORUM_RULES' => $rules_bbcode,
	'TOPIC_ID' => $topic_id,
	'TOPIC_ID_FULL' => POST_TOPIC_URL . $topic_id,
    function update_add_file($file_id = false)
    {
        global $db, $config, $user, $pafiledb_config, $pafiledb_functions;
        $ss_upload = request_post_var('screen_shot_url', '');
        $ss_upload = empty($ss_upload) ? true : false;
        $ss_remote_url = request_post_var('screen_shot_url', '');
        $ss_local = $_FILES['screen_shot']['tmp_name'] !== 'none' ? $_FILES['screen_shot']['tmp_name'] : '';
        $ss_name = $_FILES['screen_shot']['name'] !== 'none' ? $_FILES['screen_shot']['name'] : '';
        $ss_size = !empty($_FILES['screen_shot']['size']) ? $_FILES['screen_shot']['size'] : '';
        $file_upload = request_post_var('download_url', '');
        $file_upload = empty($file_upload) ? true : false;
        $file_remote_url = request_post_var('download_url', '');
        $file_remote_url = str_replace(array(' '), array('%20'), $file_remote_url);
        $file_local = $_FILES['userfile']['tmp_name'] !== 'none' ? $_FILES['userfile']['tmp_name'] : '';
        $file_realname = $_FILES['userfile']['name'] !== 'none' ? $_FILES['userfile']['name'] : '';
        $file_size = !empty($_FILES['userfile']['size']) ? $_FILES['userfile']['size'] : '';
        if ($file_size == '' && $file_remote_url != '') {
            $file_remote_url_clean = str_replace(create_server_url(), '', $file_remote_url);
            //die("$file_remote_url_clean");
            $file_size = @filesize($file_remote_url_clean);
            $file_size = $file_size == false ? 0 : $file_size;
            //die("$file_size");
        }
        $file_type = !empty($_FILES['userfile']['type']) ? $_FILES['userfile']['type'] : '';
        $cat_id = request_var('cat_id', 0);
        $file_name = request_post_var('name', '', true);
        $file_long_desc = request_post_var('long_desc', '', true);
        $file_short_desc = request_post_var('short_desc', '', true);
        $file_short_desc = !empty($file_short_desc) ? $file_short_desc : (!empty($file_long_desc) ? substr($file_long_desc, 0, 50) . '...' : '');
        $file_author = request_post_var('author', '', true);
        $file_author = !empty($file_author) ? $file_author : ($user->data['user_id'] != ANONYMOUS ? $user->data['username'] : '');
        $file_version = request_post_var('version', '', true);
        $file_website = request_post_var('website', '', true);
        if (!empty($file_website)) {
            $file_website = !preg_match('#^http[s]?:\\/\\/#i', $file_website) ? 'http://' . $file_website : $file_website;
            $file_website = preg_match('#^http[s]?\\:\\/\\/[a-z0-9\\-]+\\.([a-z0-9\\-]+\\.)?[a-z]+#i', $file_website) ? $file_website : '';
        }
        $file_posticon = request_post_var('posticon', '');
        $file_license = request_post_var('license', 0);
        $file_pin = request_post_var('pin', 0);
        $file_ss_link = request_post_var('sshot_link', 0);
        $file_dls = request_post_var('file_download', 0);
        $file_time = time();
        $file_time_sql = '';
        if ($cat_id == -1) {
            $this->error[] = $lang['Missing_field'];
        }
        if (empty($file_name)) {
            $this->error[] = $lang['Missing_field'];
        }
        if (empty($file_long_desc)) {
            $this->error[] = $lang['Missing_field'];
        }
        if (empty($file_remote_url) && empty($file_local) && !$file_id) {
            $this->error[] = $lang['Missing_field'];
        }
        $forbidden_extensions = array_map('trim', @explode(',', $pafiledb_config['forbidden_extensions']));
        $file_extension = $pafiledb_functions->get_extension($file_realname);
        if (in_array($file_extension, $forbidden_extensions)) {
            $this->error[] = 'You are not allowed to upload this type of files';
        }
        if (sizeof($this->error)) {
            return;
        }
        $physical_file_name = '';
        if ($file_id) {
            $sql = 'SELECT file_dlurl, file_size, unique_name, file_dir, real_name, file_approved
				FROM ' . PA_FILES_TABLE . "\n\t\t\t\tWHERE file_id = '{$file_id}'";
            $result = $db->sql_query($sql);
            $file_data = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!empty($file_remote_url) || !empty($file_local)) {
                $file_time_sql = 'file_time = \'' . time() . '\',';
                if (!empty($file_data['unique_name'])) {
                    $pafiledb_functions->pafiledb_unlink(IP_ROOT_PATH . $file_data['file_dir'] . $file_data['unique_name']);
                }
            } else {
                $file_remote_url_old = $file_remote_url;
                $file_realname_old = $file_realname;
                $file_remote_url = $file_data['file_dlurl'];
                $physical_file_name = $file_data['unique_name'];
                $file_realname = $file_data['real_name'];
                //die($file_remote_url_old . '<br />' . $file_remote_url . '<br />' . $file_realname_old . '<br />' . $file_realname);
                if ($file_remote_url_old != $file_remote_url || $file_realname_old != $file_realname) {
                    $file_time_sql = 'file_time = \'' . time() . '\',';
                }
                if (empty($file_local)) {
                    $file_upload = false;
                }
            }
        }
        if ($file_upload) {
            $physical_file_name = $pafiledb_functions->gen_unique_name('.' . $file_extension);
            $file_info = $pafiledb_functions->upload_file($file_local, $physical_file_name, $file_size, $pafiledb_config['upload_dir']);
            if ($file_info['error']) {
                message_die(GENERAL_ERROR, $file_info['message']);
            }
        }
        $ss_upload = request_post_var('screen_shot_url', '');
        $ss_upload = empty($ss_upload) ? true : false;
        $ss_remote_url = request_post_var('screen_shot_url', '');
        $ss_local = $_FILES['screen_shot']['tmp_name'] !== 'none' ? $_FILES['screen_shot']['tmp_name'] : '';
        $ss_name = $_FILES['screen_shot']['name'] !== 'none' ? $_FILES['screen_shot']['name'] : '';
        $ss_size = !empty($_FILES['screen_shot']['size']) ? $_FILES['screen_shot']['size'] : '';
        if (!empty($ss_remote_url) || !empty($ss_local)) {
            if ($ss_local) {
                $ss_extension = $pafiledb_functions->get_extension($ss_name);
                if (in_array($ss_extension, $forbidden_extensions)) {
                    // block unwanted screenshots
                    //echo(IP_ROOT_PATH . $pafiledb_config['screenshots_dir'] . $ss_name . ' - FORBIDDEN');
                    $screen_shot_url = '';
                } else {
                    $screen_shot_info = $pafiledb_functions->upload_file($ss_local, $ss_name, $ss_size, $pafiledb_config['screenshots_dir']);
                    if ($screen_shot_info['error']) {
                        message_die(GENERAL_ERROR, $screen_shot_info['message']);
                    }
                    $screen_shot_url = $screen_shot_info['url'];
                }
            } else {
                $screen_shot_url = $ss_remote_url;
            }
            if ($screen_shot_url != '') {
                $server_path = create_server_url();
                if (strpos($screen_shot_url, $server_path) !== false) {
                    $ss_localpath = str_replace($server_path, '', $screen_shot_url);
                    $is_image = @getimagesize($ss_localpath);
                    if ($is_image === false) {
                        // remove unwanted screenshots
                        @unlink(IP_ROOT_PATH . $pafiledb_config['screenshots_dir'] . $ss_name);
                        $screen_shot_url = '';
                    }
                }
            }
        }
        // MX addon
        if ($pafiledb_config['need_validation'] == 0) {
            if (!$file_id) {
                $file_approved = 1;
            } else {
                $file_approved = isset($file_data['file_approved']) ? $file_data['file_approved'] : 0;
            }
        } elseif ($pafiledb_config['need_validation'] == 1) {
            if (!$file_id) {
                $file_approved = ($pafiledb->modules[$pafiledb->module_name]->auth[$_REQUEST['cat_id']]['auth_mod'] || $user->data['user_level'] == ADMIN) && $user->data['session_logged_in'] ? 1 : 0;
            } else {
                $file_approved = isset($file_data['file_approved']) ? $file_data['file_approved'] : 0;
            }
        }
        if (!$file_id) {
            $sql = 'INSERT INTO ' . PA_FILES_TABLE . " (user_id, poster_ip, file_name, file_size, unique_name, real_name, file_dir, file_desc, file_creator, file_version, file_longdesc, file_ssurl, file_sshot_link, file_dlurl, file_time, file_update_time, file_catid, file_posticon, file_license, file_dls, file_last, file_pin, file_docsurl, file_approved)\n\t\t\t\t\tVALUES('{$user->data['user_id']}', '" . $db->sql_escape($user->ip) . "', '" . $db->sql_escape($file_name) . "', '{$file_size}', '{$physical_file_name}', '{$file_realname}', '{$pafiledb_config['upload_dir']}', '" . $db->sql_escape($file_short_desc) . "', '" . $db->sql_escape($file_author) . "', '" . $db->sql_escape($file_version) . "', '" . $db->sql_escape($file_long_desc) . "', '{$screen_shot_url}', '{$file_ss_link}', '{$file_remote_url}', '{$file_time}', '{$file_time}', '{$cat_id}', '{$file_posticon}', '{$file_license}', '{$file_dls}', '0', '{$file_pin}', '{$file_website}', '{$file_approved}')";
        } else {
            $sql = "UPDATE " . PA_FILES_TABLE . "\n\t\t\t\tSET file_name = '" . $db->sql_escape($file_name) . "',\n\t\t\t\tfile_size = '{$file_size}',\n\t\t\t\tunique_name = '{$physical_file_name}',\n\t\t\t\treal_name = '{$file_realname}',\n\t\t\t\tfile_dir = '{$pafiledb_config['upload_dir']}',\n\t\t\t\tfile_desc = '" . $db->sql_escape($file_short_desc) . "',\n\t\t\t\tfile_longdesc = '" . $db->sql_escape($file_long_desc) . "',\n\t\t\t\tfile_creator = '" . $db->sql_escape($file_author) . "',\n\t\t\t\tfile_version = '" . $db->sql_escape($file_version) . "',\n\t\t\t\tfile_ssurl = '{$screen_shot_url}',\n\t\t\t\tfile_sshot_link = '{$file_ss_link}',\n\t\t\t\tfile_dlurl = '{$file_remote_url}',\n\t\t\t\t" . $file_time_sql . "\n\t\t\t\tfile_update_time = '{$file_time}',\n\t\t\t\tfile_catid = '{$cat_id}',\n\t\t\t\tfile_posticon = '{$file_posticon}',\n\t\t\t\tfile_license = '{$file_license}',\n\t\t\t\tfile_pin = '{$file_pin}',\n\t\t\t\tfile_docsurl = '{$file_website}',\n\t\t\t\tfile_dls = '{$file_dls}',\n\t\t\t\tfile_approved = '{$file_approved}'\n\t\t\t\tWHERE file_id = '{$file_id}'";
        }
        $db->sql_query($sql);
        $this->modified(true);
        if ($file_id) {
            return $file_id;
        } else {
            return $db->sql_nextid();
        }
    }
Example #16
0
 /**
  * Selects which template to use
  */
 function use_template($template_file, $template_lang = '', $no_template = false, $plugin_path = '')
 {
     global $config;
     if (trim($template_file) == '') {
         message_die(GENERAL_ERROR, 'No template file set', '', __LINE__, __FILE__);
     }
     if (trim($template_lang) == '') {
         $template_lang = $config['default_lang'];
     }
     $email_template_path = IP_ROOT_PATH . (!empty($plugin_path) ? $plugin_path : '');
     $email_lang_folder = 'language/lang_' . $template_lang . '/';
     $email_format_folder = 'email/' . (!empty($config['html_email']) ? 'html/' : 'txt/');
     if (empty($this->tpl_msg[$template_lang . $template_file])) {
         $tpl_file = $email_template_path . $email_lang_folder . $email_format_folder . $template_file . '.tpl';
         if (!@file_exists(@phpbb_realpath($tpl_file))) {
             // Try to force English!
             $email_lang_folder = 'language/lang_english/';
             $tpl_file = $email_template_path . $email_lang_folder . $email_format_folder . $template_file . '.tpl';
             if (!@file_exists(@phpbb_realpath($tpl_file))) {
                 message_die(GENERAL_ERROR, 'Could not find email template file :: ' . $template_file, '', __LINE__, __FILE__);
             }
         }
         if (!($fd = @fopen($tpl_file, 'r'))) {
             message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
         }
         $this->tpl_msg[$template_lang . $template_file] = @fread($fd, @filesize($tpl_file));
         @fclose($fd);
     }
     if (!empty($config['html_email'])) {
         $mail_header = '';
         $mail_footer = '';
         if (!$no_template) {
             // We don't check here if the file exists for the same lang, because we already checked above and switched to English if needed
             // Also we use here IP_ROOT_PATH and not the full path, since header is only in root
             $tpl_header = IP_ROOT_PATH . $email_lang_folder . $email_format_folder . 'html_mail_header.tpl';
             if (!($fd = @fopen($tpl_header, 'r'))) {
                 message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_header, '', __LINE__, __FILE__);
             }
             $mail_header = fread($fd, filesize($tpl_header));
             fclose($fd);
             // Mighty Gorgon - Add Server URL - BEGIN
             $server_url = create_server_url();
             $mail_header = str_replace('{ROOT}', $server_url, $mail_header);
             $mail_header = str_replace('{SITENAME}', $config['sitename'], $mail_header);
             // Mighty Gorgon - Add Server URL - END
             $tpl_footer = IP_ROOT_PATH . $email_lang_folder . $email_format_folder . 'html_mail_footer.tpl';
             if (!($fd = @fopen($tpl_footer, 'r'))) {
                 message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_footer, '', __LINE__, __FILE__);
             }
             $mail_footer = @fread($fd, @filesize($tpl_footer));
             @fclose($fd);
         }
         $this->msg = $mail_header . $this->tpl_msg[$template_lang . $template_file] . $mail_footer;
     } else {
         $this->msg = $this->tpl_msg[$template_lang . $template_file];
     }
     return true;
 }
/**
* Generate board url (example: http://www.example.com/phpBB)
* @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com)
*/
function generate_board_url($without_script_path = false)
{
    return create_server_url($without_script_path);
}
Example #18
0
	{
		header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
	}
	header('Last-Modified: ' . $MyGMTtime);
	header('Etag: ' . $MyETag);
	header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
	header('Content-Type: text/xml; charset=' . $encoding_charset);
	readfile($cache_file);
}
else
{
	// END Cache Mod

	// BEGIN Create main board information (some code borrowed from functions_post.php)
	// Build URL components
	$index_url = create_server_url();
	$viewpost = CMS_PAGE_VIEWTOPIC;
	$replypost = CMS_PAGE_POSTING . '?mode=quote';
	$index = CMS_PAGE_HOME;
	$viewpost_url = $index_url . $viewpost;
	$replypost_url = $index_url . $replypost;
	// Reformat site name and description
	$site_name = strip_tags($config['sitename']);
	$site_description = strip_tags($config['site_desc']);
	// Set the fully qualified url to your smilies folder
	$smilies_path = $config['smilies_path'];
	$smilies_url = $index_url . $smilies_path;
	$smilies_path = preg_replace("/\//", "\/", $smilies_path);
	// END Create main board information

	// Auth check
Example #19
0
* 4 => File is empty
* 5 => File too big
*/
if (isset($_FILES['userfile'])) {
    $filename = strtolower($_FILES['userfile']['name']);
    $types = explode(',', $filetypes);
    $file = explode('.', $filename);
    $extension = $file[sizeof($file) - 1];
    $filename = substr($filename, 0, strlen($filename) - strlen($extension) - 1);
    if (!in_array($extension, $types)) {
        // Extension not allowed
        //echo('3');
        echo '3|' . $filename . '.' . $extension . '|0|0|0';
        exit;
    }
    $server_path = create_server_url();
    if ($user->data['user_id'] < 0) {
        $filename = 'guest_' . preg_replace('/[^a-z0-9]+/', '_', $filename);
    } else {
        $filename = preg_replace('/[^a-z0-9]+/', '_', $filename);
        if (USERS_SUBFOLDERS_IMG == true) {
            if (is_dir($upload_dir . $user->data['user_id'])) {
                $upload_dir = $upload_dir . $user->data['user_id'] . '/';
            } else {
                $dir_creation = @mkdir($upload_dir . $user->data['user_id'], 0777);
                if ($dir_creation == true) {
                    $upload_dir = $upload_dir . $user->data['user_id'] . '/';
                } else {
                    $filename = 'user_' . $user->data['user_id'] . '_' . $filename;
                }
            }
function album_comment_notify($pic_id)
{
    global $db, $config, $user, $lang, $album_config;
    // One row SQL for caching purpose...
    $sql = "SELECT ban_userid FROM " . BANLIST_TABLE . " WHERE ban_userid <> 0 ORDER BY ban_userid ASC";
    $result = $db->sql_query($sql, 0, 'ban_', USERS_CACHE_FOLDER);
    $user_id_sql = '';
    while ($row = $db->sql_fetchrow($result)) {
        if (isset($row['ban_userid']) && !empty($row['ban_userid'])) {
            $user_id_sql .= ', ' . $row['ban_userid'];
        }
    }
    $sql = "SELECT u.user_id, u.user_email, u.user_lang, p.pic_title\n\t\t\t\tFROM " . ALBUM_COMMENT_WATCH_TABLE . " cw, " . USERS_TABLE . " u\n\t\t\t\tLEFT JOIN " . ALBUM_TABLE . " AS p ON p.pic_id = {$pic_id}\n\t\t\t\tWHERE cw.pic_id = {$pic_id}\n\t\t\t\t\tAND cw.user_id NOT IN (" . $user->data['user_id'] . ", " . ANONYMOUS . $user_id_sql . ")\n\t\t\t\t\tAND cw.notify_status = " . COMMENT_WATCH_UN_NOTIFIED . "\n\t\t\t\t\tAND u.user_id = cw.user_id";
    $result = $db->sql_query($sql);
    $bcc_list_ary = array();
    if ($row = $db->sql_fetchrow($result)) {
        $pic_title = $row['pic_title'];
        // Sixty second limit
        @set_time_limit(60);
        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));
        //
        // Let's do some checking to make sure that mass mail functions
        // are working in win32 versions of php.
        //
        if (preg_match('/[c-z]:\\\\.*/i', getenv('PATH')) && !$config['smtp_delivery']) {
            $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
            // We are running on windows, force delivery to use our smtp functions
            // since php's are broken by default
            $config['smtp_delivery'] = 1;
            $config['smtp_host'] = @$ini_val('SMTP');
        }
        if (sizeof($bcc_list_ary)) {
            include IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
            $emailer = new emailer();
            $server_url = create_server_url();
            $album_showpage_url = $server_url . 'album_showpage.' . PHP_EXT;
            @reset($bcc_list_ary);
            while (list($user_lang, $bcc_list) = each($bcc_list_ary)) {
                $emailer->use_template('album_comment_notify', $user_lang);
                for ($i = 0; $i < sizeof($bcc_list); $i++) {
                    $emailer->bcc($bcc_list[$i]);
                }
                // The Comment_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['Pic_comment_notification']);
                // This is a nasty kludge to remove the username var ... till translators update their templates
                $emailer->msg = preg_replace('#[ ]?{USERNAME}#', '', $emailer->msg);
                $email_sig = create_signature($config['board_email_sig']);
                $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'PIC_TITLE' => $pic_title, 'U_PIC' => $album_showpage_url . '?pic_id=' . $pic_id, 'U_STOP_WATCHING_COMMENT' => $album_showpage_url . '?pic_id=' . $pic_id . '&unwatch=comment'));
                $emailer->send();
                $emailer->reset();
            }
        }
    }
    $db->sql_freeresult($result);
    if ($update_watched_sql != '') {
        $sql = "UPDATE " . ALBUM_COMMENT_WATCH_TABLE . "\n\t\t\tSET notify_status = " . COMMENT_WATCH_NOTIFIED . "\n\t\t\tWHERE pic_id = {$pic_id}\n\t\t\t\tAND user_id IN ({$update_watched_sql})";
        $db->sql_query($sql);
    }
}
function jr_admin_make_admin_link()
{
    global $user, $lang;
    if (!$user->data['session_logged_in']) {
        return '&nbsp;';
    }
    $full_server_url = create_server_url();
    if ($user->data['user_level'] == ADMIN) {
        return '<a href="' . $full_server_url . ADM . '/index.' . PHP_EXT . '?sid=' . $user->data['session_id'] . '">' . $lang['Admin_panel'] . '</a>';
    }
    $jr_admin_userdata = jr_admin_get_user_info($user->data['user_id']);
    if (!empty($jr_admin_userdata['user_jr_admin'])) {
        return '<a href="' . $full_server_url . ADM . '/index.' . PHP_EXT . '?sid=' . $user->data['session_id'] . '">' . $lang['Admin_panel'] . '</a>';
    } else {
        return '&nbsp;';
    }
}
Example #22
0
 function process_tag(&$item)
 {
     global $db, $cache, $config, $user, $lang, $topic_id, $local_urls, $meta_content;
     if (function_exists('create_server_url')) {
         $server_url = create_server_url();
         $local_urls = empty($local_urls) ? array($server_url) : array_merge(array($server_url), $local_urls);
     } else {
         $host = getenv('HTTP_HOST');
         $host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (!empty($host) ? $host : $config['server_name']);
         $server_url = 'http://' . $host . $config['script_path'];
     }
     //LIW - BEGIN
     $max_image_width = intval($config['liw_max_width']);
     //LIW - END
     $tag = $item['tag'];
     //echo 'process_tag(', $tag, ')<br />';
     $start = substr($this->text, $item['start'], $item['start_len']);
     $end = substr($this->text, $item['end'], $item['end_len']);
     $content = substr($this->text, $item['start'] + $item['start_len'], $item['end'] - $item['start'] - $item['start_len']);
     $error = array('valid' => false, 'start' => $this->process_text($start), 'end' => $this->process_text($end));
     if (isset($item['valid']) && $item['valid'] == false) {
         return $error;
     }
     // check if empty item is allowed
     if (!strlen($content)) {
         $allow_empty = true;
         if ($item['is_html'] && isset($this->allowed_html[$tag]['allow_empty']) && !$this->allowed_html[$tag]['allow_empty']) {
             $allow_empty = false;
         }
         if (!$item['is_html'] && isset($this->allowed_bbcode[$tag]['allow_empty']) && !$this->allowed_bbcode[$tag]['allow_empty']) {
             $allow_empty = false;
         }
         if (!$allow_empty) {
             return array('valid' => true, 'html' => '', 'end' => '', 'allow_nested' => false);
         }
     }
     // check if nested item is allowed
     if ($item['iteration']) {
         if ($item['is_html'] && !$this->allowed_html[$tag]['nested']) {
             return $error;
         }
         if (!$item['is_html'] && !$this->allowed_bbcode[$tag]['nested']) {
             return $error;
         }
     }
     // Simple tags: B, EM, STRONG, I, U, TT, STRIKE, SUP, SUB, DIV, SPAN, CENTER
     if ($tag === 'b' || $tag === 'em' || $tag === 'strong' || $tag === 'i' || $tag === 'u' || $tag === 'tt' || $tag === 'strike' || $tag === 'sup' || $tag === 'sub' || $tag === 'div' || $tag === 'span' || $tag === 'center') {
         $extras = $this->allow_styling ? array('style', 'class', 'name') : array('class', 'name');
         $html = '<' . $tag . $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</' . $tag . '>');
     }
     // COLOR
     if ($tag === 'color') {
         $extras = $this->allow_styling ? array('class') : array();
         $color = $this->valid_color(isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['color']) ? $item['params']['color'] : false));
         if ($color === false) {
             return $error;
         }
         $html = '<span style="' . ($this->allow_styling && isset($item['params']['style']) ? htmlspecialchars($this->valid_style($item['params']['style'], '')) : '') . 'color: ' . $color . ';"' . $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</span>');
     }
     // RAINBOW
     if ($tag === 'rainbow') {
         /*
         if($this->is_sig && !$config['allow_all_bbcode'])
         {
         	return $error;
         }
         */
         $html = $this->rainbow($content);
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // GRADIENT
     if ($tag === 'gradient') {
         /*
         if($this->is_sig && !$config['allow_all_bbcode'])
         {
         	return $error;
         }
         */
         $default_color1 = '#000080';
         $color1 = $this->valid_color(isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['cols']) ? $item['params']['cols'] : $default_color1), true);
         $color1 = $color1 === false ? $default_color1 : $color1;
         $default_color2 = '#aaccee';
         $color2 = $this->valid_color(isset($item['params']['cole']) ? $item['params']['cole'] : $default_color2, true);
         $color2 = $color2 === false ? $default_color2 : $color2;
         $mode = $this->process_text(isset($item['params']['mode']) ? $item['params']['mode'] : '');
         $default_iterations = 10;
         $iterations = intval(isset($item['params']['iterations']) ? $item['params']['iterations'] : $default_iterations);
         $iterations = $iterations < 10 || $iterations > 100 ? $default_iterations : $iterations;
         $html = $this->gradient($content, $color1, $color2, $mode, $iterations);
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // HIGHLIGHT
     if ($tag === 'highlight') {
         $extras = $this->allow_styling ? array('class') : array();
         $default_param = '#ffffaa';
         $color = isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['color']) ? $item['params']['color'] : $default_param);
         $color = $this->valid_color($color);
         if ($color === false) {
             return $error;
         }
         $html = '<span style="' . ($this->allow_styling && isset($item['params']['style']) ? htmlspecialchars($this->valid_style($item['params']['style'], '')) : '') . 'background-color: ' . $color . ';"' . $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</span>');
     }
     // SIZE
     if ($tag === 'size') {
         $extras = $this->allow_styling ? array('class') : array();
         $default_param = 0;
         $size = intval(isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['size']) ? $item['params']['size'] : $default_param));
         if ($size > 0 && $size < 7) {
             // vBulletin-style sizes
             switch ($size) {
                 case 1:
                     $size = 7;
                     break;
                 case 2:
                     $size = 8;
                     break;
                 case 3:
                     $size = 10;
                     break;
                 case 4:
                     $size = 12;
                     break;
                 case 5:
                     $size = 15;
                     break;
                 case 6:
                     $size = 24;
                     break;
             }
         }
         if ($size < 6 || $size > 48) {
             return $error;
         }
         $html = '<span style="' . ($this->allow_styling && isset($item['params']['style']) ? htmlspecialchars($this->valid_style($item['params']['style'], '')) : '') . 'font-size: ' . $size . 'px; line-height: 116%;"' . $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</span>');
     }
     // Single tags: HR
     if ($tag === 'hr') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $extras = $this->allow_styling ? array('style', 'class') : array();
         $color = $this->valid_color(isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['color']) ? $item['params']['color'] : false));
         $html = '<' . $tag . ($color === false ? $this->allow_styling && isset($item['params']['style']) ? ' style="' . htmlspecialchars($this->valid_style($item['params']['style'], '')) . '"' : '' : ' style="border-color: ' . $color . ';"') . ' />';
         return array('valid' => true, 'html' => $html);
     }
     // ALIGN
     if ($tag === 'align') {
         $extras = $this->allow_styling ? array('style', 'class') : array();
         $default_param = 'left';
         $align = isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['align']) ? $item['params']['align'] : $default_param);
         if ($align === 'left' || $align === 'right' || $align === 'center' || $align === 'justify') {
             $html = '<div style="text-align: ' . $align . ';' . ($align === 'center' ? ' margin-left: auto; margin-right: auto;' : '') . '">';
             return array('valid' => true, 'start' => $html, 'end' => '</div>');
         } else {
             return $error;
         }
     }
     // IMG
     if ($tag === 'img') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         // main parameters
         $params = array('src' => false, 'alt' => false, 'slide' => false);
         // additional allowed parameters
         $extras = $this->allow_styling ? array('width', 'height', 'border', 'style', 'class', 'title', 'align') : array('width', 'height', 'border', 'title', 'align');
         if ($config['thumbnail_highslide']) {
             $slideshow = !empty($item['params']['slide']) ? ', { slideshowGroup: \'' . $this->process_text($item['params']['slide']) . '\' } ' : '';
         }
         $liw_bypass = false;
         // [img=blah]blah2[/img]
         if (isset($item['params']['param'])) {
             $params['src'] = $item['params']['param'];
             $img_url = $params['src'];
             $img_url_enc = urlencode(ip_utf8_decode($params['src']));
             $path_parts = pathinfo($img_url);
             $params['alt'] = !empty($content) ? $content : ip_clean_string($path_parts['filename'], $lang['ENCODING'], true);
         } elseif (isset($item['params']['src'])) {
             $params['src'] = $item['params']['src'];
             $img_url = $params['src'];
             $img_url_enc = urlencode(ip_utf8_decode($params['src']));
             $path_parts = pathinfo($img_url);
             $params['alt'] = isset($item['params']['alt']) ? $item['params']['alt'] : (!empty($content) ? $content : ip_clean_string($path_parts['filename'], $lang['ENCODING'], true));
             for ($i = 0; $i < sizeof($extras); $i++) {
                 if (!empty($item['params'][$extras[$i]])) {
                     if ($extras[$i] === 'style') {
                         $style = $this->valid_style($item['params']['style']);
                         if ($style !== false) {
                             $params['style'] = $style;
                         }
                     } else {
                         $params[$extras[$i]] = $item['params'][$extras[$i]];
                     }
                 }
             }
         } elseif (!empty($content)) {
             $params['src'] = $content;
             $img_url = $params['src'];
             $img_url_enc = urlencode(ip_utf8_decode($params['src']));
             $path_parts = pathinfo($img_url);
             $params['alt'] = isset($item['params']['alt']) ? $item['params']['alt'] : (isset($params['title']) ? $params['title'] : ip_clean_string($path_parts['filename'], $lang['ENCODING'], true));
             // LIW - BEGIN
             if ($config['liw_enabled'] == 1 && $max_image_width > 0 && $config['thumbnail_posts'] == 0) {
                 $liw_bypass = true;
                 if (isset($item['params']['width'])) {
                     $item['params']['width'] = $item['params']['width'] > $max_image_width ? $max_image_width : $item['params']['width'];
                 } else {
                     $image_size = @getimagesize($content);
                     $item['params']['width'] = $image_size[0] > $max_image_width ? $max_image_width : $image_size[0];
                 }
             }
             // LIW - END
             for ($i = 0; $i < sizeof($extras); $i++) {
                 if (!empty($item['params'][$extras[$i]])) {
                     if ($extras[$i] === 'style') {
                         $style = $this->valid_style($item['params']['style']);
                         if ($style !== false) {
                             $params['style'] = $style;
                         }
                     } else {
                         $params[$extras[$i]] = $item['params'][$extras[$i]];
                     }
                 }
             }
         }
         $is_smiley = false;
         if (substr($params['src'], 0, strlen(BBCODE_SMILIES_PATH)) == BBCODE_SMILIES_PATH) {
             $is_smiley = true;
         }
         if (!$is_smiley && $config['thumbnail_posts'] && $liw_bypass == false) {
             $process_thumb = !empty($config['thumbnail_cache']) ? true : false;
             $thumb_exists = false;
             $thumb_processed = false;
             $is_light_view = false;
             if (isset($item['params']['thumb'])) {
                 if ($item['params']['thumb'] == 'false') {
                     $process_thumb = false;
                 }
             }
             if (!empty($process_thumb)) {
                 $thumb_processed = true;
                 $pic_id = $img_url;
                 $pic_fullpath = str_replace(array(' '), array('%20'), $pic_id);
                 $pic_id = str_replace('http://', '', str_replace('https://', '', $pic_id));
                 $pic_path[] = array();
                 $pic_path = explode('/', $pic_id);
                 $pic_filename = end($pic_path);
                 $file_part = explode('.', strtolower($pic_filename));
                 $pic_filetype = end($file_part);
                 $thumb_ext_array = array('gif', 'jpg', 'png');
                 if (in_array($pic_filetype, $thumb_ext_array)) {
                     $user_dir = '';
                     $users_images_path = str_replace('http://', '', str_replace('https://', '', $server_url . str_replace(IP_ROOT_PATH, '', POSTED_IMAGES_PATH)));
                     $pic_title = substr($pic_filename, 0, strlen($pic_filename) - strlen($pic_filetype) - 1);
                     $pic_title_reg = preg_replace('/[^A-Za-z0-9]+/', '_', $pic_title);
                     $pic_thumbnail = 'mid_' . md5($pic_id) . '_' . $pic_filename;
                     if (strpos($pic_id, $users_images_path) !== false) {
                         $user_dir = str_replace($pic_filename, '', str_replace($users_images_path, '', $pic_id));
                         $pic_thumbnail = $pic_filename;
                     }
                     $pic_thumbnail_fullpath = POSTED_IMAGES_THUMBS_PATH . $user_dir . $pic_thumbnail;
                     // Light View - BEGIN
                     $light_view = request_var('light_view', 0);
                     // Force to false for debugging purpose...
                     $light_view = 0;
                     if (!empty($light_view) && !empty($user_dir)) {
                         $is_light_view = true;
                         $pic_thumbnail_fullpath = POSTED_IMAGES_THUMBS_S_PATH . $user_dir . $pic_thumbnail;
                     }
                     // Light View - END
                     if (file_exists($pic_thumbnail_fullpath)) {
                         $thumb_exists = true;
                         $params['src'] = $server_url . str_replace(IP_ROOT_PATH, '', $pic_thumbnail_fullpath);
                     }
                 }
             }
             $cache_image = true;
             $cache_append = '';
             if (isset($item['params']['cache'])) {
                 if ($item['params']['cache'] == 'false') {
                     //$bbc_eamp = '&amp;';
                     $bbc_eamp = '&';
                     $cache_image = false;
                     $cache_append = 'cache=false' . $bbc_eamp . 'rand=' . md5(rand()) . $bbc_eamp;
                 } else {
                     $cache_image = true;
                 }
             }
             if (!empty($process_thumb) && ($thumb_exists == false || $cache_image == false)) {
                 $pic_thumbnail_script = $server_url . CMS_PAGE_IMAGE_THUMBNAIL . '?' . $cache_append . 'pic_id=' . $img_url_enc;
                 // Light View - BEGIN
                 if (!empty($thumb_processed) && !empty($is_light_view)) {
                     $img_url_enc = $user_dir . $pic_thumbnail;
                     $pic_thumbnail_script = $server_url . CMS_PAGE_IMAGE_THUMBNAIL_S . '?' . $cache_append . 'pic_id=' . $img_url_enc;
                 }
                 // Light View - END
                 $params['src'] = $pic_thumbnail_script;
             }
         }
         // generate html
         $html = '<img';
         foreach ($params as $var => $value) {
             if ($this->process_text($value) != '') {
                 $html .= ' ' . $var . '="' . $this->process_text($value) . '"';
             }
             if ($var == 'src' && !$this->is_sig) {
                 $meta_content['og_img'][] = $value;
             }
         }
         if (!isset($params['title'])) {
             $html .= ' title="' . $this->process_text($params['alt']) . '"';
         }
         $html .= ' />';
         // add url
         /*
         if (strpos($params['src'], trim($config['server_name'])) == false)
         {
         	$html = $this->process_text($params['alt']);
         }
         */
         // Light View - BEGIN
         if (!empty($thumb_processed) && !empty($is_light_view)) {
             $item['inurl'] = true;
         }
         // Light View - END
         if (empty($item['inurl']) && !$is_smiley) {
             if ($this->allow_hs && $config['thumbnail_posts'] && $config['thumbnail_highslide']) {
                 $extra_html = ' class="highslide" onclick="return hs.expand(this' . $slideshow . ')"';
             } else {
                 $extra_html = ' target="_blank" title="' . $lang['OpenNewWindow'] . '"';
             }
             $html = '<a href="' . $this->process_text($img_url) . '"' . $extra_html . '>' . $html . '</a>';
         }
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // IMGBA
     if ($tag === 'imgba') {
         if ($this->is_sig) {
             return $error;
         }
         // main parameters
         $params = array('before' => false, 'after' => false, 'width' => false, 'w' => false, 'height' => false, 'h' => false, 'alt' => false, 'title' => false);
         foreach ($params as $k => $v) {
             $params[$k] = $item['params'][$k];
         }
         if (empty($params['before']) || empty($params['after'])) {
             return $error;
         }
         $path_parts = pathinfo($params['before']);
         (int) ($params['width'] = !empty($params['w']) ? intval($params['w']) : intval($params['width']));
         (int) ($params['height'] = !empty($params['h']) ? intval($params['h']) : intval($params['height']));
         $params['alt'] = !empty($params['alt']) ? $params['alt'] : ip_clean_string($path_parts['filename'], $lang['ENCODING'], true);
         if (empty($params['width']) || empty($params['height'])) {
             return $error;
         }
         // Since we passed the main tests, we may force all needed JS inclusions...
         $config['jquery_ui'] = true;
         $config['jquery_ui_ba'] = true;
         $max_width = 600;
         $or_width = $params['width'];
         $or_height = $params['height'];
         if ($params['width'] > $max_width) {
             $params['width'] = $max_width;
             $params['height'] = $max_width / ($or_width / $or_height);
         }
         // additional allowed parameters
         $extras = $this->allow_styling ? array('style', 'class') : array();
         for ($i = 0; $i < sizeof($extras); $i++) {
             if (!empty($item['params'][$extras[$i]])) {
                 if ($extras[$i] === 'style') {
                     $style = $this->valid_style($item['params']['style']);
                     if ($style !== false) {
                         $params['style'] = $style;
                     }
                 } else {
                     $params[$extras[$i]] = $item['params'][$extras[$i]];
                 }
             }
         }
         $container = 'imgba_' . substr(md5($params['before']), 0, 6);
         $imgba_error = false;
         $allowed_ext = array('gif', 'jpeg', 'jpg', 'png');
         $img_test_array = array('before', 'after');
         // Few "pseudo-security" tests
         foreach ($img_test_array as $img_test) {
             $file_ext = substr(strrchr($params[$img_test], '.'), 1);
             //if (!in_array($file_ext, $allowed_ext) || (strpos($params[$img_test], $server_url) !== 0) || (strpos($params[$img_test], '?') !== 0))
             if (!in_array($file_ext, $allowed_ext)) {
                 $imgba_error = true;
             }
         }
         if (!empty($imgba_error)) {
             return $error;
         }
         // generate html
         $html = '';
         $html .= '<div id="' . $container . '"';
         foreach ($params as $var => $value) {
             if (in_array($value, array('width', 'height')) && $this->process_text($value) != '') {
                 $html .= ' ' . $var . '="' . $this->process_text($value) . '"';
             }
         }
         $html .= '>';
         $img_alt = $this->process_text($params['alt']);
         $img_title = !empty($params['title']) ? ' title="' . $this->process_text($params['title']) . '"' : '';
         $html .= '<div><img src="' . $params['before'] . '" width="' . $params['width'] . '" height="' . $params['height'] . '" alt="Before: ' . $img_alt . '"' . $img_title . ' /></div>';
         $html .= '<div><img src="' . $params['after'] . '" width="' . $params['width'] . '" height="' . $params['height'] . '" alt="After: ' . $img_alt . '"' . $img_title . ' /></div>';
         $html .= '</div>';
         $html .= '<script type="text/javascript">$(function(){ $(\'#' . $container . '\').beforeAfter({imagePath: \'' . $server_url . 'templates/common/jquery/\', showFullLinks: true, cursor: \'e-resize\', dividerColor: \'#dd2222\', beforeLinkText: \'' . $lang['IMG_BA_SHOW_ONLY_BEFORE'] . '\', afterLinkText: \'' . $lang['IMG_BA_SHOW_ONLY_AFTER'] . '\'}); });</script>';
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // ALBUMIMG
     if ($tag === 'albumimg') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         // main parameters
         $params = array('src' => false, 'alt' => false);
         // additional allowed parameters
         $extras = $this->allow_styling ? array('width', 'height', 'border', 'style', 'class', 'title', 'align') : array('width', 'height', 'border', 'title', 'align');
         // [albumimg=blah]blah2[/albumimg]
         if (isset($item['params']['param'])) {
             $params['src'] = $item['params']['param'];
             $pic_url = $item['params']['param'];
             $params['alt'] = $content;
         } elseif (isset($item['params']['src'])) {
             $params['src'] = $item['params']['src'];
             $pic_url = $item['params']['src'];
             $params['alt'] = isset($item['params']['alt']) ? $item['params']['alt'] : $content;
             for ($i = 0; $i < sizeof($extras); $i++) {
                 if (!empty($item['params'][$extras[$i]])) {
                     if ($extras[$i] === 'style') {
                         $style = $this->valid_style($item['params']['style']);
                         if ($style !== false) {
                             $params['style'] = $style;
                         }
                     } else {
                         $params[$extras[$i]] = $item['params'][$extras[$i]];
                     }
                 }
             }
         } elseif (!empty($content)) {
             $params['src'] = $content;
             $pic_url = $content;
             $params['alt'] = isset($item['params']['alt']) ? $item['params']['alt'] : (isset($params['title']) ? $params['title'] : '');
             for ($i = 0; $i < sizeof($extras); $i++) {
                 if (!empty($item['params'][$extras[$i]])) {
                     if ($extras[$i] === 'style') {
                         $style = $this->valid_style($item['params']['style']);
                         if ($style !== false) {
                             $params['style'] = $style;
                         }
                     } else {
                         $params[$extras[$i]] = $item['params'][$extras[$i]];
                     }
                 }
             }
         }
         // generate html
         $pic_url = $server_url . 'album_showpage.' . PHP_EXT . '?pic_id=' . $pic_url;
         if (isset($item['params']['mode'])) {
             $pic_mode = $item['params']['mode'];
             if ($pic_mode === 'full') {
                 $params['src'] = $server_url . 'album_picm.' . PHP_EXT . '?pic_id=' . $params['src'];
             } else {
                 $params['src'] = $server_url . 'album_thumbnail.' . PHP_EXT . '?pic_id=' . $params['src'];
             }
         } else {
             $params['src'] = $server_url . 'album_thumbnail.' . PHP_EXT . '?pic_id=' . $params['src'];
         }
         $html = '<img';
         foreach ($params as $var => $value) {
             $html .= ' ' . $var . '="' . $this->process_text($value) . '"';
             if ($var == 'src' && !$this->is_sig) {
                 $meta_content['og_img'][] = $value;
             }
         }
         if (!isset($params['title'])) {
             $html .= ' title="' . $this->process_text($params['alt']) . '"';
         }
         $html .= ' />';
         // add url
         if (empty($item['inurl'])) {
             $html = '<a href="' . $this->process_text($pic_url) . '" title="' . $lang['Click_enlarge_pic'] . '">' . $html . '</a>';
         }
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // ATTACHMENT
     if ($tag === 'attachment' || $tag === 'download') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $html = '';
         $params['id'] = isset($item['params']['param']) ? intval($item['params']['param']) : (isset($item['params']['id']) ? intval($item['params']['id']) : false);
         $params['title'] = isset($item['params']['title']) ? $this->process_text($item['params']['title']) : false;
         $params['description'] = isset($item['params']['description']) ? $this->process_text($item['params']['description']) : (!empty($content) ? $this->process_text($content) : false);
         $params['icon'] = isset($item['params']['icon']) ? $this->process_text($item['params']['icon']) : false;
         $color = $this->valid_color(isset($item['params']['color']) ? $item['params']['color'] : false);
         $bgcolor = $this->valid_color(isset($item['params']['bgcolor']) ? $item['params']['bgcolor'] : false);
         $errored = false;
         if ($params['id'] <= 0) {
             $errored = true;
         }
         if (!$errored) {
             if ($tag === 'attachment') {
                 if (!function_exists('get_attachment_details')) {
                     include_once IP_ROOT_PATH . 'includes/functions_bbcode.' . PHP_EXT;
                 }
                 $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $user->data);
                 $is_download_auth_ary = auth(AUTH_DOWNLOAD, AUTH_LIST_ALL, $user->data);
                 $attachment_details = get_attachment_details($params['id']);
                 if ($attachment_details == false || !$is_auth_ary[$attachment_details['forum_id']]['auth_read'] || !$is_download_auth_ary[$attachment_details['forum_id']]['auth_download']) {
                     $errored = true;
                 }
             } else {
                 if (!function_exists('get_download_details')) {
                     include_once IP_ROOT_PATH . 'includes/functions_bbcode.' . PHP_EXT;
                 }
                 $attachment_details = get_download_details($params['id']);
                 $errored = $attachment_details == false ? true : false;
             }
         }
         if (!$errored) {
             if ($tag === 'attachment') {
                 $params['title'] = $params['title'] ? $params['title'] : (!empty($attachment_details['real_filename']) ? $attachment_details['real_filename'] : '&nbsp;');
                 $params['description'] = $params['description'] ? $params['description'] : (!empty($attachment_details['comment']) ? $attachment_details['comment'] : ' ');
                 $params['icon'] = IP_ROOT_PATH . FILES_ICONS_DIR . ($params['icon'] ? $params['icon'] : 'default.png');
                 $download_url = IP_ROOT_PATH . 'download.' . PHP_EXT . '?id=' . $params['id'];
             } else {
                 $params['title'] = $params['title'] ? $params['title'] : (!empty($attachment_details['file_name']) ? $attachment_details['file_name'] : '&nbsp;');
                 $params['description'] = $params['description'] ? $params['description'] : (!empty($attachment_details['file_desc']) ? $attachment_details['file_desc'] : ' ');
                 $params['icon'] = IP_ROOT_PATH . FILES_ICONS_DIR . ($params['icon'] ? $params['icon'] : (!empty($attachment_details['file_posticon']) ? $attachment_details['file_posticon'] : 'default.png'));
                 $attachment_details['filesize'] = $attachment_details['file_size'];
                 $attachment_details['download_count'] = $attachment_details['file_dls'];
                 $download_url = IP_ROOT_PATH . 'dload.' . PHP_EXT . '?action=file&amp;file_id=' . $params['id'];
             }
             $params['title'] = htmlspecialchars($params['title']);
             $params['description'] = htmlspecialchars($params['description']);
             $params['icon'] = file_exists($params['icon']) ? $params['icon'] : IP_ROOT_PATH . FILES_ICONS_DIR . 'default.png';
             $style = $color || $bgcolor ? ' style="' . ($color ? 'color: ' . $color . ';' : '') . ($bgcolor ? 'background-color: ' . $bgcolor . ';' : '') . '"' : '';
             $html .= '<div class="mg_attachtitle"' . $style . '>' . $params['title'] . '</div>';
             $html .= '<div class="mg_attachdiv"><table>';
             $html .= '<tr><td style="width: 15%;"><b class="gensmall">' . $lang['Description'] . ':</b></td><td style="width: 75%;"><span class="gensmall">' . $params['description'] . '</span></td><td rowspan="3" class="row-center" style="width: 10%;"><img src="' . $params['icon'] . '" alt="' . $params['description'] . '" /><br /><a href="' . append_sid($download_url) . '" title="' . $lang['Download'] . ' ' . $params['title'] . '"><b>' . $lang['Download'] . '</b></a></td></tr>';
             $html .= '<tr><td><b class="gensmall">' . $lang['FILESIZE'] . ':</b></td><td><span class="gensmall">' . round($attachment_details['filesize'] / 1024, 2) . ' KB</span></td></tr>';
             $html .= '<tr><td><b class="gensmall">' . $lang['DOWNLOADED'] . ':</b></td><td><span class="gensmall">' . $attachment_details['download_count'] . '</span></td></tr>';
             $html .= '</table></div>';
         } else {
             $style = $color || $bgcolor ? ' style="' . ($color ? 'color: ' . $color . ';' : '') . ($bgcolor ? 'background-color: ' . $bgcolor . ';' : '') . '"' : '';
             $html .= '<div class="mg_attachtitle"' . $style . '>' . $lang['Not_Authorized'] . '</div>';
             $html .= '<div class="mg_attachdiv"><div style="text-align: center;">' . $lang['FILE_NOT_AUTH'] . '</div></div>';
         }
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // LIST
     if ($tag === 'list' || $tag === 'ul' || $tag === 'ol') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $extras = $this->allow_styling ? array('style', 'class') : array();
         // check if nested tags are all [*]
         $nested_count = 0;
         for ($i = 0; $i < sizeof($item['items']); $i++) {
             $tag2 = $item['items'][$i]['tag'];
             if ($tag2 === '*' || $tag2 === 'li') {
                 $nested_count++;
             }
         }
         if (!$nested_count) {
             // no <li> items. return error
             return $error;
         }
         // replace "list" with html tag
         if ($tag === 'list') {
             if (isset($item['params']['param']) || isset($item['params']['type'])) {
                 $tag = 'ol';
             } else {
                 $tag = 'ul';
             }
         }
         // valid tag. process subitems to make sure there are no extra items and remove all code between elements
         $last_item = false;
         for ($i = 0; $i < sizeof($item['items']); $i++) {
             $item2 =& $item['items'][$i];
             $tag2 = $item2['tag'];
             if ($tag2 === '*' || $tag2 === 'li') {
                 // mark as valid
                 $item2['list_valid'] = true;
                 if ($last_item === false) {
                     // change start position to end of [list]
                     $pos = !empty($pos) ? $pos : 0;
                     $pos2 = $item2['start'] + $item2['start_len'];
                     $item2['start'] = $pos;
                     $item2['start_len'] = $pos2 - $pos;
                     $item2['first_entry'] = true;
                 }
                 $last_item =& $item['items'][$i];
             }
         }
         // generate html
         $html = '<' . $tag;
         if (isset($item['params']['param'])) {
             $html .= ' type="' . htmlspecialchars($item['params']['param']) . '"';
         } elseif (isset($item['params']['type'])) {
             $html .= ' type="' . htmlspecialchars($item['params']['type']) . '"';
         }
         $html .= $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</li></' . $tag . '>');
     }
     // [*], LI
     if ($tag === '*' || $tag === 'li') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $extras = $this->allow_styling ? array('style', 'class') : array();
         // if not marked as valid return error
         if (empty($item['list_valid'])) {
             return $error;
         }
         $html = '<li';
         if (empty($item['first_entry'])) {
             // add closing tag for previous list entry
             $html = '</li>' . $html;
         }
         $html .= $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '');
     }
     // FONT
     if ($tag === 'font') {
         $fonts = array('Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Impact', 'Lucida Console', 'Lucida Sans Unicode', 'Microsoft Sans Serif', 'Symbol', 'Tahoma', 'Times New Roman', 'Traditional Arabic', 'Trebuchet MS', 'Verdana', 'Webdings', 'Wingdings');
         if (defined('FONTS_DIR')) {
             foreach ($cache->obtain_fonts() as $font_file) {
                 $fonts[] = substr($font_file, 0, -4);
             }
         }
         $extras = $this->allow_styling ? array('style', 'class') : array();
         $default_param = 'Verdana';
         $font = isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['font']) ? $item['params']['font'] : $default_param);
         $font = in_array($font, $fonts) ? $font : $default_param;
         $html = '<span style="font-family: \'' . $font . '\';">';
         return array('valid' => true, 'start' => $html, 'end' => '</span>');
     }
     // CELL
     if ($tag === 'cell') {
         $extras = $this->allow_styling ? array('style', 'class', 'align', 'border') : array('class', 'align');
         $width = isset($item['params']['width']) ? ' width: ' . intval($item['params']['width']) . 'px;' : '';
         $height = isset($item['params']['height']) ? ' height: ' . intval($item['params']['height']) . 'px;' : '';
         $padding = isset($item['params']['padding']) ? ' padding: ' . intval($item['params']['padding']) . 'px;' : '';
         $margin = isset($item['params']['margin']) ? ' margin: ' . intval($item['params']['margin']) . 'px;' : '';
         $borderwidth = isset($item['params']['borderwidth']) ? ' border-width: ' . intval($item['params']['borderwidth']) . 'px;' : '';
         $bgcolor = $this->valid_color(isset($item['params']['bgcolor']) ? $item['params']['bgcolor'] : false);
         $bgcolor = $bgcolor !== false ? ' background-color: ' . $bgcolor . ';' : '';
         $bordercolor = $this->valid_color(isset($item['params']['bordercolor']) ? $item['params']['bordercolor'] : false);
         $bordercolor = $bordercolor !== false ? ' border-color: ' . $bordercolor . ';' : '';
         $color = $this->valid_color(isset($item['params']['color']) ? $item['params']['color'] : false);
         $color = $color !== false ? ' color: ' . $color . ';' : '';
         $html = '<div style="' . ($this->allow_styling && isset($item['params']['style']) ? htmlspecialchars($this->valid_style($item['params']['style'], '')) : '') . $height . $width . $bgcolor . $bordercolor . $borderwidth . $color . $padding . $margin . '"' . $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</div>');
     }
     // URL, A
     if ($tag === 'url' || $tag === 'a') {
         $extras = $this->allow_styling ? array('style', 'class', 'name', 'title') : array('name', 'title');
         $allow_nested = true;
         $strip_text = false;
         $show_content = true;
         $url = '';
         // get url
         if (!empty($item['params']['param'])) {
             $url = $item['params']['param'];
         } elseif (!empty($item['params']['href'])) {
             $url = $item['params']['href'];
         } elseif (!$item['is_html']) {
             $url = $content;
             $allow_nested = false;
             $strip_text = true;
         } else {
             return $error;
         }
         if ($url === $content && strlen($content) > 64) {
             $content = htmlspecialchars(substr($content, 0, 35) . '...' . substr($content, strlen($content) - 15));
             $show_content = false;
         }
         // check if its email
         if (substr(strtolower($url), 0, 7) === 'mailto:') {
             $item['tag'] = 'email';
             return $this->process_tag($item);
         }
         // check for invalid urls
         $url = $this->valid_url($url, '');
         if (empty($url)) {
             return $error;
         }
         // check nested items
         if (!$allow_nested) {
             for ($i = 0; $i < sizeof($item['items']); $i++) {
                 $item['items'][$i]['valid'] = false;
             }
         } else {
             for ($i = 0; $i < sizeof($item['next']); $i++) {
                 $tag2 = $item['next'][$i]['tag'];
                 $is_html = $item['next'][$i]['item']['is_html'];
                 $item['next'][$i]['item']['inurl'] = true;
                 if ($is_html && !$this->allowed_html[$tag2]['inurl']) {
                     $item['next'][$i]['item']['valid'] = false;
                 }
                 if (!$is_html && !$this->allowed_bbcode[$tag2]['inurl']) {
                     $item['next'][$i]['item']['valid'] = false;
                 }
             }
         }
         // check for incomplete url
         if (substr(strtolower($url), 0, 4) === 'www.') {
             $url = 'http://' . $url;
         }
         // remove extra characters at the end
         $last_char = substr($url, strlen($url) - 1);
         $last_char_i = ord($last_char);
         if ($last_char_i > 32 && $last_char_i < 47 || $last_char_i > 57 && $last_char_i < 65) {
             $url = substr($url, 0, strlen($url) - 1);
         }
         // check if url is local
         $is_local_url = false;
         if (!empty($local_urls)) {
             foreach ($local_urls as $local_url) {
                 if (strlen($url) > strlen($local_url) && strpos($url, $local_url) === 0) {
                     $is_local_url = true;
                 }
             }
         }
         if (empty($is_local_url) && strpos($url, ':') === false) {
             $is_local_url = true;
         }
         // generate html
         $url_target = isset($item['params']['target']) && ($item['params']['target'] != 0 || $item['params']['target'] != 'false') ? true : false;
         $html = '<a' . ($this->allow_styling && isset($item['params']['class']) ? '' : ' class="post-url"') . ' href="' . htmlspecialchars($url) . '"' . ($is_local_url && empty($url_target) ? '' : ' target="_blank"' . (!empty($item['params']['nofollow']) || $this->is_sig ? ' rel="nofollow"' : '')) . $this->add_extras($item['params'], $extras) . '>';
         if ($config['disable_html_guests'] && !$user->data['session_logged_in']) {
             return array('valid' => true, 'html' => $lang['Links_For_Guests'], 'allow_nested' => false);
         } else {
             if ($show_content) {
                 return array('valid' => true, 'start' => $html, 'end' => '</a>');
             } else {
                 return array('valid' => true, 'html' => $html . $content . '</a>', 'allow_nested' => false);
             }
         }
     }
     // EMAIL
     if ($tag === 'email') {
         $extras = $this->allow_styling ? array('style', 'class', 'name', 'title') : array('name', 'title');
         $allow_nested = true;
         $strip_text = false;
         $url = '';
         // get url
         if (!empty($item['params']['param'])) {
             $url = $item['params']['param'];
         } elseif (!empty($item['params']['href'])) {
             $url = $item['params']['href'];
         } elseif (!empty($item['params']['addr'])) {
             $url = $item['params']['addr'];
         } else {
             $url = $content;
             $pos = strpos($url, '?');
             if ($pos) {
                 $content = substr($url, 0, $pos);
             }
             if (substr(strtolower($url), 0, 7) === 'mailto:') {
                 $content = substr($content, 7);
             }
             $allow_nested = false;
             $strip_text = true;
         }
         if (empty($url)) {
             return $error;
         }
         // disable nested items
         for ($i = 0; $i < sizeof($item['items']); $i++) {
             $item['items'][$i]['valid'] = false;
         }
         // generate html
         if (substr(strtolower($url), 0, 7) === 'mailto:') {
             $url = substr($url, 7);
         }
         $email = '<a' . ($this->allow_styling && isset($item['params']['class']) ? '' : ' class="post-email"') . ' href="mailto:' . htmlspecialchars($url) . '"' . $this->add_extras($item['params'], $extras) . '>' . $content . '</a>';
         $pos = strpos($url, '?');
         if ($pos) {
             $str = substr($url, 0, $pos);
         } else {
             $str = $url;
         }
         if (defined('IN_AJAX_CHAT')) {
             $html = htmlspecialchars(str_replace(array('@', '.'), array(' [at] ', ' [dot] '), $str));
         } else {
             $noscript = '<noscript>' . htmlspecialchars(str_replace(array('@', '.'), array(' [at] ', ' [dot] '), $str)) . '</noscript>';
             // make javascript from it
             $html = BBCODE_NOSMILIES_START . '<script type="text/javascript">' . "\n" . '// <![CDATA[' . "\n";
             $bit_lenght = 5;
             for ($i = 0; $i < strlen($email); $i += $bit_lenght) {
                 $str = substr($email, $i, $bit_lenght);
                 //$str = preg_replace('/[^A-Za-z0-9_\-@.]+/', '_', $str);
                 $html .= 'document.write(\'' . str_replace('/', '\\/', addslashes($str)) . '\');' . "\n";
             }
             $html .= "\n" . '// ]]>' . "\n" . '</script>' . "\n" . $noscript . BBCODE_NOSMILIES_END;
         }
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // QUOTE
     if ($tag === 'quote' || $tag === 'blockquote' || $tag === 'ot') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         if ($item['iteration'] > $config['quote_iterations']) {
             return $error;
         }
         // check user
         $target_user = '';
         $post_rev = '';
         if (isset($item['params']['param'])) {
             $target_user = htmlspecialchars($item['params']['param']);
         } elseif (isset($item['params']['user'])) {
             $target_user = htmlspecialchars($item['params']['user']);
             if (isset($item['params']['userid']) && intval($item['params']['userid'])) {
                 $target_user = '******' . CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . intval($item['params']['userid']) . '">' . $target_user . '</a>';
             }
         }
         // generate html
         $html = '<blockquote class="quote"';
         if (isset($item['params']['post']) && intval($item['params']['post'])) {
             $post_rev = $user->data['is_bot'] ? '&nbsp;' : '[<a href="#" onclick="open_postreview(\'show_post.php?p=' . intval($item['params']['post']) . '\'); return false;" class="genmed">' . $lang['ReviewPost'] . '</a>]';
             $html .= ' cite="' . CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . intval($item['params']['post']) . '#p' . intval($item['params']['post']) . '"';
         }
         $html .= '>';
         if ($target_user) {
             if ($tag === 'ot') {
                 $html .= '<div class="quote-user"><div class="error-message" style="display:inline;">' . $lang['OffTopic'] . '</div>&nbsp;' . $target_user . ':&nbsp;' . $post_rev . '</div>';
             } else {
                 $html .= '<div class="quote-user">' . $target_user . '&nbsp;' . $lang['wrote'] . ':&nbsp;' . $post_rev . '</div>';
             }
         } else {
             if ($tag === 'ot') {
                 $html .= '<div class="quote-nouser">&nbsp;<div class="error-message" style="display: inline;">' . $lang['OffTopic'] . '</div>:</div>';
             } else {
                 $html .= '<div class="quote-nouser">' . $lang['Quote'] . ':</div>';
             }
         }
         $html .= '<div class="post-text post-text-hide-flow">';
         return array('valid' => true, 'start' => $html, 'end' => '</div></blockquote>');
     }
     // INLINE CODE
     if ($tag === 'c') {
         $extras = $this->allow_styling ? array('style', 'name') : array('name');
         $html = '<code class="inline"' . $this->add_extras($item['params'], $extras) . '>';
         return array('valid' => true, 'start' => $html, 'end' => '</code>');
     }
     // CODE
     if ($tag === 'code') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         // replace spaces and tabs with &nbsp;
         if (!defined('EXTRACT_CODE')) {
             /*
             $search = array(
             	'  ',
             	"\t"
             );
             $replace = array(
             	'&nbsp; ',
             	'&nbsp; &nbsp; '
             );
             $text = str_replace($search, $replace, $this->process_text($content, false, true));
             */
             $text = $this->process_text($content, false, true);
         } else {
             $text = $this->process_text($content, false, true);
             $search = array('[highlight]', '[/highlight]');
             $replace = array('', '');
             $text = str_replace($search, $replace, $text);
         }
         // check filename
         if (isset($item['params']['filename'])) {
             $item['params']['file'] = $item['params']['filename'];
         }
         if (defined('EXTRACT_CODE') && $this->code_counter == EXTRACT_CODE) {
             $GLOBALS['code_text'] = $text;
             if (!empty($item['params']['file'])) {
                 $GLOBALS['code_filename'] = $item['params']['file'];
             }
         }
         if (substr($text, 0, 1) === "\n") {
             $text = substr($text, 1);
         } elseif (substr($text, 0, 2) === "\r\n") {
             $text = substr($text, 2);
         }
         $linenumbers = true;
         if (isset($item['params']['linenumbers'])) {
             $linenumbers = $item['params']['linenumbers'] == 'true' ? true : false;
         }
         if ($linenumbers == true) {
             // convert to list
             if (isset($item['params']['syntax'])) {
                 if ($item['params']['syntax'] == 'php') {
                     /*
                     $html = strtr($text, array_flip(get_html_translation_table(HTML_ENTITIES)));
                     $html = highlight_string($html, true);
                     $html_search = array('<font color="', '</font', '&nbsp;');
                     $xhtml_replace = array('<code style="color:', '</code', ' ');
                     //$xhtml_replace = array('<div style="display:inline;color:', '</div', ' ');
                     //$xhtml_replace = array('<span style="display:inline;color:', '</span', ' ');
                     $html = str_replace ($html_search, $xhtml_replace, $html);
                     $html = '<li class="code-row"><div class="code-row-text">' . $html . '</div></li>';
                     */
                     /*
                     $html_search = array('<br />');
                     $xhtml_replace = array('</div></li><li class="code-row"><div class="code-row-text">');
                     $html = str_replace ($html_search, $xhtml_replace, $html);
                     */
                     //PHP Highlight - Start
                     $code_ary = explode("\n", $text);
                     $open_php_tag = 0;
                     $close_php_tag = 0;
                     for ($i = 0; $i < sizeof($code_ary); $i++) {
                         if ($code_ary[$i] == '' || $code_ary[$i] == ' ' || $code_ary[$i] == '&nbsp;' || $code_ary[$i] == "\n" || $code_ary[$i] == "\r" || $code_ary[$i] == "\n\r") {
                             $html .= '<li class="code-row"><span class="code-row-text">&nbsp;&nbsp;</span></li>';
                         } else {
                             $prefix = strpos(' ' . $code_ary[$i], '&lt;?') ? '' : '<?php ';
                             $suffix = strpos(' ' . $code_ary[$i], '?&gt;') ? '' : '?>';
                             $code_ary[$i] = str_replace(array('&lt;', '&gt;'), array('<', '>'), $code_ary[$i]);
                             $code_ary[$i] = highlight_string(strtr($prefix . $code_ary[$i] . $suffix, array_flip(get_html_translation_table(HTML_ENTITIES))), true);
                             $html_search = array('<code>', '</code>');
                             $xhtml_replace = array('', '');
                             $code_ary[$i] = str_replace($html_search, $xhtml_replace, $code_ary[$i]);
                             if ($open_php_tag || $prefix != '') {
                                 $html_search = array('&lt;?php');
                                 $xhtml_replace = array('');
                                 $code_ary[$i] = str_replace($html_search, $xhtml_replace, $code_ary[$i]);
                             }
                             if ($close_php_tag || $suffix != '') {
                                 $html_search = array('?&gt;&nbsp;', '?&gt;');
                                 $xhtml_replace = array('', '');
                                 $code_ary[$i] = str_replace($html_search, $xhtml_replace, $code_ary[$i]);
                             }
                             $prefix == '' ? $open_php_tag++ : ($open_php_tag ? $open_php_tag-- : '');
                             $suffix == '' ? $close_php_tag++ : ($close_php_tag ? $close_php_tag-- : '');
                             $html .= '<li class="code-row"><span class="code-row-text">' . $code_ary[$i] . '&nbsp;</span></li>';
                         }
                     }
                     $html_search = array('<font color="', '</font', '&nbsp;', '<code style="color:#0000BB"></code>', '<code style="color:#0000BB"> </code>', '>  <');
                     $xhtml_replace = array('<code style="color:', '</code', ' ', '', '', '>&nbsp;<');
                     $html = str_replace($html_search, $xhtml_replace, $html);
                     //PHP Highlight - End
                 } else {
                     $search = array("\n", '[highlight]', '[/highlight]');
                     $replace = array('&nbsp;</span></li><li class="code-row"><span class="code-row-text">', '<span class="code-row-highlight">', '</span>');
                     $html = '<li class="code-row code-row-first"><span class="code-row-text">' . str_replace($search, $replace, $text) . '&nbsp;</span></li>';
                 }
             } else {
                 $search = array("\n", '[highlight]', '[/highlight]');
                 $replace = array('&nbsp;</span></li><li class="code-row"><span class="code-row-text">', '<span class="code-row-highlight">', '</span>');
                 $html = '<li class="code-row code-row-first"><span class="code-row-text">' . str_replace($search, $replace, $text) . '&nbsp;</span></li>';
             }
             $str = '<li class="code-row"><div class="code-row-text">&nbsp;</div></li>';
             if (substr($html, strlen($html) - strlen($str)) === $str) {
                 $html = substr($html, 0, strlen($html) - strlen($str));
             }
             $start = isset($item['params']['start']) ? intval($item['params']['start']) : 1;
             $can_download = !empty($this->code_post_id) ? $this->code_post_id : 0;
             if ($can_download) {
                 //$download_text = ' [<a href="download.php?post=' . $can_download;
                 $download_text = ' [<a href="download_post.' . PHP_EXT . '?post=' . $can_download;
                 if ($this->code_counter) {
                     $download_text .= '&amp;item=' . $this->code_counter;
                 }
                 $download_text .= '">' . $lang['Download'] . '</a>]';
             } else {
                 $download_text = '';
             }
             $code_id = substr(md5($content . mt_rand()), 0, 8);
             $str = BBCODE_NOSMILIES_START . '<div class="code">';
             $str .= '<div class="code-header" id="codehdr2_' . $code_id . '" style="position: relative;">' . $lang['Code'] . ':' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [<a href="#" onclick="ShowHide(\'code_' . $code_id . '\',\'code2_' . $code_id . '\',\'\'); ShowHide(\'codehdr_' . $code_id . '\', \'codehdr2_' . $code_id . '\', \'\'); return false;">' . $lang['Hide'] . '</a>]</div>';
             $str .= '<div class="code-header" id="codehdr_' . $code_id . '" style="position: relative; display: none;">' . $lang['Code'] . ':' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [<a href="#" onclick="ShowHide(\'code_' . $code_id . '\',\'code2_' . $code_id . '\',\'\'); ShowHide(\'codehdr_' . $code_id . '\',\'codehdr2_' . $code_id . '\',\'\'); return false;">' . $lang['Show'] . '</a>]</div>';
             $html = $str . '<div class="code-content" id="code_' . $code_id . '" style="position: relative;"><ol class="code-list" start="' . $start . '">' . $html . '</ol></div></div>' . BBCODE_NOSMILIES_END;
             // check highlight
             // format: highlight="1,2,3-10"
             if (isset($item['params']['highlight'])) {
                 $search = '<li class="code-row';
                 $replace = '<li class="code-row code-row-highlight';
                 $search_len = strlen($search);
                 $replace_len = strlen($replace);
                 // get highlight string
                 $items = array();
                 $str = $item['params']['highlight'];
                 $list = explode(',', $str);
                 for ($i = 0; $i < sizeof($list); $i++) {
                     $str = trim($list[$i]);
                     if (strpos($str, '-')) {
                         $row = explode('-', $str);
                         if (sizeof($row) == 2) {
                             $num1 = intval($row[0]);
                             if ($num1 == 0) {
                                 $num1 = 1;
                             }
                             $num2 = intval($row[1]);
                             if ($num1 > 0 && $num2 > $num1 && $num2 - $num1 < 256) {
                                 for ($j = $num1; $j <= $num2; $j++) {
                                     $items['row' . $j] = true;
                                 }
                             }
                         }
                     } else {
                         $num = intval($str);
                         if ($num) {
                             $items['row' . $num] = true;
                         }
                     }
                 }
                 if (sizeof($items)) {
                     // process all lines
                     $num = $start - 1;
                     $pos = strpos($html, $search);
                     $total = sizeof($items);
                     $found = 0;
                     while ($pos !== false) {
                         $num++;
                         if (isset($items['row' . $num])) {
                             $found++;
                             $html = substr($html, 0, $pos) . $replace . substr($html, $pos + $search_len);
                             $pos += $replace_len;
                         } else {
                             $pos += $search_len;
                         }
                         $pos = $found < $total ? strpos($html, $search, $pos) : false;
                     }
                 }
             }
             // $html = BBCODE_NOSMILIES_START . '<div class="code"><div class="code-header">Code:</div><div class="code-content">' . $text . '</div></div>' . BBCODE_NOSMILIES_END;
             $this->code_counter++;
             return array('valid' => true, 'html' => $html, 'allow_nested' => false);
         } else {
             $syntax_highlight = false;
             if (isset($item['params']['syntax'])) {
                 if ($item['params']['syntax'] == 'php') {
                     $html = strtr($text, array_flip(get_html_translation_table(HTML_ENTITIES)));
                     $html = highlight_string($html, true);
                     $html_search = array('<code>', '</code>', '<font color="', '</font', '&nbsp;', '<code style="color:#0000BB"></code>', '<code style="color:#0000BB"> </code>');
                     $xhtml_replace = array('', '', '<code style="color:', '</code', ' ', '', '');
                     $html = str_replace($html_search, $xhtml_replace, $html);
                     $syntax_highlight = true;
                 }
             }
             if ($syntax_highlight == false) {
                 $html = $text;
                 $search = array('[highlight]', '[/highlight]');
                 $replace = array('</span><span class="code-row code-row-highlight">', '</span><span class="code-row-text">');
                 $html = str_replace($search, $replace, $html);
                 $html = str_replace(array("\n", "\r\n"), array("<br />\n", "<br />\r\n"), $html);
             }
             $can_download = !empty($this->code_post_id) ? $this->code_post_id : 0;
             if ($can_download) {
                 $download_text = ' [<a href="download_post.' . PHP_EXT . '?post=' . $can_download;
                 if ($this->code_counter) {
                     $download_text .= '&amp;item=' . $this->code_counter;
                 }
                 $download_text .= '">' . $lang['Download'] . '</a>]';
             } else {
                 $download_text = '';
             }
             $code_id = substr(md5($content . mt_rand()), 0, 8);
             $str = BBCODE_NOSMILIES_START . '<div class="code">';
             $str .= '<div class="code-header" id="codehdr2_' . $code_id . '" style="position: relative;">' . $lang['Code'] . ':' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [<a href="#" onclick="ShowHide(\'code_' . $code_id . '\',\'code2_' . $code_id . '\',\'\'); ShowHide(\'codehdr_' . $code_id . '\',\'codehdr2_' . $code_id . '\',\'\'); return false;">' . $lang['Hide'] . '</a>] [<a href="#" onclick="select_text(\'code_' . $code_id . '\'); return false;">' . $lang['Select'] . '</a>]</div>';
             $str .= '<div class="code-header" id="codehdr_' . $code_id . '" style="position: relative; display: none;">' . $lang['Code'] . ':' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [<a href="#" onclick="ShowHide(\'code_' . $code_id . '\',\'code2_' . $code_id . '\',\'\'); ShowHide(\'codehdr_' . $code_id . '\',\'codehdr2_' . $code_id . '\',\'\'); return false;">' . $lang['Show'] . '</a>]</div>';
             $html = $str . '<div class="code-content" id="code_' . $code_id . '" style="position: relative;"><span class="code-row-text">' . $html . '</span></div></div>' . BBCODE_NOSMILIES_END;
             $this->code_counter++;
             return array('valid' => true, 'html' => $html, 'allow_nested' => false);
         }
     }
     // CODEBLOCK
     if ($tag === 'codeblock') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         if (!defined('EXTRACT_CODE')) {
             /*
             $search = array(
             	'  ',
             	"\t"
             );
             $replace = array(
             	'&nbsp; ',
             	'&nbsp; &nbsp; '
             );
             $text = str_replace($search, $replace, $this->process_text($content, false, true));
             */
             $text = $this->process_text($content, false, true);
         } else {
             $text = $this->process_text($content, false, true);
             $search = array('[highlight]', '[/highlight]');
             $replace = array('', '');
             $text = str_replace($search, $replace, $text);
         }
         // check filename
         if (isset($item['params']['filename'])) {
             $item['params']['file'] = $item['params']['filename'];
         }
         if (defined('EXTRACT_CODE') && $this->code_counter == EXTRACT_CODE) {
             $GLOBALS['code_text'] = $text;
             if (!empty($item['params']['file'])) {
                 $GLOBALS['code_filename'] = $item['params']['file'];
             }
         }
         if (substr($text, 0, 1) === "\n") {
             $text = substr($text, 1);
         } elseif (substr($text, 0, 2) === "\r\n") {
             $text = substr($text, 2);
         }
         $syntax_highlight = false;
         if (isset($item['params']['syntax'])) {
             if ($item['params']['syntax'] == 'php') {
                 $html = strtr($text, array_flip(get_html_translation_table(HTML_ENTITIES)));
                 $html = highlight_string($html, true);
                 $html_search = array('<code>', '</code>', '<font color="', '</font', '&nbsp;', '<code style="color:#0000BB"></code>', '<code style="color:#0000BB"> </code>');
                 $xhtml_replace = array('', '', '<code style="color:', '</code', ' ', '', '');
                 $html = str_replace($html_search, $xhtml_replace, $html);
                 $syntax_highlight = true;
             }
         }
         if ($syntax_highlight == false) {
             $html = $text;
             $search = array('[highlight]', '[/highlight]');
             $replace = array('</span><span class="code-row code-row-highlight">', '</span><span class="code-row-text">');
             $html = str_replace($search, $replace, $html);
             $html = str_replace(array("\n", "\r\n"), array("<br />\n", "<br />\r\n"), $html);
         }
         $can_download = !empty($this->code_post_id) ? $this->code_post_id : 0;
         if ($can_download) {
             $download_text = ' [<a href="download_post.' . PHP_EXT . '?post=' . $can_download;
             if ($this->code_counter) {
                 $download_text .= '&amp;item=' . $this->code_counter;
             }
             $download_text .= '">' . $lang['Download'] . '</a>]';
         } else {
             $download_text = '';
         }
         $code_id = substr(md5($content . mt_rand()), 0, 8);
         $str = BBCODE_NOSMILIES_START . '<div class="code">';
         $str .= '<div class="code-header" id="codehdr2_' . $code_id . '" style="position: relative;">' . $lang['Code'] . ':' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [<a href="#" onclick="ShowHide(\'code_' . $code_id . '\',\'code2_' . $code_id . '\',\'\'); ShowHide(\'codehdr_' . $code_id . '\',\'codehdr2_' . $code_id . '\',\'\'); return false;">' . $lang['Hide'] . '</a>] [<a href="#" onclick="select_text(\'code_' . $code_id . '\'); return false;">' . $lang['Select'] . '</a>]</div>';
         $str .= '<div class="code-header" id="codehdr_' . $code_id . '" style="position: relative; display: none;">' . $lang['Code'] . ':' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [<a href="#" onclick="ShowHide(\'code_' . $code_id . '\',\'code2_' . $code_id . '\',\'\'); ShowHide(\'codehdr_' . $code_id . '\',\'codehdr2_' . $code_id . '\',\'\'); return false;">' . $lang['Show'] . '</a>]</div>';
         $html = $str . '<div class="code-content" id="code_' . $code_id . '" style="position: relative;"><span class="code-row-text">' . $html . '</span></div></div>' . BBCODE_NOSMILIES_END;
         $this->code_counter++;
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // HIDE
     if ($tag === 'hide') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         if ($item['iteration'] > 1) {
             return $error;
         }
         $show = false;
         if (defined('IS_ICYPHOENIX') && $user->data['session_logged_in']) {
             if ($user->data['user_level'] == ADMIN || $user->data['user_level'] == MOD) {
                 $show = true;
             } else {
                 $sql = "SELECT p.poster_id, p.topic_id\n\t\t\t\t\t\tFROM " . POSTS_TABLE . " p\n\t\t\t\t\t\tWHERE p.topic_id = " . intval($topic_id) . "\n\t\t\t\t\t\tAND p.poster_id = " . $user->data['user_id'];
                 $db->sql_return_on_error(true);
                 $result = $db->sql_query($sql);
                 $db->sql_return_on_error(false);
                 if ($result) {
                     $show = $db->sql_numrows($result) ? true : false;
                     $db->sql_freeresult($result);
                 }
                 $sql = "SELECT *\n\t\t\t\t\t\tFROM " . POSTS_LIKES_TABLE . "\n\t\t\t\t\t\tWHERE topic_id = " . intval($topic_id) . "\n\t\t\t\t\t\tAND user_id = " . $user->data['user_id'];
                 $db->sql_return_on_error(true);
                 $result = $db->sql_query($sql);
                 $db->sql_return_on_error(false);
                 if ($result) {
                     $show = $db->sql_numrows($result) || $show == true ? true : false;
                     $db->sql_freeresult($result);
                 }
             }
         }
         // generate html
         $html = '<blockquote class="quote"><div class="quote-nouser">' . $lang['xs_bbc_hide_message'] . ':</div><div class="post-text post-text-hide-flow">';
         if (!$show) {
             return array('valid' => true, 'html' => $html . $lang['xs_bbc_hide_message_explain'] . '</div></blockquote>', 'allow_nested' => false);
         } else {
             return array('valid' => true, 'start' => $html, 'end' => '</div></blockquote>');
         }
     }
     // SPOILER
     if ($tag === 'spoiler') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         if ($item['iteration'] > 1) {
             return $error;
         }
         $spoiler_id = substr(md5($content . mt_rand()), 0, 8);
         $str = '<div class="spoiler">';
         $str .= '<div class="code-header" id="spoilerhdr_' . $spoiler_id . '" style="position: relative;">' . $lang['bbcb_mg_spoiler'] . ': [ <a href="#" onclick="ShowHide(\'spoiler_' . $spoiler_id . '\', \'spoiler2_' . $spoiler_id . '\', \'\'); ShowHide(\'spoilerhdr_' . $spoiler_id . '\', \'spoilerhdr2_' . $spoiler_id . '\', \'\'); return false;">' . $lang['Show'] . '</a> ]</div>';
         $str .= '<div class="code-header" id="spoilerhdr2_' . $spoiler_id . '" style="position: relative; display: none;">' . $lang['bbcb_mg_spoiler'] . ': [ <a href="#" onclick="ShowHide(\'spoiler_' . $spoiler_id . '\', \'spoiler2_' . $spoiler_id . '\', \'\'); ShowHide(\'spoilerhdr_' . $spoiler_id . '\', \'spoilerhdr2_' . $spoiler_id . '\', \'\'); return false;">' . $lang['Hide'] . '</a> ]</div>';
         $str .= '<div class="spoiler-content" id="spoiler2_' . $spoiler_id . '" style="position: relative; display: none;">' . $html;
         return array('valid' => true, 'start' => $str, 'end' => '</div></div>');
     }
     // USER
     // Insert the username and avatar for the selected id
     if ($tag === 'user') {
         if ($this->is_sig) {
             return $error;
         }
         if (isset($item['params']['param'])) {
             $bb_userid = (int) $item['params']['param'];
         } else {
             $bb_userid = (int) $content;
         }
         if ($bb_userid < 2) {
             return $error;
         }
         $bb_user_data = get_userdata($bb_userid);
         if (empty($bb_user_data)) {
             return $error;
         }
         $bb_name_link = colorize_username($bb_user_data['user_id'], $bb_user_data['username'], $bb_user_data['user_color'], $bb_user_data['user_active']);
         $bb_avatar_img = user_get_avatar($bb_user_data['user_id'], $bb_user_data['user_level'], $bb_user_data['user_avatar'], $bb_user_data['user_avatar_type'], $bb_user_data['user_allowavatar'], '', 30);
         $html = $bb_avatar_img . ' ' . $bb_name_link;
         return array('valid' => true, 'html' => $html);
     }
     // LANGVAR
     // Insert the content of a lang var into post... maybe we need to filter something?
     if ($tag === 'langvar') {
         if (isset($item['params']['param'])) {
             $langvar = $item['params']['param'];
         } else {
             $langvar = $content;
         }
         $html = isset($lang[$langvar]) ? $lang[$langvar] : '';
         return array('valid' => true, 'html' => $html);
     }
     // LANGUAGE
     // Parse the content only if in the same language of the user viewing it!!!
     if ($tag === 'language') {
         $language = '';
         if (isset($item['params']['param'])) {
             $language = $item['params']['param'];
         }
         $content = $config['default_lang'] != $language ? '' : $content;
         // We need this trick to process BBCodes withing language BBCode
         if (empty($content)) {
             return array('valid' => true, 'html' => '');
         } else {
             return array('valid' => true, 'start' => '', 'end' => '');
         }
     }
     // SEARCH
     if ($tag === 'search') {
         if (empty($content)) {
             return $error;
         }
         $str = '<a href="' . CMS_PAGE_SEARCH . '?search_keywords=' . urlencode($this->process_text($content)) . '">';
         return array('valid' => true, 'start' => $str, 'end' => '</a>');
     }
     // TAG
     if ($tag === 'tag') {
         if (empty($content)) {
             return $error;
         }
         $str = '<a href="tags.' . PHP_EXT . '?tag_text=' . urlencode($this->process_text($content)) . '">';
         return array('valid' => true, 'start' => $str, 'end' => '</a>');
     }
     // Random number or quote (quote not implemented yet)
     if ($tag === 'random') {
         $max_n = 6;
         $max_n = intval(isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['max']) ? $item['params']['max'] : 6));
         $max_n = $max_n <= 0 ? 6 : $max_n;
         /*
         include_once(IP_ROOT_PATH . 'language/lang_' . $config['default_lang'] . '/lang_randomquote.' . PHP_EXT);
         $randomquote_phrase = $randomquote[rand(0, sizeof($randomquote) - 1)];
         */
         $html = rand(1, $max_n);
         return array('valid' => true, 'html' => $html);
     }
     // MARQUEE
     if ($tag === 'marquee') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $extras = $this->allow_styling ? array('style', 'class') : array();
         $directions_array = array('up', 'right', 'down', 'left');
         $default_param = 'right';
         $direction = isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['direction']) ? $item['params']['direction'] : $default_param);
         $direction = in_array($direction, $directions_array) ? $direction : $default_param;
         $default_scroll = '120';
         $scrolldelay = isset($item['params']['scrolldelay']) ? intval($item['params']['scrolldelay']) : $default_scroll;
         $scrolldelay = $scrolldelay > 10 && $scrolldelay < 601 ? $scrolldelay : $default_scroll;
         $default_behavior = 'scroll';
         $behavior = isset($item['params']['behavior']) ? intval($item['params']['behavior']) : $default_behavior;
         $behavior = $behavior === 'alternate' || $behavior === 'slide' ? $behavior : $default_behavior;
         $html = '<marquee behavior="' . $behavior . '" direction="' . $direction . '" scrolldelay="' . $scrolldelay . '" loop="true" onmouseover="this.stop()" onmouseout="this.start()">';
         return array('valid' => true, 'start' => $html, 'end' => '</marquee>');
     }
     // Active Content - BEGIN
     // Added by Tom XS2 Build 054
     if ($config['switch_bbcb_active_content'] == 1) {
         // FLASH, SWF, FLV, VIDEO, REAL, QUICK, STREAM, EMFF, VIMEO, YOUTUBE, GOOGLEVIDEO
         if ($tag === 'flash' || $tag === 'swf' || $tag === 'flv' || $tag === 'video' || $tag === 'ram' || $tag === 'quick' || $tag === 'stream' || $tag === 'emff' || $tag === 'mp3' || $tag === 'vimeo' || $tag === 'youtube' || $tag === 'googlevideo') {
             if ($this->is_sig && !$config['allow_all_bbcode']) {
                 return $error;
             }
             $content = $this->process_text(isset($item['params']['param']) ? $item['params']['param'] : $content);
             $color_1 = $this->valid_color(isset($item['params']['colors']) ? $item['params']['colors'] : false);
             $color_2 = $this->valid_color(isset($item['params']['colore']) ? $item['params']['colore'] : false);
             $width_array = array(320, 425, 400, 480, 540, 640);
             $height_array = array(240, 350, 300, 360, 420, 480, 385);
             // 4/3 YouTube width and height: 425x350
             // 16/9 YouTube width and height: 640x385
             $default_width = $tag === 'vimeo' || $tag === 'youtube' || $tag === 'googlevideo' ? 640 : 320;
             $width = isset($item['params']['width']) ? intval($item['params']['width']) : $default_width;
             $width = $width > 10 && $width < 641 ? $width : $default_width;
             $default_height = $tag === 'vimeo' || $tag === 'youtube' || $tag === 'googlevideo' ? 385 : 240;
             $height = isset($item['params']['height']) ? intval($item['params']['height']) : $default_height;
             $height = $height > 10 && $height < 481 ? $height : $default_height;
             if ($tag === 'flash' || $tag === 'swf') {
                 $html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' . $width . '" height="' . $height . '"><param name="movie" value="' . $content . '"><param name="quality" value="high"><param name="scale" value="noborder"><param name="wmode" value="transparent"><param name="bgcolor" value="#000000"><embed src="' . $content . '" quality="high" scale="noborder" wmode="transparent" bgcolor="#000000" width="' . $width . '" height="' . $height . '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>';
             } elseif ($tag === 'flv') {
                 $html = '<object type="application/x-shockwave-flash" width="' . $width . '" height="' . $height . '" wmode="transparent" data="flv_player.swf?file=' . $content . '&amp;autoStart=false"><param name="movie" value="flv_player.swf?file=' . $content . '&amp;autoStart=false"/><param name="wmode" value="transparent"/></object>';
             } elseif ($tag === 'video') {
                 $html = '<div align="center"><embed src="' . $content . '" width="' . $width . '" height="' . $height . '" autostart="false"></embed></div>';
             } elseif ($tag === 'ram') {
                 $html = '<div align="center"><embed src="' . $content . '" align="center" width="275" height="40" type="audio/x-pn-realaudio-plugin" console="cons" controls="ControlPanel" autostart="false"></embed></div>';
             } elseif ($tag === 'quick') {
                 $html = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="' . $width . '" height="' . $height . '" align="middle"><param name="controller" value="true"><param name="type" value="video/quicktime"><param name="autoplay" value="true"><param name="target" value="myself"><param name="src" value="' . $content . '"><param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html"><param name="kioskmode" value="true"><embed src="' . $content . '" width="' . $width . '" height="' . $height . '" align="middle" kioskmode="true" controller="true" target="myself" type="video/quicktime" border="0" pluginspage="http://www.apple.com/quicktime/download/indext.html"></embed></object>';
             } elseif ($tag === 'stream') {
                 $html = '<object id="wmp" width="' . $width . '" height="' . $height . '" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,0,0" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"><param name="FileName" value="' . $content . '"><param name="ShowControls" value="1"><param name="ShowDisplay" value="0"><param name="ShowStatusBar" value="1"><param name="AutoSize" value="1"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows95/downloads/contents/wurecommended/s_wufeatured/mediaplayer/default.asp" src="' . $content . '" name="MediaPlayer2" showcontrols="1" showdisplay="0" showstatusbar="1" autosize="1" visible="1" animationatstart="0" transparentatstart="1" loop="0" height="70" width="300"></embed></object>';
             } elseif ($tag === 'emff' || $tag === 'mp3') {
                 $html = '<object data="emff_player.swf" type="application/x-shockwave-flash" width="200" height="55" align="top" ><param name="FlashVars" value="src=' . $content . '" /><param name="movie" value="emff_player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#f8f8f8" /></object>';
             } elseif ($tag === 'vimeo') {
                 $width = in_array($width, $width_array) ? $width : 640;
                 $height = in_array($height, $height_array) ? $height : 385;
                 $html = '<object type="application/x-shockwave-flash" width="' . $width . '" height="' . $height . '" data="http://www.vimeo.com/moogaloop.swf?clip_id=' . $content . '"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $content . '" /></object><br /><a href="http://www.vimeo.com/moogaloop.swf?clip_id=' . $content . '" target="_blank">Link</a><br />';
             } elseif ($tag === 'youtube') {
                 //check URL type
                 $video_file = $content;
                 if (strpos($content, 'youtu.be') !== false) {
                     // Short URL
                     // parse the URL to split it in parts
                     $parsed_url = parse_url($content);
                     // get the path and delete the initial / simbol
                     $video_file = str_replace('/', '', $parsed_url['path']);
                 } elseif (strrpos($content, 'youtube') !== false) {
                     // Long URL
                     // parse the URL to split it in parts
                     $parsed_url = parse_url($content);
                     // get the query part (vars) and parse them into name and value
                     parse_str($parsed_url['query'], $qvars);
                     // send the value to the destination var.
                     $video_file = $qvars['v'];
                 }
                 $video_file = preg_replace('/[^A-Za-z0-9_-]+/', '', $video_file);
                 $color_append = '';
                 if ($color_1 || $color_2) {
                     $color_append .= $color_1 ? '&amp;color1=0x' . str_replace('#', '', $color_1) : '';
                     $color_append .= $color_2 ? '&amp;color2=0x' . str_replace('#', '', $color_2) : '';
                 }
                 $width = in_array($width, $width_array) ? $width : 640;
                 $height = in_array($height, $height_array) ? $height : 385;
                 $video_link = '<br /><a href="http://youtube.com/watch?v=' . $video_file . $color_append . '" target="_blank">YouTube Link</a><br />';
                 // OLD OBJECT Version
                 //$html = '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $video_file . $color_append . '" /><embed src="http://www.youtube.com/v/' . $video_file . $color_append . '" type="application/x-shockwave-flash" width="' . $width . '" height="' . $height . '"></embed></object>' . $video_link;
                 // IFRAME Version
                 $html = '<iframe width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $video_file . '?autoplay=0' . $color_append . '" frameborder="0"></iframe>' . $video_link;
             } elseif ($tag === 'googlevideo') {
                 $width = in_array($width, $width_array) ? $width : 640;
                 $height = in_array($height, $height_array) ? $height : 385;
                 $html = '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=' . $content . '"></param><embed style="width:' . $width . 'px; height:' . $height . 'px;" id="VideoPlayback" align="middle" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=' . $content . '" allowScriptAccess="sameDomain" quality="best" bgcolor="#f8f8f8" scale="noScale" salign="TL" FlashVars="playerMode=embedded"></embed></object><br /><a href="http://video.google.com/videoplay?docid=' . $content . '" target="_blank">Link</a><br />';
             }
             return array('valid' => true, 'html' => $html);
         }
     }
     // Active Content - END
     // SMILEY
     if ($tag === 'smiley') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $extras = $this->allow_styling ? array('style', 'class') : array();
         $text = htmlspecialchars(isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['text']) ? $item['params']['text'] : $content));
         if (isset($item['params']['smilie'])) {
             if ($item['params']['smilie'] == 'standard' || $item['params']['smilie'] == 'random') {
                 //$smilie = $item['params']['smilie'];
                 $smilie = '1';
             } else {
                 $smilie = intval($item['params']['smilie']);
             }
         } else {
             $smilie = '1';
         }
         $default_fontcolor = '000000';
         $fontcolor = $this->valid_color(isset($item['params']['fontcolor']) ? $item['params']['fontcolor'] : $default_fontcolor);
         $fontcolor = $fontcolor === false ? $default_fontcolor : str_replace('#', '', $fontcolor);
         $default_shadowcolor = '888888';
         $shadowcolor = $this->valid_color(isset($item['params']['shadowcolor']) ? $item['params']['shadowcolor'] : $default_shadowcolor);
         $shadowcolor = $shadowcolor === false ? $default_shadowcolor : str_replace('#', '', $shadowcolor);
         $default_shieldshadow = 0;
         $shieldshadow = isset($item['params']['shieldshadow']) ? $item['params']['shieldshadow'] == 1 ? 1 : $default_param : $default_param;
         //$html = '<img src="text2shield.' . PHP_EXT . '?smilie=' . $smilie . '&amp;fontcolor=' . $fontcolor . '&amp;shadowcolor=' . $shadowcolor . '&amp;shieldshadow=' . $shieldshadow . '&amp;text=' . $text . '" alt="Smiley" title="Smiley" />';
         $html = '<img src="text2shield.' . PHP_EXT . '?smilie=' . $smilie . '&amp;fontcolor=' . $fontcolor . '&amp;shadowcolor=' . $shadowcolor . '&amp;shieldshadow=' . $shieldshadow . '&amp;text=' . urlencode(ip_utf8_decode($text)) . '" alt="' . $text . '" title="' . $text . '" />';
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // OPACITY
     if ($tag === 'opacity') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         if (isset($item['params']['param'])) {
             $opacity = intval($item['params']['param']);
             if ($opacity > 0 && $opacity < 101) {
                 $opacity = $opacity;
             }
         } else {
             $opacity = '100';
         }
         $opacity_dec = $opacity / 100;
         $html = '<div class="opacity" style="opacity: ' . $opacity_dec . '; filter: Alpha(Opacity=' . $opacity . ');">';
         return array('valid' => true, 'start' => $html, 'end' => '</div>');
     }
     // FADE
     if ($tag === 'fade') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         if (isset($item['params']['param'])) {
             $opacity = intval($item['params']['param']);
             if ($opacity > 0 && $opacity < 101) {
                 $opacity = $opacity;
             }
         } else {
             $opacity = '100';
         }
         $opacity_dec = $opacity / 100;
         $html = '<div style="display: inline; height: 1; opacity: ' . $opacity_dec . '; filter: Alpha(Opacity=' . $opacity . ',FinishOpacity=0,Style=1,StartX=0,FinishX=100%);">';
         //$html = '<div style="display:inline;height:1;filter:Alpha(Opacity=' . $opacity . ',FinishOpacity=0,Style=1,StartX=0,FinishX=100%);">';
         return array('valid' => true, 'start' => $html, 'end' => '</div>');
     }
     // IE AND HTML 4 ONLY TAGS - BEGIN
     // Let's add a global IF so we can skip them all in once to speed up things...
     // Enable these tags only if you know how to make them work...
     if ($tag === 'glow' || $tag === 'shadow' || $tag === 'blur' || $tag === 'wave' || $tag === 'fliph' || $tag === 'flipv') {
         return array('valid' => true, 'start' => '', 'end' => '');
     }
     /*
     if(($tag === 'glow') || ($tag === 'shadow') || ($tag === 'blur') || ($tag === 'wave') || ($tag === 'fliph') || ($tag === 'flipv'))
     {
     	// GLOW
     	if($tag === 'glow')
     	{
     		$default_color = '#fffffa';
     		$color = $this->valid_color((isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['color']) ? $item['params']['color'] : $default_color)));
     		if($color === false)
     		{
     			return $error;
     		}
     		$html = '<div style="display: inline; filter: glow(color=' . $color . '); height: 20px;">';
     		return array(
     			'valid' => true,
     			'start' => $html,
     			'end' => '</div>',
     		);
     	}
     
     	// SHADOW
     	if($tag === 'shadow')
     	{
     		$default_color = '#666666';
     		$color = $this->valid_color((isset($item['params']['param']) ? $item['params']['param'] : (isset($item['params']['color']) ? $item['params']['color'] : $default_color)));
     		if($color === false)
     		{
     			return $error;
     		}
     		$html = '<div style="display: inline; filter: shadow(color=' . $color . '); height: 20;">';
     		return array(
     			'valid' => true,
     			'start' => $html,
     			'end' => '</div>',
     		);
     	}
     
     	// BLUR
     	if($tag === 'blur')
     	{
     		if($this->is_sig && !$config['allow_all_bbcode'])
     		{
     			return $error;
     		}
     		if(isset($item['params']['param']))
     		{
     			$strenght = intval($item['params']['param']);
     			if (($strenght > 0) && ($strenght < 101))
     			{
     				$strenght = $strenght;
     			}
     		}
     		else
     		{
     			$strenght = '100';
     		}
     		$strenght_dec = $strenght / 100;
     		$html = '<div style="display: inline; width: 100%; height: 20; filter: Blur(add=1,direction=270,strength=' . $strenght . ');">';
     		return array(
     			'valid' => true,
     			'start' => $html,
     			'end' => '</div>',
     		);
     	}
     
     	// WAVE
     	if($tag === 'wave')
     	{
     		if($this->is_sig && !$config['allow_all_bbcode'])
     		{
     			return $error;
     		}
     		if(isset($item['params']['param']))
     		{
     			$strenght = intval($item['params']['param']);
     			if (($strenght > 0) && ($strenght < 101))
     			{
     				$strenght = $strenght;
     			}
     		}
     		else
     		{
     			$strenght = '100';
     		}
     		$strenght_dec = $strenght / 100;
     		$html = '<div style="display: inline; width: 100%; height: 20; filter: Wave(add=1,direction=270,strength=' . $strenght . ');">';
     		return array(
     			'valid' => true,
     			'start' => $html,
     			'end' => '</div>',
     		);
     	}
     
     	// FLIPH, FLIPV
     	if(($tag === 'fliph') || ($tag === 'flipv'))
     	{
     		if($this->is_sig && !$config['allow_all_bbcode'])
     		{
     			return $error;
     		}
     		$html = '<div style="display: inline; filter: ' . $tag . '; height: 1;">';
     		return array(
     			'valid' => true,
     			'start' => $html,
     			'end' => '</div>',
     		);
     	}
     }
     */
     // OLD IE AND HTML 4 ONLY TAGS - END
     // TEX
     if ($tag === 'tex') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         $html = '<img src="cgi-bin/mimetex.cgi?' . $content . '" alt="" border="0" style="vertical-align: middle;" />';
         return array('valid' => true, 'html' => $html, 'allow_nested' => false);
     }
     // TABLE
     if ($tag === 'table') {
         if ($this->is_sig && !$config['allow_all_bbcode']) {
             return $error;
         }
         // additional allowed parameters
         $extras = $this->allow_styling ? array('style', 'class', 'align', 'width', 'height', 'border', 'cellspacing', 'cellpadding') : array('style', 'class', 'align', 'width');
         if (isset($item['params']['param'])) {
             $table_class = $item['params']['param'];
         } else {
             $table_class = '';
         }
         for ($i = 0; $i < sizeof($extras); $i++) {
             if (!empty($item['params'][$extras[$i]])) {
                 if ($extras[$i] === 'style') {
                     $style = $this->valid_style($item['params']['style']);
                     if ($style !== false) {
                         $params['style'] = $style;
                     }
                 } else {
                     $params[$extras[$i]] = $item['params'][$extras[$i]];
                 }
             }
         }
         if (!isset($params['class'])) {
             $params['class'] = $table_class;
         }
         // generate html
         $html = '<table';
         foreach ($params as $var => $value) {
             $html .= ' ' . $var . '="' . $this->process_text($value) . '"';
         }
         $html .= ' >' . $content . '</table>';
         return array('valid' => true, 'html' => $html, 'allow_nested' => true);
     }
     /*
     // TR
     if($tag === 'tr')
     {
     	if($this->is_sig && !$config['allow_all_bbcode'])
     	{
     		return $error;
     	}
     	// generate html
     	$html = '<tr>' . $content . '</tr>';
     	return array(
     		'valid' => true,
     		'html' => $html,
     		'allow_nested' => true,
     	);
     }
     
     // TD
     if($tag === 'td')
     {
     	if($this->is_sig && !$config['allow_all_bbcode'])
     	{
     		return $error;
     	}
     	// additional allowed parameters
     	$extras = $this->allow_styling ? array('class', 'align', 'width', 'height') : array('class', 'align', 'width', 'height');
     
     	for($i = 0; $i < sizeof($extras); $i++)
     	{
     		if(!empty($item['params'][$extras[$i]]))
     		{
     			if($extras[$i] === 'style')
     			{
     				$style = $this->valid_style($item['params']['style']);
     				if($style !== false)
     				{
     					$params['style'] = $style;
     				}
     			}
     			else
     			{
     				$params[$extras[$i]] = $item['params'][$extras[$i]];
     			}
     		}
     	}
     	// generate html
     	$html = '<td';
     	foreach($params as $var => $value)
     	{
     		$html .= ' ' . $var . '="' . $this->process_text($value) . '"';
     	}
     	$html .= ' >' . $content . '</td>';
     	return array(
     		'valid' => true,
     		'html' => $html,
     		'allow_nested' => true,
     	);
     }
     */
     // To use IFRAMES you just need to decomment this block of code (and allow the tag on top of this file)... good luck!
     // IFRAME
     //<iframe src="index.html" scrolling="no" width="100%" height="190" frameborder="0" marginheight="0" marginwidth="0"></iframe>
     //[iframe height=100]docs/index.html[/iframe]
     //[iframe src=docs/index.html height=100] [/iframe]
     /*
     if($tag === 'iframe')
     {
     	if(isset($item['params']['param']))
     	{
     		$params['src'] = $item['params']['param'];
     	}
     	elseif(isset($item['params']['src']))
     	{
     		$params['src'] = $item['params']['src'];
     	}
     	elseif(!empty($content))
     	{
     		$params['src'] = $content;
     	}
     	if(isset($item['params']['scrolling']) && ($params['scrolling'] == 'no'))
     	{
     		$params['scrolling'] = 'no';
     		//$params['scrolling'] = $item['params']['scrolling'];
     	}
     	else
     	{
     		$params['scrolling'] = 'yes';
     	}
     	if(isset($item['params']['width']))
     	{
     		$params['width'] = $item['params']['width'];
     	}
     	else
     	{
     		$params['width'] = '100%';
     	}
     	if(isset($item['params']['height']))
     	{
     		$params['height'] = $item['params']['height'];
     	}
     	else
     	{
     		$params['height'] = '600';
     	}
     
     	foreach($params as $var => $value)
     	{
     		if ($this->process_text($value) != '')
     		{
     			$html .= ' ' . $var . '="' . $this->process_text($value) . '"';
     		}
     	}
     	$extras = $this->allow_styling ? array('style', 'class') : array('class');
     	$html = '<iframe' . $html . '>';
     	return array(
     		'valid' => true,
     		'start' => $html,
     		'end' => '</iframe>'
     	);
     }
     */
     // Invalid tag
     return $error;
 }
Example #23
0
/**
* Page Header
*/
function page_header($title = '', $parse_template = false)
{
    global $db, $cache, $config, $user, $template, $images, $theme, $lang, $tree;
    global $table_prefix, $SID, $_SID;
    global $ip_cms, $cms_config_vars, $cms_config_global_blocks, $cms_config_layouts, $cms_page;
    global $starttime, $base_memory_usage, $do_gzip_compress, $start;
    global $gen_simple_header, $meta_content, $nav_separator, $nav_links, $nav_pgm, $nav_add_page_title, $skip_nav_cat;
    global $breadcrumbs;
    global $forum_id, $topic_id;
    if (defined('HEADER_INC')) {
        return;
    }
    define('HEADER_INC', true);
    // gzip_compression
    $config['gzip_compress_runtime'] = isset($config['gzip_compress_runtime']) ? $config['gzip_compress_runtime'] : $config['gzip_compress'];
    $config['url_rw_runtime'] = $config['url_rw'] || $config['url_rw_guests'] && $user->data['user_id'] == ANONYMOUS ? true : false;
    if ($config['gzip_compress_runtime']) {
        if (@extension_loaded('zlib') && !headers_sent()) {
            ob_start('ob_gzhandler');
        }
    } else {
        // We need to enable this otherwise URL Rewrite will not work without output buffering
        if ($config['url_rw_runtime'] && !headers_sent()) {
            ob_start();
        }
    }
    // CMS
    if (!defined('CMS_INIT')) {
        define('CMS_INIT', true);
        $cms_config_vars = $cache->obtain_cms_config();
        $cms_config_global_blocks = $cache->obtain_cms_global_blocks_config(false);
    }
    //$server_url = create_server_url();
    $page_url = pathinfo($_SERVER['SCRIPT_NAME']);
    $page_query = $_SERVER['QUERY_STRING'];
    $meta_content['page_title'] = !empty($title) ? $title : $meta_content['page_title'];
    $meta_content['page_title'] = empty($meta_content['page_title']) ? $config['sitename'] : strip_tags($meta_content['page_title']);
    $meta_content['page_title_clean'] = empty($meta_content['page_title_clean']) ? strip_tags($meta_content['page_title']) : $meta_content['page_title_clean'];
    // DYNAMIC META TAGS - BEGIN
    // Reset some defaults... to be sure some values are taken from DB properly
    $lang['Default_META_Keywords'] = !empty($config['site_meta_keywords_switch']) && !empty($config['site_meta_keywords']) ? $config['site_meta_keywords'] : (!empty($lang['Default_META_Keywords']) ? $lang['Default_META_Keywords'] : strtolower(htmlspecialchars(strip_tags($config['sitename']))));
    $lang['Default_META_Description'] = !empty($config['site_meta_description_switch']) && !empty($config['site_meta_description']) ? $config['site_meta_description'] : (!empty($lang['Default_META_Description']) ? $lang['Default_META_Description'] : htmlspecialchars(strip_tags($config['site_desc'])));
    $lang['Default_META_Author'] = !empty($config['site_meta_author_switch']) && !empty($config['site_meta_author']) ? $config['site_meta_author'] : (!empty($lang['Default_META_Author']) ? $lang['Default_META_Author'] : htmlspecialchars(strip_tags($config['sitename'])));
    $lang['Default_META_Copyright'] = !empty($config['site_meta_copyright_switch']) && !empty($config['site_meta_copyright']) ? $config['site_meta_copyright'] : (!empty($lang['Default_META_Copyright']) ? $lang['Default_META_Copyright'] : htmlspecialchars(strip_tags($config['sitename'])));
    $meta_content_pages_array = array(CMS_PAGE_VIEWFORUM, CMS_PAGE_VIEWFORUMLIST, CMS_PAGE_VIEWTOPIC);
    if (!in_array($page_url['basename'], $meta_content_pages_array)) {
        $meta_content['cat_id'] = request_var(POST_CAT_URL, 0);
        $meta_content['forum_id'] = request_var(POST_FORUM_URL, 0);
        $meta_content['topic_id'] = request_var(POST_TOPIC_URL, 0);
        $meta_content['post_id'] = request_var(POST_POST_URL, 0);
        $no_meta_pages_array = array(CMS_PAGE_LOGIN, CMS_PAGE_PRIVMSG, CMS_PAGE_POSTING, 'kb.' . PHP_EXT);
        if (!in_array($page_url['basename'], $no_meta_pages_array) && (!empty($meta_content['post_id']) || !empty($meta_content['topic_id']) || !empty($meta_content['forum_id']) || !empty($meta_content['cat_id']))) {
            @(include_once IP_ROOT_PATH . 'includes/functions_meta.' . PHP_EXT);
            create_meta_content();
        } else {
            $meta_content['page_title'] = defined('IN_LOGIN') ? $lang['Login'] : $meta_content['page_title'];
            $meta_content['description'] = defined('IN_LOGIN') ? $lang['Default_META_Description'] : $meta_content['description'];
            $meta_content['keywords'] = defined('IN_LOGIN') ? $lang['Default_META_Keywords'] : $meta_content['keywords'];
        }
    }
    $meta_content['description'] = !empty($meta_content['description']) ? $meta_content['description'] . (META_TAGS_ATTACH ? ' - ' . $lang['Default_META_Description'] : '') : $lang['Default_META_Description'];
    $meta_content['keywords'] = !empty($meta_content['keywords']) ? $meta_content['keywords'] . (META_TAGS_ATTACH ? ' - ' . $lang['Default_META_Keywords'] : '') : $lang['Default_META_Keywords'];
    $meta_content['description'] = strip_tags($meta_content['description']);
    $meta_content['keywords'] = strip_tags($meta_content['keywords']);
    $meta_content['keywords'] = substr($meta_content['keywords'], -2) == ', ' ? substr($meta_content['keywords'], 0, -2) : $meta_content['keywords'];
    $phpbb_meta = '';
    $phpbb_meta .= '<meta name="author" content="' . $lang['Default_META_Author'] . '" />' . "\n";
    $phpbb_meta .= '<meta name="description" content="' . str_replace('"', '', $meta_content['description']) . '" />' . "\n";
    $phpbb_meta .= '<meta name="keywords" content="' . str_replace('"', '', $meta_content['keywords']) . '" />' . "\n";
    // These META are not valid and needed anymore by SEO and HTML 5
    /*
    $phpbb_meta .= '<meta name="title" content="' . $meta_content['page_title'] . '" />' . "\n";
    $phpbb_meta .= '<meta name="copyright" content="' . $lang['Default_META_Copyright'] . '" />' . "\n";
    $phpbb_meta .= '<meta name="category" content="general" />' . "\n";
    $phpbb_meta .= '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9" />' . "\n";
    */
    if (defined('IN_ADMIN') || defined('IN_CMS') || defined('IN_SEARCH') || defined('IN_POSTING')) {
        $phpbb_meta_content = 'noindex,nofollow';
    } else {
        if (defined('ROBOTS_NOINDEX')) {
            $phpbb_meta_content = 'noindex';
        } else {
            $phpbb_meta_content = 'index,follow';
        }
    }
    $phpbb_meta .= '<meta name="robots" content="' . $phpbb_meta_content . '" />' . "\n";
    $phpbb_meta .= !empty($lang['Extra_Meta']) ? $lang['Extra_Meta'] . "\n\n" : "\n";
    $canonical_pages_array = array(CMS_PAGE_FORUM, CMS_PAGE_VIEWFORUM, CMS_PAGE_VIEWTOPIC);
    if (in_array($page_url['basename'], $canonical_pages_array)) {
        $canonical_append = '';
        if ($page_url['basename'] == CMS_PAGE_FORUM) {
            $canonical_append .= !empty($meta_content['cat_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_CAT_URL . '=' . $meta_content['cat_id'] : '';
        }
        $canonical_append .= !empty($meta_content['forum_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_FORUM_URL . '=' . $meta_content['forum_id'] : '';
        $canonical_append .= !empty($meta_content['topic_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_TOPIC_URL . '=' . $meta_content['topic_id'] : '';
        $canonical_append .= !empty($meta_content['post_id']) ? (empty($canonical_append) ? '' : '&amp;') . POST_POST_URL . '=' . $meta_content['post_id'] : '';
        $canonical_append .= !empty($start) ? (empty($canonical_append) ? '' : '&amp;') . 'start=' . $start : '';
        $canonical_url = $page_url['basename'] . (empty($canonical_append) ? '' : '?') . $canonical_append;
        $phpbb_meta .= !empty($canonical_url) ? '<link rel="canonical" href="' . $canonical_url . '" />' . "\n" : '';
    }
    // DYNAMIC META TAGS - END
    // Mighty Gorgon - Smart Header - Begin
    $encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
    $lang_dir = !empty($lang['DIRECTION']) ? $lang['DIRECTION'] : 'ltr';
    $header_lang = !empty($lang['HEADER_LANG']) ? $lang['HEADER_LANG'] : 'en-gb';
    $xml_header_lang = !empty($lang['HEADER_LANG_XML']) ? $lang['HEADER_LANG_XML'] : 'en-gb';
    $doctype_html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
    //$doctype_html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
    $doctype_html .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="' . $lang_dir . '" lang="' . $header_lang . '" xml:lang="' . $xml_header_lang . '">' . "\n";
    if ($page_url['basename'] == CMS_PAGE_VIEWONLINE) {
        $phpbb_meta .= '<meta http-equiv="refresh" content="180;url=viewonline.' . PHP_EXT . '" />' . "\n";
    }
    // Mighty Gorgon - Smart Header - End
    // Mighty Gorgon - AJAX Features - Begin
    $ajax_user_check = '';
    $ajax_user_check_alt = '';
    if (!empty($config['ajax_features'])) {
        $ajax_user_check = 'onkeyup="AJAXUsernameSearch(this.value, 0);"';
        $ajax_user_check_alt = 'onkeyup="AJAXUsernameSearch(this.value, 1);"';
    }
    // Mighty Gorgon - AJAX Features - End
    // Generate HTML required for Mozilla Navigation bar
    $nav_base_url = create_server_url();
    // Mozilla navigation bar - Default items that should be valid on all pages.
    // Defined here to correctly assign the Language Variables and be able to change the variables within code.
    $nav_links['top'] = array('url' => append_sid(CMS_PAGE_HOME), 'title' => $config['sitename']);
    $nav_links['forum'] = array('url' => append_sid(CMS_PAGE_FORUM), 'title' => sprintf($lang['Forum_Index'], $config['sitename']));
    $nav_links['search'] = array('url' => append_sid(CMS_PAGE_SEARCH), 'title' => $lang['Search']);
    $nav_links['help'] = array('url' => append_sid(CMS_PAGE_FAQ), 'title' => $lang['FAQ']);
    $nav_links['author'] = array('url' => append_sid(CMS_PAGE_MEMBERLIST), 'title' => $lang['Memberlist']);
    $nav_links_html = '';
    while (list($nav_item, $nav_array) = @each($nav_links)) {
        if (!empty($nav_array['url'])) {
            $nav_links_html .= '<link rel="' . $nav_item . '" type="text/html" title="' . strip_tags($nav_array['title']) . '" href="' . $nav_base_url . $nav_array['url'] . '" />' . "\n";
        } else {
            // We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
            while (list(, $nested_array) = each($nav_array)) {
                $nav_links_html .= '<link rel="' . $nav_item . '" type="text/html" title="' . strip_tags($nested_array['title']) . '" href="' . $nav_base_url . $nested_array['url'] . '" />' . "\n";
            }
        }
    }
    // RSS Autodiscovery - BEGIN
    $rss_url = $nav_base_url . 'rss.' . PHP_EXT;
    $rss_forum_id = request_var(POST_FORUM_URL, 0);
    $rss_url_append = '';
    $rss_a_url_append = '';
    if ($rss_forum_id != 0) {
        $rss_url_append = '?' . POST_FORUM_URL . '=' . $rss_forum_id;
        $rss_a_url_append = '&amp;' . POST_FORUM_URL . '=' . $rss_forum_id;
    }
    $nav_links_html .= '<link rel="alternate" type="application/rss+xml" title="RSS" href="' . $rss_url . $rss_url_append . '" />' . "\n";
    $nav_links_html .= '<link rel="alternate" type="application/atom+xml" title="Atom" href="' . $rss_url . '?atom' . $rss_a_url_append . '" />' . "\n";
    // RSS Autodiscovery - END
    // Time Management - BEGIN
    // Format Timezone. We are unable to use array_pop here, because of PHP3 compatibility
    $s_timezone = str_replace('.0', '', sprintf('%.1f', number_format($config['board_timezone'], 1)));
    $l_timezone = $lang['tz'][$s_timezone];
    if (!$user->data['session_logged_in']) {
        $user->data['user_time_mode'] = $config['default_time_mode'];
    }
    switch ($user->data['user_time_mode']) {
        case MANUAL_DST:
            $time_message = sprintf($lang['All_times'], $l_timezone) . $lang['dst_enabled_mode'];
            break;
        case SERVER_SWITCH:
            $time_message = sprintf($lang['All_times'], $l_timezone);
            if (@date('I')) {
                $time_message = $time_message . $lang['dst_enabled_mode'];
            }
            break;
        default:
            $time_message = sprintf($lang['All_times'], $l_timezone);
            break;
    }
    $time_message = str_replace('GMT', 'UTC', $time_message);
    // Time Management - END
    // Mighty Gorgon - Advanced Switches - BEGIN
    $new_pm_switch = false;
    $new_private_chat_switch = false;
    // LOGGED IN CHECK - BEGIN
    if (!$user->data['session_logged_in']) {
        // Allow autologin?
        if (!isset($config['allow_autologin']) || $config['allow_autologin']) {
            $template->assign_block_vars('switch_allow_autologin', array());
        }
        $smart_redirect = strrchr($_SERVER['SCRIPT_NAME'], '/');
        $smart_redirect = substr($smart_redirect, 1, strlen($smart_redirect));
        if ($smart_redirect == CMS_PAGE_PROFILE || $smart_redirect == CMS_PAGE_LOGIN) {
            $smart_redirect = '';
        }
        if (isset($_GET) && !empty($smart_redirect)) {
            $smart_get_keys = array_keys($_GET);
            for ($i = 0; $i < sizeof($_GET); $i++) {
                //Better sanitize each key...
                $smart_get_keys[$i] = htmlspecialchars($smart_get_keys[$i]);
                if ($smart_get_keys[$i] != 'sid') {
                    $smart_redirect .= '&amp;' . $smart_get_keys[$i] . '=' . urlencode(ip_utf8_decode($_GET[$smart_get_keys[$i]]));
                }
            }
        }
        $u_login_logout = CMS_PAGE_LOGIN;
        $u_login_logout .= !empty($smart_redirect) ? '?redirect=' . $smart_redirect : '';
        $l_login_logout = $lang['Login'];
        $l_login_logout2 = $lang['Login'];
        $s_last_visit = '';
        $icon_pm = $images['pm_no_new_msg'];
        $l_privmsgs_text = $lang['Login_check_pm'];
        $l_privmsgs_text_unread = '';
        $s_privmsg_new = 0;
        $icon_private_chat = $images['private_chat'];
        $u_private_chat = '#';
    } else {
        if (!empty($user->data['user_popup_pm'])) {
            $template->assign_block_vars('switch_enable_pm_popup', array());
        }
        $u_login_logout = CMS_PAGE_LOGIN . '?logout=true&amp;sid=' . $user->data['session_id'];
        $l_login_logout = $lang['Logout'] . ' (' . $user->data['username'] . ')';
        $l_login_logout2 = $lang['Logout'];
        $s_last_visit = create_date($config['default_dateformat'], $user->data['user_lastvisit'], $config['board_timezone']);
        // DOWNLOADS ADV - BEGIN
        //@include(IP_ROOT_PATH . PLUGINS_PATH . $config['plugins']['downloads']['dir'] . 'includes/dl_page_header_inc.' . PHP_EXT);
        // DOWNLOADS ADV - END
        // Obtain number of new private messages
        if (empty($gen_simple_header)) {
            // Birthday - BEGIN
            // see if user has or have had birthday, also see if greeting are enabled
            if ($user->data['user_birthday'] != 999999 && $config['birthday_greeting'] && create_date('Ymd', time(), $config['board_timezone']) >= $user->data['user_next_birthday_greeting'] . realdate('md', $user->data['user_birthday'])) {
                if (!function_exists('birthday_pm_send')) {
                    include_once IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT;
                }
                birthday_pm_send();
            }
            // Birthday - END
            if ($user->data['user_profile_view'] && $user->data['user_profile_view_popup']) {
                $template->assign_vars(array('PROFILE_VIEW' => true, 'U_PROFILE_VIEW' => append_sid('profile_view_popup.' . PHP_EXT)));
            }
            if ($user->data['user_new_privmsg'] && !$config['privmsg_disable']) {
                $new_pm_switch = true;
                $l_message_new = $user->data['user_new_privmsg'] == 1 ? $lang['New_pm'] : $lang['New_pms'];
                $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
                if ($user->data['user_last_privmsg'] > $user->data['user_lastvisit']) {
                    $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\tSET user_last_privmsg = '" . $user->data['user_lastvisit'] . "'\n\t\t\t\t\t\tWHERE user_id = " . $user->data['user_id'];
                    $db->sql_query($sql);
                    $s_privmsg_new = 1;
                    $icon_pm = $images['pm_new_msg'];
                } else {
                    $s_privmsg_new = 0;
                    $icon_pm = $images['pm_new_msg'];
                }
            } else {
                $l_privmsgs_text = $lang['No_new_pm'];
                $s_privmsg_new = 0;
                $icon_pm = $images['pm_no_new_msg'];
            }
            $icon_private_chat = $images['private_chat'];
            if (!empty($user->data['user_private_chat_alert'])) {
                $new_private_chat_switch = true;
                $icon_private_chat = $images['private_chat_alert'];
                $ajax_chat_page = !empty($config['ajax_chat_link_type']) ? CMS_PAGE_AJAX_CHAT : CMS_PAGE_AJAX_SHOUTBOX;
                $ajax_chat_room = 'chat_room=' . $user->data['user_private_chat_alert'];
                $ajax_chat_link = append_sid($ajax_chat_page . '?' . $ajax_chat_room);
                $ajax_chat_ref = !empty($config['ajax_chat_link_type']) ? $ajax_chat_link . '" target="_chat' : '#" onclick="window.open(\'' . $ajax_chat_link . '\', \'_chat\', \'width=720,height=600,resizable=yes\'); $(\'#shoutbox_pvt_alert\').css(\'display\', \'none\'); return false;';
                $u_private_chat = $ajax_chat_ref;
            }
            if ($user->data['user_unread_privmsg']) {
                $l_message_unread = $user->data['user_unread_privmsg'] == 1 ? $lang['Unread_pm'] : $lang['Unread_pms'];
                $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']);
            } else {
                $l_privmsgs_text_unread = $lang['No_unread_pm'];
            }
        } else {
            $icon_pm = $images['pm_no_new_msg'];
            $l_privmsgs_text = $lang['Login_check_pm'];
            $l_privmsgs_text_unread = '';
            $s_privmsg_new = 0;
        }
        // We don't want this SQL being too expensive... so we will allow the number of new messages only for some pages... (you can add here other pages if you wish!)
        // We will also allow the number of new messages only for users which log on frequently
        $new_messages_counter_pages_array = array(CMS_PAGE_FORUM, CMS_PAGE_VIEWFORUM);
        $display_counter = $config['enable_new_messages_number'] && !$user->data['is_bot'] && in_array($page_url['basename'], $new_messages_counter_pages_array) && $user->data['user_lastvisit'] > time() - LAST_LOGIN_DAYS_NEW_POSTS_RESET * 60 * 60 * 24 ? true : false;
        if ($display_counter) {
            $auth_forum = '';
            if ($user->data['user_level'] != ADMIN) {
                if (!function_exists('auth_forum_read')) {
                    include_once IP_ROOT_PATH . 'includes/functions_upi2db.' . PHP_EXT;
                }
                $user->data['auth_forum_id'] = isset($user->data['auth_forum_id']) ? $user->data['auth_forum_id'] : auth_forum_read($user->data);
                $auth_forum = !empty($user->data['auth_forum_id']) ? ' AND p.forum_id IN (' . $user->data['auth_forum_id'] . ') ' : '';
            }
            $sql = "SELECT p.forum_id, t.topic_poster\n\t\t\t\tFROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t\n\t\t\t\tWHERE t.topic_id = p.topic_id\n\t\t\t\tAND p.post_time >= " . $user->data['user_lastvisit'] . $auth_forum . "\n\t\t\t\tAND p.poster_id != " . $user->data['user_id'];
            $db->sql_return_on_error(true);
            $result = $db->sql_query($sql);
            $db->sql_return_on_error(false);
            if ($result) {
                $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $user->data);
                $new_posts = 0;
                while ($row = $db->sql_fetchrow($result)) {
                    if (intval($is_auth_ary[$row['forum_id']]['auth_read']) != AUTH_SELF || $user->data['user_level'] == ADMIN || $user->data['user_level'] == MOD && $config['allow_mods_view_self'] == true || $row['topic_poster'] == $user->data['user_id']) {
                        $new_posts++;
                    }
                }
                $lang['Search_new'] = $lang['Search_new'] . ' (' . $new_posts . ')';
                $lang['New'] = $lang['New'] . ' (' . $new_posts . ')';
                $lang['NEW_POSTS_SHORT'] = $lang['New_Label'] . ' (' . $new_posts . ')';
                $lang['NEW_POSTS_LONG'] = $lang['New_Messages_Label'] . ' (' . $new_posts . ')';
                $lang['Search_new2'] = $lang['Search_new2'] . ' (' . $new_posts . ')';
                $lang['Search_new_p'] = $lang['Search_new_p'] . ' (' . $new_posts . ')';
                $db->sql_freeresult($result);
            }
        } else {
            $lang['NEW_POSTS_SHORT'] = $lang['New_Label'];
            $lang['NEW_POSTS_LONG'] = $lang['New_Messages_Label'];
        }
    }
    // LOGGED IN CHECK - END
    if (!defined('IN_CMS')) {
        // UPI2DB - BEGIN
        $upi2db_first_use = '';
        $u_display_new = array();
        if ($user->data['upi2db_access']) {
            $u_display_new = index_display_new($user->data['upi2db_unread']);
            $template->assign_block_vars('switch_upi2db_on', array());
            $template->assign_var('IS_UPI2DB', true);
            $upi2db_first_use = $user->data['user_upi2db_datasync'] == '0' ? '<script type="text/javascript">' . "\n" . '// <![CDATA[' . "\n" . 'alert ("' . $lang['upi2db_first_use_txt'] . '");' . "\n" . '// ]]>' . "\n" . '</script>' : '';
        } else {
            if ($user->data['session_logged_in']) {
                $template->assign_block_vars('switch_upi2db_off', array());
            }
        }
        // UPI2DB - END
        // Digests - BEGIN
        if (!empty($config['cron_digests_interval']) && $config['cron_digests_interval'] > 0) {
            if (!defined('DIGEST_SITE_URL')) {
                $digest_server_url = create_server_url();
                define('DIGEST_SITE_URL', $digest_server_url);
            }
            setup_extra_lang(array('lang_digests'));
            if ($user->data['session_logged_in']) {
                $template->assign_block_vars('switch_show_digests', array());
            }
        }
        // Digests - END
        // Visit Counter - BEGIN
        if ($config['visit_counter_switch']) {
            $sql = "UPDATE " . CONFIG_TABLE . "\n\t\t\t\t\tSET config_value = (config_value + 1)\n\t\t\t\t\tWHERE config_name = 'visit_counter'";
            $result = $db->sql_query($sql);
        }
        // Visit Counter - END
        // Mighty Gorgon - Random Quote - Begin
        $randomquote_phrase = '';
        if ($config['show_random_quote']) {
            @(include_once IP_ROOT_PATH . 'language/lang_' . $config['default_lang'] . '/lang_randomquote.' . PHP_EXT);
            $randomquote_phrase = $randomquote[rand(0, sizeof($randomquote) - 1)];
        }
        // Mighty Gorgon - Random Quote - End
        // Mighty Gorgon - Advanced Switches - END
        // Show Online Block - BEGIN
        // Get basic (usernames + totals) online situation
        $online_userlist = '';
        $l_online_users = '';
        $ac_online_users = array('reg' => 0, 'guests' => 0, 'tot' => 0, 'list' => '', 'text' => '');
        if (defined('SHOW_ONLINE') && !$user->data['is_bot']) {
            include IP_ROOT_PATH . 'includes/users_online_block.' . PHP_EXT;
        }
        // Show Online Block - END
        // CrackerTracker v5.x
        /*
         * CrackerTracker IP Range Scanner
         */
        $marknow = request_var('marknow', '');
        if ($marknow == 'ipfeature' && $user->data['session_logged_in']) {
            // Mark IP Feature Read
            $user->data['ct_last_ip'] = $user->data['ct_last_used_ip'];
            $sql = 'UPDATE ' . USERS_TABLE . ' SET ct_last_ip = ct_last_used_ip WHERE user_id=' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            if (!empty($_SERVER['HTTP_REFERER'])) {
                preg_match('#/([^/]*?)$#', $_SERVER['HTTP_REFERER'], $backlink);
                redirect($backlink[1]);
            }
        }
        if ($config['ctracker_login_ip_check'] == 1 && $user->data['ct_enable_ip_warn'] == 1 && $user->data['session_logged_in']) {
            include_once IP_ROOT_PATH . 'includes/ctracker/classes/class_ct_userfunctions.' . PHP_EXT;
            $ctracker_user = new ct_userfunctions();
            $check_ip_range = $ctracker_user->check_ip_range();
            if ($check_ip_range != 'allclear') {
                $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'ffdfdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => $check_ip_range, 'L_MARK_MESSAGE' => $lang['ctracker_gmb_markip'], 'U_MARK_MESSAGE' => append_sid('index.' . PHP_EXT . '?marknow=ipfeature')));
            }
        }
        /*
         * CrackerTracker Global Message Function
         */
        if ($marknow == 'globmsg' && $user->data['session_logged_in']) {
            // Mark Global Message as read
            $user->data['ct_global_msg_read'] = 0;
            $sql = 'UPDATE ' . USERS_TABLE . ' SET ct_global_msg_read = 0 WHERE user_id=' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            if (!empty($_SERVER['HTTP_REFERER'])) {
                preg_match('#/([^/]*?)$#', $_SERVER['HTTP_REFERER'], $backlink);
                redirect($backlink[1]);
            }
        }
        if ($user->data['ct_global_msg_read'] == 1 && $user->data['session_logged_in'] && $config['ctracker_global_message'] != '') {
            // Output Global Message
            $global_message_output = '';
            if ($config['ctracker_global_message_type'] == 1) {
                $global_message_output = $config['ctracker_global_message'];
            } else {
                $global_message_output = sprintf($lang['ctracker_gmb_link'], $config['ctracker_global_message'], $config['ctracker_global_message']);
            }
            $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'e1ffdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => $global_message_output, 'L_MARK_MESSAGE' => $lang['ctracker_gmb_mark'], 'U_MARK_MESSAGE' => append_sid('index.' . PHP_EXT . '?marknow=globmsg')));
        }
        if (($config['login_history'] == 1 || $config['login_ip_check'] == 1) && $user->data['session_logged_in']) {
            $template->assign_block_vars('login_sec_link', array());
        }
        /*
         * CrackerTracker Password Expiry Check
         */
        if ($user->data['session_logged_in'] && $config['ctracker_pw_control'] == 1) {
            $pwd_expiry_time = $user->data['user_passchg'] + (!empty($config['ctracker_pw_validity']) ? (int) $config['ctracker_pw_validity'] : 365) * 24 * 60 * 60;
            if (time() > $pwd_expiry_time) {
                $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'ffdfdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => sprintf($lang['ctracker_info_pw_expired'], $config['ctracker_pw_validity'], $user->data['user_id']), 'L_MARK_MESSAGE' => '', 'U_MARK_MESSAGE' => ''));
            }
        }
        /*
         * CrackerTracker Debug Mode Check
         */
        if (defined('CT_DEBUG_MODE') && CT_DEBUG_MODE === true && $user->data['user_level'] == ADMIN) {
            $template->assign_block_vars('ctracker_message', array('ROW_COLOR' => 'ffdfdf', 'ICON_GLOB' => $images['ctracker_note'], 'L_MESSAGE_TEXT' => $lang['ctracker_dbg_mode'], 'L_MARK_MESSAGE' => '', 'U_MARK_MESSAGE' => ''));
        }
        // CrackerTracker v5.x
        if ($config['switch_header_table']) {
            $template->assign_block_vars('switch_header_table', array('HEADER_TEXT' => $config['header_table_text'], 'L_STAFF_MESSAGE' => $lang['staff_message']));
        }
        if ($config['show_calendar_box_index']) {
            $path_parts = pathinfo($_SERVER['SCRIPT_NAME']);
            if ($path_parts['basename'] != CMS_PAGE_LOGIN) {
                if (!defined('IN_CALENDAR')) {
                    if (intval($config['calendar_header_cells']) > 0) {
                        $template->assign_block_vars('switch_calendar_box', array());
                        include_once IP_ROOT_PATH . 'includes/functions_calendar.' . PHP_EXT;
                        display_calendar('CALENDAR_BOX', intval($config['calendar_header_cells']));
                    }
                }
            }
        }
        $top_html_block_text = get_ad('glt');
        $header_banner_text = get_ad('glh');
        $nav_menu_ads_top = get_ad('nmt');
        $nav_menu_ads_bottom = get_ad('nmb');
        $social_connect_buttons = '';
        if (!empty($config['enable_social_connect'])) {
            include_once IP_ROOT_PATH . 'includes/class_social_connect.' . PHP_EXT;
            $available_networks = SocialConnect::get_available_networks();
            foreach ($available_networks as $social_network) {
                $social_connect_url = append_sid(CMS_PAGE_LOGIN . '?social_network=' . $social_network->get_name_clean());
                $social_connect_img = '<img src="' . IP_ROOT_PATH . 'images/social_connect/' . $social_network->get_name_clean() . '_button_connect.png" alt="" title="' . $social_network->get_name() . '" />';
                $social_connect_buttons .= '<a href="' . $social_connect_url . '">' . $social_connect_img . '</a>';
            }
        }
        // The following assigns all _common_ variables that may be used at any point in a template.
        $template->assign_vars(array('TOTAL_USERS_ONLINE' => $l_online_users, 'LOGGED_IN_USER_LIST' => $online_userlist, 'BOT_LIST' => !empty($online_botlist) ? $online_botlist : '', 'AC_LIST_TEXT' => $ac_online_users['text'], 'AC_LIST' => $ac_online_users['list'], 'RECORD_USERS' => sprintf($lang['Record_online_users'], $config['record_online_users'], create_date($config['default_dateformat'], $config['record_online_date'], $config['board_timezone'])), 'TOP_HTML_BLOCK' => $top_html_block_text, 'S_HEADER_BANNER' => empty($header_banner_text) ? false : true, 'HEADER_BANNER_CODE' => $header_banner_text, 'NAV_MENU_ADS_TOP' => $nav_menu_ads_top, 'NAV_MENU_ADS_BOTTOM' => $nav_menu_ads_bottom, 'L_SEARCH_NEW' => $lang['Search_new'], 'L_SEARCH_NEW2' => $lang['Search_new2'], 'L_NEW' => $lang['New'], 'L_NEW2' => empty($lang['NEW_POSTS_SHORT']) ? $lang['New_Label'] : $lang['NEW_POSTS_SHORT'], 'L_NEW3' => empty($lang['NEW_POSTS_LONG']) ? $lang['New_Messages_Label'] : $lang['NEW_POSTS_LONG'], 'L_POSTS' => $lang['Posts'], 'L_DISPLAY_ALL' => !empty($u_display_new) ? $u_display_new['all'] : '', 'L_DISPLAY_U' => !empty($u_display_new) ? $u_display_new['u'] : '', 'L_DISPLAY_M' => !empty($u_display_new) ? $u_display_new['m'] : '', 'L_DISPLAY_P' => !empty($u_display_new) ? $u_display_new['p'] : '', 'L_DISPLAY_UNREAD' => !empty($u_display_new) ? $u_display_new['unread'] : '', 'L_DISPLAY_MARKED' => !empty($u_display_new) ? $u_display_new['marked'] : '', 'L_DISPLAY_PERMANENT' => !empty($u_display_new) ? $u_display_new['permanent'] : '', 'L_DISPLAY_U_S' => !empty($u_display_new) ? $u_display_new['u_string_full'] : '', 'L_DISPLAY_M_S' => !empty($u_display_new) ? $u_display_new['m_string_full'] : '', 'L_DISPLAY_P_S' => !empty($u_display_new) ? $u_display_new['p_string_full'] : '', 'L_DISPLAY_UNREAD_S' => !empty($u_display_new) ? $u_display_new['unread_string'] : '', 'L_DISPLAY_MARKED_S' => !empty($u_display_new) ? $u_display_new['marked_string'] : '', 'L_DISPLAY_PERMANENT_S' => !empty($u_display_new) ? $u_display_new['permanent_string'] : '', 'U_DISPLAY_U' => !empty($u_display_new) ? $u_display_new['u_url'] : '', 'U_DISPLAY_M' => !empty($u_display_new) ? $u_display_new['m_url'] : '', 'U_DISPLAY_P' => !empty($u_display_new) ? $u_display_new['p_url'] : '', 'L_SEARCH_UNANSWERED' => $lang['Search_unanswered'], 'L_SEARCH_SELF' => $lang['Search_your_posts'], 'L_RECENT' => $lang['Recent_topics'], 'L_WATCHED_TOPICS' => $lang['Watched_Topics'], 'L_BOOKMARKS' => $lang['Bookmarks'], 'L_DIGESTS' => $lang['DIGESTS'], 'L_DRAFTS' => $lang['Drafts'], 'RANDOM_QUOTE' => $randomquote_phrase, 'L_LOGIN_SEC' => $lang['ctracker_gmb_loginlink'], 'U_LOGIN_SEC' => append_sid('ct_login_history.' . PHP_EXT), 'L_VIEWER' => $lang['Username'], 'L_NUMBER' => $lang['Views'], 'L_STAMP' => $lang['Last_updated'], 'L_YOUR_ACTIVITY' => $lang['Cpl_Personal_Profile'], 'L_PROFILE_EXPLAIN' => $lang['profile_explain'], 'L_PROFILE_MAIN' => $lang['profile_main'], 'L_CPL_NAV' => $lang['Profile'], 'L_CPL_REG_INFO' => $lang['Registration_info'], 'L_CPL_DELETE_ACCOUNT' => $lang['Delete_My_Account'], 'L_CPL_PROFILE_INFO' => $lang['Profile_info'], 'L_CPL_PROFILE_VIEWED' => $lang['Profile_viewed'], 'L_CPL_AVATAR_PANEL' => $lang['Avatar_panel'], 'L_CPL_SIG_EDIT' => $lang['sig_edit_link'], 'L_CPL_PREFERENCES' => $lang['Preferences'], 'L_CPL_SETTINGS_OPTIONS' => $lang['Cpl_Settings_Options'], 'L_CPL_BOARD_SETTINGS' => $lang['Cpl_Board_Settings'], 'L_CPL_MORE_INFO' => $lang['Cpl_More_info'], 'L_CPL_NEWMSG' => $lang['Cpl_NewMSG'], 'L_CPL_PERSONAL_PROFILE' => $lang['Cpl_Personal_Profile'], 'L_CPL_OWN_POSTS' => $lang['Search_your_posts'], 'L_CPL_OWN_PICTURES' => $lang['Personal_Gallery'], 'L_CPL_BOOKMARKS' => $lang['Bookmarks'], 'L_CPL_SUBSCFORUMS' => $lang['UCP_SubscForums'], 'L_CPL_PRIVATE_MESSAGES' => $lang['Private_Messages'], 'L_CPL_INBOX' => $lang['Inbox'], 'L_CPL_OUTBOX' => $lang['Outbox'], 'L_CPL_SAVEBOX' => $lang['Savebox'], 'L_CPL_SENTBOX' => $lang['Sentbox'], 'L_CPL_DRAFTS' => $lang['Drafts'], 'L_CPL_ZEBRA' => $lang['UCP_ZEBRA'], 'L_CPL_ZEBRA_EXPLAIN' => $lang['FRIENDS_EXPLAIN'], 'U_CPL_PROFILE_VIEWED' => append_sid('profile_view_user.' . PHP_EXT . '?' . POST_USERS_URL . '=' . $user->data['user_id']), 'U_CPL_NEWMSG' => append_sid(CMS_PAGE_PRIVMSG . '?mode=post'), 'U_CPL_REGISTRATION_INFO' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=reg_info'), 'U_CPL_DELETE_ACCOUNT' => append_sid('contact_us.' . PHP_EXT . '?account_delete=' . $user->data['user_id']), 'U_CPL_PROFILE_INFO' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=profile_info'), 'U_CPL_PREFERENCES' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=preferences'), 'U_CPL_BOARD_SETTINGS' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=board_settings'), 'U_CPL_AVATAR_PANEL' => append_sid(CMS_PAGE_PROFILE . '?mode=editprofile&amp;cpl_mode=avatar'), 'U_CPL_SIGNATURE' => append_sid(CMS_PAGE_PROFILE . '?mode=signature'), 'U_CPL_OWN_POSTS' => append_sid(CMS_PAGE_SEARCH . '?search_author=' . urlencode($user->data['username']) . '&amp;showresults=posts'), 'U_CPL_OWN_PICTURES' => append_sid('album.' . PHP_EXT . '?user_id=' . $user->data['user_id']), 'U_CPL_CALENDAR_SETTINGS' => append_sid('profile_options.' . PHP_EXT . '?sub=preferences&amp;module=calendar_settings&amp;' . POST_USERS_URL . '=' . $user->data['user_id']), 'U_CPL_SUBFORUM_SETTINGS' => append_sid('profile_options.' . PHP_EXT . '?sub=preferences&amp;module=forums_settings&amp;' . POST_USERS_URL . '=' . $user->data['user_id']), 'U_CPL_SUBSCFORUMS' => append_sid('subsc_forums.' . PHP_EXT), 'U_CPL_BOOKMARKS' => append_sid(CMS_PAGE_SEARCH . '?search_id=bookmarks'), 'U_CPL_INBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=inbox'), 'U_CPL_OUTBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=outbox'), 'U_CPL_SAVEBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=savebox'), 'U_CPL_SENTBOX' => append_sid(CMS_PAGE_PRIVMSG . '?folder=sentbox'), 'U_CPL_DRAFTS' => append_sid('drafts.' . PHP_EXT), 'U_CPL_ZEBRA' => append_sid(CMS_PAGE_PROFILE . '?mode=zebra&amp;zmode=friends'), 'SOCIAL_CONNECT_BUTTONS' => $social_connect_buttons, 'P_ACTIVITY_MOD_PATH' => PLUGINS_PATH . $config['plugins']['activity']['dir'], 'U_ACTIVITY' => append_sid('activity.' . PHP_EXT), 'L_ACTIVITY' => $lang['Activity']));
    }
    // The following assigns all _common_ variables that may be used at any point in a template.
    $current_time = create_date($config['default_dateformat'], time(), $config['board_timezone']);
    $template->assign_vars(array('DOCTYPE_HTML' => $doctype_html, 'HEADER_LANG' => $header_lang, 'NAV_LINKS' => $nav_links_html, 'S_HIGHSLIDE' => !empty($config['thumbnail_highslide']) ? true : false, 'S_HEADER_DROPDOWN' => $config['switch_header_dropdown'] ? true : false, 'S_HEADER_DD_LOGGED_IN' => $config['switch_header_dropdown'] && $user->data['upi2db_access'] ? true : false, 'S_AJAX_FEATURES' => !empty($config['ajax_features']) ? true : false, 'S_AJAX_USER_CHECK' => $ajax_user_check, 'S_AJAX_USER_CHECK_ALT' => $ajax_user_check_alt, 'U_LOGIN_LOGOUT' => append_sid(IP_ROOT_PATH . $u_login_logout), 'USER_USERNAME' => $user->data['session_logged_in'] ? htmlspecialchars($user->data['username']) : $lang['Guest'], 'UPI2DB_FIRST_USE' => $upi2db_first_use, 'L_PAGE_TITLE' => $meta_content['page_title_clean'], 'PAGE_TITLE' => $config['page_title_simple'] ? $meta_content['page_title_clean'] : $meta_content['page_title'], 'META_TAG' => $phpbb_meta, 'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit), 'CURRENT_TIME' => sprintf($lang['Current_time'], $current_time), 'CURRENT_TIME_ONLY' => $current_time, 'S_TIMEZONE' => $time_message, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, 'PRIVATE_MESSAGE_NEW_FLAG' => $s_privmsg_new, 'PRIVMSG_IMG' => $icon_pm, 'NEW_PM_SWITCH' => $new_pm_switch, 'PRIVATE_CHAT_IMG' => $icon_private_chat, 'U_PRIVATE_CHAT' => $u_private_chat, 'NEW_PRIVATE_CHAT_SWITCH' => $new_private_chat_switch, 'L_USERNAME' => $lang['Username'], 'L_PASSWORD' => $lang['Password'], 'L_LOGIN_LOGOUT' => $l_login_logout, 'L_LOGIN_LOGOUT2' => $l_login_logout2, 'L_LOGIN' => $lang['Login'], 'L_HOME' => $lang['Home'], 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_REGISTER' => $lang['Register'], 'L_BOARDRULES' => $lang['BoardRules'], 'L_PROFILE' => $lang['Profile'], 'L_CPL_NAV' => $lang['Profile'], 'L_SEARCH' => $lang['Search'], 'L_PRIVATEMSGS' => $lang['Private_Messages'], 'L_WHO_IS_ONLINE' => $lang['Who_is_Online'], 'L_MEMBERLIST' => $lang['Memberlist'], 'L_FAQ' => $lang['FAQ'], 'L_ADV_SEARCH' => $lang['Adv_Search'], 'L_SEARCH_EXPLAIN' => $lang['Search_Explain'], 'L_KB' => $lang['KB_title'], 'L_NEWS' => $lang['News_Cmx'], 'L_USERGROUPS' => $lang['Usergroups'], 'L_BOARD_DISABLE' => $lang['Board_disabled'], 'L_AJAX_SHOUTBOX' => $lang['Ajax_Chat'], 'L_BACK_TOP' => $lang['Back_to_top'], 'L_BACK_BOTTOM' => $lang['Back_to_bottom'], 'L_CALENDAR' => $lang['Calendar'], 'L_DOWNLOADS' => $lang['Downloads'], 'L_DOWNLOADS_ADV' => $lang['Downloads_ADV'], 'L_HACKS_LIST' => $lang['Hacks_List'], 'L_AVATAR_GEN' => $lang['AvatarGenerator'], 'L_LINKS' => $lang['Links'], 'L_WORDGRAPH' => $lang['Wordgraph'], 'L_ACRONYMS' => $lang['Acronyms'], 'L_SITEMAP' => $lang['Sitemap'], 'L_RANKS' => $lang['Rank_Header'], 'L_STAFF' => $lang['Staff'], 'L_CONTACT_US' => $lang['Contact_us'], 'L_UPLOAD_IMAGE' => $lang['Upload_Image_Local'], 'L_UPLOADED_IMAGES' => $lang['Uploaded_Images_Local'], 'L_ALBUM' => $lang['Album'], 'L_PIC_NAME' => $lang['Pic_Name'], 'L_DESCRIPTION' => $lang['Description'], 'L_GO' => $lang['Go'], 'L_SEARCH_CONTENTS' => $lang['Search_Contents'], 'L_SEARCH_MATCHES' => $lang['Search_Matches'], 'U_PREFERENCES' => append_sid('profile_options.' . PHP_EXT), 'L_PREFERENCES' => $lang['Preferences']));
    // get the nav sentence
    $nav_key = '';
    $nav_key = !empty($meta_content['cat_id']) ? POST_CAT_URL . $meta_content['cat_id'] : $nav_key;
    $nav_key = !empty($meta_content['forum_id']) ? POST_FORUM_URL . $meta_content['forum_id'] : $nav_key;
    $nav_key = !empty($meta_content['topic_id']) ? POST_TOPIC_URL . $meta_content['topic_id'] : $nav_key;
    $nav_key = !empty($meta_content['post_id']) ? POST_POST_URL . $meta_content['post_id'] : $nav_key;
    if (empty($nav_key)) {
        $selected_id = request_var('selected_id', 0);
        $nav_key = $selected_id < 0 ? 0 : $selected_id;
        $nav_key = empty($nav_key) ? 'Root' : $nav_key;
    }
    $nav_separator = empty($nav_separator) ? empty($lang['Nav_Separator']) ? '&nbsp;&raquo;&nbsp;' : $lang['Nav_Separator'] : $nav_separator;
    $nav_cat_desc = '';
    if (!isset($skip_nav_cat)) {
        $nav_pgm = empty($nav_pgm) ? '' : $nav_pgm;
        $nav_cat_desc = make_cat_nav_tree($nav_key, $nav_pgm, $meta_content);
    }
    if (!empty($nav_cat_desc)) {
        $nav_server_url = create_server_url();
        $nav_cat_desc = $nav_separator . $nav_cat_desc;
        $breadcrumbs['address'] = $nav_separator . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_FORUM) . '">' . $lang['Forum'] . '</a>' . $nav_cat_desc;
        if (isset($nav_add_page_title) && $nav_add_page_title == true) {
            $breadcrumbs['address'] = $breadcrumbs['address'] . $nav_separator . '<a href="#" class="nav-current">' . $meta_content['page_title'] . '</a>';
        }
    }
    // send to template
    $template->assign_vars(array('S_PAGE_NAV' => isset($cms_page['page_nav']) ? $cms_page['page_nav'] : true, 'NAV_SEPARATOR' => $nav_separator, 'NAV_CAT_DESC' => $nav_cat_desc, 'BREADCRUMBS_ADDRESS' => empty($breadcrumbs['address']) ? $meta_content['page_title_clean'] != $config['sitename'] ? $lang['Nav_Separator'] . '<a href="#" class="nav-current">' . $meta_content['page_title_clean'] . '</a>' : '' : $breadcrumbs['address'], 'S_BREADCRUMBS_BOTTOM_LEFT_LINKS' => empty($breadcrumbs['bottom_left_links']) ? false : true, 'BREADCRUMBS_BOTTOM_LEFT_LINKS' => empty($breadcrumbs['bottom_left_links']) ? '&nbsp;' : $breadcrumbs['bottom_left_links'], 'S_BREADCRUMBS_BOTTOM_RIGHT_LINKS' => empty($breadcrumbs['bottom_right_links']) ? false : true, 'BREADCRUMBS_BOTTOM_RIGHT_LINKS' => empty($breadcrumbs['bottom_right_links']) ? '&nbsp;' : $breadcrumbs['bottom_right_links']));
    if ($config['board_disable'] && $user->data['user_level'] == ADMIN) {
        $template->assign_block_vars('switch_admin_disable_board', array());
    }
    if (!defined('IN_CMS')) {
        $cms_page['global_blocks'] = empty($cms_page['global_blocks']) ? false : true;
        //$cms_page['global_blocks'] = ((!isset($cms_page['page_id']) || !$cms_page['global_blocks']) ? false : true);
        $cms_page_blocks = empty($cms_page['page_id']) || empty($cms_config_layouts[$cms_page['page_id']]) ? false : true;
        if (empty($gen_simple_header) && !defined('HAS_DIED') && !defined('IN_LOGIN') && ($cms_page['global_blocks'] || $cms_page_blocks) && (!$config['board_disable'] || $user->data['user_level'] == ADMIN)) {
            $template->assign_var('SWITCH_CMS_GLOBAL_BLOCKS', true);
            $ip_cms->cms_parse_blocks($cms_page['page_id'], !empty($cms_page['page_id']), $cms_page['global_blocks'], 'header');
            if ($ip_cms->cms_parse_blocks($cms_page['page_id'], !empty($cms_page['page_id']), $cms_page['global_blocks'], 'headerleft')) {
                $template->assign_vars(array('HEADER_WIDTH' => $cms_config_vars['header_width'], 'HL_BLOCK' => true));
            }
            if ($ip_cms->cms_parse_blocks($cms_page['page_id'], !empty($cms_page['page_id']), $cms_page['global_blocks'], 'headercenter')) {
                $template->assign_var('HC_BLOCK', true);
            }
        }
        if (empty($gen_simple_header)) {
            if ($ip_cms->cms_parse_blocks(0, true, true, 'gheader')) {
                $template->assign_var('GH_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghtop')) {
                $template->assign_var('GT_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghbottom')) {
                $template->assign_var('GB_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghleft')) {
                $template->assign_var('GL_BLOCK', true);
            }
            if ($ip_cms->cms_parse_blocks(0, true, true, 'ghright')) {
                $template->assign_var('GR_BLOCK', true);
            }
        }
        if (defined('PARSE_CPL_NAV')) {
            $template->set_filenames(array('cpl_menu_output' => 'profile_cpl_menu.tpl'));
            $template->assign_var_from_handle('CPL_MENU_OUTPUT', 'cpl_menu_output');
        }
    }
    if ($user->data['user_level'] != ADMIN && $config['board_disable'] && !defined('HAS_DIED') && !defined('IN_ADMIN') && !defined('IN_LOGIN')) {
        if (!defined('STATUS_503')) {
            define('STATUS_503', true);
        }
        if ($config['board_disable_mess_st']) {
            message_die(GENERAL_MESSAGE, $config['board_disable_message']);
        } else {
            message_die(GENERAL_MESSAGE, $lang['Board_disabled']);
        }
    }
    if (!defined('AJAX_HEADERS')) {
        // application/xhtml+xml not used because of IE
        $encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
        header('Content-type: text/html; charset=' . $encoding_charset);
        header('Cache-Control: private, no-cache="set-cookie"');
        header('Expires: 0');
        header('Pragma: no-cache');
    }
    if ($parse_template) {
        $header_tpl = empty($gen_simple_header) ? 'overall_header.tpl' : 'simple_header.tpl';
        $template->set_filenames(array('overall_header' => $header_tpl));
        $template->pparse('overall_header');
    }
    define('HEADER_INC_COMPLETED', true);
    return;
}
Example #24
0
 /**
  * Sets up the Syndication Specific template variables.
  *
  * @param integer Overides the number of items to be rendered.
  * @return void
  *
  * @access public
  */
 function renderSyndication($num_items = 0)
 {
     global $lang;
     $encoding = $lang['ENCODING'];
     $sitename = $this->config['sitename'] . ' :: RSS';
     $copyright = $this->config['sitename'] . ' :: ' . gmdate('Y', time());
     $server_url = create_server_url();
     $this->setVariables(array('NEWS_TITLE' => $this->config['sitename'], 'URL' => $server_url, 'FORUM_PATH' => $this->config['script_path'], 'DESC' => $this->config['news_rss_desc'], 'LANGUAGE' => $this->config['news_rss_language'], 'COPYRIGHT' => $copyright, 'EDITOR' => $this->config['board_email'], 'WEBMASTER' => $this->config['board_email'], 'TTL' => $this->config['news_rss_ttl'], 'CATEGORY' => $this->config['news_rss_cat'], 'GENERATOR' => $sitename, 'CONTENT_ENCODING' => $encoding, 'PUB_DATE' => gmdate('r', gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('y')))));
     if ($this->config['news_rss_image'] != '' && $this->config['news_rss_image_desc'] != '') {
         $this->setBlockVariables('image', array('IMAGE' => $this->config['news_rss_image'], 'IMAGE_TITLE' => $this->config['news_rss_image_desc']));
     }
     $this->item_count = 1;
     $catid = request_var('cat_id', 0);
     if ($num_items > 0) {
         $this->data->setItemCount($num_items);
     } else {
         $this->data->setItemCount($this->config['news_rss_item_count']);
     }
     $articles = $this->data->fetchArticles(0, $catid);
     $this->prepareArticles($articles, $this->config['news_rss_show_abstract'], false);
 }
Example #25
0
	redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=' . 'tellafriend.' . PHP_EXT . '&topic_title=' . urlencode($topic_title) . '&topic_id=' . $topic_id .'&topic_url=' . urlencode($topic_url), true));
}

if (($config['url_rw'] == true) || ($config['url_rw_guests'] == true))
{
	$topic_link = create_server_url() . make_url_friendly($topic_title) . '-vt' . $topic_id . '.html';
}
else
{
	$topic_link = create_server_url() . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id;
}

// Was an URl sent instead of a topic id?
if (($topic_id == 0) && ($topic_url != ''))
{
	$topic_link = create_server_url() . $topic_url;
}

$mail_body = str_replace("{TOPIC}", htmlspecialchars_decode($topic_title), $lang['TELL_FRIEND_BODY']);
$mail_body = str_replace("{LINK}", $topic_link, $mail_body);
$mail_body = str_replace("{SITENAME}", $config['sitename'], $mail_body);

$template->assign_vars(array(
	'SUBMIT_ACTION' => append_sid($PHP_SELF, true),
	'L_SUBMIT' => $lang['Send_email'],
	'SITENAME' => $config['sitename'],

	'SENDER_NAME' => $user->data['username'],
	'SENDER_MAIL' => $user->data['user_email'],

	'L_TELL_FRIEND_BODY' => $mail_body,
 /**
  * Send user notifications on new topic or reply
  */
 function send_notifications($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user)
 {
     global $config, $lang, $db, $user;
     global $bbcode;
     $current_time = time();
     include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT;
     if ($mode != 'delete') {
         if ($mode == 'reply') {
             // Look for users with notification enabled
             $sql = "SELECT u.user_id, u.user_email, u.user_lang, u.username, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . TOPICS_WATCH_TABLE . " tw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE tw.topic_id = " . $topic_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('tw.user_id', $this->exclude_users, true, true) . "\n\t\t\t\t\t\tAND tw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND u.user_id = tw.user_id\n\t\t\t\t\t\tAND u.user_active = 1";
             $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {
                 if (!in_array($row['user_id'], $this->notify_userid)) {
                     if ($row['user_email'] != '') {
                         $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']);
                     }
                     $this->notify_userid[] = $row['user_id'];
                     $this->notify_forum_name = $row['forum_name'];
                 }
             }
             $db->sql_freeresult($result);
         }
         if ($mode == 'newtopic' || $mode == 'reply') {
             // Reply or New Topic forum notification
             $sql = "SELECT u.user_id, u.user_email, u.user_lang, f.forum_name\n\t\t\t\t\tFROM " . USERS_TABLE . " u, " . FORUMS_WATCH_TABLE . " fw, " . FORUMS_TABLE . " f\n\t\t\t\t\tWHERE fw.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND " . $db->sql_in_set('fw.user_id', array_merge($this->exclude_users, $this->notify_userid), true, true) . "\n\t\t\t\t\t\tAND fw.notify_status = " . TOPIC_WATCH_UN_NOTIFIED . "\n\t\t\t\t\t\tAND f.forum_id = " . $forum_id . "\n\t\t\t\t\t\tAND f.forum_notify = '1'\n\t\t\t\t\t\tAND u.user_id = fw.user_id\n\t\t\t\t\t\tAND u.user_active = 1";
             $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {
                 if (!in_array($row['user_id'], $this->notify_userid)) {
                     if ($row['user_email'] != '') {
                         $this->notify_userdata[] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'user_lang' => $row['user_lang']);
                     }
                     $this->notify_userid[] = $row['user_id'];
                     $this->notify_forum_name = $row['forum_name'];
                 }
             }
             $db->sql_freeresult($result);
         }
         // Users array built, so start sending notifications
         if (sizeof($this->notify_userdata) > 0) {
             include_once IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT;
             $emailer = new emailer();
             $server_url = create_server_url();
             $topic_title = unprepare_message($topic_title);
             $topic_title = censor_text($topic_title);
             $post_text = unprepare_message($post_data['message']);
             $post_text = censor_text($post_text);
             if (!empty($config['html_email'])) {
                 $bbcode->allow_bbcode = !empty($config['allow_bbcode']) ? $config['allow_bbcode'] : false;
                 $bbcode->allow_html = !empty($config['allow_html']) ? $config['allow_html'] : false;
                 $bbcode->allow_smilies = !empty($config['allow_smilies']) ? $config['allow_smilies'] : false;
                 $post_text = $bbcode->parse($post_text);
             } else {
                 $post_text = $bbcode->plain_message($post_text, '');
             }
             for ($i = 0; $i < sizeof($this->notify_userdata); $i++) {
                 $emailer->use_template('topic_notify', $this->notify_userdata[$i]['user_lang']);
                 $emailer->bcc($this->notify_userdata[$i]['user_email']);
                 // 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']);
                 // This is a nasty kludge to remove the username var ... till (if?) translators update their templates
                 $emailer->msg = preg_replace('#[ ]?{USERNAME}#', $this->notify_userdata[$i]['username'], $emailer->msg);
                 if ($config['url_rw'] == '1') {
                     $topic_url = $server_url . str_replace('--', '-', make_url_friendly($topic_title) . '-vp' . $post_id . '.html#p' . $post_id);
                 } else {
                     $topic_url = $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id . '#p' . $post_id;
                 }
                 $email_sig = create_signature($config['board_email_sig']);
                 $emailer->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'TOPIC_TITLE' => $topic_title, 'POST_TEXT' => $post_text, 'POSTERNAME' => $post_data['username'], 'FORUM_NAME' => $this->notify_forum_name, 'ROOT' => $server_url, 'U_TOPIC' => $topic_url, 'U_STOP_WATCHING_TOPIC' => $server_url . CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic_id . '&unwatch=topic'));
                 $emailer->send();
                 $emailer->reset();
             }
         }
         // Emails sent, so set users were notified
         $sql = "UPDATE " . TOPICS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE topic_id = " . $topic_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true);
         $db->sql_query($sql);
         $sql = "UPDATE " . FORUMS_WATCH_TABLE . "\n\t\t\t\tSET notify_status = " . TOPIC_WATCH_NOTIFIED . "\n\t\t\t\tWHERE forum_id = " . $forum_id . "\n\t\t\t\tAND " . $db->sql_in_set('user_id', $this->notify_userid, false, true);
         $db->sql_query($sql);
         // Delete notification for poster if present, or re-activate it if requested
         if (!$notify_user && !empty($row['topic_id'])) {
             $this->delete_topic_watch($user->data['user_id'], $topic_id);
         } elseif ($notify_user && empty($row['topic_id'])) {
             $this->delete_topic_watch($user->data['user_id'], $topic_id);
             $this->insert_topic_watch($user->data['user_id'], $topic_id, $forum_id, TOPIC_WATCH_UN_NOTIFIED);
         }
     }
 }
    private function init_posting()
    {
        global $db, $config, $user, $lang;
        include IP_ROOT_PATH . 'includes/functions_post.' . PHP_EXT;
        $sql = 'SELECT *
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . (int) $this->poster_id;
        $result = $db->sql_query($sql);
        $poster_data = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        // backward posting (from the oldest to the newest)
        $i = sizeof($this->items) > $this->posting_limit ? $this->posting_limit - 1 : sizeof($this->items);
        $j = 0;
        while ($i >= 0 && ($this->posting_limit == 0 || $this->posting_limit > $j)) {
            $subject = substr($this->items[$i]['title'], 0, 254);
            // check if this topic is not already posted
            $sql = 'SELECT topic_title
					FROM ' . TOPICS_TABLE . '
					WHERE topic_title = "' . $db->sql_escape($subject) . '"
						AND topic_poster = ' . (int) $this->poster_id;
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            // Do we have a new item to post ?
            if (strnatcasecmp($row['topic_title'], $subject)) {
                // templates RSS / ATOM has different indexes for messages
                $temp = $this->feed_type == 'rss' || $this->feed_type == 'rdf' ? 'description' : 'content';
                $message = $this->html_to_bbcode($this->feed_name . "\n\n" . $this->items[$i][$temp]);
                $post_time = time();
                // Icy Phoenix Posting - BEGIN
                // Force the user to be admin to avoid flood check...
                $user->data['user_level'] = ADMIN;
                $topic_title_clean = substr(ip_clean_string($subject, $lang['ENCODING']), 0, 254);
                $forum_id = $this->poster_forum_destination_id;
                $topic_id = 0;
                $post_id = 0;
                $post_mode = 'newtopic';
                $post_data = array();
                $poll_data = array('title' => '', 'start' => time(), 'length' => 0, 'max_options' => 1, 'change' => 0);
                if (POSTING_DEBUG) {
                    die($subject . '<br /><br />' . $message);
                } else {
                    prepare_post($post_mode, $post_data, 1, 0, 0, '', $poster_data['username'], $subject, $message, '', array(), $poll_data, '', '', '', '', '', '', '', 0, 0);
                    submit_post($post_mode, $post_data, '', '', $forum_id, $topic_id, $post_id, $topic_type, 1, 0, 1, 0, 1, $poster_data['username'], $subject, $topic_title_clean, '', $message, '', '', $poll_data, '', '', '', '', '', '', 0, 0, false, '', 0, 0);
                }
                // Icy Phoenix Posting - END
            }
            // change $i to the next (ehm previous :D ) item
            $i--;
            $j++;
        }
        // TODO rebuild/sync forums latest topics and post counts
        // redirect to index
        if (!$this->cron_init) {
            redirect(create_server_url());
        }
    }
Example #28
0
	{
		header ('Cache-Control: no-cache, pre-check=0, post-check=0, max-age=0');
	}
	else
	{
		header ('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
	}
	header('Last-Modified: ' . $MyGMTtime);
	header('Etag: ' . $MyETag);
	header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
	header ('Content-Type: text/xml; charset=' . $encoding_charset);
	readfile($cache_data_file);
}
else
{
	$server_url = create_server_url();

	// GYM
	$xml_urlset = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

	$xml_sitemap_header = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>
' . $xml_urlset . '
	<url>
		<loc>' . $server_url . '</loc>
		<changefreq>always</changefreq>
		<priority>1.0</priority>
	</url>';
	$xml_sitemap_body = '';
	$xml_sitemap_footer = '
</urlset>';
Example #29
0
        unset($file_urls);
        unset($userfiles);
        unset($locations);
        foreach ($data as $mirror_id => $mirror_data) {
            $file_upload = empty($mirror_data['download_url']) ? true : false;
            $file_remote_url = !empty($mirror_data['download_url']) ? $mirror_data['download_url'] : '';
            $file_local = $mirror_data['tmp_name'] !== 'none' ? $mirror_data['tmp_name'] : '';
            $file_realname = $mirror_data['name'] !== 'none' ? $mirror_data['name'] : '';
            $file_size = !empty($mirror_data['size']) ? $mirror_data['size'] : '';
            $file_type = !empty($mirror_data['type']) ? $mirror_data['type'] : '';
            $mirror_location = !empty($mirror_data['location']) ? $mirror_data['location'] : '';
            $pafiledb->mirror_add_update($file_id, $file_upload, $file_remote_url, $file_local, $file_realname, $file_size, $file_type, $mirror_location, $mirror_id);
        }
        unset($data);
    }
    $sql = 'SELECT f.*
		FROM ' . PA_MIRRORS_TABLE . " AS f\n\t\tWHERE f.file_id = '" . $file_id . "'\n\t\tORDER BY mirror_id";
    $result = $db->sql_query($sql);
    $mirrors_data = array();
    while ($row = $db->sql_fetchrow($result)) {
        $mirrors_data[$row['mirror_id']] = $row;
    }
    $template->assign_vars(array('ROW_NOT_EMPTY' => empty($mirrors_data) ? false : true, 'FILESIZE' => intval($pafiledb_config['max_file_size']), 'L_MIRROR_LOCATION' => $lang['Mirror_location'], 'L_FILE_UPLOAD' => $lang['File_upload'], 'L_FILE_DELETE' => $lang['Delete'], 'L_DELETE' => $lang['Delete_selected'], 'L_FILEINFO_UPLOAD' => $lang['Fileinfo_upload'], 'L_UPLOADED_FILE' => $lang['Uploaded_file'], 'L_FILE_URL' => $lang['Fileurl'], 'L_FILE_URL_INFO' => $lang['Fileurl'], 'L_MODIFY' => $lang['Efiletitle'], 'L_ADD_NEW' => $lang['Afiletitle'], 'L_ADD_NEW_MIRROR' => $lang['Add_new_mirror']));
    foreach ($mirrors_data as $mirror_id => $mirror_data) {
        $template->assign_block_vars('row', array('LOCATION' => $mirror_data['mirror_location'], 'MIRROR_ID' => $mirror_id, 'MIRROR_URL' => $mirror_data['file_dlurl'], 'MIRROR_FILE' => $mirror_data['unique_name'], 'U_UPLOADED_MIRROR' => create_server_url() . '/' . $mirror_data['file_dir'] . $mirror_data['unique_name']));
    }
}
$template->assign_vars(array('ERROR' => sizeof($pafiledb->error) ? implode('<br />', $pafiledb->error) : ''));
$template->display('admin');
$pafiledb->_pafiledb();
include IP_ROOT_PATH . ADM . '/page_footer_admin.' . PHP_EXT;