| Server IP : 207.135.97.11 / Your IP : 172.19.0.1 Web Server : LiteSpeed System : Linux 6d372a2d2e33 5.14.0-611.24.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 23 11:42:43 UTC 2026 x86_64 User : nobody ( 65534) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/ed.net.au/wp-content/plugins/search-regex/includes/sql/ |
Upload File : |
<?php
namespace SearchRegex\Sql;
/**
* A simple sanitizer for table names, column names, and raw (pre-sanitized) names. This shouldn't be treated as a replacement for $wpdb->prepare, and is just
* a way of being extra-paranoid when forming queries with known column and table names.
*/
class Value {
/**
* Underlying value
*
* @readonly
*/
private string $value;
/**
* Constructor
*
* @param string $value Value.
*/
public function __construct( $value ) {
$this->value = $value;
}
/**
* Get the sanitized value.
*
* @return string
*/
public function get_value() {
return $this->value;
}
/**
* Create a Value with a known sanitized value. You should only use this when you are sure the value is safe.
*
* @param string $value Value.
* @return Value
*/
public static function safe_raw( $value ) {
return new Value( $value );
}
/**
* Create a Value for a SQL column. Performs column sanitization and allows for column aliases
*
* @param string $column Column name.
* @return Value
*/
public static function column( $column ) {
$column = (string) preg_replace( '/[^ A-Za-z0-9_\-\.]/', '', $column );
return new Value( $column );
}
/**
* Create a Value for a SQL table name. Performs table name sanitization.
*
* @param string $table Table name.
* @return Value
*/
public static function table( $table ) {
$table = (string) preg_replace( '/[^A-Za-z0-9_\-]/', '', $table );
return new Value( $table );
}
}