Skip to content

Instantly share code, notes, and snippets.

@Ashkanph
Created June 30, 2018 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ashkanph/9eb3dfca6a46b2ea9c13c8b7955c3ba4 to your computer and use it in GitHub Desktop.
Save Ashkanph/9eb3dfca6a46b2ea9c13c8b7955c3ba4 to your computer and use it in GitHub Desktop.
My PHP proxy
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
//$ch = curl_init($_GET['url']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
//echo "http://185.162.235.142:80/".$_GET['url'];
//curl_setopt($ch, CURLOPT_PROXY, "http://999.999.999.999:2000"); //your proxy url
//curl_setopt($ch, CURLOPT_PROXYPORT, "2000"); // your proxy port number
//curl_setopt($ch, CURLOPT_URL, "http://999.999.999.999/api/v1/category");
// curl_setopt($ch, CURLOPT_URL, "http://999.999.999.999.3");
curl_setopt($ch, CURLOPT_URL, "http://999.999.999.999:80/".$_GET['url']);
// curl_setopt($ch, CURLOPT_PORT, 2040);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-type: application/vnd+cbnv+endpoint']);
$output = curl_exec($ch);
//$info = curl_getinfo($ch);
//var_dump($info);
//var_dump(curl_error($ch));
curl_close($ch);
echo $output;
//echo function_exists('curl_exec');
//echo extension_loaded('curl');
/*
echo '<pre>';
var_dump(curl_version());
echo '</pre>';
*/
/*
// To check if ports are open
//$host = 'http://999.999.999.999/api/v1/category';
$host = 'egovahi.ir';
$ports = array(88, 21, 25, 80, 81, 110, 443, 3306, 2000);
foreach ($ports as $port)
{
$connection = @fsockopen($host, $port);
if (is_resource($connection))
{
echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "\n";
fclose($connection);
}
else
{
echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n";
}
}
*/
//echo file_get_contents("http://999.999.999.999/".$_GET['url']);
/*
$fp = fsockopen('999.999.999.999:2000/api/v1', 2000, $errno, $errstr, 5);
if (!$fp) {
echo "port is closed or blocked";
} else {
echo "port is open and available";
fclose($fp);
}*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment