PluginProbe
The WP Remote WordPress Plugin / 5.56
The WP Remote WordPress Plugin v5.56
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
wpremote / protect / wp_user.php

wp_user.php in The WP Remote WordPress Plugin 5.56, at protect/wp_user.php

64 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3
4 if (!class_exists('WPRProtectWPUser_V556')) :
5 class WPRProtectWPUser_V556 {
6 public $id;
7 public $role;
8 public $role_level;
9 public $capabilities;
10 public $capability_names = array();
11 public $time;
12
13 const COOKIE_NAME = "mcfw-wp-user-cookie";
14
15 public function __construct($id, $role_level, $capabilities, $time) {
16 $this->id = $id;
17 $this->role_level = $role_level;
18 $this->capabilities = $capabilities;
19 $this->time = $time;
20 }
21
22 public static function defaultUser() {
23 $time = (int) floor(time() / 43200);
24 return (new WPRProtectWPUser_V556(0, 0, array(), $time));
25 }
26
27 public static function _serialize($user) {
28 return $user->id . '|' . $user->role_level . '|' . implode(',', $user->capabilities) . '|' .
29 $user->time;
30 }
31
32 public static function _unserialize($serialized_user) {
33 if (!is_string($serialized_user)) {
34 return null;
35 }
36
37 $user_attrs = explode('|', $serialized_user);
38 if (count($user_attrs) !== 4) {
39 return null;
40 }
41 list($id, $role_level, $capabilities, $time) = $user_attrs;
42 $capabilities = array_map('intval', explode(',', $capabilities));
43
44 return (new WPRProtectWPUser_V556((int) $id, (int) $role_level, $capabilities, (int) $time));
45 }
46
47 public function isIdentical($user) {
48 return (($this->id === $user->id) && ($this->role_level === $user->role_level) &&
49 ($this->capabilities === $user->capabilities) && ($this->time === $user->time));
50 }
51
52 public function isLoggedIn() {
53 return $this->id !== 0;
54 }
55
56 public function getInfo() {
57 return array(
58 'id' => $this->id,
59 'role' => $this->role,
60 'capabilities' => $this->capability_names
61 );
62 }
63 }
64 endif;