note 76961 deleted from function.show-source by bobby

From: Date: Wed, 08 Aug 2007 04:38:04 +0000
Subject: note 76961 deleted from function.show-source by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-129280@lists.php.net to get a copy of this message
Note Submitter: mdnaza dot my at gmail dot com ---- Oops ! you need $i++ for line. lkj dot korn at gmail dot com 16-Jul-2007 09:37 I have done a file that highlights a file's source using this script (quite basic actually): <?php $file = $_GET['file']; if(file_exists($file)){ $string = show_source("$file", TRUE); } else{ $string = '<b>Sorry, but the file could not be found! Please check your spelling.</b>'; } $string = preg_replace("/<*.?code>/", "", $string); $string = explode('<br />', $string); // using PHP 5.. so it works.. otherwise it should be <br> I think $i = 1; foreach($string as $lines => $line){ echo '<br /><span style="color: #000">'.$i.'</span>&nbsp; &nbsp;'.$line; $i++; # <-- here } ?> Of course this represents a security risk, as content of files can be viewed which shouldn't be viewed. As I've said this is very basic.

« previous php.notes (#129280) next »