Changeset 8752

Show
Ignore:
Timestamp:
02/01/10 18:11:03 (2 years ago)
Author:
mbrevda
Message:

closes #1386;

  • removing schedule_functions - moving all functions to functions.inc.php
  • fixes ftp backup temp file
  • imrpove handeling of includes, widen textarea for include/exclude names
  • better handeling of excludes
  • add migration script
  • update uninstall script to reflect new db schema
  • version bump
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.7/backup/bin/ampbackup.php

    r8465 r8752  
    1111 OR 
    1212 The program is called from the backup.php script and implemented immediately as such: 
    13  ampbackup.pl <Backup_Name> <Backup_Voicemail_(yes/no)> <Backup_Recordings_(yes/no)> <Backup_Configuration_files(yes/no)>  
     13 ampbackup.php <Backup_Name> <Backup_Voicemail_(yes/no)> <Backup_Recordings_(yes/no)> <Backup_Configuration_files(yes/no)>  
    1414 <Backup_CDR_(yes/no)> <Backup_FOP_(yes/no) 
    1515 
    16  example ampbackup.pl "My_Nightly_Backup" yes yes no no yes 
     16 example ampbackup.php "My_Nightly_Backup" yes yes no no yes 
    1717 
    1818 
     
    3232$amp_conf=getconf((isset($_ENV['FREEPBXCONFIG']) && strlen($_ENV['FREEPBXCONFIG']))?$_ENV['FREEPBXCONFIG']:'/etc/amportal.conf'); 
    3333$ast_conf=getconf((isset($_ENV['ASTERISKCONFIG']) && strlen($_ENV['ASTERISKCONFIG']))?$_ENV['ASTERISKCONFIG']:'/etc/asterisk/asterisk.conf'); 
    34 //default some options if they are blank 
    35 if(!isset($amp_conf['AMPBACKADMIN'])){$amp_conf['AMPBACKADMIN']=true;} 
    36 if(!isset($amp_conf['AMPBACKUPEMAILFROM'])){$amp_conf['AMPBACKUPEMAILFROM']='backup@freepbx.org';} 
    37 if(!isset($amp_conf['AMPBACKUPEMAILMAX'])){$amp_conf['AMPBACKUPEMAILMAX']='10MB';} 
    38 //var_dump($amp_conf); 
    39 //$opts=getOpts(); 
    40 $opts['ftpfile']="/tmp/freepbx-backup.ftp"; 
    41 $opts['budir']=$amp_conf['ASTVARLIBDIR']."/backups"; 
    42 $opts['now']=date('Ymd.h.i.s'); 
    43 if($amp_conf['AMPBACKUPSUDO']==true){$sudo='/usr/bin/sudo';} 
     34 
    4435//connect to database 
    4536include_once('DB.php'); 
    4637if(!isset($db)){$db = DB::connect('mysql://'.$amp_conf['AMPDBUSER'].':'.$amp_conf['AMPDBPASS'].'@'.$amp_conf['AMPDBHOST'].'/'.$amp_conf['AMPDBNAME']);} // attempt connection 
    47  
    4838if($argc == 1){//no args recieved - show help text 
    4939  showopts(); 
    5040}elseif($argc == 2){//one arg recievied. Hmm, this sounds like a backup schedules id... Lets look in the DB for more details 
    51   $sql = "SELECT Name, Voicemail, Recordings, Configurations, CDR, FOP from Backup where ID= ?"; 
    52   $res=$db->getRow($sql,array($argv[1]), DB_FETCHMODE_ASSOC); 
    53   if(!$res){echo "No Backup Schedules defined in backup table or you may need to run this program with more arguments.\n";exit;} 
    54   $opts['name']=isset($res['Name'])?$res['Name']:false; 
    55   $opts['voicemail']=(isset($res['Voicemail'])&& $res['Voicemail']=='yes')?true:false; 
    56   $opts['recordings']=(isset($res['Recordings'])&& $res['Recordings']=='yes')?true:false; 
    57   $opts['configs']=(isset($res['Configurations'])&& $res['Configurations']=='yes')?true:false; 
    58   $opts['cdr']=(isset($res['CDR'])&& $res['CDR']=='yes')?true:false; 
    59   $opts['fop']=(isset($res['FOP'])&& $res['FOP']=='yes')?true:false; 
     41  $sql = "SELECT * FROM backup WHERE id= ?"; 
     42  $opts=$db->getRow($sql,array($argv[1]), DB_FETCHMODE_ASSOC); 
     43  if(!$opts){echo "No Backup Schedules defined in backup table or you may need to run this program with more arguments.\n";exit;} 
    6044}else{ 
    6145  $opts['name']=isset($argv[1])?$argv[1]:false; 
    6246  $opts['voicemail']=(isset($argv[2])&& $argv[2]=='yes')?true:false; 
    6347  $opts['recordings']=(isset($argv[3])&& $argv[3]=='yes')?true:false; 
    64   $opts['configs']=(isset($argv[4])&& $argv[4]=='yes')?true:false; 
     48  $opts['configurations']=(isset($argv[4])&& $argv[4]=='yes')?true:false; 
    6549  $opts['cdr']=(isset($argv[5])&& $argv[5]=='yes')?true:false; 
    6650  $opts['fop']=(isset($argv[6])&& $argv[6]=='yes')?true:false; 
    6751} 
    68 //var_dump($opts); 
    69  
     52$opts['ftpfile']='/tmp/freepbx-backup.ftp'; 
     53$opts['budir']=$amp_conf['ASTVARLIBDIR'].'/backups'; 
     54$opts['now']=date('Ymd.h.i.s'); 
     55 
     56if($opts['sudo']==true){$sudo='/usr/bin/sudo';}else{$sudo='';} 
    7057//if all options are set to no/false, return an error 
    71 if(!$opts['voicemail']&&!$opts['recordings']&&!$opts['configs']&&!$opts['cdr']&&!$opts['fop']){echo "Backup Error: You need to set at least one option to yes\n";showopts();} 
     58if(!$opts['voicemail']&&!$opts['recordings']&&!$opts['configurations']&&!$opts['cdr']&&!$opts['fop']&&!$opts['include']){echo "Backup Error: You need to set at least one option to yes\n";showopts();} 
    7259system('/bin/rm -rf /tmp/ampbackups.'.$opts['now'].' > /dev/null  2>&1');//remove stale backup 
    7360system('/bin/mkdir /tmp/ampbackups.'.$opts['now'].' > /dev/null  2>&1');//create directory for current backup 
     
    7663//backup recordings in requested 
    7764if($opts['recordings']){system('/bin/tar -Pcz -f /tmp/ampbackups.'.$opts['now'].'/recordings.tar.gz '.$amp_conf['ASTVARLIBDIR'].'/sounds/custom');} 
    78 //backup configs if requested 
    79 if($opts['configs']){ 
     65//backup configurations if requested 
     66if($opts['configurations']){ 
    8067  system($amp_conf['ASTVARLIBDIR'].'/bin/dumpastdb.php '.$opts['now'].' > /dev/null'); 
    8168 
    8269  $cmd='/bin/tar -Pcz -f /tmp/ampbackups.'.$opts['now'].'/configurations.tar.gz '.$amp_conf['ASTVARLIBDIR'].'/agi-bin/ '; 
    8370  $cmd.=$amp_conf['ASTVARLIBDIR'].'/bin/ '.$amp_conf['ASTETCDIR'].' /etc/amportal.conf '; 
    84   if($amp_conf['AMPBACKADMIN']!='false'){$cmd.=$amp_conf['AMPWEBROOT'].'/admin ';}//include admin/ unless otherwise requested 
     71  if($opts['admin']=='yes'){$cmd.=$amp_conf['AMPWEBROOT'].'/admin ';}//include admin/ unless otherwise requested 
    8572  if(isset($amp_conf['ZAP2DAHDICOMPAT']) && $amp_conf['ZAP2DAHDICOMPAT']==true){$cmd.='/etc/dahdi ';}else{$cmd.='/etc/zaptel.conf ';}//include zap OR dahdi 
    8673  $cmd.='/tmp/ampbackups.'.$opts['now'].'/astdb.dump'; 
    8774  system($cmd); 
    88   if ($amp_conf['AMPPROVROOT']){ 
    89   $xfile=''; 
    90     if(isset($amp_conf['AMPPROVEXCLUDE']) && $amp_conf['AMPPROVEXCLUDE']){$xfile='--exclude-from '.$amp_conf['AMPPROVEXCLUDE'];};//file containing exclude list 
    91     if(isset($amp_conf['AMPPROVEXCLUDELIST']) && $amp_conf['AMPPROVEXCLUDELIST']){ 
    92       $exclude=''; 
    93       $ex=explode(' ',$amp_conf['AMPPROVEXCLUDELIST']); 
     75  if($opts['include']){ 
     76    $exclude=''; 
     77    if(isset($opts['exclude']) && $opts['exclude']!=''){ 
     78      $exclude=str_replace(array("\n","\r","\r\n"),' ',$opts['exclude']); 
     79      $ex=explode(' ',$exclude); 
    9480      foreach($ex as $x){ //exclude each option in the space delimited list 
    9581        $exclude.='--exclude='.$x.' '; 
    9682      }  
    9783    } 
    98     system($sudo.' /bin/tar -Pcz -f /tmp/ampbackups.'.$opts['now'].'/phoneconfig.tar.gz '.$amp_conf['AMPPROVROOT'].' '.$xfile.' '.$exclude); 
     84    $inculde=str_replace(array("\n","\r","\r\n"),' ',$opts['include']); 
     85    $exec=$sudo.' /bin/tar -Pcz -f /tmp/ampbackups.'.$opts['now'].'/phoneconfig.tar.gz '.$inculde.' '.$exclude; 
     86    system($exec); 
    9987  } 
    10088  system('mysqldump --add-drop-table -h'.$amp_conf['AMPDBHOST'].' -u'.$amp_conf['AMPDBUSER'].' -p'.$amp_conf['AMPDBPASS'].' --database '.$amp_conf['AMPDBNAME'].' > /tmp/ampbackups.'.$opts['now'].'/asterisk.sql'); 
     
    118106 Note - the hardcoded full backup that cron does will overwrite each day at destination. 
    119107*/ 
    120 if(isset($amp_conf['FTPBACKUP']) && $amp_conf['FTPBACKUP']=='yes'){ 
    121   $fh=fopen($opts['ftpfile'], 'w')|| die('Failed to open '.$opts['ftpfile']."\n")
    122   $data='user '.$amp_conf['FTPUSER'].' '.$amp_conf['FTPPASSWORD']." \n"; 
     108if( $opts['ftpuser'] && $opts['ftppass'] && $opts['ftphost']){ 
     109  $fh=fopen($opts['ftpfile'], 'w')
     110  $data='user '.$opts['ftpuser'].' '.$opts['ftppass']." \n"; 
    123111  $data.="binary\n"; 
    124   if($amp_conf['FTPSUBDIR']!=''){$data.="cd $ftpsubdir \n";} 
     112  if($opts['ftpdir']!=''){$data.="cd ${opts['ftpdir']} \n";} 
    125113  $data.='lcd '.$opts['budir'].'/'.$opts['name']."/\n"; 
    126114  $data.='put '.$opts['now'].".tar.gz\n"; 
     
    128116  fwrite($fh, $data); 
    129117  fclose($fh); 
    130   system ('ftp -n '.$amp_conf['FTPSERVER'].' < '.$opts['ftpfile'].' > /dev/null  2>&1'); 
    131 
    132  
    133 //SSH backup 
    134 if(isset($amp_conf['SSHBACKUP']) && $amp_conf['SSHBACKUP']=='yes'){ 
    135   if(($amp_conf['SSHRSAKEY']!='') && ($amp_conf['SSHSERVER']!='')){ 
    136     if ($amp_conf['SSHUSER']!=''){ 
    137       $amp_conf['SSHUSER'] = system('whoami'); 
    138     } 
    139     if ($amp_conf['SSHSUBDIR']!=''){ 
    140       system('/usr/bin/ssh -o StrictHostKeyChecking=no -i '.$amp_conf['SSHRSAKEY'].' '.$amp_conf['SSHUSER'].'\@'.$amp_conf['SSHSERVER'].' mkdir -p '.$amp_conf['SSHSUBDIR']); 
    141     } 
    142     system('/usr/bin/scp -o StrictHostKeyChecking=no -i '.$amp_conf['SSHRSAKEY'].' '.$opts['budir'].'/'.$opts['name'].'/'.$opts['now'].'.tar.gz '.$amp_conf['SSHUSER'].'\@'.$amp_conf['SSHSERVER'].':'.$amp_conf['SSHSUBDIR']); 
    143   } 
    144 
    145  
    146 //EMAIL backup 
    147 if($amp_conf['AMPBACKUPEMAIL']=='yes' && isset($amp_conf['AMPBACKUPEMAILADDR'])){ 
    148   if(filesize($opts['budir'].'/'.$opts['name']) <= size2bytes(strtoupper($amp_conf['AMPBACKUPEMAILMAX']))){ 
     118  exec('ftp -n '.$opts['ftphost'].' < '.$opts['ftpfile'].' ',$ftpres); 
     119
     120 
     121//ssh backup 
     122if($opts['sshkey'] && $opts['sshhost']){ 
     123  if(!$opts['sshuser']){exec('whoami',$opts['sshuser']);}//use username of whoever scrip is running as if username isnt set 
     124  if($opts['sshdir']!=''){  //ensure that remote directory exists 
     125    system('/usr/bin/ssh -o StrictHostKeyChecking=no -i '.$opts['sshkey'].' '.$opts['sshuser'].'\@'.$opts['sshhost'].' mkdir -p '.$opts['sshdir']); 
     126  } 
     127  system('/usr/bin/scp -o StrictHostKeyChecking=no -i '.$opts['sshkey'].' '.$opts['budir'].'/'.$opts['name'].'/'.$opts['now'].'.tar.gz '.$opts['sshuser'].'\@'.$opts['sshhost'].':'.$opts['sshdir']); 
     128
     129 
     130//email backup 
     131if($opts['emailaddr']){ 
     132  if(filesize($opts['budir'].'/'.$opts['name']) <= $opts['emailmaxsize'].$opts['emailmaxtype']){ 
    149133    //credit to: http://articles.sitepoint.com/print/advanced-email-php 
    150134    $hostname=exec('/bin/hostname',$name); 
     
    190174    //echo "To:\n";echo $amp_conf['AMPBACKUPEMAILADDR'];echo "\n\nSubject:\n";echo $subject;echo "\n\nMessage:\n";echo $message;echo "\n\nHeaders:\n";echo $headers."\n"; 
    191175    // Send the message 
    192     mail($amp_conf['AMPBACKUPEMAILADDR'], $subject, $message, $headers); 
     176    mail($opts['emailaddr'], $subject, $message, $headers); 
    193177  } 
    194178} 
     
    197181function size2bytes($str){  
    198182  $bytes=0;  
    199   $bytes_array=array('B' => 1, 'KB' => 1024, 'MB' => 1024 * 1024, 'GB' => 1024 * 1024 * 1024,  
    200                 'TB' => 1024 * 1024 * 1024 * 1024, 'PB' => 1024 * 1024 * 1024 * 1024 * 1024,);  
     183  $bytes_array=array('B'=>1, 'KB'=>1024, 'MB'=>1024*1024, 'GB'=>1024*1024*1024,  
     184                'TB'=>1024*1024*1024*1024, 'PB'=>1024*1024*1024*1024*1024);  
    201185  $bytes=floatval($str); 
    202   if(preg_match('#([KMGTP]?B)$#si', $str, $matches) && !empty($bytes_array[$matches[1]])){  
     186  if(preg_match('#([KMGTP]?B)$#si',$str,$matches) && !empty($bytes_array[$matches[1]])){  
    203187      $bytes*=$bytes_array[$matches[1]];  
    204188  }  
     
    218202  exit(1); 
    219203} 
     204 
    220205function getconf($filename) { 
    221206  $file = file($filename); 
     
    240225} 
    241226 
    242 if(!function_exists('dbug')){ 
    243  function dbug($disc=null,$msg=null){ 
    244   $debug=true; 
    245   if ($debug){ 
    246   $fh = fopen("/tmp/freepbx_debug.log", 'a') or die("can't open file"); 
    247   if($disc){$disc=' \''.$disc.'\':';} 
    248   fwrite($fh,date("Y-M-d H:i:s").$disc."\n"); //add timestamp 
    249   if (is_array($msg)) { 
    250     fwrite($fh,print_r($msg,true)."\n"); 
    251   } else { 
    252     fwrite($fh,$msg."\n"); 
    253  
    254   fclose($fh); 
    255  
    256 
    257 
     227 
     228function dbug($disc=null,$msg=null){ 
     229  $debug=true; 
     230  if ($debug){ 
     231  $fh = fopen("/tmp/freepbx_debug.log", 'a') or die("can't open file"); 
     232  if($disc){$disc=' \''.$disc.'\':';} 
     233  fwrite($fh,date("Y-M-d H:i:s").$disc."\n"); //add timestamp 
     234  if (is_array($msg)) { 
     235    fwrite($fh,print_r($msg,true)."\n"); 
     236  } else { 
     237    fwrite($fh,$msg."\n"); 
     238 
     239  fclose($fh); 
     240 
     241
     242 
    258243?> 
  • modules/branches/2.7/backup/functions.inc.php

    r8742 r8752  
    11<?php 
    2 //This file is part of FreePBX. 
    3 // 
    4 //    FreePBX is free software: you can redistribute it and/or modify 
    5 //    it under the terms of the GNU General Public License as published by 
    6 //    the Free Software Foundation, either version 2 of the License, or 
    7 //    (at your option) any later version. 
    8 // 
    9 //    FreePBX is distributed in the hope that it will be useful, 
    10 //    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12 //    GNU General Public License for more details. 
    13 // 
    14 //    You should have received a copy of the GNU General Public License 
    15 //    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>. 
    16 // 
    17 // Copyright (C) 2005 VerCom Systems, Inc. & Ron Hartmann (rhartmann@vercomsystems.com) 
    18 // Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) 
    19 // 
    20 // this function is in charge of looking into the database and creating crontab jobs for each of the Backup Sets 
    21 // The crontab file is for user asterisk. 
    22 // 
    23 // The program preserves any other cron jobs (Not part of the backup) that are installed for the user asterisk  
    24 // 
     2 
     3/* This file is part of FreePBX. 
     4 *  
     5 *     FreePBX is free software: you can redistribute it and/or modify 
     6 *     it under the terms of the GNU General Public License as published by 
     7 *     the Free Software Foundation, either version 2 of the License, or 
     8 *     (at your option) any later version. 
     9 *  
     10 *     FreePBX is distributed in the hope that it will be useful, 
     11 *     but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 *     GNU General Public License for more details. 
     14 *  
     15 *     You should have received a copy of the GNU General Public License 
     16 *     along with FreePBX.  If not, see <http: * www.gnu.org/licenses/>. 
     17 *  
     18 *  
     19 *  this function is in charge of looking into the database and creating crontab jobs for each of the Backup Sets 
     20 *  The crontab file is for user asterisk. 
     21 *  
     22 *  The program preserves any other cron jobs (Not part of the backup) that are installed for the user asterisk  
     23 */  
    2524 
    2625function backup_retrieve_backup_cron(){ 
     
    5352  return ($ret1 == 0 && $ret2 == 0); 
    5453} 
     54 
     55function backup_list_files($dir='', $display='', $file='') { 
     56  global $type,$asterisk_conf,$amp_conf; 
     57  $html=''; 
     58  if(is_dir($dir)){ 
     59    if(($file!=".") && ($file!="..") && ($file!="")){ 
     60      $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to delete this File Set?")."','config.php?type=$type&display=$display&action=deletedataset&dir=$dir')\">"; 
     61      $html.=_("DELETE ALL THE DATA IN THIS SET").'<span>'._("Delete this backup set and all data associated with this backup set..").'</span></a><br></li><br>'; 
     62    } 
     63    if($dh = opendir($dir)){ 
     64      while(($file = readdir($dh))!== false){ 
     65        $file_arr[]=$file; 
     66      } 
     67      rsort($file_arr); 
     68      $count=25; 
     69      foreach($file_arr as $file){ 
     70        if(($file!=".") && ($file!="..") && ($dir==$amp_conf['ASTVARLIBDIR']."/backups/")){ 
     71          $html.="<li><a href=\"config.php?type=$type&display=$display&action=restore&dir=$dir/$file\">$file</a><br></li>"; 
     72          $count--; 
     73        }elseif(($file!=".") && ($file!="..")){ 
     74          $html.="<li><a href=\"config.php?type=$type&display=$display&action=restore&dir=$dir/$file&file=$file\">$file</a><br></li>"; 
     75          $count--; 
     76        } 
     77      } 
     78      closedir($dh); 
     79      for ($i = $count; $i > 0; $i--){ 
     80        $html.='<br />'; 
     81      } 
     82    } 
     83  }elseif(substr($dir, -6)=="tar.gz" ){ 
     84    $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to delete this File Set?")."','config.php?type=$type&display=$display&action=deletefileset&dir=$dir&file=$file')\">"; 
     85    $html.=_("Delete File Set").'<span>'._("Delete this backup set.").'</span></a><br></li><br>'; 
     86    $tar_string="tar tfz \"$dir\" | cut -d'/' -f4"; 
     87    exec($tar_string,$restore_files,$error); 
     88    $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to restore this COMPLETE file set?\\nDoing so will permanently over-write all FreePBX and Asterisk files\\nYou will lose all Your Call Detail Records and any Voicemail that was recorded between the BACKUP DATE and NOW!")."','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=ALL&file=$file')\">"; 
     89    $html.=_("Restore Entire Backup Set").'<span>';  
     90    $html.=_("Restore your Complete Backup set overwriting all files.").'</span></a><br></li><br>'; 
     91    if(array_search('voicemail.tar.gz',$restore_files)){ 
     92      $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to Restore this file set?\\nDoing so will permanently delete any new voicemail you have in your mailbox\\nsince this backup on")." $file!','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=VoiceMail&file=$file')\">"; 
     93      $html.=_('Restore VoiceMail Files').'<span>';  
     94      $html.=_('Restore your Voicemail files from this backup set.  NOTE! This will delete any voicemail currently in the voicemail boxes.'); 
     95      $html.='</span></a><br></li><br>'; 
     96    } 
     97    if(array_search('recordings.tar.gz',$restore_files)){ 
     98      $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to Restore this file set?\\nNOTE! This will OVERWRITE any voicerecordings currently on the system. It will NOT delete new files not currently in the backup set")."','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=Recordings&file=$file')\">"; 
     99      $html.=_('Restore System Recordings Files').'<span>';  
     100      $html.=_("Restore your system Voice Recordings including AutoAttendent files from this backup set.  NOTE! This will OVERWRITE any voicerecordings  currently on the system. It will NOT delete new files not currently in the backup set").'</span></a><br></li><br>'; 
     101    } 
     102    if(array_search('configurations.tar.gz',$restore_files)){ 
     103      $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to Restore this File Set?\\nDoing so will Permanently Over-Write all FreePBX and Asterisk Files!")."','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=Configurations&file=$file')\">"; 
     104      $html.=_("Restore System Configuration").'<span>'._("Restore your system configuration from this backup set.  NOTE! This will OVERWRITE any System changes you have made since this backup... ALL Itemes will be reset to what they were at the time of this backup set..").'</span></a><br></li><br>'; 
     105    } 
     106    if(array_search('fop.tar.gz',$restore_files)){ 
     107      $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to Restore the Operator Panel Files?\\nDoing so will Permanently Over-Write all Operator Panel Files!")."','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=FOP&file=$file')\">"; 
     108      $html.=_("Restore Operator Panel").'<span>';  
     109      $html.=_('Restore the Operator Panel from this backup set.  NOTE! This will OVERWRITE any Operator Panel Changes you have made since this backup... ALL Itemes will be reset to what they were at the time of this backup set..').'</span></a><br></li><br>'; 
     110    } 
     111    if(array_search('cdr.tar.gz',$restore_files)){ 
     112      $html.="<li><a class=\"info\" href=\"javascript:decision('"._("Are you sure you want to Restore the CALL DETAIL FILES?\\nDoing so will Permanently DELETE all CALL RECORDS!")."','config.php?type=$type&display=$display&action=restored&dir=$dir&filetype=CDR&file=$file')\">"; 
     113      $html.=_("Restore Call Detail Report").'<span>';  
     114      $html.=_("Restore the Call Detail Records from this backup set.  NOTE! This will DELETE ALL CALL RECORDS that have been saved since this backup set..");  
     115      $html.='</span></a><br></li><br>'; 
     116    } 
     117  }else{ 
     118    $html.='<h2>'._("ERROR its not a BACKUP SET file").'</h2>'; 
     119  } 
     120  echo $html; 
     121} 
     122 
     123function backup_restore_tar($dir="", $file="",$filetype="", $display="") { 
     124  global $asterisk_conf,$amp_conf; 
     125  $error = false; 
     126  $tar='/bin/tar'; 
     127  if($amp_conf['AMPBACKUPSUDO']==true){$sudo='/usr/bin/sudo';}else{$sudo='';}//use sudo if requested - DANGEROUS!!! 
     128  switch($filetype){ 
     129    case 'ALL': 
     130      $fileholder=substr($file, 0,-7); 
     131      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     132      $error = ($error || ($ret != 0)); 
     133   
     134      // First restore voicemial (for some reason if you do it all at once these don't get restored 
     135      exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail 2>&1',$out_arr,$ret); 
     136      $error = ($error || ($ret != 0)); 
     137      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | $tar -Pxvz"; 
     138      exec($tar_cmd,$out_arr,$ret); 
     139      $error = ($error || ($ret != 0)); 
     140   
     141      // Next, recordings cause same issue as above 
     142      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | $tar -Pxvz"; 
     143      exec($tar_cmd,$out_arr,$ret); 
     144      $error = ($error || ($ret != 0)); 
     145   
     146      // Now the rest and then we'll get on with the databases 
     147      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | $tar -Pxvz"; 
     148      exec($tar_cmd,$out_arr,$ret); 
     149      $error = ($error || ($ret != 0)); 
     150      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz /tmp/ampbackups.$fileholder/cdr.tar.gz  | $tar -Pxvz"; 
     151      exec($tar_cmd,$out_arr,$ret); 
     152      $error = ($error || ($ret != 0)); 
     153      $tar_cmd="$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/asteriskcdr.sql /tmp/ampbackups.$fileholder/astdb.dump"; 
     154      exec($tar_cmd,$out_arr,$ret); 
     155      $error = ($error || ($ret != 0)); 
     156   
     157      $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql 2>&1"; 
     158      exec($sql_cmd,$out_arr,$ret); 
     159      $error = ($error || ($ret != 0)); 
     160      $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql 2>&1"; 
     161      exec($sql_cmd,$out_arr,$ret); 
     162      $error = ($error || ($ret != 0)); 
     163      exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder 2>&1",$out_arr,$ret); 
     164      $error = ($error || ($ret != 0)); 
     165       
     166      //restore additional file (aka AMPPROVROOT), using sudo if requested 
     167      $tar_cmd="$sudo $tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/phoneconfig.tar.gz |$sudo $tar -Pxvz"; 
     168      exec($tar_cmd,$out_arr,$ret); 
     169      $error = ($error || ($ret != 0)); 
     170      exec("/bin/rm -rf /tmp/ampbackups.$fileholder",$out_arr,$ret); 
     171      $error = ($error || ($ret != 0)); 
     172      if(!error){$message=_("Restored All Files in BackupSet");} 
     173      break; 
     174    case 'VoiceMail': 
     175      $fileholder=substr($file, 0,-7); 
     176      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     177      $error = ($error || ($ret != 0)); 
     178      exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail 2>&1',$out_arr,$ret); 
     179      $error = ($error || ($ret != 0)); 
     180      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | $tar -Pxvz"; 
     181      exec($tar_cmd,$out_arr,$ret); 
     182      $error = ($error || ($ret != 0)); 
     183      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     184      $error = ($error || ($ret != 0)); 
     185      if(!error){$message=_("Restored VoiceMail");} 
     186    break; 
     187    case 'Recordings': 
     188      $fileholder=substr($file, 0,-7); 
     189      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     190      $error = ($error || ($ret != 0)); 
     191      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | $tar -Pxvz"; 
     192      exec($tar_cmd,$out_arr,$ret); 
     193      $error = ($error || ($ret != 0)); 
     194      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     195      $error = ($error || ($ret != 0)); 
     196      if(!error){$message=_("Restored System Recordings");} 
     197    break; 
     198    case 'Configurations': 
     199      $fileholder=substr($file, 0,-7); 
     200      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     201      $error = ($error || ($ret != 0)); 
     202      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | $tar -Pxvz"; 
     203      exec($tar_cmd,$out_arr,$ret); 
     204      $error = ($error || ($ret != 0)); 
     205      $tar_cmd="$$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/astdb.dump"; 
     206      exec($tar_cmd,$out_arr,$ret); 
     207      $error = ($error || ($ret != 0)); 
     208      $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql"; 
     209      exec($sql_cmd,$out_arr,$ret); 
     210      $error = ($error || ($ret != 0)); 
     211      exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder 2>&1",$out_arr,$ret); 
     212      $error = ($error || ($ret != 0)); 
     213      //restore additional file (aka AMPPROVROOT), using sudo if requested 
     214      $tar_cmd="$sudo $tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/phoneconfig.tar.gz |$sudo $tar -Pxvz"; 
     215      exec($tar_cmd,$out_arr,$ret); 
     216       
     217      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     218      $error = ($error || ($ret != 0)); 
     219      if(!error){$message=_("Restored System Configuration");} 
     220    break; 
     221    case 'FOP': 
     222      $fileholder=substr($file, 0,-7); 
     223      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     224      $error = ($error || ($ret != 0)); 
     225      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz | $tar -Pxvz"; 
     226      exec($tar_cmd,$out_arr,$ret); 
     227      $error = ($error || ($ret != 0)); 
     228      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     229      $error = ($error || ($ret != 0)); 
     230      if(!error){$message=_("Restored Operator Panel");} 
     231    break; 
     232    case 'CDR': 
     233      $fileholder=substr($file, 0,-7); 
     234      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     235      $error = ($error || ($ret != 0)); 
     236      $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/cdr.tar.gz | $tar -Pxvz"; 
     237      exec($tar_cmd,$out_arr,$ret); 
     238      $error = ($error || ($ret != 0)); 
     239      $tar_cmd="$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asteriskcdr.sql"; 
     240      exec($tar_cmd,$out_arr,$ret); 
     241      $error = ($error || ($ret != 0)); 
     242      $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql 2>&1"; 
     243      exec($sql_cmd,$out_arr,$ret); 
     244      $error = ($error || ($ret != 0)); 
     245      exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); 
     246      $error = ($error || ($ret != 0)); 
     247      if(!error){$message=_("Restored CDR logs");} 
     248    break; 
     249  } 
     250  return ($error)?$message:_('Restore Failed, see System Status Notification for details'); 
     251} 
     252 
     253function backup_get(){ 
     254  global $db; 
     255  $sql = "SELECT * FROM backup ORDER BY name ASC"; 
     256  $results = $db->getAll($sql); 
     257  if(DB::IsError($results)) { 
     258    $results = null; 
     259  } 
     260  return $results; 
     261} 
     262 
     263function backup_delete_set($id=''){ 
     264  global $db,$asterisk_conf,$amp_conf; 
     265  $sql = "DELETE FROM backup WHERE id =?"; 
     266  $result = $db->query($sql,array($id)); 
     267  if(DB::IsError($result)) { 
     268    die_freepbx($result->getMessage()); 
     269  } 
     270  backup_retrieve_backup_cron(); 
     271} 
     272 
     273function backup_save_schedule($parms){ 
     274  global $db,$asterisk_conf,$amp_conf; 
     275  //build query based on the following keys 
     276  $parms_num=array('admin','cdr','command','configurations','days','emailaddr', 
     277                  'emailmaxsize','emailmaxtype','exclude','fop','ftpdir','ftphost', 
     278                  'ftppass','ftpuser','hours','id','include','method','minutes', 
     279                  'months','name','recordings','sshdir','sshhost','sshkey','sshuser', 
     280                  'sudo','voicemail','weekdays'); 
     281  foreach($parms_num as $dprm){$db_parms[$dprm]=isset($parms[$dprm])?$parms[$dprm]:'';} 
     282  $keys=$vals=''; 
     283  //dont include empty values in the query 
     284  foreach(array_keys($db_parms) as $key){ 
     285    if($db_parms[$key]!=''){ 
     286      $keys.=$key.','; 
     287    } 
     288  } 
     289  foreach(array_values($db_parms) as $val){ 
     290    if($val!=''){ 
     291      $vals.='"'.$db->escapeSimple($val).'",'; 
     292    } 
     293  } 
     294  $keys=substr($keys,0,-1);$vals=substr($vals,0,-1); 
     295  $sql='INSERT INTO backup ('.$keys.') VALUES ('.$vals.')'; 
     296  $result = $db->query($sql); 
     297  if(DB::IsError($result)) { 
     298    die_freepbx($result->getMessage().'<hr>'.$sql); 
     299  } 
     300   
     301  if($parms['method']=='now' && $result){ 
     302    $latest=$db->getOne('select last_insert_id()'); 
     303    $backup_script=$asterisk_conf['astvarlibdir'].'/bin/ampbackup.php '.$latest; 
     304    exec($backup_script,$res); 
     305  } 
     306  backup_retrieve_backup_cron(); 
     307   
     308} 
     309function backup_get_string($parms){ 
     310  global $asterisk_conf; 
     311  switch($parms['backup_schedule']){ 
     312    case 'hourly': 
     313      $cron_string='0 * * * * '; 
     314    break; 
     315    case 'daily': 
     316      $cron_string='0 0 * * * '; 
     317    break; 
     318    case 'weekly': 
     319      $cron_string='0 0 * * 0 '; 
     320    break; 
     321    case 'monthly': 
     322      $cron_string='0 0 1 * * '; 
     323    break; 
     324    case 'yearly': 
     325      $cron_string='0 0 1 1 * '; 
     326    break; 
     327    case 'now': 
     328      $cron_string='0 0 0 0 0 '; 
     329    break; 
     330    case 'follow_schedule': 
     331      $mins_string=$hours_string=$days_string=$months_string=$weekdays_string=''; 
     332      if(is_array($parms['mins'])){ 
     333        foreach($parms['mins'] as $value){ 
     334          $mins_string.=":$value:"; 
     335        } 
     336      }else{ 
     337        $mins_string=":0:"; 
     338      } 
     339      if(is_array($parms['hours'])){ 
     340        foreach($parms['hours'] as $value){ 
     341          $hours_string.=":$value:"; 
     342        } 
     343      }else{ 
     344        $hours_string=":0:"; 
     345      } 
     346      if(isset($parms['all_days']) && $parms['all_days']=='0'){ 
     347        foreach($parms['days'] as $value){ 
     348          $days_string.=":$value:"; 
     349        } 
     350      }else{ 
     351        $days_string="*"; 
     352      } 
     353      if(isset($parms['all_months']) && $parms['all_months']=='0'){ 
     354        foreach($parms['months'] as $value){ 
     355          $months_string.=":$value:"; 
     356        } 
     357      }else{ 
     358        $months_string="*"; 
     359      } 
     360      if(isset($parms['all_weekdays']) && $parms['all_weekdays']=='0'){ 
     361        foreach($parms['weekdays'] as $value){ 
     362         $weekdays_string.=":$value:"; 
     363        } 
     364      }else{ 
     365        $weekdays_string="*"; 
     366      } 
     367      $cron_mins_string=trim($mins_string,":"); 
     368      $cron_hours_string=trim($hours_string,":"); 
     369      $cron_days_string=trim($days_string,":"); 
     370      $cron_months_string=trim($months_string,":"); 
     371      $cron_weekdays_string=trim($weekdays_string,":"); 
     372      $cron_string=str_replace("::", ",", "$cron_mins_string $cron_hours_string $cron_days_string $cron_months_string $cron_weekdays_string"); 
     373    break; 
     374  } 
     375  $backup_string['name']=$parms['name']; 
     376  $backup_string['method']=$parms['backup_schedule']; 
     377  $backup_string['minutes']=isset($mins_string)?$mins_string:''; 
     378  $backup_string['hours']=isset($hours_string)?$hours_string:''; 
     379  $backup_string['days']=isset($days_string)?$days_string:''; 
     380  $backup_string['months']=isset($months_string)?$months_string:''; 
     381  $backup_string['weekdays']=isset($weekdays_string)?$weekdays_string:''; 
     382  $backup_string['command']=$cron_string.' '.$asterisk_conf['astvarlibdir'].'/bin/ampbackup.php'; 
     383  $ret=array_merge($parms,$backup_string); 
     384  return ($ret); 
     385} 
     386function Get_Backup_Times($id){ 
     387  global $db; 
     388  $sql = "SELECT minutes, hours, days, months, weekdays, method From backup where id=?"; 
     389  $results = $db->getAll($sql,array($id)); 
     390  if(DB::IsError($results)) { 
     391    $results = Array(null, null, null, null, null, null); 
     392  } 
     393  return $results; 
     394} 
     395function Get_Backup_Options($id){ 
     396  global $db; 
     397  $sql = "SELECT * FROM backup WHERE id=?"; 
     398  $results = $db->getAll($sql,array($id),DB_FETCHMODE_ASSOC); 
     399  if(DB::IsError($results)) { 
     400    $results = Array(null, null, null, null, null, null); 
     401  } 
     402  return $results[0]; 
     403} 
     404function backup_showopts($id=''){ 
     405  $tabindex=0; 
     406  if ($id==''){ 
     407    $opts=array('name','voicemail','recordings','configurations','cdr','fop'); 
     408    foreach($opts as $o){$opts[$o]='';}//set defaults to '' 
     409  }else{ 
     410    $opts=Get_Backup_Options($id); 
     411  } 
     412  ?> 
     413  <table> 
     414  <tr><td colspan="2"><h5><?php echo _("Basic Settings")?><hr></h5></td></tr> 
     415  <tr> 
     416      <td><a href="#" class="info"><?php echo _("Schedule Name:")?><span><?php echo _("Give this Backup Schedule a brief name to help you identify it.");?></span></a></td> 
     417      <td><input type="text" name="name" value="<?php echo (isset($opts['name'])?$opts['name']:''); ?>" tabindex="<?php echo ++$tabindex;?>"></td> 
     418  </tr> 
     419  <tr> 
     420    <td><a href="#" class="info"><?php echo _("VoiceMail");?><span><?php echo _("Backup the System VoiceMail Boxes... CAUTION: Could result in large file");?></span></a>: </td> 
     421    <td><input type="checkbox" name="voicemail"  tabindex="<?php echo ++$tabindex;?>" value="yes" <?php echo ($opts['voicemail']=='yes')?'checked':''; ?> /></td> 
     422  </tr> 
     423  <tr> 
     424    <td><a href="#" class="info"><?php echo _("System Recordings");?><span><?php echo _("Backup the System Recordings (AutoAttendent, Music On Hold, System Recordings)");?></span></a>: </td> 
     425    <td><input type="checkbox" name="recordings" value="yes" <?php echo ($opts['recordings']=='yes')?'checked':''; ?> /></td> 
     426  </tr> 
     427  <tr> 
     428    <td><a href="#" class="info"><?php echo _("System Configuration");?><span><?php echo _("Backup the System Configurations (Database, etc files, SQL Database, astdb)");?></span></a>: </td> 
     429    <td><input type="checkbox" name="configurations" value="yes" <?php echo ($opts['configurations']=='yes')?'checked':''; ?>/></td> 
     430  </tr> 
     431  <tr> 
     432    <td><a href="#" class="info"><?php echo _("Admin Web Directory");?><span><?php echo _("Backup the admin web directory (i.e. the static FreePBX web files). This is usefull to have durring a restore to prevent a version mismatch, but can baloon the backup size.");?></span></a>: </td> 
     433    <td><input type="checkbox" name="admin" value="yes" <?php echo ($opts['admin']=='yes')?'checked':''; ?>/></td> 
     434  </tr> 
     435  <tr> 
     436    <td><a href="#" class="info"><?php echo _("CDR");?><span><?php echo _("Backup the System Call Detail Reporting (HTML and Database)");?></span></a>: </td> 
     437    <td><input type="checkbox" name="cdr" value="yes" <?php echo ($opts['cdr']=='yes')?'checked':''; ?>/></td> 
     438  </tr> 
     439  <tr> 
     440    <td><a href="#" class="info"><?php echo _("Operator Panel");?><span><?php echo _("Backup the Operator Panel (HTML and Database)");?></span></a>: </td> 
     441    <td><input type="checkbox" name="fop" value="yes" <?php echo ($opts['fop']=='yes')?'checked':''; ?>/></td> 
     442  </tr> 
     443 
     444  <tr><td colspan="2"><h5><span class="tog files">+</span><?php echo _(' Additonal Files')?><hr></h5></td></tr> 
     445  <tr class="hide files"> 
     446    <td><a href="#" class="info"><?php echo _("Additional files and folders");?><span><?php echo _("Backup any additional files and folders listed here.");?></span></a>: </td> 
     447    <td><textarea name="include" style="width: 400px" /><?php echo $opts['include']; ?></textarea></td> 
     448  </tr> 
     449  <tr class="hide files"> 
     450    <td><a href="#" class="info"><?php echo _("Exclude files and folders");?><span><?php echo _("Exclude any  files and folders from the include listed above.");?></span></a>: </td> 
     451    <td><textarea name="exclude" style="width: 400px" /><?php echo $opts['exclude']; ?></textarea></td> 
     452  </tr> 
     453   
     454  <tr><td colspan="2"><h5><span class="tog ftp">+</span><?php echo _(' FTP Settings')?><hr></h5></td></tr> 
     455  <tr class="hide ftp"> 
     456    <td><a href="#" class="info"><?php echo _("Ftp User Name");?><span><?php echo _('');?></span></a>: </td> 
     457    <td><input type="text" name="ftpuser" value="<?php echo $opts['ftpuser']; ?>" /></td> 
     458  </tr> 
     459  <tr class="hide ftp"> 
     460    <td><a href="#" class="info"><?php echo _("Ftp Password");?><span><?php echo _('');?></span></a>: </td> 
     461    <td><input type="text" name="ftppass" value="<?php echo $opts['ftppass']; ?>" /></td> 
     462  </tr> 
     463  <tr class="hide ftp"> 
     464    <td><a href="#" class="info"><?php echo _("Ftp Hostname");?><span><?php echo _('IP address or FQDN of FTP server');?></span></a>: </td> 
     465    <td><input type="text" name="ftphost" value="<?php echo $opts['ftphost']; ?>" /></td> 
     466  </tr> 
     467  <tr class="hide ftp"> 
     468    <td><a href="#" class="info"><?php echo _("Ftp Directory");?><span><?php echo _('Directory on FTP server where the backup should be copied to');?></span></a>: </td> 
     469    <td><input type="text" name="ftpdir" value="<?php echo $opts['ftpdir']; ?>" /></td> 
     470  </tr> 
     471  <tr><td colspan="2"><h5><span class="tog ssh">+</span><?php echo _(' SSH Settings')?><hr></h5></td></tr> 
     472  <tr class="hide ssh"> 
     473    <td><a href="#" class="info"><?php echo _("SSH User Name");?><span><?php echo _('');?></span></a>: </td> 
     474    <td><input type="text" name="sshuser" value="<?php echo $opts['sshuser']; ?>" /></td> 
     475  </tr> 
     476  <tr class="hide ssh"> 
     477    <td><a href="#" class="info"><?php echo _("SSH Key");?><span><?php echo _('Location of ssh private key to be used when connect to hossst');?></span></a>: </td> 
     478    <td><input type="text" name="sshkey" value="<?php echo $opts['sshkey']; ?>" /></td> 
     479  </tr> 
     480  <tr class="hide ssh"> 
     481    <td><a href="#" class="info"><?php echo _("SSH Hostname");?><span><?php echo _('IP address or FQDN of remote ssh host');?></span></a>: </td> 
     482    <td><input type="text" name="sshhost" value="<?php echo $opts['sshhost']; ?>" /></td> 
     483  </tr> 
     484  <tr class="hide ssh"> 
     485    <td><a href="#" class="info"><?php echo _("SSH Directory");?><span><?php echo _('Directory on remote server where the backup should be copied t');?></span></a>: </td> 
     486    <td><input type="text" name="sshdir" value="<?php echo $opts['sshdir']; ?>" /></td> 
     487  </tr>  
     488  <tr><td colspan="2"><h5><span class="tog email">+</span><?php echo _(' Email Settings')?><hr></h5></td></tr> 
     489  <tr class="hide email"> 
     490    <td><a href="#" class="info"><?php echo _("Email Address");?><span><?php echo _('Email address where backups should be emailed to');?></span></a>: </td> 
     491    <td><input type="text" name="emailaddr" value="<?php echo $opts['emailaddr']; ?>" /></td> 
     492  </tr>  
     493  <tr class="hide email"> 
     494    <td><a href="#" class="info"><?php echo _("Max email size");?><span><?php echo _('The maximum size a backup can be and still be emailed. Some email servers limit the size of email atttachments, this will make sure that files larger than the max size are not sent. Valid options include: xB, xKB, xMB');?></span></a>: </td> 
     495    <td><select name="emailmaxsize"> 
     496        <?php if($opts['emailmaxsize']==''){$opts['emailmaxsize']=25;}//default max email size to 25 
     497         for($i=1;$i<21;$i++){    echo '<option value="'.$i.'" '.($opts['emailmaxsize']==$i?'selected':'').' >'.$i.'</option>';} 
     498         for($i=25;$i<51;$i+=5){  echo '<option value="'.$i.'" '.($opts['emailmaxsize']==$i?'selected':'').' >'.$i.'</option>';} 
     499         for($i=60;$i<101;$i+=10){echo '<option value="'.$i.'" '.($opts['emailmaxsize']==$i?'selected':'').' >'.$i.'</option>';}?> 
     500        </select> 
     501        <select name="emailmaxtype"> 
     502        <?php if($opts['emailmaxtype']==''){$opts['emailmaxtype']='MB';}//default max type to MB 
     503         $maxtypes=array('B','KB','MB'); 
     504        foreach($maxtypes as $max){echo '<option value="'.$max.'" '.($opts['emailmaxtype']==$max?'selected':'').' >'.$max.'</option>';  } ?> 
     505      </select> 
     506      </td> 
     507  </tr> 
     508  <style type="text/css"> 
     509  .tog{cursor:pointer;color:black} 
     510  .hide{display:none} 
     511  h5{margin-top:10px;margin-bottom:10px} 
     512  </style> 
     513  <script language="javascript" type="text/javascript"> 
     514    $(document).ready(function() { 
     515      $('.tog').click(function(){ 
     516        var tclass = $(this).attr('class'); tclass = tclass.replace('tog ', ''); 
     517        if($(this).text()=='+'){ 
     518          $(this).text('- '); 
     519          $('.'+tclass).show(); 
     520        }else{ 
     521          $(this).text('+'); 
     522          $('.'+tclass).not('.tog').hide(); 
     523        } 
     524 
     525       }) 
     526    }); 
     527  </script> 
     528  <?php 
     529} 
     530function Schedule_Show_Minutes($Minutes_Set=""){ 
     531  echo "<br><br><table> <tr>"; 
     532  echo "<td valign=top><select multiple size=12 name=mins[]>"; 
     533  for ($minutes=0; $minutes<=59; $minutes++){ 
     534/* if (($minutes==12)||($minutes==24)||($minutes==36)||($minutes==48)) { echo  
     535"</select></td>"; echo "<td width=2 valign=top><select multiple size=12  
     536name=mins[]>"; } */  
     537    if (strstr($Minutes_Set,":$minutes:")) 
     538      echo "<option value=\"$minutes\" selected>$minutes"; 
     539    else 
     540      echo "<option value=\"$minutes\" >$minutes"; 
     541  } 
     542  echo "</select></td>"; 
     543  echo "</tr></table></td>"; 
     544} 
     545function Schedule_Show_Hours($Hours_Set=""){ 
     546  echo "<br><br><table> <tr>"; 
     547  echo "<td valign=top><select multiple size=12 name=hours[]>"; 
     548  for ($hours=0; $hours<=23; $hours++) 
     549  { 
     550  /* if ($hours==12) { echo "</select></td>"; echo "<td valign=top><select multiple size=12 name=hours[]>"; } */  
     551    if (strstr($Hours_Set,":$hours:")) 
     552      echo "<option value=\"$hours\" selected>$hours"; 
     553    else 
     554      echo "<option value=\"$hours\" >$hours"; 
     555  } 
     556  echo "</select></td>"; 
     557  echo "</tr></table></td>"; 
     558} 
     559 
     560function Schedule_Show_Days($Days_Set=""){ 
     561  if (($Days_Set=="") || ($Days_Set=="*")){ 
     562  echo "<input type=radio name=all_days value=1 checked>"; echo _("All"); echo "<br>"; 
     563  echo "<input type=radio name=all_days value=0 >"; echo _("Selected"); echo "<br>"; 
     564  } 
     565  else{ 
     566  echo "<input type=radio name=all_days value=1 >"; echo _("All"); echo "<br>"; 
     567  echo "<input type=radio name=all_days value=0 checked>"; echo _("Selected"); echo "<br>"; 
     568  } 
     569 
     570  echo "<table> <tr>"; 
     571  echo "<td valign=top><select multiple size=12 name=days[]>"; 
     572  for ($days=1; $days<=31; $days++) 
     573  { 
     574/* if (($days==13)||($days==25)) { echo "</select></td>"; echo "<td valign=top><select multiple size=12 name=days[]>"; } */  
     575  if ((strstr($Days_Set,":$days:"))|| ($Days_Set=="*")) 
     576      echo "<option value=\"$days\" selected>$days"; 
     577    else 
     578      echo "<option value=\"$days\" >$days"; 
     579  } 
     580  echo "</select></td>"; 
     581  echo "</tr></table></td>"; 
     582} 
     583 
     584function Schedule_Show_Months($Months_Set=""){ 
     585  if (($Months_Set=="") || ($Months_Set=="*")){ 
     586  echo "<input type=radio name=all_months value=1 checked>"; echo _("All"); echo "<br>"; 
     587  echo "<input type=radio name=all_months value=0 >"; echo _("Selected"); echo "<br>"; 
     588  } 
     589  else{ 
     590  echo "<input type=radio name=all_months value=1 >"; echo _("All"); echo "<br>"; 
     591  echo "<input type=radio name=all_months value=0 checked>"; echo _("Selected"); echo "<br>"; 
     592  } 
     593  echo "<table> <tr>"; 
     594  echo "<td valign=top><select multiple size=12 name=months[]>"; 
     595  echo ((strstr($Months_Set,":1:") || ($Months_Set=="*")) ? '<option value="1" selected>'._("January"):'<option value="1" >'._("January")); 
     596  echo ((strstr($Months_Set,":2:") || ($Months_Set=="*")) ? '<option value="2" selected>'._("February"):'<option value="2" >'._("February")); 
     597  echo ((strstr($Months_Set,":3:") || ($Months_Set=="*")) ? '<option value="3" selected>'._("March"):'<option value="3" >'._("March")); 
     598  echo ((strstr($Months_Set,":4:") || ($Months_Set=="*")) ? '<option value="4" selected>'._("April"):'<option value="4" >'._("April")); 
     599  echo ((strstr($Months_Set,":5:") || ($Months_Set=="*")) ? '<option value="5" selected>'._("May"):'<option value="5" >'._("May")); 
     600  echo ((strstr($Months_Set,":6:") || ($Months_Set=="*")) ? '<option value="6" selected>'._("June"):'<option value="6" >'._("June")); 
     601  echo ((strstr($Months_Set,":7:") || ($Months_Set=="*")) ? '<option value="7" selected>'._("July"):'<option value="7" >'._("July")); 
     602  echo ((strstr($Months_Set,":8:") || ($Months_Set=="*")) ? '<option value="8" selected>'._("August"):'<option value="8" >'._("August")); 
     603  echo ((strstr($Months_Set,":9:") || ($Months_Set=="*")) ? '<option value="9" selected>'._("September"):'<option value="9" >'._("September")); 
     604  echo ((strstr($Months_Set,":10:") || ($Months_Set=="*")) ? '<option value="10" selected>'._("October"):'<option value="10" >'._("October")); 
     605  echo ((strstr($Months_Set,":11:") || ($Months_Set=="*")) ? '<option value="11" selected>'._("November"):'<option value="11" >'._("November")); 
     606  echo ((strstr($Months_Set,":12:") || ($Months_Set=="*")) ? '<option value="12" selected>'._("December"):'<option value="12" >'._("December")); 
     607 
     608  echo "</select></td>"; 
     609  echo "</tr></table></td>"; 
     610} 
     611 
     612function Schedule_Show_Weekdays($Weekdays_Set=""){ 
     613  if (($Weekdays_Set=="") || ($Weekdays_Set=="*")){ 
     614  echo "<input type=radio name=all_weekdays value=1 checked>";echo _("All"); echo "<br>"; 
     615  echo "<input type=radio name=all_weekdays value=0 >";echo _("Selected"); echo "<br>"; 
     616  } 
     617  else{ 
     618  echo "<input type=radio name=all_weekdays value=1 >";echo _("All"); echo "<br>"; 
     619  echo "<input type=radio name=all_weekdays value=0 checked>";echo _("Selected"); echo "<br>"; 
     620  } 
     621  echo "<table> <tr>"; 
     622  echo "<td valign=top><select multiple size=12 name=weekdays[]>"; 
     623  echo ((strstr($Weekdays_Set,":1:") || ($Weekdays_Set=="*")) ? '<option value="1" selected>'._("Monday"):'<option value="1" >'._("Monday")); 
     624  echo ((strstr($Weekdays_Set,":2:") || ($Weekdays_Set=="*")) ? '<option value="2" selected>'._("Tuesday"):'<option value="2" >'._("Tuesday")); 
     625  echo ((strstr($Weekdays_Set,":3:") || ($Weekdays_Set=="*")) ? '<option value="3" selected>'._("Wednesday"):'<option value="3" >'._("Wednesday")); 
     626  echo ((strstr($Weekdays_Set,":4:") || ($Weekdays_Set=="*")) ? '<option value="4" selected>'._("Thursday"):'<option value="4" >'._("Thursday")); 
     627  echo ((strstr($Weekdays_Set,":5:") || ($Weekdays_Set=="*")) ? '<option value="5" selected>'._("Friday"):'<option value="5" >'._("Friday")); 
     628  echo ((strstr($Weekdays_Set,":6:") || ($Weekdays_Set=="*")) ? '<option value="6" selected>'._("Saturday"):'<option value="6" >'._("Saturday")); 
     629  echo ((strstr($Weekdays_Set,":0:") || ($Weekdays_Set=="*")) ? '<option value="0" selected>'._("Sunday"):'<option value="0" >'._("Sunday")); 
     630 
     631  echo "</select></td>"; 
     632  echo "</tr></table></td>"; 
     633} 
     634function show_quickbar($method=''){ 
    55635?> 
     636  <tr bgcolor=#b7b7b7> <td colspan=6><?php echo _("Run Backup");?>  
     637  <select name=backup_schedule> 
     638  <option value=follow_schedule <?php echo ($method=="follow_schedule"?"SELECTED":'')?>><?php echo _("Follow Schedule Below");?> 
     639  <option value=now <?php echo ($method=="now"?"SELECTED":'')?>><?php echo _("Now");?> 
     640  <option value=daily <?php echo ($method=="daily"?"SELECTED":'')?>><?php echo _("Daily (at midnight)");?> 
     641  <option value=weekly <?php echo ($method=="weekly"?"SELECTED":'')?>><?php echo _("Weekly (on Sunday)");?> 
     642  <option value=monthly <?php echo ($method=="monthly"?"SELECTED":'')?>><?php echo _("Monthly (on the 1st)");?> 
     643  <option value=yearly <?php echo ($method=="yearly"?"SELECTED":'')?>><?php echo _("Yearly (on 1st Jan)");?> 
     644  </select> 
     645  </td></tr> 
     646<?php 
     647} 
     648function show_schedule($quickbar="no", $BackupID=""){ 
     649  if ($BackupID==""){ 
     650    $Minutes=""; 
     651    $Hours=""; 
     652    $Days=""; 
     653    $Months=""; 
     654    $Weekdays=""; 
     655    $Method="follow_schedule"; 
     656  }else{ 
     657    $backup_times=Get_Backup_Times($BackupID); 
     658    foreach ($backup_times as $bk_times)  
     659      $Minutes=$bk_times[0]?"$bk_times[0]":''; 
     660      $Hours=$bk_times[1]?"$bk_times[1]":''; 
     661      $Days=$bk_times[2]?"$bk_times[2]":''; 
     662      $Months=$bk_times[3]?"$bk_times[3]":''; 
     663      $Weekdays=$bk_times[4]?"$bk_times[4]":''; 
     664      $Method=$bk_times[5]?"$bk_times[5]":''; 
     665     
     666  } 
     667  if ($quickbar=="yes") 
     668    show_quickbar($Method); 
     669  else 
     670    echo "<tr bgcolor=#7f7f7f>"; 
     671  echo "<td><b>"._("Minutes")."</b></td> <td><b>"._("Hours")."</b></td> <td><b>"._("Days")."</b></td> <td><b>"._("Months")."</b></td><td><b>"._("Weekdays")."</b></td> </tr> <tr bgcolor=#b7b7b7>"; 
     672  echo "<td valign=top>"; 
     673  Schedule_Show_Minutes($Minutes);  
     674  echo "<td valign=top>"; 
     675  Schedule_Show_Hours($Hours); 
     676  echo "<td valign=top>"; 
     677  Schedule_Show_Days($Days);  
     678  echo "<td valign=top>"; 
     679  Schedule_Show_Months($Months); 
     680  echo "<td valign=top>"; 
     681  Schedule_Show_Weekdays($Weekdays); 
     682} 
     683 
     684 
     685?> 
  • modules/branches/2.7/backup/install.php

    r7470 r8752  
    11<?php 
    2 //This file is part of FreePBX. 
    3 // 
    4 //    FreePBX is free software: you can redistribute it and/or modify 
    5 //    it under the terms of the GNU General Public License as published by 
    6 //    the Free Software Foundation, either version 2 of the License, or 
    7 //    (at your option) any later version. 
    8 // 
    9 //    FreePBX is distributed in the hope that it will be useful, 
    10 //    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    12 //    GNU General Public License for more details. 
    13 // 
    14 //    You should have received a copy of the GNU General Public License 
    15 //    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>. 
    16 // 
    17 // Copyright (C) 2005 VerCom Systems, Inc. & Ron Hartmann (rhartmann@vercomsystems.com) 
    18 // Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) 
    19 // 
     2 
     3/* This file is part of FreePBX. 
     4 *  
     5 *     FreePBX is free software: you can redistribute it and/or modify 
     6 *     it under the terms of the GNU General Public License as published by 
     7 *     the Free Software Foundation, either version 2 of the License, or 
     8 *     (at your option) any later version. 
     9 *  
     10 *     FreePBX is distributed in the hope that it will be useful, 
     11 *     but WITHOUT ANY WARRANTY; without even the implied warranty of 
     12 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 *     GNU General Public License for more details. 
     14 *  
     15 *     You should have received a copy of the GNU General Public License 
     16 *     along with FreePBX.  If not, see <http: * www.gnu.org/licenses/>. 
     17 *  
     18 *  
     19 *  this function is in charge of looking into the database and creating crontab jobs for each of the Backup Sets 
     20 *  The crontab file is for user asterisk. 
     21 *  
     22 *  The program preserves any other cron jobs (Not part of the backup) that are installed for the user asterisk  
     23 */  
    2024 
    2125global $db; 
     
    3640$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT"; 
    3741if($amp_conf["AMPDBENGINE"] == "sqlite3")  { 
    38   $sql = " 
    39   CREATE TABLE IF NOT EXISTS Backup ( 
    40       Name varchar(50) default NULL, 
    41       Voicemail varchar(50) default NULL, 
    42       Recordings varchar(50) default NULL, 
    43       Configurations varchar(50) default NULL, 
    44       CDR varchar(55) default NULL, 
    45       FOP varchar(50) default NULL, 
    46       Minutes varchar(50) default NULL, 
    47       Hours varchar(50) default NULL, 
    48       Days varchar(50) default NULL, 
    49       Months varchar(50) default NULL, 
    50       Weekdays varchar(50) default NULL, 
    51       Command varchar(200) default NULL, 
    52       Method varchar(50) default NULL, 
    53       ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT 
     42  $sql=" 
     43  CREATE TABLE IF NOT EXISTS backup ( 
     44    name varchar(50) default NULL, 
     45    voicemail  varchar(50) default NULL, 
     46    recordings varchar(50) default NULL, 
     47    configurations  varchar(50) default NULL, 
     48    cdr varchar(55) default NULL, 
     49    fop varchar(50)  default NULL, 
     50    minutes varchar(50) default NULL, 
     51    hours varchar(50) default NULL,  
     52    days varchar(50) default NULL, 
     53    months varchar(50) default NULL, 
     54    weekdays  varchar(50) default NULL, 
     55    command varchar(200) default NULL, 
     56    method varchar(50)  default NULL, 
     57    id int(11) INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 
     58    ftpuser varchar(50), 
     59    ftppass varchar(50), 
     60    ftphost varchar(50), 
     61    ftpdir varchar(150), 
     62    sshuser varchar(50), 
     63    sshkey varchar(150), 
     64    sshhost varchar(50), 
     65    sshdir varchar(150), 
     66    emailaddr varchar(75), 
     67    emailmaxsize varchar(25), 
     68    emailmaxtype varchar(5), 
     69    admin varchar(10), 
     70    include blob, 
     71    exclude blob, 
     72    sudo varchar(25) 
    5473  ); 
    5574  "; 
    56 
    57 else  { 
    58   $sql = " 
    59   CREATE TABLE IF NOT EXISTS Backup ( 
    60       Name varchar(50) default NULL, 
    61       Voicemail varchar(50) default NULL, 
    62       Recordings varchar(50) default NULL, 
    63       Configurations varchar(50) default NULL, 
    64       CDR varchar(55) default NULL, 
    65       FOP varchar(50) default NULL, 
    66       Minutes varchar(50) default NULL, 
    67       Hours varchar(50) default NULL, 
    68       Days varchar(50) default NULL, 
    69       Months varchar(50) default NULL, 
    70       Weekdays varchar(50) default NULL, 
    71       Command varchar(200) default NULL, 
    72       Method varchar(50) default NULL, 
    73       ID int(11) NOT NULL AUTO_INCREMENT, 
    74       PRIMARY KEY  (ID) 
    75   ); 
     75}else{ 
     76  $sql=" 
     77  CREATE TABLE IF NOT EXISTS backup(  
     78    name varchar(50) default NULL, 
     79    voicemail  varchar(50) default NULL, 
     80    recordings varchar(50) default NULL, 
     81    configurations  varchar(50) default NULL, 
     82    cdr varchar(55) default NULL, 
     83    fop varchar(50)  default NULL, 
     84    minutes varchar(50) default NULL, 
     85    hours varchar(50) default NULL,  
     86    days varchar(50) default NULL, 
     87    months varchar(50) default NULL, 
     88    weekdays  varchar(50) default NULL, 
     89    command varchar(200) default NULL, 
     90    method varchar(50)  default NULL, 
     91    id int(11) NOT NULL AUTO_INCREMENT, 
     92    ftpuser varchar(50), 
     93    ftppass varchar(50), 
     94    ftphost varchar(50), 
     95    ftpdir varchar(150), 
     96    sshuser varchar(50), 
     97    sshkey varchar(150), 
     98    sshhost varchar(50), 
     99    sshdir varchar(150), 
     100    emailaddr varchar(75), 
     101    emailmaxsize varchar(25), 
     102    emailmaxtype varchar(5), 
     103    admin varchar(10), 
     104    include blob, 
     105    exclude blob, 
     106    sudo varchar(25), 
     107  PRIMARY KEY (id) ); 
    76108  "; 
    77109} 
     
    79111if(DB::IsError($check)) { 
    80112  die_freepbx("Can not create Backup table"); 
     113} 
     114 
     115$migrate=$db->getAll('show tables like "Backup"'); 
     116if(DB::IsError($check)) { 
     117  die_freepbx("Can check for Backup table"); 
     118} 
     119if(count($migrate) > 0){//migrate to new backup structure 
     120  $sql=$db->query('insert into backup (Name, Voicemail, Recordings, Configurations, CDR, FOP, Minutes, Hours, Days, Months, Weekdays, Command, Method, ID) select * from Backup;'); 
     121  if(DB::IsError($sql)) { 
     122    die_freepbx("Cannot migrate Backup table"); 
     123  } 
     124  //get data from amportal and populate the table with it 
     125  //ftp 
     126  if($amp_conf['FTPBACKUP']==strtolower('yes')){ 
     127    $data['ftpuser']=$amp_conf['FTPUSER']; 
     128    $data['ftppass']=$amp_conf['FTPPASSWORD']; 
     129    $data['ftphost']=$amp_conf['FTPSERVER']; 
     130    $data['ftpdir']=$amp_conf['FTPSUBDIR']; 
     131  } 
     132  //ssh 
     133  if(isset($amp_conf['SSHBACKUP']) && $amp_conf['SSHBACKUP']==strtolower('yes')){ 
     134    $data['sshuser']=$amp_conf['SSHUSER']; 
     135    $data['sshkey']=$amp_conf['SSHRSAKEY']; 
     136    $data['sshhost']=$amp_conf['SSHSERVER']; 
     137    $data['sshdir']=$amp_conf['SSHSUBDIR']; 
     138  } 
     139  //includes & excludes 
     140  if(isset($amp_conf['AMPPROVROOT']) && $amp_conf['AMPPROVROOT']!=''){ 
     141    $data['include']=str_replace(' ',"\n",$amp_conf['AMPPROVROOT']); 
     142    if(isset($amp_conf['AMPPROVEXCLUDELIST']) && $amp_conf['AMPPROVEXCLUDELIST']!=''){ 
     143      $data['exclude']=str_replace('',"\r",trim($opts['AMPPROVEXCLUDELIST'])); 
     144    } 
     145    if(isset($amp_conf['AMPPROVEXCLUDE']) && $amp_conf['AMPPROVEXCLUDE']!=''){ 
     146      @$data['exclude']=implode("\r",file($amp_conf['AMPPROVEXCLUDE'])); 
     147    } 
     148  } 
     149 
     150  $db_parms=$data; 
     151  $data=''; 
     152  //dont include empty values in the query 
     153  foreach(array_keys($db_parms) as $key){ 
     154    if($db_parms[$key]!=''){ 
     155      $data.=$key.'="'.$db->escapeSimple($db_parms[$key]).'",'; 
     156    } 
     157  } 
     158  $data=substr($data,0,-1);//remove trailing , 
     159  $sql='UPDATE backup set '.$data; 
     160  $check = $db->query($sql); 
     161  if(DB::IsError($check)) { 
     162    die_freepbx("Can not migrate Backup table"); 
     163  } 
    81164} 
    82165 
  • modules/branches/2.7/backup/module.xml

    r8717 r8752  
    22  <rawname>backup</rawname> 
    33  <name>Backup &amp; Restore</name> 
    4   <version>2.7.0beta1.0</version> 
     4  <version>2.7.0.1beta1.0</version> 
    55  <publisher>FreePBX</publisher> 
    66  <license>GPLv2+</license> 
     
    1515  </depends> 
    1616  <changelog> 
     17    *2.7.0.1beta1.0* #1386 
    1718    *2.7.0beta1.0* #3982, #3996, #3999 
    1819    *2.6.0.4* #3975 - multipal backup improvements 
  • modules/branches/2.7/backup/page.backup.php

    r8742 r8752  
    2121 
    2222<?php 
    23 include_once "schedule_functions.php"; 
     23 
    2424global $asterisk_conf; 
    2525$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; 
     
    148148  </form> 
    149149  <br><br><br><br><br> 
    150  
     150  <script language="javascript" type="text/javascript"> 
     151    $(document).ready(function() { 
     152      $("[name='Submit']").click(function(){ 
     153        if($("[name='name']").val().split(' ').length > 1){ 
     154          alert('<?php echo _('Backup names cannot contain spaces.'); ?>'); 
     155        return false; 
     156        } 
     157      }) 
     158    }); 
     159  </script> 
    151160<?php 
    152161} 
  • modules/branches/2.7/backup/uninstall.php

    r7470 r8752  
    2121global $db; 
    2222global $asterisk_conf; 
    23 $sql = "DELETE FROM Backup"; 
     23$sql = "DELETE FROM backup"; 
    2424$result = $db->query($sql); 
    2525if(DB::IsError($result)) { 
     
    2929//exec($Cron_Script); 
    3030backup_retrieve_backup_cron(); 
    31 sql('DROP TABLE Backup'); 
     31sql('DROP TABLE backup'); 
    3232 
    3333?>