HTML source into PHP

I would like to be able to retrieve the actual source of a HTML file from my own web server via php is this possible?

This you can also put in youre php page orcourse


<html>
<head>
<!-- Begin
function viewSource() {
document.getSource.view.value="Please wait!";
setTimeout("document.getSource.view.value='View Source!'",6000);
window.location.href= "view-source:" + document.getSource.url.value;
return false;
}
//  End -->
</script>
</HEAD>

<!-- put this within youre <body> -->

<BODY>

<center>
Type in a full URL and click "View Source"
<br>
<br>
<form name=getSource onSubmit="return viewSource();">
<input type=text name=url value="http://">
<br>
<br>
<input type=submit name=view value="View Source">
</form>
</center>
</body>
</html>

Well realistically I am looking for a way to be able to call a PHP script that will echo back the HTML of a page on my server so I can view it and update it. So maybe I should have been more specific…also, btw I couldn’t get that script to work. You can check it out http://www.simplifiedsoftware.org/test.php it does nothing and I cut and pasted your code :frowning:

Sorry…


<SCRIPT LANGUAGE="JavaScript">

Add that before
<-- Begin

put it into php file:

<?php show_source(basename($_GET['url'])); ?>

and use it like

file.php?url=www.kirupa.com

:slight_smile:

Didnt know that worked for html lol, never tried it either…

why can’t ya just gop up to veiw>source in ie and its in mozilla too

lol

Signifer, that won’t work because it’ll show the HTML generated by the PHP script and not the actual PHP script.

Actually guys…I had to go to this code.


function ShowSourceXML($filename="",$wrap=true) {
 if (file_exists($filename)) {
 
	 ob_start();
	 show_source( $filename );
	 $t = ob_get_contents();
	 ob_end_clean();
  
	 $source=explode("<br />",$t);
	 $counter=1;
	 $final = '<?xml version="1.0" encoding="iso-8859-1"?><source>';
		foreach ($source as $line) {
			$final .= "<line lineNum='".$counter++."'><![CDATA[$line]]></line>";
		}  
	 $final .= "</source>";
  echo $final;
  
 } else {
  echo false;
 }
}

That returns the sites HTML or PHP or XML data…in XML form…its sweeet. It is moded code from a site I found…It returned it as a HTML page with each line numbered…so I just changed a few things…thanks for all the help though!