@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | // Total lured |
| 6 | 6 | // ----------------------------------------------------------------------------------------------------------- |
| 7 | 7 | |
| 8 | -$captcha_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 8 | +$captcha_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 9 | 9 | if (is_file($captcha_file)) { |
| 10 | 10 | $capdatas = json_decode(file_get_contents($captcha_file), true); |
| 11 | 11 | // Trim json stats files to last 7 days of data |
@@ -16,36 +16,36 @@ discard block |
||
| 16 | 16 | $variables_secret = SYS_PATH.'/core/json/variables.secret.json'; |
| 17 | 17 | $config_secret = json_decode(file_get_contents($variables_secret)); |
| 18 | 18 | |
| 19 | -if ($config_secret->captcha_key=="") { |
|
| 19 | +if ($config_secret->captcha_key == "") { |
|
| 20 | 20 | $captcha['timestamp'] = $timestamp; |
| 21 | 21 | // get amount of accounts requiring a captcha |
| 22 | 22 | $req = "SELECT COUNT(*) as total " |
| 23 | 23 | . "FROM workerstatus WHERE `captcha` > '0' " |
| 24 | 24 | . "AND last_modified >= UTC_TIMESTAMP() - INTERVAL 60 SECOND"; |
| 25 | - $result = $mysqli->query($req); |
|
| 26 | - $data = $result->fetch_object(); |
|
| 25 | + $result = $mysqli->query($req); |
|
| 26 | + $data = $result->fetch_object(); |
|
| 27 | 27 | $captcha['captcha_accs'] = $data->total; |
| 28 | 28 | // Add the datas in file |
| 29 | - $capdatas[] = $captcha; |
|
| 29 | + $capdatas[] = $captcha; |
|
| 30 | 30 | } else { |
| 31 | 31 | if (!empty($capdatas)) { |
| 32 | 32 | $lastCaptcha = array_pop($capdatas); |
| 33 | 33 | } else { |
| 34 | - $lastCaptcha["timestamp"]=strtotime("-7 days", strtotime(date("Y-m-d"))); |
|
| 34 | + $lastCaptcha["timestamp"] = strtotime("-7 days", strtotime(date("Y-m-d"))); |
|
| 35 | 35 | } |
| 36 | 36 | $lastCaptchaDate = date("Y-m-d", $lastCaptcha["timestamp"]); |
| 37 | 37 | $startTime = strtotime($lastCaptchaDate); |
| 38 | - $endTime = strtotime(date("Y-m-d"))+date("Z"); |
|
| 38 | + $endTime = strtotime(date("Y-m-d")) + date("Z"); |
|
| 39 | 39 | $timeDiff = abs($endTime - $startTime); |
| 40 | - $numberDays = intval($timeDiff/86400) ; // 86400 seconds in one day |
|
| 41 | - if ($numberDays>7) { |
|
| 42 | - $numberDays=7; |
|
| 40 | + $numberDays = intval($timeDiff / 86400); // 86400 seconds in one day |
|
| 41 | + if ($numberDays > 7) { |
|
| 42 | + $numberDays = 7; |
|
| 43 | 43 | } |
| 44 | - while ($numberDays>=0) { |
|
| 45 | - $day = $endTime-($numberDays*86400); |
|
| 44 | + while ($numberDays >= 0) { |
|
| 45 | + $day = $endTime - ($numberDays * 86400); |
|
| 46 | 46 | $captchaUrl = |
| 47 | - "http://2captcha.com/res.php?key=" . |
|
| 48 | - $config_secret->captcha_key . "&action=getstats&date=" . date("Y-m-d", $day); |
|
| 47 | + "http://2captcha.com/res.php?key=". |
|
| 48 | + $config_secret->captcha_key."&action=getstats&date=".date("Y-m-d", $day); |
|
| 49 | 49 | |
| 50 | 50 | $ch = curl_init(); |
| 51 | 51 | curl_setopt($ch, CURLOPT_URL, $captchaUrl); |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | $capXml = simplexml_load_string($fileContents); |
| 68 | 68 | |
| 69 | 69 | foreach ($capXml as $key => $value) { |
| 70 | - if ( ($numberDays==0 |
|
| 71 | - && ((int)$value->Attributes()->hour >= (int)date("H", $lastCaptcha["timestamp"]) |
|
| 72 | - && ((int)$value->Attributes()->hour <= (int)date("H"))) |
|
| 73 | - ) || $numberDays>0) { |
|
| 70 | + if (($numberDays == 0 |
|
| 71 | + && ((int) $value->Attributes()->hour >= (int) date("H", $lastCaptcha["timestamp"]) |
|
| 72 | + && ((int) $value->Attributes()->hour <= (int) date("H"))) |
|
| 73 | + ) || $numberDays > 0) { |
|
| 74 | 74 | $captcha['timestamp'] = |
| 75 | - strtotime(date("Y-m-d", $day) . " " . $value->Attributes()->hour . ":00")+date("Z"); |
|
| 76 | - $captcha['captcha_accs'] = (string)$value->volume; |
|
| 77 | - $capdatas[] = $captcha; |
|
| 75 | + strtotime(date("Y-m-d", $day)." ".$value->Attributes()->hour.":00") + date("Z"); |
|
| 76 | + $captcha['captcha_accs'] = (string) $value->volume; |
|
| 77 | + $capdatas[] = $captcha; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | --$numberDays; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | // This file only include other files to have only 1 entry in your crontabs. |
| 4 | 4 | // ------------------------------------------------------------------------ |
| 5 | 5 | |
| 6 | -$config_file = dirname(__FILE__).'/../../config.php'; |
|
| 6 | +$config_file = dirname(__FILE__).'/../../config.php'; |
|
| 7 | 7 | |
| 8 | 8 | include_once($config_file); |
| 9 | 9 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | # MySQL |
| 26 | -$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 26 | +$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 27 | 27 | |
| 28 | 28 | if ($mysqli->connect_error != '') { |
| 29 | 29 | die('MySQL connect error'); |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // Update dashboard data |
| 34 | 34 | // the following files are updated every run |
| 35 | -$gym_file = SYS_PATH.'/core/json/gym.stats.json'; |
|
| 36 | -$pokestop_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
|
| 37 | -$pokemonstats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
|
| 35 | +$gym_file = SYS_PATH.'/core/json/gym.stats.json'; |
|
| 36 | +$pokestop_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
|
| 37 | +$pokemonstats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (is_file($gym_file)) { |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | |
| 126 | 126 | function trim_stats_json($array, $timestamp) |
| 127 | 127 | { |
| 128 | - foreach($array as $key => $value) { |
|
| 128 | + foreach ($array as $key => $value) { |
|
| 129 | 129 | if ($value['timestamp'] < $timestamp) { |
| 130 | 130 | unset($array[$key]); |
| 131 | 131 | } |