| 71 | | |
|---|
| 72 | | if (array_search('recordings.tar.gz',$restore_files)){ |
|---|
| 73 | | echo "<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')\">"; |
|---|
| 74 | | echo _("Restore System Recordings Files"); |
|---|
| 75 | | echo "<span>"; |
|---|
| 76 | | echo _("Restore your system Voice Recordings including AutoAttendant 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"); echo "</span></a><br></li>"; |
|---|
| 77 | | echo "<br>"; |
|---|
| 78 | | } |
|---|
| 79 | | if (array_search('configurations.tar.gz',$restore_files)){ |
|---|
| 80 | | echo "<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')\">"; |
|---|
| 81 | | echo _("Restore System Configuration"); echo "<span>"; echo _("Restore your system configuration from this backup set. NOTE! This will OVERWRITE any System changes you have made since this backup... ALL items will be reset to what they were at the time of this backup set.."); echo "</span></a><br></li>"; |
|---|
| 82 | | echo "<br>"; |
|---|
| 83 | | } |
|---|
| 84 | | if (array_search('fop.tar.gz',$restore_files)){ |
|---|
| 85 | | echo "<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')\">"; |
|---|
| 86 | | echo _("Restore Operator Panel"); |
|---|
| 87 | | echo "<span>"; |
|---|
| 88 | | echo _("Restore the Operator Panel from this backup set. NOTE! This will OVERWRITE any Operator Panel Changes you have made since this backup... ALL items will be reset to what they were at the time of this backup set.."); |
|---|
| 89 | | echo "</span></a><br></li>"; |
|---|
| 90 | | echo "<br>"; |
|---|
| 91 | | } |
|---|
| 92 | | if (array_search('cdr.tar.gz',$restore_files)){ |
|---|
| 93 | | echo "<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')\">"; |
|---|
| 94 | | echo _("Restore Call Detail Report"); |
|---|
| 95 | | echo "<span>"; |
|---|
| 96 | | echo _("Restore the Call Detail Records from this backup set. NOTE! This will DELETE ALL CALL RECORDS that have been saved since this backup set.."); |
|---|
| 97 | | echo "</span></a><br></li>"; |
|---|
| 98 | | echo "<br>"; |
|---|
| 99 | | } |
|---|
| 100 | | } else { |
|---|
| 101 | | echo "<h2>"; echo _("ERROR its not a BACKUP SET file");echo "</h2>"; |
|---|
| 102 | | } |
|---|
| 103 | | } |
|---|
| 104 | | |
|---|
| 105 | | function Restore_Tar_Files($dir="", $file="",$filetype="", $display="") { |
|---|
| 106 | | global $asterisk_conf; |
|---|
| 107 | | global $amp_conf; |
|---|
| | 51 | } |
|---|
| | 52 | }elseif(substr($dir, -6)=="tar.gz" ){ |
|---|
| | 53 | $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')\">"; |
|---|
| | 54 | $html.=_("Delete File Set").'<span>'._("Delete this backup set.").'</span></a><br></li><br>'; |
|---|
| | 55 | $tar_string="tar tfz \"$dir\" | cut -d'/' -f4"; |
|---|
| | 56 | exec($tar_string,$restore_files,$error); |
|---|
| | 57 | $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')\">"; |
|---|
| | 58 | $html.=_("Restore Entire Backup Set").'<span>'; |
|---|
| | 59 | $html.=_("Restore your Complete Backup set overwriting all files.").'</span></a><br></li><br>'; |
|---|
| | 60 | if(array_search('voicemail.tar.gz',$restore_files)){ |
|---|
| | 61 | $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')\">"; |
|---|
| | 62 | $html.=_('Restore VoiceMail Files').'<span>'; |
|---|
| | 63 | $html.=_('Restore your Voicemail files from this backup set. NOTE! This will delete any voicemail currently in the voicemail boxes.'); |
|---|
| | 64 | $html.='</span></a><br></li><br>'; |
|---|
| | 65 | } |
|---|
| | 66 | if(array_search('recordings.tar.gz',$restore_files)){ |
|---|
| | 67 | $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')\">"; |
|---|
| | 68 | $html.=_('Restore System Recordings Files').'<span>'; |
|---|
| | 69 | $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>'; |
|---|
| | 70 | } |
|---|
| | 71 | if(array_search('configurations.tar.gz',$restore_files)){ |
|---|
| | 72 | $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')\">"; |
|---|
| | 73 | $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>'; |
|---|
| | 74 | } |
|---|
| | 75 | if(array_search('fop.tar.gz',$restore_files)){ |
|---|
| | 76 | $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')\">"; |
|---|
| | 77 | $html.=_("Restore Operator Panel").'<span>'; |
|---|
| | 78 | $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>'; |
|---|
| | 79 | } |
|---|
| | 80 | if(array_search('cdr.tar.gz',$restore_files)){ |
|---|
| | 81 | $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')\">"; |
|---|
| | 82 | $html.=_("Restore Call Detail Report").'<span>'; |
|---|
| | 83 | $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.."); |
|---|
| | 84 | $html.='</span></a><br></li><br>'; |
|---|
| | 85 | } |
|---|
| | 86 | }else{ |
|---|
| | 87 | $html.='<h2>'._("ERROR its not a BACKUP SET file").'</h2>'; |
|---|
| | 88 | } |
|---|
| | 89 | echo $html; |
|---|
| | 90 | } |
|---|
| | 91 | |
|---|
| | 92 | function backup_restore_tar($dir="", $file="",$filetype="", $display="") { |
|---|
| | 93 | global $asterisk_conf,$amp_conf; |
|---|
| 110 | | if($amp_conf['AMPBACKUPSUDO']==true){$sudo='/usr/bin/sudo';} |
|---|
| 111 | | if($filetype=="ALL") { |
|---|
| 112 | | |
|---|
| 113 | | $fileholder=substr($file, 0,-7); |
|---|
| 114 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 115 | | $error = ($error || ($ret != 0)); |
|---|
| 116 | | |
|---|
| 117 | | // First restore voicemial (for some reason if you do it all at once these don't get restored |
|---|
| 118 | | // |
|---|
| 119 | | exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail 2>&1',$out_arr,$ret); |
|---|
| 120 | | $error = ($error || ($ret != 0)); |
|---|
| 121 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | $tar -Pxvz"; |
|---|
| 122 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 123 | | $error = ($error || ($ret != 0)); |
|---|
| 124 | | |
|---|
| 125 | | // Next, recordings cause same issue as above |
|---|
| 126 | | // |
|---|
| 127 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | $tar -Pxvz"; |
|---|
| 128 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 129 | | $error = ($error || ($ret != 0)); |
|---|
| 130 | | |
|---|
| 131 | | // Now the rest and then we'll get on with the databases |
|---|
| 132 | | // |
|---|
| 133 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | $tar -Pxvz"; |
|---|
| 134 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 135 | | $error = ($error || ($ret != 0)); |
|---|
| 136 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz /tmp/ampbackups.$fileholder/cdr.tar.gz | $tar -Pxvz"; |
|---|
| 137 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 138 | | $error = ($error || ($ret != 0)); |
|---|
| 139 | | $tar_cmd="$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/asteriskcdr.sql /tmp/ampbackups.$fileholder/astdb.dump"; |
|---|
| 140 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 141 | | $error = ($error || ($ret != 0)); |
|---|
| 142 | | |
|---|
| 143 | | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql 2>&1"; |
|---|
| 144 | | exec($sql_cmd,$out_arr,$ret); |
|---|
| 145 | | $error = ($error || ($ret != 0)); |
|---|
| 146 | | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql 2>&1"; |
|---|
| 147 | | exec($sql_cmd,$out_arr,$ret); |
|---|
| 148 | | $error = ($error || ($ret != 0)); |
|---|
| 149 | | exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder 2>&1",$out_arr,$ret); |
|---|
| 150 | | $error = ($error || ($ret != 0)); |
|---|
| 151 | | |
|---|
| 152 | | //restore additional file (aka AMPPROVROOT), using sudo if requested |
|---|
| 153 | | $tar_cmd="$sudo $tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/phoneconfig.tar.gz |$sudo $tar -Pxvz"; |
|---|
| 154 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 155 | | $error = ($error || ($ret != 0)); |
|---|
| 156 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder",$out_arr,$ret); |
|---|
| 157 | | $error = ($error || ($ret != 0)); |
|---|
| 158 | | |
|---|
| 159 | | if (!error) { |
|---|
| 160 | | $Message=_("Restored All Files in Backup Set"); |
|---|
| 161 | | } |
|---|
| 162 | | |
|---|
| 163 | | } else if($filetype=="VoiceMail") { |
|---|
| 164 | | |
|---|
| 165 | | $fileholder=substr($file, 0,-7); |
|---|
| 166 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 167 | | $error = ($error || ($ret != 0)); |
|---|
| 168 | | exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail 2>&1',$out_arr,$ret); |
|---|
| 169 | | $error = ($error || ($ret != 0)); |
|---|
| 170 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | $tar -Pxvz"; |
|---|
| 171 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 172 | | $error = ($error || ($ret != 0)); |
|---|
| 173 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 174 | | $error = ($error || ($ret != 0)); |
|---|
| 175 | | |
|---|
| 176 | | if (!error) { |
|---|
| 177 | | $Message=_("Restored VoiceMail"); |
|---|
| 178 | | } |
|---|
| 179 | | |
|---|
| 180 | | } else if($filetype=="Recordings") { |
|---|
| 181 | | |
|---|
| 182 | | $fileholder=substr($file, 0,-7); |
|---|
| 183 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 184 | | $error = ($error || ($ret != 0)); |
|---|
| 185 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | $tar -Pxvz"; |
|---|
| 186 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 187 | | $error = ($error || ($ret != 0)); |
|---|
| 188 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 189 | | $error = ($error || ($ret != 0)); |
|---|
| 190 | | |
|---|
| 191 | | if (!error) { |
|---|
| 192 | | $Message=_("Restored System Recordings"); |
|---|
| 193 | | } |
|---|
| 194 | | |
|---|
| 195 | | } else if($filetype=="Configurations"){ |
|---|
| 196 | | |
|---|
| 197 | | $fileholder=substr($file, 0,-7); |
|---|
| 198 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 199 | | $error = ($error || ($ret != 0)); |
|---|
| 200 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | $tar -Pxvz"; |
|---|
| 201 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 202 | | $error = ($error || ($ret != 0)); |
|---|
| 203 | | $tar_cmd="$$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/astdb.dump"; |
|---|
| 204 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 205 | | $error = ($error || ($ret != 0)); |
|---|
| 206 | | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql"; |
|---|
| 207 | | exec($sql_cmd,$out_arr,$ret); |
|---|
| 208 | | $error = ($error || ($ret != 0)); |
|---|
| 209 | | exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder 2>&1",$out_arr,$ret); |
|---|
| 210 | | $error = ($error || ($ret != 0)); |
|---|
| 211 | | //restore additional file (aka AMPPROVROOT), using sudo if requested |
|---|
| 212 | | $tar_cmd="$sudo $tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/phoneconfig.tar.gz |$sudo $tar -Pxvz"; |
|---|
| 213 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 214 | | |
|---|
| 215 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 216 | | $error = ($error || ($ret != 0)); |
|---|
| 217 | | |
|---|
| 218 | | if (!error) { |
|---|
| 219 | | $Message=_("Restored System Configuration"); |
|---|
| 220 | | } |
|---|
| 221 | | |
|---|
| 222 | | } else if($filetype=="FOP"){ |
|---|
| 223 | | |
|---|
| 224 | | $fileholder=substr($file, 0,-7); |
|---|
| 225 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 226 | | $error = ($error || ($ret != 0)); |
|---|
| 227 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz | $tar -Pxvz"; |
|---|
| 228 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 229 | | $error = ($error || ($ret != 0)); |
|---|
| 230 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 231 | | $error = ($error || ($ret != 0)); |
|---|
| 232 | | |
|---|
| 233 | | if (!error) { |
|---|
| 234 | | $Message=_("Restored Operator Panel"); |
|---|
| 235 | | } |
|---|
| 236 | | |
|---|
| 237 | | } else if($filetype=="CDR"){ |
|---|
| 238 | | |
|---|
| 239 | | $fileholder=substr($file, 0,-7); |
|---|
| 240 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 241 | | $error = ($error || ($ret != 0)); |
|---|
| 242 | | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/cdr.tar.gz | $tar -Pxvz"; |
|---|
| 243 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 244 | | $error = ($error || ($ret != 0)); |
|---|
| 245 | | $tar_cmd="$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asteriskcdr.sql"; |
|---|
| 246 | | exec($tar_cmd,$out_arr,$ret); |
|---|
| 247 | | $error = ($error || ($ret != 0)); |
|---|
| 248 | | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql 2>&1"; |
|---|
| 249 | | exec($sql_cmd,$out_arr,$ret); |
|---|
| 250 | | $error = ($error || ($ret != 0)); |
|---|
| 251 | | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| 252 | | $error = ($error || ($ret != 0)); |
|---|
| 253 | | |
|---|
| 254 | | if (!error) { |
|---|
| 255 | | $Message=_("Restored CDR logs"); |
|---|
| 256 | | } |
|---|
| 257 | | |
|---|
| 258 | | } |
|---|
| 259 | | if (! $error) { |
|---|
| 260 | | $Message=_("Restore Failed, see System Status Notification for details"); |
|---|
| 261 | | return ($Message); |
|---|
| 262 | | } else { |
|---|
| 263 | | // TODO: put in notification error and add code above to collect details |
|---|
| 264 | | // along the way to put something meaningful in it |
|---|
| 265 | | // |
|---|
| 266 | | return ($Message); |
|---|
| 267 | | } |
|---|
| 268 | | } |
|---|
| 269 | | function Get_Backup_Sets() { |
|---|
| 270 | | global $db; |
|---|
| 271 | | $sql = "SELECT * FROM Backup"; |
|---|
| 272 | | $results = $db->getAll($sql); |
|---|
| 273 | | if(DB::IsError($results)) { |
|---|
| 274 | | $results = null; |
|---|
| 275 | | } |
|---|
| 276 | | return $results; |
|---|
| 277 | | } |
|---|
| 278 | | function Delete_Backup_Set($ID="") { |
|---|
| 279 | | global $db; |
|---|
| 280 | | global $asterisk_conf; |
|---|
| 281 | | global $amp_conf; |
|---|
| 282 | | $sql = "DELETE FROM Backup WHERE ID = '$ID'"; |
|---|
| 283 | | $result = $db->query($sql); |
|---|
| 284 | | if(DB::IsError($result)) { |
|---|
| 285 | | die_freepbx($result->getMessage()); |
|---|
| 286 | | } |
|---|
| 287 | | //$Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron.php"; |
|---|
| 288 | | //exec($Cron_Script); |
|---|
| 289 | | //TODO: should we check and act on false return |
|---|
| | 96 | if($amp_conf['AMPBACKUPSUDO']==true){$sudo='/usr/bin/sudo';}else{$sudo='';}//use sudo if requested - DANGEROUS!!! |
|---|
| | 97 | switch($filetype){ |
|---|
| | 98 | case 'ALL': |
|---|
| | 99 | $fileholder=substr($file, 0,-7); |
|---|
| | 100 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 101 | $error = ($error || ($ret != 0)); |
|---|
| | 102 | |
|---|
| | 103 | // First restore voicemial (for some reason if you do it all at once these don't get restored |
|---|
| | 104 | exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail 2>&1',$out_arr,$ret); |
|---|
| | 105 | $error = ($error || ($ret != 0)); |
|---|
| | 106 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | $tar -Pxvz"; |
|---|
| | 107 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 108 | $error = ($error || ($ret != 0)); |
|---|
| | 109 | |
|---|
| | 110 | // Next, recordings cause same issue as above |
|---|
| | 111 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | $tar -Pxvz"; |
|---|
| | 112 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 113 | $error = ($error || ($ret != 0)); |
|---|
| | 114 | |
|---|
| | 115 | // Now the rest and then we'll get on with the databases |
|---|
| | 116 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | $tar -Pxvz"; |
|---|
| | 117 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 118 | $error = ($error || ($ret != 0)); |
|---|
| | 119 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz /tmp/ampbackups.$fileholder/cdr.tar.gz | $tar -Pxvz"; |
|---|
| | 120 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 121 | $error = ($error || ($ret != 0)); |
|---|
| | 122 | $tar_cmd="$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/asteriskcdr.sql /tmp/ampbackups.$fileholder/astdb.dump"; |
|---|
| | 123 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 124 | $error = ($error || ($ret != 0)); |
|---|
| | 125 | |
|---|
| | 126 | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql 2>&1"; |
|---|
| | 127 | exec($sql_cmd,$out_arr,$ret); |
|---|
| | 128 | $error = ($error || ($ret != 0)); |
|---|
| | 129 | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql 2>&1"; |
|---|
| | 130 | exec($sql_cmd,$out_arr,$ret); |
|---|
| | 131 | $error = ($error || ($ret != 0)); |
|---|
| | 132 | exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder 2>&1",$out_arr,$ret); |
|---|
| | 133 | $error = ($error || ($ret != 0)); |
|---|
| | 134 | |
|---|
| | 135 | //restore additional file (aka AMPPROVROOT), using sudo if requested |
|---|
| | 136 | $tar_cmd="$sudo $tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/phoneconfig.tar.gz |$sudo $tar -Pxvz"; |
|---|
| | 137 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 138 | $error = ($error || ($ret != 0)); |
|---|
| | 139 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder",$out_arr,$ret); |
|---|
| | 140 | $error = ($error || ($ret != 0)); |
|---|
| | 141 | if(!error){$message=_("Restored All Files in BackupSet");} |
|---|
| | 142 | break; |
|---|
| | 143 | case 'VoiceMail': |
|---|
| | 144 | $fileholder=substr($file, 0,-7); |
|---|
| | 145 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 146 | $error = ($error || ($ret != 0)); |
|---|
| | 147 | exec('/bin/rm -rf '.$amp_conf['ASTSPOOLDIR'].'/voicemail 2>&1',$out_arr,$ret); |
|---|
| | 148 | $error = ($error || ($ret != 0)); |
|---|
| | 149 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/voicemail.tar.gz | $tar -Pxvz"; |
|---|
| | 150 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 151 | $error = ($error || ($ret != 0)); |
|---|
| | 152 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 153 | $error = ($error || ($ret != 0)); |
|---|
| | 154 | if(!error){$message=_("Restored VoiceMail");} |
|---|
| | 155 | break; |
|---|
| | 156 | case 'Recordings': |
|---|
| | 157 | $fileholder=substr($file, 0,-7); |
|---|
| | 158 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 159 | $error = ($error || ($ret != 0)); |
|---|
| | 160 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/recordings.tar.gz | $tar -Pxvz"; |
|---|
| | 161 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 162 | $error = ($error || ($ret != 0)); |
|---|
| | 163 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 164 | $error = ($error || ($ret != 0)); |
|---|
| | 165 | if(!error){$message=_("Restored System Recordings");} |
|---|
| | 166 | break; |
|---|
| | 167 | case 'Configurations': |
|---|
| | 168 | $fileholder=substr($file, 0,-7); |
|---|
| | 169 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 170 | $error = ($error || ($ret != 0)); |
|---|
| | 171 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/configurations.tar.gz | $tar -Pxvz"; |
|---|
| | 172 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 173 | $error = ($error || ($ret != 0)); |
|---|
| | 174 | $tar_cmd="$$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asterisk.sql /tmp/ampbackups.$fileholder/astdb.dump"; |
|---|
| | 175 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 176 | $error = ($error || ($ret != 0)); |
|---|
| | 177 | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asterisk.sql"; |
|---|
| | 178 | exec($sql_cmd,$out_arr,$ret); |
|---|
| | 179 | $error = ($error || ($ret != 0)); |
|---|
| | 180 | exec($amp_conf['AMPBIN']."/restoreastdb.php $fileholder 2>&1",$out_arr,$ret); |
|---|
| | 181 | $error = ($error || ($ret != 0)); |
|---|
| | 182 | //restore additional file (aka AMPPROVROOT), using sudo if requested |
|---|
| | 183 | $tar_cmd="$sudo $tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/phoneconfig.tar.gz |$sudo $tar -Pxvz"; |
|---|
| | 184 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 185 | |
|---|
| | 186 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 187 | $error = ($error || ($ret != 0)); |
|---|
| | 188 | if(!error){$message=_("Restored System Configuration");} |
|---|
| | 189 | break; |
|---|
| | 190 | case 'FOP': |
|---|
| | 191 | $fileholder=substr($file, 0,-7); |
|---|
| | 192 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 193 | $error = ($error || ($ret != 0)); |
|---|
| | 194 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/fop.tar.gz | $tar -Pxvz"; |
|---|
| | 195 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 196 | $error = ($error || ($ret != 0)); |
|---|
| | 197 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 198 | $error = ($error || ($ret != 0)); |
|---|
| | 199 | if(!error){$message=_("Restored Operator Panel");} |
|---|
| | 200 | break; |
|---|
| | 201 | case 'CDR': |
|---|
| | 202 | $fileholder=substr($file, 0,-7); |
|---|
| | 203 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 204 | $error = ($error || ($ret != 0)); |
|---|
| | 205 | $tar_cmd="$tar -PxvOz -f \"$dir\" /tmp/ampbackups.$fileholder/cdr.tar.gz | $tar -Pxvz"; |
|---|
| | 206 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 207 | $error = ($error || ($ret != 0)); |
|---|
| | 208 | $tar_cmd="$tar -Pxvz -f \"$dir\" /tmp/ampbackups.$fileholder/asteriskcdr.sql"; |
|---|
| | 209 | exec($tar_cmd,$out_arr,$ret); |
|---|
| | 210 | $error = ($error || ($ret != 0)); |
|---|
| | 211 | $sql_cmd="mysql -u ".$amp_conf['AMPDBUSER']." -p".$amp_conf['AMPDBPASS']." < /tmp/ampbackups.$fileholder/asteriskcdr.sql 2>&1"; |
|---|
| | 212 | exec($sql_cmd,$out_arr,$ret); |
|---|
| | 213 | $error = ($error || ($ret != 0)); |
|---|
| | 214 | exec("/bin/rm -rf /tmp/ampbackups.$fileholder 2>&1",$out_arr,$ret); |
|---|
| | 215 | $error = ($error || ($ret != 0)); |
|---|
| | 216 | if(!error){$message=_("Restored CDR logs");} |
|---|
| | 217 | break; |
|---|
| | 218 | } |
|---|
| | 219 | return ($error)?$message:_('Restore Failed, see System Status Notification for details'); |
|---|
| | 220 | } |
|---|
| | 221 | |
|---|
| | 222 | function backup_get(){ |
|---|
| | 223 | global $db; |
|---|
| | 224 | $sql = "SELECT * FROM backup ORDER BY name ASC"; |
|---|
| | 225 | $results = $db->getAll($sql); |
|---|
| | 226 | if(DB::IsError($results)) { |
|---|
| | 227 | $results = null; |
|---|
| | 228 | } |
|---|
| | 229 | return $results; |
|---|
| | 230 | } |
|---|
| | 231 | |
|---|
| | 232 | function backup_delete_set($id=''){ |
|---|
| | 233 | global $db,$asterisk_conf,$amp_conf; |
|---|
| | 234 | $sql = "DELETE FROM backup WHERE id =?"; |
|---|
| | 235 | $result = $db->query($sql,array($id)); |
|---|
| | 236 | if(DB::IsError($result)) { |
|---|
| | 237 | die_freepbx($result->getMessage()); |
|---|
| | 238 | } |
|---|
| 292 | | function Save_Backup_Schedule($Backup_Parms, $backup_options ) |
|---|
| 293 | | { |
|---|
| 294 | | global $db; |
|---|
| 295 | | global $asterisk_conf; |
|---|
| 296 | | global $amp_conf; |
|---|
| 297 | | if ($Backup_Parms[1]=="now") |
|---|
| 298 | | { |
|---|
| 299 | | $Cron_Script=$asterisk_conf['astvarlibdir']."/bin/ampbackup.php '$Backup_Parms[0]' $backup_options[0] $backup_options[1] $backup_options[2] $backup_options[3] $backup_options[4]"; |
|---|
| 300 | | //echo "$Cron_Script"; |
|---|
| 301 | | /* |
|---|
| 302 | | * ***** Next few lines would execute the script nativly, but will show the shebang in the web page ***** |
|---|
| 303 | | * |
|---|
| 304 | | * $argv=array('', $Backup_Parms[0], $backup_options[0], $backup_options[1], $backup_options[2], $backup_options[3], $backup_options[4]); |
|---|
| 305 | | * $argc=count($argv); |
|---|
| 306 | | * include($asterisk_conf['astvarlibdir'].'/bin/ampbackup.php') |
|---|
| 307 | | */ |
|---|
| 308 | | exec($Cron_Script); |
|---|
| 309 | | } |
|---|
| 310 | | $sql = "INSERT INTO Backup (Name, Voicemail, Recordings, Configurations, CDR, FOP, Minutes, Hours, Days, Months,Weekdays, Command, Method ) VALUES ("; |
|---|
| 311 | | $sql .= "'".$Backup_Parms[0]."',"; |
|---|
| 312 | | $sql .= "'".$backup_options[0]."',"; |
|---|
| 313 | | $sql .= "'".$backup_options[1]."',"; |
|---|
| 314 | | $sql .= "'".$backup_options[2]."',"; |
|---|
| 315 | | $sql .= "'".$backup_options[3]."',"; |
|---|
| 316 | | $sql .= "'".$backup_options[4]."',"; |
|---|
| 317 | | $sql .= "'".$Backup_Parms[2]."',"; |
|---|
| 318 | | $sql .= "'".$Backup_Parms[3]."',"; |
|---|
| 319 | | $sql .= "'".$Backup_Parms[4]."',"; |
|---|
| 320 | | $sql .= "'".$Backup_Parms[5]."',"; |
|---|
| 321 | | $sql .= "'".$Backup_Parms[6]."',"; |
|---|
| 322 | | $sql .= "'".$Backup_Parms[7]."',"; |
|---|
| 323 | | $sql .= "'".$Backup_Parms[1]."');"; |
|---|
| 324 | | $result = $db->query($sql); |
|---|
| 325 | | if(DB::IsError($result)) { |
|---|
| 326 | | die_freepbx($result->getMessage().'<hr>'.$sql); |
|---|
| 327 | | } |
|---|
| 328 | | //$Cron_Script=$asterisk_conf['astvarlibdir']."/bin/retrieve_backup_cron.php"; |
|---|
| 329 | | //exec($Cron_Script); |
|---|
| | 241 | |
|---|
| | 242 | function backup_save_schedule($parms){ |
|---|
| | 243 | global $db,$asterisk_conf,$amp_conf; |
|---|
| | 244 | //build query based on the following keys |
|---|
| | 245 | $parms_num=array('admin','cdr','command','configurations','days','emailaddr', |
|---|
| | 246 | 'emailmaxsize','emailmaxtype','exclude','fop','ftpdir','ftphost', |
|---|
| | 247 | 'ftppass','ftpuser','hours','id','include','method','minutes', |
|---|
| | 248 | 'months','name','recordings','sshdir','sshhost','sshkey','sshuser', |
|---|
| | 249 | 'sudo','voicemail','weekdays'); |
|---|
| | 250 | foreach($parms_num as $dprm){$db_parms[$dprm]=isset($parms[$dprm])?$parms[$dprm]:'';} |
|---|
| | 251 | $keys=$vals=''; |
|---|
| | 252 | //dont include empty values in the query |
|---|
| | 253 | foreach(array_keys($db_parms) as $key){ |
|---|
| | 254 | if($db_parms[$key]!=''){ |
|---|
| | 255 | $keys.=$key.','; |
|---|
| | 256 | } |
|---|
| | 257 | } |
|---|
| | 258 | foreach(array_values($db_parms) as $val){ |
|---|
| | 259 | if($val!=''){ |
|---|
| | 260 | $vals.='"'.$db->escapeSimple($val).'",'; |
|---|
| | 261 | } |
|---|
| | 262 | } |
|---|
| | 263 | $keys=substr($keys,0,-1);$vals=substr($vals,0,-1); |
|---|
| | 264 | $sql='INSERT INTO backup ('.$keys.') VALUES ('.$vals.')'; |
|---|
| | 265 | $result = $db->query($sql); |
|---|
| | 266 | if(DB::IsError($result)) { |
|---|
| | 267 | die_freepbx($result->getMessage().'<hr>'.$sql); |
|---|
| | 268 | } |
|---|
| | 269 | if($parms['method']=='now' && $result){ |
|---|
| | 270 | $latest=$db->getOne('select last_insert_id()'); |
|---|
| | 271 | $backup_script=$asterisk_conf['astvarlibdir'].'/bin/ampbackup.php '.$latest; |
|---|
| | 272 | exec($backup_script); |
|---|
| | 273 | } |
|---|
| 335 | | if ($backup_schedule=="hourly") |
|---|
| 336 | | $Cron_String="0 * * * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"; |
|---|
| 337 | | else if ($backup_schedule=="daily") |
|---|
| 338 | | $Cron_String="0 0 * * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"; |
|---|
| 339 | | else if ($backup_schedule=="weekly") |
|---|
| 340 | | $Cron_String="0 0 * * 0 ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"; |
|---|
| 341 | | else if ($backup_schedule=="monthly") |
|---|
| 342 | | $Cron_String="0 0 1 * * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"; |
|---|
| 343 | | else if ($backup_schedule=="yearly") |
|---|
| 344 | | $Cron_String="0 0 1 1 * ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"; |
|---|
| 345 | | else if ($backup_schedule=="follow_schedule") |
|---|
| 346 | | { |
|---|
| 347 | | $mins_string=''; |
|---|
| 348 | | $hours_string=''; |
|---|
| 349 | | if (count($mins)<1) |
|---|
| 350 | | $mins_string=":0:"; |
|---|
| 351 | | else{ |
|---|
| 352 | | foreach ($mins as $value) |
|---|
| 353 | | $mins_string.=":$value:"; |
|---|
| 354 | | } |
|---|
| 355 | | if (count($hours)<1) |
|---|
| 356 | | $hours_string=":0:"; |
|---|
| 357 | | else{ |
|---|
| 358 | | foreach ($hours as $value) |
|---|
| 359 | | $hours_string.=":$value:"; |
|---|
| 360 | | } |
|---|
| 361 | | if(($ALL_days=="1")||(count($days)<1)) |
|---|
| 362 | | $days_string="*"; |
|---|
| 363 | | else{ |
|---|
| 364 | | foreach ($days as $value) |
|---|
| 365 | | $days_string.=":$value:"; |
|---|
| 366 | | } |
|---|
| 367 | | if(($ALL_months=="1")||(count($months)<1)) |
|---|
| 368 | | $months_string="*"; |
|---|
| 369 | | else{ |
|---|
| 370 | | foreach ($months as $value) |
|---|
| 371 | | $months_string.=":$value:"; |
|---|
| 372 | | } |
|---|
| 373 | | if($ALL_weekdays=="1"||(count($weekdays)<1)) |
|---|
| 374 | | $weekdays_string="*"; |
|---|
| 375 | | else{ |
|---|
| 376 | | foreach ($weekdays as $value) |
|---|
| 377 | | $weekdays_string.=":$value:"; |
|---|
| 378 | | } |
|---|
| 379 | | $cron_mins_string=trim($mins_string,":"); |
|---|
| 380 | | $cron_hours_string=trim($hours_string,":"); |
|---|
| 381 | | $cron_days_string=trim($days_string,":"); |
|---|
| 382 | | $cron_months_string=trim($months_string,":"); |
|---|
| 383 | | $cron_weekdays_string=trim($weekdays_string,":"); |
|---|
| 384 | | $Cron_String=str_replace("::", ",", "$cron_mins_string $cron_hours_string $cron_days_string $cron_months_string $cron_weekdays_string ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"); |
|---|
| 385 | | } |
|---|
| 386 | | else if ($backup_schedule=="now") |
|---|
| 387 | | $Cron_String="0 0 0 0 0 ".$asterisk_conf['astvarlibdir']."/bin/ampbackup.php"; |
|---|
| 388 | | $Backup_String[]=$name; |
|---|
| 389 | | $Backup_String[]=$backup_schedule; |
|---|
| 390 | | $Backup_String[]=isset($mins_string)?$mins_string:''; |
|---|
| 391 | | $Backup_String[]=isset($hours_string)?$hours_string:''; |
|---|
| 392 | | $Backup_String[]=isset($days_string)?$days_string:''; |
|---|
| 393 | | $Backup_String[]=isset($months_string)?$months_string:''; |
|---|
| 394 | | $Backup_String[]=isset($weekdays_string)?$weekdays_string:''; |
|---|
| 395 | | $Backup_String[]=$Cron_String; |
|---|
| 396 | | |
|---|
| 397 | | return ($Backup_String); |
|---|
| 398 | | } |
|---|
| 399 | | function Get_Backup_Times($BackupID) |
|---|
| 400 | | { |
|---|
| 401 | | global $db; |
|---|
| 402 | | $sql = "SELECT Minutes, Hours, Days, Months, Weekdays, Method From Backup where ID=\"$BackupID\""; |
|---|
| 403 | | $results = $db->getAll($sql); |
|---|
| 404 | | if(DB::IsError($results)) { |
|---|
| 405 | | $results = Array(null, null, null, null, null, null); |
|---|
| 406 | | } |
|---|
| 407 | | return $results; |
|---|
| 408 | | } |
|---|
| 409 | | function Get_Backup_Options($BackupID) |
|---|
| 410 | | { |
|---|
| 411 | | global $db; |
|---|
| 412 | | $sql = "SELECT Name, Voicemail, Recordings, Configurations, CDR, FOP FROM Backup where ID=\"$BackupID\""; |
|---|
| 413 | | $results = $db->getAll($sql); |
|---|
| 414 | | if(DB::IsError($results)) { |
|---|
| 415 | | $results = Array(null, null, null, null, null, null); |
|---|
| 416 | | } |
|---|
| 417 | | return $results; |
|---|
| 418 | | } |
|---|
| 419 | | function Show_Backup_Options($ID="") |
|---|
| 420 | | { |
|---|
| | 279 | switch($parms['backup_schedule']){ |
|---|
| | 280 | case 'hourly': |
|---|
| | 281 | $cron_string='0 * * * * '; |
|---|
| | 282 | break; |
|---|
| | 283 | case 'daily': |
|---|
| | 284 | $cron_string='0 0 * * * '; |
|---|
| | 285 | break; |
|---|
| | 286 | case 'weekly': |
|---|
| | 287 | $cron_string='0 0 * * 0 '; |
|---|
| | 288 | break; |
|---|
| | 289 | case 'monthly': |
|---|
| | 290 | $cron_string='0 0 1 * * '; |
|---|
| | 291 | break; |
|---|
| | 292 | case 'yearly': |
|---|
| | 293 | $cron_string='0 0 1 1 * '; |
|---|
| | 294 | break; |
|---|
| | 295 | case 'now': |
|---|
| | 296 | $cron_string='0 0 0 0 0 '; |
|---|
| | 297 | break; |
|---|
| | 298 | case 'follow_schedule': |
|---|
| | 299 | $mins_string=$hours_string=$days_string=$months_string=$weekdays_string=''; |
|---|
| | 300 | if(is_array($parms['mins'])){ |
|---|
| | 301 | foreach($parms['mins'] as $value){ |
|---|
| | 302 | $mins_string.=":$value:"; |
|---|
| | 303 | } |
|---|
| | 304 | }else{ |
|---|
| | 305 | $mins_string=":0:"; |
|---|
| | 306 | } |
|---|
| | 307 | if(is_array($parms['hours'])){ |
|---|
| | 308 | foreach($parms['hours'] as $value){ |
|---|
| | 309 | $hours_string.=":$value:"; |
|---|
| | 310 | } |
|---|
| | 311 | }else{ |
|---|
| | 312 | $hours_string=":0:"; |
|---|
| | 313 | } |
|---|
| | 314 | if(isset($parms['all_days']) && $parms['all_days']=='0'){ |
|---|
| | 315 | foreach($parms['days'] as $value){ |
|---|
| | 316 | $days_string.=":$value:"; |
|---|
| | 317 | } |
|---|
| | 318 | }else{ |
|---|
| | 319 | $days_string="*"; |
|---|
| | 320 | } |
|---|
| | 321 | if(isset($parms['all_months']) && $parms['all_months']=='0'){ |
|---|
| | 322 | foreach($parms['months'] as $value){ |
|---|
| | 323 | $months_string.=":$value:"; |
|---|
| | 324 | } |
|---|
| | 325 | }else{ |
|---|
| | 326 | $months_string="*"; |
|---|
| | 327 | } |
|---|
| | 328 | if(isset($parms['all_weekdays']) && $parms['all_weekdays']=='0'){ |
|---|
| | 329 | foreach($parms['weekdays'] as $value){ |
|---|
| | 330 | $weekdays_string.=":$value:"; |
|---|
| | 331 | } |
|---|
| | 332 | }else{ |
|---|
| | 333 | $weekdays_string="*"; |
|---|
| | 334 | } |
|---|
| | 335 | $cron_mins_string=trim($mins_string,":"); |
|---|
| | 336 | $cron_hours_string=trim($hours_string,":"); |
|---|
| | 337 | $cron_days_string=trim($days_string,":"); |
|---|
| | 338 | $cron_months_string=trim($months_string,":"); |
|---|
| | 339 | $cron_weekdays_string=trim($weekdays_string,":"); |
|---|
| | 340 | $cron_string=str_replace("::", ",", "$cron_mins_string $cron_hours_string $cron_days_string $cron_months_string $cron_weekdays_string"); |
|---|
| | 341 | break; |
|---|
| | 342 | } |
|---|
| | 343 | $backup_string['name']=$parms['name']; |
|---|
| | 344 | $backup_string['method']=$parms['backup_schedule']; |
|---|
| | 345 | $backup_string['minutes']=isset($mins_string)?$mins_string:''; |
|---|
| | 346 | $backup_string['hours']=isset($hours_string)?$hours_string:''; |
|---|
| | 347 | $backup_string['days']=isset($days_string)?$days_string:''; |
|---|
| | 348 | $backup_string['months']=isset($months_string)?$months_string:''; |
|---|
| | 349 | $backup_string['weekdays']=isset($weekdays_string)?$weekdays_string:''; |
|---|
| | 350 | $backup_string['command']=$cron_string.' '.$asterisk_conf['astvarlibdir'].'/bin/ampbackup.php'; |
|---|
| | 351 | $ret=array_merge($parms,$backup_string); |
|---|
| | 352 | return ($ret); |
|---|
| | 353 | } |
|---|
| | 354 | function Get_Backup_Times($id){ |
|---|
| | 355 | global $db; |
|---|
| | 356 | $sql = "SELECT minutes, hours, days, months, weekdays, method From backup where id=?"; |
|---|
| | 357 | $results = $db->getAll($sql,array($id)); |
|---|
| | 358 | if(DB::IsError($results)) { |
|---|
| | 359 | $results = Array(null, null, null, null, null, null); |
|---|
| | 360 | } |
|---|
| | 361 | return $results; |
|---|
| | 362 | } |
|---|
| | 363 | function Get_Backup_Options($id){ |
|---|
| | 364 | global $db; |
|---|
| | 365 | $sql = "SELECT * FROM backup WHERE id=?"; |
|---|
| | 366 | $results = $db->getAll($sql,array($id),DB_FETCHMODE_ASSOC); |
|---|
| | 367 | if(DB::IsError($results)) { |
|---|
| | 368 | $results = Array(null, null, null, null, null, null); |
|---|
| | 369 | } |
|---|
| | 370 | return $results[0]; |
|---|
| | 371 | } |
|---|
| | 372 | function backup_showopts($id=''){ |
|---|