File: /home/coopserp/public_html/util.php.tar
home/coopserp/public_html/wp-content/plugins/siteseo/main/settings/util.php 0000644 00000006662 15152642235 0023353 0 ustar 00 <?php
/*
* SITESEO
* https://siteseo.io
* (c) SiteSEO Team
*/
namespace SiteSEO\Settings;
if(!defined('ABSPATH')){
die('HACKING ATTEMPT!');
}
class Util{
static function clean_text($text){
return sanitize_text_field(wp_unslash($text));
}
static function clean_url($url){
if(is_array($url)){
return map_deep(wp_unslash($url), 'sanitize_url');
}
return sanitize_url(wp_unslash($url));
}
static function render_toggle($title, $toggle_key, $toggle_state, $nonce, $label = false){
$is_active = $toggle_state ? 'active' : '';
$state_text = $toggle_state ? 'Disable' : 'Enable';
// for dashbord screen
if(!empty($label)){
echo '<div class="siteseo-toggle-cnt">
<div class="siteseo-toggle-Sw '.esc_attr($is_active).'" id="siteseo-toggleSw-' . esc_attr($toggle_key) . '" data-nonce="'.esc_attr($nonce).'" data-toggle-key="'.esc_attr($toggle_key).'" data-action="siteseo_save_'.esc_attr($toggle_key).'"></div>
<input type="hidden" name="siteseo_options['.esc_attr($toggle_key) . ']" id="'.esc_attr($toggle_key).'" value="'.esc_attr($toggle_state).'">
</div>';
}else{
echo '<div class="siteseo-toggle-cnt">
<span id="siteseo-tab-title"><strong>'.esc_html($title).'</strong></span>
<div class="siteseo-toggle-Sw '.esc_attr($is_active).'" id="siteseo-toggleSw-'.esc_attr($toggle_key).'" data-nonce="' . esc_attr($nonce) . '" data-toggle-key="'.esc_attr($toggle_key).'" data-action="siteseo_save_'.esc_attr($toggle_key).'"></div>
<span id="siteseo-arrow-icon" class="dashicons dashicons-arrow-left-alt siteseo-arrow-icon"></span>
<p class="toggle_state_'.esc_attr($toggle_key).'">'.esc_html($state_text).'</p>
<input type="hidden" name="siteseo_options['.esc_attr($toggle_key).']" id="'.esc_attr($toggle_key).'" value="'.esc_attr($toggle_state).'">
</div>';
}
}
static function admin_header(){
echo '<div class="siteseo-navbar">
<div class="logo">
<img alt="'.esc_html__('siteseo logo', 'siteseo').'" height="30" src="'. esc_url(SITESEO_ASSETS_URL).'/img/logo-24.svg'.'" width="40"/>
<div class="siteseo-breadcrumb">
<a href="#">'.esc_html__('Home', 'siteseo').'</a>
<span>/</span>
<a class="active" href="">'.esc_html(get_admin_page_title()).'</a>
</div>
</div>';
echo'<div class="links">
<span class="siteseo-header-version-badge">v'.esc_html(SITESEO_VERSION).'</span>
<a target="_blank" href="https://siteseo.io/docs/">'.esc_html__('Docs', 'siteseo').'</a>';
if(!defined('SITEPAD')){
echo'<a target="_blank" class="support" href="https://softaculous.deskuss.com/open.php?topicId=22">'.esc_html__('Support', 'siteseo').'</a>';
}
echo'</div>
</div>';
}
static function importable_plugins(){
return [
'wordpress-seo/wp-seo.php' => 'Yoast SEO',
'all-in-one-seo-pack/all_in_one_seo_pack.php' => 'All In One SEO',
'autodescription/autodescription.php' => 'The SEO Framework',
'seo-by-rank-math/rank-math.php' => 'Rank Math',
'wp-seopress/seopress.php' => 'SEOPress',
'slim-seo/slim-seo.php' => 'Slim SEO',
'surerank/surerank.php' => 'Surerank'
];
}
static function submit_btn($value = ''){
echo '<div class="siteseo-submit-button"><input type="submit" id="submit" name="submit" value="'.esc_attr($value ?: 'Save changes') . '" class="submit-button"></div>';
}
static function extract_content($input){
if(preg_match('/content=["\']([^"\']+)["\']/', $input, $matches)){
return $matches[1];
}
return $input;
}
} home/coopserp/public_html/wp-content/plugins/speedycache/main/util.php 0000644 00000021614 15152642420 0022303 0 ustar 00 <?php
namespace SpeedyCache;
if(!defined('ABSPATH')){
die('HACKING ATTEMPT!');
}
class Util{
static function sanitize_get($name, $default = ''){
if(empty($_GET[$name])){
return $default;
}
if(is_array($_GET[$name]) || is_object($_GET[$name])){
return map_deep(wp_unslash($_GET[$name]), 'sanitize_text_field');
}
return sanitize_text_field(wp_unslash($_GET[$name]));
}
static function sanitize_post($name, $default = ''){
if(empty($_POST[$name])){
return $default;
}
if(is_array($_POST[$name]) || is_object($_POST[$name])){
return map_deep(wp_unslash($_POST[$name]), 'sanitize_text_field');
}
return sanitize_text_field(wp_unslash($_POST[$name]));
}
static function sanitize_request($name, $default = ''){
if(empty($_REQUEST[$name])){
return $default;
}
if(is_array($_REQUEST[$name]) || is_object($_REQUEST[$name])){
return map_deep(wp_unslash($_REQUEST[$name]), 'sanitize_text_field');
}
return sanitize_text_field(wp_unslash($_REQUEST[$name]));
}
static function sanitize_server($name, $default = ''){
if(empty($_SERVER[$name])){
return $default;
}
return sanitize_text_field(wp_unslash($_SERVER[$name]));
}
static function pagespeed_color($score){
// The structure of this array is 0 => [Stroke Color, Background Color, Text Color]
$score_color_map = array(
0 => ['#c00', '#c003', '#c00'], // Red
50 => ['#fa3', '#ffa50036', '#fa3'],// Orange
90 => ['#0c6', '#00cc663b', '#080']// Green
);
if($score >= 0 && $score < 50){
return $score_color_map[0];
}
if($score >= 50 && $score < 90){
return $score_color_map[50];
}
return $score_color_map[90];
}
static function url_to_path($url){
$url = preg_replace('/\?.*/', '', $url); // Removing any query string
$dir_slug = str_replace(site_url(), '', $url);
if(defined('SITEPAD')){
global $sitepad;
$file_path = $sitepad['path'] . '/' .trim($dir_slug, '/');
} else {
$file_path = ABSPATH . trim($dir_slug, '/');
}
return wp_normalize_path($file_path);
}
static function path_to_url($path){
$path = wp_normalize_path($path);
if(defined('SITEPAD')){
global $sitepad;
$abs_path = wp_normalize_path($sitepad['path']);
} else {
$abs_path = wp_normalize_path(ABSPATH);
}
$path = str_replace($abs_path, '', $path);
$url = site_url() . '/' . $path;
return $url;
}
static function cache_path($loc = ''){
if((defined('WP_CLI') && WP_CLI) || empty($_SERVER['HTTP_HOST'])){
global $blog_id;
$url = get_option('home');
if(!empty($blog_id) && is_multisite()){
switch_to_blog($blog_id);
$url = get_option('home');
restore_current_blog();
}
$url = wp_parse_url($url);
$host = $url['host'];
return trailingslashit(SPEEDYCACHE_CACHE_DIR . '/'.$host.'/'.$loc);
}
$host = sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST']));
return trailingslashit(SPEEDYCACHE_CACHE_DIR . '/'.$host.'/'.$loc);
}
// Creates a config file based on the URL of the website
static function set_config_file(){
global $speedycache;
$export_config['settings']['status'] = !empty($speedycache->options['status']);
$export_config['settings']['gzip'] = !empty($speedycache->options['gzip']);
$export_config['settings']['logged_in_user'] = !empty($speedycache->options['logged_in_user']);
$export_config['settings']['mobile_theme'] = !empty($speedycache->options['mobile_theme']);
$export_config['settings']['mobile'] = !empty($speedycache->options['mobile']);
//$export_config['user_agents'] = speedycache_get_excluded_useragent();
$export_config['excludes'] = get_option('speedycache_exclude', []);
$config = var_export($export_config, true);
$url = get_site_url();
$file = parse_url(untrailingslashit($url));
$file['path'] = (!empty($file['path'])) ? str_replace( '/', '.', untrailingslashit($file['path'])) : '';
$config_file_path = WP_CONTENT_DIR .'/speedycache-config/'. strtolower($file['host']) . $file['path'] . '.php';
if(!file_exists(WP_CONTENT_DIR .'/speedycache-config/')){
if(mkdir(WP_CONTENT_DIR .'/speedycache-config/', 0755, true)){
touch(WP_CONTENT_DIR .'/speedycache-config/index.html');
file_put_contents(WP_CONTENT_DIR .'/speedycache-config/.htaccess', 'deny from all');
}
}
$config_temp = file_get_contents(SPEEDYCACHE_DIR . '/assets/config-template.php');
$config_content = str_replace("'REPLACE_CONFIG'", $config, $config_temp);
file_put_contents($config_file_path, $config_content);
}
static function dir_size($dir){
$size = 0;
foreach(glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $file){
$size += is_file($file) ? filesize($file) : self::dir_size($file);
}
return $size;
}
static function cache_lifespan(){
global $speedycache;
$schedule_time = 0;
if(empty($speedycache->options['purge_interval'])){
return $schedule_time;
}
if(!empty($speedycache->options['purge_enable_exact_time']) && !empty($speedycache->options['purge_exact_time'])){
$schedule_time = DAY_IN_SECONDS;
} elseif($speedycache->options['purge_interval_unit'] == 'hours'){
$schedule_time = HOUR_IN_SECONDS * $speedycache->options['purge_interval'];
} elseif($speedycache->options['purge_interval_unit'] == 'days'){
$schedule_time = DAY_IN_SECONDS * $speedycache->options['purge_interval'];
}
return (int) $schedule_time;
}
static function lifespan_cron(){
global $speedycache;
if(empty($speedycache->options['purge_interval'])){
return;
}
if(!empty(wp_next_scheduled('speedycache_purge_cache'))){
return;
}
if(!empty($speedycache->options['purge_enable_exact_time']) && !empty($speedycache->options['purge_exact_time'])){
// Getting the exact time of the user's timezone by using the offset and strtotime return gtm time.
$future_timestamp = strtotime('today '.$speedycache->options['purge_exact_time']);
$offset = get_option('gmt_offset') * HOUR_IN_SECONDS;
$current_time = time() - $offset;
$future_timestamp -= $offset;
if(time() > $future_timestamp){
$future_timestamp = strtotime('tomorrow '.$speedycache->options['purge_exact_time']);
$future_timestamp -= $offset;
}
$schedule_time = $future_timestamp - time();
} elseif($speedycache->options['purge_interval_unit'] == 'hours'){
$schedule_time = HOUR_IN_SECONDS * $speedycache->options['purge_interval'];
} elseif($speedycache->options['purge_interval_unit'] == 'days'){
$schedule_time = DAY_IN_SECONDS * $speedycache->options['purge_interval'];
}
wp_schedule_event(time() + $schedule_time, 'speedycache_expired_cache_schedule', 'speedycache_purge_cache');
}
static function preload_cron(){
global $speedycache;
if(empty($speedycache->options['preload_interval']) || empty($speedycache->options['preload'])){
return;
}
if(wp_next_scheduled('speedycache_preload')){
return;
}
$schedule_time = HOUR_IN_SECONDS * (int) $speedycache->options['preload_interval'];
wp_schedule_event(time() + $schedule_time, 'speedycache_preload_cache_schedule', 'speedycache_preload');
}
static function custom_expiry_cron($schedules){
$cache_interval = self::cache_lifespan();
if(empty($cache_interval)){
return $schedules;
}
$schedules['speedycache_expired_cache_schedule'] = [
'interval' => $cache_interval,
'display' => __('SpeedyCache Cache Lifespan cron', 'speedycache'),
];
return $schedules;
}
static function custom_preload_cron($schedules){
global $speedycache;
if(empty($speedycache->options['preload_interval'])){
return $schedules;
}
$cache_interval = $speedycache->options['preload_interval'] * HOUR_IN_SECONDS;
if(empty($cache_interval)){
return $schedules;
}
$schedules['speedycache_preload_cache_schedule'] = [
'interval' => $cache_interval,
'display' => __('SpeedyCache Cache Preload cron', 'speedycache'),
];
return $schedules;
}
static function custom_cron($schedules){
// Every 14 days (Fortnight)
$schedules['speedycache_fortnight'] = [
'interval' => 14 * DAY_IN_SECONDS,
'display' => __('Once Every Fortnight', 'speedycache'),
];
// Monthly (approx 30 days)
$schedules['speedycache_monthly'] = [
'interval' => 30 * DAY_IN_SECONDS,
'display' => __('Once Monthly', 'speedycache'),
];
return $schedules;
}
// Deletes binaries
static function delete_cwebp(){
$binary_dir = wp_upload_dir()['basedir'] .'/speedycache-binary';
if(!file_exists($binary_dir)){
return;
}
$binaries = @scandir($binary_dir);
$binaries = array_diff($binaries, ['.', '..']);
if(empty($binaries)){
@rmdir($binary_dir);
return;
}
foreach($binaries as $binary){
if(file_exists($binary_dir.'/'.$binary)){
@unlink($binary_dir.'/'.$binary);
}
}
}
}