private function installTemplateContent($template_name) { $default_content_folder = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR; $default_content_file = $default_content_folder . 'mw_default_content.zip'; if ($template_name) { if (function_exists('templates_path')) { $template_dir = templates_path() . DS . $template_name; $template_dir = normalize_path($template_dir, true); if (is_dir($template_dir)) { $template_default_content = $template_dir . 'mw_default_content.zip'; if (is_file($template_default_content) and is_readable($template_default_content)) { $default_content_file = $template_default_content; $default_content_folder = $template_dir; } } } } if (is_file($default_content_file)) { $restore = new \Microweber\Utils\Backup(); $restore->backups_folder = $default_content_folder; $restore->backup_file = 'mw_default_content.zip'; ob_start(); try { $rest = $restore->exec_restore(); } catch (Exception $e) { return false; } ob_get_clean(); return true; } else { return false; } }
public function restore($params) { if (!defined('MW_NO_SESSION')) { define('MW_NO_SESSION', 1); } $id = null; if (isset($params['id'])) { $id = $params['id']; } elseif (isset($_GET['filename'])) { $id = $params['filename']; } elseif (isset($_GET['file'])) { $id = $params['file']; } if ($id == null) { return array('error' => 'You have not provided a backup to restore.'); die; } ob_start(); $api = new \Microweber\Utils\Backup(); $this->app->cache_manager->clear(); $rest = $api->exec_restore($params); $this->app->cache_manager->clear(); ob_end_clean(); return array('success' => 'Backup was restored!'); return $rest; }
if (defined('templates_path()')) { $template_dir = templates_path() . DS . $to_save['default_template']; $template_dir = normalize_path($template_dir, true); if (is_dir($template_dir)) { $template_default_content = $template_dir . 'mw_default_content.zip'; if (is_file($template_default_content) and is_readable($template_default_content)) { $default_content_file = $template_default_content; $default_content_folder = $template_dir; } } } } if (is_file($default_content_file)) { __mw_install_log('Installing default content'); define("MW_NO_DEFAULT_CONTENT", true); $restore = new \Microweber\Utils\Backup(); $restore->backups_folder = $default_content_folder; $restore->backup_file = 'mw_default_content.zip'; // $restore->debug = 1; ob_start(); $rest = $restore->exec_restore(); ob_get_clean(); __mw_install_log('Default content is installed'); } } } if (isset($to_save['default_template']) and $to_save['default_template'] != false and $to_save['default_template'] != '{default_template}') { $templ = $to_save['default_template']; $templ = str_replace('..', '', $templ); $option = array(); $option['option_value'] = trim($templ);