function backup_save_schedule($parms) { global $db, $asterisk_conf, $amp_conf; //build query based on the following keys $parms_num = array('admin', 'cdr', 'command', 'configurations', 'days', 'emailaddr', 'emailmaxsize', 'emailmaxtype', 'exclude', 'fop', 'ftpdir', 'ftphost', 'ftppass', 'ftpuser', 'hours', 'id', 'include', 'method', 'minutes', 'months', 'name', 'recordings', 'sshdir', 'sshhost', 'sshkey', 'sshuser', 'remotesshhost', 'remotesshuser', 'remotesshkey', 'remoterestore', 'sudo', 'voicemail', 'weekdays', 'overwritebackup'); foreach ($parms_num as $dprm) { $db_parms[$dprm] = isset($parms[$dprm]) ? $parms[$dprm] : ''; } $keys = $vals = ''; //dont include empty values in the query foreach (array_keys($db_parms) as $key) { if ($db_parms[$key] != '') { $keys .= $key . ','; } } foreach (array_values($db_parms) as $val) { if ($val != '') { $vals .= '"' . $db->escapeSimple($val) . '",'; } } $keys = substr($keys, 0, -1); $vals = substr($vals, 0, -1); $sql = 'INSERT INTO backup (' . $keys . ') VALUES (' . $vals . ')'; $result = $db->query($sql); if (DB::IsError($result)) { die_freepbx($result->getMessage() . '<hr>' . $sql); } if ($parms['method'] == 'now' && $result) { $latest = $db->getOne('select last_insert_id()'); $backup_script = $asterisk_conf['astvarlibdir'] . '/bin/ampbackup.php ' . $latest; exec($backup_script, $res); } backup_retrieve_backup_cron(); }
<?php //This file is part of FreePBX. // // FreePBX is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 2 of the License, or // (at your option) any later version. // // FreePBX is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with FreePBX. If not, see <http://www.gnu.org/licenses/>. // // Copyright (C) 2005 VerCom Systems, Inc. & Ron Hartmann (rhartmann@vercomsystems.com) // Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) // global $db; global $asterisk_conf; $sql = "DELETE FROM backup"; $result = $db->query($sql); if (DB::IsError($result)) { die_freepbx($result->getMessage()); } //$Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron.php"; //exec($Cron_Script); backup_retrieve_backup_cron(); sql('DROP TABLE backup');