sql('UPDATE backup_templates SET data = "' . addslashes($createdby) . '"'); out(_('added default backup templates')); } } else { // Load serverids. This is fixed. If you ever need to change these, // be smarter. $serverids = array('local' => 1, 'mysql' => 2, 'cdr'); } // Do we need a default backup job? if ($db->getOne('SELECT COUNT(*) FROM backup') < 1) { // Yes. Add a default backup $new = array('id' => '', 'name' => 'Default backup', 'desc' => _('Default backup; automatically installed'), 'cron_schedule' => 'monthly', 'type' => array('mysql', 'astdb'), 'path' => array('server-' . $server['mysql'], 'astdb'), 'exclude' => array('', ''), 'storage_servers' => array($serverids['local']), 'bu_server' => 0, 'delete_amount' => 12); if (!function_exists("backup_put_backup")) { include_once __DIR__ . "/functions.inc/backup.php"; } backup_put_backup($new); $createdby = serialize(array('created_by' => 'install.php')); sql('UPDATE backup SET data = "' . addslashes($createdby) . '"'); } $freepbx_conf = freepbx_conf::create(); // AMPBACKUPEMAILFROM // $set['value'] = ''; $set['defaultval'] =& $set['value']; $set['readonly'] = 0; $set['hidden'] = 0; $set['level'] = 0; $set['module'] = 'backup'; $set['category'] = 'Backup Module'; $set['emptyok'] = 1; $set['name'] = 'Email "From:" Address';
public function doConfigPageInit($page) { $_REQUEST['submit'] = isset($_REQUEST['submit']) ? $_REQUEST['submit'] : ''; $_REQUEST['action'] = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $_REQUEST['id'] = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; switch ($page) { case 'backup': if ($_REQUEST['submit'] == _('Delete') && $_REQUEST['action'] == 'save') { $_REQUEST['action'] = 'delete'; } switch ($_REQUEST['action']) { case 'wizard': $current_servers = backup_get_server('all_detailed'); $server = array(); $backup = array(); $create_server = false; $backup['bu_server'] = '0'; extract($_REQUEST, EXTR_SKIP); foreach ($current_servers as $key => $value) { if ($value['name'] == 'Local Storage' && $value['type'] == 'local' && $value['immortal'] == 'true') { $backup['storage_servers'][] = $value['id']; } if ($value['name'] == 'Config server' && $value['type'] == 'mysql' && $value['immortal'] == 'true') { $mysqlserver = $value['id']; } if ($value['name'] == 'CDR server' && $value['type'] == 'local' && $value['immortal'] == 'true') { $cdrserver = $value['id']; } if ($value['type'] == $wizremtype) { //If a server has the same host AND user we assume it already exists $create_server = !($wizserveraddr == $value['host'] && $wizserveruser == $value['user']); } } if ($create_server && $wizremote == 'yes') { $server['name'] = $wizname; $server['desc'] = $wizdesc ? $wizdesc : _('Wizard') . ": " . $wizname; $server['type'] = $wizremtype; $server['host'] = $wizserveraddr; $server['user'] = $wizserveruser; $server['path'] = $wizremotepath ? $wizremotepath : ''; switch ($wizremtype) { case 'ftp': $server['port'] = $wizserverport ? $wizserverport : '21'; $server['password'] = $wizftppass ? $wizftppass : ''; $server['transfer'] = $wiztrans; break; case 'ssh': $server['port'] = $wizserverport ? $wizserverport : '22'; $server['key'] = $wizsshkeypath; break; } $backup['storage_servers'][] = backup_put_server($server); } //Create Backup Job $backup['name'] = $wizname; $backup['desc'] = $wizdesc; if ($wiznotif == 'yes' && !empty($wizemail)) { $backup['email'] = $wizemail; } else { $backup['email'] = ''; } //cron $backup['cron_minute'] = array('*'); $backup['cron_dom'] = array('*'); $backup['cron_dow'] = array('*'); $backup['cron_hour'] = array('*'); $backup['cron_month'] = array('*'); $backup['cron_schedule'] = $wizfreq; switch ($wizfreq) { case 'daily': $backup['cron_hour'] = array($wizat); break; case 'weekly': $backup['cron_dow'] = array($wizat[0]); $backup['cron_hour'] = array($wizat[1]); break; case 'monthly': $backup['cron_dom'] = array($wizat[0]); $backup['cron_hour'] = array('23'); $backup['cron_minute'] = array('59'); break; } $backup['delete_amount'] = '3'; //3 runs $backup['delete_time'] = '30'; //clear backups older than 30... $backup['delete_time_type'] = 'days'; //...days //Backup Configs $backup['type'][] = 'astdb'; $backup['path'][] = ''; $backup['exclude'][] = ''; $backup['type'][] = 'dir'; $backup['path'][] = '__AMPWEBROOT__/admin'; $backup['exclude'][] = ''; $backup['type'][] = 'dir'; $backup['path'][] = '__ASTETCDIR__'; $backup['exclude'][] = ''; $backup['type'][] = 'dir'; $backup['path'][] = '__AMPBIN__'; $backup['exclude'][] = ''; $backup['type'][] = 'dir'; $backup['path'][] = '/etc/dahdi'; $backup['exclude'][] = ''; $backup['type'][] = 'file'; $backup['path'][] = '/etc/freepbx.conf'; $backup['exclude'][] = ''; //Backup CDR if ($wizcdr == 'yes' && isset($cdrserver)) { $backup['type'][] = 'mysql'; $backup['path'][] = 'server-' . $cdrserver; $backup['exclude'][] = ''; } //Backup Voicemail if ($wizvm == 'yes') { $backup['type'][] = 'dir'; $backup['path'][] = '__ASTSPOOLDIR__/voicemail'; $backup['exclude'][] = ''; } //Backup Voicemail if ($wizbu == 'yes') { $backup['type'][] = 'dir'; $backup['path'][] = '__ASTSPOOLDIR__/monitor'; $backup['exclude'][] = ''; } backup_put_backup($backup); break; case 'delete': backup_del_backup($_REQUEST['id']); //TODO: Not allowed in 5.5 unset($_REQUEST['action']); unset($_REQUEST['id']); break; } break; } }
$var['action'] = 'run'; } $var['brand'] = $amp_conf['DASHBOARD_FREEPBX_BRAND'] ? $amp_conf['DASHBOARD_FREEPBX_BRAND'] : _('FreePBX'); //action actions switch ($var['action']) { case 'ajax_save': //clear all buffers, we dont want to return any html while (ob_get_level()) { ob_end_clean(); } $var['id'] = backup_put_backup($var); exit; //no need to do anything else, get out //no need to do anything else, get out case 'save': $var['id'] = backup_put_backup($var); $_REQUEST['id'] = $var['id']; $_REQUEST['action'] = 'edit'; \FreePBX::View()->redirect_standard('id', 'action'); break; case 'run': //dont stop untill were all done //backup will compelte EVEN IS USER NAVIGATES AWAY FROM PAGE!! ignore_user_abort(true); //clear all buffers, those will interfere with the stream while (ob_get_level()) { ob_end_clean(); } ob_start(); header('Content-Type: text/event-stream'); header('Cache-Control: no-cache');