dvadf
File manager - Edit - /home/theblueo/tv/wp-includes/pomo/lib/NSL.tar
Back
Persistent/Persistent.php 0000666 00000003712 15214044270 0011563 0 ustar 00 <?php namespace NSL\Persistent; use NSL\Persistent\Storage\Session; use NSL\Persistent\Storage\StorageAbstract; use NSL\Persistent\Storage\Transient; use WP_User; require_once dirname(__FILE__) . '/Storage/Abstract.php'; require_once dirname(__FILE__) . '/Storage/Session.php'; require_once dirname(__FILE__) . '/Storage/Transient.php'; class Persistent { private static $instance; /** @var StorageAbstract */ private $storage; public function __construct() { self::$instance = $this; add_action('init', array( $this, 'init' ), 0); add_action('wp_login', array( $this, 'transferSessionToUser' ), 10, 2); } public function init() { if ($this->storage === NULL) { if (is_user_logged_in()) { $this->storage = new Transient(); } else { $this->storage = new Session(); } } } public static function set($key, $value) { self::$instance->storage->set($key, $value); } public static function get($key) { return self::$instance->storage->get($key); } public static function delete($key) { self::$instance->storage->delete($key); } /** * @param $user_login * @param WP_User $user */ public function transferSessionToUser($user_login, $user = null) { if (!$user) { // For do_action( 'wp_login' ) calls that lacked passing the 2nd arg. $user = get_user_by('login', $user_login); } $newStorage = new Transient($user->ID); /** * $this->storage might be NULL if init action not called yet */ if ($this->storage !== NULL) { $newStorage->transferData($this->storage); } $this->storage = $newStorage; } public static function clear() { self::$instance->storage->clear(); } } new Persistent(); Persistent/Storage/Transient.php 0000666 00000000443 15214044270 0012774 0 ustar 00 <?php namespace NSL\Persistent\Storage; class Transient extends StorageAbstract { public function __construct($user_id = false) { if ($user_id === false) { $user_id = get_current_user_id(); } $this->sessionId = 'nsl_persistent_' . $user_id; } } Persistent/Storage/Session.php 0000666 00000005134 15214044270 0012452 0 ustar 00 <?php namespace NSL\Persistent\Storage; class Session extends StorageAbstract { /** * @var string name of the cookie. Can be changed with nsl_session_name filter and NSL_SESSION_NAME constant. * * @see https://pantheon.io/docs/caching-advanced-topics/ */ private $sessionName = 'SESSnsl'; public function __construct() { /** * WP Engine hosting needs custom cookie name to prevent caching. * * @see https://wpengine.com/support/wpengine-ecommerce/ */ if (class_exists('WpePlugin_common', false)) { $this->sessionName = 'wordpress_nsl'; } if (defined('NSL_SESSION_NAME')) { $this->sessionName = NSL_SESSION_NAME; } $this->sessionName = apply_filters('nsl_session_name', $this->sessionName); } public function clear() { parent::clear(); $this->destroy(); } private function destroy() { $sessionID = $this->sessionId; if ($sessionID) { $this->setCookie($sessionID, time() - YEAR_IN_SECONDS, apply_filters('nsl_session_use_secure_cookie', false)); add_action('shutdown', array( $this, 'destroySiteTransient' )); } } public function destroySiteTransient() { $sessionID = $this->sessionId; if ($sessionID) { delete_site_transient('nsl_' . $sessionID); } } protected function load($createSession = false) { static $isLoaded = false; if ($this->sessionId === null) { if (isset($_COOKIE[$this->sessionName])) { $this->sessionId = 'nsl_persistent_' . md5(SECURE_AUTH_KEY . $_COOKIE[$this->sessionName]); } else if ($createSession) { $unique = uniqid('nsl', true); $this->setCookie($unique, apply_filters('nsl_session_cookie_expiration', 0), apply_filters('nsl_session_use_secure_cookie', false)); $this->sessionId = 'nsl_persistent_' . md5(SECURE_AUTH_KEY . $unique); $isLoaded = true; } } if (!$isLoaded) { if ($this->sessionId !== null) { $data = maybe_unserialize(get_site_transient($this->sessionId)); if (is_array($data)) { $this->data = $data; } $isLoaded = true; } } } private function setCookie($value, $expire, $secure = false) { setcookie($this->sessionName, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure); } } Persistent/Storage/Abstract.php 0000666 00000002763 15214044270 0012577 0 ustar 00 <?php namespace NSL\Persistent\Storage; abstract class StorageAbstract { protected $sessionId = null; protected $data = array(); public function set($key, $value) { $this->load(true); $this->data[$key] = $value; $this->store(); } public function get($key) { $this->load(); if (isset($this->data[$key])) { return $this->data[$key]; } return null; } public function delete($key) { $this->load(); if (isset($this->data[$key])) { unset($this->data[$key]); $this->store(); } } public function clear() { $this->data = array(); $this->store(); } protected function load($createSession = false) { static $isLoaded = false; if (!$isLoaded) { $data = maybe_unserialize(get_site_transient($this->sessionId)); if (is_array($data)) { $this->data = $data; } $isLoaded = true; } } private function store() { if (empty($this->data)) { delete_site_transient($this->sessionId); } else { set_site_transient($this->sessionId, $this->data, apply_filters('nsl_persistent_expiration', HOUR_IN_SECONDS)); } } /** * @param StorageAbstract $storage */ public function transferData($storage) { $this->data = $storage->data; $this->store(); $storage->clear(); } } REST.php 0000666 00000003255 15214044270 0006042 0 ustar 00 <?php namespace NSL; use Exception; use NextendSocialLogin; use WP_Error; use WP_REST_Request; use WP_REST_Response; use function add_action; use function register_rest_route; class REST { public function __construct() { add_action('rest_api_init', array( $this, 'rest_api_init' )); } public function rest_api_init() { register_rest_route('nextend-social-login/v1', '/(?P<provider>\w[\w\s\-]*)/get_user', array( 'args' => array( 'provider' => array( 'required' => true, 'validate_callback' => array( $this, 'validate_provider' ) ), 'access_token' => array( 'required' => true, ), ), array( 'methods' => 'POST', 'callback' => array( $this, 'get_user' ) ), )); } public function validate_provider($providerID) { return NextendSocialLogin::isProviderEnabled($providerID); } /** * @param WP_REST_Request $request Full details about the request. * * @return WP_Error|WP_REST_Response */ public function get_user($request) { $provider = NextendSocialLogin::$enabledProviders[$request['provider']]; try { $user = $provider->findUserByAccessToken($request['access_token']); } catch (Exception $e) { return new WP_Error('error', $e->getMessage()); } return $user; } } new REST(); Notices.php 0000666 00000012343 15214044270 0006667 0 ustar 00 <?php namespace NSL; use NSL\Persistent\Persistent; use WP_Error; class Notices { private static $notices; private static $instance; public static function init() { if (self::$instance === null) { self::$instance = new self; } } private function __construct() { add_action('init', array( $this, 'load' ), 11); if (basename($_SERVER['PHP_SELF']) !== 'options-general.php' || empty($_GET['page']) || $_GET['page'] !== 'nextend-social-login') { add_action('admin_notices', array( $this, 'admin_notices' )); } add_action('admin_print_footer_scripts', array( $this, 'notices_fallback' )); add_action('wp_print_footer_scripts', array( $this, 'notices_fallback' )); } public function load() { self::$notices = maybe_unserialize(self::get()); if (!is_array(self::$notices)) { self::$notices = array(); } } private static function add($type, $message) { if (!isset(self::$notices[$type])) { self::$notices[$type] = array(); } if (!in_array($message, self::$notices[$type])) { self::$notices[$type][] = $message; } self::set(); } /** * @param $message string|WP_Error */ public static function addError($message) { if (is_wp_error($message)) { foreach ($message->get_error_messages() as $m) { self::add('error', $m); } } else { self::add('error', $message); } } public static function getErrors() { if (isset(self::$notices['error'])) { $errors = self::$notices['error']; unset(self::$notices['error']); self::set(); return $errors; } return false; } public static function addSuccess($message) { self::add('success', $message); } public static function displayNotices() { $html = self::getHTML(); if (!empty($html)) { echo '<div class="nsl-admin-notices">' . $html . '</div>'; } } public function admin_notices() { echo self::getHTML(); } /** * Displays the non-displayed notices in lightbox as a fallback */ public function notices_fallback() { $html = self::getHTML(); if (!empty($html)) { ?> <div id="nsl-notices-fallback" onclick="this.parentNode.removeChild(this);"> <?php echo $html; ?> <style> #nsl-notices-fallback { position: fixed; right: 10px; top: 10px; z-index: 10000; } .admin-bar #nsl-notices-fallback { top: 42px; } #nsl-notices-fallback > div { position: relative; background: #fff; border-left: 4px solid #fff; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .1); margin: 5px 15px 2px; padding: 1px 20px; } #nsl-notices-fallback > div.error { display: block; border-left-color: #dc3232; } #nsl-notices-fallback > div.updated { display: block; border-left-color: #46b450; } #nsl-notices-fallback p { margin: .5em 0; padding: 2px; } #nsl-notices-fallback > div:after { position: absolute; right: 5px; top: 5px; content: '\00d7'; display: block; height: 16px; width: 16px; line-height: 16px; text-align: center; font-size: 20px; cursor: pointer; } </style> </div> <?php } } private static function getHTML() { $html = ''; if (isset(self::$notices['success'])) { foreach (self::$notices['success'] AS $message) { $html .= '<div class="updated"><p>' . $message . '</p></div>'; } } if (isset(self::$notices['error'])) { foreach (self::$notices['error'] AS $message) { $html .= '<div class="error"><p>' . $message . '</p></div>'; } } self::clear(); return $html; } private static function get() { return Persistent::get('notices'); } private static function set() { Persistent::set('notices', self::$notices); } public static function clear() { Persistent::delete('notices'); self::$notices = array(); } } GDPR.php 0000666 00000012270 15214044270 0006016 0 ustar 00 <?php namespace NSL; use NextendSocialLogin; class GDPR { public function __construct() { add_action('admin_init', array( $this, 'add_privacy_policy_content' )); add_filter('wp_privacy_personal_data_exporters', array( $this, 'register_exporter' ), -1); /* add_filter('wp_privacy_personal_data_erasers', array( $this, 'register_eraser' )); */ } public function add_privacy_policy_content() { if (!function_exists('wp_add_privacy_policy_content')) { return; } $content = ''; $content .= '<h2>' . __('What personal data we collect and why we collect it') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . sprintf(__('%1$s collects data when a visitor register, login or link the account with with any of the enabled social provider. It collects the following data: email address, name, social provider identifier and access token. Also it can collect profile picture and more fields with the Pro Addon\'s sync data feature.'), 'Nextend Social Login') . '</p>'; $content .= '<h2>' . __('Who we share your data with') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . sprintf(__('%1$s stores the personal data on your site and does not share it with anyone except the access token which used for the authenticated communication with the social providers.'), 'Nextend Social Login') . '</p>'; $content .= '<h2>' . __('Does the plugin share personal data with third parties') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . sprintf(__('%1$s use the access token what the social provider gave to communicate with the providers to verify account and securely access personal data.'), 'Nextend Social Login') . '</p>'; $content .= '<h2>' . __('How long we retain your data') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . sprintf(__('%1$s removes the collected personal data when the user deleted from WordPress.'), 'Nextend Social Login') . '</p>'; $content .= '<h2>' . __('Does the plugin use personal data collected by others?') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . sprintf(__('%1$s use the personal data collected by the social providers to create account on your site when the visitor authorize it.'), 'Nextend Social Login') . '</p>'; $content .= '<h2>' . __('Does the plugin store things in the browser?') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . sprintf(__('Yes, %1$s must create a cookie for visitors who use the social login authorization flow. This cookie required for every provider to secure the communication and to redirect the user back to the last location.'), 'Nextend Social Login') . '</p>'; $content .= '<h2>' . __('Does the plugin collect telemetry data, directly or indirectly?') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . __('No') . '</p>'; $content .= '<h2>' . __('Does the plugin enqueue JavaScript, tracking pixels or embed iframes from a third party?') . '</h2>'; $content .= '<p class="privacy-policy-tutorial">' . __('No') . '</p>'; wp_add_privacy_policy_content('Nextend Social Login', wp_kses_post($content)); } public function register_exporter($exporters) { $exporters['nextend-facebook-connect'] = array( 'exporter_friendly_name' => 'Nextend Social Login', 'callback' => array( $this, 'exporter' ), ); return $exporters; } public function exporter($email_address, $page = 1) { $email_address = trim($email_address); $data_to_export = array(); $user = get_user_by('email', $email_address); if (!$user) { return array( 'data' => array(), 'done' => true, ); } $user_data_to_export = array(); foreach (NextendSocialLogin::$allowedProviders AS $provider) { $user_data_to_export = array_merge($user_data_to_export, $provider->exportPersonalData($user->ID)); } if (!empty($user_data_to_export)) { $data_to_export[] = array( 'group_id' => 'user', 'group_label' => __('User'), 'item_id' => "user-{$user->ID}", 'data' => $user_data_to_export, ); } return array( 'data' => $data_to_export, 'done' => true, ); } public function register_eraser($erasers) { $erasers['nextend-facebook-connect'] = array( 'exporter_friendly_name' => 'Nextend Social Login', 'callback' => array( $this, 'eraser' ), ); return $erasers; } public function eraser($email_address, $page = 1) { return array( 'items_removed' => false, 'items_retained' => false, 'messages' => array(), 'done' => true, ); } } new GDPR();
dvadf
dvadf
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings