403Webshell
Server IP : 54.37.205.81  /  Your IP : 216.73.216.76
Web Server : nginx/1.22.1
System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64
User : debian ( 1000)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/cameramodaitalia.it/public/wp-content/plugins/crmi-ai-agent/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/cameramodaitalia.it/public/wp-content/plugins/crmi-ai-agent/crmi-ai-agent.php
<?php
/**
 * Plugin Name: CRMI Live AI Agent
 * Description: Un widget di chat AI "agente live" per WordPress basato sull'API di OpenAI. Rende un pulsante flottante e/o uno shortcode [crmi_ai_agent].
 * Version: 1.0.0
 * Author: CRMI + ChatGPT
 * License: GPLv2 or later
 * Text Domain: crmi-ai-agent
 */

if ( ! defined( 'ABSPATH' ) ) exit;

define( 'CRMI_AI_AGENT_VERSION', '1.0.0' );
define( 'CRMI_AI_AGENT_DIR', plugin_dir_path(__FILE__) );
define( 'CRMI_AI_AGENT_URL', plugin_dir_url(__FILE__) );

require_once CRMI_AI_AGENT_DIR . 'includes/class-crmi-ai-agent-admin.php';
require_once CRMI_AI_AGENT_DIR . 'includes/class-crmi-ai-agent-rest.php';

/**
 * Enqueue scripts/styles frontend
 */
function crmi_ai_agent_enqueue() {
    // CSS
    wp_enqueue_style( 'crmi-ai-agent', CRMI_AI_AGENT_URL . 'assets/agent.css', array(), CRMI_AI_AGENT_VERSION );
    // JS
    wp_enqueue_script( 'crmi-ai-agent', CRMI_AI_AGENT_URL . 'assets/agent.js', array('wp-i18n','wp-util'), CRMI_AI_AGENT_VERSION, true );

    $opts = get_option('crmi_ai_agent_options', array());
    $data = array(
        'restUrl'   => esc_url_raw( rest_url('crmi-ai/v1/chat') ),
        'nonce'     => wp_create_nonce('wp_rest'),
        'welcome'   => isset($opts['welcome']) ? $opts['welcome'] : 'Ciao! Come posso aiutarti?',
        'brand'     => isset($opts['brand']) ? $opts['brand'] : '#000000',
        'showBubble'=> !empty($opts['bubble']) ? (bool)$opts['bubble'] : false,
        'gdpr'      => !empty($opts['gdpr_text']) ? $opts['gdpr_text'] : 'Questo assistente usa IA per rispondere. Non inserire dati sensibili.',
        'fallback'  => array(
            'whatsapp' => isset($opts['whatsapp']) ? $opts['whatsapp'] : '',
            'email'    => isset($opts['email']) ? $opts['email'] : ''
        ),
        'shortcodePresent' => false, // sarà aggiornato dallo shortcode render
    );
    wp_localize_script('crmi-ai-agent', 'CRMI_AI_AGENT', $data);
}
add_action('wp_enqueue_scripts', 'crmi_ai_agent_enqueue');

/**
 * Shortcode [crmi_ai_agent]
 */
function crmi_ai_agent_shortcode($atts) {
    // Flag per non duplicare quando c'è anche il bubble auto
    wp_add_inline_script('crmi-ai-agent', 'if (window.CRMI_AI_AGENT) { CRMI_AI_AGENT.shortcodePresent = true; }','before');
    ob_start();
    include CRMI_AI_AGENT_DIR . 'templates/agent-widget.php';
    return ob_get_clean();
}
add_shortcode('crmi_ai_agent', 'crmi_ai_agent_shortcode');

/**
 * Auto-inject del bottone flottante nel footer se attivo
 */
function crmi_ai_agent_footer_inject() {
    $opts = get_option('crmi_ai_agent_options', array());
    $show = !empty($opts['bubble']);
    if ( $show ) {
        // Output div mount point
        echo '<div id="crmi-ai-agent-floating-root"></div>';
    }
}
add_action('wp_footer', 'crmi_ai_agent_footer_inject');

// Init Admin and REST
add_action('plugins_loaded', function() {
    new CRMI_AI_Agent_Admin();
    new CRMI_AI_Agent_Rest();
});

Youez - 2016 - github.com/yon3zu
LinuXploit