Пример #1
0
 public function getTemplateOptionsTab()
 {
     $tplOptsData = array('main' => array('title' => 'Main', 'content' => $this->getMainOptionsHtml()));
     $tplOptsData = dispatcherBup::applyFilters('adminTemplateOptions', $tplOptsData);
     $this->assign('tplOptsData', $tplOptsData);
     return parent::getContent('templateOptionsTab');
 }
Пример #2
0
 /**
  * Write to the log backup settings
  * @param array $settingsArray
  */
 public function writeBackupSettings($settingsArray)
 {
     $text = __('Backup settings: ', BUP_LANG_CODE);
     $settingsStringArray = array();
     if (!empty($settingsArray['full'])) {
         $settingsStringArray[] = __('Full backup', BUP_LANG_CODE);
     }
     if (!empty($settingsArray['wp_core'])) {
         $settingsStringArray[] = __('Wordpress Core', BUP_LANG_CODE);
     }
     if (!empty($settingsArray['plugins'])) {
         $settingsStringArray[] = __('Plugins folder', BUP_LANG_CODE);
     }
     if (!empty($settingsArray['themes'])) {
         $settingsStringArray[] = __('Themes folder', BUP_LANG_CODE);
     }
     if (!empty($settingsArray['uploads'])) {
         $settingsStringArray[] = __('Uploads folder', BUP_LANG_CODE);
     }
     if (!empty($settingsArray['any_directories'])) {
         $settingsStringArray[] = __('Any folder inside wp-content', BUP_LANG_CODE);
     }
     if (!empty($settingsArray['database'])) {
         $settingsStringArray[] = dispatcherBup::applyFilters('changeDBSettingStringInLog', 'Database backup');
     }
     if (!empty($settingsArray['exclude'])) {
         $settingsStringArray[] = __('Exclude: ', BUP_LANG_CODE) . $settingsArray['exclude'];
     }
     if (!empty($settingsArray['email_ch'])) {
         $settingsStringArray[] = __('Email notification: ', BUP_LANG_CODE) . $settingsArray['email'];
     }
     $text .= implode('; ', $settingsStringArray) . '.';
     $this->add($text);
 }
Пример #3
0
 public function indexAction()
 {
     $model = $this->getModel();
     $backups = $model->getBackupsList();
     $providers = array();
     $old = $model->getOldBackupsList();
     return $this->render('index', array('backups' => $backups, 'old' => $old, 'providers' => dispatcherBup::applyFilters('adminSendToLinks', $providers)));
 }
Пример #4
0
 public function initMenu()
 {
     $accessCap = 'manage_options';
     $subMenuTabs = array(1 => array('parentSlug' => $this->_file, 'pageTitle' => __('Overview', BUP_LANG_CODE), 'capability' => $accessCap, 'menuSlug' => 'admin.php?page=supsystic-backup&tab=overview'), 2 => array('parentSlug' => $this->_file, 'pageTitle' => __('Backup', BUP_LANG_CODE), 'capability' => $accessCap, 'menuSlug' => $this->_file), 3 => array('parentSlug' => $this->_file, 'pageTitle' => __('Schedule', BUP_LANG_CODE), 'capability' => $accessCap, 'menuSlug' => 'admin.php?page=supsystic-backup&tab=bupSchedule'), 4 => array('parentSlug' => $this->_file, 'pageTitle' => __('Restore', BUP_LANG_CODE), 'capability' => $accessCap, 'menuSlug' => 'admin.php?page=supsystic-backup&tab=bupLog'), 5 => array('parentSlug' => $this->_file, 'pageTitle' => __('Migration', BUP_LANG_CODE), 'capability' => $accessCap, 'menuSlug' => 'admin.php?page=supsystic-backup&tab=migration'));
     $subMenuTabs = dispatcherBup::applyFilters('addAdminSubMenuTabs', $subMenuTabs);
     ksort($subMenuTabs);
     add_menu_page(__('Backup by Supsystic', BUP_LANG_CODE), __('Backup by Supsystic', BUP_LANG_CODE), $accessCap, $this->_file, array(frameBup::_()->getModule('options')->getView(), 'getAdminPage'));
     foreach ($subMenuTabs as $tab) {
         add_submenu_page($tab['parentSlug'], $tab['pageTitle'], $tab['pageTitle'], $tab['capability'], $tab['menuSlug']);
     }
 }
Пример #5
0
 public function getComingSoonPageHtml()
 {
     $this->_beforeShow();
     $this->assign('msgTitle', frameBup::_()->getModule('options')->get('msg_title'));
     $this->assign('msgTitleColor', frameBup::_()->getModule('options')->get('msg_title_color'));
     $this->assign('msgTitleFont', frameBup::_()->getModule('options')->get('msg_title_font'));
     $msgTitleStyle = array();
     if (!empty($this->msgTitleColor)) {
         $msgTitleStyle['color'] = $this->msgTitleColor;
     }
     if (!empty($this->msgTitleFont)) {
         $msgTitleStyle['font-family'] = $this->msgTitleFont;
         $this->_styles[] = 'http://fonts.googleapis.com/css?family=' . $this->msgTitleFont . '&subset=latin,cyrillic-ext';
     }
     $this->assign('msgTitleStyle', utilsBup::arrToCss($msgTitleStyle));
     $this->assign('msgText', frameBup::_()->getModule('options')->get('msg_text'));
     $this->assign('msgTextColor', frameBup::_()->getModule('options')->get('msg_text_color'));
     $this->assign('msgTextFont', frameBup::_()->getModule('options')->get('msg_text_font'));
     $msgTextStyle = array();
     if (!empty($this->msgTextColor)) {
         $msgTextStyle['color'] = $this->msgTextColor;
     }
     if (!empty($this->msgTextFont)) {
         $msgTextStyle['font-family'] = $this->msgTextFont;
         if ($this->msgTitleFont != $this->msgTextFont) {
             $this->_styles[] = 'http://fonts.googleapis.com/css?family=' . $this->msgTextFont . '&subset=latin,cyrillic-ext';
         }
     }
     $this->assign('msgTextStyle', utilsBup::arrToCss($msgTextStyle));
     if ($this->_useSubscribeForm && frameBup::_()->getModule('options')->get('sub_enable')) {
         $this->_scripts[] = frameBup::_()->getModule('subscribe')->getModPath() . 'js/frontend.subscribe.js';
         $this->assign('subscribeForm', frameBup::_()->getModule('subscribe')->getController()->getView()->getUserForm());
     }
     if ($this->_useSocIcons) {
         $this->assign('socIcons', frameBup::_()->getModule('social_icons')->getController()->getView()->getFrontendContent());
     }
     if (file_exists($this->getModule()->getModDir() . 'css/style.css')) {
         $this->_styles[] = $this->getModule()->getModPath() . 'css/style.css';
     }
     $this->assign('logoPath', $this->getModule()->getLogoImgPath());
     $this->assign('bgCssAttrs', dispatcherBup::applyFilters('tplBgCssAttrs', $this->getModule()->getBgCssAttrs()));
     $this->assign('styles', dispatcherBup::applyFilters('tplStyles', $this->_styles));
     $this->assign('scripts', dispatcherBup::applyFilters('tplScripts', $this->_scripts));
     $this->assign('initJsVars', dispatcherBup::applyFilters('tplInitJsVars', $this->initJsVars()));
     $this->assign('messages', frameBup::_()->getRes()->getMessages());
     $this->assign('errors', frameBup::_()->getRes()->getErrors());
     return parent::getContent($this->getCode() . 'BUPHtml');
 }
Пример #6
0
 /**
  * Get an associative array with dropbox metadata from sandbox
  * @return array|null
  */
 public function getUploadedFiles($stacksFolder = '')
 {
     if (!$this->isAuthenticated()) {
         return null;
     }
     $url = self::API_URL . 'metadata/sandbox' . $this->getDropboxPath() . $stacksFolder;
     $request = curlBup::createGetRequest($url, array('file_limit' => 25000, 'list' => 'true', 'locale' => 'en'));
     $request->setAuthorization($this->getToken());
     // try {
     $response = json_decode($request->exec(), true);
     // } catch (RuntimeException $e) {
     //   exit (sprintf('Dropbox Client error: %s\nTry to refresh page', $e->getMessage()));
     // }
     if (isset($response['error'])) {
         return null;
     }
     // Formatting uploading data files for use their on backups page
     $files = array();
     if (!$stacksFolder) {
         foreach ($response['contents'] as $file) {
             $pathInfo = pathinfo($file['path']);
             $backupInfo = $this->getBackupInfoByFilename($pathInfo['basename']);
             if (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'sql') {
                 $files[$backupInfo['id']]['dropbox']['sql'] = $file;
                 $files[$backupInfo['id']]['dropbox']['sql']['backupInfo'] = $backupInfo;
                 $files[$backupInfo['id']]['dropbox']['sql']['backupInfo'] = dispatcherBup::applyFilters('addInfoIfEncryptedDb', $files[$backupInfo['id']]['dropbox']['sql']['backupInfo']);
             } else {
                 $files[$backupInfo['id']]['dropbox']['zip'] = $file;
                 $files[$backupInfo['id']]['dropbox']['zip']['backupInfo'] = $backupInfo;
             }
         }
         unset($response['contents']);
         $response['contents'] = $files;
     } else {
         foreach ($response['contents'] as $file) {
             $pathInfo = pathinfo($file['path']);
             $files[] = basename($pathInfo['dirname']) . '/' . basename($file['path']);
         }
         $response = $files;
     }
     return $response;
 }
Пример #7
0
 public function getMainOptionsTab()
 {
     if (!isset($this->optModel)) {
         $this->assign('optModel', $this->getModel());
     }
     $backupPlaces = dispatcherBup::applyFilters('getBackupDestination', array());
     // sorting $backupPlaces by $backupPlaces['sortNum']
     $sort = array();
     foreach ($backupPlaces as $key => $row) {
         $sort[$key] = $row['sortNum'];
     }
     array_multisort($sort, SORT_ASC, $backupPlaces);
     $backupDest = frameBup::_()->getModule('options')->get('glb_dest');
     $zipNotExtMsg = frameBup::_()->getModule('backup')->getController()->checkExtensions();
     $zipExtExist = $zipNotExtMsg !== true ? 'disabled' : true;
     $this->assign('zipExtExist', $zipExtExist);
     $this->assign('zipNotExtMsg', $zipNotExtMsg);
     $this->assign('backupPlaces', $backupPlaces);
     $this->assign('backupDest', $backupDest);
     $this->assign('backupOptions', parent::getContent('backupOptions'));
     return parent::getContent('mainOptionsTab');
 }
Пример #8
0
 public function getDestinationHandlers()
 {
     $handlers = array();
     $handlers = dispatcherBup::applyFilters('adminBackupUpload', $handlers);
     return $handlers;
 }
Пример #9
0
?>
                        </td>
                        <td class="col-w-1perc">
                            <i class="fa fa-question supsystic-tooltip" title="<?php 
_e('Secret key for encrypting DB data', BUP_LANG_CODE);
?>
"></i>
                        </td>
                        <td class="col-w-1perc">
                            &nbsp;
                        </td>
                    </tr>
                    <tr class="bupSecretKeyDBRow" style="display: none">
                        <td colspan="3">
                            <?php 
echo dispatcherBup::applyFilters('getInputForSecretKeyEncryptDb', '');
?>
                        </td>
                    </tr>
                </table>

            </div>

            <div class="toeBupOptResponsive">
                <h3><?php 
_e('Additional Settings', BUP_LANG_CODE);
?>
</h3>
                <hr/>

                <table class="form-table" style="width: 100% !important;">
Пример #10
0
 public function init()
 {
     if (is_admin() && frameBup::_()->isPluginAdminPage()) {
         $this->_styles = array('styleBup' => array('path' => BUP_CSS_PATH . 'style.css'), 'adminStylesBup' => array('path' => BUP_CSS_PATH . 'adminStyles.css'), 'jquery-tabs' => array('path' => BUP_CSS_PATH . 'jquery-tabs.css'), 'jquery-buttons' => array('path' => BUP_CSS_PATH . 'jquery-buttons.css'), 'wp-jquery-ui-dialog' => array(), 'farbtastic' => array(), 'jquery-dialog' => array('path' => BUP_CSS_PATH . 'jquery-dialog.css'), 'jquery-progress' => array('path' => BUP_CSS_PATH . 'jquery-progress.css'));
         $defaultPlugTheme = frameBup::_()->getModule('options')->get('default_theme');
         $ajaxurl = admin_url('admin-ajax.php');
         if (frameBup::_()->getModule('options')->get('ssl_on_ajax')) {
             $ajaxurl = uriBup::makeHttps($ajaxurl);
         }
         $jsData = array('siteUrl' => BUP_SITE_URL, 'imgPath' => BUP_IMG_PATH, 'loader' => BUP_LOADER_IMG, 'close' => BUP_IMG_PATH . 'cross.gif', 'ajaxurl' => $ajaxurl, 'animationSpeed' => frameBup::_()->getModule('options')->get('js_animation_speed'), 'siteLang' => langBup::getData(), 'options' => frameBup::_()->getModule('options')->getByCode(), 'BUP_CODE' => BUP_CODE);
         $jsData = dispatcherBup::applyFilters('jsInitVariables', $jsData);
         frameBup::_()->addScript('jquery');
         frameBup::_()->addScript('jquery-ui-tabs', '', array('jquery'));
         frameBup::_()->addScript('jquery-ui-dialog', '', array('jquery'));
         frameBup::_()->addScript('jquery-ui-button', '', array('jquery'));
         frameBup::_()->addScript('farbtastic');
         frameBup::_()->addScript('commonBup', BUP_JS_PATH . 'common.js');
         frameBup::_()->addScript('coreBup', BUP_JS_PATH . 'core.js');
         //installerBup::isUsed() ? frameBup::_()->addScript('adminOptionsBup', BUP_JS_PATH. 'admin.options.js') : false;
         frameBup::_()->addScript('adminOptionsBup', BUP_JS_PATH . 'admin.options.js');
         frameBup::_()->addScript('ajaxupload', BUP_JS_PATH . 'ajaxupload.js');
         frameBup::_()->addScript('postbox', get_bloginfo('wpurl') . '/wp-admin/js/postbox.js');
         frameBup::_()->addJSVar('coreBup', 'BUP_DATA', $jsData);
         /*$desktop = true;
         		if(utilsBup::isTablet()) {
         			$this->_styles['style-tablet'] = array();
         			$desktop = false;
         		} elseif(utilsBup::isMobile()) {
         			$this->_styles['style-mobile'] = array();
         			$desktop = false;
         		}
         		if($desktop) {
         			$this->_styles['style-desctop'] = array();
         		}*/
         foreach ($this->_styles as $s => $sInfo) {
             if (isset($sInfo['for'])) {
                 if ($sInfo['for'] == 'frontend' && is_admin() || $sInfo['for'] == 'admin' && !is_admin()) {
                     continue;
                 }
             }
             $canBeSubstituted = true;
             if (isset($sInfo['substituteFor'])) {
                 switch ($sInfo['substituteFor']) {
                     case 'frontend':
                         $canBeSubstituted = !is_admin();
                         break;
                     case 'admin':
                         $canBeSubstituted = is_admin();
                         break;
                 }
             }
             if ($canBeSubstituted && file_exists(BUP_TEMPLATES_DIR . $defaultPlugTheme . DS . $s . '.css')) {
                 frameBup::_()->addStyle($s, BUP_TEMPLATES_PATH . $defaultPlugTheme . '/' . $s . '.css');
             } elseif ($canBeSubstituted && file_exists(utilsBup::getCurrentWPThemeDir() . 'csp' . DS . $s . '.css')) {
                 frameBup::_()->addStyle($s, utilsBup::getCurrentWPThemePath() . '/toe/' . $s . '.css');
             } elseif (!empty($sInfo['path'])) {
                 frameBup::_()->addStyle($s, $sInfo['path']);
             } else {
                 frameBup::_()->addStyle($s);
             }
         }
         add_action('wp_head', array($this, 'addInitJsVars'));
     }
     parent::init();
 }
Пример #11
0
<div class="backupBlock" align="right">
 <fieldset>
	<legend><?php 
echo '#' . $this->storageData[0] . ' ' . $this->storageData[1];
?>
</legend>
    <div align="left" id="MSG_EL_ID_<?php 
echo $this->storageData[0];
?>
"></div>
    <div class="bup_a_Send_to"><a href="javascript:void (0)">send to ></a></div>
    <div align="right" class="bup_Send_to">
        <?php 
$storageProviders = array();
$storageProviders = dispatcherBup::applyFilters('adminSendToLinks', $storageProviders);
?>
        <?php 
foreach ($storageProviders as $provider) {
    ?>
            <a 
                id="<?php 
    echo $this->storageData[0];
    ?>
" 
                rel="<?php 
    echo implode(',', $this->storageData[2]) . ',log-id' . $this->storageData[0] . '.txt';
    ?>
"
                class="upload" 
                href="javascript:void(0)" 
                data-action="<?php 
Пример #12
0
 private function _flexRestore($filename)
 {
     $res = true;
     $permitted = array('CREATE', 'INSERT', 'DROP');
     $query = '';
     $allMetadata = array();
     $metaDataValidated = false;
     $config = $this->getConfig();
     $transaction = $this->getTransactionSupport();
     $handle = fopen($filename, 'r');
     $handle = dispatcherBup::applyFilters('decryptDbData', $handle, $filename);
     $decryptKeyExist = dispatcherBup::applyFilters('checkIsSecretKeyToDecryptDBExist', false);
     $queriesStarted = false;
     $iteratorEmptyRow = 0;
     // This iterator used to control decrypted data, if data not decrypted - all query will be empty, well then secret key is wrong
     while (($row = fgets($handle)) !== false) {
         // Parse file row-by-row as it can be too large to store all data - in memory in one time
         $row = trim($row);
         $iteratorEmptyRow++;
         if (preg_match('/--\\s*@(.*);/', $row, $metadata)) {
             // At first - let's find metadata, it should be in the begining of file
             $metaKeyValue = array_map('trim', explode('=', $metadata[1]));
             $allMetadata[$metaKeyValue[0]] = $metaKeyValue[1];
             continue;
         }
         if (!$metaDataValidated) {
             // If metadata was not validated - do not go futher
             if (empty($allMetadata)) {
                 // At the begining of our sql file - no metadata for now, so just continue to search
                 continue;
             }
             if ($this->validateMetadata($allMetadata) === false) {
                 // Then - try to validate metadata
                 $res = false;
                 break;
             } else {
                 $metaDataValidated = true;
             }
             // Validated - can go futher
         }
         if (!$queriesStarted) {
             // This code should be executed only when queries part started
             if (!$this->_startQueries($config, $transaction)) {
                 break;
             }
             $queriesStarted = true;
         }
         $rowAplied = false;
         foreach ($permitted as $canStartQuery) {
             if (strpos($row, $canStartQuery) === 0) {
                 // Check - if this is start of our query
                 if (!empty($query)) {
                     // If we have some not executed query (in some case) - execute it
                     $this->_runQuery($query, $config, $transaction);
                     $iteratorEmptyRow = 0;
                 }
                 $query = $row;
                 $rowAplied = true;
                 break;
             }
         }
         if (!empty($query) && !$rowAplied) {
             // Just continue to compose query if it was already started
             $query .= $row;
         }
         if (strpos($row, '#endQuery')) {
             // If this is end of query - just execute it and prepare for next one
             $this->_runQuery($query, $config, $transaction);
             $iteratorEmptyRow = 0;
             $query = '';
         }
         if (empty($query) && empty($row) && $decryptKeyExist && $iteratorEmptyRow > 20) {
             do_action('bupClearSecretKeyToDecryptDb');
             return array('error' => __('Secret key for decrypt DB data wrong! Please, try again.', BUP_LANG_CODE));
         }
     }
     if ($queriesStarted) {
         // If queries was started - then let's finish it's execution correctly
         $this->_endQueries($config, $transaction);
     }
     fclose($handle);
     if ($this->haveErrors()) {
         return false;
     }
 }
Пример #13
0
 /**
  * Restore Action
  * Restore system and/or database from backup
  */
 public function restoreAction()
 {
     $request = reqBup::get('post');
     $response = new responseBup();
     $filename = $request['filename'];
     $model = $this->getModel();
     // This block for pro-version module 'scrambler'
     $needKeyToDecryptDB = dispatcherBup::applyFilters('checkIsNeedSecretKeyToEncryptedDB', false, $filename, $request);
     if ($needKeyToDecryptDB) {
         $response->addData(array('need' => 'secretKey'));
         return $response->ajaxExec();
     }
     $result = $model->restore($filename);
     if (false === $result) {
         $errors = array_merge($model->getDatabase()->getErrors(), $model->getFilesystem()->getErrors());
         if (empty($errors)) {
             $errors = __('Unable to restore from ' . $filename, BUP_LANG_CODE);
         }
         $response->addError($errors);
     } elseif (is_array($result) && array_key_exists('error', $result)) {
         $response->addError($result['error']);
     } elseif (is_array($result) && !empty($result)) {
         $content = __('Unable to restore backup files. Check folder or files writing permissions. Try to set 766 permissions to the:', BUP_LANG_CODE) . ' <br>' . implode('<br>', $result);
         $response->addError($content);
     } else {
         $response->addData($result);
         $response->addMessage(__('Done!', BUP_LANG_CODE));
     }
     $response->addData(array('result' => $result));
     return $response->ajaxExec();
 }
Пример #14
0
 /**
  * Returns uploaded file to plugin's root folder
  *
  * @since  1.0
  * @uses   \Dropbox\Client
  * @see    https://www.dropbox.com/developers/core/start/php#listing
  * @return null|array
  */
 public function getUploadedFiles()
 {
     // never executed, but dont remove, ok?
     if ($this->isAuthenticated() === false) {
         return null;
     }
     // try {
     $client = new Dropbox\Client($this->getToken(), $this->applicationName);
     $response = $client->getMetadataWithChildren(rtrim($this->getDropboxPath(), '/'));
     // Formatting uploading data files for use their on backups page
     $files = array();
     foreach ($response['contents'] as $file) {
         $pathInfo = pathinfo($file['path']);
         $backupInfo = $this->getBackupInfoByFilename($pathInfo['basename']);
         if (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'sql') {
             $files[$backupInfo['id']]['dropbox']['sql'] = $file;
             $files[$backupInfo['id']]['dropbox']['sql']['backupInfo'] = $backupInfo;
             $files[$backupInfo['id']]['dropbox']['sql']['backupInfo'] = dispatcherBup::applyFilters('addInfoIfEncryptedDb', $files[$backupInfo['id']]['dropbox']['sql']['backupInfo']);
         } elseif (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'zip') {
             $files[$backupInfo['id']]['dropbox']['zip'] = $file;
             $files[$backupInfo['id']]['dropbox']['zip']['backupInfo'] = $backupInfo;
         }
     }
     unset($response['contents']);
     $response['contents'] = $files;
     return $response;
     // } catch (Exception $e) {
     //echo sprintf('Dropbox client error: %s. Try to refresh page', $e->getMessage());
     //}
 }
Пример #15
0
 /**
  * Returns the list of the objects inside the folder.
  * @param  string $folderId
  * @return stdClass[]|null
  */
 public function getFolderObjects($folderId, $getStacksFolder = false)
 {
     $url = $this->buildUrl('{folder_id}/files?access_token={token}', array('folder_id' => $folderId, 'token' => $this->getAccessToken()));
     $response = wp_remote_get($url);
     if ($this->hasError($response)) {
         return null;
     }
     $body = json_decode(wp_remote_retrieve_body($response));
     if (!empty($body->data[0]->name) && strpos($body->data[0]->name, 'backup_') !== false) {
         if ($getStacksFolder) {
             $folders = array();
             foreach ($body->data as $key => $folder) {
                 $folders[] = $folder;
             }
             return $folders;
         } else {
             // Formatting uploading data files for use their on backups page
             $files = array();
             foreach ($body->data as $key => $file) {
                 $backupInfo = $this->getBackupInfoByFilename($file->name);
                 if (empty($files[$backupInfo['id']]['onedrive'])) {
                     $files[$backupInfo['id']]['onedrive'] = new stdClass();
                 }
                 if (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'sql') {
                     $files[$backupInfo['id']]['onedrive']->sql = $body->data[$key];
                     $files[$backupInfo['id']]['onedrive']->sql->backupInfo = $backupInfo;
                     $files[$backupInfo['id']]['onedrive']->sql->backupInfo = dispatcherBup::applyFilters('addInfoIfEncryptedDb', $files[$backupInfo['id']]['onedrive']->sql->backupInfo);
                 } else {
                     $files[$backupInfo['id']]['onedrive']->zip = $body->data[$key];
                     $files[$backupInfo['id']]['onedrive']->zip->backupInfo = $backupInfo;
                 }
             }
             return $files;
         }
     }
     return $body->data;
 }
Пример #16
0
 /**
  * Returns uploaded files to amazon s3
  *
  * @since  1.1
  * @uses   \Aws\S3\S3Client
  * @see    http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.S3.S3Client.html#_listObjects
  * @see    http://www.php.net/manual/ru/class.arrayaccess.php
  * @see    http://www.php.net/manual/ru/class.iteratoraggregate.php
  * @see    http://www.php.net/manual/ru/class.countable.php
  * @see    http://docs.aws.amazon.com/aws-sdk-php/latest/class-Guzzle.Common.ToArrayInterface.html
  * @param  boolean $match Show only backups files or show all files in bucket
  * @param  integer $order ascending or descending
  * @return array
  */
 public function getUploadedFiles($stacksFolder = '', $match = true, $order = amazonModelBup::ORDER_DESCENDING)
 {
     $credentials = $this->getCredentials();
     $bucket = $this->getBucket();
     $files = array();
     //        $pattern     = '/([a-z_]+[0-9_-]{20}[a-z]{4,8}_id[0-9]+(.sql|.zip))/';
     $pattern = '/(backup_.*)/';
     $client = Aws\S3\S3Client::factory(array('key' => $credentials['access'], 'secret' => $credentials['secret']));
     $filesIterator = $client->getIterator('ListObjects', array('Bucket' => $bucket, 'Prefix' => $this->getCurrentDomain() . '/' . $stacksFolder));
     foreach ($filesIterator as $storageFile) {
         if ($match === true) {
             if (preg_match($pattern, $storageFile['Key'])) {
                 $files[] = $storageFile['Key'];
             }
         } else {
             $files[] = $storageFile['Key'];
         }
     }
     if ($order = amazonModelBup::ORDER_DESCENDING) {
         krsort($files);
     }
     if ($stacksFolder) {
         return $files;
     } else {
         // Formatting uploading data files for use their on backups page
         $newFiles = array();
         foreach ($files as $file) {
             $pathElementsCount = explode('/', $file);
             // if $pathElementsCount contains 3 element - so this is filesystem backup with stacks, else backup with one big archive
             $oneFileBackup = count($pathElementsCount) > 2 ? false : true;
             $extension = pathinfo($file, PATHINFO_EXTENSION);
             if ($extension === 'sql' || $extension === 'zip' && $oneFileBackup) {
                 $backupInfo = $this->getBackupInfoByFilename($file);
             } else {
                 $backupInfo = $this->getBackupInfoByFilename(pathinfo($file, PATHINFO_DIRNAME));
             }
             if (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'sql') {
                 $newFiles[$backupInfo['id']]['amazon']['sql']['file'] = $file;
                 $newFiles[$backupInfo['id']]['amazon']['sql']['backupInfo'] = $backupInfo;
                 $newFiles[$backupInfo['id']]['amazon']['sql']['backupInfo'] = dispatcherBup::applyFilters('addInfoIfEncryptedDb', $newFiles[$backupInfo['id']]['amazon']['sql']['backupInfo']);
             } elseif (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'zip' && $oneFileBackup) {
                 $newFiles[$backupInfo['id']]['amazon']['zip']['file'] = $file;
                 $newFiles[$backupInfo['id']]['amazon']['zip']['backupInfo'] = $backupInfo;
             } else {
                 $newFiles[$backupInfo['id']]['amazon']['zip']['file'] = pathinfo($file, PATHINFO_DIRNAME);
                 $newFiles[$backupInfo['id']]['amazon']['zip']['backupInfo'] = $backupInfo;
             }
         }
         return $newFiles;
     }
 }
Пример #17
0
 public function checkCloudServiceRemoteServerIsAuth($destination)
 {
     $isAuthorized = false;
     $handlers = dispatcherBup::applyFilters('adminBackupUpload', array());
     /* @var modelBup $handlerModel*/
     $handlerModel = !empty($handlers[$destination][0]) ? $handlers[$destination][0] : null;
     if (is_a($handlerModel, 'modelBup')) {
         $isAuthorized = $handlerModel->isUserAuthorizedInService($destination);
         if (!$isAuthorized) {
             $this->pushError($handlerModel->getErrors());
         }
     } else {
         $this->pushError(__('Unexpected error.', BUP_LANG_CODE));
     }
     return $isAuthorized;
 }
Пример #18
0
 public function getDomainFiles($stacksFolder = false, $getStacks = false)
 {
     $pageToken = null;
     $domain = $this->getDomain($stacksFolder);
     $child = array();
     if (!$domain) {
         return null;
     }
     $client = $this->getClient();
     $service = new Google_DriveService($client);
     do {
         try {
             $parameters = array();
             if ($pageToken) {
                 $parameters['pageToken'] = $pageToken;
             }
             $children = $service->children->listChildren($domain['id'], $parameters);
             $child = array_merge($child, $children['items']);
             $token = null;
             if (isset($children['nextPageToken'])) {
                 $pageToken = $children['nextPageToken'];
             }
         } catch (Exception $e) {
             $pageToken = null;
             $this->pushError($e->getMessage());
             return array();
         }
     } while ($pageToken);
     // Formatting uploading data files for use their on backups page
     $files = array();
     if ($getStacks) {
         $i = 0;
         foreach ($child as $file) {
             $fileInfo = $service->files->get($file['id']);
             if (!empty($fileInfo['downloadUrl']) && !empty($fileInfo['title'])) {
                 $files[$i]['downloadUrl'] = $fileInfo['downloadUrl'];
                 $files[$i]['title'] = $fileInfo['title'];
                 $i++;
             }
         }
     } else {
         foreach ($child as $file) {
             $backupInfo = $service->files->get($file['id']);
             $backupInfo = $this->getBackupInfoByFilename($backupInfo['title']);
             if (!empty($backupInfo['ext']) && $backupInfo['ext'] == 'sql') {
                 $files[$backupInfo['id']]['gdrive']['sql'] = $service->files->get($file['id']);
                 $files[$backupInfo['id']]['gdrive']['sql']['backupInfo'] = $backupInfo;
                 $files[$backupInfo['id']]['gdrive']['sql']['backupInfo'] = dispatcherBup::applyFilters('addInfoIfEncryptedDb', $files[$backupInfo['id']]['gdrive']['sql']['backupInfo']);
             } else {
                 $files[$backupInfo['id']]['gdrive']['zip'] = $service->files->get($file['id']);
                 $files[$backupInfo['id']]['gdrive']['zip']['backupInfo'] = $backupInfo;
             }
         }
     }
     return $files;
 }
Пример #19
0
            <!-- Log modal window end  -->

            <!-- Migrate promo modal window start  -->
            <div id="bupShowMigratePromoDlg" title="<?php 
_e('Get PRO Verion!', BUP_LANG_CODE);
?>
" style="display: none">
                <p id="bupMigratePromoText" class="supsystic-plugin">
                    <?php 
_e('Please, be advised, that this option is available only in PRO version. You can', BUP_LANG_CODE);
?>
                    <a class="button button-primary button-small" href="<?php 
echo frameBup::_()->getModule('promo_supsystic')->getMainLink();
?>
" target="_blank"><?php 
_e('Get PRO', BUP_LANG_CODE);
?>
</a>
                </p>
            </div>
            <!-- Migrate promo modal window end  -->
            <?php 
echo dispatcherBup::applyFilters('getInputsForReplaceMigrationData', '');
?>

            <?php 
echo dispatcherBup::applyFilters('getModalWindowForSecretKeyEncryptDB', '');
?>
        </div>
    </div>
</section>