Advertisement
dwikharisma

infinite

Feb 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.83 KB | None | 0 0
  1. public function infinite(){
  2.         $postygdiambil="";
  3.         $hal = $this->input->get('hal');
  4.         $recent = $this->input->get('recent');
  5.         /*load cache*/
  6.         $url_c='https://admin.travelingyuk.com/wp-json/wp/v2/posts?filter[orderby]=date&order=desc&per_page=50&status=publish';
  7.         if( $result_c   = $this->is_cache($url_c)){
  8.             $result_c   = $this->cache('GET',$url_c);
  9.         }else{
  10.             $result_c       = file_get_contents($url_c);          
  11.             $result_c       = $this->cache('SET',$url_c,$result_c,3600);
  12.         }
  13.         $datax=json_decode($result_c,TRUE);
  14.  
  15.         if ($hal && $recent){
  16.             if(array_key_exists('excludeinfinit', $_COOKIE)) {
  17.                 $excludeinfinits=explode(',', rtrim($_COOKIE['excludeinfinit'],","));
  18.                 array_push($excludeinfinits, $recent);
  19.                 /*cache*/
  20.                 $url='https://native.travelingyuk.com/infinit';
  21.                 if( $result     = $this->is_cache($url)){
  22.                     $result     = $this->cache('GET',$url);
  23.                 }else{
  24.                     $result     = file_get_contents($url);          
  25.                     $result     = $this->cache('SET',$url,$result,3600);
  26.                 }
  27.                 $natives=json_decode($result,true);
  28.                 foreach ($excludeinfinits as $excludeinfinit) {
  29.                     if(($key=array_search($excludeinfinit,$natives))!==false){
  30.                         unset($natives[$key]);
  31.                     }
  32.                 }
  33.                 if(count($natives)>0){
  34.                     $natives=array_values($natives);
  35.                     setcookie('excludeinfinit', $_COOKIE['excludeinfinit'].$natives[0].',', time() + (60*60*24*30), '/');
  36.                     $id=$natives[0];
  37.                     /*cache*/
  38.                     $url_link='https://native.travelingyuk.com/infinit/get?id='.$id;
  39.                     if( $result_link    = $this->is_cache($url_link)){
  40.                         $result_link    = $this->cache('GET',$url_link);
  41.                     }else{
  42.                         $result_link        = file_get_contents($url_link);          
  43.                         $result_link        = $this->cache('SET',$url_link,$result_link,3600);
  44.                     }
  45.  
  46.                     $link = $result_link;
  47.                     $postygdiambil = base_url().substr($link,1);
  48.                 } else { //native sdh tmpil smua
  49.                     $exclude='';
  50.                     foreach ($natives as $native) {
  51.                         $exclude=$exclude.$native.',';
  52.                     }
  53.                     foreach ($excludeinfinits as $excludeinfinit) {
  54.                         $exclude=$exclude.$excludeinfinit.',';
  55.                     }
  56.                     $exclude=$exclude.$recent;
  57.                      /*cache*/
  58.                     $like=explode(',', rtrim($exclude,","));
  59.                     $datas = array_filter($datax, function ($datax) use ($like) {
  60.                         foreach ($like as $key => $r) {
  61.                             if (stripos($datax['id'], $r) !== false) {
  62.                                 return false;
  63.                             }
  64.                         }          
  65.                         return true;
  66.                     });
  67.                     //print_r($datas);
  68.                     setcookie('excludeinfinit', $_COOKIE['excludeinfinit'].$datas[$hal]['id'].',', time() + (60*60*24*30), '/');
  69.                     $postygdiambil=$datas[$hal]['link'];
  70.                 }
  71.             } else {
  72.                 /*cache*/
  73.                 $url='https://native.travelingyuk.com/index.php/infinit';
  74.                 if( $result     = $this->is_cache($url)){
  75.                     $result     = $this->cache('GET',$url);
  76.                 }else{
  77.                     $result     = file_get_contents($url);          
  78.                     $result     = $this->cache('SET',$url,$result,3600);
  79.                 }
  80.                 $natives=json_decode($result,true);
  81.                 if(count($natives)>0){
  82.                     //hilangkn recent post
  83.                     if(($key=array_search($recent,$natives))!==false){
  84.                         unset($natives[$key]);
  85.                     }
  86.                     setcookie('excludeinfinit', $natives[0].',', time() + (60*60*24*30), '/');
  87.                     $id=$natives[0];
  88.                     /*cache*/
  89.                     $url_link='https://native.travelingyuk.com/infinit/get?id='.$id;
  90.                     if( $result_link    = $this->is_cache($url_link)){
  91.                         $result_link    = $this->cache('GET',$url_link);
  92.                     }else{
  93.                         $result_link        = file_get_contents($url_link);          
  94.                         $result_link        = $this->cache('SET',$url_link,$result_link,3600);
  95.                     }
  96.                     $link = $result_link;
  97.                     $postygdiambil = base_url().substr($link,1);
  98.                 } else {
  99.                     $exclude=(!empty($exclude) ? $exclude : 0);
  100.                     /*cache*/
  101.                     $like=explode(',', rtrim($exclude,","));
  102.                     $datas = array_filter($datax, function ($datax) use ($like) {
  103.                         foreach ($like as $key => $r) {
  104.                             if (stripos($datax['id'], $r) !== false) {
  105.                                 return false;
  106.                             }
  107.                         }          
  108.                         return true;
  109.                     });
  110.                     setcookie('excludeinfinit', $_COOKIE['excludeinfinit'].$datas[$hal]['id'].',', time() + (60*60*24*30), '/');
  111.                     $postygdiambil=$datas[$hal]['link'];
  112.                 }
  113.             }
  114.            
  115.             if(is_null($postygdiambil)){
  116.                 /*cache*/
  117.                     $like=explode(',', rtrim($exclude,","));
  118.                     $datas = array_filter($datax, function ($datax) use ($like) {
  119.                         foreach ($like as $key => $r) {
  120.                             if (stripos($datax['id'], $r) !== false) {
  121.                                 return false;
  122.                             }
  123.                         }          
  124.                         return true;
  125.                     });
  126.                 setcookie('excludeinfinit', $_COOKIE['excludeinfinit'].$datas[$hal]['id'].',', time() + (60*60*24*30), '/');
  127.                 $postygdiambil=$datas[$hal]['link'];
  128.             }
  129.  
  130.             $gasend=$postygdiambil."?iklan=1";//$datas[0]['link'];
  131.             $gasend=str_replace('admin.', '', $gasend);
  132.             $result=$this->travelingyuk->infinite($gasend,$this->device);
  133.             echo $result['data'];
  134.             //print_r($result['data']);
  135.         }
  136.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement