Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index($id = NULL)
- {
- $start = microtime(true);
- /* Get data from DB, and if we have problems with database, we load data from our cache (if cache exists:D) */
- if(!$query = $this->database->_get_server_list('servers', 300))
- {
- exit;
- }
- /* Working with data */
- foreach ($query->result() as $result)
- {
- /* Prepare to pass host and port to script */
- list($host, $port) = explode(':', $result->address);
- /* Passing and recieving data */
- $GS = new GoldSource($host, $port);
- $results[$result->id] = $GS->get_details();
- /* Checiking for bad array keys */
- if(!is_array($results[$result->id]))
- {
- unset($results[$result->id]);
- }
- else
- {
- $results[$result->id]['id'] = $result->id;
- }
- }
- /* Remove HTML and XSS codes before cache */
- $results = $this->_clean($results);
- /* Pass data to cache */
- $this->cache->file->save('list', $results, 3600);
- echo 'Exec time: '.(microtime(true) - $start).' s.';
- }
- public function _clean($data = NULL)
- {
- $this->load->helper('security');
- $data = $this->security->xss_clean($data);
- $data = html_escape($data);
- return $data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement