public function testCreate() { $admin = $this->admins('Test'); $server = $this->servers('127.0.0.1'); $model = new SBBan(); $model->name = 'Tester'; $model->type = SBBan::TYPE_STEAM; $model->steam = 'STEAM_0:1:2'; $model->reason = 'Testing'; $model->length = 5; $model->server_id = $server->id; $model->admin_id = $admin->id; $this->assertTrue($model->save()); }
public function actionBanGroup($id) { $group = new SteamGroup($id); $members = $group->members; do { // SteamProfile::getSummaries is limited to 100 Steam IDs, // so repeatedly remove the first 100 until the array is empty. $steamids = array_splice($members, 0, 100); $profiles = SteamProfile::getSummaries($steamids); $steamids = Helpers::getSteamId($steamids); foreach ($profiles as $i => $member) { $ban = new SBBan(); $ban->type = SBBan::TYPE_STEAM; $ban->steam = $steamids[$i]; $ban->name = $member['personaname']; $ban->reason = 'Member of Steam Community group "' . $group->groupName . '"'; $ban->length = 0; $ban->save(); } } while (!empty($members)); }
public function actionImport() { $file = $_FILES['file']; switch ($file['name']) { // Source Dedicated Server case 'banned_ip.cfg': case 'banned_user.cfg': foreach (file($file['tmp_name']) as $line) { list(, $length, $identity) = explode(' ', rtrim($line)); // If this is not a permanent ban, ignore if ($length) { continue; } // Steam ID if (preg_match(SourceBans::PATTERN_STEAM, $identity)) { $ban = new SBBan(); $ban->type = SBBan::TYPE_STEAM; $ban->steam = $identity; $ban->reason = 'Imported from banned_user.cfg'; $ban->length = 0; $ban->save(); } else { if (preg_match(SourceBans::PATTERN_IP, $identity)) { $ban = new SBBan(); $ban->type = SBBan::TYPE_IP; $ban->ip = $identity; $ban->reason = 'Imported from banned_ip.cfg'; $ban->length = 0; $ban->save(); } } } break; // ESEA Ban List // ESEA Ban List case 'esea_ban_list.csv': $handle = fopen($file['tmp_name'], 'r'); while (list($steam, $name) = fgetcsv($handle, 4096)) { $steam = 'STEAM_' . trim($steam); if (!preg_match(SourceBans::PATTERN_STEAM, $steam)) { continue; } $ban = new SBBan(); $ban->type = SBBan::TYPE_STEAM; $ban->steam = $steam; $ban->name = $name; $ban->reason = 'Imported from esea_ban_list.csv'; $ban->length = 0; $ban->save(); } fclose($handle); break; default: throw new CHttpException(500, Yii::t('sourcebans', 'controllers.bans.import.error')); } SourceBans::log('Bans imported', 'Bans imported from ' . $file['name']); Yii::app()->user->setFlash('success', Yii::t('sourcebans', 'Imported successfully')); $this->redirect(array('default/bans')); }