View previous topic :: View next topic |
Author |
Message |
TuMTuM
Joined: 17 Feb 2002
Posts: 425
|
Posted: 08-11-2002 04:06 PM Post subject: [phpSourceView] Here is the source |
|
|
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%"> </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 :P). |
|
Back to top |
|
M0nKeY
Joined: 09 Feb 2002
Posts: 1235
|
Posted: 08-11-2002 10:05 PM Post subject: |
|
|
That could be really usefull. |
|
Back to top |
|
TuMTuM
Joined: 17 Feb 2002
Posts: 425
|
Posted: 08-13-2002 03:36 PM Post subject: |
|
|
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"> <code>'.$i.'</code> </td><td bgcolor="#E1E1E1"><code>'.$source[$i-1].'<code> </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"> <code>'.$i.'</code> </td><td bgcolor="#E1E1E1"><code>'.$source[$i-1].'<code> </td></tr>';
}
echo '</table></td></tr></table>';
}
|
|
Back to top |
|
|