PluginProbe
The WP Remote WordPress Plugin / 6.36
The WP Remote WordPress Plugin v6.36
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 / fw / rule.php

rule.php in The WP Remote WordPress Plugin 6.36, at protect/fw/rule.php

193 lines 11.7 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('WPRProtectFWRule_V636')) :
5 class WPRProtectFWRule_V636 {
6 public $id;
7 public $logic;
8 public $actions;
9 public $execute_on;
10 public $min_rule_engine_ver;
11 public $max_rule_engine_ver;
12 public $config = array();
13 public $opts = array();
14
15 const EXE_ON_BOOT = 1;
16 const EXE_ON_PRE_UPDATE_OPTION = 2;
17 const EXE_ON_PRE_DELETE_POST = 3;
18 const EXE_ON_WP_INSERT_POST_EMPTY_CONTENT = 4;
19 const EXE_ON_INSERT_USER_META = 5;
20 const EXE_ON_DELETE_OPTION = 6;
21 const EXE_ON_DELETE_USER = 7;
22 const EXE_ON_PASSWORD_RESET = 8;
23 const EXE_ON_SEND_AUTH_COOKIES = 9;
24 const EXE_ON_SET_AUTH_COOKIE = 10;
25 const EXE_ON_INIT = 11;
26 const EXE_ON_USER_REGISTER = 12;
27 const EXE_ON_ADD_USER_META = 13;
28 const EXE_ON_UPDATE_USER_METADATA = 14;
29 const EXE_ON_UPDATE_USER_META = 15;
30 const EXE_ON_ADD_OPTION = 16;
31 const EXE_ON_WP_PRE_INSERT_USER_DATA = 17;
32
33 const SQLIREGEX = '/(?:[^\\w<]|\\/\\*\\![0-9]*|^)(?:
34 @@HOSTNAME|
35 ALTER|ANALYZE|ASENSITIVE|
36 BEFORE|BENCHMARK|BETWEEN|BIGINT|BINARY|BLOB|
37 CALL|CASE|CHANGE|CHAR|CHARACTER|CHAR_LENGTH|COLLATE|COLUMN|CONCAT|CONDITION|CONSTRAINT|CONTINUE|CONVERT|CREATE|CROSS|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|
38 DATABASE|DATABASES|DAY_HOUR|DAY_MICROSECOND|DAY_MINUTE|DAY_SECOND|DECIMAL|DECLARE|DEFAULT|DELAYED|DELETE|DESCRIBE|DETERMINISTIC|DISTINCT|DISTINCTROW|DOUBLE|DROP|DUAL|DUMPFILE|
39 EACH|ELSE|ELSEIF|ELT|ENCLOSED|ESCAPED|EXISTS|EXIT|EXPLAIN|EXTRACTVALUE|
40 FETCH|FLOAT|FLOAT4|FLOAT8|FORCE|FOREIGN|FROM|FULLTEXT|
41 GRANT|GROUP|HAVING|HEX|HIGH_PRIORITY|HOUR_MICROSECOND|HOUR_MINUTE|HOUR_SECOND|
42 IFNULL|IGNORE|INDEX|INFILE|INNER|INOUT|INSENSITIVE|INSERT|INTERVAL|ISNULL|ITERATE|
43 JOIN|KILL|LEADING|LEAVE|LIMIT|LINEAR|LINES|LOAD|LOAD_FILE|LOCALTIME|LOCALTIMESTAMP|LOCK|LONG|LONGBLOB|LONGTEXT|LOOP|LOW_PRIORITY|
44 MASTER_SSL_VERIFY_SERVER_CERT|MATCH|MAXVALUE|MEDIUMBLOB|MEDIUMINT|MEDIUMTEXT|MID|MIDDLEINT|MINUTE_MICROSECOND|MINUTE_SECOND|MODIFIES|
45 NATURAL|NO_WRITE_TO_BINLOG|NULL|NUMERIC|OPTION|ORD|ORDER|OUTER|OUTFILE|
46 PRECISION|PRIMARY|PRIVILEGES|PROCEDURE|PROCESSLIST|PURGE|
47 RANGE|READ_WRITE|REGEXP|RELEASE|REPEAT|REQUIRE|RESIGNAL|RESTRICT|RETURN|REVOKE|RLIKE|ROLLBACK|
48 SCHEMA|SCHEMAS|SECOND_MICROSECOND|SELECT|SENSITIVE|SEPARATOR|SHOW|SIGNAL|SLEEP|SMALLINT|SPATIAL|SPECIFIC|SQLEXCEPTION|SQLSTATE|SQLWARNING|SQL_BIG_RESULT|SQL_CALC_FOUND_ROWS|SQL_SMALL_RESULT|STARTING|STRAIGHT_JOIN|SUBSTR|
49 TABLE|TERMINATED|TINYBLOB|TINYINT|TINYTEXT|TRAILING|TRANSACTION|TRIGGER|
50 UNDO|UNHEX|UNION|UNLOCK|UNSIGNED|UPDATE|UPDATEXML|USAGE|USING|UTC_DATE|UTC_TIME|UTC_TIMESTAMP|
51 VALUES|VARBINARY|VARCHAR|VARCHARACTER|VARYING|WHEN|WHERE|WHILE|WRITE|YEAR_MONTH|ZEROFILL)(?=[^\\w]|$)/ix';
52 const XSSREGEX = '/(?:
53 #tags
54 (?:\\<|\\+ADw\\-|\\xC2\\xBC)(script|iframe|svg|object|embed|applet|link|style|meta|\\/\\/|\\?xml\\-stylesheet)(?:[^\\w]|\\xC2\\xBE)|
55 #protocols
56 (?:^|[^\\w])(?:(?:\\s*(?:&\\#(?:x0*6a|0*106)|j)\\s*(?:&\\#(?:x0*61|0*97)|a)\\s*(?:&\\#(?:x0*76|0*118)|v)\\s*(?:&\\#(?:x0*61|0*97)|a)|\\s*(?:&\\#(?:x0*76|0*118)|v)\\s*(?:&\\#(?:x0*62|0*98)|b)|\\s*(?:&\\#(?:x0*65|0*101)|e)\\s*(?:&\\#(?:x0*63|0*99)|c)\\s*(?:&\\#(?:x0*6d|0*109)|m)\\s*(?:&\\#(?:x0*61|0*97)|a)|\\s*(?:&\\#(?:x0*6c|0*108)|l)\\s*(?:&\\#(?:x0*69|0*105)|i)\\s*(?:&\\#(?:x0*76|0*118)|v)\\s*(?:&\\#(?:x0*65|0*101)|e))\\s*(?:&\\#(?:x0*73|0*115)|s)\\s*(?:&\\#(?:x0*63|0*99)|c)\\s*(?:&\\#(?:x0*72|0*114)|r)\\s*(?:&\\#(?:x0*69|0*105)|i)\\s*(?:&\\#(?:x0*70|0*112)|p)\\s*(?:&\\#(?:x0*74|0*116)|t)|\\s*(?:&\\#(?:x0*6d|0*109)|m)\\s*(?:&\\#(?:x0*68|0*104)|h)\\s*(?:&\\#(?:x0*74|0*116)|t)\\s*(?:&\\#(?:x0*6d|0*109)|m)\\s*(?:&\\#(?:x0*6c|0*108)|l)|\\s*(?:&\\#(?:x0*6d|0*109)|m)\\s*(?:&\\#(?:x0*6f|0*111)|o)\\s*(?:&\\#(?:x0*63|0*99)|c)\\s*(?:&\\#(?:x0*68|0*104)|h)\\s*(?:&\\#(?:x0*61|0*97)|a)|\\s*(?:&\\#(?:x0*64|0*100)|d)\\s*(?:&\\#(?:x0*61|0*97)|a)\\s*(?:&\\#(?:x0*74|0*116)|t)\\s*(?:&\\#(?:x0*61|0*97)|a)(?!(?:&\\#(?:x0*3a|0*58)|\\:)(?:&\\#(?:x0*69|0*105)|i)(?:&\\#(?:x0*6d|0*109)|m)(?:&\\#(?:x0*61|0*97)|a)(?:&\\#(?:x0*67|0*103)|g)(?:&\\#(?:x0*65|0*101)|e)(?:&\\#(?:x0*2f|0*47)|\\/)(?:(?:&\\#(?:x0*70|0*112)|p)(?:&\\#(?:x0*6e|0*110)|n)(?:&\\#(?:x0*67|0*103)|g)|(?:&\\#(?:x0*62|0*98)|b)(?:&\\#(?:x0*6d|0*109)|m)(?:&\\#(?:x0*70|0*112)|p)|(?:&\\#(?:x0*67|0*103)|g)(?:&\\#(?:x0*69|0*105)|i)(?:&\\#(?:x0*66|0*102)|f)|(?:&\\#(?:x0*70|0*112)|p)?(?:&\\#(?:x0*6a|0*106)|j)(?:&\\#(?:x0*70|0*112)|p)(?:&\\#(?:x0*65|0*101)|e)(?:&\\#(?:x0*67|0*103)|g)|(?:&\\#(?:x0*74|0*116)|t)(?:&\\#(?:x0*69|0*105)|i)(?:&\\#(?:x0*66|0*102)|f)(?:&\\#(?:x0*66|0*102)|f)|(?:&\\#(?:x0*73|0*115)|s)(?:&\\#(?:x0*76|0*118)|v)(?:&\\#(?:x0*67|0*103)|g)(?:&\\#(?:x0*2b|0*43)|\\+)(?:&\\#(?:x0*78|0*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.*?\\*\\/)*(?:\\\\0*68|\\\\0*48|h)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*61|\\\\0*41|a)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*76|\\\\0*56|v)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*69|\\\\0*49|i)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*6f|\\\\0*4f|o)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*72|\\\\0*52|r)(?:\\/\\*.*?\\*\\/)*)|(?:(?:\\\\0*2d|\\\\0*2d|-)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*6d|\\\\0*4d|m)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*6f|\\\\0*4f|o)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*7a|\\\\0*5a|z)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*2d|\\\\0*2d|-)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*62|\\\\0*42|b)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*69|\\\\0*49|i)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*6e|\\\\0*4e|n)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*64|\\\\0*44|d)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*69|\\\\0*49|i)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*6e|\\\\0*4e|n)(?:\\/\\*.*?\\*\\/)*(?:\\\\0*67|\\\\0*47|g)(?:\\/\\*.*?\\*\\/)*))[^\\w]*(?:\\\\0*3a|\\\\0*3a|:)[^\\w]*(?:\\\\0*75|\\\\0*55|u)(?:\\\\0*72|\\\\0*52|r)(?:\\\\0*6c|\\\\0*4c|l)|
61 #properties
62 (?:^|[^\\w])(?:on(?:abort|activate|afterprint|afterupdate|autocomplete|autocompleteerror|beforeactivate|beforecopy|beforecut|beforedeactivate|beforeeditfocus|beforepaste|beforeprint|beforeunload|beforeupdate|blur|bounce|cancel|canplay|canplaythrough|cellchange|change|click|close|contextmenu|controlselect|copy|cuechange|cut|dataavailable|datasetchanged|datasetcomplete|dblclick|deactivate|drag|dragend|dragenter|dragleave|dragover|dragstart|drop|durationchange|emptied|encrypted|ended|error|errorupdate|filterchange|finish|focus|focusin|focusout|formchange|forminput|hashchange|help|input|invalid|keydown|keypress|keyup|languagechange|layoutcomplete|load|loadeddata|loadedmetadata|loadstart|losecapture|message|mousedown|mouseenter|mouseleave|mousemove|mouseout|mouseover|mouseup|mousewheel|move|moveend|movestart|mozfullscreenchange|mozfullscreenerror|mozpointerlockchange|mozpointerlockerror|offline|online|page|pagehide|pageshow|paste|pause|play|playing|popstate|progress|propertychange|ratechange|readystatechange|reset|resize|resizeend|resizestart|rowenter|rowexit|rowsdelete|rowsinserted|scroll|search|seeked|seeking|select|selectstart|show|stalled|start|storage|submit|suspend|timer|timeupdate|toggle|unload|volumechange|waiting|webkitfullscreenchange|webkitfullscreenerror|wheel)|formaction|data\\-bind|ev:event)[^\\w]
63 )/ix';
64
65 public function __construct($attributes) {
66 $this->id = $attributes['id'];
67 $this->logic = $attributes['rule_logic'];
68 $this->actions = $attributes['actions'];
69 $this->execute_on = $attributes['execute_on'];
70 $this->min_rule_engine_ver = $attributes['min_rule_engine_ver'];
71
72 if (array_key_exists('max_rule_engine_ver', $attributes)) {
73 $this->max_rule_engine_ver = $attributes['max_rule_engine_ver'];
74 }
75
76 if (array_key_exists('config', $attributes) && is_array($attributes['config'])) {
77 $this->config = $attributes['config'];
78 }
79
80 if (array_key_exists('opts', $attributes) && is_array($attributes['opts'])) {
81 $this->opts = $attributes['opts'];
82 }
83 }
84
85 public static function init($attributes) {
86 if (!is_array($attributes)) {
87 return false;
88 }
89
90 if (!array_key_exists('min_rule_engine_ver', $attributes) || !is_float($attributes['min_rule_engine_ver']) ||
91 $attributes['min_rule_engine_ver'] > WPRProtectFWRuleEngine_V636::VERSION) {
92
93 return false;
94 }
95
96 if (array_key_exists('max_rule_engine_ver', $attributes) && (!is_float($attributes['max_rule_engine_ver']) ||
97 $attributes['max_rule_engine_ver'] < WPRProtectFWRuleEngine_V636::VERSION)) {
98
99 return false;
100 }
101
102 if (!array_key_exists('id', $attributes) || (is_int($attributes['id']) && $attributes['id'] <= 0)) {
103 return false;
104 }
105
106 if (!array_key_exists('rule_logic', $attributes) || !is_array($attributes['rule_logic'])) {
107 return false;
108 }
109
110 if (!array_key_exists('actions', $attributes) || !is_array($attributes['actions'])) {
111 return false;
112 }
113
114 if (!array_key_exists('execute_on', $attributes)) {
115 if (array_key_exists('level', $attributes) && $attributes['level'] === 1) {
116 $attributes['execute_on'] = WPRProtectFWRule_V636::EXE_ON_BOOT;
117 } else {
118 return false;
119 }
120 }
121
122 return new WPRProtectFWRule_V636($attributes);
123 }
124
125 public function isExeOnBoot() {
126 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_BOOT);
127 }
128
129 public function isExeOnPreUpdateOption() {
130 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_PRE_UPDATE_OPTION);
131 }
132
133 public function isExeOnPreDeletePost() {
134 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_PRE_DELETE_POST);
135 }
136
137 public function isExeOnWPInsertPostEmptyContent() {
138 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_WP_INSERT_POST_EMPTY_CONTENT);
139 }
140
141 public function isExeOnInsertUserMeta() {
142 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_INSERT_USER_META);
143 }
144
145 public function isExeOnDeleteOption() {
146 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_DELETE_OPTION);
147 }
148
149 public function isExeOnDeleteUser() {
150 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_DELETE_USER);
151 }
152
153 public function isExeOnPasswordReset() {
154 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_PASSWORD_RESET);
155 }
156
157 public function isExeOnSendAuthCookies() {
158 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_SEND_AUTH_COOKIES);
159 }
160
161 public function isExeOnSetAuthCookie() {
162 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_SET_AUTH_COOKIE);
163 }
164
165 public function isExeOnInit() {
166 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_INIT);
167 }
168
169 public function isExeOnUserRegister() {
170 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_USER_REGISTER);
171 }
172
173 public function isExeOnAddUserMeta() {
174 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_ADD_USER_META);
175 }
176
177 public function isExeOnUpdateUserMetadata() {
178 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_UPDATE_USER_METADATA);
179 }
180
181 public function isExeOnUpdateUserMeta() {
182 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_UPDATE_USER_META);
183 }
184
185 public function isExeOnAddOption() {
186 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_ADD_OPTION);
187 }
188
189 public function isExeOnWpPreInsertUserData() {
190 return ($this->execute_on === WPRProtectFWRule_V636::EXE_ON_WP_PRE_INSERT_USER_DATA);
191 }
192 }
193 endif;