public static function make_openbenchmarking_request($request, $post = array()) { $url = pts_openbenchmarking::openbenchmarking_host() . 'f/client.php'; $to_post = array_merge(array('r' => $request, 'client_version' => PTS_CORE_VERSION, 'gsid' => defined('PTS_GSID') ? PTS_GSID : null, 'gsid_e' => defined('PTS_GSID_E') ? PTS_GSID_E : null), $post); if (PTS_IS_CLIENT && ($account = pts_openbenchmarking_client::get_openbenchmarking_account()) && is_array($account)) { $to_post = array_merge($to_post, $account); } return pts_network::http_upload_via_post($url, $to_post); }
public static function upload_usage_data($task, $data) { if (!pts_network::internet_support_available()) { return false; } switch ($task) { case 'test_install': list($test_install, $time_elapsed) = $data; $upload_data = array('test_identifier' => $test_install->test_profile->get_identifier(), 'test_version' => $test_install->test_profile->get_test_profile_version(), 'elapsed_time' => $time_elapsed); pts_network::http_upload_via_post(pts_openbenchmarking::openbenchmarking_host() . 'extern/statistics/report-test-install.php', $upload_data); break; case 'test_complete': list($test_result, $time_elapsed) = $data; $upload_data = array('test_identifier' => $test_result->test_profile->get_identifier(), 'test_version' => $test_result->test_profile->get_test_profile_version(), 'elapsed_time' => $time_elapsed); pts_network::http_upload_via_post(pts_openbenchmarking::openbenchmarking_host() . 'extern/statistics/report-test-completion.php', $upload_data); break; case 'test_install_failure': list($test_install, $error) = $data; $upload_data = array('test_identifier' => $test_install->test_profile->get_identifier(), 'error' => $error, 'os' => phodevi::read_property('system', 'vendor-identifier')); pts_network::http_upload_via_post(pts_openbenchmarking::openbenchmarking_host() . 'extern/statistics/report-test-install-failure.php', $upload_data); break; } }
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); }