Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- header("Access-Control-Allow-Origin: *");
- require_once("Rest.php");
- include_once 'db.php';
- class API extends REST {
- public $data = "";
- const DB_SERVER = "localhost";
- const DB_USER = "root";
- const DB_PASSWORD = "root";
- const DB = "buscars";
- private $db = NULL;
- private $mysqli = NULL;
- private $conn;
- public function __construct(){
- parent::__construct(); // Iniciar parent contructor
- $this->dbConnect(); // Iniciar Database connection
- $this -> conn = new DB; // Carregar arquivo DB
- $base_url=$_SERVER['SERVER_NAME'];
- define('car_images',$base_url."/uploads/cars/");
- define('brand_images',$base_url."/uploads/brands/");
- define('carType_images',$base_url."/uploads/carType/");
- define('user_images',$base_url."/uploads/user/");
- // ================================================================== //
- define('Login_successfully',html_entity_decode('Login com sucesso'));
- define('Missing_Parameter',html_entity_decode('Parâmetro ausente'));
- define('Error_in_Update_service_provider_details',html_entity_decode('Erro nos detalhes do provedor de serviço de atualização'));
- define('Invalid_ID_Pass',html_entity_decode('ID ou senha de email inválida'));
- define('Error_in_Add_service_provider',html_entity_decode('Erro em Adicionar provedor de serviços'));
- define('Error_in_Add_service_provider',html_entity_decode('Erro em Adicionar provedor de serviços'));
- define('New_Password_send_to_your_mobile_number_and_Registered_Email',html_entity_decode('Nova senha envia para o seu número de celular e e-mail registrado'));
- define('Car_Model_List',html_entity_decode('Lista de modelos de carros'));
- define('No_Services',html_entity_decode('Atualmente você não está registrado para nenhum serviço'));
- define('Car_Details_Get_Successfully',html_entity_decode('Detalhes do carro obtêm sucesso'));
- define('Internal_server_error',html_entity_decode('Erro do Servidor Interno'));
- define('Subscription_plan_activated_successfully',html_entity_decode('Plano de assinatura ativado com sucesso,Verifique seu e-mail para detalhes'));
- define('Brand_List',html_entity_decode('Lista de marcas'));
- define('Signup_successfully',html_entity_decode('“Cadastro efetuado com sucesso!'));
- define('Inactive_account',html_entity_decode('Conta Inativa pelo administrador, entre em contato com Admin'));
- define("No_CAR_FOUND",html_entity_decode('Nenhum carro encontrado neste critério'));
- define("Car_Details_get_successfully",html_entity_decode('Detalhes do carro obtêm sucesso'));
- define('NoCarModalFound',html_entity_decode('Não foi encontrado nenhum modelo de carro'));
- define('Car_found',html_entity_decode('carros encontrados'));
- define('Service_provider_found',html_entity_decode('Provedor de serviços encontrado'));
- define('No_Service_Provider_Found',html_entity_decode('Nenhum fornecedor de serviços encontrado'));
- define('Request_sent_successfully',html_entity_decode('Pedido enviado com sucesso'));
- define('add_interest',html_entity_decode('Interesse enviado com sucesso!'));
- define('remove_interest',html_entity_decode('Interesse enviado com sucesso!'));
- define('add_favourite',html_entity_decode('Adicionado com sucesso'));
- define('remove_favourite',html_entity_decode('remover favorito com sucesso'));
- define('remove_favourite',html_entity_decode('remover favorito com sucesso'));
- define('Please_wait_for_admin_approval',html_entity_decode('Aguarde a aprovação do administrador'));
- define('Feedback_sent_successfully',html_entity_decode('Feedback enviado com sucesso'));
- define('Service_Provider_Details',html_entity_decode('Detalhes do fornecedor de serviços'));
- define('Admin_Service_Provider_Details',html_entity_decode('Aguarde a aprovação do administrador'));
- define('Error_in_Add_service_provider_details',html_entity_decode('Erro em Adicionar detalhes do fornecedor de serviços'));
- define('Api_key','AIzaSyDpLWwS0Q25KLcqQuavhiH3y__xHiLLjrQ');
- define('Profile_updated_successfully',html_entity_decode('Perfil atualizado com sucesso'));
- define('you_have_successfully_registered_for_service_provider',html_entity_decode('Você se registrou com sucesso para o provedor de serviços. Aguarde a aprovação do administrador.'));
- define('You_need_to_signup_first',html_entity_decode('Voce precisa se inscrever primeiro'));
- define('No_Record_Found',html_entity_decode('Nenhum Registro Encontrado'));
- define('Your_account_is_inactivated_by_admin',html_entity_decode('Sua conta está inativada pelo administrador'));
- // ================================================================== //
- }
- /*
- * Connect to Database
- */
- private function dbConnect(){
- $this->mysqli = new mysqli(self::DB_SERVER, self::DB_USER, self::DB_PASSWORD, self::DB);
- }
- /*
- * Dynmically call the method based on the query string
- */
- public function processApi(){
- $func = strtolower(trim(str_replace("/","",$_REQUEST['x'])));
- if((int)method_exists($this,$func) > 0)
- $this->$func();
- else
- $this->response('',404); // If the method not exist with in this class "Page not found".
- }
- public function service_provider(){
- return true;
- }
- //faz login do usuario
- private function user_login(){
- if($this->get_request_method() != "POST"){
- $this->response('',406);
- }
- $user_email = $_REQUEST['user_email'];
- $user_pass = $_REQUEST['user_pass'];
- $user_device_type = $_REQUEST['user_device_type'];
- if (!empty($user_email) and !empty($user_pass)) {
- if(filter_var($user_email, FILTER_VALIDATE_EMAIL)){
- $sql="
- SELECT *
- FROM tbl_user
- LEFT JOIN tbl_state
- ON tbl_state.state_id='tbl_user.user_state'
- LEFT JOIN tbl_city
- ON tbl_city.city_id='tbl_user.user_city'
- WHERE tbl_user.user_email='$user_email'
- AND user_password = '".md5($user_pass)."'"
- ;
- $records_user = $this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
- $result = $records_user->fetch_assoc();
- if (!empty($result)) {
- $user_status = $result['user_status'];
- $verified_status = $result['verified_status'];
- if($verified_status==1){
- if($user_status ==1){
- $user_id = $result['user_id'];
- $city_id = $result['user_city'];
- $city_name = $result['city_name'];
- $city_name = html_entity_decode($city_name);
- $state_name = $result['state_name'];
- $state_name = html_entity_decode($state_name);
- $state_id = $result['user_state'];
- $user_login_type = $result['user_login_type'];
- // $city_name = $records_user[0]['city_name'];
- // $state_name = $records_user[0]['state_name'];
- $data['user_device_type'] = $user_device_type;
- // $data['user_device_token'] = $user_device_token;
- // $data['user_device_id'] = $user_device_id;
- // $data['user_city'] = $user_city;
- // $data['user_state'] = $user_state;
- if(!empty($result['user_profile_pic'])){
- $pic=user_images.$result['user_profile_pic'];
- } else {
- $pic='';
- }
- $update_token = $this->conn->updatetablebyid('tbl_user', 'user_id', $user_id, $data);
- $post = array(
- "status" => "true",
- "message" =>Login_successfully,
- 'user_id'=>$user_id,
- 'user_name'=>$result['user_name'],
- 'user_email'=>$result['user_email'],
- 'user_phone'=>$result['user_phone'],
- 'user_profile_pic'=>$pic,
- 'user_type'=>$result['user_type'],
- 'verified_status'=>$result['verified_status'],
- 'city_id'=>$city_id,
- 'city_name'=>$city_name,
- 'state_id'=>$state_id,
- 'state_name'=>$state_name,
- 'user_password'=>$user_pass,
- 'user_login_type'=>$user_login_type
- );
- } else {
- $post = array("status" => "false", "message" => Your_account_is_inactivated_by_admin );
- }
- } else {
- $post = array("status" => "false", "message" => Please_wait_for_admin_approval );
- }
- } else {
- $post = array("status" => "false", "message" => Invalid_ID_Pass);
- }
- }
- } else{
- $post = array(
- "status" => "false",
- "message" => Missing_Parameter,
- 'user_email' => $user_email,
- 'user_pass' => $user_pass
- );
- }
- echo $this->response($this->json($post), 200);
- }
- function email_verification($user_email){
- $path = 'http://'.$_SERVER['HTTP_HOST'].'/Recharge/email_verify/';
- $path1='http://'.$_SERVER['HTTP_HOST'].'/Recharge/webassets/images/logo.png';
- $subject = 'Email verification link';
- $mail_msg .= '
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body bgcolor="#f1f1f1">
- <table cellpadding="0" cellspacing="0" width="600" style="background:#fff; border:1px solid #cbcbcb; margin:0 auto; font-family:Arial, Helvetica, sans-serif; font-size:12px;">
- <thead class="header">
- <tr>
- <td style="background:#fff; height:62px; width:100%; padding:5px; border-bottom:1px solid #DDD;" valign="middle">
- <a href="#" style="margin-left:10px;"><img width="100" src="'.$path1.'" alt="..."/></a>
- </td>
- </tr>
- </thead>
- <tbody style=" border-bottom:1px solid #ddd;">
- <tr>
- <td style="padding:10px 15px;">
- <h1 style="margin-bottom:0px; color:#5BBE4F;">Dear ' . ucfirst($user_email) . '</h1>
- Thank you for registering with Us. Before we can activate your account one last step must be taken to complete your registration!<br/><br/>
- Please note - you must complete this last step to become a registered member. You will only need to click on the link once, and your account will be updated.<br/>
- To complete your registration, click on the link below:<br/><br/>
- <div style="padding:20px; background-color: #70a93c; color:#fff; text-align:center;">
- <a href=' . $path . "verify_email.php?email=" . base64_encode($user_email) . '>Please click here activate your accout</a>
- </div>
- Price
- </td>
- </tr>
- <tr>
- <td style="padding:10px 15px;"></td>
- </tr>
- <tr>
- <td style="background:#ddd; height:1px; width:100%;"></td>
- </tr>
- </tbody>
- <tfoot style="background:#fff; text-align:center; color:#333;">
- <tr>
- <td style="color:#666;">
- <p>Copyright © 2015 Your plate All right reserved - site by Ypsilon It Solution</p>
- </td>
- <tr>
- </tfoot>
- </table>
- </body>
- </html>
- ';
- $headers = "Organization: OyaCharge\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
- $headers .= "X-Priority: 3\r\n";
- $headers .= "X-Mailer: PHP" . phpversion() . "\r\n";
- $header = "From:blm.ypsilon@gmail.com \r\n";
- $header .= "Cc:blm.ypsilon@gmail.com \r\n";
- $header .= "MIME-Version: 1.0\r\n";
- $header .= "Content-type: text/html\r\n";
- $this->sendElasticEmail($user_email, $subject, "OyaCharge", $mail_msg, "care@oyacharge.com", "OyaCharge");
- }
- //envia um email depois de cadastrar o usuario
- function emailBoasVindas(){
- $email = "webv3@hotmail.com";
- $subject = "Bem vindo ao Buscars";
- $headers = 'From: webmaster@example.com' . "\r\n" .
- 'Reply-To: webmaster@example.com' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- $txt='
- <html>
- <head>
- <title> Cadastro bem sucedido!</title>
- </head>
- <body style="" >
- <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc; border-top-left-radius: 18px; border-top-right-radius:18px; font-family:"Ubuntu",sans-serif !important; font-family:"Ubuntu",sans-serif!important;">
- <tr>
- <td style="color:#ff6600;font-size:30px;font-weight:600;padding:36px 0;text-align:center; background-image:url('.user_images.'bg.jpg); background-repeat:no-repeat; border-top-left-radius: 15px; border-top-right-radius:15px; overflow:hidden;">
- Cadastro bem sucedido
- </td>
- </tr>
- <tr>
- <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
- Bem vindo ao Buscars<br />
- O carro zero na palma da sua mão!
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- Qualquer dúvida entre em contato com nossa equipe no <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
- </td>
- </tr>
- <tr >
- <td style="text-align:center; padding:15px;">
- <img width="150" src="'.user_images.'logo1.png" />
- </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- mail($email, $subject, $txt, $headers);
- }
- //registra o usuario
- function registrarUsuario(){
- if(
- !empty($_REQUEST['user_name']) &&
- !empty($_REQUEST['user_email']) &&
- !empty($_REQUEST['user_phone']) &&
- !empty($_REQUEST['user_password']) &&
- !empty($_REQUEST['user_city']) &&
- !empty($_REQUEST['user_state'])
- ){
- $user_name = $_REQUEST['user_name'];
- $user_email = $_REQUEST['user_email'];
- $user_phone = $_REQUEST['user_phone'];
- $user_password = md5($_REQUEST['user_password']);
- $user_city = $_REQUEST['user_city'];
- $user_state = $_REQUEST['user_state'];
- $current_date = date("Y-m-d h:i:s");
- //$email_records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
- //verifica se ja existe um usuario com esse email registrado
- $sql = "SELECT * FROM tbl_user WHERE user_email= '".$user_email."'";
- $email_existente = $this->mysqli->query($sql);
- $email_existente = $email_existente->num_rows;
- //caso nao exista nenhum registro com esse email
- if( $email_existente == 0 ){
- $fields = "user_name, user_email, user_phone, user_state, user_city, user_password, user_login_type, user_created_date";
- $values = "'$user_name', '$user_email', '$user_phone', '$user_state', '$user_city', '$user_password', '1', '$current_date'";
- $query = "INSERT INTO tbl_user($fields) VALUES($values)";
- $query = $this->mysqli->query($query);
- if( $query ){
- $res = array(
- "status" => true,
- "message" => "Usuario registrado com sucesso!"
- );
- //envia email de boas findas
- //$this->emailBoasVindas($user_email);
- echo json_encode($res);
- exit;
- }
- }else{
- $res = array(
- "status" => false,
- "message" => "Este e-mail já está registado"
- );
- echo json_encode($res);
- exit;
- }
- }else{
- $res = array(
- 'status' => false,
- "message" => "Faltando parametro",
- 'user_name' => $_REQUEST['user_name'],
- 'user_email' => $_REQUEST['user_email'],
- 'user_phone' => $_REQUEST['user_phone'],
- 'user_password' => $_REQUEST['user_password'],
- 'user_city' => $_REQUEST['user_city'],
- 'user_state' => $_REQUEST['user_state']
- );
- echo json_encode($res);
- exit;
- }
- }
- function signup() {
- if(
- !empty($_REQUEST['user_name']) &&
- !empty($_REQUEST['user_email']) &&
- !empty($_REQUEST['user_mobile']) &&
- !empty($_REQUEST['user_pass']) &&
- !empty($_REQUEST['user_city']) &&
- !empty($_REQUEST['user_state']) &&
- !empty($_REQUEST['user_device_type'])&&
- // !empty($_REQUEST['user_device_token']) &&
- !empty($_REQUEST['user_device_id'])
- ){
- $user_name = $_REQUEST['user_name'];
- $user_email = $_REQUEST['user_email'];
- $user_mobile = $_REQUEST['user_mobile'];
- $password = md5($_REQUEST['user_pass']);
- $user_city = $_REQUEST['user_city'];
- $user_state = $_REQUEST['user_state'];
- $device_type = $_REQUEST['user_device_type'];
- // $device_token = $_REQUEST['user_device_token'];
- $device_id = $_REQUEST['user_device_id'];
- $user_type = $_REQUEST['user_type'];
- $current_date = date("Y-m-d h:i:s");
- $email_records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
- if (!empty($email_records)){
- $post = array(
- "status" => "false",
- "message" => "Este e-mail já está registado",
- "email" => $user_email
- );
- echo $this -> json($post);
- exit();
- } else {
- $user_image = '';
- if ($_FILES['user_img']['name']) {
- $user_image = $_FILES['user_img']['name'];
- }
- $attachment = $_FILES['user_img']['name'];
- if (!empty($attachment)) {
- $file_extension = explode(".", $_FILES["user_img"]["name"]);
- $new_extension = strtolower(end($file_extension));
- $today = time();
- $custom_name = "user_img" . $today;
- $file_name = $custom_name . "." . $new_extension;
- if (
- $new_extension == 'png' ||
- $new_extension == 'jpeg' ||
- $new_extension == 'jpg' ||
- $new_extension == 'bmp')
- {
- move_uploaded_file($_FILES['user_img']['tmp_name'], "../uploads/user/" . $file_name);
- }
- }
- if (!empty($file_name)) {
- $user_profile_pic = $file_name;
- } else{
- $user_profile_pic = '';
- }
- if($user_type==1){
- //print_r('here');
- $insert = $this -> conn -> insertnewrecords(
- 'tbl_user',
- 'user_name,
- user_email,
- user_phone,
- user_state,
- user_city,
- user_password,
- user_login_type,
- user_device_type,
- user_device_id,
- user_created_date,
- user_profile_pic,
- user_type',
- '"' . $user_name . '",
- "' . $user_email . '",
- "' . $user_mobile . '",
- "' . $user_state . '",
- "' . $user_city . '",
- "' . $password . '",
- "1",
- "' . $device_type . '",
- "' . $device_id . '",
- "' . $current_date . '",
- "' . $user_profile_pic . '",
- "' . $user_type . '"'
- // user_device_token,
- // "' . $device_token . '",
- );
- //print_r($insert); die();
- } else {
- $insert = $this -> conn -> insertnewrecords(
- 'tbl_user',
- 'user_name,
- user_email,
- user_phone,
- user_state,
- user_city,
- user_password,
- user_login_type,
- user_device_type,
- user_device_id,
- user_created_date,
- user_profile_pic,
- user_type,
- verified_status',
- '"' . $user_name . '",
- "' . $user_email . '",
- "' . $user_mobile . '",
- "' . $user_state . '",
- "' . $user_city . '",
- "' . $password . '",
- "1",
- "' . $device_type . '",
- "' . $device_id . '",
- "' . $current_date . '",
- "' . $user_profile_pic . '",
- "' . $user_type . '",
- "' . 2 . '"'
- // user_device_token,
- // "' . $device_token . '",
- );
- }
- //print_r($insert); die();
- if ($insert > 0) {
- $to = $user_email;
- $subject = "Bem vindo ao Buscars";
- $txt='
- <html>
- <head>
- <title> Cadastro bem sucedido!</title>
- </head>
- <body style="" >
- <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc; border-top-left-radius: 18px; border-top-right-radius:18px; font-family:"Ubuntu",sans-serif !important; font-family:"Ubuntu",sans-serif!important;">
- <tr>
- <td style="color:#ff6600;font-size:30px;font-weight:600;padding:36px 0;text-align:center; background-image:url('.user_images.'bg.jpg); background-repeat:no-repeat; border-top-left-radius: 15px; border-top-right-radius:15px; overflow:hidden;">
- Cadastro bem sucedido
- </td>
- </tr>
- <tr>
- <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
- Bem vindo ao Buscars<br />
- O carro zero na palma da sua mão!
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- Qualquer dúvida entre em contato com nossa equipe no <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
- </td>
- </tr>
- <tr >
- <td style="text-align:center; padding:15px;">
- <img width="150" src="'.user_images.'logo1.png" />
- </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- // $headers = "MIME-Version: 1.0" . "\r\n";
- // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
- // // More headers
- // $headers .= 'From: "Buscar" <app@buscarsbr.com.brzz>' . "\r\n";
- // $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
- $this->smtp_mail($to, $subject,"Buscar", $txt, " emerson@dopcomunicacao.com.br", "BusCar assinatura");
- // mail($to,$subject,$txt,$headers);
- $post = array(
- "status" => "true",
- "message" => Signup_successfully,
- 'user_id' => $insert,
- 'user_name' => $user_name,
- 'user_email' => $user_email,
- 'user_city' => $user_city,
- 'user_pic'=> user_images.$file_name,
- 'user_type'=> $user_type,
- 'verified_status'=>'2'
- );
- echo $this -> json($post);
- }
- }
- } else {
- $error = array(
- 'status' => "Failed",
- "message" => Missing_Parameter,
- 'user_name' => $_REQUEST['user_name'],
- 'user_email' => $_REQUEST['user_email'],
- 'user_mobile' => $_REQUEST['user_mobile'],
- 'user_pass' => $_REQUEST['user_pass'],
- 'user_city' => $_REQUEST['user_city'],
- 'user_state' => $_REQUEST['user_state'],
- 'user_device_type' => $_REQUEST['user_device_type'],
- // 'user_device_token' => $_REQUEST['user_device_token'],
- 'user_device_id' => $_REQUEST['user_device_id']
- );
- }
- echo $this -> json($error);
- }
- //Metodo que faz UPDATE dos dados do usuario
- //e faz upload de imagem de perfil
- function update() {
- if(empty($_REQUEST['user_id'])){
- $post = array(
- 'status' => "Failed",
- "message" => "Parametro user_id nao encontrado",
- 'user_id' => $_POST['user_id']
- );
- // $this->response($this->json($error), 400);
- echo json_encode($post);
- exit;
- }
- $user_id = $_REQUEST['user_id'];
- $user_name = $_REQUEST['user_name'];
- $user_email = $_REQUEST['user_email'];
- $user_mobile = $_REQUEST['user_phone'];
- $user_city = $_REQUEST['user_city'];
- $user_state = $_REQUEST['user_state'];
- $storage_image = $_REQUEST['storage_image'];
- $user_password = md5($_REQUEST['user_password']);
- $data_response = json_encode($_REQUEST);
- $sql="select * from tbl_user where user_id='".$user_id."'";
- //se encontrar algum registro com o id de usuario passado por parametro
- $usuario_encontrado = 0;
- //resultado do select de usuario com id passado
- $queryResult = false;
- if ($this->mysqli->connect_errno) {
- $err = array(
- "status" => "false",
- "message" => "Erro conexão $this->mysqli->connect_error"
- );
- echo $this->json($err);
- exit;
- }else{
- $queryResult = $this->mysqli->query($sql);
- if ( $queryResult ) {
- $usuario_encontrado = $result->num_rows;
- }else{
- printf("Connect failed: %s\n", $this->mysqli->connect_error);
- exit;
- }
- }
- if( $usuario_encontrado ){
- $result=mysql_fetch_array($queryResult);
- //valida se email existe ja em outro usuario
- $query="select * from tbl_user where user_email='".$user_email."' and user_id !='".$user_id."'";
- $record=$this->conn->getData($query);
- if(!empty($record)){
- $post= array(
- "status" => "false",
- "message" => "Este e-mail já está registado",
- 'email' => $user_email
- );
- echo $this->json($post);
- exit();
- }
- }
- //upload da imagem
- $attachment = $_FILES['user_img']['name'];
- if (!empty($attachment)) {
- $file_extension = explode(".", $_FILES["user_img"]["name"]);
- $file_extension = strtolower(end($file_extension));
- $today = time();
- $custom_name = "user_img" . $today;
- $file_name = $custom_name . "." . $file_extension;
- if (
- strtolower($file_extension) == 'png' ||
- strtolower($file_extension) == 'jpeg' ||
- strtolower($file_extension) == 'jpg' ||
- strtolower($file_extension) == 'bmp'
- ) {
- $uploaded = move_uploaded_file($_FILES['user_img']['tmp_name'], "./upload_images/".$file_name);
- $user_profile_pic = $file_name;
- }else{
- $post= array(
- "status" => "false",
- "message" => "Formato de imagem nao suportado"
- );
- echo $this->json($post);
- exit;
- }
- } else{
- $user_profile_pic = $storage_image;
- }
- //faz o update com os novos dados
- $updateSql="
- update tbl_user set user_name='".$user_name."',
- user_profile_pic='".$user_profile_pic."',
- user_email='".$user_email."',
- user_phone='".$user_mobile."',
- user_city='".$user_city."',
- user_state='".$user_state."',
- user_password='".$user_password."'
- where user_id='".$user_id."'
- ";
- $updateResult = $this->mysqli->query($updateSql);
- if ( $updateResult ) {
- $post= array(
- "status" => "true",
- "message" => "Dados atualizados!",
- "user_profile_pic" => $user_profile_pic
- );
- echo $this->json($post);
- exit;
- }else{
- printf("Erro ao fazer UPDATE no banco: %s\n", $this->mysqli->connect_error);
- exit;
- }
- }
- function social_login() {
- $user_email = $_REQUEST['user_email'];
- $user_firstname = $_REQUEST['user_firstname'];
- $user_lastname = $_REQUEST['user_lastname'];
- $user_name = $user_firstname." ".$user_lastname;
- $user_social_id = $_REQUEST['user_social_id'];
- //Social ID
- $login_type = 2;
- // 1-Facebook,2-Google+
- // if($login_type=='2'){
- // $log_type = 'Facebook'; }else if($login_type=='3') {
- // $log_type = 'Google+'; }
- $current_date = date("Y-m-d h:i:sa");
- $user_device_type = $_REQUEST['user_device_type'];
- $user_device_token = $_REQUEST['user_device_token'];
- $user_device_id = $_REQUEST['user_device_id'];
- $profile_pic = $_REQUEST['user_img'];
- if (!empty($user_email) && !empty($user_social_id)) {
- $records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
- $user_id = $records[0]['user_id'];
- $user_email = $records[0]['user_email'];
- $user_contact_no = $records[0]['user_phone'];
- $user_login_type = $records[0]['user_login_type'];
- $user_city = $records[0]['user_city'];
- $user_state = $records[0]['user_state'];
- if (!empty($user_id)) {
- $status = $records[0]['user_status'];
- if ($status == '1') {
- $data['user_name'] = $user_name;
- $data['user_email'] = $user_email;
- $data['user_social_id'] = $user_social_id;
- $data['user_login_type'] = 2;
- $data['user_created_date'] = $current_date;
- $data['user_device_type'] = $user_device_type;
- $data['user_device_token'] = $user_device_token;
- $data['user_device_id'] = $user_device_id;
- $data['user_profile_pic'] = $profile_pic;
- $data['user_ip_address'] = $_SERVER['REMOTE_ADDR'];
- if(!empty($user_state) && !empty($user_city)) {
- $sql111="
- SELECT * FROM tbl_user
- LEFT join tbl_state on tbl_state.state_id=tbl_user.user_state
- LEFT join tbl_city on tbl_city.city_id =tbl_user.user_city
- where user_email='".$user_email."'
- ";
- $record=$this->conn->getData($sql111);
- $user_state=$record[0]['user_state'];
- $user_city=$record[0]['user_city'];
- $city_name=html_entity_decode($record[0]['city_name']);
- $state_name=html_entity_decode($record[0]['state_name']);
- } else {
- $user_state="";
- $user_city="";
- $city_name="";
- $state_name="";
- }
- $update_toekn = $this -> conn -> updatetablebyid('tbl_user', 'user_id', $user_id, $data);
- $sql111="
- SELECT * FROM tbl_user
- LEFT join tbl_state on tbl_state.state_id=tbl_user.user_state
- LEFT join tbl_city on tbl_city.city_id =tbl_user.user_city
- where user_id='".$user_id."'
- ";
- $record=$this->conn->getData($sql111);
- //$post=array('status'=>'true','message'=>Login_successfully,'user_id'=>$user_id,'user_name'=>$record[0]['user_name'],'user_profile_pic'=>$img,'user_phone'=>$record[0]['user_phone'],'city_id'=>$record[0]['city_id'],'city_name'=>$record[0]['city_name'],'state_id'=>$record[0]['user_state'],'state_name'=>$record[0]['state_name'],'user_email'=>$record[0]['user_email'],'verified_status'=>$record[0]['verified_status'],'user_type'=>$record[0]['user_type'],'user_password'=>$record[0]['user_password'],'user_login_type'=>$record[0]['user_login_type']);
- $post = array(
- "ResponseCode"=>"200",
- "status" => "true",
- "message" => Login_successfully,
- 'user_id' => $user_id,
- 'login_type' => $login_type,
- 'user_name' => $user_name,
- 'profile_pic' => $profile_pic,
- 'user_email' => $user_email,
- 'user_phone' =>$user_contact_no,
- 'user_login_type'=>$user_login_type,
- 'city_id'=>$user_city,
- 'city_name'=>$city_name,
- 'state_id'=>$user_state,
- 'state_name'=>$state_name
- );
- } else {
- $post = array(
- "ResponseCode"=>"500",
- "status" => "inactive",
- "message" => Inactive_account
- );
- }
- } else {
- //$reffer_code = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 6);
- $user_email = $_POST['user_email'];
- $user_phone = $_POST['user_phone'];
- $user_login_type = 2;
- $insert = $this -> conn -> insertnewrecords(
- 'tbl_user',
- 'user_state,
- user_city,
- user_name,
- user_email,
- user_social_id,
- user_login_type,
- user_created_date,
- user_profile_pic,
- user_device_type,
- user_device_token,
- user_device_id,
- user_phone',
- '26,5341,"'
- . $user_name . '","'
- . $user_email . '","'
- . $user_social_id . '","'
- . $user_login_type . '","'
- . $current_date . '","'
- . $profile_pic . '","'
- . $user_device_type . '","'
- . $user_device_token . '","'
- . $user_device_id . '","'
- . $user_phone . '"'
- );
- if ($insert) {
- $wallet_amount = 0;
- $sql111="select * from tbl_user where user_email='".$user_email."'";
- $record=$this->conn->getData($sql111);
- $user_state=$record[0]['user_state'];
- $user_city=$record[0]['user_state'];
- if(!empty($user_state) && !empty($user_city)) {
- $sql111="
- SELECT * FROM tbl_user
- LEFT join tbl_state on tbl_state.state_id=tbl_user.user_state
- LEFT join tbl_city on tbl_city.city_id =tbl_user.user_city
- where user_email='".$user_email."'
- ";
- $record=$this->conn->getData($sql111);
- $user_state=$record[0]['user_state'];
- $user_city=$record[0]['user_city'];
- $city_name=$record[0]['city_name'];
- $state_name=$record[0]['state_name'];
- } else {
- $user_state="";
- $user_city="";
- $city_name="";
- $state_name="";
- }
- $post=array(
- 'ResponseCode'=>'200',
- 'status'=>'true',
- 'message'=>Login_successfully,
- 'user_id'=>$record[0]['user_id'],
- 'user_name'=>$record[0]['user_name'],
- 'profile_pic'=>$img,
- 'user_phone'=>$record[0]['user_phone'],
- 'city_id'=>$user_city,
- 'city_name'=>$city_name,
- 'state_id'=>$user_state,
- 'state_name'=>$state_name,
- 'user_email'=>$record[0]['user_email'],
- 'verified_status'=>$record[0]['verified_status'],
- 'user_type'=>$record[0]['user_type'],
- 'user_password'=>$record[0]['user_password'],
- 'user_login_type'=>$record[0]['user_login_type']
- );
- // $post = array("status" => "true", "message" => Login_successfully, 'user_id' => $user_id, 'login_type' => $login_type, 'user_name' => $user_name, 'profile_pic' => $profile_pic, 'user_email' => $user_email, 'user_phone' =>$user_contact_no,'user_login_type'=>$user_login_type,'city_id'=>$record[0]['city_id'],'city_name'=>$record[0]['city_name'],'state_id'=>$record[0]['user_state'],'state_name'=>$record[0]['state_name']);
- }
- }
- } else {
- $post = array(
- 'ResponseCode'=>'500',
- 'status' => "Failed",
- "message" => Missing_Parameter,
- 'user_email' => $user_email,
- 'user_social_id' => $user_social_id
- );
- }
- echo $this -> json($post);
- }
- function forgot_passowrd() {
- $email = $_REQUEST['email'];
- if (!empty($email)) {
- $records_user = $records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $email);
- if (!empty($records_user)) {
- $user_id = $records_user[0]['user_id'];
- $password = rand(111111111,999999999);
- $new_password = md5($password);
- $data['user_password'] = $new_password;
- $update_password = $this -> conn -> updatetablebyid('tbl_user','user_id', $user_id, $data);
- $subject = 'Aviso de alteração de senha';
- $message .= '
- <html>
- <head>
- <title> Aviso de alteração de senha</title>
- </head>
- <body style="" >
- <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc;border-top-left-radius: 18px;border-top-right-radius:18px;font-family:"Ubuntu",sans-serif!important; font-family: "Ubuntu",sans-serif!important;">
- <tr>
- <td style="color:#ff6600;font-size:30px;font-weight:600;padding:36px 0;text-align:center; background-image:url('.user_images.'bg.jpg); background-repeat:no-repeat; border-top-left-radius: 15px; border-top-right-radius:15px;overflow:hidden;">
- Aviso de alteração de senha
- </td>
- </tr>
- <tr>
- <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
- Este aviso confirma que a sua senha foi alterada em Buscars.
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-weight:600; font-size:18px">
- <span style="margin-right:15px"> E-mail :</span>
- <span> ' .$email.' </span>
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-weight:600; font-size:18px">
- <span style="margin-right:15px"> Senha :</span>
- <span>'.$password.' </span>
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- Caso você não tenha alterado sua senha, contate a equipe de suporte em <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
- </td>
- </tr>
- <tr >
- <td style="text-align:center; padding:15px;"> <img width="150" src="'.user_images.'logo1.png" /> </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- $this->smtp_mail($email, $subject,"Buscar", $message, " app@buscarsbr.com.br", "BusCar");
- $post = array('status' => "true", "message" =>'Nova senha envia para o seu e-mail registrado');
- } else {
- $post = array('status' => "false", "message" => "Email inválido ou celular não");
- }
- echo $this -> json($post);
- } else {
- $post = array('status' => "false", "message" => "invalid parameter");
- echo $this -> json($post);
- }
- }
- function user_profile() {
- header("Content-Type: text/html;charset=utf-8");
- $user_id = $_REQUEST['user_id'];
- if (!empty($user_id)) {
- $records = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
- if (!empty($records)) {
- $user_id = $records['0']['user_id'];
- $user_name = $records['0']['user_name'];
- $user_email = $records['0']['user_email'];
- $user_contact_no = $records['0']['user_contact_no'];
- $login_type = $records['0']['user_login_type'];
- $profile_pic = $records['0']['user_profile_pic'];
- $self_reffer_code = $records['0']['user_refferal_code'];
- $wallet_amount = $records[0]['wallet_amount'];
- $pin_status = $records[0]['user_pin_status'];
- $get_sms = $records['0']['get_sms'];
- $total_sms = $records[0]['total_sms'];
- if (!empty($profile_pic)) {
- if (filter_var($profile_pic, FILTER_VALIDATE_URL)) {
- $img = $profile_pic;
- } else {
- $img = self_img_url . $profile_pic;
- }
- } else {
- $img = '';
- }
- $user_refferal_codel = $records['0']['user_refferal_code'];
- $post = array(
- "status" => "true",
- "user_id" => $user_id,
- 'user_name' => $user_name,
- 'user_email' => $user_email,
- "user_contact_no" => $user_contact_no,
- 'user_login_type' => $login_type,
- 'wallet_amount' => $wallet_amount,
- 'profile_pic' => $img,
- 'total_sms' => $get_sms,
- 'remaining_sms' => $total_sms,
- 'user_pin_status' => $pin_status,
- 'reffer_code' => $self_reffer_code
- );
- } else {
- $post = array('status' => "false", "message" => "Nenhum usuário existe", 'user_id' => $user_id);
- }
- } else {
- $post = array('status' => "false", "message" => Missing_Parameter, 'user_id' => $user_id);
- }
- echo $this -> json($post);
- }
- function change_password() {
- $user_id = $_POST['user_id'];
- $old_password = $_POST['old_password'];
- $new_password = $_POST['new_password'];
- if (!empty($user_id)) {
- $records = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
- $old_user_password = $records['0']['user_password'];
- $old_password = md5($old_password);
- if ($old_password == $old_user_password){
- $data['user_password'] = md5($new_password);
- $update_toekn = $this -> conn -> updatetablebyid('user', 'user_id', $user_id, $data);
- $post = array('status' => "true", "message" => "Senha alterada com sucesso", 'user_id' => $user_id);
- } else {
- $post = array('status' => "false", "message" => "Senha antiga inválida", 'user_id' => $user_id);
- echo $this -> json($post);
- exit();
- }
- } else {
- $post = array('status' => "false", "message" => Missing_Parameter, 'user_id' => $user_id);
- }
- echo $this -> json($post);
- }
- function edit_profile() {
- $user_id = $_POST['user_id'];
- if (!empty($user_id)){
- $user_name = $_POST['user_name'];
- if (!empty($user_name)) {
- $data['user_name'] = $user_name;
- }
- $user_email = $_REQUEST['user_email'];
- if (!empty($user_email)) {
- $records_user = $this -> conn -> get_table_field_doubles_not('user', 'user_email', $user_email,'user_id',$user_id);
- if(empty($records_user)){
- $data['user_email'] = $user_email;
- }else{
- $post = array('status' => "false", "message" => "Este e-mail já está registado", 'user_email' => $user_email);
- echo $this -> json($post);
- exit();
- }
- }
- $new_password = $_POST['new_password'];
- $old_password = $_POST['old_password'];
- if (!empty($new_password) && !empty($old_password)) {
- $records = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
- $old_user_password = $records['0']['user_password'];
- $old_password = md5($old_password);
- if ($old_password == $old_user_password) {
- $data['user_password'] = md5($new_password);
- } else {
- $post = array('status' => "false", "message" => "Senha antiga inválida", 'user_id' => $user_id);
- echo $this -> json($post);
- exit();
- }
- }
- $user_image = '';
- if ($_FILES['self_img']['name']) {
- $user_image = $_FILES['self_img']['name'];
- }
- $attachment = $_FILES['self_img']['name'];
- if (!empty($attachment)) {
- $file_extension = explode(".", $_FILES["self_img"]["name"]);
- $new_extension = strtolower(end($file_extension));
- $today = time();
- $custom_name = "self_img" . $today;
- $file_name = $custom_name . "." . $new_extension;
- if ($new_extension == 'png' || $new_extension == 'jpeg' || $new_extension == 'jpg' || $new_extension == 'bmp') {
- move_uploaded_file($_FILES['self_img']['tmp_name'], "../uploads/self_img/" . $file_name);
- }
- }
- if (!empty($file_name)) {
- $data['user_profile_pic'] = $file_name;
- }
- $update_toekn = $this -> conn -> updatetablebyid('user', 'user_id', $user_id, $data);
- $records_user = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
- $name = $records_user['0']['user_name'];
- $email = $records_user['0']['user_email'];
- $user_login_type = $records_user['0']['user_login_type'];
- $profile_pic = $records_user['0']['user_profile_pic'];
- if($user_login_type=='1'){
- $image = self_img_url . $profile_pic;
- } else if($user_login_type!='1'){
- $image=$profile_pic;
- } else{
- $image = '';
- }
- $post = array(
- 'status' => "true",
- "message" => "Atualização de perfil com sucesso",
- 'user_id' => $user_id,
- 'user_name' => $name,
- 'user_email' => $email,
- 'user_id' => $user_id,
- 'user_profile_pic' => $image
- );
- } else{
- $post = array('status' => "false", "message" => Missing_Parameter, 'user_id' => $user_id);
- }
- echo $this -> json($post);
- }
- function get_car_by_distance(){
- header("Content-Type: text/html; charset=UTF-8",true);
- header('Content-Type: application/json; charset=UTF-8',true);
- $user_i = '23';
- $mil = '205';
- $lat = '-23.5506103';
- $long = '-46.6472723';
- $cidad = '5341';
- if(!empty($user_i)){
- $user_id = $user_i;
- // if(!empty($_REQUEST['user_id'])){
- // $user_id = $_REQUEST['user_id'];
- if ($mil==0){
- $mil=1;
- }
- // if ($_REQUEST['miles']==0){
- // $_REQUEST['miles']=1;
- // }
- if((!empty($lat) || !empty($long) || !empty($mil)) || (!empty($cidad))){
- if(!empty($lat) && !empty($long)){
- $latitude = $lat;
- $longitude = $long;
- $miles = $mil;
- }
- // if((!empty($_REQUEST['latitude']) || !empty($_REQUEST['longitude']) || !empty($_REQUEST['miles'])) || (!empty($_REQUEST['city']))){
- // if(!empty($_REQUEST['latitude']) && !empty($_REQUEST['longitude'])){
- // $latitude = $_REQUEST['latitude'];
- // $longitude = $_REQUEST['longitude'];
- // $miles = $_REQUEST['miles'];
- // }
- else {
- $city = $cidad;
- // $city = $_REQUEST['city'];
- $miles=200;
- $query="select * from tbl_city where city_id='".$city."'";
- $record = $this->mysqli->query($query) or die($this->mysqli->error.__LINE__);
- // $record=$this->conn->getData($query);
- // print_r($record); die();
- if(empty($record)){
- $post=array('status'=>'false','message'=>'Nenhum fornecedor de serviços encontrado');
- echo $this -> json($post);
- exit();
- }
- $latitude = $record[0]['city_lat'];
- $longitude = $record[0]['city_long'];
- $city_name=html_entity_decode($record[0]['city_name']);
- if(!empty($latitude) && !empty($longitude)){
- $latitude = $record[0]['city_lat'];
- $longitude = $record[0]['city_long'];
- } else{
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => "https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyCcsjliFLtVzAeYAn0vdRrx3D8jV1FYpLo&address=".urlencode($city_name).",Brazil",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => array(
- "cache-control: no-cache",
- "postman-token: 6d979a5a-5977-52a4-02b0-2d1e2fcf869a"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- "cURL Error #:" . $err;
- } else {
- $response;
- }
- $result = json_decode($response, TRUE);
- $latitude = $result['results'][0]['geometry']['location']['lat'];
- $longitude = $result['results'][0]['geometry']['location']['lng'];
- $insert = $this->conn->insertnewrecords('tbl_city', 'city_lat, city_long', '"' . $user_id . '","' . $service_provider_userid . '"');
- $update="update tbl_city set city_lat='".$latitude."', city_long='".$longitude."' where city_id='".$city."'";
- $result=mysql_query($update);
- }
- }
- $sql = "
- SELECT *,
- (3959
- * acos (cos (radians('$latitude') )
- * cos( radians( car_latitude ) )
- * cos( radians( car_longitude ) - radians('$longitude') )
- + sin ( radians('$latitude') )
- * sin( radians( car_latitude ) )
- )
- ) AS distance
- FROM tbl_cars
- LEFT JOIN tbl_carYear
- on tbl_carYear.carYear_id = tbl_cars.car_Year
- LEFT JOIN tbl_carFuel
- on tbl_carFuel.carFuel_id = tbl_cars.car_Fuel
- LEFT JOIN tbl_carGear
- on tbl_carGear.carGear_id = tbl_cars.car_Gear
- LEFT JOIN tbl_brand
- on tbl_brand.brand_id = tbl_cars.car_Brand
- LEFT JOIN tbl_carVersion
- on tbl_carVersion.carVersion_id = tbl_cars.car_Version
- LEFT JOIN tbl_blindagem
- on tbl_blindagem.blindagem_id = tbl_cars.car_blindagem
- LEFT JOIN tbl_carModel
- on tbl_carModel.carModel_id = tbl_cars.car_model
- WHERE car_user_id!=$user_id
- AND tbl_cars.car_status = 1
- AND tbl_carYear.carYear_status = 1
- AND tbl_carFuel.carFuel_status = 1
- AND tbl_carGear.carGear_status = 1
- AND tbl_brand.brand_status = 1
- AND tbl_carVersion.carVersion_status = 1
- AND tbl_blindagem.blindagem_status = 1
- AND tbl_carModel.car_Model_status = 1
- HAVING distance < '$miles'
- ORDER BY distance
- ";
- // $record=$this->conn->getData($sql);
- $record_sql=$this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
- while ($dados = $record_sql->fetch_assoc()) {
- $dados[] = utf8_decode($dados);
- $record[] = $dados;
- }
- // print_r($record); die();
- foreach ($record as $key=>$value) {
- if($value['car_featured']==1){
- $car_user_id = $value['car_user_id'];
- // print_r($car_user_id); die();
- $query_subcription=" select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
- $record_query=$this->mysqli->query($query_subcription) or die($this->mysqli->error.__LINE__);
- while ($dados1 = $record_query->fetch_assoc()) {
- $dados1[] = utf8_decode($dados1);
- $record_subcription[] = $dados1;
- if(!empty($record_subcription)){
- $end_date=$record_subcription['end_date'];
- $date=date("Y-m-d h:i:s a");
- if(!($date<=$end_date)) {
- $value['car_featured']='2';
- } else {
- $value['car_featured']='1';
- }
- // print_r($value['car_featured']); echo '<pre>'; print_r($record_subcription);
- } else {
- $value['car_featured']='2';
- }
- }
- }
- $car_id = $value['car_id'];
- $car_name = utf8_encode($value['car_name']);
- $car_fullname = utf8_encode($value['car_fullname']);
- $car_price = $value['car_price'];
- $car_model = $value['carYear_name'];
- $carFuel_type = utf8_encode($value['carFuel_type']);
- $carGear_type = $value['carGear_type'];
- $car_featured = $value['car_featured'];
- // $carVersion_name = html_entity_decode($value['carVersion_name']);
- $carVersion_name = utf8_encode($value['carVersion_name']);
- $car_images = explode(",",$value['car_images']);
- $brand_images = brand_images.$value['brand_image'];
- $Resellerprice = $value['car_Reseller_price'];
- $favourite_status = $value['favourite_status'];
- // $carFuel_type = html_entity_decode($carFuel_type);
- // $car_name = $value['car_name'];
- // $car_fullname = $value['car_fullname'];
- // $car_price = $this->moneyFormatIndia($value['car_price']);
- // $Resellerprice = $this->moneyFormatIndia($value['car_Reseller_price']);
- $response = array();
- $response = [
- 'car_id' => $car_id,
- 'car_name' => $car_name,
- 'car_fullname'=>$car_fullname,
- 'car_price'=>$car_price,
- 'car_model'=>$car_model,
- 'car_images'=>car_images.$car_images[0],
- 'car_featured'=>$car_featured,
- 'fuel_type'=>$carFuel_type,
- 'gear_type'=>$carGear_type,
- 'reseller_price'=>$Resellerprice,
- 'favourite_status'=>$favourite_status,
- 'brand_images'=>$brand_images,
- 'carVersion_name'=>$carVersion_name
- ];
- // print_r($response);
- $responseData= json_encode($response);
- $postJson[]= json_decode($responseData);
- }
- if (!empty($postJson)) {
- $post = array("status" => "true", "message" => count($postJson)." ".Car_found,'cars'=>$postJson);
- } else {
- $post = array('status' => "false", "message" => No_Record_Found);
- }
- } else {
- $post=array('status'=>'false','message'=>Missing_Parameter);
- }
- } else {
- $post=array('status'=>'false','message'=>Missing_Parameter);
- }
- // echo $this -> json($post);
- echo $this->json($post);
- }
- function state_list() {
- $state = $this -> conn -> get_table_row_byidvalue('tbl_state', 'state_status', 1);
- foreach ($state as $key => $value) {
- $state_id = $value['state_id'];
- $state_name = html_entity_decode($value['state_name']);
- $country_id = $value['country_ids'];
- $response[] = array(
- 'state_id' => $state_id,
- 'state_name' => $state_name,
- 'country_id'=>$country_id
- );
- }
- if (!empty($response)) {
- $post = array(
- "status" => "true",
- "message" => 'Lista de estados encontrada',
- 'states'=>$response
- );
- } else {
- $post = array(
- 'status' => "false",
- "message" => No_Record_Found
- );
- }
- echo $this -> json($post);
- }
- function city_list() {
- header("Content-Type: text/html; charset=UTF-8",true);
- header('Content-Type: application/json; charset=UTF-8',true);
- $state_id = $_REQUEST['state_id'];
- // $state_id = '26';
- if (!empty($state_id)) {
- $city = $this -> conn -> get_table_field_doubles('tbl_city', 'city_status', 1, 'state_ids', $state_id);
- foreach ($city as $key => $value) {
- $city_id =$value['city_id'];
- $city_name = html_entity_decode($value['city_name']);
- $response[] = array(
- 'city_id' => $city_id,
- 'city_name' => $city_name,
- 'state_id' => $state_id
- );
- }
- if (!empty($response)) {
- $post = array(
- "status" => "true",
- 'state_id' => $state_id,
- "message" => 'Lista de cidades encontrada',
- 'city'=>$response
- );
- } else {
- $post = array(
- 'status' => "false",
- "message" => No_Record_Found
- );
- }
- } else {
- $post = array(
- 'status' => "false",
- "message" => Missing_Parameter,
- 'state_id' => $state_id
- );
- }
- echo $this -> json($post);
- }
- function car_list(){
- header("Content-Type: text/html;charset=utf-8");
- header('Content-Type: application/json;charset=utf-8');
- $user_id= '23';
- $state_id= '26';
- $city_id= '5341';
- // $user_id=$_REQUEST['user_id'];
- // $state_id=$_REQUEST['state_id'];
- // $city_id=$_REQUEST['city_id'];
- if(!empty($state_id) && !empty($city_id)){
- $sql="where car_state_id='".$state_id."' and car_city_id='".$city_id."' AND";
- } elseif (!empty($state_id)){
- $sql="where car_state_id='".$state_id."' AND ";
- } else {
- $sql='where';
- }
- $sql="
- SELECT * FROM tbl_cars
- JOIN tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
- JOIN tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
- JOIN tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
- JOIN tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
- JOIN tbl_carVersion on tbl_carVersion.carVersion_id=tbl_cars.car_Version
- JOIN tbl_blindagem on tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
- JOIN tbl_carModel on tbl_carModel.carModel_id=tbl_cars.car_model
- ".$sql." tbl_cars.car_status=1
- AND tbl_carYear.carYear_status=1
- AND tbl_carFuel.carFuel_status=1
- AND tbl_carGear.carGear_status=1
- AND tbl_brand.brand_status=1
- AND tbl_carVersion.carVersion_status=1
- AND tbl_blindagem.blindagem_status=1
- AND tbl_carModel.car_Model_status=1
- ORDER BY RAND()
- ";
- $record=$this->conn->getData($sql);
- foreach ($record as $key => $value) {
- $car_id = $value['car_id'];
- $sql1 = "select * from tbl_favourite where favourite_car_ID='".$car_id."' and favourite_user_ID='".$user_id."'";
- $record1 = $this->conn->getData($sql1);
- if (!empty($record1)){
- $favourite_status=$record1[0]['favourite_status'];
- if ($favourite_status='1'){
- $favourite_status='1';
- } else {
- $favourite_status='2';
- }
- } else {
- $favourite_status='2';
- }
- $car_user_id = $value['car_user_id'];
- $query_subcription = "select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
- $record_subcription = $this->conn->getData($query_subcription);
- if (!empty($record_subcription)){
- $end_date=$record_subcription[0]['end_date'];
- $date=date("Y-m-d h:i:s a");
- if (!($date<=$end_date)){
- $value['car_featured']='2';
- }
- } else {
- $value['car_featured']='2';
- }
- $car_name = $value['car_name'];
- $car_name = html_entity_decode($car_name);
- $car_fullname = $value['car_fullname'];
- $car_fullname = html_entity_decode($car_fullname);
- $car_price = $value['car_price'];
- $car_model = $value['carYear_name'];
- $car_featured = $value['car_featured'];
- $carFuel_type = $value['carFuel_type'];
- $carFuel_type = html_entity_decode($carFuel_type);
- $carVersion_name = $value['carVersion_name'];
- $carGear_type = $value['carGear_type'];
- $car_featured = $value['car_featured'];
- $brand_images = brand_images.$value['brand_image'];
- $car_images = $value['car_profile_pick'];
- $Resellerprice = $value['car_Reseller_price'];
- // $car_price = $this->moneyFormatIndia($value['car_price']);
- // $carVersion_name = html_entity_decode($carVersion_name );
- // $car_images = explode(",",$value['car_images']);
- //$Resellerprice = $this->moneyFormatIndia($value['car_Reseller_price']);
- $response[] = array(
- 'car_id' => $car_id,
- 'car_name' => $car_name,
- 'car_fullname'=>$car_fullname,
- 'car_price'=>$car_price,
- 'car_model'=>$car_model,
- 'car_images'=>car_images.$car_images,
- 'car_featured'=>$car_featured,
- 'fuel_type'=>$carFuel_type,
- 'gear_type'=>$carGear_type,
- 'reseller_price'=>$Resellerprice,
- 'carVersion_name'=>$carVersion_name,
- 'favourite_status'=>$favourite_status,
- 'brand_images'=>$brand_images
- );
- }
- if (!empty($response)) {
- $post = array("status" => "true", "message" => count($response)." ".Car_found,'cars'=>$response);
- } else {
- $post = array('status' => "false", "message" => No_Record_Found);
- }
- echo $this -> json($post);
- }
- function get_carDetails(){
- header("Content-Type: text/html;charset=utf-8");
- header('Content-Type: application/json;charset=utf-8');
- if(!empty($_REQUEST['car_id'])){
- $car_id=$_REQUEST['car_id'];
- $user_id=$_REQUEST['user_id'];
- // $carIdTeste = 3;
- // $userIdTeste = 151;
- // if(!empty($carIdTeste)){
- // $car_id=$carIdTeste;
- // $user_id=$userIdTeste;
- // $car_city_id=$_REQUEST['car_city_id'];
- // $car_state_id=$_REQUEST['car_state_id'];
- $sql="
- SELECT * FROM tbl_cars
- JOIN tbl_user ON tbl_user.user_id=tbl_cars.car_user_id
- JOIN tbl_state ON tbl_state.state_id=tbl_cars.car_state_id
- JOIN tbl_city ON tbl_city.city_id=tbl_cars.car_city_id
- JOIN tbl_brand ON tbl_brand.brand_id=tbl_cars.car_Brand
- JOIN tbl_carFuel ON tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
- JOIN tbl_carGear ON tbl_carGear.carGear_id=tbl_cars.car_Gear
- JOIN tbl_carVersion ON tbl_carVersion.carVersion_id=tbl_cars.car_Version
- JOIN tbl_carModel ON tbl_carModel.carModel_id=tbl_cars.car_model
- JOIN tbl_carYear ON tbl_carYear.carYear_id=tbl_cars.car_Year
- JOIN tbl_CarType on tbl_CarType.carType_id=tbl_cars.car_category_id
- WHERE tbl_cars.car_id='".$car_id."'"
- ;
- // $record=$this->conn->getData($sql);
- $record_sql=$this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
- while ($dados = $record_sql->fetch_assoc()) {
- $record[] = $dados;
- }
- // print_r($record); die();
- if(!empty($record)){
- $sql1="select * from tbl_interest where interest_car_ID='".$car_id."' and interest_user_ID='".$user_id."'";
- // $record1=$this->conn->getData($sql1);
- $record_sql1=$this->mysqli->query($sql1) or die($this->mysqli->error.__LINE__);
- while ($dados1 = $record_sql1->fetch_assoc()) {
- $record1[] = $dados1;
- }
- if(!empty($record1)){
- $car_interest='1';
- }
- else{
- $car_interest='2';
- }
- $sql1="select * from tbl_favourite where favourite_car_ID='".$car_id."' and favourite_user_ID='".$user_id."'";
- // $record1=$this->conn->getData($sql1);
- $record_sql1=$this->mysqli->query($sql1) or die($this->mysqli->error.__LINE__);
- while ($dados1 = $record_sql1->fetch_assoc()) {
- $record1[] = $dados1;
- }
- $favourite_status=$record1[0]['favourite_status'];
- if($favourite_status==1){
- $favourite_status='1';
- }
- else{
- $favourite_status='2';
- }
- $favourite_status;
- $sql_version="select * from tbl_carVersion where car_Model_id='".$record[0]['car_Version']."' and carVersion_status=1";
- // $version=$this->conn->getData($sql_version);
- $record_sql_version=$this->mysqli->query($sql_version) or die($this->mysqli->error.__LINE__);
- while ($dados2 = $record_sql_version->fetch_assoc()) {
- $version[] = $dados2;
- }
- $price=$record[0]['car_price'];
- $car_user_id=$record[0]['car_user_id'];
- // $sql1="select * from shop_profile where user_id ='".$car_user_id."' ";
- // $record1=$this->conn->getData($sql1);
- // $author_name=$record1[0]['author_name'];
- // $profile_pick=user_images.$record1[0]['profile_pick'];
- // $shop_name=$record1[0]['shop_name'];
- $reseller = $record[0]['car_Reseller_price'];
- $car_name = $record[0]['car_name'];
- $car_name = utf8_encode($car_name);
- $car_fullname = $record[0]['car_fullname'];
- $car_fullname = utf8_encode($car_fullname);
- // $car_name = $record[0]['car_name'];
- // $car_fullname = $record[0]['car_fullname'];
- $car_price = $p;
- $car_model = $record[0]['carYear_name'];
- $vendor_name = utf8_encode($record[0]['user_name']);
- $vendor_email = $record[0]['user_email'];
- $vendor_phone = $record[0]['user_phone'];
- $state_name = utf8_encode($record[0]['state_name']);
- $city_name = utf8_encode($record[0]['city_name']);
- $car_latitude = $record[0]['car_latitude'];
- $car_longitude = $record[0]['car_longitude'];
- $car_Brand = utf8_encode($record[0]['brand_name']);
- $brand_images = brand_images.$record[0]['brand_image'];
- $car_Fuel = utf8_encode($record[0]['carFuel_type']);
- $car_Gear = utf8_encode($record[0]['carGear_type']);
- $car_color = $record[0]['car_color'];
- $car_addr = utf8_encode($record[0]['car_address']);
- $car_color = explode(",",$car_color);
- foreach($car_color as $key => $value) {
- $color_id=$value;
- $query22="select * from tbl_carColor where carColor_id='".$color_id."'";
- // $record2=$this->conn->getData($query22);
- $record_query22=$this->mysqli->query($query22) or die($this->mysqli->error.__LINE__);
- while ($record2 = $record_query22->fetch_assoc()) {
- $carColor_name=$record2['carColor_name'];
- $carColor_code=$record2['carColor_code'];
- $carColor_id=$record2['carColor_id'];
- }
- $color_detail[$key]=array(
- 'carColor_name'=>$carColor_name,
- 'carColor_code'=>$carColor_code,
- 'carColor_id'=>$carColor_id
- );
- }
- $car_version = utf8_encode($record[0]['carVersion_name']);
- $car_option = utf8_encode($record[0]['car_option']);
- $car_blindagem = utf8_encode($record[0]['car_blindagem']);
- $Resellerprice = $r;
- $car_type = utf8_encode($record[0]['carType_name']);
- $car_door = $record[0]['car_door'];
- $car_posted = date("d/m/Y",strtotime($record[0]['car_created_date']));
- $car_images = explode(",",$record[0]['car_images']);
- if(!empty($car_images)){
- foreach ($car_images as $value) {
- $imagesCar[]=car_images.$value;
- }
- }else {
- $imagesCar=array();
- }
- $sql1="select * from shop_profile where user_id ='".$car_user_id."' ";
- // $record1=$this->conn->getData($sql1);
- $record_sql1=$this->mysqli->query($sql1) or die($this->mysqli->error.__LINE__);
- while ($dados1 = $record_sql1->fetch_assoc()) {
- $record1[] = $dados1;
- }
- $author_name=$record1[0]['author_name'];
- $profile_pick=user_images.$record1[0]['profile_pick'];
- $shop_name=$record1[0]['shop_name'];
- $email=$record1[0]['email'];
- $phone=$record1[0]['phone'];
- if(!empty($email)){
- $vendor_email=$email;
- }
- if(!empty($phone)){
- $vendor_phone=$phone;
- }
- // $post= ();
- $post= [
- 'status'=>'true',
- 'message'=>Car_Details_Get_Successfully,
- 'car_id'=>$car_id,
- 'car_name'=>$car_name,
- 'car_fullname'=>$car_fullname,
- 'car_price'=> $price,
- 'car_model'=>$car_model,
- 'vendor_name'=>$vendor_name,
- 'vendor_email'=>$vendor_email,
- 'vendor_phone'=>$vendor_phone,
- 'car_images'=>$imagesCar,
- 'car_state'=>$state_name,
- 'car_city'=>$city_name,
- 'car_latitude'=>$car_latitude,
- 'car_longitude'=>$car_longitude,
- 'car_Brand'=>$car_Brand,
- 'car_Fuel'=>$car_Fuel,
- 'car_Gear'=>$car_Gear,
- 'color_detail'=>$color_detail,
- 'carVersion_name'=>$car_version,
- 'car_posted'=>$car_posted,
- 'interest'=>$car_interest,
- 'reseller_price'=> $reseller,
- 'car_type'=>$car_type,
- 'car_door'=>$car_door,
- 'car_option'=>$car_option,
- 'favourite_status'=>$favourite_status,
- 'car_blindagem'=>$car_blindagem,
- 'brand_image'=>$brand_images,
- 'author_name'=>utf8_encode($author_name),
- 'profile_pick'=>$profile_pick,
- 'shop_name'=>utf8_encode($shop_name),
- 'version'=>utf8_encode($version),
- 'car_addr'=>$car_addr
- ];
- } else {
- $post=array('status'=>'false','message'=>No_CAR_FOUND,'car_id'=>$_REQUEST['car_id']);
- }
- } else {
- $post=array('status'=>'false','message'=>Missing_Parameter,'car_id'=>$_REQUEST['car_id']);
- }
- // print_r($post);
- echo $this->json($post);
- }
- function brand_carType() {
- header("Content-Type: text/html;charset=utf-8");
- header('Content-Type: application/json;charset=utf-8');
- $sql="SELECT max(car_price) as max_carPRice from tbl_cars";
- $pricerecord= $this->conn->getData($sql);
- $brand = $this->conn->get_table_row_byidvalue('tbl_brand', 'brand_status', 1);
- foreach ($brand as $key => $value) {
- $brand_id = $value['brand_id'];
- $brand_name = $value['brand_name'];
- $brand_image = brand_images.$value['brand_image'];
- $brand_response[] = array(
- 'brand_id' => $brand_id,
- 'brand_name' => $brand_name,
- 'brand_image'=>$brand_image
- );
- }
- $carType = $this->conn->get_table_row_byidvalue('tbl_CarType', 'carType_status', 1);
- foreach ($carType as $key => $value) {
- $carType_id = $value['carType_id'];
- $carType_name = $value['carType_name'];
- $carType_image = carType_images.$value['carType_image'];
- $carType_response[] = array(
- 'carType_id' => $carType_id,
- 'carType_name' => $carType_name,
- 'carType_image'=>$carType_image
- );
- }
- $post = array(
- "status" => "true",
- "message" => 'Lista encontrada',
- 'brand'=>$brand_response,
- 'carType'=>$carType_response,
- 'car_Maxprice'=>$pricerecord[0]['max_carPRice']
- );
- echo $this -> json($post);
- }
- function filter_type_list() {
- $blindagemSql = $this-> conn -> get_table_row_byidvalue('tbl_blindagem', 'blindagem_status', 1);
- if(!empty($blindagemSql)){
- foreach ($blindagemSql as $key => $value) {
- $blindagem_id = $value['blindagem_id'];
- $blindagem_type = $value['blindagem_type'];
- $blindagem[] = array(
- 'blindagem_id' => $blindagem_id,
- 'blindagem_type' => $blindagem_type
- );
- }
- } else {
- $blindagem=array();
- }
- $brandSql = $this -> conn -> get_table_row_byidvalue('tbl_brand', 'brand_status', 1);
- if(!empty($brandSql)){
- foreach ($brandSql as $key => $value) {
- $brand_id = $value['brand_id'];
- $brand_name = $value['brand_name'];
- $brand_image = brand_images.$value['brand_image'];
- $brand[] = array(
- 'brand_id' => $brand_id,
- 'brand_name' => $brand_name,
- 'brand_image' => $brand_image
- );
- }
- } else{
- $brand=array();
- }
- $carColorSql = $this -> conn -> get_table_row_byidvalue('tbl_carColor', 'carColor_status', 1);
- if(!empty($carColorSql)){
- foreach ($carColorSql as $key => $value) {
- $carColor_id = $value['carColor_id'];
- $carColor_name = $value['carColor_name'];
- $carColor_code = $value['carColor_code'];
- $carColor[] = array(
- 'carColor_id' => $carColor_id,
- 'carColor_name' => $carColor_name,
- 'carColor_code' => $carColor_code
- );
- }
- }else{
- $carColor=array();
- }
- $carFuelSql = $this -> conn -> get_table_row_byidvalue('tbl_carFuel', 'carFuel_status', 1);
- if(!empty($carFuelSql)){
- foreach ($carFuelSql as $key => $value) {
- $carFuel_id = $value['carFuel_id'];
- $carFuel_type = html_entity_decode($value['carFuel_type']);
- $carFuel[] = array(
- 'carFuel_id' => $carFuel_id,
- 'carFuel_type' => $carFuel_type
- );
- }
- } else{
- $carFuel=array();
- }
- $carGearSql = $this -> conn -> get_table_row_byidvalue('tbl_carGear', 'carGear_status', 1);
- if(!empty($carGearSql)){
- foreach ($carGearSql as $key => $value) {
- $carGear_id = $value['carGear_id'];
- $carGear_type = $value['carGear_type'];
- $carGear[] = array(
- 'carGear_id' => $carGear_id,
- 'carGear_type' => $carGear_type
- );
- }
- } else{
- $carGear=array();
- }
- //$carModelSql = $this -> conn -> get_table_row_byidvalue('tbl_carModel', 'car_Model_status', 1);
- if(!empty($_REQUEST['brand_id'])){
- $where=" AND car_Modal_brand=".$_REQUEST['brand_id'];
- $where1=" AND car_Brand=".$_REQUEST['brand_id'];
- } else{
- $where="";
- $where1="";
- }
- if(!empty($_REQUEST['modal_id'])){
- $where2=" AND car_model=".$_REQUEST['modal_id'];
- } else{
- $where2="";
- }
- $carModelSql = $this -> conn -> getData("SELECT * FROM `tbl_carModel` WHERE car_Model_status=1 ".$where);
- if(!empty($carModelSql)){
- foreach ($carModelSql as $key => $value) {
- $carModel_id = $value['carModel_id'];
- $carModel_name = html_entity_decode($value['carModel_name']);
- $caModel_category_id = $value['caModel_category_id'];
- $caModel_brand_id = $value['car_Modal_brand'];
- $carModel[] = array(
- 'carModel_id' => $carModel_id,
- 'carModel_name' => $carModel_name,
- 'caModel_category_id' => $caModel_category_id,
- 'car_Modal_brand'=>$caModel_brand_id
- );
- }
- } else{
- $carModel=array();
- }
- //$carVersionSql = $this -> conn -> get_table_row_byidvalue('tbl_carVersion', 'carVersion_status', 1);
- $carVersionSql = $this -> conn -> getData("SELECT * FROM `tbl_carVersion` INNER JOIN tbl_cars ON(tbl_carVersion.carVersion_id=tbl_cars.car_Version) WHERE carVersion_status=1 ".$where1.$where2);
- if(!empty($carVersionSql)){
- foreach ($carVersionSql as $key => $value) {
- $carVersion_id = $value['carVersion_id'];
- $carVersion_name = $value['carVersion_name'];
- $carVersion_category = $value['carVersion_category'];
- $car_Model_id = $value['car_Model_id'];
- $carVersion[] = array(
- 'carVersion_id' => $carVersion_id,
- 'carVersion_name' => $carVersion_name,
- 'carVersion_category' => $carVersion_category,
- 'car_Model_id'=>$car_Model_id
- );
- }
- } else{
- $carVersion=array();
- }
- $carYearSql = $this -> conn -> get_table_row_byidvalue('tbl_carYear', 'carYear_status', 1);
- if(!empty($carYearSql)){
- foreach ($carYearSql as $key => $value) {
- $carYear_id = $value['carYear_id'];
- $carYear_name = $value['carYear_name'];
- $carYear[] = array(
- 'carYear_id' => $carYear_id,
- 'carYear_name' => $carYear_name
- );
- }
- } else{
- $carYear=array();
- }
- $post=array(
- 'status'=>'true',
- 'blindagem'=>$blindagem,
- 'carColor'=>$carColor,
- 'carFuel'=>$carFuel,
- 'carGear'=>$carGear,
- 'carModel'=>$carModel,
- 'carVersion'=>$carVersion,
- 'carYear'=>$carYear,
- 'carBrand'=>$brand
- );
- echo $this -> json($post);
- }
- function myfunction($products,$value){
- // echo $value;
- foreach($products as $key => $product){
- if (
- strtolower($product['car_name']) == $value ||
- strtolower($product['car_fullname']) == $value ||
- strtolower($product['car_price']) == $value ||
- strtolower($product['car_latitude']) == $value ||
- strtolower($product['car_latitude']) == $value ||
- strtolower($product['car_address']) == $value ||
- strtolower($product['car_Reseller_price']) == $value ||
- preg_match('/\b' .$value. '\b/', strtolower($product['car_option'])) ||
- strtolower($product['car_created_date']) == $value ||
- strtolower($product['carYear_name']) == $value ||
- strtolower($product['carFuel_type']) == $value ||
- strtolower($product['carGear_type']) == $value ||
- strtolower($product['brand_name']) == $value ||
- strtolower($product['carVersion_name']) == $value ||
- strtolower($product['carType_name']) == $value ||
- strtolower($product['blindagem_type']) == $value ||
- strtolower($product['carModel_name'])== $value ||
- preg_match('/\b' .$value. '\b/', strtolower($product['car_color_name']))
- ){
- $key_info[]=$key;
- }
- }
- return $key_info;
- }
- function remove_favourite(){
- $car_id = $_REQUEST['car_id'];
- $user_id = $_REQUEST['user_id'];
- $sql = "DELETE FROM tbl_favourite WHERE favourite_user_ID = '".$user_id."' AND favourite_car_ID = '".$car_id."'";
- $remover = $this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
- }
- function add_favourite(){
- if(!empty($_REQUEST['car_id']) && !empty($_REQUEST['user_id']) && !empty($_REQUEST['favourite_status'])){
- $carID = $_REQUEST['car_id'];
- $userID = $_REQUEST['user_id'];
- $favourite = $_REQUEST['favourite_status'];
- $sql1="select car_user_id from tbl_cars where car_id='".$carID."'";
- $recordcar=$this->conn->getData($sql1);
- $car_user_id = $recordcar[0]['car_user_id'];
- if($favourite=='1'){
- $sql="select * from tbl_favourite where favourite_car_ID='".$carID."' and favourite_user_ID='".$userID."'";
- $record=$this->conn->getData($sql);
- if(!empty($record)){
- $data['favourite_datetime'] = date("Y-m-d H:i:s");
- $data['favourite_status'] = '1';
- $this->conn->updatetabletwobyid('tbl_favourite','favourite_car_ID',$carID,'favourite_user_ID',$userID,$data);
- $post=array('status'=>'true','message'=>add_favourite,'favourite_status'=>$favourite);
- }else {
- $datetime = date("Y-m-d H:i:s");
- $insert = $this -> conn -> insertnewrecords(
- 'tbl_favourite',
- 'favourite_car_ID,
- favourite_user_ID,
- favourite_datetime,car_user_id',
- '"' . $carID . '",
- "' . $userID . '",
- "' . $datetime . '",
- "' . $car_user_id . '"
- '
- );
- if($insert>0){
- $post=array('status'=>'true','message'=>add_favourite,'favourite_status'=>$favourite);
- } else{
- $post=array('status'=>'false','message'=>Internal_server_error);
- }
- }
- } else if($favourite=='2') {
- $data['favourite_status']='2';
- $this->conn->updatetabletwobyid('tbl_favourite','favourite_car_ID',$carID,'favourite_user_ID',$userID,$data);
- $post=array(
- 'status'=>'true',
- 'message'=>"Adicionado aos favoritos com sucesso!",
- 'favourite_status'=>$favourite
- );
- }
- } else{
- $post=array(
- 'status'=>'false',
- 'message'=>Missing_Parameter,
- 'car_id'=>$_REQUEST['car_id'],
- 'user_id'=>$_REQUEST['user_id'],
- 'favourite_status'=>$_REQUEST['favourite_status']
- );
- }
- echo $this -> json($post);
- }
- function filter_cars(){
- header("Content-Type: text/html;charset=utf-8");
- header('Content-Type: application/json;charset=utf-8');
- // $carSearch= 'gasolina,preto,coupé';
- // if(!empty($carSearch)){
- if(!empty($_REQUEST['car_search'])){
- $sql="
- SELECT * FROM tbl_cars
- jOIN tbl_carYear ON tbl_carYear.carYear_id=tbl_cars.car_Year
- jOIN tbl_carFuel ON tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
- jOIN tbl_carGear ON tbl_carGear.carGear_id=tbl_cars.car_Gear
- jOIN tbl_brand ON tbl_brand.brand_id=tbl_cars.car_Brand
- jOIN tbl_carVersion ON tbl_carVersion.carVersion_id=tbl_cars.car_Version
- jOIN tbl_blindagem ON tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
- jOIN tbl_carModel ON tbl_carModel.carModel_id=tbl_cars.car_model
- JOIN tbl_CarType ON tbl_CarType.carType_id=tbl_cars.car_category_id
- WHERE tbl_cars.car_status=1
- AND tbl_carYear.carYear_status=1
- AND tbl_carFuel.carFuel_status=1
- AND tbl_carGear.carGear_status=1
- AND tbl_brand.brand_status=1
- AND tbl_carVersion.carVersion_status=1
- AND tbl_blindagem.blindagem_status=1
- AND tbl_carModel.car_Model_status=1
- AND tbl_CarType.carType_status=1
- ORDER BY RAND()
- ";
- $car_info=$this->conn->getData($sql);
- foreach($car_info as $key1 => $product){
- $car_color=$product['car_color'];
- $car_color=explode(",",$car_color);
- $car_color_string="";
- foreach($car_color as $key => $value){
- $color_id=$value;
- $query22="select * from tbl_carColor where carColor_id='".$color_id."'";
- $record2=$this->conn->getData($query22);
- $car_color_string.=$record2[0]['carColor_name'].',';
- }
- $car_color_string = rtrim($car_color_string,',');
- $car_info[$key1]['car_color_name']=$car_color_string;
- }
- // $car_search=$carSearch;
- $car_search=$_REQUEST['car_search'];
- $car_search=explode(",",$car_search);
- foreach($car_search as $value){
- $info=strtolower($value);
- $key=$this->myfunction($car_info,$info);
- $key_data[]=$key;
- }
- $countData = count($key_data);
- if ($countData<= 1) {
- $oneDimensionalArray = call_user_func_array('array_merge', $key_data);
- } else{
- $oneDimensionalArray = call_user_func_array('array_intersect', $key_data);
- }
- $oneDimensionalArray = array_unique($oneDimensionalArray);
- foreach($oneDimensionalArray as $value){
- $car_detail[]=$car_info[$value];
- }
- foreach ($car_detail as $key => $value) {
- $car_id = $value['car_id'];
- $car_user_id = $value['car_user_id'];
- $query_subcription="select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
- $record_subcription=$this->conn->getData($query_subcription);
- if(!empty($record_subcription)){
- $end_date=$record_subcription[0]['end_date'];
- $date=date("Y-m-d h:i:s a");
- if(!($date<=$end_date)){
- $value['car_featured']='2';
- }
- } else {
- $value['car_featured']='2';
- }
- $car_name = $value['car_name'];
- $car_name = html_entity_decode($car_name);
- $car_fullname = $value['car_fullname'];
- $car_fullname = html_entity_decode($car_fullname);
- $car_price = $value['car_price'];
- $car_model = $value['carYear_name'];
- $car_featured = $value['car_featured'];
- $carFuel_type = $value['carFuel_type'];
- $carFuel_type = html_entity_decode($carFuel_type);
- $carVersion_name = $value['carVersion_name'];
- $carType_name = $value['carType_name'];
- $carType_name = html_entity_decode($carType_name);
- $carGear_type = $value['carGear_type'];
- $car_featured = $value['car_featured'];
- $brand_images = brand_images.$value['brand_image'];
- $car_images = $value['car_profile_pick'];
- $car_color_name = $value['car_color_name'];
- $carVersion_name = $value['carVersion_name'];
- $Resellerprice = $value['car_Reseller_price'];
- $response[] = array(
- 'car_id' => $car_id,
- 'car_name' => $car_name,
- 'car_fullname'=>$car_fullname,
- 'car_price'=>$car_price,
- 'car_model'=>$car_model,
- 'car_images'=>car_images.$car_images,
- 'car_featured'=>$car_featured,
- 'fuel_type'=>$carFuel_type,
- 'gear_type'=>$carGear_type,
- 'reseller_price'=>$Resellerprice,
- 'carVersion_name'=>$carVersion_name,
- 'favourite_status'=>$favourite_status,
- 'brand_images'=>$brand_images,
- 'car_color_name'=>$car_color_name,
- 'carVersion_name'=>$carVersion_name,
- 'carType_name'=>$carType_name
- );
- }
- if (!empty($response)) {
- $post = array("status" => 'true', "message" => count($response)." ".Car_found,'cars'=>$response);
- } else {
- $post = array('status' => "false", "message" => No_Record_Found);
- }
- echo $this -> json($post);
- die();
- }
- if(
- !empty($_REQUEST['brand_type'])
- || !empty($_REQUEST['blindagem_filter'])
- || !empty($_REQUEST['carColor_filter'])
- || !empty($_REQUEST['carFuel_filter'])
- || !empty($_REQUEST['carModel_filter'])
- || !empty($_REQUEST['carVersion_filter'])
- || !empty($_REQUEST['carGear_filter'])
- || !empty($_REQUEST['carYear_filter'])
- || !empty($_REQUEST['price_filter'])
- ){
- $user_id=$_REQUEST['user_id'];
- $priceFilterType = $_REQUEST['priceFilterType'];
- if($priceFilterType=='1'){
- $orderBy="Asc";
- } else if ($priceFilterType=='2'){
- $orderBy="Desc";
- }
- $sql='';
- $price_filter = $_REQUEST['price_filter'];
- if($price_filter ==1) {
- $low_price = $_REQUEST['low_price'];
- $high_price = $_REQUEST['high_price'];
- if(!empty($sql)){
- $sql.='and car_price between "'.$low_price.'" and "'.$high_price.'"';
- } else {
- $sql.='car_price between "'.$low_price.'" and "'.$high_price.'"';
- }
- }
- $brand_type = $_REQUEST['brand_type'];
- if($brand_type=='1'){
- $brand_id = $_REQUEST['brand_id'];
- if(!empty($sql)){
- $sql.='and car_Brand="'.$brand_id.'"';
- } else {
- $sql.='car_Brand="'.$brand_id.'"';
- }
- }
- $car_type = $_REQUEST['car_type'];
- if($car_type=='1'){
- $car_type_id = $_REQUEST['car_type_id'];
- if(!empty($sql)){
- $sql.='and car_category_id="'.$car_type_id.'"';
- } else {
- $sql.='car_category_id="'.$car_type_id.'"';
- }
- }
- $blindagem_filter = $_REQUEST['blindagem_filter'];
- if($blindagem_filter=='1') {
- $blindagem = $_REQUEST['blindagem'];
- if(!empty($sql)){
- $sql.='and car_blindagem="'.$blindagem.'"';
- } else {
- $sql.='car_blindagem="'.$blindagem.'"';
- }
- }
- $carColor_filter = $_REQUEST['carColor_filter'];
- if($carColor_filter=='1') {
- $carColor = $_REQUEST['carColor'];
- if(!empty($sql)){
- $sql.='and car_color LIKE "'.'%'.$carColor.'%'.'"';
- } else {
- $sql.='car_color LIKE "'.'%'.$carColor.'%'.'"';
- }
- }
- $carFuel_filter = $_REQUEST['carFuel_filter'];
- if($carFuel_filter=='1'){
- $carFuel = $_REQUEST['carFuel'];
- if(!empty($sql)) {
- $sql.='and car_Fuel="'.$carFuel.'"';
- } else {
- $sql.='car_Fuel="'.$carFuel.'"';
- }
- }
- $carModel_filter = $_REQUEST['carModel_filter'];
- if($carModel_filter=='1'){
- $carModel = $_REQUEST['carModel'];
- if(!empty($sql)){
- $sql.='and car_model="'.$carModel.'"';
- } else {
- $sql.='car_model="'.$carModel.'"';
- }
- }
- $carVersion_filter = $_REQUEST['carVersion_filter'];
- if($carVersion_filter=='1'){
- $carVersion = $_REQUEST['carVersion'];
- if(!empty($sql)){
- $sql.='and car_Version="'.$carVersion.'"';
- } else {
- $sql.='car_Version="'.$carVersion.'"';
- }
- }
- $carGear_filter = $_REQUEST['carGear_filter'];
- if($carGear_filter=='1'){
- $carGear = $_REQUEST['carGear'];
- if(!empty($sql)){
- $sql.='and car_Gear="'.$carGear.'"';
- } else {
- $sql.='car_Gear="'.$carGear.'"';
- }
- }
- $carYear_filter = $_REQUEST['carYear_filter'];
- if($carYear_filter=='1'){
- $carYear = $_REQUEST['carYear'];
- if(!empty($sql)) {
- $sql.='and car_Year="'.$carYear.'"';
- } else {
- $sql.='car_Year="'.$carYear.'"';
- }
- }
- if(!empty($sql)){
- $query="
- SELECT * FROM tbl_cars
- jOIN tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
- jOIN tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
- jOIN tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
- jOIN tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
- jOIN tbl_carVersion on tbl_carVersion.carVersion_id=tbl_cars.car_Version
- jOIN tbl_blindagem on tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
- jOIN tbl_carModel on tbl_carModel.carModel_id=tbl_cars.car_model
- WHERE ".$sql."
- AND tbl_cars.car_status=1
- AND tbl_carYear.carYear_status=1
- AND tbl_carFuel.carFuel_status=1
- AND tbl_carGear.carGear_status=1
- AND tbl_brand.brand_status=1
- AND tbl_carVersion.carVersion_status=1
- AND tbl_blindagem.blindagem_status=1
- AND tbl_carModel.car_Model_status=1
- ORDER BY car_price ".$orderBy
- ;
- } else {
- $query="
- SELECT * FROM tbl_cars
- jOIN tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
- jOIN tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
- jOIN tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
- jOIN tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
- jOIN tbl_carVersion on tbl_carVersion.carVersion_id=tbl_cars.car_Version
- jOIN tbl_blindagem on tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
- jOIN tbl_carModel on tbl_carModel.carModel_id=tbl_cars.car_model
- WHERE tbl_cars.car_status=1
- AND tbl_carYear.carYear_status=1
- AND tbl_carFuel.carFuel_status=1
- AND tbl_carGear.carGear_status=1
- AND tbl_brand.brand_status=1
- AND tbl_carVersion.carVersion_status=1
- AND tbl_blindagem.blindagem_status=1
- AND tbl_carModel.car_Model_status=1
- ORDER BY car_price ".$orderBy
- ;
- }
- // print_r($query); die();
- // print_r($query);
- $record=$this->conn->getData($query);
- if(!empty($record)){
- foreach ($record as $key => $value){
- $car_id = $value['car_id'];
- $sql1="select * from tbl_favourite where favourite_car_ID='".$car_id."' and favourite_user_ID='".$user_id."'";
- $record1=$this->conn->getData($sql1);
- if(!empty($record1)){
- $favourite_status=$record1[0]['favourite_status'];
- if($favourite_status==1){
- $favourite_status='1';
- } else {
- $favourite_status='2';
- }
- } else {
- $favourite_status='2';
- }
- $car_user_id = $value['car_user_id'];
- $query_subcription="select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
- $record_subcription=$this->conn->getData($query_subcription);
- if(!empty($record_subcription)) {
- $end_date=$record_subcription[0]['end_date'];
- $date=date("Y-m-d h:i:s a");
- if(!($date<=$end_date)){
- $value['car_featured']='2';
- }
- } else {
- $value['car_featured']='2';
- }
- $car_id = $value['car_id'];
- $car_name = html_entity_decode($value['car_name']);
- $car_fullname = html_entity_decode($value['car_fullname']);
- $car_price = $value['car_price'];
- $car_model = $value['carYear_name'];
- $car_featured = $value['car_featured'];
- $carFuel_type = html_entity_decode($value['carFuel_type']);
- $carGear_type = $value['carGear_type'];
- $car_featured = $value['car_featured'];
- $car_images = explode(",",$value['car_images']);
- $Resellerprice = $value['car_Reseller_price'];
- $carVersion_name = $value['carVersion_name'];
- $brand_images = brand_images.$value['brand_image'];
- // $r=number_format($Resellerprice);
- $response[] = array(
- 'car_id' => $car_id,
- 'car_name' => $car_name,
- 'car_fullname'=>$car_fullname,
- 'car_price'=>$car_price,
- 'car_model'=>$car_model,
- 'car_images'=>car_images.$car_images[0],
- 'car_featured'=>$car_featured,
- 'fuel_type'=>$carFuel_type,
- 'gear_type'=>$carGear_type,
- 'reseller_price'=>$Resellerprice,
- 'carVersion_name'=>$carVersion_name,
- 'brand_images'=>$brand_images,
- 'favourite_status'=>$favourite_status
- );
- }
- $post=array(
- 'status'=>'true',
- 'message'=>count($response)." ".Car_found,
- 'cars'=>$response
- );
- } else {
- $post=array('status'=>'false','message'=>No_CAR_FOUND);
- }
- } else {
- $post=array(
- 'status'=>'false',
- 'message'=>Missing_Parameter,
- 'blindagem_filter'=>$_REQUEST['blindagem_filter'],
- 'carColor_filter'=>$_REQUEST['carColor_filter'],
- 'carFuel_filter'=>$_REQUEST['carFuel_filter'],
- 'carModel_filter'=>$_REQUEST['carModel_filter'],
- 'carVersion_filter'=>$_REQUEST[''],
- 'carYear_filter'=>$_REQUEST['carYear_filter'],
- 'reseller_price'=>$Resellerprice
- );
- }
- echo $this -> json($post);
- }
- function favourite_car_list() {
- header("Content-Type: text/html;charset=utf-8");
- // setlocale(LC_MONETARY,"en_US");
- // money_format($car_price);
- $user_id=$_REQUEST['user_id'];
- if(!empty($user_id)){
- // $state = $this -> conn -> get_table_row_byidvalue('tbl_cars', 'car_status', 1);
- $sql1="
- SELECT * FROM tbl_cars
- join tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
- join tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
- join tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
- join tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
- join tbl_favourite on tbl_favourite.favourite_car_ID=tbl_cars.car_id
- where tbl_favourite.favourite_status = 1
- AND favourite_user_ID ='".$user_id."'
- ";
- $record=$this->conn->getData($sql1);
- foreach ($record as $key => $value){
- $car_user_id = $value['car_user_id'];
- $query_subcription ="
- SELECT * FROM tbl_subcription_payment
- where sub_pay_userID='".$car_user_id."'
- ORDER BY sub_payment_id DESC
- ";
- $record_subcription=$this->conn->getData($query_subcription);
- if(!empty($record_subcription)){
- $end_date=$record_subcription[0]['end_date'];
- $date=date("Y-m-d h:i:s a");
- if(!($date<=$end_date)){
- $value['car_featured']='2';
- }
- } else{
- $value['car_featured']='2';
- }
- $car_id = $value['car_id'];
- $car_name = $value['car_name'];
- $car_name = html_entity_decode($car_name);
- $car_fullname = $value['car_fullname'];
- $car_fullname = html_entity_decode($car_fullname);
- $car_price = $value['car_price'];
- $car_model = $value['carYear_name'];
- $car_featured = $value['car_featured'];
- $carFuel_type = $value['carFuel_type'];
- $carFuel_type = html_entity_decode($carFuel_type);
- $carGear_type = $value['carGear_type'];
- $car_featured = $value['car_featured'];
- $favourite_status = $value['favourite_status'];
- $car_images = explode(",",$value['car_images']);
- $brand_images = brand_images.$value['brand_image'];
- // $car_name = $value['car_name'];
- // $car_fullname = $value['car_fullname'];
- // $car_price = $this->moneyFormatIndia($value['car_price']);
- // $Resellerprice = $this->moneyFormatIndia($value['car_Reseller_price']);
- $Resellerprice = $value['car_Reseller_price'];
- $response[] = array(
- 'car_id' => $car_id,
- 'car_name' => $car_name,
- 'car_fullname'=>$car_fullname,
- 'car_price'=>$car_price,
- 'car_model'=>$car_model,
- 'car_images'=>car_images.$car_images[0],
- 'car_featured'=>$car_featured,
- 'fuel_type'=>$carFuel_type,
- 'gear_type'=>$carGear_type,
- 'reseller_price'=>$Resellerprice,
- 'favourite_status'=>$favourite_status,
- 'brand_images'=>$brand_images
- );
- }
- if (!empty($response)) {
- $post = array("status" => "true", "message" => count($response)." ".Car_found,'cars'=>$response);
- } else{
- $post = array('status' => "false", "message" => No_Record_Found);
- }
- } else{
- $post = array("status" => "false", "message" => "parâmetro faltando");
- }
- echo $this -> json($post);
- }
- function add_interest() {
- if(!empty($_REQUEST['car_id']) && !empty($_REQUEST['user_id']) && !empty($_REQUEST['interest_status'])) {
- $carID = $_REQUEST['car_id'];
- $userID = $_REQUEST['user_id'];
- $interest = $_REQUEST['interest_status'];
- $sql1="select car_user_id from tbl_cars where car_id='".$carID."'";
- $recordcar=$this->conn->getData($sql1);
- $car_user_id = $recordcar[0]['car_user_id'];
- $carname = $this -> conn -> get_table_row_byidvalue('tbl_cars', 'car_id',$carID);
- $userData1 = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_id',$userID);
- $unm=$userData1[0]['user_name'];
- $uphn=$userData1[0]['user_phone'];
- $carname=$carname[0]['car_name'];
- // print_r($userData1[0]['user_name']); die();
- if($interest=='1'){
- $sql="select * from tbl_interest where interest_car_ID='".$carID."' and interest_user_ID='".$userID."'";
- $record=$this->conn->getData($sql);
- if(!empty($record)){
- $data['interest_datetime'] = date("Y-m-d H:i:s");
- $data['interest_status'] = '1';
- $this->conn->updatetabletwobyid('tbl_interest','interest_car_ID',$carID,'interest_user_ID',$userID,$data);
- $user = $this -> conn -> get_table_row_byidvalue('shop_profile', 'user_id',$car_user_id);
- foreach ($user as $key => $value) {
- $user_email = $value['email'];
- $user_phone = $value['phone'];
- }
- $user_phone=$user_phone;
- $sms_msg="Alguém está interessado em seu carro ".$carname.", por favor, verifique os detalhes em Admin,Comercial Nome:".$unm.",Comercial No:".$uphn.".";
- $this->send_sms($user_phone,$sms_msg);
- $to = $user_email;
- $subject = "Interesse em Carro";
- $txt = "Alguém interessado em seu carro.";
- $txt='
- <html>
- <head>
- <title> Email</title>
- <style>
- .button {
- background-color: #ff6600;
- border: none;
- color: white;
- padding: 12px 72px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 25px 2px;
- cursor: pointer;
- }
- </style>
- </head>
- <body style="" >
- <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc;
- border-top-left-radius: 18px;border-top-right-radius:18px;font-family:"Ubuntu",sans-serif!important; font-family:"Ubuntu",sans-serif!important;">
- <tr>
- <td style="color:#ff6600;font-size:30px;font-weight:600;padding:36px 0;text-align:center;background-image:url('.user_images.'bg.jpg); background-repeat:no-repeat;border-top-left-radius: 15px; border-top-right-radius:15px; overflow:hidden;">
- Interesse em Carro "'.$carname.'"
- </td>
- </tr>
- <tr>
- <td style="font-size: 25px;padding: 15px 55px;text-align: center; color:#777777;">
- Uma pessoa se interessou em seu carro!
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- Comercial Nome:"'.$unm.'",Comercial No:"'.$uphn.'" !
- </td>
- </tr>
- <tr>
- Comercial Nome:".$unm.",Comercial No:".$uphn."
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- caso você não tenha alterado sua senha, contate a equipe de suporte
- </td>
- </tr>
- <tr>
- <th>
- <a href="http://cms.buscarsbr.com.br/user_login" class="button">ACESSAR PAINEL</a>
- </th>
- </tr>
- <tr >
- <td style="text-align:center; padding:15px;">
- <img width="150" src="'.user_images.'logo1.png" />
- </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- $headers = "MIME-Version: 1.0" . "\r\n";
- $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
- // // More headers
- $headers .= 'From: "Buscar" <app@buscarsbr.com.br>' . "\r\n";
- $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
- // mail($to,$subject,$txt,$headers);
- $post=array('status'=>'true','message'=>add_interest,'interest'=>$interest);
- } else{
- $datetime = date("Y-m-d H:i:s");
- $insert = $this -> conn -> insertnewrecords('tbl_interest', 'interest_car_ID, interest_user_ID, interest_datetime, car_user_id', '"' . $carID . '","' . $userID . '","' . $datetime . '","' . $car_user_id . '"');
- if($insert>0){
- $user = $this -> conn -> get_table_row_byidvalue('shop_profile', 'user_id',$car_user_id);
- foreach ($user as $key => $value) {
- $user_email = $value['email'];
- $user_phone = $value['phone'];
- }
- $user_phone=$user_phone;
- $sms_msg="Alguém está interessado em seu carro ".$carname.", por favor, verifique os detalhes em Admin,Comercial Nome:".$unm.",Comercial No:".$uphn.".";
- $this->send_sms($user_phone,$sms_msg);
- $to = $user_email;
- $subject = "Interesse em Carro";
- $txt = "intrest uma pessoa em seu carro";
- $txt='
- <html>
- <head>
- <title> Email</title>
- <style>
- .button {
- background-color: #ff6600;
- border: none;
- color: white;
- padding: 12px 72px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 25px 2px;
- cursor: pointer;
- }
- </style>
- </head>
- <body style="" >
- <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc;border-top-left-radius: 18px;border-top-right-radius:18px;font-family:"Ubuntu",sans-serif!important; font-family:"Ubuntu",sans-serif!important;">
- <tr>
- <td style="color:#ff6600;font-size:30px;font-weight:600;padding:36px 0;text-align:center;background-image:url('.user_images.'bg.jpg); background-repeat:no-repeat; border-top-left-radius: 15px; border-top-right-radius:15px; overflow:hidden;">
- Interesse em Carro "'.$carname.'"
- </td>
- </tr>
- <tr>
- <td style="font-size: 25px;padding: 15px 55px;text-align: center; color:#777777;">
- Uma pessoa se interessou em seu carro!
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- Comercial Nome:"'.$unm.'",Comercial No:"'.$uphn.'" !
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- caso você não tenha alterado sua senha, contate a equipe de suporte
- </td>
- </tr>
- <tr>
- <th>
- <a href="http://cms.buscarsbr.com.br/user_login" class="button">ACESSAR PAINEL</a>
- </th>
- </tr>
- <tr >
- <td style="text-align:center; padding:15px;">
- <img width="150" src="'.user_images.'logo1.png" />
- </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- // $headers = "MIME-Version: 1.0" . "\r\n";
- // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
- // // More headers
- // $headers .= 'From: "Buscar" <app@buscarsbr.com.br>' . "\r\n";
- $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
- $post=array('status'=>'true','message'=>add_interest,'interest'=>$interest);
- } else{
- $post=array('status'=>'false','message'=>Internal_server_error);
- }
- }
- } else if($interest=='2'){
- $data['interest_status']='2';
- $this->conn->updatetabletwobyid('tbl_interest','interest_car_ID',$carID,'interest_user_ID',$userID,$data);
- $post=array('status'=>'true','message'=>remove_interest,'interest'=>$interest);
- }
- } else{
- $post=array(
- 'status'=>'false',
- 'message'=>Missing_Parameter,
- 'car_id'=>$_REQUEST['car_id'],
- 'user_id'=>$_REQUEST['user_id'],
- 'interest_status'=>$_REQUEST['interest_status']
- );
- }
- echo $this -> json($post);
- }
- function subscription_list() {
- $state = $this -> conn -> get_table_row_byidvalue('tbl_subscription', 'subscription_status', 1);
- foreach ($state as $key => $value) {
- $subscription_id = $value['subscription_id'];
- $subscription_type = $value['subscription_type'];
- $subscription_name = $value['subscription_name'];
- $subscription_name = html_entity_decode($subscription_name);
- $subscription_amount = $value['subscription_amount'];
- $subscription_validity = $value['subscription_validity'];
- $subscription_desc = html_entity_decode($value['subscription_desc']);
- $sub_pay_userID=$_REQUEST['sub_pay_userID'];
- $query="select * from tbl_subcription_payment where sub_pay_userID='".$sub_pay_userID."' ORDER BY sub_payment_id DESC";
- $record=$this->conn->getData($query);
- $sub_planID=$record[0]['sub_planID'];
- if($subscription_id ==$sub_planID){
- $sub_pay_status = 1;
- } else{
- $sub_pay_status = 2;
- }
- $response[] = array(
- 'subscription_id' => $subscription_id,
- 'subscription_name' => $subscription_name,
- 'subscription_amount'=>$subscription_amount,
- 'subscription_validity'=>$subscription_validity,
- 'subscription_desc'=>$subscription_desc,
- 'subscription_type'=>$subscription_type,
- 'sub_pay_status'=>$sub_pay_status
- );
- }
- if (!empty($response)) {
- $post = array("status" => "true", "message" => 'Lista de inscrição encontrada','subscription'=>$response);
- } else {
- $post = array('status' => "false", "message" => No_Record_Found);
- }
- echo $this -> json($post);
- }
- // estrutura para notificacao nativa
- // tarefa :: integrar firebase cloud msg
- function android_notification() {
- // function android_notification($gcm_id, $msg) {
- // $gcm_id = '15s158123';
- // $msg = "Teste!!";
- if (!empty($gcm_id)) {
- $registrationIds = array($gcm_id);
- $message = array("msg" => $msg);
- $GOOGLE_API_KEY = Api_key;
- $fields = array(
- 'registration_ids' => $registrationIds,
- 'data' => $message
- );
- $headers = array(
- 'Authorization: key=' . $GOOGLE_API_KEY,
- 'Content-Type: application/json'
- );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
- $result = curl_exec($ch);
- curl_close($ch);
- print_r($result);die;
- // return $result;
- }
- }
- // processo de pagamento
- function authentication() {
- if(!empty($_REQUEST['authentication']) && !empty($_REQUEST['user_id']))
- {
- $current_date=date("Y-m-d H:i:s");
- $authentication = $_REQUEST['authentication'];
- $user_id = $_REQUEST['user_id'];
- $data['authentication'] = $authentication;
- $refresh_token=$this->payment_process($authentication);
- $refresh_token_final=json_decode($refresh_token, True);
- $data['payment_details']=$refresh_token;
- $update_toekn = $this -> conn -> updatetablebyid('tbl_user', 'user_id', $user_id, $data);
- $t_id=json_decode($refresh_token_final['transactionDetails'],TRUE);
- //if(!empty($_REQUEST['user_id']) && !empty($_REQUEST['subscription_id']) && !empty($_REQUEST['sub_pay_name']) && !empty($_REQUEST['sub_pay_cnpg']) && !empty($_REQUEST['sub_pay_email']) && !empty($_REQUEST['sub_pay_phone']))
- //$insert = $this -> conn -> insertnewrecords('tbl_payment_details', 'id,user_id,access_token,refresh_token,authentication_code,transaction_details', $vals);
- $this->subscription_transaction($t_id['id'],$t_id['state'],$refresh_token_final['refresh_token'],$_REQUEST['user_id'],$_REQUEST['subscription_id'],$_REQUEST['sub_pay_name'],$_REQUEST['sub_pay_cnpg'],$_REQUEST['sub_pay_email'],$_REQUEST['sub_pay_phone'],$data['payment_details']);
- $sql2= " INSERT INTO tbl_payment_details_log (user_id, transaction_details, payment_date)
- VALUES ('".$_REQUEST['user_id']."', '".$refresh_token."', '".$current_date."')";
- $insert=$this->conn->insert($sql2);
- $post=array('status'=>'true','message'=>'Update successfully','transaction_id'=>$t_id['id']);
- }
- else{
- $post=array('status'=>'false','message'=>'Invalid peremeter');
- }
- echo $this -> json($post);
- }
- // pagamento recursivo.
- function recursive_payment_process(){
- $end_date = date('Y-m-d');
- $current_date=date("Y-m-d H:i:s");
- $new_end_date = date('Y-m-d', strtotime("+1 months", strtotime($current_date)));
- //$sql="select * from tbl_subcription_payment GROUP BY `sub_pay_userID`
- //ORDER BY `sub_payment_id` DESC";
- /*echo $sql="select * from `tbl_subcription_payment` LEFT JOIN `tbl_user` ON tbl_subcription_payment.sub_pay_userID=tbl_user.user_email WHERE `sub_payment_id` IN (
- SELECT MAX(`sub_payment_id`)
- FROM `tbl_subcription_payment`
- GROUP BY `sub_pay_userID`
- ) AND `end_date`='".$end_date."' AND `sub_plan_pai_status`=1";
- die();*/
- $sql="select * from `tbl_subcription_payment` WHERE `sub_payment_id` IN (
- SELECT MAX(`sub_payment_id`)
- FROM `tbl_subcription_payment`
- GROUP BY `sub_pay_userID`
- ) AND `end_date`='".$end_date."' AND `sub_plan_pai_status`=1";
- $records=$this->conn->getData($sql);
- if(count($records) > 0){
- foreach($records as $record){
- $sqlu="SELECT * FROM `tbl_user` WHERE `user_id`='".$record['sub_pay_userID']."'";
- $user_details=$this->conn->getData($sqlu);
- //print_r($user_details);die();
- if($record['refresh_token'] != ""){
- //print_r($user_details[0]['user_email']);die();
- //Refresh Token and payment
- $token=$this->refresh_token($record['refresh_token']);
- $response=$this->payment_init($token);
- $final_res=array();
- $final_res['token']=$token;
- $final_res['refresh_token']=$record['refresh_token'];
- //$final_res['authentication']=$authentication;
- $final_res['transactionDetails']=$response;
- $return_res=json_encode($final_res);
- $data['payment_details']=$return_res;
- $update_toekn = $this -> conn -> updatetablebyid('tbl_user', 'user_id', $record['sub_pay_userID'], $data);
- $refresh_token_final=json_decode($return_res, True);
- $t_id=json_decode($refresh_token_final['transactionDetails'],TRUE);
- $data_sub['sub_pay_transID']=$t_id['id'];
- $data_sub['sub_pay_status']=$t_id['state'];
- $data_sub['refresh_token']=$record['refresh_token'];
- $data_sub['end_date']=$new_end_date;
- $data_sub['sub_pay_datetime']=$current_date;
- $data_sub['payment_details']=$return_res;
- $update_subscription = $this -> conn -> updatetablebyid('tbl_subcription_payment', 'sub_payment_id', $record['sub_payment_id'], $data_sub);
- //$t_id['id'],$t_id['state']
- //Update Logs table
- $sql2= " INSERT INTO tbl_payment_details_log (user_id, transaction_details, payment_date)
- VALUES ('".$record['sub_pay_userID']."', '".$return_res."', '".$current_date."')";
- $insert=$this->conn->insert($sql2);
- //$insert = $this -> conn -> insertnewrecords('tbl_payment_details_log','user_id,transaction_details,date', '"'.$record['sub_pay_userID'].'","'.$return_res.'","'.$current_date .'"');
- //Update Logs table
- //echo $insert.'kkk';
- //print_r($return_res);
- $to = $user_details[0]['user_email'];
- $subject = "Renovação da inscrição";
- $txt = "Seu plano de assinatura foi renovado com sucesso.";
- $headers = "From:admin@gmail.com";
- mail($to,$subject,$txt,$headers);
- }
- }
- echo "Records Updated";
- }else{
- echo "No Records Found";
- }
- //print_r($records);
- die();
- }
- //Processo de Pagamento
- function payment_process($authentication)
- {
- //$authentication=$_REQUEST['authentication'];
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => "https://api.sandbox.paypal.com/v1/oauth2/token",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "grant_type=authorization_code&response_type=token&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&code=".$authentication,
- CURLOPT_HTTPHEADER => array(
- "authorization: Basic QVhyNTBOR0VnNFdqaV93X21mcmR4SzdoUGZXZzJFRGh6T3RsSW8tQ3pTaGVXX25IdFVKNEh4dVRjdEc3dVA5NU82NEk4X3RNOENxQTg5Qkw6RUNnQkgtMXZIdnB6M0hqaS1wbWFqeFdSUXMtS3RwQjFLakpoN3hoakpaV1RiUWZXMFAyMm16M09DaTRtTG1qTTdPV0dndUwxUUpKUkxXNjQ=",
- "cache-control: no-cache",
- "content-type: application/x-www-form-urlencoded",
- "postman-token: 651e3443-9dc0-84da-0bcc-6522f9ed1c0d"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- $res=json_decode($response);
- $res->refresh_token;
- $token=$this->refresh_token($res->refresh_token);
- //echo $token;die();
- $response=$this->payment_init($token);
- //$final_res=json_decode($response);
- $final_res=array();
- $final_res['token']=$token;
- $final_res['refresh_token']=$res->refresh_token;
- $final_res['authentication']=$authentication;
- $final_res['transactionDetails']=$response;
- $return_res=json_encode($final_res);
- //$insert = $this -> conn -> insertnewrecords('tbl_payment_details','id,user_id,access_token,refresh_token,authentication_code,transaction_details', 'NULL,1,uuu,rrr,lll,ggg');
- //echo $return_res .'</br>';
- //echo $this->db->last_query();die();
- //echo $return_res;die();
- //print_r($final_res);die();
- return $return_res;
- }
- }
- // Atualizacao Token
- function refresh_token($r_token) {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => "https://api.sandbox.paypal.com/v1/oauth2/token",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "grant_type=refresh_token&refresh_token=".$r_token,
- CURLOPT_HTTPHEADER => array(
- "authorization: Basic QVhyNTBOR0VnNFdqaV93X21mcmR4SzdoUGZXZzJFRGh6T3RsSW8tQ3pTaGVXX25IdFVKNEh4dVRjdEc3dVA5NU82NEk4X3RNOENxQTg5Qkw6RUNnQkgtMXZIdnB6M0hqaS1wbWFqeFdSUXMtS3RwQjFLakpoN3hoakpaV1RiUWZXMFAyMm16M09DaTRtTG1qTTdPV0dndUwxUUpKUkxXNjQ=",
- "cache-control: no-cache",
- "content-type: application/x-www-form-urlencoded",
- "postman-token: f37c7027-0774-23fb-de41-43ed3456732d"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- $get_token=json_decode($response);
- return $get_token->access_token;
- //return $response;
- //$access_token=$get_token['access_token'];
- }
- }
- // estrutura do pagamento - inicio da mesma --__--
- function payment_init($token){
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => "https://api.sandbox.paypal.com/v1/payments/payment",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => "{\n \"intent\":\"authorize\",\n \"payer\":{\n \"payment_method\":\"paypal\"\n },\n \"transactions\":[\n {\n \"amount\":{\n \"currency\":\"BRL\",\n \"total\":\"10.00\"\n },\n \"description\":\"test future payment\"\n }\n ]\n }",
- CURLOPT_HTTPHEADER => array(
- "authorization: Bearer ".$token,
- "cache-control: no-cache",
- "content-type: application/json",
- "paypal-client-metadata-id: c2edbd6e97b14ff2b19ddb8eec9d264c",
- "postman-token: ac31ba6c-58fd-ca3e-92ef-d5e950f82003"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- return $response;
- }
- }
- function update_feedback() {
- if(!empty($_REQUEST['feedback_id'])){
- $feedback_id = $_REQUEST['feedback_id'];
- $feedback_name = $_REQUEST['feedback_name'];
- $feedback_email = $_REQUEST['feedback_email'];
- $feedback_subject = $_REQUEST['feedback_subject'];
- $feedback_message = $_REQUEST['feedback_message'];
- $sql="select * from tbl_feedback where feedback_id='".$feedback_id."'";
- $res=mysql_query($sql);
- $row=mysql_num_rows($res);
- if($row>0)
- {
- $result=mysql_fetch_array($res);
- if(!empty($feedback_name))
- {
- $feedback_name=$feedback_name;
- }else{
- $feedback_name=$result['feedback_name'];;
- }
- if(!empty($feedback_email))
- {
- $feedback_email=$feedback_email;
- }else{
- $feedback_email=$result['feedback_email'];
- }
- if(!empty($feedback_subject))
- {
- $feedback_subject=$feedback_subject;
- }else{
- $feedback_subject=$result['feedback_subject'];
- }
- if(!empty($feedback_message))
- {
- $feedback_message=$feedback_message;
- }else{
- $feedback_message=$result['feedback_message'];
- }
- $update="update tbl_feedback set feedback_name='".$feedback_name."', feedback_email='".$feedback_email."', feedback_subject='".$feedback_subject."', feedback_message='".$feedback_message."' where feedback_id='".$feedback_id."'";
- $result=mysql_query($update);
- $sql111="select * from tbl_feedback where feedback_id='".$feedback_id."'";
- $record=$this->conn->getData($sql111);
- $post=array('status'=>'true','message'=>'Comentários atualizados com sucesso','$feedback_id'=>$feedback_id,'feedback_name'=>$record[0]['feedback_name'],'feedback_email'=>$record[0]['feedback_email'],'feedback_subject'=>$record[0]['feedback_subject'],'feedback_message'=>$record[0]['feedback_message']);
- }else{
- $post=array('status'=>'flase','message'=>No_Record_Found);
- }
- echo json_encode($post);
- }else{
- $post = array('status' => "Failed", "message" => Missing_parameter, 'feedback_id' => $_POST['feedback_id']);
- // $this->response($this->json($error), 400);
- echo json_encode($post);
- }
- }
- function add_feedback()
- {
- if(!empty($_REQUEST['feedback_name']) && !empty($_REQUEST['feedback_email'])&& !empty($_REQUEST['feedback_subject'])&& !empty($_REQUEST['feedback_message'])) // service provider category_id
- {
- $feedback_name = $_REQUEST['feedback_name'];
- $feedback_email = $_REQUEST['feedback_email'];
- $feedback_subject = $_REQUEST['feedback_subject'];
- $feedback_message = $_REQUEST['feedback_message'];
- $insert = $this -> conn -> insertnewrecords('tbl_feedback', 'feedback_name,feedback_email,feedback_subject,feedback_message', '"' . $feedback_name . '","' . $feedback_email . '","' . $feedback_subject . '","' . $feedback_message . '"');
- if ($insert > 0)
- {
- $post = array("status" => "true", "message" => Feedback_sent_successfully,'feedback_name' => $feedback_name,'feedback_email' => $feedback_email,'feedback_subject' => $feedback_subject, 'feedback_message' => $feedback_message);
- echo $this -> json($post);
- }
- else
- {
- $post = array("status" => "false", "message" => 'O feedback falhou');
- echo $this -> json($post);
- }
- }
- else
- {
- $error=array('status' => "Failed", "message" => Missing_Parameter, 'feedback_name' => $_REQUEST['feedback_name'], 'feedback_email' => $_REQUEST['feedback_email'], 'feedback_subject' => $_REQUEST['feedback_subject'], 'feedback_message' => $_REQUEST['feedback_message']);
- echo $this -> json($error);
- }
- }
- function email_verification2($user_email){
- $path = 'http://'.$_SERVER['HTTP_HOST'].'/Recharge/email_verify/';
- $path1='http://'.$_SERVER['HTTP_HOST'].'/Recharge/webassets/images/logo.png';
- $subject = 'Email verification link';
- $mail_msg .= '
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body bgcolor="#f1f1f1">
- <table cellpadding="0" cellspacing="0" width="600" style="background:#fff; border:1px solid #cbcbcb; margin:0 auto; font-family:Arial, Helvetica, sans-serif; font-size:12px;">
- <thead class="header">
- <tr>
- <td style="background:#fff; height:62px; width:100%; padding:5px; border-bottom:1px solid #DDD;" valign="middle">
- <a href="#" style="margin-left:10px;"><img width="100" src="'.$path1.'" alt="..."/></a>
- </td>
- </tr>
- </thead>
- <tbody style=" border-bottom:1px solid #ddd;">
- <tr>
- <td style="padding:10px 15px;">
- <h1 style="margin-bottom:0px; color:#5BBE4F;">Dear ' . ucfirst($user_email) . '</h1>
- Thank you for registering with Us. Before we can activate your account one last step must be taken to complete your registration!<br/><br/>
- Please note - you must complete this last step to become a registered member. You will only need to click on the link once, and your account will be updated.<br/>
- To complete your registration, click on the link below:<br/><br/>
- <div style="padding:20px; background-color: #70a93c; color:#fff; text-align:center;">
- <a href=' . $path . "verify_email.php?email=" . base64_encode($user_email) . '>Please click here activate your accout</a>
- </div>
- Price
- </td>
- </tr>
- <tr>
- <td style="padding:10px 15px;"></td>
- </tr>
- <tr>
- <td style="background:#ddd; height:1px; width:100%;"></td>
- </tr>
- </tbody>
- <tfoot style="background:#fff; text-align:center; color:#333;">
- <tr>
- <td style="color:#666;">
- <p>Copyright © 2015 Your plate All right reserved - site by Ypsilon It Solution</p>
- </td>
- <tr>
- </tfoot>
- </table>
- </body>
- </html>
- ';
- $headers = "Organization: OyaCharge\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
- $headers .= "X-Priority: 3\r\n";
- $headers .= "X-Mailer: PHP" . phpversion() . "\r\n";
- $header = "From:blm.ypsilon@gmail.com \r\n";
- $header .= "Cc:blm.ypsilon@gmail.com \r\n";
- $header .= "MIME-Version: 1.0\r\n";
- $header .= "Content-type: text/html\r\n";
- $this->sendElasticEmail($user_email, $subject, "OyaCharge", $mail_msg, "care@oyacharge.com", "OyaCharge");
- }
- function signup2() {
- if(
- !empty($_REQUEST['user_name']) &&
- !empty($_REQUEST['user_email']) &&
- !empty($_REQUEST['user_mobile']) &&
- !empty($_REQUEST['user_pass']) &&
- !empty($_REQUEST['user_city']) &&
- !empty($_REQUEST['user_state']) &&
- !empty($_REQUEST['user_device_type'])&&
- // !empty($_REQUEST['user_device_token']) &&
- !empty($_REQUEST['user_device_id'])
- ){
- $user_name = $_REQUEST['user_name'];
- $user_email = $_REQUEST['user_email'];
- $user_mobile = $_REQUEST['user_mobile'];
- $password = md5($_REQUEST['user_pass']);
- $user_city = $_REQUEST['user_city'];
- $user_state = $_REQUEST['user_state'];
- $device_type = $_REQUEST['user_device_type'];
- // $device_token = $_REQUEST['user_device_token'];
- $device_id = $_REQUEST['user_device_id'];
- $user_type = $_REQUEST['user_type'];
- $current_date = date("Y-m-d h:i:s");
- $email_records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
- if (!empty($email_records)){
- $post = array(
- "status" => "false",
- "message" => "Este e-mail já está registado",
- "email" => $user_email
- );
- echo $this -> json($post);
- exit();
- } else {
- $user_image = '';
- if ($_FILES['user_img']['name']) {
- $user_image = $_FILES['user_img']['name'];
- }
- $attachment = $_FILES['user_img']['name'];
- if (!empty($attachment)) {
- $file_extension = explode(".", $_FILES["user_img"]["name"]);
- $new_extension = strtolower(end($file_extension));
- $today = time();
- $custom_name = "user_img" . $today;
- $file_name = $custom_name . "." . $new_extension;
- if (
- $new_extension == 'png' ||
- $new_extension == 'jpeg' ||
- $new_extension == 'jpg' ||
- $new_extension == 'bmp')
- {
- move_uploaded_file($_FILES['user_img']['tmp_name'], "../uploads/user/" . $file_name);
- }
- }
- if (!empty($file_name)) {
- $user_profile_pic = $file_name;
- } else{
- $user_profile_pic = '';
- }
- if($user_type==1){
- //print_r('here');
- $insert = $this -> conn -> insertnewrecords(
- 'tbl_user',
- 'user_name,
- user_email,
- user_phone,
- user_state,
- user_city,
- user_password,
- user_login_type,
- user_device_type,
- user_device_id,
- user_created_date,
- user_profile_pic,
- user_type',
- '"' . $user_name . '",
- "' . $user_email . '",
- "' . $user_mobile . '",
- "' . $user_state . '",
- "' . $user_city . '",
- "' . $password . '",
- "1",
- "' . $device_type . '",
- "' . $device_id . '",
- "' . $current_date . '",
- "' . $user_profile_pic . '",
- "' . $user_type . '"'
- // user_device_token,
- // "' . $device_token . '",
- );
- //print_r($insert); die();
- } else {
- $insert = $this -> conn -> insertnewrecords(
- 'tbl_user',
- 'user_name,
- user_email,
- user_phone,
- user_state,
- user_city,
- user_password,
- user_login_type,
- user_device_type,
- user_device_id,
- user_created_date,
- user_profile_pic,
- user_type,
- verified_status',
- '"' . $user_name . '",
- "' . $user_email . '",
- "' . $user_mobile . '",
- "' . $user_state . '",
- "' . $user_city . '",
- "' . $password . '",
- "1",
- "' . $device_type . '",
- "' . $device_id . '",
- "' . $current_date . '",
- "' . $user_profile_pic . '",
- "' . $user_type . '",
- "' . 2 . '"'
- // user_device_token,
- // "' . $device_token . '",
- );
- }
- //print_r($insert); die();
- if ($insert > 0) {
- $to = $user_email;
- $subject = "Bem vindo ao Buscars";
- $txt='
- <html>
- <head>
- <title> Cadastro bem sucedido!</title>
- </head>
- <body style="" >
- <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc; border-top-left-radius: 18px; border-top-right-radius:18px; font-family:"Ubuntu",sans-serif !important; font-family:"Ubuntu",sans-serif!important;">
- <tr>
- <td style="color:#ff6600;font-size:30px;font-weight:600;padding:36px 0;text-align:center; background-image:url('.user_images.'bg.jpg); background-repeat:no-repeat; border-top-left-radius: 15px; border-top-right-radius:15px; overflow:hidden;">
- Cadastro bem sucedido
- </td>
- </tr>
- <tr>
- <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
- Bem vindo ao Buscars<br />
- O carro zero na palma da sua mão!
- </td>
- </tr>
- <tr>
- <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
- Qualquer dúvida entre em contato com nossa equipe no <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
- </td>
- </tr>
- <tr >
- <td style="text-align:center; padding:15px;">
- <img width="150" src="'.user_images.'logo1.png" />
- </td>
- </tr>
- </table>
- </body>
- </html>
- ';
- // $headers = "MIME-Version: 1.0" . "\r\n";
- // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
- // // More headers
- // $headers .= 'From: "Buscar" <app@buscarsbr.com.brzz>' . "\r\n";
- // $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
- $this->smtp_mail($to, $subject,"Buscar", $txt, " emerson@dopcomunicacao.com.br", "BusCar assinatura");
- // mail($to,$subject,$txt,$headers);
- $post = array(
- "status" => "true",
- "message" => Signup_successfully,
- 'user_id' => $insert,
- 'user_name' => $user_name,
- 'user_email' => $user_email,
- 'user_city' => $user_city,
- 'user_pic'=> user_images.$file_name,
- 'user_type'=> $user_type,
- 'verified_status'=>'2'
- );
- echo $this -> json($post);
- }
- }
- } else {
- $error = array(
- 'status' => "Failed",
- "message" => Missing_Parameter,
- 'user_name' => $_REQUEST['user_name'],
- 'user_email' => $_REQUEST['user_email'],
- 'user_mobile' => $_REQUEST['user_mobile'],
- 'user_pass' => $_REQUEST['user_pass'],
- 'user_city' => $_REQUEST['user_city'],
- 'user_state' => $_REQUEST['user_state'],
- 'user_device_type' => $_REQUEST['user_device_type'],
- // 'user_device_token' => $_REQUEST['user_device_token'],
- 'user_device_id' => $_REQUEST['user_device_id']
- );
- }
- echo $this -> json($error);
- }
- private function json($data){
- if(is_array($data)){
- return json_encode($data);
- }
- }
- }
- // Initiiate Library
- $api = new API;
- $api->processApi();
- ?>
Add Comment
Please, Sign In to add comment