| Server IP : 13.126.101.145 / Your IP : 216.73.217.50 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/themes/hello-elementor-child/custom/ |
Upload File : |
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
include_once($_SERVER['DOCUMENT_ROOT'] . '/wp-config.php');
require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
global $wpdb;
// print_r($_POST);exit;
$full_name = $_POST['full_name'];
$lead_email = $_POST['lead_email'];
$lead_phone = $_POST['lead_phone'];
$location = $_POST['location'];
$region = getRegionLeads($location);
$product_name = $_POST['product_name'];
$subsidary_products = $_POST['subsidary_products'];
$remarks = sanitize_textarea_field($_POST['remarks']);
$stdate = $_POST['start_date'];
$enddate = $_POST['end_date'];
$start_date = date("Y-m-d",strtotime($stdate));
$end_date = date("Y-m-d",strtotime($enddate));
$tablename ='wp_leads';
$date = date('Y-m-d H:i:s');
$user_ID = get_current_user_id();
// to store data in leads table
$result = $wpdb->insert('wp_leads', array(
'full_name' => $full_name,
'user_id' => $user_ID ?? 0,
'lead_email' => $lead_email,
'lead_phone' => $lead_phone,
'rental_startdate' => $start_date,
'rental_enddate' => $end_date,
'location' => $location,
'region' => $region,
'product_name' => $product_name,
'subsidary_products' => $subsidary_products,
'remarks'=> $remarks,
'lead_created_on' => $date
));
$lastid = $wpdb->insert_id;
//Send In App Notification
if ($user_ID) {
create_notification(
'User Raised An Enquiry',
'User "' . $user_login .'" has raised an Enquiry in RMS Portal.',
array(
'meta_input' => array(
'user_id' => $user->ID,
'action' => 'create_enquiry',
)
)
);
}
else {
create_notification(
'Visitor Raised An Enquiry',
'Visitor "' . $full_name .'" has raised an Enquiry in RMS Portal.',
array(
'meta_input' => array(
'user_id' => $full_name,
'action' => 'create_enquiry',
)
)
);
}
// send data to oracle crm api and get lead id
if (function_exists('curl_init')) {
$postData = [
'Name' => $full_name,
'Stage_c' => "Lead",
'PrimaryContactPartyName' => $full_name,
'PrimaryContactEmailAddress' => $lead_email,
'PrimaryPhoneNumber' => $lead_phone,
'ProductGroupName' => $product_name,
'LeadType_c' => "Ebiz",
'LeadSource_c' => "RMS",
'EquipmentType_c' => "Rental",
'Location_c' => $location,
'Remarks_c' => $remarks
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://eiik-test.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/leads',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Basic ' . base64_encode("GMMRMS01:Gmm#rms01")
]
]);
$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpcode == 201) {
$decode = json_decode($response, true);
$wpdb->update('wp_leads', [
'lead_id' => $decode['LeadId'],
'lead_number' => $decode['LeadNumber'],
'lead_source' => "RMS",
'lead_type' => "Ebiz",
'equipment_type' => "Rental",
'crm_response' => $response,
'lead_created_on' => $date
], ['id' => $lastid]);
}
} else {
file_put_contents(__DIR__ . '/lead-debug.txt', "❌ cURL is NOT enabled\n", FILE_APPEND);
}
// Send email
try {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->SMTPAuth = true;
$mail->Username = 'ADtest@gmmcoindia.com';
$mail->Password = '!N$s1ie3$';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('ADtest@gmmcoindia.com', 'GMMCO');
$mail->addAddress($lead_email);
$mail->isHTML(true);
$mail->Subject = 'Thank You for Your Request';
$mail->Body = "<h1>Dear " . ucwords($full_name) . "</h1>
<p>Thanks for visiting us. Your enquiry is important to us and has been received. Our team will reach out to you shortly.</p>
<p>Team GRS</p>";
$mail->send();
echo json_encode(['success' => true, 'message' => 'Enquiry submitted and mail sent successfully.']);
} catch (Exception $e) {
echo json_encode(['success' => false, 'message' => 'Mail could not be sent. Mailer Error: ' . $mail->ErrorInfo]);
}
// Region helper
function getRegionLeads($location) {
$south = ['Karnataka', 'Kerala', 'Tamil Nadu'];
$east = ['Andhra Pradesh', 'Telangana'];
$west = ['Maharashtra', 'Goa', 'Gujarat'];
$north = ['Madhya Pradesh', 'Chhattisgarh'];
if (in_array($location, $south)) return 'South';
elseif (in_array($location, $north)) return 'North';
elseif (in_array($location, $east)) return 'East';
elseif (in_array($location, $west)) return 'West';
else return 'Other';
}
/* function sendSMS(){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://boancomm.net/boansms/boansmsinterface.aspx',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'mobileno='.$user_phone.'&smsmsg=Dear%20Customer%20'.$otp.'%20is%20Gmmco%20Ltd%20OTP%20to%20verify%20your%20mobile%20number%20for%20Website%20related%20services%20to%20reach%20you&uname=gmmco&pwd=gmmco11&pid=1194',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
//echo $response;
if($res){
echo 0;
}else{
echo 1;
}
} */