function sns_backup_initial_check()
{
    Sns_Checker::initialCheck();
}
 public function __construct()
 {
     Sns_Checker::checkFTP();
 }
function sns_backup_manual_backup()
{
    @set_time_limit(0);
    register_shutdown_function('sns_register_shutdown');
    try {
        Sns_Log::log_msg('########PROCESS STARTED########' . PHP_EOL);
        $state = Sns_State::get_status();
        if ($state['status'] == Sns_State::STATUS_ACTIVE) {
            throw new Sns_Exception_Unavailable_Operation('There is an existing active process.Please wait.');
        }
        $stateData = array('status' => Sns_State::STATUS_ACTIVE, 'type' => Sns_State::TYPE_BACKUP, 'start_date' => date('Y-m-d H:i:s'));
        Sns_State::update($stateData);
        Sns_Checker::check();
        $locations = isset($_POST['locations']) ? $_POST['locations'] : array();
        $destination = new Sns_Destination(Sns_Backup::BACKUP_MODE_MANUAL);
        $destination->set_destinations($locations);
        $destination->save();
        $backup = new Sns_Backup(Sns_Backup::BACKUP_MODE_MANUAL);
        Sns_State::$currentBackupFilename = $backup->getFilename();
        $dest = 'local';
        if (count($locations)) {
            $dest .= ',' . implode(',', array_keys($locations));
        }
        $options = Sns_Option::get_options(true);
        foreach ($options as $option => $data) {
            if ($option == Sns_Option::FULL) {
                $option_list = array($option);
                break;
            }
            if ($option != Sns_Option::COUNT) {
                $option_list[] = $option;
            }
        }
        $options = implode(',', array_values($option_list));
        $engLogDecription = '----------------------------------------------------';
        $engLogDecription .= "\n" . ucfirst($stateData['type']) . ": " . $options;
        $engLogDecription .= "\nDestination: " . $dest . "\n";
        $engLogDecription .= "----------------------------------------------------\n";
        Sns_Log::log_msg($engLogDecription);
        Sns_Log::log_action('Backing up');
        $warns = $backup->backup();
        Sns_Log::log_action('Backing up', SNS_LOG_END);
        Sns_Log::log_msg("\n");
        $skipped_files = '';
        if (!empty($warns['not_readable'])) {
            $skipped_files .= '*********WARNING**********' . PHP_EOL;
            $skipped_files .= 'The following files are not readable and were excluded from backup package' . PHP_EOL;
            $i = 1;
            foreach ($warns['not_readable'] as $file) {
                $skipped_files .= $i . '. ' . $file . PHP_EOL;
                $i++;
            }
            Sns_Log::log_msg($skipped_files);
        }
        $stateData = array('status' => Sns_State::STATUS_FINISHED, 'type' => Sns_State::TYPE_BACKUP);
        Sns_State::update($stateData);
        Sns_Log::log_msg('########PROCESS ENDED########' . PHP_EOL);
    } catch (Exception $e) {
        Sns_Log::log_exception_obj($e);
        $ex_data = Sns_Exception_Handler::get_exception_data($e);
        $stateData = array('status' => Sns_State::STATUS_FAILED, 'type' => Sns_State::TYPE_BACKUP, 'msg' => $ex_data['status'] . ' : ' . $ex_data['msg']);
        Sns_State::update($stateData);
        Sns_Log::log_msg('########PROCESS ENDED########' . PHP_EOL);
        Sns_Log::report('backup');
    }
    die;
}