Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.76 KB | None | 0 0
  1. <?php
  2.  
  3. class welcomeMessage
  4. {
  5.  
  6. function start(&$clientList, &$channelList, &$serverInfo, &$config)
  7. {
  8. global $query;
  9. global $clients;
  10. global $instanceid;
  11. global $pdo;
  12.  
  13. $msg = fopen('include/config/messages/welcomeMessage.txt', "r");
  14.  
  15.  
  16. $clients['nowi'] = self::clientlist($clientList);
  17. if(array_key_exists('actual',$clients))
  18. {
  19. $clients['roznica'] = array_diff($clients['nowi'], $clients['actual']);
  20.  
  21.  
  22.  
  23. if(count($clients['roznica']) != 0) {
  24. foreach($clients['roznica'] as $clid) {
  25. $client1 = $query->getElement('data', $query->clientInfo($clid));
  26. $queryaM = $pdo->prepare("SELECT * FROM adminMessage WHERE uid = '".$client1['client_unique_identifier']."' ");
  27. $queryaM->execute();
  28. $row = $queryaM->fetch(PDO::FETCH_ASSOC);
  29. if($queryaM->rowCount() > 0) $adminMessage = "[b]Wiadomość od Administracji:[/b] ".$row['message'];
  30. while(!feof($msg))
  31. {
  32. $line = fgets($msg);
  33. if(!$config[$instanceid]['instance']['enable_database'])
  34. {
  35. if(strpos($line, '[topTimeSpent]') || strpos($line, '[topConnectionTime]'))
  36. {
  37. $line = null;
  38. }
  39. $message = self::convertmsg($line, $clid, $serverInfo);
  40. $queryaM = $pdo->prepare("SELECT * FROM adminMessage WHERE uid = '".$client1['client_unique_identifier']."' ");
  41. $queryaM->execute();
  42. $row = $queryaM->fetch(PDO::FETCH_ASSOC);
  43. $adminMessage = "[b]Wiadomość od Administracji:[/b] ".$row['message'];
  44. }
  45. else
  46. {
  47. $message = self::convertDbMsg($line, $clid, $serverInfo, $config);
  48. }
  49. $query->sendMessage(1, $clid, $message);
  50. }
  51. if(isset($adminMessage)) {
  52. $query->sendMessage(1, $clid, $adminMessage);
  53. $queryaM = $pdo->prepare("DELETE FROM adminMessage WHERE uid = '".$client1['client_unique_identifier']."' ");
  54. $queryaM->execute();
  55. }
  56. }
  57. }
  58. }
  59.  
  60. $clients['actual'] = $clients['nowi'];
  61. }
  62.  
  63. function clientlist($clientList) {
  64.  
  65. global $query;
  66.  
  67. $clients['all'] = $clientList;
  68.  
  69. $clients['recent'] = array();
  70. foreach($clients['all'] as $client) {
  71.  
  72. if($client['client_type'] == 0) {
  73. array_push($clients['recent'], $client['clid']);
  74. }
  75. }
  76.  
  77. return $clients['recent'];
  78. }
  79.  
  80. function convertmsg($msg, $clientid, $serverInfo)
  81. {
  82. global $query;
  83. global $instance;
  84.  
  85. $client = $query->getElement('data', $query->clientInfo($clientid));
  86. $serverinfo = $serverInfo;
  87.  
  88. $result = $instance->convertSeconds($serverinfo['virtualserver_uptime']);
  89.  
  90. $uptime = '';
  91. if($result['days']>0)
  92. {
  93. $uptime .= ''.$result['days'].' dni ';
  94. }
  95. if($result['hours']>0)
  96. {
  97. $uptime .= ''.$result['hours'].' godzin ';
  98. }
  99. if($result['minutes']>0)
  100. {
  101. $uptime .= ''.$result['minutes'].' minut';
  102. }
  103. if($uptime=='')
  104. {
  105. $uptime .= ''.$result['seconds'].' sekund';
  106. }
  107.  
  108.  
  109. $online = $serverinfo['virtualserver_clientsonline'] - $serverInfo['virtualserver_queryclientsonline'];
  110.  
  111. $fp = fopen("cache/onlinerecord", "r");
  112. $tekst = fread($fp, 4);
  113. $record = (int)$tekst;
  114. fclose($fp);
  115.  
  116.  
  117. $podmien = array(
  118. 1 => array(1 => '[nickname]', 2 => $client['client_nickname']),
  119. 2 => array(1 => '[connections]', 2 => $client['client_totalconnections']),
  120. 3 => array(1 => '[client_first_connected]', 2 => date("d.m.Y", $client['client_created'])),
  121. 4 => array(1 => '[client_last_connected]', 2 => date("d.m.Y", $client['client_lastconnected'])),
  122. 5 => array(1 => '[server_name]', 2 => $serverinfo['virtualserver_name']),
  123. 6 => array(1 => '[online]', 2 => $online),
  124. 7 => array(1 => '[max]', 2 => $serverinfo['virtualserver_maxclients']),
  125. 8 => array(1 => '[uptime]', 2 => $uptime),
  126. 9 => array(1 => '[record]', 2 => $record));
  127.  
  128. foreach($podmien as $new)
  129. {
  130. $msg = str_replace($new[1], $new[2], $msg);
  131. }
  132.  
  133. return $msg;
  134. }
  135.  
  136. function convertDbMsg($msg, $clientid, $serverInfo, $config)
  137. {
  138. global $query;
  139. global $instance;
  140. global $instanceid;
  141. global $pdo;
  142.  
  143.  
  144. $client = $query->getElement('data', $query->clientInfo($clientid));
  145. $serverinfo = $serverInfo;
  146.  
  147. $sql= $pdo->prepare("SELECT * FROM topConnectionTime WHERE uid = '".$client['client_unique_identifier']."' ");
  148. $sql->execute();
  149.  
  150. $u_data=$sql->fetch(PDO::FETCH_ASSOC);
  151.  
  152. if(!$u_data['id']==null && $client['client_type']!=1)
  153. {
  154. $init = $u_data['connectionTime']/1000;
  155. $hours = floor($init / 3600);
  156. $minutes = floor(($init / 60) % 60);
  157. $seconds = $init % 60;
  158. $topConnectionTime = '';
  159. if($hours>0)
  160. {
  161. $topConnectionTime .= ''.$hours.' godzin ';
  162. }
  163. if($minutes>0)
  164. {
  165. $topConnectionTime .= ''.$minutes.' minut ';
  166. }
  167. if($seconds>0)
  168. {
  169. $topConnectionTime .= ''.$seconds.' sekund';
  170. }
  171. }
  172. else
  173. {
  174. $topConnectionTime = 'Brak najdłuższego czasu połączenia';
  175. }
  176.  
  177. $sql= $pdo->prepare("SELECT * FROM topTimeSpent WHERE uid = '".$client['client_unique_identifier']."' ");
  178. $sql->execute();
  179.  
  180. $u_data = $sql->fetch(PDO::FETCH_ASSOC);
  181.  
  182. if($u_data['id']!=null && $client['client_type']!=1)
  183. {
  184. $init = $u_data['timeSpent'];
  185. $hours = floor($init / 3600);
  186. $minutes = floor(($init / 60) % 60);
  187. $seconds = $init % 60;
  188. $topTimeSpent = '';
  189. if($hours>0)
  190. {
  191. $topTimeSpent .= ''.$hours.' godzin ';
  192. }
  193. if($minutes>0)
  194. {
  195. $topTimeSpent .= ''.$minutes.' minut ';
  196. }
  197. if($seconds>0)
  198. {
  199. $topTimeSpent .= ''.$seconds.' sekund';
  200. }
  201. }
  202. else
  203. {
  204. $topTimeSpent = 'Brak czasu spędzonego na serwerze';
  205. }
  206.  
  207.  
  208.  
  209. $result = $instance->convertSeconds($serverinfo['virtualserver_uptime']);
  210.  
  211. $uptime = '';
  212. if($result['days']>0)
  213. {
  214. $uptime .= ''.$result['days'].' dni ';
  215. }
  216. if($result['hours']>0)
  217. {
  218. $uptime .= ''.$result['hours'].' godzin ';
  219. }
  220. if($result['minutes']>0)
  221. {
  222. $uptime .= ''.$result['minutes'].' minut';
  223. }
  224. if($uptime=='')
  225. {
  226. $uptime .= ''.$result['seconds'].' sekund';
  227. }
  228.  
  229. $online = $serverinfo['virtualserver_clientsonline'] - $serverInfo['virtualserver_queryclientsonline'];
  230.  
  231. $fp = fopen("cache/onlinerecord", "r");
  232. $tekst = fread($fp, 4);
  233. $record = (int)$tekst;
  234. fclose($fp);
  235.  
  236.  
  237. $podmien = array(
  238. 1 => array(1 => '[nickname]', 2 => $client['client_nickname']),
  239. 2 => array(1 => '[connections]', 2 => $client['client_totalconnections']),
  240. 3 => array(1 => '[client_first_connected]', 2 => date("d.m.Y", $client['client_created'])),
  241. 4 => array(1 => '[client_last_connected]', 2 => date("d.m.Y", $client['client_lastconnected'])),
  242. 5 => array(1 => '[server_name]', 2 => $serverinfo['virtualserver_name']),
  243. 6 => array(1 => '[online]', 2 => $online),
  244. 7 => array(1 => '[max]', 2 => $serverinfo['virtualserver_maxclients']),
  245. 8 => array(1 => '[uptime]', 2 => $uptime),
  246. 9 => array(1 => '[record]', 2 => $record),
  247. 10 => array(1 => '[topConnectionTime]', 2 => $topConnectionTime),
  248. 11 => array(1 => '[topTimeSpent]', 2 => $topTimeSpent));
  249.  
  250. foreach($podmien as $new)
  251. {
  252. $msg = str_replace($new[1], $new[2], $msg);
  253. }
  254.  
  255. return $msg;
  256. }
  257.  
  258. }
  259.  
  260. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement