mirror of
https://github.com/twisterarmy/cloud-server.git
synced 2025-03-13 05:51:46 +00:00
add userPost filter, allow mixed data input
This commit is contained in:
parent
91f368af58
commit
a596be9eb4
@ -4,7 +4,7 @@ class Filter {
|
||||
|
||||
public static function userName(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^a-zA-Z0-9_]+/u', '', $string);
|
||||
$string = preg_replace('/[^a-zA-Z0-9_]+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 16);
|
||||
|
||||
@ -13,71 +13,76 @@ class Filter {
|
||||
|
||||
public static function userPrivateKey(mixed $string) {
|
||||
|
||||
return preg_replace('/[^a-zA-Z0-9_]+/u', '', $string);
|
||||
return preg_replace('/[^a-zA-Z0-9_]+/u', '', (string) $string);
|
||||
}
|
||||
|
||||
public static function blockHash(mixed $string) {
|
||||
|
||||
return preg_replace('/[^a-zA-Z0-9]+/u', '', $string);
|
||||
return preg_replace('/[^a-zA-Z0-9]+/u', '', (string) $string);
|
||||
}
|
||||
|
||||
public static function fullName(string $string) {
|
||||
public static function fullName(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\s\w]+/u', '', $string);
|
||||
$string = preg_replace('/[^\s\w]+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 200);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function location(string $string) {
|
||||
public static function sigUserPost(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\s\w\.\,]+/u', '', $string);
|
||||
return preg_replace('/[^a-zA-Z0-9]+/u', '', (string) $string);
|
||||
}
|
||||
|
||||
public static function location(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\s\w\.\,]+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 200);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function url(string $string) {
|
||||
public static function url(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\w\?\&\=\.\:\/]+/u', '', $string);
|
||||
$string = preg_replace('/[^\w\?\&\=\.\:\/]+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 200);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function bitMessage(string $string) {
|
||||
public static function bitMessage(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\w\-]+/u', '', $string);
|
||||
$string = preg_replace('/[^\w\-]+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 200);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function tox(string $string) {
|
||||
public static function tox(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\w]+/u', '', $string);
|
||||
$string = preg_replace('/[^\w]+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 200);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function bio(string $string) {
|
||||
public static function bio(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\s\w\.\,\:\;\@\?\!\+\`\&\^\%\#\=\-\_\~\*\/\(\)\[\]\<\>\"\']+/u', '', $string);
|
||||
$string = preg_replace('/[^\s\w\.\,\:\;\@\?\!\+\`\&\^\%\#\=\-\_\~\*\/\(\)\[\]\<\>\"\']+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 500);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function post(string $string) {
|
||||
public static function post(mixed $string) {
|
||||
|
||||
$string = preg_replace('/[^\s\w\.\,\:\;\@\?\!\+\`\&\^\%\#\=\-\_\~\*\/\(\)\[\]\<\>\"\']+/u', '', $string);
|
||||
$string = preg_replace('/[^\s\w\.\,\:\;\@\?\!\+\`\&\^\%\#\=\-\_\~\*\/\(\)\[\]\<\>\"\']+/u', '', (string) $string);
|
||||
|
||||
$string = mb_substr($string, 0, 140);
|
||||
|
||||
@ -93,4 +98,43 @@ class Filter {
|
||||
|
||||
return (int) $int;
|
||||
}
|
||||
|
||||
public static function userPost(mixed $userPost) {
|
||||
|
||||
$result = [];
|
||||
foreach ((array) $userPost as $key => $value) {
|
||||
|
||||
switch ($key) {
|
||||
case 'height':
|
||||
$result[$key] = self::int($value);
|
||||
break;
|
||||
case 'time':
|
||||
$result[$key] = self::int($value);
|
||||
break;
|
||||
case 'k':
|
||||
$result[$key] = self::int($value);
|
||||
break;
|
||||
case 'lastk':
|
||||
$result[$key] = self::int($value);
|
||||
break;
|
||||
case 'n':
|
||||
$result[$key] = self::userName($value);
|
||||
break;
|
||||
case 'msg':
|
||||
$result[$key] = self::post($value);
|
||||
break;
|
||||
case 'msg2':
|
||||
$result[$key] = self::post($value);
|
||||
break;
|
||||
case 'sig_rt':
|
||||
$result[$key] = self::sigUserPost($value);
|
||||
break;
|
||||
case 'rt':
|
||||
$result[$key] = self::userPost($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user