Beispiel #1
2
require_once 'av_init.php';
if (!Session::am_i_admin()) {
    $error = _("You do not have permission to see this section");
    Util::response_bad_request($error);
}
// Close session write for real background loading
session_write_close();
/**
Job ID is optional, when empty we must lookup for any backup job (Pending in the API)
*/
$job_id = POST('job_id');
$system_id = POST('system_id');
ossim_valid($job_id, OSS_UUID, OSS_NULLABLE, 'illegal: Job ID');
ossim_valid($system_id, OSS_UUID, 'illegal: System ID');
if (ossim_error()) {
    Util::response_bad_request(ossim_get_error_clean());
}
$backup_list = array();
$data = array();
try {
    $backup_object = new Av_backup($system_id, 'configuration');
    $backup_status = $backup_object->get_backup_status($job_id);
} catch (Exception $e) {
    $exp_msg = $e->getMessage();
    Util::response_bad_request($exp_msg);
}
$response['status'] = 'success';
$response['data'] = $backup_status;
echo json_encode($response);
/* End of file get_backup_status.php */
/* Location: /av_backup/providers/get_backup_status.php */
Beispiel #2
2
$system_id = POST('system_id');
ossim_valid($maxrows, OSS_DIGIT, 'illegal: iDisplayLength');
ossim_valid($from, OSS_DIGIT, 'illegal: iDisplayStart');
ossim_valid($order, OSS_ALPHA, 'illegal: iSortCol_0');
ossim_valid($torder, OSS_LETTER, 'illegal: sSortDir_0');
ossim_valid($search_str, OSS_INPUT, OSS_NULLABLE, 'illegal: sSearch');
ossim_valid($sec, OSS_DIGIT, 'illegal: sEcho');
ossim_valid($system_id, OSS_UUID, 'illegal: System ID');
if (ossim_error()) {
    Util::response_bad_request(ossim_get_error_clean());
}
$tz = Util::get_timezone();
$backup_list = array();
$data = array();
try {
    $backup_object = new Av_backup($system_id, 'configuration');
    $_backup_list_arr = $backup_object->get_backup_list();
} catch (Exception $e) {
    $exp_msg = $e->getMessage();
    Util::response_bad_request($exp_msg);
}
// Get and store the last backup date
$_last_date = strtotime("19700101000000");
foreach ($_backup_list_arr as $_backup_data) {
    if ($_backup_data['date'] > $_last_date) {
        $_last_date = $_backup_data['date'];
    }
}
$_last_date = gmdate('U', $_last_date + 3600 * $tz);
$backup_object->set_session_last_date($_last_date);
// Get total before filtering
Beispiel #3
1
        }
        break;
    case 'download_backup':
        //Validate Form token
        $token = POST('token');
        if (Token::verify('tk_backup_action', $token) == FALSE) {
            $error = Token::create_error_message();
            Util::response_bad_request($error);
        }
        $validate = array('system_id' => array('validation' => 'OSS_UUID', 'e_message' => 'illegal:' . _('System ID')), 'backup_file' => array('validation' => 'OSS_ALPHA, OSS_SCORE, OSS_DOT', 'e_message' => 'illegal:' . _('Backup File')));
        $system_id = POST('system_id');
        $backup_file = POST('backup_file');
        $validation_errors = validate_form_fields('POST', $validate);
        if (!empty($validation_errors)) {
            Util::response_bad_request(_('Validation error - unable to download backup file. Please try again.'));
        } else {
            try {
                $backup_object = new Av_backup($system_id, 'configuration');
                $download_response = $backup_object->download_backup($backup_file);
                $data['status'] = 'success';
                $data['data']['msg'] = _('Backup file is ready for download.');
                $data['data']['job_id'] = $download_response['job_id'];
            } catch (Exception $e) {
                Util::response_bad_request(_('An API error occurred - backup could not be downloaded. Please try again.'));
            }
        }
        break;
}
echo json_encode($data);
/* End of file backup_actions.php */
/* Location: /av_backup/controllers/backup_actions.php */
 * @package    ossim-framework\Assets
 * @autor      AlienVault INC
 * @license    http://www.gnu.org/licenses/gpl-2.0.txt
 * @copyright  2003-2006 ossim.net
 * @copyright  2007-2013 AlienVault
 * @link       https://www.alienvault.com/
 */
require_once 'av_init.php';
if (!Session::am_i_admin()) {
    $error = _("You do not have permission to see this section");
    Util::response_bad_request($error);
}
// Close session write for real background loading
session_write_close();
$system_id = POST('system_id');
ossim_valid($system_id, OSS_UUID, 'illegal: System ID');
if (ossim_error()) {
    Util::response_bad_request(ossim_get_error_clean());
}
try {
    $backup_object = new Av_backup($system_id, 'configuration');
    $last_date = $backup_object->get_session_last_date();
} catch (Exception $e) {
    $exp_msg = $e->getMessage();
    Util::response_bad_request($exp_msg);
}
$response['status'] = 'success';
$response['data'] = $last_date;
echo json_encode($response);
/* End of file get_backup_last_date.php */
/* Location: /av_backup/providers/get_backup_last_date.php */
Beispiel #5
0
    $nt = new Notification('nt_1', $config_nt);
    $nt->show();
    die;
}
$validate = array('system_id' => array('validation' => 'OSS_UUID', 'e_message' => 'illegal:' . _('System ID')), 'backup_file' => array('validation' => 'OSS_ALPHA, OSS_SCORE, OSS_DOT', 'e_message' => 'illegal:' . _('Backup File')), 'job_id' => array('validation' => 'OSS_UUID', 'e_message' => 'illegal:' . _('Job ID')));
$system_id = POST('system_id');
$backup_file = POST('backup_file');
$job_id = POST('job_id');
$validation_errors = validate_form_fields('POST', $validate);
if (!empty($validation_errors)) {
    $config_nt['content'] = _('Validation error - unable to download backup file. Please try again.') . $back_link;
    $nt = new Notification('nt_1', $config_nt);
    $nt->show();
    die;
}
$backup_object = new Av_backup($system_id, 'configuration');
$f_length = $backup_object->get_session_file_size($backup_file);
$file = $backup_object->download_path . '/' . $backup_file;
if (!file_exists($file)) {
    $config_nt['content'] = _('File not found. Please try again.') . $back_link;
    $nt = new Notification('nt_1', $config_nt);
    $nt->show();
    die;
}
// Don't send the headers still we know the file is right
$headers_sent = FALSE;
$pointer = 0;
while ($pointer < $f_length) {
    $rs = fopen($file, "r");
    fseek($rs, $pointer);
    $val = fgets($rs, 1048576);