<?php 
function get_sourcecode($filename, $first_line_num=1, $num_color="#999") {

 // Get highlighted code
 $html_code = highlight_file($filename, TRUE);

 // Bookmark #1:
 // Remove the first "<code>" tag from "$html_code" (if any)
 if (substr($html_code, 0, 6) == "<code>") {
  $html_code = substr($html_code, 6, strlen($html_code));
 }

 // Replacement-map to replace deprecated "<font>" tag with "<span>"
 $xhtml_convmap = array(
  '<font' => '<span',
  '</font>' => '</span>',
  'color="' => 'style="color:'
 );

 // Replace "<font>" tags with "<span>" tags, to generate a valid XHTML code
 $html_code = strtr($html_code, $xhtml_convmap);

 ### Okay, Now we have a valid XHTML code
 ### Let's add the line numbers...

 $arr_html_code = explode("<br />", $html_code);
 $total_lines = count($arr_html_code);

 $retval = "";
 $line_counter = 0;
 $last_line_num = $first_line_num + $total_lines;
 foreach ($arr_html_code as $html_line) {

  // Calculate number of current line
  $current_line = $first_line_num + $line_counter;

  // Append new line to "$retval"
  $retval .=
   str_repeat("&nbsp;", strlen($last_line_num) - strlen($current_line) ) .
   "<span style=\"color:{$num_color}\">{$current_line}: </span>" .
   $html_line .
   "<br />"
  ;

  $line_counter++;

 } // end: foreach


 $retval = "<code>" . $retval; // Why? remember Bookmark #1, that I removed the tag "<code>"

 return $retval;

} // end: get_sourcecode

?>
<?php
					  $path=$view;
		   $fsize = filesize($path) ;
		   $fmodified = date("d/M/y G:i:s", filemtime($path)) ;
     	   $faccessed = date("d/M/y G:i:s", fileatime($path)) ;

			?>
 <br>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f7f7f7">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
        <tr bgcolor="#FFFFFF">
          <td width="20%" bgcolor="fafafa"><input class="textboxgray" type="button" name="Button" value="Back" onClick="window.location='admin.php?page=fm&rel_dir=<?php echo $rel_dir; ?>'"></td>
          <td colspan="3" bgcolor="fafafa"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td width="20%" bgcolor="fafafa">File </td>
          <td colspan="3" bgcolor="fafafa"><?php echo $path; ?></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td>File size </td>
          <td width="44%"><?php echo $fsize ?> Bytes</td>
          <td width="21%">Owner </td>
          <td width="15%"><?php echo fileowner($path); ?></td>
        </tr>
        <tr bgcolor="fafafa">
          <td>Last modified </td>
          <td><?php echo $fmodified; ?></td>
          <td>Group </td>
          <td><?php echo filegroup($path); ?></td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td>Last accessed &nbsp;&nbsp;&nbsp;&nbsp;</td>
          <td><?php echo $faccessed; ?></td>
          <td>Permission </td>
          <td><?php printf( "%o", fileperms($path) ) ; ?></td>
        </tr>
      </table></td>
  </tr>
</table>
<br>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f7f7f7">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
        <tr>
          <td bgcolor="#FFFFFF" > <?php
					   $ext=array();
                	   $ext=explode(".",$view,strlen($view));
  				       $extn=$ext[count($ext)-1];
					  if(isimage($extn))
					  {
					  $iurl=str_replace($absolute_path,"",$view);
					  echo '<center><br><image src="'.$iurl.'" name="preview"> </center><br><BR>';
					  }
					  else {
					  $line_num=0;
					  print get_sourcecode($view, $line_num);
					  }

					  ?> </td>
        </tr>
      </table></td>
  </tr>
</table>
<?php
					  if(isimage($extn))
					  {
?>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><script language="JavaScript" type="text/JavaScript">
	var owidth= new Number(0);
	var oheight=new Number(0);
	var first=new Number(0);
	function init()
	{
	document.owidth=document.preview.width;
	document.oheight=document.preview.height;
	}
	function resize(size)
	{
	if(first==0)
	{init();
	first=1;
	}
	switch(size)
	{
	case 1 :
	document.preview.width=document.owidth;
	document.preview.height=document.oheight;
	break;
	case 2 :
	document.preview.width=document.owidth*2;
	document.preview.height=document.oheight*2;
	break;
		case 3 :
	document.preview.width=document.owidth*3;
	document.preview.height=document.oheight*3;
	break;
		case 4 :
	document.preview.width=document.owidth*4;
	document.preview.height=document.oheight*4;
	break;
		case 5 :
	document.preview.width=document.owidth*5;
	document.preview.height=document.oheight*5;
	break;
		case 6 :
	document.preview.width=document.owidth*6;
	document.preview.height=document.oheight*6;
	break;
	}
	}
	</script>
      <table border="0" align="center" cellpadding="5" cellspacing="5">
        <tr>
          <td><div align="center">
              <table border="0" cellspacing="0" cellpadding="0" onClick="resize(1);" class="tableview">
                <tr>
                  <td background="images/icons/but_l.gif" width="4" height="19"></td>
                  <td background="images/icons/but_m.gif">1 X</td>
                  <td background="images/icons/but_r.gif" width="4" height="19"></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center">
              <table border="0" cellspacing="0" cellpadding="0" onClick="resize(2);" class="tableview">
                <tr>
                  <td background="images/icons/but_l.gif" width="4" height="19"></td>
                  <td background="images/icons/but_m.gif">2 X</td>
                  <td background="images/icons/but_r.gif" width="4" height="19"></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center">
              <table border="0" cellspacing="0" cellpadding="0" onClick="resize(3);" class="tableview">
                <tr>
                  <td background="images/icons/but_l.gif" width="4" height="19"></td>
                  <td background="images/icons/but_m.gif">3 X</td>
                  <td background="images/icons/but_r.gif" width="4" height="19"></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center">
              <table border="0" cellspacing="0" cellpadding="0" onClick="resize(4);" class="tableview">
                <tr>
                  <td background="images/icons/but_l.gif" width="4" height="19"></td>
                  <td background="images/icons/but_m.gif">4 X</td>
                  <td background="images/icons/but_r.gif" width="4" height="19"></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center">
              <table border="0" cellspacing="0" cellpadding="0" onClick="resize(5);" class="tableview">
                <tr>
                  <td background="images/icons/but_l.gif" width="4" height="19"></td>
                  <td background="images/icons/but_m.gif">5 X</td>
                  <td background="images/icons/but_r.gif" width="4" height="19"></td>
                </tr>
              </table>
            </div></td>
          <td><div align="center">
              <table border="0" cellspacing="0" cellpadding="0" onClick="resize(6);" class="tableview">
                <tr>
                  <td background="images/icons/but_l.gif" width="4" height="19"></td>
                  <td background="images/icons/but_m.gif">6 X</td>
                  <td background="images/icons/but_r.gif" width="4" height="19"></td>
                </tr>
              </table>
            </div></td>
        </tr>
      </table></td>
  </tr>
</table>
<?php
}
?>