note 76445 deleted from function.show-source by bobby

From: Date: Wed, 08 Aug 2007 04:38:18 +0000
Subject: note 76445 deleted from function.show-source by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-129281@lists.php.net to get a copy of this message
Note Submitter: lkj dot korn at gmail dot com ---- 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; } ?> 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 (#129281) next »