public function put($d = array()) { $res = new responseBup(); $id = $this->_getIDFromReq($d); $d = prepareParamsBup($d); if (is_numeric($id) && $id) { if (isset($d['active'])) { $d['active'] = is_string($d['active']) && $d['active'] == 'true' || $d['active'] == 1 ? 1 : 0; } //mmm.... govnokod?....))) /* else $d['active'] = 0;*/ if (frameBup::_()->getTable('modules')->update($d, array('id' => $id))) { $res->messages[] = __('Module Updated', BUP_LANG_CODE); $mod = frameBup::_()->getTable('modules')->getById($id); $newType = frameBup::_()->getTable('modules_type')->getById($mod['type_id'], 'label'); $newType = $newType['label']; $res->data = array('id' => $id, 'label' => $mod['label'], 'code' => $mod['code'], 'type' => $newType, 'active' => $mod['active']); } else { if ($tableErrors = frameBup::_()->getTable('modules')->getErrors()) { $res->errors = array_merge($res->errors, $tableErrors); } else { $res->errors[] = __('Module Update Failed', BUP_LANG_CODE); } } } else { $res->errors[] = __('Error module ID', BUP_LANG_CODE); } return $res; }
public function getAdminOptionsLimit($d = array()) { // deprecate frameBup::_()->addScript('adminScheduleOptions', $this->getModule()->getModPath() . 'js/admin.storage.js'); $storage = array(); //$arrStorage = $this->getModel()->getStorage(); $arrStorage = $this->getModel()->getList_A($d); $storageBlock = array(); $sendTplData = array(); $i = 0; $ret = array(); foreach ($arrStorage as $key => $el) { $i++; $title = frameBup::_()->getModule('backup')->getModel()->fileNameFormat(current($el), 'title'); $type = frameBup::_()->getModule('backup')->getModel()->fileNameFormat(current($el), 'prefix'); $header = $type == 'full' ? '<strong>Full backup</strong> ' . $title : $title; $sendTplData = array($key, $header, $el); $this->assign('storageData', $sendTplData); $storageBlock['id'] = $key; $storageBlock['bupbackupblock'] = parent::getContent('storageBlock'); array_push($ret, array('id' => $key, 'bupbackupblock' => parent::getContent('storageBlock'))); } //$this->assign('storageBlock', $storageBlock); return $ret; }
public function backupSchedule() { /** @var backupModelBup $model */ $model = frameBup::_()->getModule('backup')->getModel(); $filename = $model->generateFilename(array('sql', 'zip')); $files = array(); if ($model->isFilesystemRequired()) { $model->getFilesystem()->getArchive($filename['zip'], $model->getFilesList()); $files[] = $filename['zip']; } if ($model->isDatabaseRequired()) { $model->getDatabase()->create($filename['sql']); $files[] = $filename['sql']; } if ('ftp' !== ($dest = frameBup::_()->getModule('options')->get('sch_dest'))) { $handlers = $model->getDestinationHandlers(); foreach ($handlers as $handle => $callback) { if ($handle === $dest) { $result = call_user_func_array($callback, array($files, true)); file_put_contents(WP_CONTENT_DIR . '/schedule.log', array('Handle: ' . $handle . PHP_EOL, 'Result: ' . $result)); } } foreach ($files as $file) { @unlink($file); } } }
public function getAdminPage() { $tabsData = array('bupMainOptions' => array('title' => 'Main', 'content' => $this->getMainOptionsTab()), 'bupTemplateOptions' => array('title' => 'Options', 'content' => $this->getTemplateOptionsTab()), 'bupStorageOptions' => array('title' => 'Backups', 'content' => frameBup::_()->getModule('storage')->getController()->getView()->getAdminOptions()), 'bupScheduleOptions' => array('title' => 'Schedule', 'content' => frameBup::_()->getModule('schedule')->getController()->getView()->getAdminOptions()), 'bupLogOptions' => array('title' => 'Log', 'content' => frameBup::_()->getModule('log')->getController()->getView()->getAdminOptions()), 'bupDropboxOptions' => array('title' => 'Dropbox</a><small class="bupAIP">Available In PRO</small>', 'content' => '<a href="http://readyshoppingcart.com/product/wordpress-backup-and-restoration-plugin/" target="_blank"><img src="' . BUP_IMG_PATH . 'pro/dropbox.png" width="580" /></a>'), 'bupGdriveOptions' => array('title' => 'Google Drive</a><small class="bupAIP">Available In PRO</small>', 'content' => '<a href="http://readyshoppingcart.com/product/wordpress-backup-and-restoration-plugin/" target="_blank"><img src="' . BUP_IMG_PATH . 'pro/prev_google.png" width="580" /></a>'), 'bupAmazonS3Options' => array('title' => 'Amazon S3</a><small class="bupAIP">Available In PRO</small>', 'content' => '<a href="http://readyshoppingcart.com/product/wordpress-backup-and-restoration-plugin/" target="_blank"><img src="' . BUP_IMG_PATH . 'pro/amazon.png" width="580" /></a>'), 'bupEmailOptions' => array('title' => 'Email</a><small class="bupAIP">Available In PRO</small>', 'content' => '<a href="http://readyshoppingcart.com/product/wordpress-backup-and-restoration-plugin/" target="_blank"><img src="' . BUP_IMG_PATH . 'pro/email.png" width="580" /></a>'), 'bupOneDriveOptions' => array('title' => 'OneDrive</a><small class="bupAIP">Available In PRO</small>', 'content' => '<a href="http://readyshoppingcart.com/product/wordpress-backup-and-restoration-plugin/" target="_blank"><img src="' . BUP_IMG_PATH . 'pro/onedrive.png" width="580" /></a>')); $tabsData = dispatcherBup::applyFilters('adminOptionsTabs', $tabsData); $this->assign('tabsData', $tabsData); parent::display('optionsAdminPage'); }
public function getList_A($d = array()) { $warehouse = ABSPATH . frameBup::_()->getModule('options')->get('warehouse'); if (!file_exists($warehouse)) { utilsBup::createDir($warehouse, $params = array('chmod' => 0755, 'httpProtect' => 2)); } $arrFile = scandir($warehouse); $arrFile = array_diff($arrFile, array('.', '..')); arsort($arrFile); $arrId = array(); foreach ($arrFile as $file) { preg_match_all('~_id(\\d+)~', $file, $out); if (!empty($out[1][0]) && !in_array($out[1][0], $arrId)) { $arrId[] = $out[1][0]; // get file array } } $arrBlock = array(); foreach ($arrId as $id) { if ($id > $d['limitFrom'] && $id <= $d['limitTo']) { $pattern = "~_id{$id}~"; foreach ($arrFile as $file) { if (preg_match($pattern, $file)) { $arrBlock[$id][] = $file; } } } } return $arrBlock; }
/** * Module Installer * * @since 1.1 * @return void */ public function install() { parent::install(); foreach ($this->options as $options) { frameBup::_()->getTable('options')->insert($options); } }
public function getTabUrl($tab) { static $mainUrl; if (empty($mainUrl)) { $mainUrl = frameBup::_()->getModule('adminmenu')->getMainLink(); } return empty($tab) ? $mainUrl : $mainUrl . '&tab=' . $tab; }
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']); } }
/** * Get the content for templates module tab * * @return type */ public function getTabContent() { $templates = frameBup::_()->getModule('templatesBup')->getModel()->get(); if (empty($templates)) { $tpl = 'noTemplates'; } else { $this->assign('templatesBup', $templates); $this->assign('default_theme', frameBup::_()->getModule('optionsBup')->getModel()->get('default_theme')); $tpl = 'templatesTab'; } return parent::getContent($tpl); }
public function init() { parent::init(); if (is_admin() && frameBup::_()->isPluginAdminPage()) { frameBup::_()->addScript('adminOneDriveOptions', $this->getModPath() . 'js/onedrive.admin.js'); } include rtrim($this->getModDir(), '/') . '/classes/skydriveBup.php'; dispatcherBup::addFilter('getBackupDestination', array($this, 'addOnedriveBupDestination')); dispatcherBup::addFilter('adminSendToLinks', array($this, 'registerStorage')); dispatcherBup::addfilter('adminBackupUpload', array($this, 'registerUploadMethod')); dispatcherBup::addfilter('adminGetUploadedFiles', array($this, 'getUploadedFiles')); }
public function initPage($posts) { if (count($posts) == 1) { if ($posts[0]->post_type == 'page') { if ($page = $this->getByID($posts[0]->ID)) { $this->_current = $page; frameBup::_()->getModule($page->mod)->exec($page->action); remove_filter('the_content', 'wpautop'); } } } return $posts; }
public function initJsVars() { $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'), 'BUP_CODE' => BUP_CODE); return '<script type="text/javascript"> // <!-- var BUP_DATA = ' . utilsBup::jsonEncode($jsData) . '; // --> </script>'; }
protected function _createView($name = '') { if (empty($name)) { $name = $this->getCode(); } $parentModule = frameBup::_()->getModule($this->getCode()); $className = ''; if (import($parentModule->getModDir() . 'views' . DS . $name . '.php')) { $className = toeGetClassNameBup($name . 'View'); } if ($className) { $view = new $className(); $view->setCode($this->getCode()); return $view; } return NULL; }
public function showReviewAdminNotice() { if (is_admin() && frameBup::_()->isPluginAdminPage()) { $showReviewBlock = get_option('bupShowReviewBlockV2'); // v2 because was v1 and it don't using now $bupShowReviewBlockTimestamp = get_option('bupShowReviewBlockTimestampV2'); $sendStatAfterSevenDays = get_option('sendStatAfterSevenDays'); if ($showReviewBlock === false) { add_option('bupShowReviewBlockV2', 'yes'); add_option('sendStatAfterSevenDays', 'yes'); add_option('bupShowReviewBlockTimestampV2', time()); } elseif ($showReviewBlock === 'yes' && time() > $bupShowReviewBlockTimestamp + 86400 * 7) { if ($sendStatAfterSevenDays === 'yes') { $this->getModel()->sendUsageStat(array('code' => 'seven_days_passed', 'visits' => 1)); update_option('sendStatAfterSevenDays', 'no'); } echo parent::getContent('reviewNotice'); } } }
/** * Returns all finded log files * @return array */ public function getFilesList() { $options = frameBup::_()->getModule('options'); $path = realpath(ABSPATH) . $options->get('warehouse'); $files = array(); $matches = array(); $nodes = @scandir($path); if (!is_array($nodes) || empty($nodes)) { return $files; } foreach ($nodes as $node) { if (preg_match('/([\\d]+).txt/', $node, $matches)) { $content = file_get_contents($path . $node); $linesArray = preg_split('/\\n|\\r/', $content); $lines = count($linesArray); $files[] = array('filepath' => $path . $node, 'filename' => $node, 'backup_id' => $matches[1], 'lines' => $lines, 'content' => $content); } } krsort($files); return $files; }
public function initMenu() { $firstTimeLookedToPlugin = installerBup::isUsed(); //$firstTimeLookedToPlugin = false; if ($firstTimeLookedToPlugin) { add_menu_page(langBup::_('Ready! Backup'), langBup::_('Ready! Backup'), 10, $this->_file, array(frameBup::_()->getModule('options')->getView(), 'getAdminPage')); } else { if (frameBup::_()->getModule('promo_ready')) { add_menu_page(langBup::_('Ready! Backup'), langBup::_('Ready! Backup'), 10, $this->_file, array(frameBup::_()->getModule('promo_ready')->getView(), 'showWelcomePage')); } else { // if not install module "promo_ready" installerBup::setUsed(); add_menu_page(langBup::_('Ready! Backup'), langBup::_('Ready! Backup'), 10, $this->_file, array(frameBup::_()->getModule('options')->getView(), 'getAdminPage')); } } /*if(!empty($this->_options)) { foreach($this->_options as $opt) { add_submenu_page($this->_file, langBup::_($opt['title']), langBup::_($opt['title']), $opt['capability'], $opt['menu_slug'], $opt['function']); } }*/ }
/** * Returns all finded log files * @return array */ public function getFilesList() { $path = frameBup::_()->getModule('warehouse')->getPath() . DIRECTORY_SEPARATOR; $files = array(); $matches = array(); $nodes = @scandir($path); if (!is_array($nodes) || empty($nodes)) { return $files; } foreach ($nodes as $node) { if (preg_match('/([\\d]+).txt/', $node, $matches)) { $backupInfo = $this->getBackupInfoByFilename($node, true); $contentArray = file($path . $node, FILE_SKIP_EMPTY_LINES); $dirSettings = @unserialize(array_pop($contentArray)); $backupFolderSize = !empty($dirSettings['backupFolderSize']) ? $dirSettings['backupFolderSize'] : null; $settings = !empty($contentArray[0]) ? substr($contentArray[0], strpos($contentArray[0], ']') + 1) : __('Settings not found!', BUP_LANG_CODE); $files[$backupInfo['id']] = array('filepath' => $path . $node, 'filename' => $node, 'backup_id' => $matches[1], 'content' => htmlspecialchars(implode(null, $contentArray)), 'settings' => $settings, 'backupFolderSize' => $backupFolderSize); } } krsort($files); return $files; }
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'); }
/** * Collect the tabs from the given modules * * @param array $modules * @return array of tab */ public function getTabs($modules = array()) { if (!is_array($modules)) { $modules = array($modules); } $tabs = array(); if (!empty($modules)) { foreach ($modules as $module) { if ($module['has_tab'] && frameBup::_()->getModule($module['code'])) { $moduleTabs = frameBup::_()->getModule($module['code'])->getTabs(); if (!empty($moduleTabs)) { $tabs = array_merge($tabs, $moduleTabs); } } } } if (!empty($tabs)) { usort($tabs, array($this, 'sortTabsCallback')); $tempTabs = $tabs; foreach ($tempTabs as $i => $tab) { $parent = $tab->getParent(); if (empty($parent) && ($parentIter = $this->getTabIterByModule($tabs, $parent))) { array_splice($tabs, $parentIter + 1, 1, array($tabs[$parentIter + 1], $tab)); } } } return $tabs; }
public function getModule() { return frameBup::_()->getModule($this->_code); }
protected function addRefreshTokenToJSONToken($token) { $refreshToken = frameBup::_()->getTable('options')->get('value', array('code' => 'gdrive_refresh_token'), '', 'row'); if (!empty($refreshToken['value']) && false !== json_decode($token)) { $token = json_decode($token); $token->refresh_token = $refreshToken['value']; $token = json_encode($token); } return $token; }
<?php echo langBup::_('Exclude:'); echo htmlBup::text('opt_values[exclude]', array('attrs' => 'class="excludeInput" title="If entering multiple files/directories, then separate them with commas."', 'value' => frameBup::_()->getModule('options')->get('exclude'))); ?> </div> <div class="emailOpt"> <table> <tr> <td width="120"><?php echo langBup::_('Email notification:'); ?> </td> <td><?php echo htmlBup::checkbox('opt_values[email_ch]', array('attrs' => 'class="bupCheckboxNotUnCheck"', 'value' => 1, 'checked' => frameBup::_()->getModule('options')->getValueType('email') ? 'checked' : '')); ?> </td> </tr> </table> <div class="emailAddress" <?php echo frameBup::_()->getModule('options')->getValueType('email') ? '' : 'style="display:none"'; ?> > <?php echo htmlBup::text('opt_values[email]', array('attrs' => 'class="excludeInput" placeholder="*****@*****.**" title=""', 'value' => frameBup::_()->getModule('options')->get('email'))); ?> </div> </div> </div>
protected function saveRefreshTokenExpireTime($refreshTokenExpireTime) { $storage = frameBup::_()->getModule('warehouse')->getPath(); $this->deleteRefreshTokenExpireTime(); $result = file_put_contents($storage . '/' . uniqid('onedriveExpireTimeRefreshToken') . '.json', $refreshTokenExpireTime); if (!$result) { @error_log('Backup by Supsystic: Failed to write OneDrive refresh token expire time.'); } }
/** * Save this in static var - to futher usage * @return array with states */ public static function getCachedStates($clearCache = false) { if (empty(self::$states) || $clearCache) { self::$states = frameBup::_()->getTable('states')->leftJoin(frameBup::_()->getTable('countries'), 'country_id')->getAll('toe_states.id, toe_states.name, toe_states.code, toe_states.country_id, toe_cry.name AS c_name, toe_cry.iso_code_2 AS c_iso_code_2, toe_cry.iso_code_3 AS c_iso_code_3'); } return self::$states; }
<section> <div class="supsystic-item supsystic-panel"> <a href="<?php echo frameBup::_()->getModule('promo_supsystic')->getMainLink(); ?> " target="_blank"> <img src="<?php echo BUP_IMG_PATH; ?> pro/schedule_pro.jpg" style="max-width: 100%;" /> </a> <a class="button button-primary button-large" href="<?php echo frameBup::_()->getModule('promo_supsystic')->getMainLink(); ?> " target="_blank" style="position: absolute; left: 240px; top: 15px;"> <?php echo __('Get PRO', BUP_LANG_CODE); ?> </a> </div> </section>
public function getTime($ind) { $unserArr = unserialize(frameBup::_()->getModule('options')->get('sch_time')); return $unserArr[$ind]; }
/** * Download Action * Downloads file from Amazon S3 to local storage * This action triggers before restoring from Amazon S3 * * @since 1.1 */ public function downloadAction() { $request = reqBup::get('post'); $response = new responseBup(); /**@var amazonModelBup $model*/ $model = $this->getModel(); $extension = pathinfo($request['filename'], PATHINFO_EXTENSION); $filename = pathinfo($request['filename'], PATHINFO_BASENAME); if ($extension === 'sql' || $extension === 'zip') { if (file_exists($model->getBackupsPath() . $filename) || $model->download($request['filename']) === 201) { $response->addData(array('filename' => $filename)); } else { $response->addError(array(__('File not found on Amazon S3', BUP_LANG_CODE))); } } else { $stacksFolder = basename($request['filename']) . '/'; $stacksFileList = $model->getUploadedFiles($stacksFolder); if (!empty($stacksFileList)) { $backupPath = $model->getBackupsPath(); $result = true; if (!file_exists($backupPath . $stacksFolder)) { frameBup::_()->getModule('warehouse')->getController()->getModel('warehouse')->create($backupPath . $stacksFolder . DS); } foreach ($stacksFileList as $stack) { if (!file_exists($backupPath . $stacksFolder . basename($stack))) { $result = $model->download($stack, $stacksFolder) === 201 && $result ? true : false; } } if ($result) { $response->addData(array('filename' => basename($stacksFolder))); } else { $response->addError(__('All stacks not downloaded!', BUP_LANG_CODE)); frameBup::_()->getModule('backup')->getController()->getModel('filesystem')->deleteLocalBackup(array($backupPath . $stacksFolder)); } } else { $response->addError(__('Files not found on Amazon S3!', BUP_LANG_CODE)); } } $response->ajaxExec(); }
/** * Download Action */ public function downloadAction() { $request = reqBup::get('get'); $filename = $request['download']; $file = ABSPATH . frameBup::_()->getModule('options')->get('warehouse') . $filename; if (is_file($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($file)); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } }
</div> <div class="bupMargDest"> <?php echo htmlBup::radiobutton('dest_opt', array('attrs' => 'class="' . $not_piad . '"', 'value' => 'googledrive', 'checked' => frameBup::_()->getModule('options')->get('glb_dest') == 'googledrive' ? 'checked' : '')); ?> Google Drive </div> <div class="bupMargDest"> <?php echo htmlBup::radiobutton('dest_opt', array('attrs' => 'class="' . $not_piad . '"', 'value' => 'amazon', 'checked' => frameBup::_()->getModule('options')->get('glb_dest') == 'amazon' ? 'checked' : '')); ?> Amazon S3 </div> <div class="bupMargDest"> <?php echo htmlBup::radiobutton('dest_opt', array('attrs' => 'class="' . $not_piad . '"', 'value' => 'onedrive', 'checked' => frameBup::_()->getModule('options')->get('glb_dest') == 'onedrive' ? 'checked' : '')); ?> Microsoft OneDrive </div> <div> <?php echo htmlBup::hidden('reqType', array('value' => 'ajax')); ?> <?php echo htmlBup::hidden('page', array('value' => 'options')); ?> <?php echo htmlBup::hidden('action', array('value' => 'saveMainFromDestGroup')); ?> <?php
/** * Save backup destination 'dropbox', when user clicked on Authenticate button */ public function saveBackupDestinationOnAuthenticate() { frameBup::_()->getTable('options')->update(array('value' => 'dropbox'), array('code' => 'glb_dest')); }