PluginProbe
Passster – Password Protect Pages and Content / 3.5.4
Passster – Password Protect Pages and Content v3.5.4
4.3.15 4.3.14 4.3.12 4.3.13 4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.5 trunk 3.5.4 3.5.5.2 3.5.5.8 3.5.5.9 4.0 4.1.4 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.15 4.2.16 All 47 releases
content-protector / src / class-ps-conditional.php

class-ps-conditional.php in Passster – Password Protect Pages and Content 3.5.4, at src/class-ps-conditional.php

104 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace passster;
4
5 class PS_Conditional
6 {
7 /**
8 * Check if valid authentication exists.
9 *
10 * @param array $atts array of attributes.
11 * @return boolean
12 */
13 public static function is_valid( $atts )
14 {
15 // valid user.
16 if ( self::is_user_valid( $atts ) ) {
17 return true;
18 }
19 // valid link.
20 if ( self::is_link_valid( $atts ) ) {
21 return true;
22 }
23 // is Cookie set?
24 if ( !isset( $_COOKIE['passster'] ) || empty($_COOKIE['passster']) ) {
25 return false;
26 }
27 $input = base64_decode( $_COOKIE['passster'] );
28 // password.
29 if ( isset( $atts['password'] ) ) {
30 if ( $input == $atts['password'] ) {
31 return true;
32 }
33 }
34 // passwords.
35
36 if ( isset( $atts['passwords'] ) ) {
37 $passwords = explode( ',', str_replace( ' ', '', $atts['passwords'] ) );
38 if ( !empty($passwords) && in_array( $input, $passwords, true ) ) {
39 return true;
40 }
41 }
42
43 // password lists.
44
45 if ( isset( $atts['password_list'] ) ) {
46 $passwords_in_list = get_post_meta( $atts['password_list'], 'passster_passwords', true );
47 $passwords_in_list = explode( ',', $passwords_in_list );
48 $expire = get_post_meta( $atts['password_list'], 'passster_expire_passwords', true );
49
50 if ( in_array( $input, $passwords_in_list ) ) {
51 self::maybe_expire_password_from_list( $input, $passwords_in_list, $atts['password_list'] );
52 return true;
53 }
54
55 }
56
57 // captcha.
58 if ( isset( $atts['captcha'] ) ) {
59 if ( 'captcha' == $input ) {
60 return true;
61 }
62 }
63 // recaptcha.
64 if ( isset( $atts['recaptcha'] ) ) {
65 if ( 'recaptcha' == $input ) {
66 return true;
67 }
68 }
69 // if nothing was correct.
70 return false;
71 }
72
73 /**
74 * Return user name and role as array
75 *
76 * @param array $atts added attributes.
77 * @return boolean
78 */
79 public static function is_user_valid( $atts )
80 {
81 }
82
83 /**
84 * Check if link is valid.
85 *
86 * @param array $atts array of attributes.
87 * @return boolean
88 */
89 public static function is_link_valid( $atts )
90 {
91 }
92
93 /**
94 * Maybe expire an password from a list by usage or time.
95 *
96 * @param string $password given password.
97 * @param array $passwords_in_list passwords from list.
98 * @return void
99 */
100 public static function maybe_expire_password_from_list( $password, $passwords_in_list, $list_id )
101 {
102 }
103
104 }