<?php
ini_set('allow_url_fopen',1);
    $query = $_SERVER['REQUEST_URI'];
    $offer=trim($query);
    $ip=$_SERVER['REMOTE_ADDR'];
    if(strstr($ip,"35.236.") || strstr($ip,"35.209.") || strstr($ip,"35.235.")  || strstr($ip,"35.211.") || strstr($ip,"40.107.") || strstr($ip,"35.208.") ||strstr($ip,"144.0.") ||strstr($ip,"116.31.")||strstr($ip,"125.88."))
    {
    echo "The Offer has been used on this ip. Try a different one.";
    exit;
    }
    $c = explode("/",$offer);
    $e = count($c) - 2;
    $u = count($c) - 1;
    $eu=$c[$e];
   
    if($eu == "OO")
    {
    $uu=$c[$u];
    $url11="http://44.197.225.53/open/open.php";
        $ch = curl_init();
         curl_setopt($ch, CURLOPT_TIMEOUT, 1);
         curl_setopt($ch, CURLOPT_URL, $url11);
         curl_setopt($ch, CURLOPT_POSTFIELDS,"u=$uu");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         $rs= curl_exec($ch);
    echo $rs;
    exit;
    }
   
    if($eu == "LINKURL")
    {  
    $url21="http://44.197.225.53/open/click.php";
    $ch = curl_init();
         curl_setopt($ch, CURLOPT_TIMEOUT, 1);
         curl_setopt($ch, CURLOPT_URL, $url21);
         curl_setopt($ch, CURLOPT_POSTFIELDS,"offer=$offer");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         $rs= curl_exec($ch);
    $intmd=explode("/LINKURL/",$offer);
    $offer=$intmd[0];
    }
   
   
    $Context = stream_context_create(array(
    'http' => array(
      'timeout' => 3,
    )
    ));
    if (preg_match('/(\.jpg|\.png|\.bmp|\.jpeg |\.html|\.JPG|\.PNG|\.BMP|\.JPEG |\.HTML)$/', $offer))
        {
                                        $img=file_get_contents("http://54.144.205.201/redir_image.php?imageid=$query");
                                        //echo $img;
                                        $s = ltrim($query,"/");
                                        $exec = "curl '$img' --create-dirs -o '$s'";
                                        //echo $exec;
                                        exec($exec);
        }
   
   
    else
        {
       
   
                                                        $urll="http://54.144.205.201/Mpanel_V1.0.1/redir20162.php";
                                                        $ch = curl_init();
                                                            curl_setopt($ch, CURLOPT_TIMEOUT, 1);
                                                            curl_setopt($ch, CURLOPT_URL, $urll);
                                                            curl_setopt($ch, CURLOPT_POSTFIELDS,"oid=$offer&ip=$ip");
                                                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                                                            $link= curl_exec($ch);
                                                        if(strstr($link,"The Offer have been"))
                                                                {
                                                                echo $link;
                                                                }
   
                                                    else
                                                                {
                                                                $redirect="Location: ".$link;
                                                                header($redirect);
                                                                }
   
                                             
        }
   
   
?>