MINI Sh3ll
Path : /var/www/html/ |
|
Current File : /var/www/html/mahindra-response.php14072023 |
<?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'] = '3MVG9ZL0ppGP5UrC_SbpIQAEslzufzcGsrFRwqAr8WY9TIecByvUUNBoGN0k3Gwn6_0YApnf7lDekEdFfLlgK';
$parameters['client_secret'] = '922C07FBD52F6AE6473A68CBD96AE812B0C9758E924E5E1521DEE82169FCF010';
$parameters['username'] = '[email protected]';
$parameters['password'] = 'Mahindra@1234PPT5onKWVjV9MvGdwLGIMQ39';
$auth_url = 'https://mahindralifespaces.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',
'MHP2' => 'Print ad & Hoarding',
'PALGHAR' => 'Site Branding',
'MHT' => 'Site Branding'
];*/
$data = [];
$data['GOODLIFE'] = ['email' => '[email protected]', 'source' => 'Hoarding', 'projectName' => 'Mahindra Happinest Kalyan-2'];
$data['LIFE'] = ['email' => '[email protected]', 'source' => 'Train', 'projectName' => 'Mahindra Happinest Kalyan-2'];
$data['GOOD'] = ['email' => '[email protected]', 'source' => 'Radio', 'projectName' => 'Mahindra Happinest Kalyan-2'];
//$data['KALYAN'] = ['source' => 'Site Branding', 'projectName' => 'Mahindra Happinest Kalyan-2'];
$data['KALYAN'] = ['email' => '[email protected]', 'source' => 'Hoarding', 'projectName' => 'Mahindra Happinest Kalyan-2'];
//$data['MHP2'] = ['email' = '[email protected]', 'source' => 'Print ad & Hoarding', 'projectName' => 'Happinest Palghar'];
/*$data['MHP2'] = ['email' => '[email protected]', 'source' => 'Print ad & Hoarding', 'projectName' => 'Mahindra Happinest Palghar – 2'];
$data['PALGHAR'] = ['email' => '[email protected]', 'source' => 'Outdoor and Radio', 'projectName' => 'Mahindra Happinest Palghar – 2'];
$data['PALGHAR2'] = ['email' => '[email protected]', 'source' => 'Site Branding', 'projectName' => 'Mahindra Happinest Palghar – 2'];
*/
$data['MHP2'] = ['email' => '[email protected]', 'source' => 'Print ad & Hoarding', 'projectName' => 'a1X2x000000Lfg2'];
$data['PALGHAR'] = ['email' => '[email protected]', 'source' => 'Outdoor and Radio', 'projectName' => 'a1X2x000000Lfg2'];
$data['PALGHAR2'] = ['email' => '[email protected]', 'source' => 'Site Branding', 'projectName' => 'a1X2x000000Lfg2'];
$data['MHT'] = ['email' => '[email protected]', 'source' => 'Print ad & Hoarding', 'projectName' => 'Happinest Tathawade'];
$data['MIK'] = ['email' => '[email protected]', 'source' => 'OOH', 'projectName' => 'a1X5j0000004UVB'];
$data['MI'] = ['email' => '[email protected]', 'source' => 'Print', 'projectName' => 'a1X5j0000004UVB'];
$data['MIRIS'] = ['email' => '[email protected]', 'source' => 'Site Branding', 'projectName' => 'a1X5j0000004UVB'];
$data['MK'] = ['email' => '[email protected]', 'source' => 'Train/ Metro', 'projectName' => 'a1X5j0000004UVB'];
$data['IRIS'] = ['email' => '[email protected]', 'source' => 'Radio', 'projectName' => 'a1X5j0000004UVB'];
//$data['MHT'] = ['source' => 'Print ad & Hoarding', 'projectName' => 'a1X2x000000Kz16'];
$data['ACPB'] = ['email' => '[email protected]', 'source' => 'Email', 'projectName' => 'a1X5j0000004UVB'];
$data['MHA'] = ['email' => '[email protected]', 'source' => 'Email', 'projectName' => 'a1X5j0000004UVB'];
$keyword = strtoupper($request['keyword']);
$parameters = [];
$parameters['lastName'] = 'Customer';
$parameters['email'] = $data[$keyword]['email']; // '[email protected]';
$parameters['mobile'] = $request['mobileno'];
$parameters['projectName'] = $data[$keyword]['projectName'];
//$parameters['projectName'] = in_array($keyword, ['MHP2', 'PALGHAR']) ? 'Mahindra Happinest Palghar – 2' : 'Mahindra Happinest Kalyan-2';
//'a1X5j000000khbC'; //'a1XN0000000lGzJ';
//$parameters['source'] = $enqSubSources[$keyword];
$parameters['source'] = $data[$keyword]['source'];
$parameters['enqStatus'] = 'Open';
$parameters['enqType'] = 'Presales/Digital';
$parameters['enqSubSrc'] = $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);
$lead_url = 'https://mahindralifespaces.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);
$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