當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TaskPermission::canBackup方法代碼示例

本文整理匯總了PHP中TaskPermission::canBackup方法的典型用法代碼示例。如果您正苦於以下問題:PHP TaskPermission::canBackup方法的具體用法?PHP TaskPermission::canBackup怎麽用?PHP TaskPermission::canBackup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TaskPermission的用法示例。


在下文中一共展示了TaskPermission::canBackup方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: restore_backup

 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();
 }
開發者ID:homer6,項目名稱:concrete5-mirror,代碼行數:35,代碼來源:backup.php

示例2: view

 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);
         }
     }
 }
開發者ID:r-bansal,項目名稱:janeswalk-web-1,代碼行數:22,代碼來源:backup.php

示例3: function

$(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');
開發者ID:VonUniGE,項目名稱:concrete5-1,代碼行數:31,代碼來源:backup.php

示例4: restore_backup

 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');
 }
開發者ID:ojalehto,項目名稱:concrete5-legacy,代碼行數:40,代碼來源:backup.php


注:本文中的TaskPermission::canBackup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。