@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | // This file only include other files to have only 1 entry in your crontabs. |
| 4 | 4 | // ------------------------------------------------------------------------ |
| 5 | 5 | |
| 6 | -$filePath = dirname(__FILE__); |
|
| 7 | -$config_file = $filePath.'/../../config.php'; |
|
| 6 | +$filePath = dirname(__FILE__); |
|
| 7 | +$config_file = $filePath.'/../../config.php'; |
|
| 8 | 8 | |
| 9 | 9 | include_once($config_file); |
| 10 | 10 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | # MySQL |
| 18 | -$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 18 | +$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 19 | 19 | |
| 20 | 20 | if ($mysqli->connect_error != '') { |
| 21 | 21 | die('MySQL connect error'); |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | -$gym_file = SYS_PATH.'/core/json/gym.stats.json'; |
|
| 27 | -$pokestop_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
|
| 28 | -$pokemonstats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
|
| 26 | +$gym_file = SYS_PATH.'/core/json/gym.stats.json'; |
|
| 27 | +$pokestop_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
|
| 28 | +$pokemonstats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
|
| 29 | 29 | |
| 30 | 30 | $gymsdatas = json_decode(file_get_contents($gym_file), true); |
| 31 | 31 | $stopdatas = json_decode(file_get_contents($pokestop_file), true); |
@@ -7,53 +7,53 @@ |
||
| 7 | 7 | // Total lured |
| 8 | 8 | // ----------------------------------------------------------------------------------------------------------- |
| 9 | 9 | |
| 10 | -$captcha_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 11 | -$capdatas = json_decode(file_get_contents($captcha_file), true); |
|
| 10 | +$captcha_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 11 | +$capdatas = json_decode(file_get_contents($captcha_file), true); |
|
| 12 | 12 | |
| 13 | -if ($config->system->captcha_key=="") { |
|
| 13 | +if ($config->system->captcha_key == "") { |
|
| 14 | 14 | $captcha['timestamp'] = $timestamp; |
| 15 | 15 | // get amount of accounts requiring a captcha |
| 16 | 16 | $req = "SELECT COUNT(*) as total " |
| 17 | 17 | . "FROM workerstatus WHERE message LIKE '%encountering a captcha%' " |
| 18 | 18 | . "AND last_modified >= UTC_TIMESTAMP() - INTERVAL 60 SECOND"; |
| 19 | - $result = $mysqli->query($req); |
|
| 20 | - $data = $result->fetch_object(); |
|
| 19 | + $result = $mysqli->query($req); |
|
| 20 | + $data = $result->fetch_object(); |
|
| 21 | 21 | $captcha['captcha_accs'] = $data->total; |
| 22 | 22 | // Add the datas in file |
| 23 | - $capdatas[] = $captcha; |
|
| 23 | + $capdatas[] = $captcha; |
|
| 24 | 24 | } else { |
| 25 | 25 | if (!empty($capdatas)) { |
| 26 | 26 | $lastCaptcha = array_pop($capdatas); |
| 27 | 27 | } else { |
| 28 | - $lastCaptcha["timestamp"]=strtotime("-7 days"); |
|
| 28 | + $lastCaptcha["timestamp"] = strtotime("-7 days"); |
|
| 29 | 29 | } |
| 30 | 30 | $lastCaptchaDate = date("Y-m-d", $lastCaptcha["timestamp"]); |
| 31 | 31 | $startTime = strtotime($lastCaptchaDate); |
| 32 | 32 | $endTime = strtotime(date("Y-m-d")); |
| 33 | 33 | $timeDiff = abs($endTime - $startTime); |
| 34 | - $numberDays = intval($timeDiff/86400); // 86400 seconds in one day |
|
| 34 | + $numberDays = intval($timeDiff / 86400); // 86400 seconds in one day |
|
| 35 | 35 | echo $lastCaptcha["timestamp"]."\n"; |
| 36 | - if ($numberDays>7) { |
|
| 37 | - $numberDays=7; |
|
| 36 | + if ($numberDays > 7) { |
|
| 37 | + $numberDays = 7; |
|
| 38 | 38 | } |
| 39 | - while ($numberDays>=0) { |
|
| 40 | - $day = $startTime+($numberDays*86400); |
|
| 39 | + while ($numberDays >= 0) { |
|
| 40 | + $day = $startTime + ($numberDays * 86400); |
|
| 41 | 41 | $captchaUrl = |
| 42 | - "http://2captcha.com/res.php?key=" . |
|
| 43 | - $config->system->captcha_key . "&action=getstats&date=" . date("Y-m-d", $day); |
|
| 44 | - $fileContents= file_get_contents($captchaUrl); |
|
| 42 | + "http://2captcha.com/res.php?key=". |
|
| 43 | + $config->system->captcha_key."&action=getstats&date=".date("Y-m-d", $day); |
|
| 44 | + $fileContents = file_get_contents($captchaUrl); |
|
| 45 | 45 | $capXml = simplexml_load_string($fileContents); |
| 46 | 46 | foreach ($capXml as $key => $value) { |
| 47 | - if (($numberDays==0 && ($value->Attributes()->hour >= date("H", $lastCaptcha["timestamp"]))) |
|
| 48 | - || $numberDays>0) { |
|
| 47 | + if (($numberDays == 0 && ($value->Attributes()->hour >= date("H", $lastCaptcha["timestamp"]))) |
|
| 48 | + || $numberDays > 0) { |
|
| 49 | 49 | $captcha['timestamp'] = |
| 50 | - strtotime($value->Attributes()->date . " " . $value->Attributes()->hour . ":00"); |
|
| 51 | - $captcha['captcha_accs'] = (string)$value->volume; |
|
| 52 | - $capdatas[] = $captcha; |
|
| 50 | + strtotime($value->Attributes()->date." ".$value->Attributes()->hour.":00"); |
|
| 51 | + $captcha['captcha_accs'] = (string) $value->volume; |
|
| 52 | + $capdatas[] = $captcha; |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | $numberDays--; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | -$json = json_encode($capdatas); |
|
| 58 | +$json = json_encode($capdatas); |
|
| 59 | 59 | file_put_contents($captcha_file, $json); |