Advertisement
SrDante

Untitled

Jun 20th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.29 KB | None | 0 0
  1. <?php
  2.  
  3. $links = [
  4.     'dwindly'       => [
  5.         'id'   => 'dwindly',
  6.         'hits' => 4,
  7.         'api'  => 'https://dwindly.io/api.php?key=WOSAWOSAWSA'
  8.     ],
  9.     'linkrex'       => [
  10.         'id'   => 'linkrex',
  11.         'hits' => 1,
  12.         'api'  => 'https://linkrex.net/api?api=d035e1a785ece6953771ee77d8e324a9892d7884'
  13.     ],
  14.     'dogecoinspace' => [
  15.         'id'   => 'dogecoinspace',
  16.         'hits' => 10,
  17.         'api'  => 'https://dogecoinspace.us/shortlink/api?api=674e7e8bf5365357362e156e4d07349f6acd60a0'
  18.     ],
  19.  
  20.     'madurls'       => [
  21.         'id'   => 'madurls',
  22.         'hits' => 50,
  23.         'api'  => 'http://madurls.com/api?api=ccaf02cf8a234575d314459edf13bebd20e6c9da'
  24.     ],
  25.     'dogecoinspace' => [
  26.         'id'   => 'dogecoinspace',
  27.         'hits' => 100,
  28.         'api'  => 'https://dogecoinspace.us/shortlink/api?api=674e7e8bf5365357362e156e4d07349f6acd60a0'
  29.     ]
  30. ];
  31.  
  32. // simplified
  33. $dbdataorg = array_column($links, 'hits', 'id');
  34.  
  35. //check if any used.
  36. if ($this->user->info->linksarr === '0') {
  37.     ///nothing in db => select a random link
  38.     shuffle($links);
  39.     $linkid  = $links[0]['id'];
  40.     $linkapi = $links[0]['api'];
  41.    
  42.     if ($linkid != 'dwindly') {
  43.        
  44.         $apiget = json_decode(file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid"), true);
  45.  
  46.         if ($apiget['status'] == 'error') {
  47.             echo 'Sorry,we cannot generate a link for shortner id: ' . $links[0]['id'] . ' !  Contact admin';die();
  48.         }
  49.  
  50.         $shortenedUrl = $this->common->nohtml($apiget['shortenedUrl']);
  51.  
  52.     } else {
  53.  
  54.         $shortenedUrl = file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid");
  55.  
  56.     }
  57.  
  58. } else {
  59.  
  60.     $dbdata = unserialize($this->user->info->linksarr);
  61.  
  62.     $a    = $dbdataorg;
  63.     $b    = $dbdata;
  64.     $diff = null;
  65.     //remove from original arr, bd array
  66.     foreach ($a as $key => $val) {
  67.         if (array_key_exists($key, $b)) {
  68.             // if val ===0 => remove/dont keep it in arr
  69.             if ($val - $b[$key] > 0) {
  70.                 $diff[$key] = abs($val - $b[$key]);
  71.             }
  72.  
  73.         }
  74.         else {
  75.             $diff[$key] = $val;
  76.         }
  77.     }
  78.  
  79.     if (!is_array($diff)) {
  80.         $message = ['status' => 'error', 'message' => 'The daily claims limit was reached.Try again tomorrow.', 'title' => 'Error'];
  81.         $this->session->set_flashdata('message', $message);
  82.         redirect(site_url('faucet/' . $faucet['name']));
  83.     }
  84.  
  85.     $linksleft = $diff;
  86.  
  87.     $shuffled_array = [];
  88.  
  89.     $keys = array_keys($linksleft);
  90.     shuffle($keys);
  91.  
  92.     foreach ($keys as $key) {
  93.         $shuffled_array[$key] = $linksleft[$key];
  94.     }
  95.  
  96.     $linkid = key($shuffled_array);
  97.  
  98.     $linkapi = $links[$linkid]['api'];
  99.     $dbdata  = serialize($dbdata);
  100.  
  101.     if ($linkid != 'dwindly') {
  102.        
  103.         $apiget = json_decode(file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid"), true);
  104.  
  105.  
  106.         if ($apiget['status'] == 'error') {
  107.             echo 'Sorry,we cannot generate a link for shortner id: ' . $links[0]['id'] . ' !  Contact admin';die();
  108.         }
  109.  
  110.         $shortenedUrl = $this->common->nohtml($apiget['shortenedUrl']);
  111.  
  112.  
  113.     } else {
  114.  
  115.         $shortenedUrl = file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid");
  116.  
  117.     }
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement