403Webshell
Server IP : 62.60.133.156  /  Your IP : 216.73.217.51
Web Server : LiteSpeed
System : Linux linux24.centraldnserver.com 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64
User : mimradmin ( 1166)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, exec, popen, proc_open
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : OFF |  Pkexec : OFF
Directory :  /home/mimradmin/www/wp-content/plugins/wp-ultimate-csv-importer/importExtensions/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/mimradmin/www/wp-content/plugins/wp-ultimate-csv-importer/importExtensions/OpenAIHelper.php
<?php
/******************************************************************************************
 * Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 * You can contact Smackcoders at email address info@smackcoders.com.
 *******************************************************************************************/

 namespace Smackcoders\FCSV;

 if ( ! defined( 'ABSPATH' ) )
	exit; // Exit if accessed directly

class OpenAIHelper {
    private $apiKey;
    private $baseUrl = 'https://api.openai.com/v1/chat/completions';
    private $image_baseUrl = 'https://api.openai.com/v1/images/generations';
    public function generateContent($prompt, $maxCharacters) {
        $get_key =get_option('openAI_settings');
        $this->apiKey = $get_key;

        $data = [
            'messages' => [['role' => 'user', 'content' => $prompt]],
            'model' => 'gpt-3.5-turbo',
            'max_tokens' => $maxCharacters,
        ];

        $headers = [
            'Content-Type' => 'application/json',
            'Authorization' => 'Bearer ' . $this->apiKey,
        ];

        $response = wp_remote_post($this->baseUrl, array(
            'body' => json_encode($data),
            'headers' => $headers,
        ));

        $httpCode = wp_remote_retrieve_response_code($response);
        $decodedResponse = json_decode(wp_remote_retrieve_body($response), true);
        if (isset($httpCode) && $httpCode != 200) {
            return $httpCode;
        }
        if (isset($decodedResponse['choices'][0]['message']['content'])) {
            return $decodedResponse['choices'][0]['message']['content'];
        } else {
            return false;
        }
    }
    public function generateImage($prompt) {
        $get_key =get_option('openAI_settings');
        $this->apiKey = $get_key;
        $data = [
            'prompt' => $prompt,
            'model' => 'dall-e-3',
        ];

        $headers = [
            'Content-Type' => 'application/json',
            'Authorization' => 'Bearer ' . $this->apiKey,
        ];

        $response = wp_remote_post($this->image_baseUrl, array(
            'body' => json_encode($data),
            'headers' => $headers,
            'timeout' => 60,
        ));
        $httpCode = wp_remote_retrieve_response_code($response);
        $decodedResponse = json_decode(wp_remote_retrieve_body($response), true);

        if ($httpCode !== 200) {
            return $httpCode;
        }
        if (isset($decodedResponse['data'][0]['url'])) {
            return $decodedResponse['data'][0]['url'];
        } else {
            return false;
        }
    }
}

Youez - 2016 - github.com/yon3zu