Ejemplo n.º 1
0
 protected static function upload_to_remote_server($to_post, $server_address = null, $server_http_port = null, $account_id = null)
 {
     static $last_communication_minute = null;
     static $communication_attempts = 0;
     if ($last_communication_minute == date('i') && $communication_attempts > 8) {
         // Something is wrong, Phoromatic shouldn't be communicating with server more than four times a minute
         return false;
     } else {
         if (date('i') != $last_communication_minute) {
             $last_communication_minute = date('i');
             $communication_attempts = 0;
         }
         $communication_attempts++;
     }
     if ($server_address == null && self::$server_address != null) {
         $server_address = self::$server_address;
     }
     if ($server_http_port == null && self::$server_http_port != null) {
         $server_http_port = self::$server_http_port;
     }
     if ($account_id == null && self::$account_id != null) {
         $account_id = self::$account_id;
     }
     $to_post['aid'] = $account_id;
     $to_post['pts'] = PTS_VERSION;
     $to_post['pts_core'] = PTS_CORE_VERSION;
     $to_post['gsid'] = defined('PTS_GSID') ? PTS_GSID : null;
     $to_post['lip'] = pts_network::get_local_ip();
     $to_post['h'] = phodevi::system_hardware(true);
     $to_post['nm'] = pts_network::get_network_mac();
     $to_post['nw'] = implode(', ', pts_network::get_network_wol());
     $to_post['s'] = phodevi::system_software(true);
     $to_post['n'] = phodevi::read_property('system', 'hostname');
     $to_post['msi'] = PTS_MACHINE_SELF_ID;
     return pts_network::http_upload_via_post('http://' . $server_address . ':' . $server_http_port . '/phoromatic.php', $to_post);
 }