-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
215cc02
commit aa9c3ac
Showing
3 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,23 @@ public static function cleanString(string $string, bool $toLower = false, string | |
return $string; | ||
} | ||
|
||
/** | ||
* Clean strings like GET or POST params for SQL usage or usage in HTML. Disallowed characters are removed. | ||
* Disallowed characters to sanitize SQL queries are: /\+*#?$%&!='"`´<>{}[]() and -- (double minus) | ||
* | ||
* Example replacements: | ||
* 'Réne Nüßer' => 'Réne Nüßer', | ||
* 'Not this/\+=*#?$%&!;"\'´`<>{}[]()--nono' => 'Not thisnono', | ||
* 'But [email protected]_is,ok' => 'But [email protected]_is,ok', | ||
* | ||
* @param string $string | ||
* @return string | ||
*/ | ||
public static function sanitizeString(string $string): string | ||
{ | ||
return preg_replace('/[\/\\+*#?$%&!=\'"`´<>{}\[\]()]|--/', '', $string); | ||
} | ||
|
||
public static function getRandomString(int $length = 32, bool $lowerAndUpperCase = true): string | ||
{ | ||
$characters = implode('', range(0, 9)) . implode('', range('a', 'z')); | ||
|