function mc_write_styles($stylefile, $my_calendar_style) { if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT == true) { return false; } $standard = dirname(__FILE__) . '/styles/'; $files = my_csslist($standard); foreach ($files as $file) { $filepath = mc_get_style_path($file); $path = pathinfo($filepath); if ($path['extension'] == 'css') { $styles_whitelist[] = $filepath; } } if (in_array($stylefile, $styles_whitelist)) { if (function_exists('wp_is_writable')) { $is_writable = wp_is_writable($stylefile); } else { $is_writable = is_writeable($stylefile); } if ($is_writable) { $f = fopen($stylefile, 'w+'); fwrite($f, $my_calendar_style); // number of bytes to write, max. fclose($f); return true; } else { return false; } } return false; }
/** * Creates blank index.php and .htaccess files * * This function runs approximately once per month in order to ensure all folders * have their necessary protection files * * @since 1.1.5 * * @param bool $force * @param bool $method */ function edd_create_protection_files($force = false, $method = false) { if (false === get_transient('edd_check_protection_files') || $force) { $upload_path = edd_get_upload_dir(); // Make sure the /edd folder is created wp_mkdir_p($upload_path); // Top level .htaccess file $rules = edd_get_htaccess_rules($method); if (edd_htaccess_exists()) { $contents = @file_get_contents($upload_path . '/.htaccess'); if ($contents !== $rules || !$contents) { // Update the .htaccess rules if they don't match @file_put_contents($upload_path . '/.htaccess', $rules); } } elseif (wp_is_writable($upload_path)) { // Create the file if it doesn't exist @file_put_contents($upload_path . '/.htaccess', $rules); } // Top level blank index.php if (!file_exists($upload_path . '/index.php') && wp_is_writable($upload_path)) { @file_put_contents($upload_path . '/index.php', '<?php' . PHP_EOL . '// Silence is golden.'); } // Now place index.php files in all sub folders $folders = edd_scan_folders($upload_path); foreach ($folders as $folder) { // Create index.php, if it doesn't exist if (!file_exists($folder . 'index.php') && wp_is_writable($folder)) { @file_put_contents($folder . 'index.php', '<?php' . PHP_EOL . '// Silence is golden.'); } } // Check for the files once per day set_transient('edd_check_protection_files', true, 3600 * 24); } }
public function update() { if (!$this->is_build_with_elementor()) { return; } $this->parse_elements_css(); $meta = ['version' => ELEMENTOR_VERSION, 'time' => time(), 'fonts' => array_unique($this->fonts)]; if (empty($this->css)) { $this->delete(); $meta['status'] = self::CSS_STATUS_EMPTY; $meta['css'] = ''; } else { $file_created = false; if (wp_is_writable(dirname($this->path))) { $file_created = file_put_contents($this->path, $this->css); } if ($file_created) { $meta['status'] = self::CSS_STATUS_FILE; } else { $meta['status'] = self::CSS_STATUS_INLINE; $meta['css'] = $this->css; } } $this->update_meta($meta); }
/** * Admin Messages * * @since 1.0 * @global $wpum_options Array of all the WPUM Options * @return void */ function wpum_admin_messages() { global $wpum_options; $screen = get_current_screen(); if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true && !wpum_get_option('custom_passwords') && wpum_get_option('password_strength')) { add_settings_error('wpum-notices', 'custom-passwords-disabled', __('You have enabled the "Minimum Password Strength" option, the "Users custom passwords" is currently disabled and must be enabled for custom passwords to work.', 'wpum'), 'error'); } if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == true && !wpum_get_option('custom_passwords') && wpum_get_option('login_after_registration')) { add_settings_error('wpum-notices', 'custom-passwords-disabled', __('Error: the option "Login after registration" can only work when the option "Users custom passwords" is enabled too.', 'wpum'), 'error'); } if (isset($_GET['emails-updated']) && $_GET['emails-updated'] == true) { add_settings_error('wpum-notices', 'emails-updated', __('Email successfully updated.', 'wpum'), 'updated'); } // Display Errors in plugin settings page if ($screen->base == 'users_page_wpum-settings') { // Display error if no core page is setup if (!wpum_get_option('login_page') || !wpum_get_option('password_recovery_page') || !wpum_get_option('registration_page') || !wpum_get_option('account_page') || !wpum_get_option('profile_page')) { add_settings_error('wpum-notices', 'page-missing', __('One or more WPUM pages are not configured.', 'wpum') . ' ' . sprintf(__('<a href="%s" class="button-primary">Click here to setup your pages</a>', 'wpum'), admin_url('users.php?page=wpum-settings&tab=general&wpum_action=install_pages')), 'error'); } // Display error if wrong permalinks if (get_option('permalink_structure') == '') { add_settings_error('wpum-notices', 'permalink-wrong', sprintf(__('You must <a href="%s">change your permalinks</a> to anything else other than "default" for profiles to work.', 'wpum'), admin_url('options-permalink.php')), 'error'); } if (isset($_GET['setup_done']) && $_GET['setup_done'] == 'true') { add_settings_error('wpum-notices', 'pages-updated', __('Pages setup completed.', 'wpum'), 'updated'); } if (isset($_GET['message']) && $_GET['message'] == 'fields_fixed') { add_settings_error('wpum-notices', 'fields_fixed', __('Fields successfully fixed.', 'wpum'), 'updated'); } } // Verify if upload folder is writable if (isset($_GET['wpum_action']) && $_GET['wpum_action'] == 'check_folder_permission') { $upload_dir = wp_upload_dir(); if (!wp_is_writable($upload_dir['path'])) { add_settings_error('wpum-notices', 'permission-error', sprintf(__('Your uploads folder in "%s" is not writable. <br/>Avatar uploads will not work, please adjust folder permission.<br/><br/> <a href="%s" class="button" target="_blank">Read More</a>', 'wpum'), $upload_dir['basedir'], 'http://www.wpbeginner.com/wp-tutorials/how-to-fix-image-upload-issue-in-wordpress/'), 'error'); } else { add_settings_error('wpum-notices', 'permission-success', sprintf(__('No issues detected.', 'wpum'), admin_url('users.php?page=wpum-settings&tab=profile')), 'updated notice is-dismissible'); } } // messages for the groups and fields pages if ($screen->base == 'users_page_wpum-profile-fields') { if (isset($_GET['message']) && $_GET['message'] == 'group_success') { add_settings_error('wpum-notices', 'group-updated', __('Field group successfully updated.', 'wpum'), 'updated'); } if (isset($_GET['message']) && $_GET['message'] == 'group_delete_success') { add_settings_error('wpum-notices', 'group-deleted', __('Field group successfully deleted.', 'wpum'), 'updated'); } if (isset($_GET['message']) && $_GET['message'] == 'field_saved') { add_settings_error('wpum-notices', 'field-saved', __('Field successfully updated.', 'wpum'), 'updated'); } } // messages for tools page if ($screen->base == 'users_page_wpum-tools') { if (isset($_GET['message']) && $_GET['message'] == 'settings_imported') { add_settings_error('wpum-notices', 'settings-imported', __('Settings successfully imported.', 'wpum'), 'updated'); } } settings_errors('wpum-notices'); }
/** * If the default path is unwritable then it should fallback to the fallback path */ public function testFallbackPath() { $this->assertEquals($this->path->get_default_path(), $this->path->get_path()); if (wp_is_writable($this->path->get_default_path())) { $this->markTestSkipped('The default path was still writable'); } $this->path->calculate_path(); $this->assertEquals($this->path->get_path(), $this->path->get_fallback_path()); $this->assertFileExists($this->path->get_fallback_path()); }
private function delete_report($filename) { if (!empty($filename) && !is_string($filename)) { return new WP_Error('invalid-argument', 'The delete-report function takes a string representing an individual report.'); } $upload_path = Ithemes_Sync_Functions::get_upload_reports_dir(); if (!empty($upload_path) && wp_is_writable($upload_path)) { @unlink($upload_path . '/' . $filename); return true; } return false; }
public function can_fix() { if (GRAV_TESTS::is_editable()) { $path = $this->get_wp_config_path(); if ($path && wp_is_writable($path)) { if ($contents = file_get_contents($path)) { $contents = GRAV_TESTS::remove_comments($contents); if (preg_match('/define[^;]*WP_DEBUG.*(true|TRUE)[^;]*/s', $contents, $matches)) { return true; } } } } return false; }
function themeton_less_mkdir() { $upload_dir = wp_upload_dir(); if (wp_is_writable($upload_dir['basedir'])) { $dir = 'themeton'; $path = trailingslashit($upload_dir['basedir']) . $dir; if (!@is_dir($path)) { if (wp_mkdir_p($path)) { return $path; } } else { return $path; } } return false; }
function mc_write_styles($stylefile, $my_calendar_style) { if (function_exists('wp_is_writable')) { $is_writable = wp_is_writable($stylefile); } else { $is_writable = is_writeable($stylefile); } if ($is_writable) { $f = fopen($stylefile, 'w+'); fwrite($f, $my_calendar_style); // number of bytes to write, max. fclose($f); return true; } else { return false; } }
function wpcf7_cleanup_upload_files() { $dir = trailingslashit(wpcf7_upload_tmp_dir()); if (!is_dir($dir)) { return false; } if (!is_readable($dir)) { return false; } if (!wp_is_writable($dir)) { return false; } if ($handle = @opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file == "." || $file == ".." || $file == ".htaccess") { continue; } $stat = stat($dir . $file); if ($stat['mtime'] + 60 < time()) { // 60 secs @unlink($dir . $file); } } closedir($handle); } }
function wpcf7_cleanup_captcha_files() { if (!($captcha = wpcf7_init_captcha())) { return false; } if (is_callable(array($captcha, 'cleanup'))) { return $captcha->cleanup(); } $dir = trailingslashit(wpcf7_captcha_tmp_dir()); if (!is_dir($dir) || !is_readable($dir) || !wp_is_writable($dir)) { return false; } if ($handle = @opendir($dir)) { while (false !== ($file = readdir($handle))) { if (!preg_match('/^[0-9]+\\.(php|txt|png|gif|jpeg)$/', $file)) { continue; } $stat = @stat($dir . $file); if ($stat['mtime'] + 3600 < time()) { // 3600 secs == 1 hour @unlink($dir . $file); } } closedir($handle); } }
function wpcf7_cleanup_upload_files() { if (is_admin() || 'GET' != $_SERVER['REQUEST_METHOD'] || is_robots() || is_feed() || is_trackback()) { return; } $dir = trailingslashit(wpcf7_upload_tmp_dir()); if (!is_dir($dir) || !is_readable($dir) || !wp_is_writable($dir)) { return; } if ($handle = @opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file == "." || $file == ".." || $file == ".htaccess") { continue; } $mtime = @filemtime($dir . $file); if ($mtime && time() < $mtime + 60) { // less than 60 secs old continue; } wpcf7_rmdir_p(path_join($dir, $file)); } closedir($handle); } }
/** * Create json cloning_details.json after activation of the plugin * * @return bool */ function wpstg_create_clonedetails_files() { $path = wpstg_get_upload_dir(); if (wp_is_writable($path)) { $file = 'clone_details.json'; file_put_contents($path . '/' . $file, null); } else { WPSTG()->logger->info($path . '/' . $file . ' is not writeable! '); } }
function rs_wpss_log_reset($admin_ips = NULL, $get_fws = FALSE, $clr_hta = FALSE, $mk_log = FALSE) { /*** * $ip - Optional * $get_fws - File writeable status - returns bool * $clr_hta - Reset .htaccess only, don't reset log * $mk_log - Make log log file if none exists ***/ $admin_ips = !empty($admin_ips) && is_array($admin_ips) ? $admin_ips : get_option('spamshield_admins'); $admin_ips = rs_wpss_remove_expired_admins($admin_ips); if (!empty($admin_ips) && is_array($admin_ips)) { $admin_ips = array_map('intval', $admin_ips); $admin_ips = rs_wpss_sort_unique(array_flip($admin_ips)); } elseif (rs_wpss_is_user_admin()) { $current_ip = rs_wpss_get_ip_addr(); rs_wpss_update_user_ip(NULL, TRUE, $admin_ips); if (rs_wpss_is_valid_ip($current_ip)) { $admin_ips = (array) $current_ip; } } if (empty($admin_ips) || !is_array($admin_ips)) { $last_admin_ip = get_option('spamshield_last_admin'); if (!empty($last_admin_ip) && rs_wpss_is_valid_ip($last_admin_ip)) { $admin_ips = (array) $last_admin_ip; } } $wpss_log_key = rs_wpss_get_log_key(); $wpss_log_key_uc = rs_wpss_casetrans('upper', $wpss_log_key); $wpss_log_filnm = strpos(WPSS_SERVER_NAME_REV, WPSS_MDBUG_SERVER_NAME_REV) === 0 ? 'temp-comments-log.txt' : 'temp-comments-log-' . $wpss_log_key . '.txt'; $wpss_log_filns = array('', $wpss_log_filnm, 'temp-comments-log.init.txt', '.htaccess', 'htaccess.txt', 'htaccess.init.txt'); /* Filenames - log, log_empty, htaccess, htaccess,_orig, htaccess_empty */ $wpss_log_perlr = array(0775, 0664, 0664, 0664, 0664, 0664); /* Permission level recommended */ $wpss_log_perlm = array(0755, 0644, 0644, 0644, 0644, 0644); /* Permission level minimum */ $wpss_log_files = array(); /* Log files with full paths */ foreach ($wpss_log_filns as $f => $filn) { $wpss_log_files[] = WPSS_PLUGIN_DATA_PATH . '/' . $filn; } /* 1 - Create temp-comments-log-{random hash}.txt if it doesn't exist */ clearstatcache(); if (!file_exists($wpss_log_files[1])) { @chmod($wpss_log_files[2], 0664); @copy($wpss_log_files[2], $wpss_log_files[1]); @chmod($wpss_log_files[1], 0664); } if (!empty($mk_log)) { return FALSE; } /* 2 - Create .htaccess if it doesn't exist */ clearstatcache(); if (!file_exists($wpss_log_files[3])) { @chmod($wpss_log_files[0], 0775); @chmod($wpss_log_files[4], 0664); @chmod($wpss_log_files[5], 0664); @rename($wpss_log_files[4], $wpss_log_files[3]); @copy($wpss_log_files[5], $wpss_log_files[4]); foreach ($wpss_log_files as $f => $file) { @chmod($file, $wpss_log_perlr[$f]); } } /* 3 - Check file permissions and fix */ clearstatcache(); $wpss_log_perms = array(); /* File permissions */ foreach ($wpss_log_files as $f => $file) { $wpss_log_perms[] = substr(sprintf('%o', fileperms($file)), -4); } foreach ($wpss_log_perlr as $p => $perlr) { if ($wpss_log_perms[$p] < $perlr || !wp_is_writable($wpss_log_files[$p])) { foreach ($wpss_log_files as $f => $file) { @chmod($file, $wpss_log_perlr[$f]); } /* Correct the permissions... */ break; } } /* 4 - Clear files by copying fresh versions to existing files */ if (empty($clr_hta)) { if (file_exists($wpss_log_files[1]) && file_exists($wpss_log_files[2])) { @copy($wpss_log_files[2], $wpss_log_files[1]); } /* Log file */ } if (file_exists($wpss_log_files[3]) && file_exists($wpss_log_files[5])) { @copy($wpss_log_files[5], $wpss_log_files[3]); } /* .htaccess file */ /* 5 - Write .htaccess */ $wpss_htaccess_data = $wpss_access_ap22 = ''; $wpss_access_ap24 = 'Require all denied' . WPSS_EOL; if (!empty($admin_ips) && is_array($admin_ips)) { $ip_rgx = '^(' . str_replace(array('.', ':'), array('\\.', '\\:'), implode('|', $admin_ips)) . ')$'; $wpss_htaccess_data .= '<IfModule mod_setenvif.c>' . WPSS_EOL . "\t" . 'SetEnvIf Remote_Addr ' . $ip_rgx . ' WPSS_ACCESS_' . $wpss_log_key_uc . WPSS_EOL . '</IfModule>' . WPSS_EOL . WPSS_EOL; $wpss_access_ap22 = "\t\t" . 'Allow from env=WPSS_ACCESS_' . $wpss_log_key_uc . WPSS_EOL; $wpss_access_ap24 = 'Require env WPSS_ACCESS_' . $wpss_log_key_uc . WPSS_EOL; } $wpss_htaccess_data .= '<Files ' . $wpss_log_filnm . '>' . WPSS_EOL; $wpss_htaccess_data .= "\t" . '# Apache 2.2' . WPSS_EOL . "\t" . '<IfModule !mod_authz_core.c>' . WPSS_EOL . "\t\t" . 'Order deny,allow' . WPSS_EOL . "\t\t" . 'Deny from all' . WPSS_EOL . $wpss_access_ap22 . "\t" . '</IfModule>' . WPSS_EOL . WPSS_EOL; $wpss_htaccess_data .= "\t" . '# Apache 2.4' . WPSS_EOL . "\t" . '<IfModule mod_authz_core.c>' . WPSS_EOL . "\t\t" . $wpss_access_ap24 . "\t" . '</IfModule>' . WPSS_EOL; $wpss_htaccess_data .= '</Files>' . WPSS_EOL; $wpss_htaccess_fp = @fopen($wpss_log_files[3], 'a+'); @fwrite($wpss_htaccess_fp, $wpss_htaccess_data); @fclose($wpss_htaccess_fp); /* 6 - If $get_fws (File Writeable Status), repeat #3 again and return status */ if (!empty($get_fws)) { clearstatcache(); $wpss_log_perms = array(); /* File permissions */ foreach ($wpss_log_files as $f => $file) { $wpss_log_perms[] = substr(sprintf('%o', fileperms($file)), -4); } foreach ($wpss_log_perlm as $p => $perlm) { if ($wpss_log_perms[$p] < $perlm || !wp_is_writable($wpss_log_files[$p])) { return FALSE; } } return TRUE; } }
function hmbkp_set_server_config_notices() { $notices = HM\BackUpWordPress\Notices::get_instance(); $messages = array(); if (!HM\BackUpWordPress\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\BackUpWordPress\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 HM\BackUpWordPress\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); } }
/** * Move backup files from an existing directory and the new * location * * @param string $path The path to move the backups from * @return void */ public function move_old_backups($from) { if (!is_readable($from)) { return; } if (!wp_is_writable($this->get_path())) { return; } // Move any existing backups if ($handle = opendir($from)) { // Loop through the backup directory while (false !== ($file = readdir($handle))) { // Find all zips if ('zip' === pathinfo($file, PATHINFO_EXTENSION)) { // Try to move them if (!@rename(trailingslashit($from) . $file, trailingslashit($this->get_path()) . $file)) { // If we can't move them then try to copy them copy(trailingslashit($from) . $file, trailingslashit($this->get_path()) . $file); } } } closedir($handle); } // Delete the old directory if it's inside WP_CONTENT_DIR if (false !== strpos($from, WP_CONTENT_DIR) && $from !== $this->get_path()) { hmbkp_rmdirtree($from); } }
/** * Save global clone details options * and create clone_details.json * * @return void */ function wpstg_save_options() { global $wpstg_clone_details; $path = wpstg_get_upload_dir(); if (wp_is_writable($path)) { $file = 'clone_details.json'; file_put_contents($path . '/' . $file, json_encode($wpstg_clone_details)); } else { wpstg_log($path . '/' . $file . ' is not writeable! '); } }
/** * Send an HTTP request to a URI. * * Please note: The only URI that are supported in the HTTP Transport implementation * are the HTTP and HTTPS protocols. * * @access public * @since 2.7.0 * * @global string $wp_version * * @param string $url The request URL. * @param string|array $args { * Optional. Array or string of HTTP request arguments. * * @type string $method Request method. Accepts 'GET', 'POST', 'HEAD', or 'PUT'. * Some transports technically allow others, but should not be * assumed. Default 'GET'. * @type int $timeout How long the connection should stay open in seconds. Default 5. * @type int $redirection Number of allowed redirects. Not supported by all transports * Default 5. * @type string $httpversion Version of the HTTP protocol to use. Accepts '1.0' and '1.1'. * Default '1.0'. * @type string $user-agent User-agent value sent. * Default WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ). * @type bool $reject_unsafe_urls Whether to pass URLs through {@see wp_http_validate_url()}. * Default false. * @type bool $blocking Whether the calling code requires the result of the request. * If set to false, the request will be sent to the remote server, * and processing returned to the calling code immediately, the caller * will know if the request succeeded or failed, but will not receive * any response from the remote server. Default true. * @type string|array $headers Array or string of headers to send with the request. * Default empty array. * @type array $cookies List of cookies to send with the request. Default empty array. * @type string|array $body Body to send with the request. Default null. * @type bool $compress Whether to compress the $body when sending the request. * Default false. * @type bool $decompress Whether to decompress a compressed response. If set to false and * compressed content is returned in the response anyway, it will * need to be separately decompressed. Default true. * @type bool $sslverify Whether to verify SSL for the request. Default true. * @type string sslcertificates Absolute path to an SSL certificate .crt file. * Default ABSPATH . WPINC . '/certificates/ca-bundle.crt'. * @type bool $stream Whether to stream to a file. If set to true and no filename was * given, it will be droped it in the WP temp dir and its name will * be set using the basename of the URL. Default false. * @type string $filename Filename of the file to write to when streaming. $stream must be * set to true. Default null. * @type int $limit_response_size Size in bytes to limit the response to. Default null. * * } * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. */ public function request($url, $args = array()) { global $wp_version; $defaults = array('method' => 'GET', 'timeout' => apply_filters('http_request_timeout', 5), 'redirection' => apply_filters('http_request_redirection_count', 5), 'httpversion' => apply_filters('http_request_version', '1.0'), 'user-agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')), 'reject_unsafe_urls' => apply_filters('http_request_reject_unsafe_urls', false), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true, 'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt', 'stream' => false, 'filename' => null, 'limit_response_size' => null); // Pre-parse for the HEAD checks. $args = wp_parse_args($args); // By default, Head requests do not cause redirections. if (isset($args['method']) && 'HEAD' == $args['method']) { $defaults['redirection'] = 0; } $r = wp_parse_args($args, $defaults); /** * Filter the arguments used in an HTTP request. * * @since 2.7.0 * * @param array $r An array of HTTP request arguments. * @param string $url The request URL. */ $r = apply_filters('http_request_args', $r, $url); // The transports decrement this, store a copy of the original value for loop purposes. if (!isset($r['_redirection'])) { $r['_redirection'] = $r['redirection']; } /** * Filter whether to preempt an HTTP request's return value. * * Returning a non-false value from the filter will short-circuit the HTTP request and return * early with that value. A filter should return either: * * - An array containing 'headers', 'body', 'response', 'cookies', and 'filename' elements * - A WP_Error instance * - boolean false (to avoid short-circuiting the response) * * Returning any other value may result in unexpected behaviour. * * @since 2.9.0 * * @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false. * @param array $r HTTP request arguments. * @param string $url The request URL. */ $pre = apply_filters('pre_http_request', false, $r, $url); if (false !== $pre) { return $pre; } if (function_exists('wp_kses_bad_protocol')) { if ($r['reject_unsafe_urls']) { $url = wp_http_validate_url($url); } if ($url) { $url = wp_kses_bad_protocol($url, array('http', 'https', 'ssl')); } } $arrURL = @parse_url($url); if (empty($url) || empty($arrURL['scheme'])) { return new WP_Error('http_request_failed', __('A valid URL was not provided.')); } if ($this->block_request($url)) { return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.')); } /* * Determine if this is a https call and pass that on to the transport functions * so that we can blacklist the transports that do not support ssl verification */ $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl'; // Determine if this request is to OUR install of WordPress. $homeURL = parse_url(get_bloginfo('url')); $r['local'] = 'localhost' == $arrURL['host'] || isset($homeURL['host']) && $homeURL['host'] == $arrURL['host']; unset($homeURL); /* * If we are streaming to a file but no filename was given drop it in the WP temp dir * and pick its name using the basename of the $url. */ if ($r['stream'] && empty($r['filename'])) { $r['filename'] = get_temp_dir() . wp_unique_filename(get_temp_dir(), basename($url)); } /* * Force some settings if we are streaming to a file and check for existence and perms * of destination directory. */ if ($r['stream']) { $r['blocking'] = true; if (!wp_is_writable(dirname($r['filename']))) { return new WP_Error('http_request_failed', __('Destination directory for file streaming does not exist or is not writable.')); } } if (is_null($r['headers'])) { $r['headers'] = array(); } if (!is_array($r['headers'])) { $processedHeaders = self::processHeaders($r['headers'], $url); $r['headers'] = $processedHeaders['headers']; } if (isset($r['headers']['User-Agent'])) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } if (isset($r['headers']['user-agent'])) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } if ('1.1' == $r['httpversion'] && !isset($r['headers']['connection'])) { $r['headers']['connection'] = 'close'; } // Construct Cookie: header if any cookies are set. self::buildCookieHeader($r); // Avoid issues where mbstring.func_overload is enabled. mbstring_binary_safe_encoding(); if (!isset($r['headers']['Accept-Encoding'])) { if ($encoding = WP_Http_Encoding::accept_encoding($url, $r)) { $r['headers']['Accept-Encoding'] = $encoding; } } if (!is_null($r['body']) && '' != $r['body'] || 'POST' == $r['method'] || 'PUT' == $r['method']) { if (is_array($r['body']) || is_object($r['body'])) { $r['body'] = http_build_query($r['body'], null, '&'); if (!isset($r['headers']['Content-Type'])) { $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'); } } if ('' === $r['body']) { $r['body'] = null; } if (!isset($r['headers']['Content-Length']) && !isset($r['headers']['content-length'])) { $r['headers']['Content-Length'] = strlen($r['body']); } } $response = $this->_dispatch_request($url, $r); reset_mbstring_encoding(); if (is_wp_error($response)) { return $response; } // Append cookies that were used in this request to the response if (!empty($r['cookies'])) { $cookies_set = wp_list_pluck($response['cookies'], 'name'); foreach ($r['cookies'] as $cookie) { if (!in_array($cookie->name, $cookies_set) && $cookie->test($url)) { $response['cookies'][] = $cookie; } } } return $response; }
ob_end_clean(); $dashboard_required_array['rs-version-information'] = array('order' => 20, 'content' => $dbc); ob_start(); ?> <!-- Requirements & Recommendations --> <div class="rs-dash-widget"> <?php $dir = wp_upload_dir(); $mem_limit = ini_get('memory_limit'); $mem_limit_byte = wp_convert_hr_to_bytes($mem_limit); $upload_max_filesize = ini_get('upload_max_filesize'); $upload_max_filesize_byte = wp_convert_hr_to_bytes($upload_max_filesize); $post_max_size = ini_get('post_max_size'); $post_max_size_byte = wp_convert_hr_to_bytes($post_max_size); $writeable_boolean = wp_is_writable($dir['basedir'] . '/'); $can_connect = get_option('revslider-connection', false); $mem_limit_byte_boolean = $mem_limit_byte < 268435456; $upload_max_filesize_byte_boolean = $upload_max_filesize_byte < 33554432; $post_max_size_byte_boolean = $post_max_size_byte < 33554432; $dash_rr_status = $writeable_boolean == true && $can_connect == true && $mem_limit_byte_boolean == false && $upload_max_filesize_byte_boolean == false && $post_max_size_byte_boolean == false ? "rs-status-green-wrap" : "rs-status-red-wrap"; ?> <div class="rs-dash-title-wrap <?php echo $dash_rr_status; ?> "> <div class="rs-dash-title"><?php _e("System Requirements", 'revslider'); ?> </div>
public function set_upload_writeable_notice() { if (!wp_is_writable(WC_germanized_pro()->plugin_path() . '/uploads')) { ?> <div class="error"> <p><?php printf(_x('Seems to be that your PDF upload directory (%s) is not writeable. Please set <a href="%s" target="_blank">file permissions</a>.', 'invoices', 'woocommerce-germanized-pro'), WC_germanized_pro()->plugin_path() . '/uploads/', 'http://codex.wordpress.org/Changing_File_Permissions'); ?> </p> </div> <?php } }
/** * Send a HTTP request to a URI. * * The body and headers are part of the arguments. The 'body' argument is for the body and will * accept either a string or an array. The 'headers' argument should be an array, but a string * is acceptable. If the 'body' argument is an array, then it will automatically be escaped * using http_build_query(). * * The only URI that are supported in the HTTP Transport implementation are the HTTP and HTTPS * protocols. HTTP and HTTPS are assumed so the server might not know how to handle the send * headers. Other protocols are unsupported and most likely will fail. * * The defaults are 'method', 'timeout', 'redirection', 'httpversion', 'blocking' and * 'user-agent'. * * Accepted 'method' values are 'GET', 'POST', and 'HEAD', some transports technically allow * others, but should not be assumed. The 'timeout' is used to sent how long the connection * should stay open before failing when no response. 'redirection' is used to track how many * redirects were taken and used to sent the amount for other transports, but not all transports * accept setting that value. * * The 'httpversion' option is used to sent the HTTP version and accepted values are '1.0', and * '1.1' and should be a string. Version 1.1 is not supported, because of chunk response. The * 'user-agent' option is the user-agent and is used to replace the default user-agent, which is * 'WordPress/WP_Version', where WP_Version is the value from $wp_version. * * 'blocking' is the default, which is used to tell the transport, whether it should halt PHP * while it performs the request or continue regardless. Actually, that isn't entirely correct. * Blocking mode really just means whether the fread should just pull what it can whenever it * gets bytes or if it should wait until it has enough in the buffer to read or finishes reading * the entire content. It doesn't actually always mean that PHP will continue going after making * the request. * * @access public * @since 2.7.0 * @todo Refactor this code. The code in this method extends the scope of its original purpose * and should be refactored to allow for cleaner abstraction and reduce duplication of the * code. One suggestion is to create a class specifically for the arguments, however * preliminary refactoring to this affect has affect more than just the scope of the * arguments. Something to ponder at least. * * @param string $url URI resource. * @param str|array $args Optional. Override the defaults. * @return array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error */ function request($url, $args = array()) { global $wp_version; $defaults = array('method' => 'GET', 'timeout' => apply_filters('http_request_timeout', 5), 'redirection' => apply_filters('http_request_redirection_count', 5), 'httpversion' => apply_filters('http_request_version', '1.0'), 'user-agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true, 'stream' => false, 'filename' => null, 'limit-response-size' => null); // Pre-parse for the HEAD checks. $args = wp_parse_args($args); // By default, Head requests do not cause redirections. if (isset($args['method']) && 'HEAD' == $args['method']) { $defaults['redirection'] = 0; } $r = wp_parse_args($args, $defaults); $r = apply_filters('http_request_args', $r, $url); // The transports decrement this, store a copy of the original value for loop purposes. if (!isset($r['_redirection'])) { $r['_redirection'] = $r['redirection']; } // Allow plugins to short-circuit the request $pre = apply_filters('pre_http_request', false, $r, $url); if (false !== $pre) { return $pre; } $arrURL = parse_url($url); if (empty($url) || empty($arrURL['scheme'])) { return new WP_Error('http_request_failed', __('A valid URL was not provided.')); } if ($this->block_request($url)) { return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.')); } // Determine if this is a https call and pass that on to the transport functions // so that we can blacklist the transports that do not support ssl verification $r['ssl'] = $arrURL['scheme'] == 'https' || $arrURL['scheme'] == 'ssl'; // Determine if this request is to OUR install of WordPress $homeURL = parse_url(get_bloginfo('url')); $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host']; unset($homeURL); // If we are streaming to a file but no filename was given drop it in the WP temp dir // and pick its name using the basename of the $url if ($r['stream'] && empty($r['filename'])) { $r['filename'] = get_temp_dir() . basename($url); } // Force some settings if we are streaming to a file and check for existence and perms of destination directory if ($r['stream']) { $r['blocking'] = true; if (!wp_is_writable(dirname($r['filename']))) { return new WP_Error('http_request_failed', __('Destination directory for file streaming does not exist or is not writable.')); } } if (is_null($r['headers'])) { $r['headers'] = array(); } if (!is_array($r['headers'])) { $processedHeaders = WP_Http::processHeaders($r['headers']); $r['headers'] = $processedHeaders['headers']; } if (isset($r['headers']['User-Agent'])) { $r['user-agent'] = $r['headers']['User-Agent']; unset($r['headers']['User-Agent']); } if (isset($r['headers']['user-agent'])) { $r['user-agent'] = $r['headers']['user-agent']; unset($r['headers']['user-agent']); } // Construct Cookie: header if any cookies are set WP_Http::buildCookieHeader($r); if (!isset($r['headers']['Accept-Encoding'])) { if ($encoding = WP_Http_Encoding::accept_encoding($url, $r)) { $r['headers']['Accept-Encoding'] = $encoding; } } if (!is_null($r['body']) && '' != $r['body'] || 'POST' == $r['method'] || 'PUT' == $r['method']) { if (is_array($r['body']) || is_object($r['body'])) { $r['body'] = http_build_query($r['body'], null, '&'); if (!isset($r['headers']['Content-Type'])) { $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'); } } if ('' === $r['body']) { $r['body'] = null; } if (!isset($r['headers']['Content-Length']) && !isset($r['headers']['content-length'])) { $r['headers']['Content-Length'] = strlen($r['body']); } } return $this->_dispatch_request($url, $r); }
/** * Displays admin notices for various error / warning * conditions * * @return void */ function hmbkp_admin_notices() { // If the backups directory doesn't exist and can't be automatically created if (!is_dir(hmbkp_path())) { function hmbkp_path_exists_warning() { $php_user = exec('whoami'); $php_group = reset(explode(' ', exec('groups'))); echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress is almost ready.', 'hmbkp') . '</strong> ' . 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.', 'hmbkp'), '<code>wp-content</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>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_path_exists_warning'); } // If the backups directory exists but isn't writable if (is_dir(hmbkp_path()) && !wp_is_writable(hmbkp_path())) { function hmbkp_writable_path_warning() { $php_user = exec('whoami'); $php_group = reset(explode(' ', exec('groups'))); echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress is almost ready.', 'hmbkp') . '</strong> ' . sprintf(__('Your backups directory isn\'t writable, run %1$s or %2$s or set the permissions yourself.', 'hmbkp'), '<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>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_writable_path_warning'); } // If safe mode is active if (HM_Backup::is_safe_mode_active()) { function hmbkp_safe_mode_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . 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.', 'hmbkp'), '<code>PHP</code>', sprintf('<a href="%1$s">%2$s</a>', __('http://php.net/manual/en/features.safe-mode.php', 'hmbkp'), __('Safe Mode', 'hmbkp')), '<code>' . __('Safe Mode', 'hmbkp') . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_safe_mode_warning'); } // If a custom backups directory is defined and it doesn't exist and can't be created if (defined('HMBKP_PATH') && HMBKP_PATH && !is_dir(HMBKP_PATH)) { function hmbkp_custom_path_exists_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('Your custom backups directory %1$s doesn\'t exist and can\'t be created, your backups will be saved to %2$s instead.', 'hmbkp'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_custom_path_exists_warning'); } // If a custom backups directory is defined and exists but isn't writable if (defined('HMBKP_PATH') && HMBKP_PATH && is_dir(HMBKP_PATH) && !wp_is_writable(HMBKP_PATH)) { function hmbkp_custom_path_writable_notice() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('Your custom backups directory %1$s isn\'t writable, new backups will be saved to %2$s instead.', 'hmbkp'), '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(hmbkp_path()) . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_custom_path_writable_notice'); } // If there are any errors reported in the backup if (hmbkp_backup_errors_message()) { function hmbkp_backup_errors_notice() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress detected issues with your last backup.', 'hmbkp') . '</strong><a href="' . esc_url(add_query_arg('action', 'hmbkp_dismiss_error')) . '" style="float: right;" class="button">Dismiss</a></p>' . hmbkp_backup_errors_message() . '</div>'; } add_action('admin_notices', 'hmbkp_backup_errors_notice'); } $test_backup = new HMBKP_Scheduled_Backup('test_backup'); if (!is_readable($test_backup->get_root())) { function hmbkp_ba§ckup_root_unreadable_notice() { $test_backup = new HMBKP_Scheduled_Backup('test_backup'); echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong>' . sprintf(__('Your backup root path %s isn\'t readable.', 'hmbkp'), '<code>' . $test_backup->get_root() . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_backup_root_unreadable_notice'); } }
function set_server_config_notices() { $notices = Notices::get_instance(); $messages = array(); if (!is_dir(Path::get_path())) { $messages[] = sprintf(__('The backups directory can\'t be created because your %s directory isn\'t writable. Please create the folder manually.', 'backupwordpress'), '<code>' . esc_html(dirname(Path::get_path())) . '</code>'); } if (is_dir(Path::get_path()) && !wp_is_writable(Path::get_path())) { $messages[] = __('The backups directory isn\'t writable. Please fix the permissions.', 'backupwordpress'); } if (Backup_Utilities::is_safe_mode_on()) { $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 (!path_in_php_open_basedir(HMBKP_PATH)) { $messages[] = sprintf(__('Your server has an %1$s restriction in effect and your custom backups directory (%2$s) is not within the allowed path(s): (%3$s).', 'backupwordpress'), '<code>open_basedir</code>', '<code>' . esc_html(HMBKP_PATH) . '</code>', '<code>' . esc_html(@ini_get('open_basedir')) . '</code>'); } elseif (!file_exists(HMBKP_PATH)) { $messages[] = sprintf(__('Your custom path does not exist', '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(Path::get_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(Path::get_path()) . '</code>'); } } } if (!is_readable(Path::get_root())) { $messages[] = sprintf(__('Your site root path %s isn\'t readable.', 'backupwordpress'), '<code>' . Path::get_root() . '</code>'); } if (!Requirement_Mysqldump_Command_Path::test() && !Requirement_PDO::test()) { $messages[] = sprintf(__('Your database cannot be backed up because your server doesn\'t support %1$s or %2$s. Please contact your host and ask them to enable them.', 'backupwordpress'), '<code>mysqldump</code>', '<code>PDO</code>'); } if (count($messages) > 0) { $notices->set_notices('server_config', $messages, false); } }
/** * Admin Messages * * @since 0.9.0 * @global $wpstg_options Array of all the WPSTG Options * @return void */ function wpstg_admin_messages() { global $wpstg_options; if (wpstg_is_admin_page() && !wp_is_writable(wpstg_get_upload_dir())) { echo '<div class="error">'; echo '<p><strong>WP Staging File Permission error: </strong>' . wpstg_get_upload_dir() . ' is not write and/or readable. <br> Check if the folder ' . wpstg_get_upload_dir() . ' exists! File permissions should be chmod 755 or 777.</p>'; echo '</div>'; } $path = wpstg_get_upload_dir() . '/clone_details.json'; if (wpstg_is_admin_page() && !wpstg_clonedetailsjson_exists() || !is_readable($path)) { echo '<div class="error">'; echo '<p><strong>WP Staging File Permission error: </strong>' . $path . ' is not write and/or readable. <br> Check if the file ' . $path . ' exists! File permissions should be chmod 644 or 777.</p>'; echo '</div>'; } $path = wpstg_get_upload_dir() . '/remaining_files.json'; if (wpstg_is_admin_page() && !wpstg_remainingjson_exists() || !is_readable($path)) { echo '<div class="error">'; echo '<p><strong>WP Staging File Permission error: </strong>' . $path . ' is not write and/or readable . <br> Check if the file ' . $path . ' exists! File permissions should be chmod 644 or 777.</p>'; echo '</div>'; } if (wpstg_is_admin_page() && version_compare(WPSTG_WP_COMPATIBLE, get_bloginfo('version'), '>')) { echo '<div class="error"><p>'; echo sprintf(__('You are using an outdated version of WP Staging which has not been tested with your WordPress version %2$s.<br> As WP Staging is using crucial db and file functions it\'s important that you are using a WP Staging version<br> which has been verified to be working with your WordPress version. You risk unexpected results up to data lose if you do not so. <p>Please look at <a href="%1$s" target="_blank">%s</a> for the latest WP Staging version.', 'wpstg'), 'https://wordpress.org/plugins/wp-staging/', get_bloginfo('version')); echo '</p></div>'; } echo wpstg_show_beta_message(); $install_date = get_option('wpstg_installDate'); $display_date = date('Y-m-d h:i:s'); $datetime1 = new DateTime($install_date); $datetime2 = new DateTime($display_date); $diff_intrval = round(($datetime2->format('U') - $datetime1->format('U')) / (60 * 60 * 24)); if ($diff_intrval >= 7 && get_option('wpstg_RatingDiv') == "no") { echo '<div class="wpstg_fivestar updated" style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);"> <p>Awesome, you\'ve been using <strong>WP Staging </strong> for more than 1 week. May we ask you to give it a <strong>5-star</strong> rating on Wordpress? <p><strong>Regards,<br>René Hermenau</strong> <ul> <li><a href="https://wordpress.org/support/view/plugin-reviews/wp-staging" class="thankyou" target="_new" title="Ok, you deserved it" style="font-weight:bold;">Ok, you deserved it</a></li> <li><a href="javascript:void(0);" class="wpstg_hide_rating" title="I already did" style="font-weight:bold;">I already did</a></li> <li><a href="javascript:void(0);" class="wpstg_hide_rating" title="No, not good enough" style="font-weight:bold;">No, not good enough</a></li> </ul> </div> <script> jQuery( document ).ready(function( $ ) { jQuery(\'.wpstg_hide_rating\').click(function(){ var data={\'action\':\'wpstg_hide_rating\'} jQuery.ajax({ url: "' . admin_url('admin-ajax.php') . '", type: "post", data: data, dataType: "json", async: !0, success: function(e) { if (e=="success") { jQuery(\'.wpstg_fivestar\').slideUp(\'slow\'); } } }); }) jQuery(\'.wpstg_hide_beta\').click(function(){ var data={\'action\':\'wpstg_hide_beta\'} jQuery.ajax({ url: "' . admin_url('admin-ajax.php') . '", type: "post", data: data, dataType: "json", async: !0, success: function(e) { if (e=="success") { jQuery(\'.wpstg_beta_notice\').slideUp(\'slow\'); } } }); }) }); </script> '; } }
/** * Send an HTTP request to a URI. * * Please note: The only URI that are supported in the HTTP Transport implementation * are the HTTP and HTTPS protocols. * * @access public * @since 2.7.0 * * @param string $url The request URL. * @param string|array $args { * Optional. Array or string of HTTP request arguments. * * @type string $method Request method. Accepts 'GET', 'POST', 'HEAD', or 'PUT'. * Some transports technically allow others, but should not be * assumed. Default 'GET'. * @type int $timeout How long the connection should stay open in seconds. Default 5. * @type int $redirection Number of allowed redirects. Not supported by all transports * Default 5. * @type string $httpversion Version of the HTTP protocol to use. Accepts '1.0' and '1.1'. * Default '1.0'. * @type string $user-agent User-agent value sent. * Default WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ). * @type bool $reject_unsafe_urls Whether to pass URLs through wp_http_validate_url(). * Default false. * @type bool $blocking Whether the calling code requires the result of the request. * If set to false, the request will be sent to the remote server, * and processing returned to the calling code immediately, the caller * will know if the request succeeded or failed, but will not receive * any response from the remote server. Default true. * @type string|array $headers Array or string of headers to send with the request. * Default empty array. * @type array $cookies List of cookies to send with the request. Default empty array. * @type string|array $body Body to send with the request. Default null. * @type bool $compress Whether to compress the $body when sending the request. * Default false. * @type bool $decompress Whether to decompress a compressed response. If set to false and * compressed content is returned in the response anyway, it will * need to be separately decompressed. Default true. * @type bool $sslverify Whether to verify SSL for the request. Default true. * @type string sslcertificates Absolute path to an SSL certificate .crt file. * Default ABSPATH . WPINC . '/certificates/ca-bundle.crt'. * @type bool $stream Whether to stream to a file. If set to true and no filename was * given, it will be droped it in the WP temp dir and its name will * be set using the basename of the URL. Default false. * @type string $filename Filename of the file to write to when streaming. $stream must be * set to true. Default null. * @type int $limit_response_size Size in bytes to limit the response to. Default null. * * } * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. * A WP_Error instance upon error. */ public function request($url, $args = array()) { $defaults = array('method' => 'GET', 'timeout' => apply_filters('http_request_timeout', 5), 'redirection' => apply_filters('http_request_redirection_count', 5), 'httpversion' => apply_filters('http_request_version', '1.0'), 'user-agent' => apply_filters('http_headers_useragent', 'WordPress/' . get_bloginfo('version') . '; ' . get_bloginfo('url')), 'reject_unsafe_urls' => apply_filters('http_request_reject_unsafe_urls', false), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true, 'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt', 'stream' => false, 'filename' => null, 'limit_response_size' => null); // Pre-parse for the HEAD checks. $args = wp_parse_args($args); // By default, Head requests do not cause redirections. if (isset($args['method']) && 'HEAD' == $args['method']) { $defaults['redirection'] = 0; } $r = wp_parse_args($args, $defaults); /** * Filters the arguments used in an HTTP request. * * @since 2.7.0 * * @param array $r An array of HTTP request arguments. * @param string $url The request URL. */ $r = apply_filters('http_request_args', $r, $url); // The transports decrement this, store a copy of the original value for loop purposes. if (!isset($r['_redirection'])) { $r['_redirection'] = $r['redirection']; } /** * Filters whether to preempt an HTTP request's return value. * * Returning a non-false value from the filter will short-circuit the HTTP request and return * early with that value. A filter should return either: * * - An array containing 'headers', 'body', 'response', 'cookies', and 'filename' elements * - A WP_Error instance * - boolean false (to avoid short-circuiting the response) * * Returning any other value may result in unexpected behaviour. * * @since 2.9.0 * * @param false|array|WP_Error $preempt Whether to preempt an HTTP request's return value. Default false. * @param array $r HTTP request arguments. * @param string $url The request URL. */ $pre = apply_filters('pre_http_request', false, $r, $url); if (false !== $pre) { return $pre; } if (function_exists('wp_kses_bad_protocol')) { if ($r['reject_unsafe_urls']) { $url = wp_http_validate_url($url); } if ($url) { $url = wp_kses_bad_protocol($url, array('http', 'https', 'ssl')); } } $arrURL = @parse_url($url); if (empty($url) || empty($arrURL['scheme'])) { return new WP_Error('http_request_failed', __('A valid URL was not provided.')); } if ($this->block_request($url)) { return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.')); } // If we are streaming to a file but no filename was given drop it in the WP temp dir // and pick its name using the basename of the $url if ($r['stream']) { if (empty($r['filename'])) { $r['filename'] = get_temp_dir() . basename($url); } // Force some settings if we are streaming to a file and check for existence and perms of destination directory $r['blocking'] = true; if (!wp_is_writable(dirname($r['filename']))) { return new WP_Error('http_request_failed', __('Destination directory for file streaming does not exist or is not writable.')); } } if (is_null($r['headers'])) { $r['headers'] = array(); } // WP allows passing in headers as a string, weirdly. if (!is_array($r['headers'])) { $processedHeaders = WP_Http::processHeaders($r['headers']); $r['headers'] = $processedHeaders['headers']; } // Setup arguments $headers = $r['headers']; $data = $r['body']; $type = $r['method']; $options = array('timeout' => $r['timeout'], 'useragent' => $r['user-agent'], 'blocking' => $r['blocking'], 'hooks' => new WP_HTTP_Requests_Hooks($url, $r)); // Ensure redirects follow browser behaviour. $options['hooks']->register('requests.before_redirect', array(get_class(), 'browser_redirect_compatibility')); if ($r['stream']) { $options['filename'] = $r['filename']; } if (empty($r['redirection'])) { $options['follow_redirects'] = false; } else { $options['redirects'] = $r['redirection']; } // Use byte limit, if we can if (isset($r['limit_response_size'])) { $options['max_bytes'] = $r['limit_response_size']; } // If we've got cookies, use and convert them to Requests_Cookie. if (!empty($r['cookies'])) { $options['cookies'] = WP_Http::normalize_cookies($r['cookies']); } // SSL certificate handling if (!$r['sslverify']) { $options['verify'] = false; $options['verifyname'] = false; } else { $options['verify'] = $r['sslcertificates']; } // All non-GET/HEAD requests should put the arguments in the form body. if ('HEAD' !== $type && 'GET' !== $type) { $options['data_format'] = 'body'; } /** * Filters whether SSL should be verified for non-local requests. * * @since 2.8.0 * * @param bool $ssl_verify Whether to verify the SSL connection. Default true. */ $options['verify'] = apply_filters('https_ssl_verify', $options['verify']); // Check for proxies. $proxy = new WP_HTTP_Proxy(); if ($proxy->is_enabled() && $proxy->send_through_proxy($url)) { $options['proxy'] = new Requests_Proxy_HTTP($proxy->host() . ':' . $proxy->port()); if ($proxy->use_authentication()) { $options['proxy']->use_authentication = true; $options['proxy']->user = $proxy->username(); $options['proxy']->pass = $proxy->password(); } } // Avoid issues where mbstring.func_overload is enabled mbstring_binary_safe_encoding(); try { $requests_response = Requests::request($url, $headers, $data, $type, $options); // Convert the response into an array $http_response = new WP_HTTP_Requests_Response($requests_response, $r['filename']); $response = $http_response->to_array(); // Add the original object to the array. $response['http_response'] = $http_response; } catch (Requests_Exception $e) { $response = new WP_Error('http_request_failed', $e->getMessage()); } reset_mbstring_encoding(); /** * Fires after an HTTP API response is received and before the response is returned. * * @since 2.8.0 * * @param array|WP_Error $response HTTP response or WP_Error object. * @param string $context Context under which the hook is fired. * @param string $class HTTP transport used. * @param array $args HTTP request arguments. * @param string $url The request URL. */ do_action('http_api_debug', $response, 'response', 'Requests', $r, $url); if (is_wp_error($response)) { return $response; } if (!$r['blocking']) { return array('headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array(), 'http_response' => null); } /** * Filters the HTTP API response immediately before the response is returned. * * @since 2.9.0 * * @param array $response HTTP response. * @param array $r HTTP request arguments. * @param string $url The request URL. */ return apply_filters('http_response', $response, $r, $url); }
?> <div style="width:100%;height:50px"></div> <div class="title_line nobgnopd"><div class="view_title"><?php _e("Requirements & Recommendations", REVSLIDER_TEXTDOMAIN); ?> </div></div> <div class="valid_big_padding" style="border-top:1px solid #e5e5e5; padding:15px 15px 15px 80px; position:relative;overflow:hidden;background:#fff;"> <div class="revgray valid_big_border" style="background:#3d566e;left:0px;top:0px;position:absolute;height:100%;padding:27px 10px;"><i style="color:#fff !important;font-size:25px" class="eg-icon-thumbs-up"></i></div> <span class="slideravailableversion"><?php _e('Uploads folder writable:', REVSLIDER_TEXTDOMAIN); ?> </span><?php //check if uploads folder can be written into $dir = wp_upload_dir(); if (wp_is_writable($dir['basedir'] . '/')) { echo '<i class="revgreenicon eg-icon-ok-squared"></i>'; } else { echo '<i class="revredicon eg-icon-info-circled"></i><span style="margin-left:15px">' . __('Please set the write permission (755) to your wp-content/uploads folders.', REVSLIDER_TEXTDOMAIN) . '</span>'; } ?> <br> <span class="slideravailableversion"><?php _e('Contact ThemePunch Server:', REVSLIDER_TEXTDOMAIN); ?> </span><?php $can_connect = get_option('revslider-connection', false); if ($can_connect) { echo '<i class="revgreenicon eg-icon-ok-squared"></i>'; } else { echo '<i class="revredicon eg-icon-info-circled"></i><span style="margin-left:15px">' . __('Please make sure that your server can connect to updates.themepunch.tools and templates.themepunch.tools programmatically.', REVSLIDER_TEXTDOMAIN) . '</span>';
function dbmanager_create_backup_folder() { $plugin_path = plugin_dir_path(__FILE__); $backup_path = WP_CONTENT_DIR . '/backup-db'; $backup_options = get_option('dbmanager_options'); if (!empty($backup_options['path'])) { $backup_path = $backup_options['path']; } // Create Backup Folder if (is_dir($backup_path) && wp_is_writable($backup_path)) { if (wp_mkdir_p($backup_path)) { if (is_iis()) { if (!is_file($backup_path . '/Web.config')) { @copy($plugin_path . 'Web.config.txt', $backup_path . '/Web.config'); } } else { if (!is_file($backup_path . '/.htaccess')) { @copy($plugin_path . 'htaccess.txt', $backup_path . '/.htaccess'); } } if (!is_file($backup_path . '/index.php')) { @copy($plugin_path . 'index.php', $backup_path . '/index.php'); } @chmod($backup_path, 0750); } } }
public function can_use_static_dynamic_style() { return wp_is_writable($this->get_static_css_file_dir()); }
/** * Determine a writable directory for temporary files. * * Function's preference is the return value of sys_get_temp_dir(), * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR, * before finally defaulting to /tmp/ * * In the event that this function does not find a writable location, * It may be overridden by the WP_TEMP_DIR constant in your wp-config.php file. * * @since 2.5.0 * * @staticvar string $temp * * @return string Writable temporary directory. */ function get_temp_dir() { static $temp = ''; if (defined('WP_TEMP_DIR')) { return trailingslashit(WP_TEMP_DIR); } if ($temp) { return trailingslashit($temp); } if (function_exists('sys_get_temp_dir')) { $temp = sys_get_temp_dir(); if (@is_dir($temp) && wp_is_writable($temp)) { return trailingslashit($temp); } } $temp = ini_get('upload_tmp_dir'); if (@is_dir($temp) && wp_is_writable($temp)) { return trailingslashit($temp); } $temp = WP_CONTENT_DIR . '/'; if (is_dir($temp) && wp_is_writable($temp)) { return $temp; } return '/tmp/'; }
public function create_protection_files($force = false, $method = false) { if (false === get_transient('pdfemb_check_protection_files') || $force) { $wp_upload_dir = wp_upload_dir(); $upload_path = $wp_upload_dir['basedir'] . '/securepdfs'; wp_mkdir_p($upload_path); // Make sure the /edd folder is created wp_mkdir_p($upload_path); // Top level .htaccess file $rules = $this->get_htaccess_rules($method); if (file_exists($upload_path . '/.htaccess')) { $contents = @file_get_contents($upload_path . '/.htaccess'); if ($contents !== $rules) { // Update the .htaccess rules if they don't match @file_put_contents($upload_path . '/.htaccess', $rules); } } elseif (wp_is_writable($upload_path)) { // Create the file if it doesn't exist @file_put_contents($upload_path . '/.htaccess', $rules); } // Top level blank index.php if (!file_exists($upload_path . '/index.php') && wp_is_writable($upload_path)) { @file_put_contents($upload_path . '/index.php', '<?php' . PHP_EOL . '// This file is intentionally blank.'); } // Now place index.php files in all sub folders $folders = array(); $this->scan_folders($upload_path, $folders); foreach ($folders as $folder) { // Create index.php, if it doesn't exist if (!file_exists($folder . 'index.php') && wp_is_writable($folder)) { @file_put_contents($folder . 'index.php', '<?php' . PHP_EOL . '// This file is intentionally blank.'); } } // Check for the files every eight days set_transient('pdfemb_check_protection_files', true, 3600 * 24 * 8); } }