/** * * @param WotPlayer $player */ public static function updatePlayerGlory($player) { $result = self::ajaxRequest("http://worldoftanks.ru/community/clans/show_clan_block/?spa_id={$player->player_id}"); if (!empty($result)) { if ($result['status'] == 'ok') { $data = $result['data']; if (isset($data['glory_points_block'])) { $block = $data['glory_points_block']; $glory = $player->getGlory(); if (preg_match('/id="js-glory-points".*?>(.*?)<\\/a>/', $block, $matches)) { $glory->glory_position = preg_replace('/\\D/', '', $matches[1]) . "\n"; } if (preg_match('/Очки славы: (.*?)</', $block, $matches)) { $glory->glory_points = preg_replace('/\\D/', '', $matches[1]); } $glory->save(false); } } } }
public function actionPresense() { Yii::import('ext.teamspeak.libraries.TeamSpeak3.*', true); //cFsOcmiR // connect to local server, authenticate and spawn an object for the virtual server on port 9987 $ts3 = TeamSpeak3::factory(Yii::app()->params['tsUri']); $clientList = $ts3->clientList(); $memberGroup = $ts3->serverGroupGetByName('MUMMI'); if (empty($memberGroup)) { throw new CException('member group is empty'); } $friendGroup = $ts3->serverGroupGetByName('Друг'); if (empty($friendGroup)) { throw new CException('friend group is empty'); } foreach ($clientList as $client) { if ((string) $client['client_platform'] != 'ServerQuery') { $info = $client->getInfo(); $clientGroups = array(); foreach ($client->memberOf() as $clientGroup) { $clientGroups[$clientGroup->getId()] = $clientGroup; } $teamspeak = WotTeamspeak::model()->with(array('player', 'player.playerClan'))->findByPk($info['client_database_id']); if (empty($teamspeak)) { if (preg_match('/^\\w+/', (string) $client, $matches)) { $playerName = $matches[0]; $player = WotPlayer::model()->with(array('playerClan'))->findByAttributes(array('player_name' => $playerName)); } } else { $player = $teamspeak->player; } if (!empty($player)) { if (empty($player->playerClan)) { if (isset($clientGroups[$memberGroup->getId()])) { } $client->addServerGroup($friendGroup->getId()); $client->remServerGroup($memberGroup->getId()); } else { if (empty($teamspeak)) { $teamspeak = new WotTeamspeak(); $teamspeak->player_id = $player->player_id; $teamspeak->client_database_id = $info['client_database_id']; $teamspeak->save(false); } $sql = "INSERT IGNORE INTO wot_presense(updated_at, client_database_id)VALUES(now(),{$info['client_database_id']})"; Yii::app()->db->createCommand($sql)->execute(); } // $wins=number_format($stat->wins/$stat->battles*100,2); // $description="\nПроцент побед: {$wins} \nWN8: {$player->wn8}\nРЭ: {$player->effect}\n"; // $client->modifyDb(array('client_description'=>$description)); } else { if (isset($clientGroups[$memberGroup->getId()])) { } try { $client->remServerGroup($memberGroup->getId()); } catch (Exception $e) { } if (!isset($clientGroups[$friendGroup->getId()])) { } try { $client->addServerGroup($friendGroup->getId()); } catch (Exception $e) { } } } } }