function themer_customize_admin_theme($path) { $admin_theme = Setting::get("theme"); $settings = Plugin::getAllSettings("themer"); if ($admin_theme == "wordpress-3.8") { echo new View(THEMER . DS . "views" . DS . "head", array("color" => $settings["color"], "sidebar_width" => $settings["sidebar_width"])); } return $path; }
function settings() { $settings = Plugin::getAllSettings('tinymce'); if (!$settings) { Flash::set('error', 'TinyMCE - ' . __('unable to retrieve plugin settings.')); return; } $this->display('tinymce/views/settings', $settings); }
public function __construct() { $this->cookie = AuthUser::COOKIE_KEY; $this->session = AuthUser::SESSION_KEY; $this->fields = new pawUserFields(); $this->blacklist = new pawBlacklist(); $this->permissions = new pawPermissions(); $config = Plugin::getAllSettings("paw_users"); $this->config = paw_unserializer($config, true); }
public function __construct() { $this->theme = Setting::get("theme"); $this->settings = Plugin::getAllSettings("themer"); // This allows us to check if we're being called in the front or the back. if (defined("CMS_BACKEND")) { $this->setLayout("backend"); $this->assignToLayout("sidebar", new View("../../plugins/themer/views/sidebar")); } }
function settings() { /** You can do this... $tmp = Plugin::getAllSettings('skeleton'); $settings = array('my_setting1' => $tmp['setting1'], 'setting2' => $tmp['setting2'], 'a_setting3' => $tmp['setting3'] ); $this->display('comment/views/settings', $settings); * * Or even this... */ $this->display('skeleton/views/settings', Plugin::getAllSettings('skeleton')); }
public function settings() { if (!$this->_isInternal()) { page_not_found(); } $settings = Plugin::getAllSettings('image'); if (!$settings) { Flash::setNow('error', 'Image - ' . __('unable to retrieve plugin settings.')); } if (!isset($settings['path'])) { $settings['path'] = ''; } $this->display('image/views/settings', $settings); }
public function __construct($id) { $settings = Plugin::getAllSettings('ssp'); $this->id = $id; $sql = "SELECT * FROM ssp_images WHERE id=" . $id; $query = Record::getConnection()->query($sql); $image = $query->fetch(); foreach ($image as $k => $v) { $this->{$k} = $v; } $this->src = URL_PUBLIC . $settings['path'] . DS . "albums" . DS . "album-" . $this->aid . DS . "lg" . DS . $this->src; if (!(strpos('http://', $this->link) > -1) && $this->link[0] !== '/' && isset($this->link)) { $this->link = 'http://' . $this->link; } }
public function filemanager($params) { $settings = Plugin::getAllSettings('ckeditor') or array(); // Set translation if available $settings['lang'] = $this->_filemanager_lang(); // Set defaults if (empty($settings)) { $settings['filemanager_view'] = 'grid'; $settings['filemanager_browse_only'] = false; $settings['filemanager_base'] = rtrim(URL_PUBLIC, '/') . '/public'; $settings['filemanager_thumbs'] = true; $settings['filemanager_images'] = array('gif', 'jpg', 'jpeg', 'png'); } header("Content-type: text/html; charset=utf8"); $this->display('fm_index', array('settings' => $settings)); }
function filemanager_config() { $settings = Plugin::getAllSettings('ckeditor'); $culture = filemanager_lang(); // Set all defaults $config = array('culture' => $culture, 'doc_root' => CMS_ROOT, 'plugin' => null, 'date' => 'd M Y H:i', 'icons' => array('path' => 'images/fileicons/', 'directory' => '_Open.png', 'default' => 'default.png'), 'unallowed_files' => array('.htaccess'), 'unallowed_dirs' => array('_thumbs', '.CDN_ACCESS_LOGS', 'cloudservers'), 'upload' => array('overwrite' => true, 'imagesonly' => false, 'size' => false), 'images' => array('gif', 'jpg', 'jpeg', 'png')); // database settings if ($settings) { $config['date'] = $settings['filemanager_dateformat']; $config['images'] = unserialize($settings['filemanager_images']); $config['upload']['overwrite'] = (bool) $settings['filemanager_upload_overwrite']; $config['upload']['imagesonly'] = (bool) $settings['filemanager_upload_images_only']; $config['upload']['size'] = $settings['filemanager_upload_size'] == '0' || empty($settings['filemanager_upload_size']) ? false : (int) $settings['filemanager_upload_size']; } return $config; }
function themer_customize_admin_theme($path) { $theme = Setting::get("theme"); $settings = Plugin::getAllSettings("themer"); if ($theme == "wordpress-3.8") { $settings = unserialize($settings["wordpress-3.8"]); } else { if ($theme == "wint") { $settings = unserialize($settings["wint"]); } else { if ($theme == "fox") { $settings = unserialize($settings["fox"]); } } } $settings = array_merge(array("theme" => $theme), $settings); echo new View(THEMER . DS . "views" . DS . "head", $settings); return $path; }
public function __construct() { AuthUser::load(); if (!AuthUser::isLoggedIn()) { redirect(get_url("login")); die; } // GET SETTINGS $settings = array_merge(array("grid-size" => 3, "widget-position" => serialize(array("events" => array("part" => 1, "order" => 1), "rss_reader" => array("part" => 2, "order" => 1)))), Plugin::getAllSettings("dashboard")); // UNSERIALIZE SETTINGS foreach ($settings as $key => $value) { if (is_string($value)) { if (@unserialize($value) !== false) { $settings[$key] = unserialize($value); } } } $this->settings = $settings; // OBSERVER DashboardWidgets::init($settings["widget-position"]); Observer::observe("view_backend_layout_head", "DashboardController::loadFiles"); }
/** * Puts all settings into $this->settings */ private function __settings() { if (!$this->settings = Plugin::getAllSettings('banner')) { Flash::set('error', 'Banners - '.__('unable to retrieve plugin settings.')); redirect(get_url('setting')); return; } }//*/
private function __load_settings() { if (!$this->settings = Plugin::getAllSettings('facts')) { Flash::set('error', __('Unable to retrieve plugin settings.')); redirect(get_url('setting')); return; } }//*/
<?php defined('IN_CMS') || exit; $images = serialize(array('gif', 'jpg', 'jpeg', 'png')); $settings = array('version' => '2.1.0', 'filemanager_enabled' => '1', 'filemanager_base' => 'public/images', 'filemanager_view' => 'grid', 'filemanager_images' => $images, 'filemanager_dateformat' => 'd M Y H:i', 'filemanager_browse_only' => '0', 'filemanager_upload_overwrite' => '0', 'filemanager_upload_images_only' => '0', 'filemanager_upload_size' => '0'); $old = Plugin::getAllSettings('ckeditor'); //Other ckeditor filter if (isset($old['fileBrowserRootUri'])) { $settings['filemanager_base'] = trim($old['fileBrowserRootUri'], '/'); } else { if (isset($old['filemanager_base'])) { $settings = $old; $settings['version'] = '2.1.0'; } } // Remove all settings from db Plugin::deleteAllSettings('ckeditor'); // Insert the new ones if (Plugin::setAllSettings($settings, 'ckeditor')) { Flash::setNow('success', __('CKEditor - plugin settings initialized.')); } if (!defined('USE_MOD_REWRITE') || !USE_MOD_REWRITE) { Flash::set('info', __('FileManager will not ne ebabled if "MOD_REWRITE" is set to false')); } else { Flash::setNow('error', __('CKEditor - unable to store plugin settings!')); }
public function settings() { $this->display('easysnippet/views/settings', Plugin::getAllSettings('easysnippet')); }
<?php $settings = Plugin::getAllSettings('ssp'); ?> <h1>Slideshow Pro Admin</h1> <iframe name="ssp_admin" id="frame" style="width: calc(100% + 20px);min-width: 100%;min-height: 860px;float: left;margin-left: -20px;" ></iframe> <form id="ssp_login" target="ssp_admin" method="post" action="/slideshowpro/index.php?/users/login"> <input type="hidden" name="data[User][usr]" value="<?php echo $settings['ssp_username']; ?> " /> <input type="hidden" name="data[User][pwd]" value="<?php echo $settings['ssp_password']; ?> " /> </form> <script type="text/javascript"> document.getElementById('ssp_login').submit(); </script>
function settings() { $this->display('multi_lang/views/settings', array('settings' => Plugin::getAllSettings('multi_lang'))); }
function settings() { $this->display('fancy_image_gallery/views/settings', Plugin::getAllSettings('fancy_image_gallery')); }
function _restore($fileData) { global $__CMS_CONN__; $settings = Plugin::getAllSettings('backup_restore'); // All of the tablesnames that belong to Wolf CMS core. $tablenames = array(); if (strpos(DB_DSN, 'mysql') !== false) { $sql = 'show tables'; } if (strpos(DB_DSN, 'sqlite') !== false) { $sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table" ORDER BY name'; } if (strpos(DB_DSN, 'pgsql') !== false) { $sql = "select tablename from pg_tables where schemaname='public'"; } Record::logQuery($sql); $pdo = Record::getConnection(); $result = $pdo->query($sql); while ($col = $result->fetchColumn()) { $tablenames[] = $col; } // All fields that should be wrapped as CDATA $cdata_fields = array('title', 'content', 'content_html'); $xml = simplexml_load_string($fileData); if (false === $xml) { $errors = ''; foreach (libxml_get_errors() as $error) { $errors .= $error->message; $errors .= "<br/>\n"; } Flash::set('error', 'An error occurred with the XML backup file: :error', array(':error' => $errors)); redirect(get_url('plugin/backup_restore')); } // Import each table and table entry foreach ($tablenames as $tablename) { $container = $tablename . 's'; if (array_key_exists($container, $xml) && count($xml->{$container}->{$tablename}) > 0) { if (strpos(DB_DSN, 'sqlite') !== false) { $sql = 'DELETE FROM ' . $tablename; } else { $sql = 'TRUNCATE ' . $tablename; } Record::logQuery($sql); if (false === $__CMS_CONN__->exec($sql)) { Flash::set('error', __('Unable to truncate current table :tablename.', array(':tablename' => $tablename))); redirect(get_url('plugin/backup_restore')); } foreach ($xml->{$container}->{$tablename} as $element) { $keys = array(); $values = array(); $delete_salt = false; foreach ($element as $key => $value) { $keys[] = $key; if ($key === 'password' && empty($value)) { $delete_salt = true; if (isset($settings['default_pwd']) && $settings['default_pwd'] !== '') { $value = sha1($settings['default_pwd']); } else { $value = sha1('pswpsw123'); } $values[] = $__CMS_CONN__->quote($value); } else { $attributes = (array) $value->attributes(); $values[] = (isset($attributes['@attributes']) and $attributes['@attributes']['null']) ? 'NULL' : $__CMS_CONN__->quote($value); } } if ($delete_salt and isset($keys['salt'])) { unset($keys['salt']); } $sql = 'INSERT INTO ' . $tablename . ' (' . join(', ', $keys) . ') VALUES (' . join(', ', $values) . ')' . "\r"; if ($__CMS_CONN__->exec($sql) === false) { Flash::set('error', __('Unable to reconstruct table :tablename.', array(':tablename' => $tablename))); redirect(get_url('plugin/backup_restore')); } } } } // Erase all uploaded files? if ($settings['erasefiles'] == '1') { $this->_cleanup_directory(realpath(FILES_DIR)); } // Restore directories and files from XML if ($settings['restorefiles'] == '1' && array_key_exists('files', $xml)) { // First directories foreach ($xml->files->directory as $obj) { $name = realpath(FILES_DIR) . '/' . $obj->name; if (!file_exists($name)) { if (mkdir($name, 0777, true) === false) { Flash::set('error', __('Unable to create directory :name.', array(':name' => dirname($obj->name)))); redirect(get_url('plugin/backup_restore')); } } $this->_restore_attributes($name, $obj); } // Then files foreach ($xml->files->file as $obj) { $name = realpath(FILES_DIR) . '/' . $obj->name; if (file_put_contents($name, base64_decode($obj->content)) === false) { Flash::set('error', __('Unable to restore file :name.', array(':name' => $obj->name))); redirect(get_url('plugin/backup_restore')); } $this->_restore_attributes($name, $obj); } } Flash::set('success', __('Succesfully restored backup.')); redirect(get_url('plugin/backup_restore')); }
function _restore($fileData) { global $__CMS_CONN__; $settings = Plugin::getAllSettings('backup_restore'); // All of the tablesnames that belong to Wolf CMS core. $tablenames = array(); if (strpos(DB_DSN, 'mysql') !== false) { $sql = 'show tables'; } if (strpos(DB_DSN, 'sqlite') !== false) { $sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table" ORDER BY name'; } if (strpos(DB_DSN, 'pgsql') !== false) { $sql = "select tablename from pg_tables where schemaname='public'"; } $pdo = Record::getConnection(); $result = $pdo->query($sql); while ($col = $result->fetchColumn()) { $tablenames[] = $col; } // All fields that should be wrapped as CDATA $cdata_fields = array('content', 'content_html'); $xml = simplexml_load_string($fileData); if (false === $xml) { $errors = ''; foreach (libxml_get_errors() as $error) { $errors .= $error->message; $errors .= "<br/>\n"; } Flash::set('error', 'An error occurred with the XML backup file: :error', array(':error' => $errors)); redirect(get_url('plugin/backup_restore')); } // Import each table and table entry foreach ($tablenames as $tablename) { $container = $tablename . 's'; if (array_key_exists($container, $xml) && count($xml->{$container}->{$tablename}) > 0) { if (strpos(DB_DSN, 'sqlite') !== false) { $sql = 'DELETE FROM ' . TABLE_PREFIX . $tablename; } else { $sql = 'TRUNCATE ' . TABLE_PREFIX . $tablename; } if (false === $__CMS_CONN__->exec($sql)) { Flash::set('error', __('Unable to truncate current table :tablename.', array(':tablename' => TABLE_PREFIX . $tablename))); redirect(get_url('plugin/backup_restore')); } foreach ($xml->{$container}->{$tablename} as $element) { $keys = array(); $values = array(); foreach ($element as $key => $value) { if ($key === 'password' && (!isset($value) || empty($value) || $value === '' || $value === null)) { if (isset($settings['default_pwd']) && $settings['default_pwd'] !== '') { $value = sha1($settings['default_pwd']); } else { $value = sha1('pswpsw123'); } } $keys[] = $key; $values[] = $__CMS_CONN__->quote($value); } $sql = 'INSERT INTO ' . TABLE_PREFIX . $tablename . ' (' . join(', ', $keys) . ') VALUES (' . join(', ', $values) . ')' . "\r"; if ($__CMS_CONN__->exec($sql) === false) { Flash::set('error', __('Unable to reconstruct table :tablename.', array(':tablename' => TABLE_PREFIX . $tablename))); redirect(get_url('plugin/backup_restore')); } } } } Flash::set('success', __('Succesfully restored backup.')); redirect(get_url('plugin/backup_restore')); }
public function settings() { AuthUser::load(); if (!AuthUser::isLoggedIn()) { redirect(get_url('login')); } else { if (!AuthUser::hasPermission('admin_edit')) { Flash::set('error', __('You do not have permission to access the requested page!')); redirect(get_url()); } } $settings = Plugin::getAllSettings('file_manager'); if (!$settings) { Flash::set('error', 'Files - ' . __('unable to retrieve plugin settings.')); return; } $this->display('file_manager/views/settings', array('settings' => $settings)); }
function settings() { $tmp = Plugin::getAllSettings('comment'); $settings = array('approve' => $tmp['auto_approve_comment'], 'captcha' => $tmp['use_captcha'], 'rowspage' => $tmp['rowspage'], 'numlabel' => $tmp['numlabel']); $this->display('comment/views/settings', $settings); }
* This file is part of Wolf CMS. Wolf CMS is licensed under the GNU GPLv3 license. * Please see license.txt for the full license text. */ /* Security measure */ if (!defined('IN_CMS')) { exit; } /** * The FileManager allows users to upload and manipulate files. * * Note - Mostly rewritten since Wolf CMS 0.6.0 * * @package Plugins * @subpackage file_manager * * @author Martijn van der Kleijn <*****@*****.**> * @copyright Martijn van der Kleijn, 2008-2010 * @license http://www.gnu.org/licenses/gpl.html GPLv3 license * * @todo Starting from PHP 5.3, use FileInfo */ // check for settings $settings = Plugin::getAllSettings('file_manager'); // merge settings $settings = array('umask' => isset($settings['umask']) ? $settings['umask'] : '0022', 'dirmode' => isset($settings['dirmode']) ? $settings['dirmode'] : '0755', 'filemode' => isset($settings['filemode']) ? $settings['filemode'] : '0644', 'show_hidden' => isset($settings['show_hidden']) ? $settings['show_hidden'] : '0', 'show_backups' => isset($settings['show_backups']) ? $settings['show_backups'] : '1'); // flash message if (Plugin::setAllSettings($settings, 'file_manager')) { Flash::set('success', 'File Manager - ' . __('plugin settings initialized.')); } else { Flash::set('error', 'File Manager - ' . __('unable to store plugin settings!')); }
function settings() { $this->display('ckeditor/views/settings', Plugin::getAllSettings('ckeditor')); }
/** * Settings for Tagger to change specific features * * @since 1.1.0 * */ public function settings() { $tmp = Plugin::getAllSettings('tagger'); $settings = array('tag_type' => $tmp['tag_type'], 'case' => $tmp['case'], 'rowspage' => $tmp['rowspage'], 'sort_field' => $tmp['sort_field'], 'sort_order' => $tmp['sort_order']); $this->display('tagger/views/settings', $settings); }
public static function getWidgetSettings($widget) { if (!array_key_exists($widget, self::$widgets)) { return false; } $widget = self::$widgets[$widget]; if (!isset($widget["settings"])) { return array(); } $settings = Plugin::getAllSettings("dashboard-" . $widget["id"]); return array_merge((array) $widget["settings"], (array) $settings); }
function validateaccount($email, $rand_key_confirm) { $rand_key = $rand_key_confirm; $PDO = Record::getConnection(); $check_validated = "SELECT * FROM " . TABLE_PREFIX . "user WHERE email='{$email}'"; $result = $PDO->prepare($check_validated); $result->execute(); $count = $result->rowCount(); if ($count > 0) { $settings = Plugin::getAllSettings("registered_users"); $met = $settings["message_error_technical"]; $message_empty_name = $settings["message_empty_name"]; $message_empty_email = $settings["message_empty_email"]; $message_empty_username = $settings["message_empty_username"]; $message_empty_password = $settings["message_empty_password"]; $message_empty_password_confirm = $settings["message_empty_password_confirm"]; $message_notvalid_password = $settings["message_notvalid_password"]; $message_notvalid_username = $settings["message_notvalid_username"]; $message_notvalid_email = $settings["message_notvalid_email"]; $message_error_already_validated = $settings["message_error_already_validated"]; echo $message_error_already_validated; } else { $today = date('Y-m-d G:i:s'); $registration_temp = "SELECT * FROM " . TABLE_PREFIX . "registered_users_temp WHERE email='{$email}'"; foreach ($PDO->query($registration_temp) as $row) { $name = $row['name']; $email = $row['email']; $username = $row['username']; $password = $row['password']; $rand_key = $row['rand_key']; $reg_date = $row['reg_date']; $welcome_message = $row['welcome_message']; $message_notvalid_password = $row['message_notvalid_password']; } if ($rand_key_confirm == $rand_key) { // Let's transfer the user from the temp table to the user table //$update_user_table = "INSERT INTO ".TABLE_PREFIX."user (`id`,`name`,`email`,`username`,`password`,`created_on`,`updated_on`,`created_by_id`,`updated_by_id`) VALUES ('','$name','$email','$username','$password','$reg_date','$today','','');"; //$stmt = $__CMS_CONN__->prepare($update_user_table); //$stmt->execute(); $user = new User(); $user->name = $name; $user->email = $email; $user->username = $username; $user->salt = AuthUser::generateSalt(); $user->password = AuthUser::generateHashedPassword($password, $user->salt); $user->created_on = $reg_date; $user->updated_on = $today; $user->save(); // We don't need them in the temp table anymore $delete_temp_user = "******" . TABLE_PREFIX . "registered_users_temp WHERE email='{$email}'"; $stmt = $PDO->prepare($delete_temp_user); $stmt->execute(); // And let's make sure we have some permissions set so that user can then do something! // First we need the default permssion ID $def_permission = Plugin::getSetting("default_permissions", "registered_users"); // Then we need the correct user ID /*$user = "******".TABLE_PREFIX."user WHERE email='$email'"; foreach ($__CMS_CONN__->query($user) as $row) { $id = $row['id']; }*/ $id = $user->id; $set_permissions = "INSERT INTO " . TABLE_PREFIX . "user_role (`user_id`,`role_id`) VALUES ('{$id}','{$permission_id}');"; $stmt = $PDO->prepare($set_permissions); $stmt->execute(); // We also need to add the profile settings into DB $addprofile = "INSERT INTO " . TABLE_PREFIX . "user_profile (`id`,`firstlogin`,`subscribe`,`sysnotifications`,`haspic`,`profile_blurb`) VALUES ({$id},'1','1','1','0','your public profile...');"; $addprofile = $PDO->prepare($addprofile); $addprofile->execute(); echo $welcome_message; $loadloginclass = new RegisteredUser(); $loadloginclass->login_page(); } else { echo $message_notvalid_password; } } }
} else { $settings = array('version' => '3.5.0', 'listpublished' => 1, 'listhidden' => 0, 'imagesdir' => '/home/user/www/public/images', 'imagesuri' => '/public/images', 'cssuri' => '/public/themes/mylayout/mystylesheet.css', 'tb_obfuscate' => 'sukthvgnhgliuhgldutnvlru', 'tb_docroot' => '/var/www', 'tb_unixpermissions' => 0755, 'tb_imagepath' => '/wolfcms/public/images/', 'tb_mediapath' => '/wolfcms/public/media/', 'tb_filepath' => '/wolfcms/public/files/', 'tb_maximagesize' => '0', 'tb_maxmediasize' => '0', 'tb_maxfilesize' => '0', 'tb_autoresizewidth' => '0', 'tb_autoresizeheight' => '0', 'tb_thumbsize' => '80', 'tb_imagequality' => '80', 'tb_thumbquality' => '80', 'tb_allowedimagestypes' => '*.jpg, *.jpeg, *.gif, *.png', 'tb_allowedmediatypes' => '*.swf, *.dcr, *.mov, *.qt, *.mpg, *.mp3, *.mp4, *.mpeg, *.avi, *.wmv, *.wm, *.asf, *.asx, *.wmx, *.wvx, *.rm, *.ra, *.ram', 'tb_allowedfiletypes' => '*.*'); } // Store settings. if (Plugin::setAllSettings($settings, 'tinymce')) { if ($upgrade) { Flash::set('success', __('TinyMCE - plugin settings copied from old installation.')); } else { Flash::set('success', __('TinyMCE - plugin settings initialized.')); } } else { Flash::set('error', __('TinyMCE - unable to store plugin settings!')); } } else { // Found an old post-2.0.0 RC1 install $settings = Plugin::getAllSettings('tinymce'); $settings = array('version' => '3.5.0', 'tb_obfuscate' => 'sukthvgnhgliuhgldutnvlru', 'tb_docroot' => '/var/www', 'tb_unixpermissions' => '0755', 'tb_imagepath' => '/wolfcms/public/images/', 'tb_mediapath' => '/wolfcms/public/media/', 'tb_filepath' => '/wolfcms/public/files/', 'tb_maximagesize' => '0', 'tb_maxmediasize' => '0', 'tb_maxfilesize' => '0', 'tb_autoresizewidth' => '0', 'tb_autoresizeheight' => '0', 'tb_thumbsize' => '80', 'tb_imagequality' => '80', 'tb_thumbquality' => '80', 'tb_allowedimagestypes' => '*.jpg, *.jpeg, *.gif, *.png', 'tb_allowedmediatypes' => '*.swf, *.dcr, *.mov, *.qt, *.mpg, *.mp3, *.mp4, *.mpeg, *.avi, *.wmv, *.wm, *.asf, *.asx, *.wmx, *.wvx, *.rm, *.ra, *.ram', 'tb_allowedfiletypes' => '*.*'); // Store settings. if (Plugin::setAllSettings($settings, 'tinymce')) { Flash::set('success', __('TinyMCE - plugin settings updated.')); } else { Flash::set('error', __('TinyMCE - unable to store plugin settings!')); } } /** * This function checks to see if there is a valid old installation with regards to the DB. * * @return boolean */ function checkForOldInstall() {
function settings() { $settings = Plugin::getAllSettings('funky_cache'); $this->display('funky_cache/views/settings', array('funky_cache_by_default' => $settings['funky_cache_by_default'], 'funky_cache_suffix' => $settings['funky_cache_suffix'], 'funky_cache_folder' => $settings['funky_cache_folder'])); }
function _restore($fileData) { global $__CMS_CONN__; $settings = Plugin::getAllSettings('backup_restore'); // All of the tablesnames that belong to Fresh CMS core. $tablenames = array('layout', 'page', 'page_part', 'page_tag', 'permission', 'plugin_settings', 'setting', 'snippet', 'tag', 'user', 'user_permission'); // All fields that should be wrapped as CDATA $cdata_fields = array('content', 'content_html'); $xml = simplexml_load_string($fileData); if (false === $xml) { $errors = ''; foreach (libxml_get_errors() as $error) { $errors .= $error->message; $errors .= "<br/>\n"; } Flash::set('error', 'An error occurred with the XML backup file: :error', array(':error' => $errors)); redirect(get_url('plugin/backup_restore')); } // Import each table and table entry foreach ($tablenames as $tablename) { $container = $tablename . 's'; if (array_key_exists($container, $xml) && count($xml->{$container}->{$tablename}) > 0) { if (false === $__CMS_CONN__->exec('TRUNCATE ' . TABLE_PREFIX . $tablename)) { Flash::set('error', __('Unable to truncate current table :tablename.', array(':tablename' => TABLE_PREFIX . $tablename))); redirect(get_url('plugin/backup_restore')); } foreach ($xml->{$container}->{$tablename} as $element) { $keys = array(); $values = array(); foreach ($element as $key => $value) { if ($key === 'password' && (!isset($value) || empty($value) || $value === '' || $value === null)) { if (isset($settings['default_pwd']) && $settings['default_pwd'] !== '') { $value = sha1($settings['default_pwd']); } else { $value = sha1('pswpsw123'); } } $keys[] = $key; $values[] = $__CMS_CONN__->quote($value); } $sql = 'INSERT INTO ' . TABLE_PREFIX . $tablename . ' (' . join(', ', $keys) . ') VALUES (' . join(', ', $values) . ')' . "\r"; if ($__CMS_CONN__->exec($sql) === false) { Flash::set('error', __('Unable to reconstruct table :tablename.', array(':tablename' => TABLE_PREFIX . $tablename))); redirect(get_url('plugin/backup_restore')); } } } } Flash::set('success', __('Succesfully restored backup.')); redirect(get_url('plugin/backup_restore')); }