//print_r($new); if ($new['status'] == 'ok' && $new['status_code'] == 'NO_ERROR') { $cache->clear('get_last_roster_' . $config['clan']); $cache->set('get_last_roster_' . $config['clan'], $new); } else { unset($new); $new = $cache->get('get_last_roster_' . $config['clan'], 0); if ($new === FALSE or empty($new)) { die('No cahced data'); } } //Starting geting data if ($new['status'] == 'ok' && $new['status_code'] == 'NO_ERROR') { //Sorting roster $roster = roster_sort($new['data']['members']); $roster_id = roster_resort_id($roster); // get list of all tanks in game from api /*$tanks = $cache->get('tanks_'.$config['clan'],0,ROOT_DIR.'/cache/other/'); if(empty($tanks)){ $tanks = get_api_tanks($config); if($tanks['status'] == 'ok' && $tanks['status_code'] == 'NO_ERROR'){ $cache->clear('tanks_'.$config['clan'],ROOT_DIR.'/cache/other/'); $cache->set('tanks_'.$config['clan'], $tanks['data']['items'],ROOT_DIR.'/cache/other/'); $tanks = $tanks['data']['items']; } } */ //Check if DB updating now while (lock_check() !== TRUE) { sleep('10'); } $get = array();
function clean_db_left_players() { global $db, $cache, $config; $new = $cache->get('get_last_roster_' . $config['clan'], 0); if ($new === FALSE or empty($new['data']['members'])) { return; } $roster_id = array_keys(roster_resort_id($new['data']['members'])); if (count($roster_id) > 0) { $sql = 'SHOW TABLES LIKE "' . $db->prefix . 'col%";'; $q = $db->prepare($sql); if ($q->execute() == TRUE) { $tmp = $q->fetchAll(PDO::FETCH_COLUMN, 0); } else { die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql)); } if (count($tmp) > 0) { $roster_id_tmp = implode(',', $roster_id); foreach ($tmp as $val) { $sql = 'DELETE FROM ' . $val . ' WHERE account_id NOT IN(' . $roster_id_tmp . ');'; $q = $db->prepare($sql); if ($q->execute() != TRUE) { die(show_message($q->errorInfo(), __LINE__, __FILE__, $sql)); } //echo $sql,'<br />'; } } } }