BlaquuTM

Untitled

Sep 16th, 2018
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <?php
  2. /********************************
  3.  
  4. Author: Tymoteusz `Razor Meister` Bartnik
  5.  
  6.  
  7. Function: record_online()
  8.  
  9. ********************************/
  10.  
  11. class record_online
  12. {
  13. private static $name;
  14. private static $cfg;
  15.  
  16. static public function construct($event_name)
  17. {
  18. global $cfg;
  19. self::$cfg = $cfg[$event_name];
  20. self::$name = $event_name;
  21. }
  22.  
  23.  
  24. static function before_clients()
  25. {
  26. global $query, $server_info, $language, $xbot;
  27.  
  28. $current_online = $server_info['virtualserver_clientsonline'] - $server_info['virtualserver_queryclientsonline'];
  29. $date = date('d-m-Y G:i:s');
  30.  
  31. if(!file_exists("include/cache/record_online.txt"))
  32. {
  33. file_put_contents("include/cache/record_online.txt", json_encode(array('online' => $current_online, 'time' => time())));
  34. }
  35. else
  36. {
  37. $record = @array_reverse(json_decode(file_get_contents("include/cache/record_online.txt"), true));
  38.  
  39. if(!is_array($record) || $record[0]['online'] < $current_online)
  40. {
  41. $record = array_reverse($record);
  42. $record[] = array('online' => $current_online, 'time' => time());
  43. file_put_contents("include/cache/record_online.txt", json_encode($record));
  44. $record = array_reverse($record);
  45. }
  46. else
  47. {
  48. $current_online = $record[0]['online'];
  49. $date = date('d-m-Y G:i:s', $record[0]['time']);
  50. }
  51. }
  52. $desc ="[hr][center][size=15][img]https://i.imgur.com/VZtzkt0.png[/img][/center][hr]\n[size=10]\n[size=11][b]Informacje o aktualnym rekordzie:[/b][/size]\n\n• ".$language['function']['record_online'][1]." [b]".$current_online."[/b] osoby online.\n• ".$language['function']['record_online'][2]." [b]".$date."[/b][/size]";
  53.  
  54. if(self::$cfg['show_history'] && count($record) > 1)
  55. {
  56. $desc .= "\n \n \n [size=11][b]Historia ustanowionych rekordów:[/b][/size]\n\n";
  57. $i = 0;
  58.  
  59. foreach($record as $info)
  60. {
  61. if(($i++) == 0) continue;
  62. $desc .= "• Dnia [b]".date('d-m-Y G:i:s', $info['time'])."[/b] został ustanowiony nowy [b]Rekord[/b] wynoszący [b]".$info['online']."[/b] osób online.\n";
  63. if($i >= 10) break;
  64. }
  65. }
  66.  
  67. $desc .= $language['function']['down_desc'];
  68.  
  69. $name = str_replace('[RECORD]', $current_online, self::$cfg['channel_name']);
  70. $channel = $query->getElement('data', $query->channelInfo(self::$cfg['channel_id']));
  71. if($name != $channel['channel_name'])
  72. $xbot::check_error($query->channelEdit(self::$cfg['channel_id'], array('channel_name' => $name, 'channel_description' => $desc)), self::$name, self::$cfg['channel_id'], true);
  73. }
  74. }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment