Mindcontroll Forum Index
Mindcontroll Forum Index FAQ Memberlist Search

Mindcontroll Forum Index » Programs/Programming Development » [phpSourceView] Here is the source
Post new topic  Reply to topic View previous topic :: View next topic 
[phpSourceView] Here is the source
PostPosted: 08-11-2002 04:06 PM Reply with quote
TuMTuM
Will code HTML for food!
Joined: 17 Feb 2002
Posts: 425




Code:

<?
echo '<head><title>phpSourceView</title><style type="text/css">.phphighlight {background-color: #FFFFFF;border-color: #000000;border-style: solid;border-left-width: 1px;border-right-width: 1px;border-top-width: 1px;border-bottom-width: 1px;}.phphighlightline {background-color: #d3d3d3;text-align: right;border-right-width: 1px;}.phphighlightcode {border-left-width: 1px;}</style></head>';
if($file == $PHP_SELF or $file == "")
   {
   die('No file selected');
   }

$file = str_replace('/','',$file);
$file = str_replace('\\\\','',$file);

ob_start();
show_source ($file);
$source = ob_get_contents();
ob_end_clean();

$source = explode("<br>",$source); // Some newer versions of php might want <br /> here
echo '<center><table border="1" cellpadding="4" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="100%" bgcolor="#D3D3D3"><tr><td width="100%"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"><tr><td width="33%"><font face="Verdana" size="2">phpSourceView</font></td><td width="33%">&nbsp;</td><td width="34%" align="right"><font face="Verdana" size="2">viewing: '.$file.'</font></td></tr></table></td></tr></table></center></div>';
echo '<center><table border="0" cellpadding="4" cellspacing="0" class="phphighlight" width="100%"><tr><td class="phphighlightline"><code>';
         
for ($i = 1; $i <= count($source); $i++) {
    echo $i . '<br>';
}

echo '</td>
        <td nowrap class="phphighlightcode"><font color="#0000CC">';

for ($i = 0; $i < count($source); $i++) {
    $src .= $source[$i] . '<br />';
}
$src .= $source[count($source)-1];

echo '<code>'.$src.'<code>';

echo "<code></font></td></tr></table></center>";
?>


Now all I have to do is make a hack for vbb to display the linenumber. Use it like this: www.server.com/script.php?file=source.php. I'm gonna add some more changes, but they are only minor ones (show the contents of a directory of no file is selected, and call it using www.server.com/script.php/directory/source.php) but I need to prepare for my first day of work tomorrow (wich means sleep Razz).


Last edited by TuMTuM on 08-11-2002 04:12 PM; edited 1 time in total
View user's profile Find all posts by %s Send private message Send e-mail

PostPosted: 08-11-2002 10:05 PM Reply with quote
M0nKeY
- Remember -
Joined: 09 Feb 2002
Posts: 1235




That could be really usefull.

_________________
"Am I a man dreaming of a butterfly or a butterfly dreaming of a man?"
View user's profile Find all posts by %s Send private message Send e-mail Visit poster's website AIM Address

PostPosted: 08-13-2002 03:36 PM Reply with quote
TuMTuM
Will code HTML for food!
Joined: 17 Feb 2002
Posts: 425




Here is a shorter script, with 2 functions, file_sourceview('filename.php'); and string_sourceview('<? \n echo "Legal-Chat 0wns"; \n ?>');. With this you should be able to make hacks very easily.

Code:

function file_sourceview($file)
   {
   ob_start();
   highlight_file ($file);
   $source = ob_get_contents();
   ob_end_clean();

   $source = explode("<br />",$source);

   echo '<table border="1" cellpadding="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#666666" id="AutoNumber2" bgcolor="#325F91"><tr><td width="100%"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">';   

   for ($i = 1; $i <= count($source); $i++)
      {
       echo '<tr><td bgcolor="#C0C0C0" align="right">&nbsp;<code>'.$i.'</code>&nbsp;</td><td bgcolor="#E1E1E1"><code>'.$source[$i-1].'<code>&nbsp;</td></tr>';
      }
      
   echo '</table></td></tr></table>';
   }

function string_sourceview($string)
   {
   ob_start();
   highlight_string ($string);
   $source = ob_get_contents();
   ob_end_clean();

   $source = explode("<br />",$source);

   echo '<table border="1" cellpadding="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#666666" id="AutoNumber2" bgcolor="#325F91"><tr><td width="100%"><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">';   

   for ($i = 1; $i <= count($source); $i++)
      {
       echo '<tr><td bgcolor="#C0C0C0" align="right">&nbsp;<code>'.$i.'</code>&nbsp;</td><td bgcolor="#E1E1E1"><code>'.$source[$i-1].'<code>&nbsp;</td></tr>';
      }
      
   echo '</table></td></tr></table>';
   }
View user's profile Find all posts by %s Send private message Send e-mail

[phpSourceView] Here is the source
 Mindcontroll Forum Index » Programs/Programming Development
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You can vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Post new topic  Reply to topic  


Video Games Suck - XXXSwim - Archive
  Powered by phpBB © 2001-2005 phpBB Group. Designed for Trushkin.net | Themes Database