Advertisement
Guest User

Untitled

a guest
Dec 6th, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. public function index($id = NULL)
  2. {
  3. $start = microtime(true);
  4. /* Get data from DB, and if we have problems with database, we load data from our cache (if cache exists:D) */
  5. if(!$query = $this->database->_get_server_list('servers', 300))
  6. {
  7. exit;
  8. }
  9.  
  10.  
  11. /* Working with data */
  12. foreach ($query->result() as $result)
  13. {
  14. /* Prepare to pass host and port to script */
  15. list($host, $port) = explode(':', $result->address);
  16.  
  17. /* Passing and recieving data */
  18. $GS = new GoldSource($host, $port);
  19. $results[$result->id] = $GS->get_details();
  20.  
  21. /* Checiking for bad array keys */
  22. if(!is_array($results[$result->id]))
  23. {
  24. unset($results[$result->id]);
  25. }
  26. else
  27. {
  28. $results[$result->id]['id'] = $result->id;
  29. }
  30.  
  31. }
  32.  
  33. /* Remove HTML and XSS codes before cache */
  34. $results = $this->_clean($results);
  35.  
  36. /* Pass data to cache */
  37. $this->cache->file->save('list', $results, 3600);
  38. echo 'Exec time: '.(microtime(true) - $start).' s.';
  39. }
  40.  
  41. public function _clean($data = NULL)
  42. {
  43. $this->load->helper('security');
  44.  
  45. $data = $this->security->xss_clean($data);
  46. $data = html_escape($data);
  47.  
  48. return $data;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement