$msg]
);
}
/**
* Checks if target method is available to be called using AJAX.
*
* @param string $method Target method.
*
* @return boolean True allowed, false not.
*/
public function ajaxMethod($method)
{
global $config;
// Check access.
check_login();
return in_array($method, $this->AJAXMethods);
}
/**
* Constructor.
*
* @param boolean $must_run Must run or not.
* @param string $ajax_controller Controller.
*
* @return object
* @throws Exception On error.
*/
public function __construct(
bool $must_run=false,
$ajax_controller='include/ajax/welcome_window'
) {
$this->ajaxController = $ajax_controller;
if ($this->initialize($must_run) !== true) {
throw new Exception('Must not be shown');
}
return $this;
}
/**
* Main method.
*
* @return void
*/
public function run()
{
ui_require_css_file('new_installation_welcome_window');
echo '
'',
'content' => ' To detect and find systems on your network we will need access credentials. The SNMP community for network devices, and at least one set of credentials for Linux and Windows environments (they do not need to be super administrators, but they do need to be able to connect remotely). Without the credentials, we will only be able to detect if the devices are connected to the network.
completeStep();
$this->setStep(W_CONFIGURE_MAIL);
}
// Check current page.
$sec2 = get_parameter('sec2', '');
// Search also does not fulfill sec2.
if (empty($sec2) === true) {
$sec2 = get_parameter('keywords', '');
}
if ($must_run === false
|| ((int) $config['welcome_state']) === WELCOME_FINISHED
) {
// Do not show if finished.
return false;
}
$this->step = $this->getStep();
$this->agent = $this->getWelcomeAgent();
/*
* Configure mail. Control current flow.
*
* On empty sec2: show current step.
* On setup page: do not show.
* After mail configuration: enable agent step.
*/
if ($this->step === W_CONFIGURE_MAIL) {
if ($sec2 === 'godmode/setup/setup'
&& get_parameter('section', '') == 'general'
&& get_parameter('update_config', false) !== false
) {
// Mail configuration have been processed.
$this->step = W_CONFIGURE_MAIL;
$this->completeStep();
$this->setStep(W_CREATE_AGENT);
} else if ($sec2 === 'godmode/setup/setup'
&& get_parameter('section', '') === 'general'
) {
// Mail configuration is being processed.
return false;
} else if (empty($sec2) === true) {
// Show main page.
return true;
}
}
/*
* Create agent. Control current flow.
*
* Welcome wizard is shown if you create your first agent.
*
*/
if (empty($config['welcome_id_agent']) === true) {
// Create agent is pending.
if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('create_agent', false) !== false
) {
// Agent have been created. Store.
// Here complete step is not needed because is already done
// by setWelcomeAgent.
$this->setWelcomeAgent(
// Non yet processed. Get next available ID.
db_get_value_sql(
sprintf(
'SELECT AUTO_INCREMENT
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = "%s"
AND TABLE_NAME = "%s"',
$config['dbname'],
'tagente'
)
)
);
$this->setStep(W_CREATE_MODULE);
return true;
} else if ($sec2 === 'godmode/agentes/configurar_agente') {
// Agent is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
} else if ($this->step === W_CREATE_AGENT) {
$this->step = W_CREATE_MODULE;
}
/*
* Create module. Control current flow.
*
* On empty sec2: show current step.
* On module creation page: do not show.
* After module creation: enable alert step.
*/
if ($this->step === W_CREATE_MODULE) {
// Create module is pending.
if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'module'
&& get_parameter('create_module', false) !== false
) {
// Module have been created.
$this->completeStep();
$this->setStep(W_CREATE_ALERT);
return true;
} else if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'module'
) {
// Module is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
/*
* Create alert. Control current flow.
*
* On empty sec2: show current step.
* On alert creation page: do not show.
* After alert creation: enable discovery task step.
*/
if ($this->step === W_CREATE_ALERT) {
// Create alert is pending.
if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'alert'
&& get_parameter('create_alert', false) !== false
) {
// Alert have been created.
$this->completeStep();
$this->setStep(W_CREATE_TASK);
return true;
} else if ($sec2 === 'godmode/agentes/configurar_agente'
&& get_parameter('tab', '') === 'alert'
) {
// Alert is being created.
return false;
} else if (empty($sec2) === true) {
// If at main page, show welcome.
return true;
}
}
/*
* Create discovery task. Control current flow.
*
* On empty sec2: show current step.
* On discovery task creation page: do not show.
* After discovery task creation: finish.
*/
// Create Discovery task is pending.
// Host&Devices finishses on page 2.
if ($sec2 === 'godmode/servers/discovery'
&& (int) get_parameter('page') === 2
) {
// Discovery task have been created.
$this->step = W_CREATE_TASK;
$this->completeStep();
// Check if all other tasks had been completed.
if ($this->checkAllTasks() === true) {
// Finished! do not show.
$this->setStep(WELCOME_FINISHED);
return false;
}
return true;
} else if ($sec2 == 'godmode/servers/discovery') {
// Discovery task is being created.
return false;
}
// Check if all other tasks had been completed.
if ($this->checkAllTasks() === true) {
// Finished! do not show.
$this->setStep(WELCOME_FINISHED);
return false;
} else if (empty($sec2) === true) {
// Pending tasks.
return true;
}
if ($this->step === WELCOME_FINISHED) {
// Welcome tutorial finished.
return false;
}
// Return a reference to the new object.
return false;
}
/**
* Load JS content.
* function that enables the functions to the buttons when its action is
* completed.
* Assign the url of each button.
*
* @return string HTML code for javascript functionality.
*/
public function loadJS($flag_task=false)
{
ob_start();
?>