function hmbkp_display_error_and_offer_to_email_it() { check_ajax_referer('hmbkp_nonce', 'nonce'); if (empty($_POST['hmbkp_error'])) { die; } $errors = explode("\n", wp_strip_all_tags(stripslashes($_POST['hmbkp_error']))); HMBKP_Notices::get_instance()->set_notices('backup_errors', $errors); wp_send_json_success(wp_get_referer()); }
function hmbkp_set_server_config_notices() { $notices = HMBKP_Notices::get_instance(); $messages = array(); if (!HM_Backup::is_shell_exec_available()) { $php_user = '******'; $php_group = '<PHP GROUP>'; } else { $php_user = shell_exec('whoami'); $groups = explode(' ', shell_exec('groups')); $php_group = reset($groups); } if (!is_dir(hmbkp_path())) { $messages[] = sprintf(__('The backups directory can\'t be created because your %1$s directory isn\'t writable, run %2$s or %3$s or create the folder yourself.', 'backupwordpress'), '<code>' . esc_html(dirname(hmbkp_path())) . '</code>', '<code>chown ' . esc_html($php_user) . ':' . esc_html($php_group) . ' ' . esc_html(dirname(hmbkp_path())) . '</code>', '<code>chmod 777 ' . esc_html(dirname(hmbkp_path())) . '</code>'); } if (is_dir(hmbkp_path()) && !wp_is_writable(hmbkp_path())) { $messages[] = sprintf(__('Your backups directory isn\'t writable, run %1$s or %2$s or set the permissions yourself.', 'backupwordpress'), '<code>chown -R ' . esc_html($php_user) . ':' . esc_html($php_group) . ' ' . esc_html(hmbkp_path()) . '</code>', '<code>chmod -R 777 ' . esc_html(hmbkp_path()) . '</code>'); } if (HM_Backup::is_safe_mode_active()) { $messages[] = sprintf(__('%1$s is running in %2$s, please contact your host and ask them to disable it. BackUpWordPress may not work correctly whilst %3$s is on.', 'backupwordpress'), '<code>PHP</code>', sprintf('<a href="%1$s">%2$s</a>', __('http://php.net/manual/en/features.safe-mode.php', 'backupwordpress'), __('Safe Mode', 'backupwordpress')), '<code>' . __('Safe Mode', 'backupwordpress') . '</code>'); } if (defined('HMBKP_PATH') && HMBKP_PATH) { // Suppress open_basedir warning https://bugs.php.net/bug.php?id=53041 if (!@file_exists(HMBKP_PATH)) { $messages[] = sprintf(__('Your custom path does not exist', 'backupwordpress')); } elseif (hmbkp_is_restricted_custom_path()) { $messages[] = sprintf(__('Your custom path is unreachable due to a restriction set in your PHP configuration (open_basedir)', 'backupwordpress')); } else { if (!@is_dir(HMBKP_PATH)) { $messages[] = sprintf(__('Your custom backups directory %1$s doesn\'t exist and can\'t be created, your backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>'); } if (@is_dir(HMBKP_PATH) && !wp_is_writable(HMBKP_PATH)) { $messages[] = sprintf(__('Your custom backups directory %1$s isn\'t writable, new backups will be saved to %2$s instead.', 'backupwordpress'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>'); } } } $test_backup = new HMBKP_Scheduled_Backup('test_backup'); if (!is_readable($test_backup->get_root())) { $messages[] = sprintf(__('Your site root path %s isn\'t readable.', 'backupwordpress'), '<code>' . $test_backup->get_root() . '</code>'); } if (count($messages) > 0) { $notices->set_notices('server_config', $messages, false); } }