highlight_string()或show_source()
highlight_file();
看手册

解决方案 »

  1.   

    up
    像editplus,你在参数选项的设置和语法中自己定制就可以了,
    其他的类似。
      

  2.   

    highlight_string()
    highlight_file()这两个函数可以高亮度显示php代码
    其他代码不行
      

  3.   

    http://phpuser.com 网站用到了这个东西,你可以去研究一下啦。
      

  4.   

    (“语法加亮”显示PHP的原代码) 兄弟你有福呀!<? 
    if($simple == "y") { 
    header( "Content-type: text/plain"); 
    // $filename = "/usr/local/something.txt"; 
    $dirr = $page_url; 
    if(!eregi( "/etc/passwd", $dirr)) { 
    $dir = "./"; 
    $fd = fopen($dir.$page_url, "r"); 
    $contents = fread( $fd, filesize($page_url)); 
    echo $contents; 
    fclose($fd); 
    } else { 
    echo "<html><head><title></title></head><body>n"; 
    echo "<center>n"; 
    echo "<FONT COLOR="#FF0000" size=+2 FACE="Arial, Sans-serif"><h1>WARNING:</h1></font>n"; 
    echo "</center>n"; 
    echo "sorry you may <blink><b><font size="+2">NOT</font></b></blink> access the passwd file :-) "; 
    $dte = date( "l dS of F Y h:i:s A"); 
    $remote_ip = getenv( "REMOTE_ADDR"); 
    $requested = getenv( "REQUEST_URI"); 
    mail( "[email protected]", "[darkseed] password access", 
    "A user at $dte tried to access the /etc/passwdn $remote_ipn$requestedn"); 
    echo "your remote IP is mailed to the sysadmin right now!,
    after 3 or more attempts you domain is being blocked! if you don't wan't 
    this or you accedently accessed the passwd (Yeah right?!) 
    please mail to <a href="mailto:[email protected]">[email protected]</a>"; 
    echo "</body></html>n"; 
    } } else { 
    ?> <!-- 
    REQUIRED PARAMETERS TO URL: 
    ----------------------------------------------------------------- 
    page_url - The php page you wish to view. Default 
    from Rasmus Lerdor. 
    Example: 
    http://gw/source.php3?page_url=/mail.php3 
    OPTIONAL PARAMETERS TO URL: 
    ---------------------------------------------------------------- 
    &fontsize={size} - Something I've implemented to keep long 
    code lines from word wrapping to next line. 
    (keeps same font throughout). 
    Example: 
    http://gw/source.php3?page_url=/myphpdoc.php3&fontsize=-3 
    &formatcode={any} - Uses the html tag "<code>" and "</code>" 
    around the php3 code. (This is for us 
    who are mono-spaced code writers and like 
    to see our code documentation as such). 
    &formatcode must be lower case and can 
    be set to any value. 
    Example: 
    http://gw/source.php3?page_url=/myphpdoc.php3&formatcode=y Example with all parameters: 
    http://gw/source.php3?page_url=/source.php3&formatcode=y&fontsize=-2 
    //--> 
    <?php $page_url=escapeshellcmd($page_url); 
    if($simple == "y") { $page_url=escapeshellcmd($dir.$page_url); } if (!isset($page_url)) { 
    echo( "Invalid page URL specified. Try:<BR><B>source.php3?page_url=/source.php3</B>"); 
    exit; 

    ?> 
    <HTML> 
    <HEAD> 
    <TITLE>Source: <?echo $page_url; ?></TITLE> 
    </HEAD> 
    <BODY bgcolor=white> 
    <? 
    /* 
    include "rotate.php3"; 
    if($lnk[$i] != "" && $img[$i] != ""){ 
    echo($lnk[$i].$img[$i]."</A>"); 
    if($comments){ 
    if($cmt[$i]){ 
    echo("<br>$cmt[$i]"); 
    }else{ 
    echo("<br>$dcomment"); 


    }else{ 
    echo($errormsg); 

    */ 
    ?> <a href="http://www.teknosurf3.com/cgi-bin/ads.pl?darkseed+K+index+1+advert=NonSSI"> 
    <img src="http://www.teknosurf3.com/cgi-bin/ads.pl?darkseed+K+index+1" valign=top></a> <div align="left"> 
    <table border="0" width="620" align="left" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td width="100%"> 
    <FONT FACE="Arial, Sans-Serif, Serif"><P ALIGN="right"> 
    [ <a href="http://www.darkseed.net/php3/list.php3">BACK</a> ]</P> 
    </FONT> 
    <FONT FACE="tahoma, verdana, arial, sans-serif" SIZE=6> 
    <B><FONT COLOR=NAVY>PHP Source Code of <?php echo $page_url; ?></FONT></B><BR> <?php if (!isset($fontsize)) { 
    echo "<FONT SIZE=3 FACE="Arial, Sans-serif, Sans, Serif">"; 
    } else { 
    echo "<FONT SIZE=".$fontsize. ">"; 

    ?> <HR COLOR=NAVY NOSHADE> <?php 
    $simple = "false"; 
    $legal_dirs = array( "/manual"=>1, "/include"=>1, "/php3"=>1); 
    $dir = dirname($page_url); if ($dir && $legal_dirs[$dir]) { 
    $page_name = $DOCUMENT_ROOT . $page_url; 
    } else { 
    $page_name = basename($page_url); 
    } echo( "<!-- $page_name -->n"); if (file_exists($page_name)) { 
    $datemod = date( "h:i A m/d/Y", filectime($page_name)); 
    $strlastmod=( "<B>Last Modified: </B>".$datemod); 
    $strprintdate= "&nbsp;&nbsp;&nbsp;<B>Modification date: </B>".date( "h:i A m/d/Y"); 
    $sfilesize= "&nbsp;&nbsp;&nbsp;<B>Size: </B>".filesize($page_name); 
    $strlastmod=$strlastmod.$strprintdate.$sfilesize; 
    echo $strlastmod; 
    echo( "<BR><HR NOSHADE COLOR=NAVY>"); 
    /* if (isset($formatcode)) */ echo( "<CODE>"); 
    show_source( "./".$page_name); 
    /* if (isset($formatcode)) */ echo( "</CODE>"); 

    ?> <HR COLOR=NAVY NOSHADE> 
    </td> 
    </tr> 
    <tr> 
    <td> 
    <FONT FACE="Arial, Sans-Serif, Serif"><P ALIGN="right"> 
    [ <a href="http://www.darkseed.net/php3/list.php3">BACK</a> ]</A> 
    </FONT> 
    <br> 
    <? 
    include "rotate.php3"; 
    if($lnk[$i] != "" && $img[$i] != ""){ 
    echo($lnk[$i].$img[$i]. "</A>"); 
    if($comments){ 
    if($cmt[$i]){ 
    echo( "<br>$cmt[$i]"); 
    }else{ 
    echo( "<br>$dcomment"); 


    }else{ 
    echo($errormsg); 

    ?> 
    </td> 
    </tr> 
    </table> 
    </div> 
    </BODY> 
    </HTML> 
    <? } ?> 
     
     
      

  5.   

    楼上的代码其实精华的就是show_source()函数,可以高亮显示php代码
    btw,上面代码有安全漏洞