if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } $get_vars = array('action' => '', 'desc' => '', 'display' => '', 'exclude' => '', 'id' => '', 'name' => '', 'path' => '', 'submit' => '', 'type' => ''); foreach ($get_vars as $k => $v) { $var[$k] = isset($_REQUEST[$k]) ? $_REQUEST[$k] : $v; } //set action to delete if delete was pressed instead of submit if ($var['submit'] == _('Delete') && $var['action'] == 'save') { $var['action'] = 'delete'; } //action actions switch ($var['action']) { case 'save': $var['id'] = backup_put_template($var); break; case 'delete': $var['id'] = backup_del_template($var['id']); break; } //view actions switch ($var['action']) { case 'edit': case 'save': $var = array_merge($var, backup_get_template($var['id'])); //template id's are all prefixed by their module name for hooking reasons. Clear that past this point if (strpos($var['id'], 'backup-') === 0) { $var['id'] = substr($var['id'], 7); } $content = load_view(dirname(__FILE__) . '/views/templates/template.php', $var);
$serverids[$id] = backup_put_server($t); } sql('UPDATE backup_servers SET readonly = "a:1:{i:0;s:1:\\"*\\";}"'); sql('UPDATE backup_servers SET immortal = "true"'); $createdby = serialize(array('created_by' => 'install.php')); sql('UPDATE backup_servers SET data = "' . addslashes($createdby) . '"'); out(_('added default backup servers')); // Load default templates if needed if ($db->getOne('SELECT COUNT(*) FROM backup_templates') < 1) { //create default templates $template = array('basic' => array('id' => '', 'name' => 'Config Backup', 'desc' => _('Configurations only'), 'immortal' => 'true', 'type' => array('mysql', 'astdb'), 'path' => array('server-' . $serverids['mysql'], ''), 'exclude' => array('', '')), 'full' => array('id' => '', 'name' => 'Full Backup', 'desc' => _('A full backup of core settings and web files, doesn\'t include system sounds or recordings.'), 'type' => array('mysql', 'mysql', 'astdb', 'dir', 'dir', 'dir', 'dir', 'dir'), 'path' => array('server-' . $server['cdr'], 'server-' . $server['mysql'], 'astdb', '__ASTETCDIR__', '__AMPWEBROOT__', '__AMPBIN__', '/etc/dahdi', '/tftpboot'), 'exclude' => array('', '', '', '', '', '', '', '')), 'cdr' => array('id' => '', 'name' => 'CDRs', 'desc' => _('Call Detail Records'), 'immortal' => 'true', 'type' => array('mysql'), 'path' => array('server-' . $server['cdr']), 'exclude' => array('')), 'voicemail' => array('id' => '', 'name' => 'Voice Mail', 'desc' => _('Voice Mail Storage'), 'immortal' => 'true', 'type' => array('dir'), 'path' => array('__ASTSPOOLDIR__/voicemail'), 'exclude' => array('')), 'recordings' => array('id' => '', 'name' => 'System Audio', 'desc' => _('All system audio - including IVR prompts and Music On Hold. DOES NOT BACKUP VOICEMAIL'), 'immortal' => 'true', 'type' => array('dir', 'dir', 'dir'), 'path' => array('__ASTVARLIBDIR__/moh', '__ASTVARLIBDIR__/sounds/custom', '__ASTVARLIBDIR__/sounds/*/custom'), 'exclude' => array('', '', '')), 'safe_backup' => array('id' => '', 'name' => 'Exclude Backup Settings', 'desc' => _('Exclude Backup\'s settings so that they dont get restored, useful for a remote restore'), 'immortal' => 'true', 'type' => array('mysql'), 'path' => array('server-' . $server['mysql']), 'exclude' => array("backup\nbackup_cache\nbackup_details\nbackup_items\n" . "backup_server_details\nbackup_servers\nbackup_template_details\n" . "backup_templates\n"))); if (!function_exists("backup_put_template")) { include_once __DIR__ . "/functions.inc/templates.php"; } foreach ($template as $that => $t) { backup_put_template($t); } //lock this all down so that they're readonly sql('UPDATE backup_templates SET immortal = "true"'); $createdby = serialize(array('created_by' => 'install.php')); 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