scan_servers_copy.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. if(!DEFINED('EGP'))
  3. exit(header('Refresh: 0; URL=http://'.$_SERVER['SERVER_NAME'].'/404'));
  4. class scan_servers_copy extends cron
  5. {
  6. function __construct()
  7. {
  8. global $sql, $argv, $start_point;
  9. $servers = $argv;
  10. unset($servers[0], $servers[1], $servers[2]);
  11. $sql->query('SELECT `address` FROM `units` WHERE `id`="'.$servers[4].'" LIMIT 1');
  12. if(!$sql->num())
  13. return NULL;
  14. $unit = $sql->get();
  15. $game = $servers[3];
  16. unset($servers[3], $servers[4]);
  17. $sql->query('SELECT `unit` FROM `servers` WHERE `id`="'.$servers[5].'" LIMIT 1');
  18. $server = $sql->get();
  19. $sql->query('SELECT `address`, `passwd` FROM `units` WHERE `id`="'.$server['unit'].'" LIMIT 1');
  20. $unit = $sql->get();
  21. include(LIB.'ssh.php');
  22. // Проверка ssh соедниения пу с локацией
  23. if(!$ssh->auth($unit['passwd'], $unit['address']))
  24. return NULL;
  25. foreach($servers as $id)
  26. {
  27. $copys = $sql->query('SELECT `id` FROM `copy` WHERE `status`="0"');
  28. while($copy = $sql->get($copys))
  29. {
  30. $sql->query('SELECT `uid` FROM `servers` WHERE `id`="'.$id.'" LIMIT 1');
  31. $server = $sql->get();
  32. if(!sys::int($ssh->get('ps aux | grep copy_'.$server['uid'].' | grep -v grep | awk \'{print $2}\'')))
  33. $sql->query('UPDATE `copy` set `status`="1" WHERE `id`="'.$copy['id'].'" LIMIT 1');
  34. }
  35. }
  36. return NULL;
  37. }
  38. }
  39. ?>