| 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/DB/ |
Upload File : |
<?php
// Exit if accessed directly
/*******************************************************************************
* Copyright (c) 2019, Code Atlantic LLC
******************************************************************************/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* PUM_Subscribers Class
*/
class PUM_DB_Subscribers extends PUM_Abstract_Database {
/**
* The name of our database table
*/
public $table_name = 'pum_subscribers';
/**
* The version of our database table
*/
public $version = 3;
/**
* The name of the primary column
*/
public $primary_key = 'ID';
/**
* Get columns and formats
*/
public function get_columns() {
return array(
'ID' => '%d',
'uuid' => '%s',
'popup_id' => '%d',
'email_hash' => '%s',
'email' => '%s',
'name' => '%s',
'fname' => '%s',
'lname' => '%s',
'values' => '%s',
'user_id' => '%d',
'consent_args' => '%s',
'consent' => '%s',
'created' => '%s',
);
}
/**
* Get default column values
*/
public function get_column_defaults() {
return array(
'uuid' => '',
'popup_id' => 0,
'email_hash' => '',
'email' => '',
'name' => '',
'fname' => '',
'lname' => '',
'values' => '',
'user_id' => 0,
'consent_args' => '',
'consent' => 'no',
'created' => current_time( 'mysql', 0 ),
);
}
/**
* Create the table
*/
public function create_table() {
global $wpdb;
if ( ! function_exists( 'dbDelta' ) ) {
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
}
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE " . $this->table_name() . " (
`ID` BIGINT(20) NOT NULL AUTO_INCREMENT,
`email_hash` VARCHAR(32) NOT NULL,
`popup_id` BIGINT(20) NOT NULL,
`user_id` BIGINT(20) NOT NULL,
`email` VARCHAR(191) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`fname` VARCHAR(255) NOT NULL,
`lname` VARCHAR(255) NOT NULL,
`values` LONGTEXT NOT NULL,
`uuid` VARCHAR(255) NOT NULL,
`consent` VARCHAR(255) NOT NULL,
`consent_args` LONGTEXT NOT NULL,
`created` DATETIME NOT NULL,
PRIMARY KEY (ID),
KEY email (email),
KEY user_id (user_id),
KEY popup_id (popup_id),
KEY email_hash (email_hash)
) $charset_collate;";
dbDelta( $sql );
update_option( $this->table_name . '_db_version', $this->version );
}
public function get_by_email( $email = '' ) {
}
public function query( $args = array(), $return_type = 'OBJECT' ) {
global $wpdb;
$args = wp_parse_args( $args, array(
'fields' => '*',
'page' => null,
'limit' => null,
'offset' => null,
's' => null,
'orderby' => null,
'order' => null,
) );
$columns = $this->get_columns();
$where = "WHERE 1=1";
$values = array();
$fields = $args['fields'];
if ( $fields == '*' ) {
$fields = array_keys( $columns );
} else {
$fields = explode( ',', $args['fields'] );
$fields = array_map( 'trim', $fields );
$fields = array_map( 'sanitize_text_field', $fields );
}
// Pagination.
if ( $args['page'] >= 1 ) {
$args['offset'] = ( $args['page'] * $args['limit'] ) - $args['limit'];
}
if ( $args['s'] && ! empty( $args['s'] ) ) {
$search = wp_unslash( trim( $args['s'] ) );
$search_where = array();
foreach ( $columns as $key => $type ) {
if ( in_array( $key, $fields ) ) {
if ( $type == '%s' || ( $type == '%d' && is_numeric( $search ) ) ) {
$values[] = '%' . $search . '%';
$search_where[] = "`$key` LIKE '%s'";
}
}
}
if ( ! empty( $search_where ) ) {
$where .= ' AND (' . join( ' OR ', $search_where ) . ')';
}
}
$select_fields = implode( '`, `', $fields );
$query = "SELECT `$select_fields` FROM {$this->table_name()} $where";
if ( ! empty( $args['orderby'] ) ) {
$query .= " ORDER BY `" . wp_unslash( trim( $args['orderby'] ) ) . '`';
switch ( $args['order'] ) {
case 'asc':
case 'ASC':
$query .= " ASC";
break;
case 'desc':
case 'DESC':
default:
$query .= " DESC";
break;
}
}
if ( ! empty( $args['limit'] ) ) {
$query .= " LIMIT " . absint( $args['limit'] );
}
if ( ! empty( $args['offset'] ) ) {
$query .= " OFFSET " . absint( $args['offset'] );
}
if ( strpos( $query, '%s' ) || strpos( $query, '%d' ) ) {
$query = $wpdb->prepare( $query, $values );
}
if ( $return_type != 'model' ) {
$results = $wpdb->get_results( $query, $return_type );
}
return $results;
}
/**
* @param $args
*
* @return int
*/
public function total_rows( $args ) {
$args['limit'] = null;
$args['offset'] = null;
$args['page'] = null;
$results = $this->query( $args );
return $results ? count( $results ) : 0;
}
}