X7ROOT File Manager
Current Path:
/home/magneti1/public_html/wp-content/plugins/everest-forms/includes
home
/
magneti1
/
public_html
/
wp-content
/
plugins
/
everest-forms
/
includes
/
ðŸ“
..
ðŸ“
Helpers
ðŸ“
RestApi
ðŸ“
abstracts
ðŸ“
admin
ðŸ“
blocks
📄
class-everest-forms.php
(13.76 KB)
📄
class-evf-ajax.php
(71.97 KB)
📄
class-evf-autoloader.php
(1.92 KB)
📄
class-evf-background-process-import-entries.php
(5.15 KB)
📄
class-evf-background-updater.php
(3.27 KB)
📄
class-evf-cache-helper.php
(2.32 KB)
📄
class-evf-cron.php
(1.83 KB)
📄
class-evf-deprecated-action-hooks.php
(3.91 KB)
📄
class-evf-deprecated-filter-hooks.php
(3.64 KB)
📄
class-evf-emails.php
(19.32 KB)
📄
class-evf-fields.php
(3.58 KB)
📄
class-evf-form-handler.php
(13.66 KB)
📄
class-evf-form-task.php
(70.19 KB)
📄
class-evf-forms-features.php
(1.49 KB)
📄
class-evf-frontend-scripts.php
(15.58 KB)
📄
class-evf-install.php
(20.96 KB)
📄
class-evf-integrations.php
(3.3 KB)
📄
class-evf-log-levels.php
(2.61 KB)
📄
class-evf-logger.php
(8.27 KB)
📄
class-evf-post-types.php
(5.13 KB)
📄
class-evf-privacy.php
(7.41 KB)
📄
class-evf-report-cron.php
(6.93 KB)
📄
class-evf-reporting.php
(3.48 KB)
📄
class-evf-session-handler.php
(8.02 KB)
📄
class-evf-shortcodes.php
(2.04 KB)
📄
class-evf-smart-tags.php
(19.59 KB)
📄
class-evf-template-loader.php
(13.08 KB)
📄
class-evf-validation.php
(934 B)
ðŸ“
elementor
📄
evf-conditional-functions.php
(1.21 KB)
📄
evf-core-functions.php
(197.64 KB)
📄
evf-deprecated-functions.php
(6.22 KB)
📄
evf-entry-functions.php
(9.22 KB)
📄
evf-formatting-functions.php
(25.18 KB)
📄
evf-notice-functions.php
(6.23 KB)
📄
evf-template-functions.php
(1.2 KB)
📄
evf-template-hooks.php
(439 B)
📄
evf-update-functions.php
(16.68 KB)
ðŸ“
export
ðŸ“
fields
ðŸ“
interfaces
ðŸ“
libraries
ðŸ“
log-handlers
ðŸ“
shortcodes
ðŸ“
stats
ðŸ“
templates
Editing: class-evf-session-handler.php
<?php /** * Handle data for the current customers session. * Implements the EVF_Session abstract class. * * @package EverestForms\Classes * @since 1.0.0 */ defined( 'ABSPATH' ) || exit; /** * Session handler class. */ class EVF_Session_Handler extends EVF_Session { /** * Cookie name used for the session. * * @var string cookie name */ protected $_cookie; /** * Stores session expiry. * * @var string session due to expire timestamp */ protected $_session_expiring; /** * Stores session due to expire timestamp. * * @var string session expiration timestamp */ protected $_session_expiration; /** * True when the cookie exists. * * @var bool Based on whether a cookie exists. */ protected $_has_cookie = false; /** * Table name for session data. * * @var string Custom session table name */ protected $_table; /** * Constructor for the session class. */ public function __construct() { $this->_cookie = apply_filters( 'everest_forms_cookie', 'wp_everest_forms_session_' . COOKIEHASH ); $this->_table = $GLOBALS['wpdb']->prefix . 'evf_sessions'; } /** * Init hooks and session data. */ public function init() { $cookie = $this->get_session_cookie(); if ( $cookie ) { $this->_customer_id = $cookie[0]; $this->_session_expiration = $cookie[1]; $this->_session_expiring = $cookie[2]; $this->_has_cookie = true; // Update session if its close to expiring. if ( time() > $this->_session_expiring ) { $this->set_session_expiration(); $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); } } else { $this->set_session_expiration(); $this->_customer_id = $this->generate_customer_id(); } $this->_data = $this->get_session_data(); add_action( 'shutdown', array( $this, 'save_data' ), 20 ); add_action( 'wp_logout', array( $this, 'destroy_session' ) ); if ( ! is_user_logged_in() ) { add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); } } /** * Return true if the current user has an active session, i.e. a cookie to retrieve values. * * @return bool */ public function has_session() { return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. } /** * Set session expiration. */ public function set_session_expiration() { $this->_session_expiring = time() + intval( apply_filters( 'evf_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. $this->_session_expiration = time() + intval( apply_filters( 'evf_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. } /** * Generate a unique customer ID for guests, or return user ID if logged in. * * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID. * * @return string */ public function generate_customer_id() { $customer_id = ''; if ( is_user_logged_in() ) { $customer_id = get_current_user_id(); } if ( empty( $customer_id ) ) { require_once ABSPATH . 'wp-includes/class-phpass.php'; $hasher = new PasswordHash( 8, false ); $customer_id = md5( $hasher->get_random_bytes( 32 ) ); } return $customer_id; } /** * Get the session cookie, if set. Otherwise return false. * * Session cookies without a customer ID are invalid. * * @return bool|array */ public function get_session_cookie() { $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { return false; } list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); if ( empty( $customer_id ) ) { return false; } // Validate hash. $to_hash = $customer_id . '|' . $session_expiration; $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { return false; } return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); } /** * Get session data. * * @return array */ public function get_session_data() { return $this->has_session() ? (array) $this->get_session( $this->_customer_id, array() ) : array(); } /** * Gets a cache prefix. This is used in session names so the entire cache can be invalidated with 1 function call. * * @return string */ private function get_cache_prefix() { return EVF_Cache_Helper::get_cache_prefix( EVF_SESSION_CACHE_GROUP ); } /** * Save data. */ public function save_data() { // Dirty if something changed - prevents saving nothing new. if ( $this->_dirty && $this->has_session() ) { global $wpdb; $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->prefix}evf_sessions (`session_key`, `session_value`, `session_expiry`) VALUES (%s, %s, %d) ON DUPLICATE KEY UPDATE `session_value` = VALUES(`session_value`), `session_expiry` = VALUES(`session_expiry`)", $this->_customer_id, maybe_serialize( $this->_data ), $this->_session_expiration ) ); wp_cache_set( $this->get_cache_prefix() . $this->_customer_id, $this->_data, EVF_SESSION_CACHE_GROUP, $this->_session_expiration - time() ); $this->_dirty = false; } } /** * Destroy all session data. */ public function destroy_session() { evf_setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, apply_filters( 'evf_session_use_secure_cookie', false ) ); $this->delete_session( $this->_customer_id ); $this->_data = array(); $this->_dirty = false; $this->_customer_id = $this->generate_customer_id(); } /** * When a user is logged out, ensure they have a unique nonce by using the customer/session ID. * * @param int $uid User ID. * @return string */ public function nonce_user_logged_out( $uid ) { return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; } /** * Cleanup session data from the database and clear caches. */ public function cleanup_sessions() { global $wpdb; $wpdb->query( $wpdb->prepare( "DELETE FROM $this->_table WHERE session_expiry < %d", time() ) ); // @codingStandardsIgnoreLine. if ( class_exists( 'EVF_Cache_Helper' ) ) { EVF_Cache_Helper::incr_cache_prefix( EVF_SESSION_CACHE_GROUP ); } } /** * Returns the session. * * @param string $customer_id Customer ID. * @param mixed $default Default session value. * @return string|array */ public function get_session( $customer_id, $default = false ) { global $wpdb; if ( defined( 'WP_SETUP_CONFIG' ) ) { return false; } // Try to get it from the cache, it will return false if not present or if object cache not in use. $value = wp_cache_get( $this->get_cache_prefix() . $customer_id, EVF_SESSION_CACHE_GROUP ); if ( false === $value ) { $value = $wpdb->get_var( $wpdb->prepare( "SELECT session_value FROM $this->_table WHERE session_key = %s", $customer_id ) ); // @codingStandardsIgnoreLine. if ( is_null( $value ) ) { $value = $default; } wp_cache_add( $this->get_cache_prefix() . $customer_id, $value, EVF_SESSION_CACHE_GROUP, $this->_session_expiration - time() ); } return maybe_unserialize( $value ); } /** * Delete the session from the cache and database. * * @param int $customer_id Customer ID. */ public function delete_session( $customer_id ) { global $wpdb; wp_cache_delete( $this->get_cache_prefix() . $customer_id, EVF_SESSION_CACHE_GROUP ); $wpdb->delete( // @codingStandardsIgnoreLine. $this->_table, array( 'session_key' => $customer_id, ) ); } /** * Update the session expiry timestamp. * * @param string $customer_id Customer ID. * @param int $timestamp Timestamp to expire the cookie. */ public function update_session_timestamp( $customer_id, $timestamp ) { global $wpdb; // @codingStandardsIgnoreStart. $wpdb->update( $this->_table, array( 'session_expiry' => $timestamp, ), array( 'session_key' => $customer_id, ), array( '%d' ) ); // @codingStandardsIgnoreEnd. } }
Upload File
Create Folder