| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/popup-maker/classes/Utils/ |
Upload File : |
<?php
/*******************************************************************************
* Copyright (c) 2019, Code Atlantic LLC
******************************************************************************/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Initializes a temporary data storage engine used by core in various capacities.
*/
class PUM_Utils_DataStorage {
/**
* Retrieves stored data by key.
*
* Given a key, get the information from the database directly.
*
* @param string $key The stored option key.
* @param null|mixed $default Optional. A default value to retrieve should `$value` be empty.
* Default null.
*
* @return mixed|false The stored data, value of `$default` if not null, otherwise false.
*/
public static function get( $key, $default = null ) {
global $wpdb;
$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
if ( empty( $value ) && ! is_null( $default ) ) {
return $default;
}
return empty( $value ) ? false : maybe_unserialize( $value );
}
/**
* Write some data based on key and value.
*
* @param string $key The option_name.
* @param mixed $value The value to store.
*/
public static function write( $key, $value ) {
global $wpdb;
$value = maybe_serialize( $value );
$data = array(
'option_name' => $key,
'option_value' => $value,
'autoload' => 'no',
);
$formats = self::get_data_formats( $value );
$wpdb->replace( $wpdb->options, $data, $formats );
}
/**
* Derives the formats array based on the type of $value.
*
* @param mixed $value Value to store.
*
* @return array Formats array. First and last values will always be string ('%s').
*/
public static function get_data_formats( $value ) {
switch ( gettype( $value ) ) {
case 'integer':
$formats = array( '%s', '%d', '%s' );
break;
case 'double':
$formats = array( '%s', '%f', '%s' );
break;
default:
case 'string':
$formats = array( '%s', '%s', '%s' );
break;
}
return $formats;
}
/**
* Deletes a piece of stored data by key.
*
* @param string $key The stored option name to delete.
*
* @return int|false The number of rows deleted, or false on error.
*/
public static function delete( $key ) {
global $wpdb;
return $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
}
/**
* Deletes all options matching a given RegEx pattern.
*
* @param string $pattern Pattern to match against option keys.
*
* @return int|false The number of rows deleted, or false on error.
*/
public static function delete_by_match( $pattern ) {
global $wpdb;
// Double check to make sure the batch_id got included before proceeding.
if ( "^[0-9a-z\\_]+" !== $pattern && ! empty( $pattern ) ) {
$query = "DELETE FROM $wpdb->options WHERE option_name REGEXP %s";
$result = $wpdb->query( $wpdb->prepare( $query, $pattern ) );
} else {
$result = false;
}
return $result;
}
}