Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: showing live source

  1. #11
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    here is what I am using; (the concept is from the user comments in the php help chm file. Make sure you download the one with the user comments)

    PHP Code:

        $fc 
    file_get_contents('' $f '.php');

    #--------------------------------
        
    $fc highlight_string $fctrue );
    #--------------------------------
        
    $sections explode '<br />'$fc );
    #--------------------------------

    $fc '';
    //$fc .= '<ol>';
         
    for ( $i 0$i count $sections ); $i++ ) {
            
    $fc .= '<br ><strong>' $i .  '</strong> &nbsp; ' $sections[$i];
         }
    //$fc .= '</ol>';

    #--------------------------------

    print $fc

    tried to use a ordered list <ol> but had some probs with that.

  2. #12
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    not a bad implementation. hmm.. I did not know there was a highlight_string() function. Thanks for sharing that one owen. You live and you learn.

  3. #13
    Join Date
    Jan 2005
    Posts
    3,151
    Rep Power
    0

    Default

    PHP programmers are now making it easier for people to view their code.
    one word: dwl

    Regards,
    Pogi Tuner.

  4. #14
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    it really isn't as easy as dwl because the database, folder structure and function files still can't be seen. Some stuff you still have to figure out. If you can't read the code, you have no hope.

  5. #15
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    Quote Originally Posted by pogi_2nr
    PHP programmers are now making it easier for people to view their code.
    one word: dwl

    Regards,
    Pogi Tuner.
    dont you believe in open source. you used to be the biggest advocate I know.

  6. #16
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    Quote Originally Posted by owen
    tried to use a ordered list <ol> but had some probs with that.
    what was the problem. I go that to work pretty easily, cept it starts counting from 1, but i am sure you can fix that with css. One peculiar thing to note is the way the line numbers get colour-coded according to the line before it.

  7. #17
    Join Date
    Feb 2003
    Posts
    3,184
    Rep Power
    0

    Default

    I think the problem was that you can't have a block element (e.g. "<blockquote>" or "<code>") embeded in a <li> tag. I needed to add <code> tags because I had to load included files.

    PHP Code:

        $fc 
    preg_split("/include\(([^|]*?)\);/i"$fc, -1PREG_SPLIT_DELIM_CAPTURE );

        
    $t=array(); $tc=array();

         for ( 
    $i 0$i count $fc ); $i++ ) {
            if ( 
    $i 2  ) {
                
    $template_parse_code false;
                
    $t[$i] = eval( ' return @include(' $fc[$i] . ');' );
                
    $tc[$i] = $fc[$i];
                
    $fc[$i] = '"[::' $i '::]"';
            }
         }


    foreach(
    $t as $i => $value$fc str_replace ('"[::' $i '::]"',  '</font>include(<a onclick="sh(' $i ');">' trim($tc[$i]) . '</a>);</code><div  >' highlight_string($t[$i], true) . '</div><code>' $fc );

    print 
    $fc
    I wouldn't recommend anybody trying to use that though. Its what I call a hack.
    Last edited by owen; Jul 20, 2005 at 05:02 PM.

  8. #18
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    my own hack, an attempt to make all the numbers black. Not too perfect tho. It seems php does alot of optimization for code in the same color that runs across lines. Late for a meeting tho, probably someone else can figure it out.

    PHP Code:
    $fc file_get_contents('' $f '.php'); 

    #-------------------------------- 
        
    $fc highlight_string $fctrue ); 
    #-------------------------------- 
        
    $sections explode '<br />'$fc ); 
    #-------------------------------- 

    $fc ''
    //$fc .= '<ol>'; 
         
    $span_cache "";
         for ( 
    $i 0$i count $sections ); $i++ ) { 
            
    // $span = "";
            
    if(preg_match_all('/<span style="color: (#[0-9A-Fa-f]*)">/i',$sections[$i],$matches)) 
                
    $span_cache = ($matches[0][count($matches[0])-1]);
           
    // $fc .= "\$span_cache: " . htmlentities($span_cache) . ", \$span: " . htmlentities($span) 
            //    . ", empty(\$sections[\$i]): " . (strlen(trim($sections[$i]))) . " <br/>";
            
    $sections[$i] = rtrim($sections[$i]);
            
    $fc .= '<strong>' $i .  '</strong> &nbsp; ' . ((empty($sections[$i]))?'':$span_cache)
                . 
    $sections[$i] . ((empty($sections[$i]))?'':'</span>') . '<br />'

         }
    //$fc .= '</ol>';

    #-------------------------------- 

    print $fc

  9. #19
    Join Date
    Jun 2004
    Posts
    296
    Rep Power
    0

    Default

    Quote Originally Posted by owen

    I wouldn't recommend anybody trying to use that though. Its what I call a hack.
    If i am right, what ur trying to do here, is display source code for every included file in a script in a div that can be contracted using javascript. pretting interesting, let me know when u get it to work.

  10. #20
    Join Date
    Jan 2005
    Posts
    3,151
    Rep Power
    0

    Default

    Quote Originally Posted by alexdevmaster
    dont you believe in open source. you used to be the biggest advocate I know.
    I still believe in opensource. It is just that the majority(not all) of php developers are just
    some Dick, Tom or Harry from the street who decided "hey! lets make a site". PHPers also
    have this nasty habit of dumping errors to the enduser.

    Identity theft/worms are sure to follow with the exposure of bad coding practices.

Posting Permissions

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