function loadgame() { // 4.2 [GameName] $this->game['name'] = ''; for ($i = 0; $this->data[$i] != chr(0); $i++) { $this->game['name'] .= $this->data[$i]; } $this->data = substr($this->data, $i + 2); // 0-byte ending the string + 1 unknown byte // 4.3 [Encoded String] $temp = ''; for ($i = 0; $this->data[$i] != chr(0); $i++) { if ($i % 8 == 0) { $mask = ord($this->data[$i]); } else { $temp .= chr(ord($this->data[$i]) - !($mask & 1 << $i % 8)); } } $this->data = substr($this->data, $i + 1); // 4.4 [GameSettings] $this->game['speed'] = convert_speed(ord($temp[0])); if (ord($temp[1]) & 1) { $this->game['visibility'] = convert_visibility(0); } else { if (ord($temp[1]) & 2) { $this->game['visibility'] = convert_visibility(1); } else { if (ord($temp[1]) & 4) { $this->game['visibility'] = convert_visibility(2); } else { if (ord($temp[1]) & 8) { $this->game['visibility'] = convert_visibility(3); } } } } $this->game['observers'] = convert_observers(((ord($temp[1]) & 16) == true) + 2 * ((ord($temp[1]) & 32) == true)); $this->game['teams_together'] = convert_bool(ord($temp[1]) & 64); $this->game['lock_teams'] = convert_bool(ord($temp[2])); $this->game['full_shared_unit_control'] = convert_bool(ord($temp[3]) & 1); $this->game['random_hero'] = convert_bool(ord($temp[3]) & 2); $this->game['random_races'] = convert_bool(ord($temp[3]) & 4); if (ord($temp[3]) & 64) { $this->game['observers'] = convert_observers(4); } $temp = substr($temp, 13); // 5 unknown bytes + checksum // 4.5 [Map&CreatorName] $temp = explode(chr(0), $temp); $this->game['creator'] = $temp[1]; $this->game['map'] = $temp[0]; // 4.6 [PlayerCount] $temp = unpack('Vslots', $this->data); $this->data = substr($this->data, 4); $this->game['slots'] = $temp['slots']; // 4.7 [GameType] $this->game['type'] = convert_game_type(ord($this->data[0])); $this->game['private'] = convert_bool(ord($this->data[1])); $this->data = substr($this->data, 8); // 2 bytes are unknown and 4.8 [LanguageID] is useless // 4.9 [PlayerList] while (ord($this->data[0]) == 0x16) { $this->loadplayer(); $this->data = substr($this->data, 4); } // 4.10 [GameStartRecord] $temp = unpack('Crecord_id/vrecord_length/Cslot_records', $this->data); $this->data = substr($this->data, 4); $this->game = array_merge($this->game, $temp); $slot_records = $temp['slot_records']; // 4.11 [SlotRecord] for ($i = 0; $i < $slot_records; $i++) { if ($this->header['major_v'] >= 7) { $temp = unpack('Cplayer_id/x1/Cslot_status/Ccomputer/Cteam/Ccolor/Crace/Cai_strength/Chandicap', $this->data); $this->data = substr($this->data, 9); } elseif ($this->header['major_v'] >= 3) { $temp = unpack('Cplayer_id/x1/Cslot_status/Ccomputer/Cteam/Ccolor/Crace/Cai_strength', $this->data); $this->data = substr($this->data, 8); } else { $temp = unpack('Cplayer_id/x1/Cslot_status/Ccomputer/Cteam/Ccolor/Crace', $this->data); $this->data = substr($this->data, 7); } $temp['color'] = convert_color($temp['color']); $temp['race'] = convert_race($temp['race']); $temp['ai_strength'] = convert_ai($temp['ai_strength']); if ($temp['slot_status'] == 2) { // do not add empty slots $this->players[$temp['player_id']] = array_merge($this->players[$temp['player_id']], $temp); // Tome of Retraining $this->players[$temp['player_id']]['retraining_time'] = 0; } } // 4.12 [RandomSeed] $temp = unpack('Vrandom_seed/Cselect_mode/Cstart_spots', $this->data); $this->data = substr($this->data, 6); $this->game['random_seed'] = $temp['random_seed']; $this->game['select_mode'] = convert_select_mode($temp['select_mode']); if ($temp['start_spots'] != 0xcc) { // tournament replays from battle.net website don't have this info $this->game['start_spots'] = $temp['start_spots']; } }
function process_action_new_rel($focus, $action_array) { ///Build the relationship information using the Relationship handler $rel_handler = $focus->call_relationship_handler("module_dir", true); $rel_handler->set_rel_vardef_fields($action_array['rel_module'], $action_array['action_module']); //$rel_handler->base_bean = & $focus; $rel_handler->build_info(true); //get related bean $rel_list = $rel_handler->build_related_list("base"); if (!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true') { $check_notify = false; } else { $check_notify = true; } //All, first, filter (FIRST) if (!empty($rel_list[0])) { $rel_list = process_rel_type("rel_module_type", "rel_filter", $rel_list, $action_array); foreach ($rel_list as $rel_object) { //Connect new module to the first related bean. $rel_handler2 = $rel_object->call_relationship_handler("module_dir", true); //$rel_handler->base_bean = & $rel_object; $rel_handler2->get_relationship_information($rel_handler->rel2_bean, true); //get_relationship_information($rel_handler->rel2_bean, $rel_object); $target_module =& $rel_handler->rel2_bean; foreach ($action_array['basic'] as $field => $new_value) { if (isset($target_module->field_defs[$field]['type']) && $target_module->field_defs[$field]['type'] === 'multienum') { $new_value = workflow_convert_multienum_value($new_value); } $target_module->{$field} = convert_bool($new_value, $target_module->field_defs[$field]['type']); if ($field == "email1") { $target_module->email1_set_in_workflow = $target_module->email1; } if ($field == "email2") { $target_module->email2_set_in_workflow = $target_module->email2; } //end foreach value } foreach ($action_array['basic_ext'] as $field => $new_value) { //Only here if there is a datetime. if ($new_value == 'Triggered Date') { $target_module->{$field} = get_expiry_date(get_field_type($target_module->field_defs[$field]), $action_array['basic'][$field], true); if ($target_module->field_defs[$field]['type'] == 'date' && !empty($target_module->field_defs[$field]['rel_field'])) { $rel_field = $target_module->field_defs[$field]['rel_field']; $target_module->{$rel_field} = get_expiry_date('time', $action_array['basic'][$field], true); } } } foreach ($action_array['advanced'] as $field => $meta_array) { $new_value = process_advanced_actions($focus, $field, $meta_array, $target_module); $target_module->{$field} = $new_value; } clean_save_data($target_module, $action_array); //BEGIN BRIDGING FOR MEETINGS/CALLS if (!empty($action_array['bridge_id']) && $action_array['bridge_id'] != "") { $target_module->bridge_id = $action_array['bridge_id']; $target_module->bridge_object = $focus; } //END BRIDGING FOR MEETINGS/CALLS if ($focus->object_name == $target_module->object_name) { $target_module->processed = true; } $target_module->in_workflow = true; $target_module->not_use_rel_in_req = true; $target_module->save($check_notify); //end for loop of all,first, filter } //end if a related record exists to connect this item too. } //end function_action_new_rel }
function process_phase_test_build($results_idxs_hash) { $n = $_POST['number_of_results']; $error_function = "process_phase_test_build()"; # # Do this instead of getting all of the columns passed # so we don't overload the memory space. $columns = array("mpi_install_id", "compiler_name", "compiler_version", "suite_name", "result_message", "description", "environment", "start_timestamp", "test_result", "trial", "duration", "result_stdout", "result_stderr", "merge_stdout_stderr", "exit_value", "exit_signal", "client_serial"); $param_set = get_post_values($columns); ####### # A 'client_serial' is required, so check before moving forward if (!isset($param_set['client_serial']) || 0 == strlen($param_set['client_serial']) || !preg_match("/^\\d+\$/", $param_set['client_serial'], $m)) { $error_output = "CRITICAL ERROR: Cannot continue\n" . "-------------------------------\n" . "Invalid client_serial (" . $param_set['client_serial'] . ") given.\n" . "-------------------------------\n"; mtt_send_mail($error_output, $error_function); mtt_abort(400, $error_output); exit(1); } ####### # Get the MPI Install IDs $mpi_install_ids = get_mpi_install_ids($param_set['mpi_install_id']); foreach (array_keys($mpi_install_ids) as $k) { if (!preg_match("/\\d+\$/", $k, $m)) { $results_idxs_hash[$k] = $mpi_install_ids[$k]; } } for ($i = 0; $i < $n; $i++) { # The POST fields are enumerated starting at 1 $j = $i + 1; ######## # Select/Insert: test_build_compiler -> compiler # Error out if the client did not supply a compiler, # as DEFAULT is meaningless here $stmt_fields = array("compiler_name", "compiler_version"); $stmt_values = array(); for ($f = 0; $f < count($stmt_fields); $f++) { if (0 == strcasecmp(get_scalar($param_set[$stmt_fields[$f]], $i), "DEFAULT")) { mtt_error("ERROR: No compiler reported which is required for test_build submits " . "[field '" . $stmt_fields[$f] . "' empty]\n"); mtt_abort(400, "\nNo compiler supplied for test_build submit. " . "[field '" . $stmt_fields[$f] . "' empty]"); exit(1); } $stmt_values[] = get_scalar($param_set[$stmt_fields[$f]], $i); } $results_idxs_hash['test_build_compiler_id'] = select_insert("compiler", "compiler_id", $stmt_fields, $stmt_values, false); ######## # Select/Insert: test_suites $stmt_fields = array("suite_name", "test_suite_description"); $stmt_values = array(get_scalar($param_set['suite_name'], $i), "DEFAULT"); $results_idxs_hash['test_suite_id'] = select_insert("test_suites", "test_suite_id", $stmt_fields, $stmt_values, false); ######### # Select/Insert: Description (Test Build) $results_idxs_hash['description_id'] = 0; if (!is_sql_key_word(get_scalar($param_set['description'], $i))) { $stmt_fields = array("description"); $stmt_values = array(get_scalar($param_set['description'], $i)); $results_idxs_hash['description_id'] = select_insert("description", "description_id", $stmt_fields, $stmt_values, false); } ######### # Select/Insert: Result Message $stmt_fields = array("result_message"); $stmt_values = array(get_scalar($param_set['result_message'], $i)); $results_idxs_hash['result_message_id'] = select_insert("result_message", "result_message_id", $stmt_fields, $stmt_values, false); ######### # Select/Insert: Environment $results_idxs_hash['environment_id'] = 0; if (isset($_POST["environment_{$j}"])) { $stmt_fields = array("environment"); $stmt_values = array(get_scalar($param_set['environment'], $i)); $results_idxs_hash['environment_id'] = select_insert("environment", "environment_id", $stmt_fields, $stmt_values, false); } ######### # Insert: Result for MPI Install $stmt_fields = array("submit_id", "compute_cluster_id", "mpi_install_compiler_id", "mpi_get_id", "mpi_install_configure_id", "mpi_install_id", "test_suite_id", "test_build_compiler_id", "description_id", "start_timestamp", "test_result", "trial", "submit_timestamp", "duration", "environment_id", "result_stdout", "result_stderr", "result_message_id", "merge_stdout_stderr", "exit_value", "exit_signal", "client_serial"); $stmt_values = array($results_idxs_hash['submit_id'], $results_idxs_hash['compute_cluster_id'], $results_idxs_hash['mpi_install_compiler_id'], $results_idxs_hash['mpi_get_id'], $results_idxs_hash['mpi_install_configure_id'], $results_idxs_hash['mpi_install_id'], $results_idxs_hash['test_suite_id'], $results_idxs_hash['test_build_compiler_id'], $results_idxs_hash['description_id'], get_scalar($param_set['start_timestamp'], $i), get_scalar($param_set['test_result'], $i), get_scalar($param_set['trial'], $i), "DEFAULT", get_scalar($param_set['duration'], $i), $results_idxs_hash['environment_id'], get_scalar($param_set['result_stdout'], $i), get_scalar($param_set['result_stderr'], $i), $results_idxs_hash['result_message_id'], convert_bool(get_scalar($param_set['merge_stdout_stderr'], $i)), get_scalar($param_set['exit_value'], $i), get_scalar($param_set['exit_signal'], $i), get_scalar($param_set['client_serial'], $i)); $test_build_id = select_insert("test_build", "test_build_id", $stmt_fields, $stmt_values, true); debug("*** Test Build Id [{$test_build_id}]\n"); } return $test_build_id; }