45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* functions/sanitize.php
|
|
*
|
|
* This class is used to sanitize user input.
|
|
*
|
|
* @version 1.1.2
|
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
* @link https://TheTempusProject.com/libraries/Bedrock
|
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
*/
|
|
namespace TheTempusProject\Bedrock\Functions;
|
|
|
|
class Sanitize {
|
|
/**
|
|
* This function strips all html tags except for p/a/br from the given string.
|
|
*
|
|
* @param {string} [$data] - The string to be parsed
|
|
* @return {string} - The sanitized string.
|
|
*/
|
|
public static function contentShort( $data ) {
|
|
return strip_tags( $data, '<p><a><br>' );
|
|
}
|
|
|
|
/**
|
|
* This function is to remove $'s and brackets from the rich HTML editor
|
|
* which are the only parts that cause parse issues
|
|
*
|
|
* @param {string} [$data] - The string to be parsed
|
|
* @return {string} - The sanitized string.
|
|
*/
|
|
public static function rich( $data ) {
|
|
$data = preg_replace( '#\{#', '{', $data );
|
|
$data = preg_replace( '#\}#', '}', $data );
|
|
$data = preg_replace( '#\$#', '$', $data );
|
|
return $data;
|
|
}
|
|
|
|
public static function url( $data ) {
|
|
$trimmed = rtrim( $data, '/' );
|
|
$filtered = filter_var( $trimmed, FILTER_SANITIZE_URL );
|
|
return $filtered;
|
|
}
|
|
}
|