Advertisement
cextor

gateway script

Jul 22nd, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.44 KB | None | 0 0
  1.     <?PHP
  2.     // Coinurl Gateway v1.1
  3.     // Author: Ptv2
  4.     // Website: http://www.pak-soft.org/vb/
  5.     // Function getBrowser() from http://php.net/manual/en/function.get-browser.php#101125
  6.     error_reporting(0);
  7.     session_start();
  8.      
  9.      
  10.     // Settings
  11.     $URLs_file = "urls.dat"; // A file which contains urls
  12.     $log_enabled  = true; // Enable/disable log - Boolean true or false.
  13.     $log_file     = "status.log"; // $log_enabled must be "true" for this to take effect
  14.     $isCloudFlare = false; // If your host/server is protected by CloudFLare set this to true. Boolean true/false only.
  15.      
  16.      
  17.      
  18.      
  19.     // Do not change anything staring from here. Those are functions and pre-set internal variables
  20.     function getCoinUrl($url)
  21.     {
  22.         $uuid = "5165fa0fa1bb6049715674";
  23.         $url = rawurlencode($url);
  24.      
  25.         $result = file_get_contents("https://coinurl.com/api.php?uuid={$uuid}&url={$url}");
  26.      
  27.         if($result == 'error')
  28.             return false;
  29.         else
  30.             return $result;
  31.     }
  32.      
  33.      
  34.     $RDR   = false;
  35.     $proxy = "Not detected";
  36.     if (!file_exists($URLs_file))
  37.         file_put_contents($URLs_file, getCoinUrl("http://www.elite7hackers.us")."\n".getCoinUrl("http://leak.sx")."\n".getCoinUrl("https://www.google.com"));
  38.      
  39.     $URLs = file($URLs_file);
  40.      
  41.     function getBrowser()
  42.     {
  43.         $u_agent  = $_SERVER['HTTP_USER_AGENT'];
  44.         $bname    = 'Unknown';
  45.         $platform = 'Unknown';
  46.         $version  = "";
  47.        
  48.         //First get the platform?
  49.         if (preg_match('/linux/i', $u_agent)) {
  50.             $platform = 'linux';
  51.         } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
  52.             $platform = 'mac';
  53.         } elseif (preg_match('/windows|win32/i', $u_agent)) {
  54.             $platform = 'windows';
  55.         }
  56.        
  57.         // Next get the name of the useragent yes seperately and for good reason
  58.         if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent)) {
  59.             $bname = 'Internet Explorer';
  60.             $ub    = "MSIE";
  61.         } elseif (preg_match('/Firefox/i', $u_agent)) {
  62.             $bname = 'Mozilla Firefox';
  63.             $ub    = "Firefox";
  64.         } elseif (preg_match('/Chrome/i', $u_agent)) {
  65.             $bname = 'Google Chrome';
  66.             $ub    = "Chrome";
  67.         } elseif (preg_match('/Safari/i', $u_agent)) {
  68.             $bname = 'Apple Safari';
  69.             $ub    = "Safari";
  70.         } elseif (preg_match('/Opera/i', $u_agent)) {
  71.             $bname = 'Opera';
  72.             $ub    = "Opera";
  73.         } elseif (preg_match('/Netscape/i', $u_agent)) {
  74.             $bname = 'Netscape';
  75.             $ub    = "Netscape";
  76.         }
  77.        
  78.         // finally get the correct version number
  79.         $known   = array(
  80.             'Version',
  81.             $ub,
  82.             'other'
  83.         );
  84.         $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
  85.         if (!preg_match_all($pattern, $u_agent, $matches)) {
  86.             // we have no matching number just continue
  87.         }
  88.        
  89.         // see how many we have
  90.         $i = count($matches['browser']);
  91.         if ($i != 1) {
  92.             //we will have two since we are not using 'other' argument yet
  93.             //see if version is before or after the name
  94.             if (strripos($u_agent, "Version") < strripos($u_agent, $ub)) {
  95.                 $version = $matches['version'][0];
  96.             } else {
  97.                 $version = $matches['version'][1];
  98.             }
  99.         } else {
  100.             $version = $matches['version'][0];
  101.         }
  102.        
  103.         // check if we have a number
  104.         if ($version == null || $version == "") {
  105.             $version = "?";
  106.         }
  107.        
  108.         return array(
  109.             'userAgent' => $u_agent,
  110.             'name' => $bname,
  111.             'version' => $version,
  112.             'platform' => $platform,
  113.             'pattern' => $pattern
  114.         );
  115.     }
  116.      
  117.      
  118.     $UA = getBrowser();
  119.     $CF = "";
  120.     if (!$isCloudFlare) {
  121.         $IP = @$_SERVER['REMOTE_ADDR'];
  122.     } else {
  123.         $IP = @$_SERVER["HTTP_CF_CONNECTING_IP"] or $IP = @$_SERVER['REMOTE_ADDR'];
  124.         $CF = "-> Cloudflare possible";
  125.     }
  126.      
  127.     if ($_SERVER['HTTP_X_FORWARDED_FOR'] || $_SERVER['HTTP_X_FORWARDED'] || $_SERVER['HTTP_FORWARDED_FOR'] || $_SERVER['HTTP_VIA'] || in_array($_SERVER['REMOTE_PORT'], array(
  128.         8080,
  129.         80,
  130.         6588,
  131.         8000,
  132.         9000,
  133.         9090,
  134.         3128,
  135.         553,
  136.         554
  137.     )) || @fsockopen($IP, 80, $errno, $errstr, 1)) {
  138.         $proxy = "detected";
  139.     }
  140.      
  141.      
  142.      
  143.     $ref = @$_SERVER['HTTP_REFERER'] or $ref = "Unknown";
  144.     $vID        = sha1(session_id() . $IP . $UA['name'] . $UA['version'] . $UA['platform'] . $proxy); // Unique visistor ID
  145.     $visit_data = "Visistor $vID from IP $IP -> Browser: $UA[name] $UA[version] | OS: $UA[platform] | Proxy: $proxy $CF\n";
  146.      
  147.     class xzlog
  148.     {
  149.         public $file = "log_file.log";
  150.         public $swch = false;
  151.        
  152.        
  153.         public function file($file)
  154.         {
  155.             $this->file = $file;
  156.         }
  157.        
  158.         public function status($eod)
  159.         {
  160.             $this->swch = $eod;
  161.         }
  162.        
  163.         public function write($data = "This is log comment")
  164.         {
  165.             if ($this->swch) {
  166.                 $log_data = date("[d/M/Y H:i:s]") . " $data";
  167.                
  168.                 if (file_put_contents($this->file, $log_data, FILE_APPEND)) {
  169.                     return true;
  170.                 }
  171.             }
  172.             return false;
  173.         }
  174.     }
  175.     $log = new xzlog;
  176.     $log->file($log_file);
  177.     $log->status($log_enabled);
  178.     $log->write($visit_data);
  179.     $log->write("Visistor referred by $ref\n");
  180.      
  181.      
  182.     if (isset($_GET['id'])) {
  183.        
  184.         $ID = preg_replace('/\D/', '', $_GET['id']);
  185.         $log->write('$_GET[\'id\'] parameter detected -> ' . $ID . "\n");
  186.         if (array_key_exists($ID, $URLs)) {
  187.             $URL = trim(preg_replace('/\s+/', ' ', $URLs[$ID]));
  188.             $log->write('$_GET[\'id\'] parameter  -> ' . $ID . " has found in database -> $URL\n");
  189.             $RDR = true;
  190.         }
  191.        
  192.     } else {
  193.         $URL_count = count($URLs) - 1;
  194.         $ID        = mt_rand(0, $URL_count);
  195.         $URL       = trim(preg_replace('/\s+/', ' ', $URLs[$ID]));
  196.         $log->write("ID selected by random  -> $ID  ->  $URL\n");
  197.        
  198.         $RDR = true;
  199.        
  200.     }
  201.      
  202.     if ($RDR) {
  203.         $log->write("Visistor $vID redirected to it's location.\n" . str_repeat("_", 148) . "\n");
  204.         header("location: $URL");
  205.        
  206.         // Just in case if browser ignore redirect header
  207.         $eHTML = "<html>\n<head>\n<meta http-equiv=\"refresh\" content=\"0; url=$url\">\n</head>\n<body>\n<h1><a href='$URL'>CLICK HERE</a></h1>\n</body>\n</html>";
  208.         die($eHTML);
  209.     } else {
  210.         $log->write('$_GET[\'id\'] parameter  -> ' . $ID . " has not found in database\n" . str_repeat("_", 148) . "\n");
  211.         echo "<html>\n<head><title>ID Not found</title></head><body>\nThe URL ID you have selected is not available in database.<br/>\n";
  212.         echo "Check one of the exist URLs:<br/>\n";
  213.         foreach ($URLs as $key => $URL) {
  214.             echo "<strong>$key -></strong> <a href='?id=$key'>$URL</a><br/>\n";
  215.         }
  216.         echo "</body>\n</html>";
  217.         exit;
  218.     }
  219.      
  220.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement