Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $links = [
- 'dwindly' => [
- 'id' => 'dwindly',
- 'hits' => 4,
- 'api' => 'https://dwindly.io/api.php?key=WOSAWOSAWSA'
- ],
- 'linkrex' => [
- 'id' => 'linkrex',
- 'hits' => 1,
- 'api' => 'https://linkrex.net/api?api=d035e1a785ece6953771ee77d8e324a9892d7884'
- ],
- 'dogecoinspace' => [
- 'id' => 'dogecoinspace',
- 'hits' => 10,
- 'api' => 'https://dogecoinspace.us/shortlink/api?api=674e7e8bf5365357362e156e4d07349f6acd60a0'
- ],
- 'madurls' => [
- 'id' => 'madurls',
- 'hits' => 50,
- 'api' => 'http://madurls.com/api?api=ccaf02cf8a234575d314459edf13bebd20e6c9da'
- ],
- 'dogecoinspace' => [
- 'id' => 'dogecoinspace',
- 'hits' => 100,
- 'api' => 'https://dogecoinspace.us/shortlink/api?api=674e7e8bf5365357362e156e4d07349f6acd60a0'
- ]
- ];
- // simplified
- $dbdataorg = array_column($links, 'hits', 'id');
- //check if any used.
- if ($this->user->info->linksarr === '0') {
- ///nothing in db => select a random link
- shuffle($links);
- $linkid = $links[0]['id'];
- $linkapi = $links[0]['api'];
- if ($linkid != 'dwindly') {
- $apiget = json_decode(file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid"), true);
- if ($apiget['status'] == 'error') {
- echo 'Sorry,we cannot generate a link for shortner id: ' . $links[0]['id'] . ' ! Contact admin';die();
- }
- $shortenedUrl = $this->common->nohtml($apiget['shortenedUrl']);
- } else {
- $shortenedUrl = file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid");
- }
- } else {
- $dbdata = unserialize($this->user->info->linksarr);
- $a = $dbdataorg;
- $b = $dbdata;
- $diff = null;
- //remove from original arr, bd array
- foreach ($a as $key => $val) {
- if (array_key_exists($key, $b)) {
- // if val ===0 => remove/dont keep it in arr
- if ($val - $b[$key] > 0) {
- $diff[$key] = abs($val - $b[$key]);
- }
- }
- else {
- $diff[$key] = $val;
- }
- }
- if (!is_array($diff)) {
- $message = ['status' => 'error', 'message' => 'The daily claims limit was reached.Try again tomorrow.', 'title' => 'Error'];
- $this->session->set_flashdata('message', $message);
- redirect(site_url('faucet/' . $faucet['name']));
- }
- $linksleft = $diff;
- $shuffled_array = [];
- $keys = array_keys($linksleft);
- shuffle($keys);
- foreach ($keys as $key) {
- $shuffled_array[$key] = $linksleft[$key];
- }
- $linkid = key($shuffled_array);
- $linkapi = $links[$linkid]['api'];
- $dbdata = serialize($dbdata);
- if ($linkid != 'dwindly') {
- $apiget = json_decode(file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid"), true);
- if ($apiget['status'] == 'error') {
- echo 'Sorry,we cannot generate a link for shortner id: ' . $links[0]['id'] . ' ! Contact admin';die();
- }
- $shortenedUrl = $this->common->nohtml($apiget['shortenedUrl']);
- } else {
- $shortenedUrl = file_get_contents($linkapi . "&url=cryptsly.io/faucet/check/$randomid");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement