APP1492 = $app_id;
$this-> APPMDZhYzg2NmE0MDhmZDRjMTc5MDFmYzU4 = $app_key;
$this-> https://mv-auto22.webnode.fr/boutique-en-ligne/ = $api_url;
$this-> fr = $app_lang;
}
public function sendRequest($request_params)
{
$enc_request = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->_app_key, json_encode($request_params), MCRYPT_MODE_ECB));
$params = array();
$params["enc_request"] = $enc_request;
$params["app_id"] = $this->_app_id;
$params["app_lang"] = $this->_app_lang;
//initialize and setup the curl handler
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
// UPDATE
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute the request
$result = curl_exec($ch);
curl_close($ch);
//json_decode the result
// var_dump($result);
$result = @json_decode($result , true);
if( $result == false || isset($result["success"]) == false ) {
return $result;
}
if( $result["success"] == false ) {
return $result;
}
//return the data
return $result;
}
/**
* getFormFileServiceOptions
*
* @param mixed $server_url Description.
* @param mixed $event Description.
*
* @access public
*
* @return mixed Value.
*/
public function getFormFileServiceOptions($server_url = false , $event = false){
if (isset($server_url) AND $server_url!="" AND isset($event) AND $event!=""){
//be the POST parameters
$params = array();
$params["evt"] = $event;
//initialize and setup the curl handler
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
// UPDATE
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute the request
$result = curl_exec($ch);
curl_close($ch);
//json_decode the result
$result = @json_decode($result , true);
return $result;
}
return false;
}
/**
* getStringLang
*
* @param mixed $lang_GET Description.
*
* @access public
*
* @return mixed Value.
*/
public function getStringLang($lang_GET = false){
$current_lang = $this->setLang($lang_GET);
if (isset($lang_GET) AND in_array($lang_GET, array("fr","en"))) $current_lang = $lang_GET;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.mod-files.com/res/lang/string-".$current_lang.".json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute the request
$lang = curl_exec($ch);
curl_close($ch);
$string = json_decode($lang, TRUE);
return $string;
}
/**
* setLang
*
* @param mixed $lang Description.
*
* @access public
*
* @return mixed Value.
*/
public function setLang($lang){
if (isset($lang) AND $lang!="" ){
// if (!preg_match("/^[a-z]{2}$/i", $lang)) $lang = "en";//$this->default_lang;
if (!in_array($lang, $this->arrayLang)) $lang = $this->default_lang;
$this->current_langue = $lang;
setcookie("__mflslg_",$lang,time()+124416000,"/",null,false,true); /// cookie de choix de la langue
return $lang;
}else if (isset($_COOKIE["__mflslg_"])){
$this->current_langue = $_COOKIE["__mflslg_"];
return $_COOKIE["__mflslg_"];
}else {
$this->current_langue = $this->default_lang;
return $this->default_lang;
}
}
}
$vehicule_type = "cars";
$fields = array();
$fields["action"] = "create";
foreach ($_POST as $key => $value) $fields[$key] = $value;
if ( isset($_FILES["fileUploader"]) ) {
$filename = $_FILES["fileUploader"]["tmp_name"];
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
}
$fields["file_tmp_name"] = base64_encode($data);
$fields["file_name"] = $_FILES["fileUploader"]["name"];
$fields["file_size"] = $_FILES["fileUploader"]["size"];
$fields["file_type"] = $_FILES["fileUploader"]["type"];
$fields["file_error"] = $_FILES["fileUploader"]["error"];
$apicaller = new ApiCaller("APP1492", "MDZhYzg2NmE0MDhmZDRjMTc5MDFmYzU4", "https://www.mod-files.com/api/v1/","fr");
$string = $apicaller->getStringLang("fr");
$gearboxList = $apicaller->getFormFileServiceOptions("https://www.mod-files.com/core/launch/gearbox.launch.php" , "getGearBoxList");
$readmethodList = $apicaller->getFormFileServiceOptions("https://www.mod-files.com/core/launch/readmethod.launch.php" , "getReadMethodList");
$tuningtypeList = $apicaller->getFormFileServiceOptions("https://www.mod-files.com/core/launch/tuningtype.launch.php" , "getTuningTypeList");
$markList = $apicaller->getFormFileServiceOptions("https://www.mod-files.com/core/launch/tuningfilesviewer.launch.php" , "getMarkList");
if (isset($_POST) AND !empty($_POST)) $response_request = $apicaller->sendRequest($fields);
?>