Important alert: (current site time 7/15/2013 4:41:40 AM EDT)
 

VB icon

Proxy, 4 view bloqued pages by fortiguard o firewall

Email
Submitted on: 5/29/2013 12:48:03 PM
By: Oliver Leuyim Angel / Curda  
Level: Advanced
User Rating: Unrated
Compatibility: PHP 3.0, PHP 4.0, PHP 5.0
Views: 2969
author picture
(About the author)
 
     The code purpose is for all people that are behind a firewall and this one cant let you see some categories or pages because the profile restrictions.
well, the solution is this code. the thing the code do is to: get the content of the page posted, and grab it and finally, display the web page with the server you are running the code. for testing, create an html page, with a form with the method post, and the action property looking to this php code in diferent file. The form need to have a input text box with name of url. (prefer to not run in localhost).
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Proxy, 4 view bloqued pages by fortiguard o firewall
// Description:The code purpose is for all people that are behind a firewall and this one cant let you see some categories or pages because the profile restrictions. 
<br>
well, the solution is this code. the thing the code do is to: get the content of the page posted, and grab it and finally, display the web page with the server you are running the code. for testing, create an html page, with a form with the method post, and the action property looking to this php code in diferent file. The form need to have a input text box with name of url. (prefer to not run in localhost).
// By: Oliver Leuyim Angel / Curda
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2828&lngWId=8//for details.//**************************************

<?php 
//this file name is = phpinfo.php
/*
http://dimworks.org
autor: Leuyim
feb 2011
*/ 
ini_set('display_errors','0');
function rstrstr($haystack,$needle, $start=0){
return substr($haystack, $start,strpos($haystack, $needle));
 }
 
function urlno(){
if(empty($php_self)){$php_self = $_SERVER['PHP_SELF'];}
$filename = explode("/", $php_self); // THIS WILL BREAK DOWN THE PATH INTO AN ARRAY
for( $i = 0; $i < (count($filename) - 1); ++$i ) {
$filename2 .= '/'.$filename[$i];
}
$pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
 } else {
 $pageURL .= $_SERVER["SERVER_NAME"];
 }
//return $pageURL.$filename2;
return $pageURL.$_SERVER['PHP_SELF'];
} 
if($_POST["url"] != '')
{
 
$path_parts = pathinfo($_POST["url"]);
if($path_parts['extension'] == "zip"){
 
 // Define the path to file
 $file = $_POST["url"];
 $filesize = filesize($file);
 
 // Set headers
 header("Cache-Control: public");
 header("Content-Description: File Transfer");
 header("Content-Disposition: attachment; filename={$path_parts['basename']}");
 header("Content-Type: application/zip");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".$filesize); 
 
 // Read the file from disk
 readfile($file);
 }elseif($path_parts['extension'] == "mp3"){
 // Define the path to file
 $file = $_POST["url"];
 $filesize = filesize($file);
 
 // Set headers
 header("Cache-Control: public");
 header("Content-Description: File Transfer");
 header("Content-Disposition: attachment; filename={$path_parts['basename']}");
 header("Content-Type: application/octet-stream");
 //header("Content-type: application/force-download");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".$filesize);
 
 // Read the file from disk
 readfile($file);
}else{
$parse = parse_url($_POST["url"]);
$url = "http://".$parse["host"];
$forprint = file_get_contents($_POST["url"]); 
$parts = explode(" ",$forprint);
for($i = 0, $size = sizeof($parts); $i < $size; ++$i)
{
 $insertu = substr(trim($parts[$i]),0,6);
 if($insertu == 'href="'){ 
$parts[$i] = str_ireplace('href="',"",$parts[$i]);
$result[1] = rstrstr($parts[$i], '"');
$result[2] = strstr($parts[$i], '"');
 $insert = substr(trim($result[1]),0,1);
 $insert2 = substr(trim($result[1]),0,4);
 
 if($insert == '/'){ $parts[$i] = "href=\"".$url.$result[1].$result[2]; }
 elseif($insert2 != 'http'){ $parts[$i] = "href=\"".$url."/".$result[1].$result[2]; } 
 else{ $parts[$i] = 'href="'.$result[1].$result[2]; } 
 }
 //////////////////src=""
 $insertu = substr(trim($parts[$i]),0,5);
 if($insertu == 'src="'){ 
$parts[$i] = str_ireplace('src="',"",$parts[$i]);
$result[1] = rstrstr($parts[$i], '"');
$result[2] = strstr($parts[$i], '"');
 $insert = substr(trim($result[1]),0,1);
 $insert2 = substr(trim($result[1]),0,4);
 
 if($insert == '/'){ $parts[$i] = "src=\"".$url.$result[1].$result[2]; }
 elseif($insert2 != 'http'){ $parts[$i] = "src=\"".$url."/".$result[1].$result[2]; } 
 else{ $parts[$i] = 'src="'.$result[1].$result[2]; } 
 } 
 
}
$forprint = implode(" ",$parts);
$forprint = preg_replace_callback("/<a href=\"\s*([^\s]*)\"\s*.*?>/m",create_function('$matches','return "<a href='.urlno().'?url2=".base64_encode($matches[1]).">";'),$forprint);
print $forprint;
 }
}elseif($_GET["url2"] != '')
{
 $_GET["url2"] = base64_decode($_GET["url2"]);
 
$path_parts = pathinfo($_GET["url2"]);
if($path_parts['extension'] == "zip"){
 
 // Define the path to file
 $file = $_GET["url2"];
 $filesize = filesize($file);
 
 // Set headers
 header("Cache-Control: public");
 header("Content-Description: File Transfer");
 header("Content-Disposition: attachment; filename={$path_parts['basename']}");
 header("Content-Type: application/zip");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".$filesize); 
 
 // Read the file from disk
 readfile($file);
 }elseif($path_parts['extension'] == "mp3"){
// Define the path to file
 $file = $_GET["url2"];
 $filesize = filesize($file);
 
 // Set headers
 header("Cache-Control: public");
 header("Content-Description: File Transfer");
 header("Content-Disposition: attachment; filename={$path_parts['basename']}");
 header("Content-Type: application/octet-stream");
 //header("Content-type: application/force-download");
 header("Content-Transfer-Encoding: binary");
 header("Content-Length: ".$filesize);
 
 // Read the file from disk
 readfile($file);
 }else{
$parse = parse_url($_GET["url2"]);
$url = "http://".$parse["host"];
$forprint = file_get_contents($_GET["url2"]); 
$parts = explode(" ",$forprint);
for($i = 0, $size = sizeof($parts); $i < $size; ++$i)
{
 $insertu = substr(trim($parts[$i]),0,6);
 if($insertu == 'href="'){ 
$parts[$i] = str_ireplace('href="',"",$parts[$i]);
$result[1] = rstrstr($parts[$i], '"');
$result[2] = strstr($parts[$i], '"');
 $insert = substr(trim($result[1]),0,1);
 $insert2 = substr(trim($result[1]),0,4);
 
 if($insert == '/'){ $parts[$i] = "href=\"".$url.$result[1].$result[2]; }
 elseif($insert2 != 'http'){ $parts[$i] = "href=\"".$url."/".$result[1].$result[2]; } 
 else{ $parts[$i] = 'href="'.$result[1].$result[2]; } 
 }
 //////////////////src=""
 $insertu = substr(trim($parts[$i]),0,5);
 if($insertu == 'src="'){ 
$parts[$i] = str_ireplace('src="',"",$parts[$i]);
$result[1] = rstrstr($parts[$i], '"');
$result[2] = strstr($parts[$i], '"');
 $insert = substr(trim($result[1]),0,1);
 $insert2 = substr(trim($result[1]),0,4);
 
 if($insert == '/'){ $parts[$i] = "src=\"".$url.$result[1].$result[2]; }
 elseif($insert2 != 'http'){ $parts[$i] = "src=\"".$url."/".$result[1].$result[2]; } 
 else{ $parts[$i] = 'src="'.$result[1].$result[2]; } 
 } 
 
}
$forprint = implode(" ",$parts);
$forprint = preg_replace_callback("/<a href=\"\s*([^\s]*)\"\s*.*?>/m",create_function('$matches','return "<a href='.urlno().'?url2=".base64_encode($matches[1]).">";'),$forprint);
print $forprint;
 }
}else{
 
 phpinfo(); 
 
}
?>


Other 10 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.