The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Highlight and link function names inside code Details »» | |||||||||||||||||||||||||||
Highlight and link function names inside code
Developer Last Online: Nov 2024
Here's a nice idea I got from another site, which highlights all function names in PHP code and links to their documentary. In this hack the functions are linked to PHP.NET's docs.
Needless to add this is perfect for sites that deal with PHP coding. Demo: Code:
if(!$dohtml) { // kill any rogue html code // $bbcode=str_replace("&","&",$bbcode); $bbcode=str_replace("<","&lt;",$bbcode); $bbcode=str_replace(">","&gt;",$bbcode); $bbcode=str_replace("<","<",$bbcode); $bbcode=str_replace(">",">",$bbcode); } $bbcode=nl2br($bbcode); To install this hack download the attached file (linkfuncs.hack.php), upload to your /admin folder and use vbHacker. Have fun! Show Your Support
|
Comments |
#12
|
|||
|
|||
i have it where members can enable and disable it in options but for some reason, even if you disable it, it still shows, heres the code
[php] if ($bbuserinfo[userid]==0 or $bbuserinfo[showfunclinks]==1) { /* Highlight function names in [php] */ $allfuncs = get_defined_functions(); $searches = array(); $replaces = array(); foreach ($allfuncs['internal'] as $name) { $searches[] = "/([^a-z])$name(<\/font><font color=\"" . ini_get('highlight.keyword') . "\">){0,1}( {0,1})\(<\/font>/i"; $replaces[] = "\\1<a href=\"http://www.php.net/$name\" target=\"_blank\">$name</a>\\2\\3(</font>"; } $buffer = preg_replace($searches, $replaces, $buffer); /* end Highlight function names in PHP Code:
|
#13
|
||||
|
||||
Make sure $bbuserinfo is global in that function.
|
#14
|
|||
|
|||
Hmm, it got rid of the links but the highlighting is still there and it shows ?> at the end of the php code
|
#15
|
|||
|
|||
also the ?> if its enabled and some links arent linked as they do in the code bbcode
|
#16
|
|||
|
|||
heres my php function
[php] // ###################### Start phphighlite ####################### function phphighlite($code) { //PHP 4 only global $bbuserinfo; if (floor(phpversion())<4) { $buffer=$code; } else { $code = str_replace("<br>", "", $code); $code = str_replace("<br />", "", $code); $code = str_replace(">", ">", $code); $code = str_replace("<", "<", $code); $code = str_replace("&", "&", $code); $code = str_replace('$', '\$', $code); $code = str_replace('\n', '\\\\n', $code); $code = str_replace('\r', '\\\\r', $code); $code = str_replace('\t', '\\\\t', $code); $code = stripslashes($code); if (!strpos($code,"<?") and substr($code,0,2)!="<?") { $code="<?\n".trim($code)."\n?>"; $addedtags=1; } ob_start(); $oldlevel=error_reporting(0); highlight_string($code); error_reporting($oldlevel); $buffer = ob_get_contents(); ob_end_clean(); if ($addedtags) { $openingpos = strpos($buffer,'<?'); $closingpos = strrpos($buffer, '?'); $buffer=substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5); } $buffer = str_replace(""", "\"", $buffer); } if ($bbuserinfo[userid]==0 or $bbuserinfo[showfunclinks]) { /* Highlight function names in [php] */ $allfuncs = get_defined_functions(); $searches = array(); $replaces = array(); foreach ($allfuncs['internal'] as $name) { $searches[] = "/([^a-z])$name(<\/font><font color=\"" . ini_get('highlight.keyword') . "\">){0,1}( {0,1})\(<\/font>/i"; $replaces[] = "\\1<a href=\"http://www.php.net/$name\" target=\"_blank\">$name</a>\\2\\3(</font>"; } $buffer = preg_replace($searches, $replaces, $buffer); /* end Highlight function names in PHP Code:
|
#17
|
|||
|
|||
any one know whats wrong?
|
#18
|
|||
|
|||
^bump^
|
#19
|
||||
|
||||
This is strange. For some reason I don't see this in my options panel.
Show links to function names in code? I installed the exact same version you have here. Quote:
|
#20
|
||||
|
||||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|