View Full Version : HTML source into PHP
simpleSoft
July 10th, 2004, 01:00 PM
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?
ol4pr0
July 11th, 2004, 01:22 AM
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>
simpleSoft
July 11th, 2004, 01:39 AM
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 :(
ol4pr0
July 11th, 2004, 01:45 AM
Sorry..
<SCRIPT LANGUAGE="JavaScript">
Add that before
<-- Begin
fluid_tw0
July 11th, 2004, 02:25 PM
put it into php file:
<?php show_source(basename($_GET['url'])); ?> and use it like
file.php?url=www.kirupa.com :)
ol4pr0
July 11th, 2004, 04:45 PM
Didnt know that worked for html lol, never tried it either..
signifer123
July 11th, 2004, 05:06 PM
why can't ya just gop up to veiw>source in ie and its in mozilla too
fluid_tw0
July 12th, 2004, 06:12 PM
lol
Hans Kilian
July 13th, 2004, 03:42 AM
Signifer, that won't work because it'll show the HTML generated by the PHP script and not the actual PHP script.
simpleSoft
July 13th, 2004, 06:22 PM
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!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.