コード例 #1
0
ファイル: ajax.php プロジェクト: hungnv0789/vhtm
			$getoptions = convert_bits_to_array($calendarinfo['options'], $_CALENDAROPTIONS);
			$geteaster = convert_bits_to_array($calendarinfo['holidays'], $_CALENDARHOLIDAYS);
			$calendarinfo = array_merge($calendarinfo, $getoptions, $geteaster);
		}
	}
	if ($vbulletin->GPC['parsetype'] == 'announcement')
	{	// oh this is a kludge but there is no simple way to changing the bbcode parser from using global $post with announcements without changing function arguments
		$post = array(
			'announcementoptions' => $vbulletin->GPC['allowbbcode'] ? $vbulletin->bf_misc_announcementoptions['allowbbcode'] : 0
		);
	}

	if ($vbulletin->GPC['towysiwyg'])
	{
		// from standard to wysiwyg
		$xml->add_tag('message', process_replacement_vars(parse_wysiwyg_html(htmlspecialchars_uni($vbulletin->GPC['message']), false, $vbulletin->GPC['parsetype'], $vbulletin->GPC['allowsmilie'])));
	}
	else
	{
		// from wysiwyg to standard
		switch ($vbulletin->GPC['parsetype'])
		{
			case 'calendar':
				$dohtml = $calendarinfo['allowhtml']; break;

			case 'privatemessage':
				$dohtml = $vbulletin->options['privallowhtml']; break;

			case 'usernote':
				$dohtml = $vbulletin->options['unallowhtml']; break;
コード例 #2
0
/**
* Prepares the templates for a message editor
*
* @param	string	The text to be initially loaded into the editor
* @param	boolean	Is the initial text HTML (rather than plain text or bbcode)?
* @param	mixed	Forum ID of the forum into which we are posting. Special rules apply for values of 'privatemessage', 'usernote', 'calendar', 'announcement' and 'nonforum'. Can be an object of vB_Editor_Override as well.
* @param	boolean	Allow smilies?
* @param	boolean	Parse smilies in the text of the message?
* @param	boolean	Allow attachments?
* @param	string	Editor type - either 'fe' for full editor or 'qr' for quick reply
* @param	string	Force the editor to use the specified value as its editorid, rather than making one up
* @param	array		Information for the image popup
* @param	array		Content type handled by this editor, used to set specific CSS
*
* @return	string	Editor ID
*/
function construct_edit_toolbar($text = '', $ishtml = false, $forumid = 0, $allowsmilie = true, $parsesmilie = true, $can_attach = false, $editor_type = 'fe', $force_editorid = '', $attachinfo = array(), $content = 'content')
{
    // standard stuff
    global $vbulletin, $vbphrase, $show;
    // templates generated by this function
    global $messagearea, $smiliebox, $disablesmiliesoption, $checked, $vBeditTemplate;
    // misc stuff built by this function
    global $istyles;
    // counter for editorid
    static $editorcount = 0;
    if (is_object($forumid) and $forumid instanceof vB_Editor_Override) {
        $editor_override = $forumid;
    } else {
        $editor_override = null;
    }
    // determine what we can use
    // this was moved up here as I need the switch to determine if bbcode is enabled
    // to determine if a toolbar is usable
    if ($forumid == 'signature') {
        $sig_perms =& $vbulletin->userinfo['permissions']['signaturepermissions'];
        $sig_perms_bits =& $vbulletin->bf_ugp_signaturepermissions;
        $can_toolbar = $sig_perms & $sig_perms_bits['canbbcode'] ? true : false;
        $show['img_bbcode'] = $sig_perms & $sig_perms_bits['allowimg'] ? true : false;
        $show['font_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodefont'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_FONT) ? true : false;
        $show['size_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodesize'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_SIZE) ? true : false;
        $show['color_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodecolor'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_COLOR) ? true : false;
        $show['basic_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodebasic'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_BASIC) ? true : false;
        $show['align_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodealign'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ALIGN) ? true : false;
        $show['list_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodelist'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_LIST) ? true : false;
        $show['code_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodecode'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_CODE) ? true : false;
        $show['html_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodehtml'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_HTML) ? true : false;
        $show['php_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodephp'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_PHP) ? true : false;
        $show['url_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodelink'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL) ? true : false;
        $show['quote_bbcode'] = $sig_perms & $sig_perms_bits['canbbcodequote'] ? true : false;
    } else {
        require_once DIR . '/includes/class_bbcode.php';
        $show['font_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_FONT ? true : false;
        $show['size_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_SIZE ? true : false;
        $show['color_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_COLOR ? true : false;
        $show['basic_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_BASIC ? true : false;
        $show['align_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ALIGN ? true : false;
        $show['list_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_LIST ? true : false;
        $show['code_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_CODE ? true : false;
        $show['html_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_HTML ? true : false;
        $show['php_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_PHP ? true : false;
        $show['url_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL ? true : false;
        $show['quote_bbcode'] = true;
        // can't disable this anywhere but in sigs
    }
    $ajax_extra = '';
    $allow_custom_bbcode = true;
    if (empty($forumid)) {
        $forumid = 'nonforum';
    }
    switch ($forumid) {
        case 'privatemessage':
            $can_toolbar = $vbulletin->options['privallowbbcode'];
            $show['img_bbcode'] = $vbulletin->options['privallowbbimagecode'];
            break;
        case 'calendar':
            global $calendarinfo;
            $can_toolbar = $calendarinfo['allowbbcode'];
            $show['img_bbcode'] = $calendarinfo['allowimgcode'];
            $ajax_extra = "calendarid={$calendarinfo['calendarid']}";
            break;
        case 'announcement':
            $can_toolbar = true;
            $show['img_bbcode'] = true;
            break;
        case 'signature':
            // see above -- these are handled earlier
            break;
        case 'visitormessage':
        case 'groupmessage':
        case 'picturecomment':
            switch ($forumid) {
                case 'groupmessage':
                    $allowedoption = $vbulletin->options['sg_allowed_bbcode'];
                    break;
                case 'picturecomment':
                    $allowedoption = $vbulletin->options['pc_allowed_bbcode'];
                    break;
                default:
                    $allowedoption = $vbulletin->options['vm_allowed_bbcode'];
                    break;
            }
            $show['font_bbcode'] = ($show['font_bbcode'] and $allowedoption & ALLOW_BBCODE_FONT) ? true : false;
            $show['size_bbcode'] = ($show['size_bbcode'] and $allowedoption & ALLOW_BBCODE_SIZE) ? true : false;
            $show['color_bbcode'] = ($show['color_bbcode'] and $allowedoption & ALLOW_BBCODE_COLOR) ? true : false;
            $show['basic_bbcode'] = ($show['basic_bbcode'] and $allowedoption & ALLOW_BBCODE_BASIC) ? true : false;
            $show['align_bbcode'] = ($show['align_bbcode'] and $allowedoption & ALLOW_BBCODE_ALIGN) ? true : false;
            $show['list_bbcode'] = ($show['list_bbcode'] and $allowedoption & ALLOW_BBCODE_LIST) ? true : false;
            $show['code_bbcode'] = ($show['code_bbcode'] and $allowedoption & ALLOW_BBCODE_CODE) ? true : false;
            $show['html_bbcode'] = ($show['html_bbcode'] and $allowedoption & ALLOW_BBCODE_HTML) ? true : false;
            $show['php_bbcode'] = ($show['php_bbcode'] and $allowedoption & ALLOW_BBCODE_PHP) ? true : false;
            $show['url_bbcode'] = ($show['url_bbcode'] and $allowedoption & ALLOW_BBCODE_URL) ? true : false;
            $show['quote_bbcode'] = ($show['quote_bbcode'] and $allowedoption & ALLOW_BBCODE_QUOTE) ? true : false;
            $show['img_bbcode'] = $allowedoption & ALLOW_BBCODE_IMG ? true : false;
            $can_toolbar = ($show['font_bbcode'] or $show['size_bbcode'] or $show['color_bbcode'] or $show['basic_bbcode'] or $show['align_bbcode'] or $show['list_bbcode'] or $show['code_bbcode'] or $show['html_bbcode'] or $show['php_bbcode'] or $show['url_bbcode'] or $show['quote_bbcode'] or $show['img_bbcode']);
            $allow_custom_bbcode = $allowedoption & ALLOW_BBCODE_CUSTOM ? true : false;
            break;
        case 'nonforum':
            $can_toolbar = $vbulletin->options['allowbbcode'];
            $show['img_bbcode'] = $vbulletin->options['allowbbimagecode'];
            break;
        default:
            if ($editor_override) {
                $editor_settings = $editor_override->get_editor_settings();
                $can_toolbar = $editor_settings['can_toolbar'];
                $allow_custom_bbcode = $editor_settings['allow_custom_bbcode'];
                // note: set $show variables directly as necessary in your get_editor_settings function
            } else {
                if (intval($forumid)) {
                    $forum = fetch_foruminfo($forumid);
                    $can_toolbar = $forum['allowbbcode'];
                    $show['img_bbcode'] = $forum['allowimages'];
                } else {
                    $can_toolbar = false;
                    $show['img_bbcode'] = false;
                }
            }
            // Legacy Hook 'editor_toolbar_switch' Removed //
            break;
    }
    // set the editor mode
    if (isset($_REQUEST['wysiwyg'])) {
        // 2 = wysiwyg; 1 = standard
        if ($_REQUEST['wysiwyg']) {
            $vbulletin->userinfo['showvbcode'] = 2;
        } else {
            if ($vbulletin->userinfo['showvbcode'] == 0) {
                $vbulletin->userinfo['showvbcode'] = 0;
            } else {
                $vbulletin->userinfo['showvbcode'] = 1;
            }
        }
    }
    $toolbartype = $can_toolbar ? is_wysiwyg_compatible(-1, $editor_type) : 0;
    $show['wysiwyg_compatible'] = is_wysiwyg_compatible(2, $editor_type) == 2;
    $show['editor_toolbar'] = $toolbartype > 0;
    $templater = vB_Template::create('editor_toolbar_colors');
    $colors = $templater->render();
    switch ($editor_type) {
        case 'qr':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QR';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 100;
            $editor_template_name = 'showthread_quickreply';
            break;
        case 'qr_small':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QR';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 60;
            $editor_template_name = 'showthread_quickreply';
            break;
        case 'qr_pm':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QR';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 120;
            $editor_template_name = 'pm_quickreply';
            break;
        case 'qe':
        case 'qenr':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QE';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 200;
            $editor_template_name = 'postbit_quickedit';
            break;
            /*
            		case 'qenr':
            			if ($force_editorid == '')
            			{
            				$editorid = 'vB_Editor_QE';
            			}
            			else
            			{
            				$editorid = $force_editorid;
            			}
            
            			$editor_height = 200;
            
            			$editor_template_name = 'memberinfo_quickedit';
            			break;
            */
        /*
        		case 'qenr':
        			if ($force_editorid == '')
        			{
        				$editorid = 'vB_Editor_QE';
        			}
        			else
        			{
        				$editorid = $force_editorid;
        			}
        
        			$editor_height = 200;
        
        			$editor_template_name = 'memberinfo_quickedit';
        			break;
        */
        default:
            if ($editor_override) {
                $editorcount++;
                $editor_info = $editor_override->get_editor_type(array('force_editorid' => $force_editorid, 'editor_count' => $editorcount, 'editor_type' => $editor_type, 'toolbar_type' => $toolbartype));
                $editorid = $editor_info['editor_id'];
                $editor_height = $editor_info['editor_height'];
                $editor_template_name = $editor_info['editor_template_name'];
            } else {
                if ($force_editorid == '') {
                    $editorid = 'vB_Editor_' . str_pad(++$editorcount, 3, 0, STR_PAD_LEFT);
                } else {
                    $editorid = $force_editorid;
                }
                // set the height of the editor based on the editor_height cookie if it exists
                $editor_height = $vbulletin->input->clean_gpc('c', 'editor_height', vB_Cleaner::TYPE_UINT);
                $editor_height = $editor_height > 100 ? $editor_height : 250;
                $editor_template_name = $toolbartype ? 'editor_toolbar_on' : 'editor_toolbar_off';
            }
            break;
    }
    // init the variables used by the templates built by this function
    $vBeditJs = array('normalmode' => 'false');
    $vBeditTemplate = array('clientscript' => '', 'fontfeedback' => '', 'sizefeedback' => '', 'smiliepopup' => '');
    $extrabuttons = '';
    // Legacy Hook 'editor_toolbar_start' Removed //
    // show a post editing toolbar of some sort
    if ($show['editor_toolbar']) {
        if ($can_attach) {
            $show['attach'] = true;
        }
        // get extra buttons... experimental at the moment
        $extrabuttons = construct_editor_extra_buttons($editorid, $allow_custom_bbcode);
        if ($toolbartype == 2 or defined('VB_API') and VB_API === true) {
            // got to parse the message to be displayed from bbcode into HTML
            if ($text !== '') {
                if ($editor_override) {
                    $newpost['message'] = $editor_override->parse_for_wysiwyg($text, array('allowsmilies' => $allowsmilie and $parsesmilie, 'ishtml' => $ishtml));
                } else {
                    require_once DIR . '/includes/functions_wysiwyg.php';
                    $newpost['message'] = parse_wysiwyg_html($text, $ishtml, $forumid, iif($allowsmilie and $parsesmilie, 1, 0));
                }
            } else {
                $newpost['message'] = '';
            }
            $newpost['message'] = htmlspecialchars($newpost['message']);
            if (defined('VB_API') and VB_API === true) {
                if ($ishtml) {
                    $newpost['message_bbcode'] = convert_wysiwyg_html_to_bbcode($text);
                } else {
                    $newpost['message_bbcode'] = $text;
                }
            }
        } else {
            $newpost['message'] = $text;
            // set mode based on cookie set by javascript
            /*$vbulletin->input->clean_gpc('c', COOKIE_PREFIX . 'vbcodemode', vB_Cleaner::TYPE_INT);
            		$modechecked[$vbulletin->GPC[COOKIE_PREFIX . 'vbcodemode']] = 'checked="checked"';*/
        }
    } else {
        // do not show a post editing toolbar
        $newpost['message'] = $text;
    }
    // disable smilies option and clickable smilie
    $show['smiliebox'] = false;
    $smiliebox = '';
    $smiliepopup = '';
    $disablesmiliesoption = '';
    if ($editor_type == 'qr' or $editor_type == 'qr_small') {
        // no smilies
    } else {
        if ($allowsmilie and $show['editor_toolbar']) {
            // deal with disable smilies option
            if (!isset($checked['disablesmilies'])) {
                $vbulletin->input->clean_gpc('r', 'disablesmilies', vB_Cleaner::TYPE_BOOL);
                $checked['disablesmilies'] = iif($vbulletin->GPC['disablesmilies'], 'checked="checked"');
            }
            $templater = vB_Template::create('newpost_disablesmiliesoption');
            $templater->register('checked', $checked);
            $disablesmiliesoption = $templater->render();
            if ($toolbartype and $vbulletin->options['wysiwyg_smtotal'] > 0) {
                // query smilies
                $smilies = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT smilieid, smilietext, smiliepath, smilie.title,\n\t\t\t\t\timagecategory.title AS category\n\t\t\t\tFROM " . TABLE_PREFIX . "smilie AS smilie\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "imagecategory AS imagecategory USING(imagecategoryid)\n\t\t\t\tORDER BY imagecategory.displayorder, imagecategory.title, smilie.displayorder\n\t\t\t");
                // get total number of smilies
                $totalsmilies = $vbulletin->db->num_rows($smilies);
                if ($totalsmilies > 0) {
                    if ($vbulletin->options['wysiwyg_smtotal'] > 0) {
                        $show['wysiwygsmilies'] = true;
                        // smilie dropdown menu
                        $i = 0;
                        while ($smilie = $vbulletin->db->fetch_array($smilies)) {
                            if ($prevcategory != $smilie['category']) {
                                $prevcategory = $smilie['category'];
                                $templater = vB_Template::create('editor_smilie_category');
                                $templater->register('smilie', $smilie);
                                $smiliepopup .= $templater->render();
                            }
                            if ($i++ < $vbulletin->options['wysiwyg_smtotal']) {
                                $templater = vB_Template::create('editor_smilie_row');
                                $templater->register('smilie', $smilie);
                                $smiliepopup .= $templater->render();
                            } else {
                                $show['moresmilies'] = true;
                                break;
                            }
                        }
                    } else {
                        $show['wysiwygsmilies'] = false;
                    }
                    $vbulletin->db->free_result($smilies);
                }
            }
        }
    }
    // Legacy Hook 'editor_toolbar_end' Removed //
    $templater = vB_Template::create('editor_clientscript');
    $templater->register('vBeditJs', $vBeditJs);
    $templater->register('attachinfo', $attachinfo);
    $values = '';
    if (!empty($attachinfo['values'])) {
        foreach ($attachinfo['values'] as $key => $value) {
            $values .= "\n\t\t\t\t\t{$key}: '" . addslashes_js($value) . "',\n\t\t\t\t";
        }
    }
    $templater->register('values', $values);
    $vBeditTemplate['clientscript'] = $templater->render();
    $ajax_extra = addslashes_js($ajax_extra);
    $editortype = $toolbartype == 2 ? 1 : 0;
    $show['is_wysiwyg_editor'] = intval($editortype);
    $templater = vB_Template::create($editor_template_name);
    $templater->register('extrabuttons', $extrabuttons);
    $templater->register('ajax_extra', $ajax_extra);
    $templater->register('editorid', $editorid);
    $templater->register('editortype', $editortype);
    $templater->register('editor_height', $editor_height);
    $templater->register('forumid', $editor_override ? $editor_override->get_parse_type() : $forumid);
    $templater->register('istyles', $istyles);
    $templater->register('newpost', $newpost);
    $templater->register('parsesmilie', $parsesmilie);
    $templater->register('smiliebox', $smiliebox);
    $templater->register('vBeditTemplate', $vBeditTemplate);
    $templater->register('fontnames', $fontnames);
    $templater->register('fontsizes', $fontsizes);
    $templater->register('colors', $colors);
    $templater->register('smiliepopup', $smiliepopup);
    $templater->register('attachinfo', $attachinfo);
    $templater->register('content', $content);
    $messagearea = $templater->render();
    return $editorid;
}
コード例 #3
0
ファイル: functions_editor.php プロジェクト: holandacz/nb4
/**
* Prepares the templates for a message editor
*
* @param	string	The text to be initially loaded into the editor
* @param	boolean	Is the initial text HTML (rather than plain text or bbcode)?
* @param	mixed	Forum ID of the forum into which we are posting. Special rules apply for values of 'privatemessage', 'usernote', 'calendar', 'announcement' and 'nonforum'
* @param	boolean	Allow smilies?
* @param	boolean	Parse smilies in the text of the message?
* @param	boolean	Allow attachments?
* @param	string	Editor type - either 'fe' for full editor or 'qr' for quick reply
* @param	string	Force the editor to use the specified value as its editorid, rather than making one up
*
* @return	string	Editor ID
*/
function construct_edit_toolbar($text = '', $ishtml = false, $forumid = 0, $allowsmilie = true, $parsesmilie = true, $can_attach = false, $editor_type = 'fe', $force_editorid = '')
{
    // standard stuff
    global $vbulletin, $vbphrase, $stylevar, $show;
    // templates generated by this function
    global $messagearea, $smiliebox, $disablesmiliesoption, $checked, $vBeditTemplate;
    // misc stuff built by this function
    global $istyles;
    // counter for editorid
    static $editorcount = 0;
    // determine what we can use
    // this was moved up here as I need the switch to determine if bbcode is enabled
    // to determine if a toolbar is usable
    if ($forumid == 'signature') {
        $sig_perms =& $vbulletin->userinfo['permissions']['signaturepermissions'];
        $sig_perms_bits =& $vbulletin->bf_ugp_signaturepermissions;
        $can_toolbar = $sig_perms & $sig_perms_bits['canbbcode'] ? true : false;
        $show['img_bbcode'] = $sig_perms & $sig_perms_bits['allowimg'] ? true : false;
        $show['font_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodefont'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_FONT) ? true : false;
        $show['size_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodesize'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_SIZE) ? true : false;
        $show['color_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodecolor'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_COLOR) ? true : false;
        $show['basic_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodebasic'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_BASIC) ? true : false;
        $show['align_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodealign'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ALIGN) ? true : false;
        $show['list_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodelist'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_LIST) ? true : false;
        $show['code_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodecode'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_CODE) ? true : false;
        $show['html_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodehtml'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_HTML) ? true : false;
        $show['php_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodephp'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_PHP) ? true : false;
        $show['url_bbcode'] = ($sig_perms & $sig_perms_bits['canbbcodelink'] and $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL) ? true : false;
        $show['quote_bbcode'] = $sig_perms & $sig_perms_bits['canbbcodequote'] ? true : false;
    } else {
        require_once DIR . '/includes/class_bbcode.php';
        $show['font_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_FONT ? true : false;
        $show['size_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_SIZE ? true : false;
        $show['color_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_COLOR ? true : false;
        $show['basic_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_BASIC ? true : false;
        $show['align_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ALIGN ? true : false;
        $show['list_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_LIST ? true : false;
        $show['code_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_CODE ? true : false;
        $show['html_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_HTML ? true : false;
        $show['php_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_PHP ? true : false;
        $show['url_bbcode'] = $vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL ? true : false;
        $show['quote_bbcode'] = true;
        // can't disable this anywhere but in sigs
    }
    $ajax_extra = '';
    $allow_custom_bbcode = true;
    if (empty($forumid)) {
        $forumid = 'nonforum';
    }
    switch ($forumid) {
        case 'privatemessage':
            $can_toolbar = $vbulletin->options['privallowbbcode'];
            $show['img_bbcode'] = $vbulletin->options['privallowbbimagecode'];
            break;
        case 'usernote':
            $can_toolbar = $vbulletin->options['unallowvbcode'];
            $show['img_bbcode'] = $vbulletin->options['unallowimg'];
            break;
        case 'calendar':
            global $calendarinfo;
            $can_toolbar = $calendarinfo['allowbbcode'];
            $show['img_bbcode'] = $calendarinfo['allowimgcode'];
            $ajax_extra = "calendarid={$calendarinfo['calendarid']}";
            break;
        case 'announcement':
            $can_toolbar = true;
            $show['img_bbcode'] = true;
            break;
        case 'signature':
            // see above -- these are handled earlier
            break;
        case 'visitormessage':
        case 'groupmessage':
        case 'picturecomment':
            switch ($forumid) {
                case 'groupmessage':
                    $allowedoption = $vbulletin->options['sg_allowed_bbcode'];
                    break;
                case 'picturecomment':
                    $allowedoption = $vbulletin->options['pc_allowed_bbcode'];
                    break;
                default:
                    $allowedoption = $vbulletin->options['vm_allowed_bbcode'];
                    break;
            }
            $show['font_bbcode'] = ($show['font_bbcode'] and $allowedoption & ALLOW_BBCODE_FONT) ? true : false;
            $show['size_bbcode'] = ($show['size_bbcode'] and $allowedoption & ALLOW_BBCODE_SIZE) ? true : false;
            $show['color_bbcode'] = ($show['color_bbcode'] and $allowedoption & ALLOW_BBCODE_COLOR) ? true : false;
            $show['basic_bbcode'] = ($show['basic_bbcode'] and $allowedoption & ALLOW_BBCODE_BASIC) ? true : false;
            $show['align_bbcode'] = ($show['align_bbcode'] and $allowedoption & ALLOW_BBCODE_ALIGN) ? true : false;
            $show['list_bbcode'] = ($show['list_bbcode'] and $allowedoption & ALLOW_BBCODE_LIST) ? true : false;
            $show['code_bbcode'] = ($show['code_bbcode'] and $allowedoption & ALLOW_BBCODE_CODE) ? true : false;
            $show['html_bbcode'] = ($show['html_bbcode'] and $allowedoption & ALLOW_BBCODE_HTML) ? true : false;
            $show['php_bbcode'] = ($show['php_bbcode'] and $allowedoption & ALLOW_BBCODE_PHP) ? true : false;
            $show['url_bbcode'] = ($show['url_bbcode'] and $allowedoption & ALLOW_BBCODE_URL) ? true : false;
            $show['quote_bbcode'] = ($show['quote_bbcode'] and $allowedoption & ALLOW_BBCODE_QUOTE) ? true : false;
            $show['img_bbcode'] = $allowedoption & ALLOW_BBCODE_IMG ? true : false;
            $can_toolbar = ($show['font_bbcode'] or $show['size_bbcode'] or $show['color_bbcode'] or $show['basic_bbcode'] or $show['align_bbcode'] or $show['list_bbcode'] or $show['code_bbcode'] or $show['html_bbcode'] or $show['php_bbcode'] or $show['url_bbcode'] or $show['quote_bbcode'] or $show['img_bbcode']);
            $allow_custom_bbcode = $allowedoption & ALLOW_BBCODE_CUSTOM ? true : false;
            break;
        case 'nonforum':
            $can_toolbar = $vbulletin->options['allowbbcode'];
            $show['img_bbcode'] = $vbulletin->options['allowbbimagecode'];
            break;
        default:
            if (intval($forumid)) {
                $forum = fetch_foruminfo($forumid);
                $can_toolbar = $forum['allowbbcode'];
                $show['img_bbcode'] = $forum['allowimages'];
            } else {
                $can_toolbar = false;
                $show['img_bbcode'] = false;
            }
            ($hook = vBulletinHook::fetch_hook('editor_toolbar_switch')) ? eval($hook) : false;
            break;
    }
    // set the editor mode
    if (isset($_REQUEST['wysiwyg'])) {
        // 2 = wysiwyg; 1 = standard
        if ($_REQUEST['wysiwyg']) {
            $vbulletin->userinfo['showvbcode'] = 2;
        } else {
            if ($vbulletin->userinfo['showvbcode'] == 0) {
                $vbulletin->userinfo['showvbcode'] = 0;
            } else {
                $vbulletin->userinfo['showvbcode'] = 1;
            }
        }
    }
    $toolbartype = $can_toolbar ? is_wysiwyg_compatible(-1, $editor_type) : 0;
    $show['wysiwyg_compatible'] = is_wysiwyg_compatible(2, $editor_type) == 2;
    $show['editor_toolbar'] = $toolbartype > 0;
    switch ($editor_type) {
        case 'qr':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QR';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 100;
            $editor_template_name = 'showthread_quickreply';
            break;
        case 'qr_small':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QR';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 60;
            $editor_template_name = 'showthread_quickreply';
            break;
        case 'qe':
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_QE';
            } else {
                $editorid = $force_editorid;
            }
            $editor_height = 200;
            $editor_template_name = 'postbit_quickedit';
            break;
        default:
            if ($force_editorid == '') {
                $editorid = 'vB_Editor_' . str_pad(++$editorcount, 3, 0, STR_PAD_LEFT);
            } else {
                $editorid = $force_editorid;
            }
            // set the height of the editor based on the editor_height cookie if it exists
            $editor_height = $vbulletin->input->clean_gpc('c', 'editor_height', TYPE_UINT);
            $editor_height = $editor_height > 100 ? $editor_height : 250;
            $editor_template_name = $toolbartype ? 'editor_toolbar_on' : 'editor_toolbar_off';
            break;
    }
    // init the variables used by the templates built by this function
    $vBeditJs = array('font_options_array' => '', 'size_options_array' => '', 'istyle_array' => '', 'normalmode' => 'false');
    $vBeditTemplate = array('extrabuttons' => '', 'clientscript' => '', 'fontfeedback' => '', 'sizefeedback' => '', 'smiliepopup' => '');
    ($hook = vBulletinHook::fetch_hook('editor_toolbar_start')) ? eval($hook) : false;
    // show a post editing toolbar of some sort
    if ($show['editor_toolbar']) {
        if ($can_attach) {
            $show['attach'] = true;
        }
        $vBeditJs = construct_editor_js_arrays();
        // get extra buttons... experimental at the moment
        $vBeditTemplate['extrabuttons'] = construct_editor_extra_buttons($editorid, $allow_custom_bbcode);
        if ($toolbartype == 2) {
            // got to parse the message to be displayed from bbcode into HTML
            if ($text !== '') {
                require_once DIR . '/includes/functions_wysiwyg.php';
                $newpost['message'] = parse_wysiwyg_html($text, $ishtml, $forumid, iif($allowsmilie and $parsesmilie, 1, 0));
            } else {
                $newpost['message'] = '';
            }
            $newpost['message'] = htmlspecialchars($newpost['message']);
        } else {
            $newpost['message'] = $text;
            // set mode based on cookie set by javascript
            /*$vbulletin->input->clean_gpc('c', COOKIE_PREFIX . 'vbcodemode', TYPE_INT);
            		$modechecked[$vbulletin->GPC[COOKIE_PREFIX . 'vbcodemode']] = 'checked="checked"';*/
        }
    } else {
        // do not show a post editing toolbar
        $newpost['message'] = $text;
    }
    // disable smilies option and clickable smilie
    $show['smiliebox'] = false;
    $smiliebox = '';
    $disablesmiliesoption = '';
    if ($editor_type == 'qr' or $editor_type == 'qr_small') {
        // no smilies
    } else {
        if ($allowsmilie and $show['editor_toolbar']) {
            // deal with disable smilies option
            if (!isset($checked['disablesmilies'])) {
                $vbulletin->input->clean_gpc('r', 'disablesmilies', TYPE_BOOL);
                $checked['disablesmilies'] = iif($vbulletin->GPC['disablesmilies'], 'checked="checked"');
            }
            eval('$disablesmiliesoption = "' . fetch_template('newpost_disablesmiliesoption') . '";');
            if ($toolbartype and ($vbulletin->options['smtotal'] > 0 or $vbulletin->options['wysiwyg_smtotal'] > 0)) {
                // query smilies
                $smilies = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT smilieid, smilietext, smiliepath, smilie.title,\n\t\t\t\t\timagecategory.title AS category\n\t\t\t\tFROM " . TABLE_PREFIX . "smilie AS smilie\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "imagecategory AS imagecategory USING(imagecategoryid)\n\t\t\t\tORDER BY imagecategory.displayorder, imagecategory.title, smilie.displayorder\n\t\t\t");
                // get total number of smilies
                $totalsmilies = $vbulletin->db->num_rows($smilies);
                if ($totalsmilies > 0) {
                    if ($vbulletin->options['wysiwyg_smtotal'] > 0) {
                        $show['wysiwygsmilies'] = true;
                        // smilie dropdown menu
                        $vBeditJs['smilie_options_array'] = array();
                        $i = 0;
                        while ($smilie = $vbulletin->db->fetch_array($smilies)) {
                            if (empty($prevcategory)) {
                                $prevcategory = $smilie['category'];
                            }
                            if ($i++ < $vbulletin->options['wysiwyg_smtotal']) {
                                $vBeditJs['smilie_options_array']["{$smilie['category']}"][] = "\t\t'{$smilie['smilieid']}' : new Array('" . addslashes_js($smilie['smiliepath']) . "', '" . addslashes_js($smilie['smilietext']) . "', '" . addslashes_js($smilie['title']) . "')";
                            } else {
                                $vBeditJs['smilie_options_array']["{$prevcategory}"][] = "\t\t'more' : '" . addslashes_js($vbphrase['show_all_smilies']) . "'\n";
                                break;
                            }
                            $prevcategory = $smilie['category'];
                        }
                        foreach (array_keys($vBeditJs['smilie_options_array']) as $category) {
                            $vBeditJs['smilie_options_array']["{$category}"] = "\t'" . addslashes_js($category) . "' : {\n" . implode(",\n", $vBeditJs['smilie_options_array']["{$category}"]) . "}";
                        }
                        $vBeditJs['smilie_options_array'] = "\n" . implode(",\n", $vBeditJs['smilie_options_array']);
                    } else {
                        $show['wysiwygsmilies'] = false;
                    }
                    // clickable smilie box
                    if ($vbulletin->options['smtotal']) {
                        $vbulletin->db->data_seek($smilies, 0);
                        $i = 0;
                        $bits = array();
                        while ($smilie = $vbulletin->db->fetch_array($smilies) and $i++ < $vbulletin->options['smtotal']) {
                            $smiliehtml = "<img src=\"{$smilie['smiliepath']}\" id=\"{$editorid}_smilie_{$smilie['smilieid']}\" alt=\"" . htmlspecialchars_uni($smilie['smilietext']) . "\" title=\"" . htmlspecialchars_uni($smilie['title']) . "\" border=\"0\" class=\"inlineimg\" />";
                            eval('$bits[] = "' . fetch_template('editor_smilie') . '";');
                            if (sizeof($bits) == $vbulletin->options['smcolumns']) {
                                $smiliecells = implode('', $bits);
                                eval('$smiliebits .= "' . fetch_template('editor_smiliebox_row') . '";');
                                $bits = array();
                            }
                        }
                        // fill in empty cells if required
                        $remaining = sizeof($bits);
                        if ($remaining > 0) {
                            $remainingcolumns = $vbulletin->options['smcolumns'] - $remaining;
                            eval('$bits[] = "' . fetch_template('editor_smiliebox_straggler') . '";');
                            $smiliecells = implode('', $bits);
                            eval('$smiliebits .= "' . fetch_template('editor_smiliebox_row') . '";');
                        }
                        $show['moresmilieslink'] = iif($totalsmilies > $vbulletin->options['smtotal'], true, false);
                        $show['smiliebox'] = true;
                    }
                    $vbulletin->db->free_result($smilies);
                }
            }
            eval('$smiliebox = "' . fetch_template('editor_smiliebox') . '";');
        }
    }
    ($hook = vBulletinHook::fetch_hook('editor_toolbar_end')) ? eval($hook) : false;
    // check that $editor_css has been built
    if (!isset($GLOBALS['editor_css'])) {
        eval('$GLOBALS[\'editor_css\'] = "' . fetch_template('editor_css') . '";');
        $GLOBALS['headinclude'] .= "<!-- Editor CSS automatically added by " . substr(strrchr(__FILE__, DIRECTORY_SEPARATOR), 1) . " at line " . __LINE__ . " -->\n" . $GLOBALS['editor_css'];
    }
    eval('$vBeditTemplate[\'clientscript\'] = "' . fetch_template('editor_clientscript') . '";');
    $ajax_extra = addslashes_js($ajax_extra);
    $editortype = $toolbartype == 2 ? 1 : 0;
    $show['is_wysiwyg_editor'] = intval($editortype);
    eval('$messagearea = "' . fetch_template($editor_template_name) . '";');
    return $editorid;
}
コード例 #4
0
ファイル: newreply.php プロジェクト: hungnv0789/vhtm
	$xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');

	$quote_text = fetch_quotable_posts($quote_postids, $threadinfo['threadid'], $unquoted_post_count, $quoted_post_ids, 'other', true);

	if ($vbulletin->GPC['type'] == 'deselect')
	{
		$remaining = array_diff($quote_postids, $quoted_post_ids);
		$xml->add_tag('mqpostids', implode(',', $remaining));
		//setcookie('vbulletin_multiquote', implode(',', $remaining), 0, '/');
	}
	else
	{
		if ($vbulletin->GPC['wysiwyg'])
		{
			require_once(DIR . '/includes/functions_wysiwyg.php');
			$quote_text = parse_wysiwyg_html(htmlspecialchars_uni($quote_text), false, $threadinfo['forumid'], ($foruminfo['allowsmilies'] ? 1 : 0));
		}

		$xml->add_tag('quotes', process_replacement_vars($quote_text));
	}

	$xml->print_xml();
}

// ############################### start post reply ###############################
if ($_POST['do'] == 'postreply')
{
	// Variables reused in templates
	$posthash =& $vbulletin->input->clean_gpc('p', 'posthash', TYPE_NOHTML);
	$poststarttime =& $vbulletin->input->clean_gpc('p', 'poststarttime', TYPE_UINT);
コード例 #5
0
ファイル: ajax.php プロジェクト: holandacz/nb4
         $do_html = $photoplog_catoptions['allowhtml'] ? 1 : 0;
         $do_imgcode = $photoplog_catoptions['allowimgcode'] ? 1 : 0;
     }
 }
 $vbulletin->GPC['message'] = convert_urlencoded_unicode($vbulletin->GPC['message']);
 if ($photoplog_fileversion == 6) {
     $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
 }
 require_once DIR . '/includes/functions_wysiwyg.php';
 if ($vbulletin->GPC['towysiwyg']) {
     if ($do_imgcode) {
         $vbulletin->GPC['message'] = preg_replace("/\\[img\\]/i", "photoplog_front_vb_bb_img_tag", $vbulletin->GPC['message']);
         $vbulletin->GPC['message'] = preg_replace("/\\[\\/img\\]/i", "photoplog_back_vb_bb_img_tag", $vbulletin->GPC['message']);
     }
     ob_start();
     echo parse_wysiwyg_html(htmlspecialchars_uni($vbulletin->GPC['message']), false, $vbulletin->GPC['parsetype'], $vbulletin->GPC['allowsmilie']);
     $photoplog_html_output = ob_get_contents();
     ob_end_clean();
     if ($do_imgcode) {
         $photoplog_html_output = str_replace(array('photoplog_front_vb_bb_img_tag', 'photoplog_back_vb_bb_img_tag'), array('<img src="', '">'), $photoplog_html_output);
     }
     $photoplog_html_output = str_replace("src=\"images/smilies/", "src=\"" . $vbulletin->options['bburl'] . "/images/smilies/", $photoplog_html_output);
     if ($photoplog_fileversion == 6) {
         $xml->add_tag('message', $photoplog_html_output);
     } else {
         echo $photoplog_html_output;
     }
 } else {
     switch ($vbulletin->GPC['parsetype']) {
         case 'nonforum':
             $dohtml = $do_html;
コード例 #6
0
ファイル: ajax.php プロジェクト: holandacz/nb4
 $vbulletin->GPC['message'] = convert_urlencoded_unicode($vbulletin->GPC['message']);
 $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
 require_once DIR . '/includes/functions_wysiwyg.php';
 if ($vbulletin->GPC['parsetype'] == 'calendar') {
     require_once DIR . '/includes/functions_calendar.php';
     $vbulletin->input->clean_gpc('p', 'calendarid', TYPE_UINT);
     $calendarinfo = verify_id('calendar', $vbulletin->GPC['calendarid'], 0, 1);
     if ($calendarinfo) {
         $getoptions = convert_bits_to_array($calendarinfo['options'], $_CALENDAROPTIONS);
         $geteaster = convert_bits_to_array($calendarinfo['holidays'], $_CALENDARHOLIDAYS);
         $calendarinfo = array_merge($calendarinfo, $getoptions, $geteaster);
     }
 }
 if ($vbulletin->GPC['towysiwyg']) {
     // from standard to wysiwyg
     $xml->add_tag('message', parse_wysiwyg_html($vbulletin->GPC['message'], false, $vbulletin->GPC['parsetype'], $vbulletin->GPC['allowsmilie']));
 } else {
     // from wysiwyg to standard
     switch ($vbulletin->GPC['parsetype']) {
         case 'calendar':
             $dohtml = $calendarinfo['allowhtml'];
             break;
         case 'privatemessage':
             $dohtml = $vbulletin->options['privallowhtml'];
             break;
         case 'usernote':
             $dohtml = $vbulletin->options['unallowhtml'];
             break;
         case 'nonforum':
             $dohtml = $vbulletin->options['allowhtml'];
             break;