View Single Post
  #4  
Old 02-05-2011, 02:15 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@al3bed:
Yeah, that's what I said. X3 And yeah, I also said I hard-refreshed (Ctrl+Shift+R in FireFox, loads page ignoring cache). Adding a php.ini file inside the forum directory shouldn't do anything--my webserver is set to use only one php.ini file, after all. XD

@ForumsMods:
No, the options are uncommented (semicolon removed from the start of the line). As I said, the changes did take in the test PHP file, but did not take in the vBulletin forum.

I'm not sure if I am using post cache. Where can I find out about that?

--------------- Added [DATE]1296890277[/DATE] at [TIME]1296890277[/TIME] ---------------

Solved. Kind of.



First, I downloaded GeSHi.
http://qbnz.com/highlighter/

I uploaded the geshi folder to my includes directory, along with the geshi.php file.

I created a custom BBCode, PHPS.

I added a new plugin at bbcode_create with the following:
PHP Code:

$this
->tag_list['no_option']['phps'] = array ();
$this->tag_list['no_option']['phps']['callback'] = 'handle_external';
$this->tag_list['no_option']['phps']['external_callback'] = 'handle_geshi_php';
if (!
function_exists ('handle_geshi_php'))
{
  function 
handle_geshi_php(&$theobj, &$value, &$option)
  {
    require_once(
DIR '/includes/geshi.php');
    
$geshi = new GeSHi($value'php');
    return 
'<div class="bbcode_container"><div class="bbcode_description">PHP Code:</div><pre style="height:300px;" class="bbcode_code">'.$geshi->parse_code().'</pre></div>';
  }




I'll likely use this for JavaScript and several things that vBulletin does not support by default.

I recommend it to you other Admins that need syntax highlighting, too. :>

--------------- Added [DATE]1296893984[/DATE] at [TIME]1296893984[/TIME] ---------------

THough it was "solved" above, I learned that I was having trouble with some HTML entities.

Below is the complete PHP for the bbcode_create hook which eliminates all those problems.

PHP Code:
$this->tag_list['no_option']['phps'] = array ();
$this->tag_list['no_option']['phps']['callback'] = 'handle_external';
$this->tag_list['no_option']['phps']['external_callback'] = 'handle_geshi_php';
if (!
function_exists ('handle_geshi_php'))
{
  function 
handle_geshi_php(&$theobj, &$value, &$option)
  {
    require_once(
DIR '/includes/geshi.php');
    if (!
is_array($codefind1))
    {
      
$codefind1 = array('<br>','<br />');
      
$codereplace1 = array('','');
      
$codefind2 = array('&gt;','&lt;','&quot;','&amp;','[',']',);
      
$codereplace2 = array('>','<','"','&','[',']',);
    }
    
$code rtrim(str_replace($codefind1$codereplace1$value));
    
$code str_replace($codefind2$codereplace2$code); // finish replacements
    
$geshi = new GeSHi($code'php');
    
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
    
$code $geshi->parse_code();
    
$code preg_replace('/&amp;#([0-9]+);/''&#$1;'$code);
    
$code str_replace(array('['']'), array('['']'), $code);
    return 
'<div class="bbcode_container"><div class="bbcode_description">PHP Code:</div><div style="height: 300px;" class="bbcode_code">'.$code.'</div></div>';
  }


Yay
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01110 seconds
  • Memory Usage 1,810KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete