Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts

    func.displayCode.php

    PHP Code:
    <?php

    //http://www.actwebdesigns.co.uk
    //luke@actwebdesigns.co.uk
    //
    //<style type="text/css">
    //pre.odd { background-color: #F4F4F4; }
    //pre.even { background-color: #a0d3a5; }
    //pre.even, pre.odd { margin:0; padding:5px; font-size:12px; color:#404040; border-top:1px solid #404040;}
    //div.codeBlock { width:800px; overflow:auto; margin:0 auto; border:1px solid #404040; border-top:none;}
    //pre span.lineNo { color:#C60; }
    //</style>

    function displayCode($url)
    {
        if(
    file_exists($url))
        {
            
    $data file_get_contents($url);
            
    $lines explode(PHP_EOL$data);
            
    $x=1;
            
    $y=1;
            
    $return "<div class=\"codeBlock\">\n";
            foreach(
    $lines as $line)
            {
                if(
    $x!==1)
                {
                    
    $lineTest trim($line);
                    if(!empty(
    $lineTest))
                    {
                        
    $line str_replace("&""&amp;"$line);
                        
    $line str_replace("/""/"$line);
                        
    $line str_replace("<""&lt;"$line);
                        
    $line str_replace(">""&gt;"$line);
                        if((
    $x 1)==1)
                            
    $class "even";
                        else
                            
    $class "odd";
                        if(
    preg_match("#(^\s*&\#0047;&\#0047)|(^\s*\#)#is"$line$match))
                        {
                            
    $return .= "<pre class=\"".$class." comment\"><span class=\"lineNo\">".$y."</span> ".str_replace("/""/"$line)."</pre>\n";
                        }
                        else
                        {
                            
    $return .= "<pre class=\"".$class."\"><span class=\"lineNo\">".$y."</span> ".str_replace("/""/"$line)."</pre>\n";
                        }
                        
    $y++;
                    }
                    else
                    {
                        
    $x++;
                    }
                }
                
    $x++;
            }
            
    $return .= "</div>\n";
            
    $return preg_replace("#(\s*)@?([a-z]+(?:[a-z]|[0-9]|_)*)(\s*)\(([^\)]*)\)#is""\\1<span class=\"function\">\\2\\3</span>(\\4)"$return);
            
    $return preg_replace("#\s*(\$[^\s]*)#is"" <span class=\"variable\">\\1</span>"$return);
            return 
    $return;
            
        }
        else
        {
            return 
    "unknown path given";    
        }                   
    }

    //echo displayCode("../dir/to/page.php");
    ?>
    Last edited by Phil Jackson; 10-22-2009 at 07:15 AM.
    Website Design Mansfield
    PHP Code:
    function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
    echo 
    I_LOVE(); 


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •