コード例 #1
0
ファイル: backup.php プロジェクト: homer6/concrete5-mirror
 public function restore_backup()
 {
     $tp = new TaskPermission();
     if (!$tp->canBackup()) {
         return false;
     }
     $file = $this->post('backup_file');
     $db = Loader::db();
     chmod(DIR_FILES_BACKUPS . '/' . $file, 0666);
     $str_restSql = file_get_contents(DIR_FILES_BACKUPS . '/' . $file);
     if (!$str_restSql) {
         $this->set("error", array("There was an error trying to restore the database. This file was empty."));
         $this->view();
         return false;
     }
     $crypt = Loader::helper('encryption');
     if (!preg_match('/INSERT/m', $str_restSql) && !preg_match('/CREATE/m', $str_restSql)) {
         $str_restSql = $crypt->decrypt($str_restSql);
     }
     $arr_sqlStmts = explode("\n\n", $str_restSql);
     foreach ($arr_sqlStmts as $str_stmt) {
         if (trim($str_stmt) != "") {
             $res_restoration = $db->execute($str_stmt);
             if (!$res_restoration) {
                 $this->set("error", array("There was an error trying to restore the database. In query {$str_stmt}"));
                 return;
             }
         }
     }
     $this->set("message", "Restoration Sucessful");
     //reset perms for security!
     chmod(DIR_FILES_BACKUPS . '/' . $file, 00);
     Cache::flush();
     $this->view();
 }
コード例 #2
0
ファイル: backup.php プロジェクト: r-bansal/janeswalk-web-1
 public function view()
 {
     $tp = new TaskPermission();
     if ($tp->canBackup()) {
         $fh = Loader::helper('file');
         $arr_bckups = @$fh->getDirectoryContents(DIR_FILES_BACKUPS);
         $arr_backupfileinfo = array();
         if (count($arr_bckups) > 0) {
             foreach ($arr_bckups as $bkupfile) {
                 // This will ignore files that do not match the created backup pattern of including a timestamp in the filename
                 if (preg_match("/_([\\d]{10,})/", $bkupfile, $timestamp)) {
                     $arr_backupfileinfo[] = array("file" => $bkupfile, "date" => date("Y-m-d H:i:s", $timestamp[1]));
                 }
             }
             // The whole reason this file's overriden - sort these backups chronologically
             uasort($arr_backupfileinfo, function ($a, $b) {
                 return strcmp($b['date'], $a['date']);
             });
             $this->set('backups', $arr_backupfileinfo);
         }
     }
 }
コード例 #3
0
ファイル: backup.php プロジェクト: VonUniGE/concrete5-1
$(document).ready( function() { 
   $('a.dialog-launch').click( function() {
      $.fn.dialog.open({ href: $(this).attr('href'),modal:false });

      return false;
      
   });
});

</script>

<div style="width: 760px">

<?php 
$tp = new TaskPermission();
if ($tp->canBackup()) {
    ?>

<h1><span><?php 
    echo t('Existing Backups');
    ?>
</span></h1>
<div class="ccm-dashboard-inner">
<?php 
    if (count($backups) > 0) {
        ?>
<br/>
<table class="grid-list" cellspacing="1" cellpadding="0" border="0">
<tr>
   <td class="subheader"><?php 
        echo t('Date');
コード例 #4
0
ファイル: backup.php プロジェクト: ojalehto/concrete5-legacy
 public function restore_backup()
 {
     set_time_limit(0);
     $tp = new TaskPermission();
     if (!$tp->canBackup()) {
         return false;
     }
     $file = basename(realpath(DIR_FILES_BACKUPS . '/' . $this->post('backup_file')));
     $fh = Loader::helper('file');
     $db = Loader::db();
     if (!file_exists(DIR_FILES_BACKUPS . '/' . $file)) {
         throw new Exception(t('Invalid backup file specified.'));
     }
     chmod(DIR_FILES_BACKUPS . '/' . $file, 0666);
     $str_restSql = $fh->getContents(DIR_FILES_BACKUPS . '/' . $file);
     if (!$str_restSql) {
         $this->error->add(t("There was an error trying to restore the database. This file was empty."));
         $this->view();
         return false;
     }
     $crypt = Loader::helper('encryption');
     if (!preg_match('/INSERT/m', $str_restSql) && !preg_match('/CREATE/m', $str_restSql)) {
         $str_restSql = $crypt->decrypt($str_restSql);
     }
     $arr_sqlStmts = explode("\n\n", $str_restSql);
     foreach ($arr_sqlStmts as $str_stmt) {
         if (trim($str_stmt) != "") {
             $res_restoration = $db->execute($str_stmt);
             if (!$res_restoration) {
                 $this->error->add(t("There was an error trying to restore the database. Affected query: %s", $str_stmt));
                 $this->view();
                 return false;
             }
         }
     }
     //reset perms for security!
     chmod(DIR_FILES_BACKUPS . '/' . $file, 00);
     Cache::flush();
     $this->redirect('/dashboard/system/backup_restore/backup', 'restoration_successful');
 }