if (!isset($POST_DATA[$PK])) { $POST_DATA[$PK] = $PD; } } $requestdata = array('post' => $POST_DATA); $rd = base64_encode(serialize($requestdata)); $sha1_jid = sha1(microtime() . $rd . rand(1, 20)); $possible_server_list = array(); $assign_hf_list = new assign_hf(); $assign_hfs = $assign_hf_list->get_from_hashrange($u->id_user, $qn . "@", "BEGINS_WITH"); if ($assign_hfs && count($assign_hfs) > 0) { foreach ($assign_hfs as $assign_hf) { $possible_server_name_split = explode("@", $assign_hf['hf_server']); if ($possible_server_name_split) { $possible_server_name = $possible_server_name_split[1]; $possible_user_server = new user_server(); $possible_user_server->get_from_hashrange($u->id_user, $possible_server_name); if ($possible_user_server->name != "undefined" && intval($possible_user_server->int_online) == 1) { $possible_server_list[] = $possible_user_server; } } } // END FOREACH (ASSIGN HFS) } // sort possible servers by busyness usort($possible_server_list, "serveravailsort"); //$possible_server_list = array_reverse($possible_server_list); $list_of_eligible_servers = array(); foreach ($possible_server_list as $possible_server) { $timespan = intval(gmdate('U')) - intval($possible_server->last_ping); // if the "last seen time is within 3 minutes"
public function reassign_auto() { global $mode_server; $user_servers = array(); $user_server = new user_server(); // LIST OF ALL JOB SERVERS $user_servers = $user_server->get_from_hashrange($this->id_user); // HOW MANY NON-BUSY JOB SERVERS $not_busy_servers = array(); foreach ($user_servers as $user_server) { if (isset($user_server['is_busy'])) { if ($user_server['is_busy'] . "" != "1" && $user_server['int_online'] . "" == "1") { $not_busy_servers[] = $user_server; } } } // HOW MANY OTHER NON-BUSY JOB SERVERS (INC. THIS ONE) WERE LAST SEEN IN THE PAST 30 SECONDS $server_second_timerange = 30; $current_not_busy_servers = array(); foreach ($not_busy_servers as $not_busy_server) { $timespan = intval(get_time()) - intval($not_busy_server['last_ping']); if ($timespan < $server_second_timerange) { $current_not_busy_servers[] = $not_busy_server; } } // SORT THIS LIST usort($current_not_busy_servers, "nameindexordersort"); usort($current_not_busy_servers, "lastpingordersort"); $current_not_busy_servers_by_name = array(); foreach ($current_not_busy_servers as $current_not_busy_server) { $current_not_busy_servers_by_name[$current_not_busy_server['name']] = $current_not_busy_server; } //echo "CURRENT NOT BUSY SERVERS:";print_r($current_not_busy_servers_by_name); //echo "FIRST SERVER:".$current_not_busy_servers[0]['name']; // IS THIS SERVER THE FIRST IN THE LIST? //if ( count($current_not_busy_servers)>0 ) //&& $INSTANCE_NAME==$current_not_busy_servers[0]['name'] ) //{ $assigned_servers = array(); $assignable_hf = new assign_hf(); //echo "SEARCHING FOR ASSIGNABILITY:".$job_assign_hf; $job_reassignability = $assignable_hf->get_from_hashrange($this->id_user, $this->id_hf, "BEGINS_WITH"); //echo "ASSIGNABILITY:"; //print_r($job_reassignability); $find_id_prefix = $this->id_hf . "@"; $eligible_servers = array(); foreach ($job_reassignability as $job_reassign_hf) { //echo "ADDING ELIGIBLE SERVER:".str_replace($find_id_prefix,"",$job_reassign_hf['hf_server'])."\n"; $eligible_servers[] = str_replace($find_id_prefix, "", $job_reassign_hf['hf_server']); } $eligible_not_busy_servers = array(); foreach ($eligible_servers as $eligible_server) { if (in_array($eligible_server, array_keys($current_not_busy_servers_by_name)) && !in_array($eligible_server, $assigned_servers)) { $eligible_not_busy_servers[] = $eligible_server; } } if (count($eligible_not_busy_servers) == 0) { foreach ($eligible_servers as $eligible_server) { $eligible_not_busy_servers[] = $eligible_server; } } //echo "ELIGIBLE JOB SERVERS (NOT BUSY):";print_r($eligible_not_busy_servers); $a_job_has_been_reassigned = false; if (count($eligible_not_busy_servers) > 0) { $eligible_not_busy_server = $eligible_not_busy_servers[rand(0, count($eligible_not_busy_servers) - 1)]; $new_assigned_server = $eligible_not_busy_server; $assigned_servers[] = $new_assigned_server; $old_full_job_id = $this->id; $old_full_split = explode("@", $old_full_job_id); $old_server_name = $old_full_split[0]; $old_job_id = $old_full_split[1]; $new_full_job_id = $new_assigned_server . "@" . $old_job_id; if ($new_assigned_server != $old_server_name) { if ($mode_server) { logger("REASSIGNING JOB " . $old_job_id . " TO:\n\t" . $new_assigned_server . "\n"); } else { echo "<div align='center' style='background-color:green;color:white;'>"; echo "REASSIGNING JOB " . $old_job_id . " TO:\n\t" . $new_assigned_server . "\n"; echo "</div>"; } // UPDATE JOB ASSIGNMENT $job_obj = new job_id_user(); $job_obj->get_from_hashrange($this->id_user, $old_full_job_id); if ($job_obj->id_status == "undefined") { if ($mode_server) { logger("\tJOB HAS ALREADY BEEN RE-ASSIGNED\n"); return; } else { echo "<div align='center' style='background-color:green;color:white;'>"; echo "\tJOB HAS ALREADY BEEN RE-ASSIGNED\n"; echo "</div>"; } break; } $job_obj->delete_job_new(); $job_obj->update(array("id" => $new_full_job_id, "dt_modified" => get_time())); $job_obj->delete_job_flags(); //$job_obj->set($new_job); // UPDATE ANY PH_CHILD AND PH_PARENT ENTRIES // IF THIS JOB HAS CHANGED NAME (ASSIGNED TO A DIFFERENT SERVER), IT COULD // ONLY BE A CHILD NODE BEING RENAMED // UPDATE THE PH_CHILD ENTRY AND THEN THE PH_PARENT ENTRY THAT GOES ALONG WITH IT $find_ph_child = new ph_child(); $find_ph_child->get_from_hashrange($old_full_job_id); if ($find_ph_child->id_child_job != "undefined") { //echo "REASSIGNING CHILD"; // FIND ITS ASSOCIATED PARENT AND UPDATE $find_ph_parent = new ph_parent(); $find_ph_parent->get_from_hashrange($find_ph_child->id_parent_job, $old_full_job_id); if ($find_ph_parent->id_parent_job != "undefined") { //echo "REASSIGNING parent"; // FIND ITS ASSOCIATED PARENT AND UPDATE $find_ph_parent->update(array("id_child_job" => $new_full_job_id)); } $find_ph_child->update(array("id_child_job" => $new_full_job_id)); } // CREATE JOB_NEW TABLE ENTRY FOR JOBS TO BE FOUND if ($job_obj->id_status == "new") { $job_obj->status_new(); } $member_list = $this->member_list($this); foreach ($member_list as $member) { $this->{$member} = $job_obj->{$member}; } $a_job_has_been_reassigned = true; //break; } // END IF (OLD SERVER NAME != NEW SERVER NAME) } // END IF (COUNT OF ELIGIBLE NOT BUSY SERVERS > 0) if ($a_job_has_been_reassigned) { // A JOB HAS ALREADY BEEN SUCCESSFULLY RE-ASSIGNED, NOW EXIT LOOP TO GET TO THE CONTINUE STATEMENT BELOW } // END IF return $a_job_has_been_reassigned; }
} if (isset($_GET['action'])) { if ($_GET['action'] == 'server-offline') { if (isset($_POST['name'])) { $this_user_server = new user_server(); $this_user_server->get_from_hashrange($u->id_user, $_POST['name']); if ($this_user_server->id_user != "undefined") { $this_user_server->update(array('int_online' => '0')); } } } } if (isset($_GET['action'])) { if ($_GET['action'] == 'server-online') { if (isset($_POST['name'])) { $this_user_server = new user_server(); $this_user_server->get_from_hashrange($u->id_user, $_POST['name']); if ($this_user_server->id_user != "undefined") { $this_user_server->update(array('int_online' => '1')); } } } } if (isset($_GET['action'])) { if ($_GET['action'] == "update-uploaded-file") { if (isset($_POST['str_targetfile']) && isset($_POST['id_hf']) && isset($_POST['id'])) { if (strlen($_POST['id_hf']) > 0 && strlen($_POST['id']) > 0) { $this_hf_file = new hf_file(); $this_hf_file->get_from_hashrange($_POST['id_hf'], $_POST['id']); if (isset($_POST['btnDelete'])) { $this_hf_file->delete();
<?php include "model.classes.php"; include_once "controller.guard.php"; if (isset($_GET['dl'])) { if ($_GET['dl'] == "rdp") { if (isset($_GET['server'])) { $a_server = new user_server(); $a_server->get_from_hashrange($u->id_user, $_GET['server']); if ($a_server->id_user != "undefined") { $ip_address = $a_server->ip_address; $rdp_content = "auto connect:i:1\r\nfull address:s:{$ip_address}\r\nusername:s:Administrator"; file_download($a_server->name . ".rdp", $rdp_content); exit; } } } } $qn = ""; if (isset($_GET['q'])) { $qn = $_GET['q']; } if (strlen($qn) > 0) { if (isset($_GET['file'])) { if ($_GET['file'] == "hisfunctionxmlexport") { $u->build(); $q = new hf_id_user(); $q->get_from_hashrange($u->id_user, $qn); $q->build(); $hf_name = $q->name; $chars = ' !@#$%^&*()_+-=[]{}\\|;\':"<>?,./;';
break; } $JOB->get_from_hashrange($new_job_news->id_user, $new_job_news->id); // change to drive off of ip address $idx = $idx + 1; } // END WHILE // SKIP THE REST IF UNABLE TO FIND A JOB BY THAT NAME if ($failed_to_find_job) { continue; } $assigner_setting = new sys_setting(); $assigner_setting->get_from_hashrange("jobcluster-" . substr($id_user, 0, 10), "reassigner"); if ($assigner_setting->val == $INSTANCE_NAME) { $user_server_reassigns = array(); $user_server_reassign = new user_server(); // LIST OF ALL JOB SERVERS $user_server_reassigns = $user_server_reassign->get_from_hashrange($id_user); // HOW MANY NON-BUSY JOB SERVERS $not_busy_servers = array(); foreach ($user_server_reassigns as $user_server_reassign) { if (isset($user_server_reassign['is_busy'])) { if ($user_server_reassign['is_busy'] . "" != "1") { $not_busy_servers[] = $user_server_reassign; } } } // HOW MANY OTHER NON-BUSY JOB SERVERS (INC. THIS ONE) WERE LAST SEEN IN THE PAST 30 SECONDS $server_second_timerange = 30; $current_not_busy_servers = array(); foreach ($not_busy_servers as $not_busy_server) {