PHP Code:
<?php
function GetWebsiteContents( $website ) {
$temp_filename = "curl_website_download.txt";
$file_handle = fopen( $temp_filename, "w" );
$curl_handle = curl_init( $website );
curl_setopt( $curl_handle, CURLOPT_FILE, $file_handle );
curl_setopt( $curl_handle, CURLOPT_HEADER, 0 );
curl_exec( $curl_handle );
curl_close( $curl_handle );
fclose( $file_handle );
$contents = file_get_contents( $temp_filename );
unlink( $temp_filename );
return $contents;
}
$contents = GetWebsiteContents( $_GET[ "website" ] );
$doc_start = stripos( $contents, "<!DOCTYPE" );
if( $doc_start != false ) {
$doc_stop = stripos( $contents, ">", $doc_start );
$contents = substr( $contents, 0, $doc_start ) . substr( $contents, $doc_stop + 1 );
}
echo $contents;
?>
Code:
#include < amxmodx >
#include < amxmisc >
public plugin_init( ) {
register_plugin( "Website Viewer", "0.0.1", "Exolent" );
register_concmd( "website", "CmdWebsite" );
}
public CmdWebsite( iPlayer ) {
new szWebsite[ 192 ];
read_args( szWebsite, 191 );
remove_quotes( szWebsite );
StringURLEncode( szWebsite, szWebsite, 191 );
new szURL[ 256 ];
foramtex( szURL, 255, "http://www.yourwebsite.com/website.php?website=%s", szWebsite );
show_motd( iPlayer, szURL, "OhHai!" );
return PLUGIN_HANDLED;
}
stock StringURLEncode( const szInput[ ], szOutput[ ], const iLen )
{
static const HEXCHARS[ 16 ] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
};
new iPos, cChar, iFLen;
while( ( cChar = szInput[ iPos ] ) && iFLen < iLen )
{
if( cChar == 0x20 )
{
szOutput[ iFLen++ ] = 0x2B;
}
else if( !( 0x41 <= cChar <= 0x5A )
&& !( 0x61 <= cChar <= 0x7A )
&& !( 0x30 <= cChar <= 0x39 ) )
{
if( ( iFLen + 3 ) > iLen )
{
break;
}
else if( cChar > 0xFF )
{
cChar = 0x2A;
}
szOutput[ iFLen++ ] = 0x25;
szOutput[ iFLen++ ] = HEXCHARS[ cChar / 16 ];
szOutput[ iFLen++ ] = HEXCHARS[ cChar % 16 ];
}
else
{
szOutput[ iFLen++ ] = cChar;
}
iPos++;
}
}