Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

link to view source code


ghost's Avatar
0 0

hey guys

im trying to help one of my friends code some stuff on his site, and one of the things that he wants, is to have a link at the bottom of every page to show the source

any idea's on how to do thisQ

cheers

engelavdod


spyware's Avatar
Banned
0 0

Save every page as a .phps file and link to that.


ghost's Avatar
0 0

for viewing html source, where you show the source in div id=test:

function showsource() {
document.getElementById("test").innerHTML="<plaintext>"+document.getElementsByTagName("html")[0].innerHTML+"</plaintext>";
}

spyware's Avatar
Banned
0 0

mr noob wrote: for viewing html source, where you show the source in div id=test:

function showsource() {
document.getElementById("test").innerHTML="<plaintext>"+document.getElementsByTagName("html")[0].innerHTML+"</plaintext>";
}

Might I point out that this is quite an ugly solution? If you use this be SURE to color tags on way or the other.


ghost's Avatar
0 0

who gives a fuck if its ugly, the source is what he wanted, the source is what he got ^^


ghost's Avatar
0 0

The following works in Firefox:

Precede the href property of the anchor tag (< a >) with "view-source:". :)


SySTeM's Avatar
-=[TheOutlaw]=-
20 0

Just use PHP's highlight_file() function


ghost's Avatar
0 0

I agree with system_meltdown that he's not talking about html

&lt;?php

$disallowed = array( &quot;config.php&quot;, &quot;private.php&quot; ); //More as needed
foreach ( $disallowed as $file ) if ( $_GET[&quot;f&quot;] == $file ) die( &quot;Not allowed to view that file&quot; );
show_source( $_GET[&quot;f&quot;] );

?&gt;

OR

&lt;?php

if ( $_GET[&quot;source&quot;] == &quot;yes&quot; ) die( show_source( __FILE__ ) );

?&gt;

mido's Avatar
Member
0 0

Can't you use AJAX? (xmlHTTPrequest).


SySTeM's Avatar
-=[TheOutlaw]=-
20 0

Or you could use in_array, rather than using a foreach loop