ossim_clean_error(); echo json_encode($response); die; } //Default values for the response. $response['error'] = TRUE; $response['msg'] = _('Error when processing the request'); //checking if it is an ajax request if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { //Checking token if (!Token::verify('tk_welcome_wizard', GET('token'))) { $response['error'] = TRUE; $response['msg'] = _('Invalid Action'); } else { //Getting the object with the filters. Unserialize needed. $wizard = Welcome_wizard::get_instance(); //List of all the possibles functions $function_list = array('start_wizard' => array('name' => 'initialize_wizard', 'params' => array()), 'change_step' => array('name' => 'change_step', 'params' => array('wizard', 'data')), 'exit_wizard' => array('name' => 'exit_wizard', 'params' => array('data'))); $_function = $function_list[$action]; //Checking we have a function associated to the action given if (is_array($_function) && function_exists($_function['name'])) { //Now we translate the params list to a real array with the real parameters $params = array(); foreach ($_function['params'] as $p) { $params[] = ${$p}; } try { //Calling to the function $response = call_user_func_array($_function['name'], $params); if ($response === FALSE) { throw new Exception(_('Sorry, operation was not completed due to an error when processing the request. Try again later'));
function net_devices_activity($conn) { $response = array(); $wizard = Welcome_wizard::get_instance(); if ($wizard === FALSE) { throw new Exception(_("There was an error, the Welcome_wizard object doesn't exist. Try again later")); } $plugins = array(); $flag_end = FALSE; $task_id = $wizard->get_step_data('task_id'); if ($task_id == 'ffffffff-ffff-ffff-ffff-ffffffffffff') { $status = 1; } else { $status = Welcome_wizard::current_jobs($task_id); $status = in_array($status['job_status'], array('task-failed', 'task-succeeded', 'task-revoked')) ? 1 : 0; } if ($status == 1) { $devices = Plugin::get_plugins_by_assets(); foreach ($devices as $h_id => $p_data) { $h_id = Util::uuid_format_nc($h_id); $p_data = is_array($p_data) ? $p_data : array(); foreach ($p_data as $pkey => $pdata) { $active = Asset_host_devices::check_device_connectivity($conn, $h_id, $pdata['plugin_id'], '', TRUE); $plugins[$h_id][$pkey] = $active; if ($flag_end) { $flag_end = TRUE; } } } } $wizard->set_step_data('net_devices_data', $flag_end); $wizard->save_status(); $response['error'] = FALSE; $response['data']['plugins'] = $plugins; $response['data']['status'] = $status; return $response; }