Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Highlight and link function names inside code Details »»
Highlight and link function names inside code
Version: 1.00, by Admin (Coder) Admin is offline
Developer Last Online: Nov 2024 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 02-26-2002 Last Update: Never Installs: 11
 
No support by the author.

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("<","<",$bbcode);
    $bbcode=str_replace(">",">",$bbcode);
    $bbcode=str_replace("<","&lt;",$bbcode);
    $bbcode=str_replace(">","&gt;",$bbcode);
  }
  $bbcode=nl2br($bbcode);
(also works inside [php] tags)

To install this hack download the attached file (linkfuncs.hack.php), upload to your /admin folder and use vbHacker.

Have fun!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 06-04-2002, 06:40 AM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
 */
  } 
it still highlights and links the code and php boxes
Reply With Quote
  #13  
Old 06-04-2002, 06:46 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make sure $bbuserinfo is global in that function.
Reply With Quote
  #14  
Old 06-04-2002, 06:55 AM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, it got rid of the links but the highlighting is still there and it shows ?> at the end of the php code
Reply With Quote
  #15  
Old 06-04-2002, 07:05 AM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

also the ?> if its enabled and some links arent linked as they do in the code bbcode
Reply With Quote
  #16  
Old 06-04-2002, 07:06 AM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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("&gt;", ">", $code);
$code = str_replace("&lt;", "<", $code);

$code = str_replace("&amp;", "&", $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,'&lt;?');
$closingpos = strrpos($buffer, '?');
$buffer=substr($buffer, 0, $openingpos).substr($buffer, $openingpos+5, $closingpos-($openingpos+5)).substr($buffer, $closingpos+5);
}
$buffer = str_replace("&quot;", "\"", $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:
 */
  }

  return 
"</normalfont><table border=\"0\" align=\"center\" width=\"90%\" cellpadding=\"3\" cellspacing=\"1\"><tr><td><font face=\"Arial\" size=1 color=#616889><smallfont><b>PHP:</b></smallfont> <smallfont>(double click the code to copy it)</smallfont></font></td></tr><tr><td class=\"phptable\"><pre>" $buffer "</pre></td></tr></table><normalfont>";

Reply With Quote
  #17  
Old 06-05-2002, 04:33 AM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any one know whats wrong?
Reply With Quote
  #18  
Old 06-06-2002, 01:34 PM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^bump^
Reply With Quote
  #19  
Old 06-23-2002, 05:40 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Originally posted by FireFly
Done. Feel free to turn this off in your options.
Reply With Quote
  #20  
Old 08-21-2002, 05:02 PM
php-resource.de's Avatar
php-resource.de php-resource.de is offline
 
Join Date: Jun 2002
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Slynderdale
any one know whats wrong?
did you get it to work?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05468 seconds
  • Memory Usage 2,300KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete