MINI Sh3ll
Path : /var/www/html/ |
|
Current File : /var/www/html/mahindra-response.php.19112022 |
<?php
header("Content-Type:text/plain");
ini_set("display_errors", 0);
$request = $_GET;
function makePostRequest($url){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
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_HTTPHEADER => array(
'Cookie: CookieConsentPolicy=0:1; LSKey-c$CookieConsentPolicy=0:1; BrowserId=vLXg7UVbEe2i2e81D-MCFw'
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
function makePostRequestWithToken($leadurl, $token){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $leadurl,
CURLOPT_RETURNTRANSFER => true,
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(
'Authorization: Bearer '.$token
),
));
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
function getAuthToken(){
$parameters = [];
$parameters['grant_type'] = 'password';
$parameters['client_id'] = '3MVG9e2mBbZnmM6nS2b1kONDo41ooRgGQ3423ov0QpqVN.qhpqQSLVKyUhbv.tmmu_HxBwQBw2akE0YZgFQXh';
$parameters['client_secret'] = '614985C14C471F26CA739B10F995D740DF1D541D47259A7A22B365A33A62733F';
$parameters['username'] = '[email protected]';
$parameters['password'] = 'Mahindra@123';
$auth_url = 'https://mahindralifespaces--sandbox.my.salesforce.com/services/oauth2/token?'.http_build_query($parameters);
$auth_response = makePostRequest($auth_url);
$alogPath = getcwd().'/mahindra-auth-log-'.date('dmY').'.log';
if(!file_exists($alogPath))
mkdir(dirname($alogPath), 0777, true);
$lead_response = makePostRequestWithToken($lead_url, $token);
$data=[];
$data['datetime'] = date("Y-m-d H:i:s");
$data['auth_url'] = $auth_url;
$data['auth_response'] = $auth_response;
file_put_contents($alogPath, json_encode($data).PHP_EOL, LOCK_EX | FILE_APPEND);
return $auth_response;
}
function submitLead($token, $request){
$enqSubSources = [
'GOODLIFE'=> 'Hoarding',
'LIFE' => 'Train',
'GOOD' => 'Radio',
'KALYAN' => 'Site Branding'
];
$parameters = [];
$parameters['lastName'] = 'Customer';
$parameters['email'] = '[email protected]';
$parameters['mobile'] = $request['mobileno'];
$parameters['projectName'] = 'a1X5j000000khbC'; //'a1XN0000000lGzJ';
$parameters['source'] = $enqSubSources[strtoupper($request['keyword'])];
$parameters['enqStatus'] = 'Open';
$parameters['enqType'] = 'Presales/Digital';
$parameters['enqSubSrc'] = strtoupper($request['keyword']);
//$lead_url = 'https://mahindralifespaces--sandbox.my.salesforce.com/services/apexrest/GTech?'.http_build_query($parameters);
$lead_url = 'https://mahindralifespaces--sandbox.sandbox.my.salesforce.com/services/apexrest/GTech?'.http_build_query($parameters);
$logPath = getcwd().'/mahindra-lead-log-'.date('dmY').'.log';
if(!file_exists($logPath))
mkdir(dirname($logPath), 0777, true);
$lead_response = makePostRequestWithToken($lead_url, $token);
$data=[];
$data['datetime'] = date("Y-m-d H:i:s");
$data['token'] = $token;
$data['lead_url'] = $lead_url;
$data['lead_response'] = $lead_response;
file_put_contents($logPath, json_encode($data).PHP_EOL, LOCK_EX | FILE_APPEND);
return $lead_response;
}
$auth_data = getAuthToken();
$auth_data = json_decode($auth_data, true);
$submit_response = submitLead($auth_data['access_token'], $request);
$submit_response = json_decode($submit_response, true);
/*
print_r($auth_data);
print_r($submit_response);
*/
$response_message = '';
if(isset($submit_response['message'])){
$response_message = $submit_response['message'];
}
else
$response_message = $submit_response['error'] .' - '.$submit_response['error_description'];
print $response_message;
die;
?>
OHA YOOOO