Guest User

Untitled

a guest
Mar 13th, 2019
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 136.53 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 1);
  4.  
  5. header("Access-Control-Allow-Origin: *");
  6. require_once("Rest.php");
  7. include_once 'db.php';
  8.  
  9. class API extends REST {
  10.  
  11. public $data = "";
  12.  
  13. const DB_SERVER = "localhost";
  14. const DB_USER = "root";
  15. const DB_PASSWORD = "root";
  16. const DB = "buscars";
  17.  
  18. private $db = NULL;
  19. private $mysqli = NULL;
  20. private $conn;
  21.  
  22. public function __construct(){
  23. parent::__construct(); // Iniciar parent contructor
  24. $this->dbConnect(); // Iniciar Database connection
  25. $this -> conn = new DB; // Carregar arquivo DB
  26.  
  27. $base_url=$_SERVER['SERVER_NAME'];
  28. define('car_images',$base_url."/uploads/cars/");
  29. define('brand_images',$base_url."/uploads/brands/");
  30. define('carType_images',$base_url."/uploads/carType/");
  31. define('user_images',$base_url."/uploads/user/");
  32.  
  33. // ================================================================== //
  34.  
  35. define('Login_successfully',html_entity_decode('Login com sucesso'));
  36. define('Missing_Parameter',html_entity_decode('Parâmetro ausente'));
  37. define('Error_in_Update_service_provider_details',html_entity_decode('Erro nos detalhes do provedor de serviço de atualização'));
  38. define('Invalid_ID_Pass',html_entity_decode('ID ou senha de email inválida'));
  39. define('Error_in_Add_service_provider',html_entity_decode('Erro em Adicionar provedor de serviços'));
  40. define('Error_in_Add_service_provider',html_entity_decode('Erro em Adicionar provedor de serviços'));
  41. 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'));
  42. define('Car_Model_List',html_entity_decode('Lista de modelos de carros'));
  43. define('No_Services',html_entity_decode('Atualmente você não está registrado para nenhum serviço'));
  44. define('Car_Details_Get_Successfully',html_entity_decode('Detalhes do carro obtêm sucesso'));
  45. define('Internal_server_error',html_entity_decode('Erro do Servidor Interno'));
  46. define('Subscription_plan_activated_successfully',html_entity_decode('Plano de assinatura ativado com sucesso,Verifique seu e-mail para detalhes'));
  47. define('Brand_List',html_entity_decode('Lista de marcas'));
  48. define('Signup_successfully',html_entity_decode('“Cadastro efetuado com sucesso!'));
  49. define('Inactive_account',html_entity_decode('Conta Inativa pelo administrador, entre em contato com Admin'));
  50. define("No_CAR_FOUND",html_entity_decode('Nenhum carro encontrado neste critério'));
  51. define("Car_Details_get_successfully",html_entity_decode('Detalhes do carro obtêm sucesso'));
  52. define('NoCarModalFound',html_entity_decode('Não foi encontrado nenhum modelo de carro'));
  53. define('Car_found',html_entity_decode('carros encontrados'));
  54. define('Service_provider_found',html_entity_decode('Provedor de serviços encontrado'));
  55. define('No_Service_Provider_Found',html_entity_decode('Nenhum fornecedor de serviços encontrado'));
  56. define('Request_sent_successfully',html_entity_decode('Pedido enviado com sucesso'));
  57. define('add_interest',html_entity_decode('Interesse enviado com sucesso!'));
  58. define('remove_interest',html_entity_decode('Interesse enviado com sucesso!'));
  59. define('add_favourite',html_entity_decode('Adicionado com sucesso'));
  60. define('remove_favourite',html_entity_decode('remover favorito com sucesso'));
  61. define('remove_favourite',html_entity_decode('remover favorito com sucesso'));
  62. define('Please_wait_for_admin_approval',html_entity_decode('Aguarde a aprovação do administrador'));
  63. define('Feedback_sent_successfully',html_entity_decode('Feedback enviado com sucesso'));
  64. define('Service_Provider_Details',html_entity_decode('Detalhes do fornecedor de serviços'));
  65. define('Admin_Service_Provider_Details',html_entity_decode('Aguarde a aprovação do administrador'));
  66. define('Error_in_Add_service_provider_details',html_entity_decode('Erro em Adicionar detalhes do fornecedor de serviços'));
  67. define('Api_key','AIzaSyDpLWwS0Q25KLcqQuavhiH3y__xHiLLjrQ');
  68. define('Profile_updated_successfully',html_entity_decode('Perfil atualizado com sucesso'));
  69. 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.'));
  70. define('You_need_to_signup_first',html_entity_decode('Voce precisa se inscrever primeiro'));
  71. define('No_Record_Found',html_entity_decode('Nenhum Registro Encontrado'));
  72. define('Your_account_is_inactivated_by_admin',html_entity_decode('Sua conta está inativada pelo administrador'));
  73.  
  74. // ================================================================== //
  75. }
  76.  
  77. /*
  78. * Connect to Database
  79. */
  80. private function dbConnect(){
  81. $this->mysqli = new mysqli(self::DB_SERVER, self::DB_USER, self::DB_PASSWORD, self::DB);
  82. }
  83.  
  84. /*
  85. * Dynmically call the method based on the query string
  86. */
  87.  
  88. public function processApi(){
  89. $func = strtolower(trim(str_replace("/","",$_REQUEST['x'])));
  90. if((int)method_exists($this,$func) > 0)
  91. $this->$func();
  92. else
  93. $this->response('',404); // If the method not exist with in this class "Page not found".
  94. }
  95.  
  96. public function service_provider(){
  97. return true;
  98. }
  99.  
  100.  
  101.  
  102. //faz login do usuario
  103. private function user_login(){
  104. if($this->get_request_method() != "POST"){
  105. $this->response('',406);
  106. }
  107.  
  108. $user_email = $_REQUEST['user_email'];
  109. $user_pass = $_REQUEST['user_pass'];
  110. $user_device_type = $_REQUEST['user_device_type'];
  111.  
  112.  
  113. if (!empty($user_email) and !empty($user_pass)) {
  114. if(filter_var($user_email, FILTER_VALIDATE_EMAIL)){
  115. $sql="
  116. SELECT *
  117. FROM tbl_user
  118. LEFT JOIN tbl_state
  119. ON tbl_state.state_id='tbl_user.user_state'
  120. LEFT JOIN tbl_city
  121. ON tbl_city.city_id='tbl_user.user_city'
  122. WHERE tbl_user.user_email='$user_email'
  123. AND user_password = '".md5($user_pass)."'"
  124. ;
  125.  
  126. $records_user = $this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
  127. $result = $records_user->fetch_assoc();
  128.  
  129.  
  130. if (!empty($result)) {
  131. $user_status = $result['user_status'];
  132. $verified_status = $result['verified_status'];
  133.  
  134. if($verified_status==1){
  135. if($user_status ==1){
  136. $user_id = $result['user_id'];
  137. $city_id = $result['user_city'];
  138. $city_name = $result['city_name'];
  139. $city_name = html_entity_decode($city_name);
  140. $state_name = $result['state_name'];
  141. $state_name = html_entity_decode($state_name);
  142. $state_id = $result['user_state'];
  143. $user_login_type = $result['user_login_type'];
  144. // $city_name = $records_user[0]['city_name'];
  145. // $state_name = $records_user[0]['state_name'];
  146.  
  147. $data['user_device_type'] = $user_device_type;
  148. // $data['user_device_token'] = $user_device_token;
  149. // $data['user_device_id'] = $user_device_id;
  150. // $data['user_city'] = $user_city;
  151. // $data['user_state'] = $user_state;
  152.  
  153. if(!empty($result['user_profile_pic'])){
  154. $pic=user_images.$result['user_profile_pic'];
  155. } else {
  156. $pic='';
  157. }
  158.  
  159. $update_token = $this->conn->updatetablebyid('tbl_user', 'user_id', $user_id, $data);
  160. $post = array(
  161. "status" => "true",
  162. "message" =>Login_successfully,
  163. 'user_id'=>$user_id,
  164. 'user_name'=>$result['user_name'],
  165. 'user_email'=>$result['user_email'],
  166. 'user_phone'=>$result['user_phone'],
  167. 'user_profile_pic'=>$pic,
  168. 'user_type'=>$result['user_type'],
  169. 'verified_status'=>$result['verified_status'],
  170. 'city_id'=>$city_id,
  171. 'city_name'=>$city_name,
  172. 'state_id'=>$state_id,
  173. 'state_name'=>$state_name,
  174. 'user_password'=>$user_pass,
  175. 'user_login_type'=>$user_login_type
  176. );
  177. } else {
  178. $post = array("status" => "false", "message" => Your_account_is_inactivated_by_admin );
  179. }
  180. } else {
  181. $post = array("status" => "false", "message" => Please_wait_for_admin_approval );
  182. }
  183. } else {
  184. $post = array("status" => "false", "message" => Invalid_ID_Pass);
  185. }
  186. }
  187. } else{
  188. $post = array(
  189. "status" => "false",
  190. "message" => Missing_Parameter,
  191. 'user_email' => $user_email,
  192. 'user_pass' => $user_pass
  193. );
  194. }
  195. echo $this->response($this->json($post), 200);
  196. }
  197.  
  198. function email_verification($user_email){
  199. $path = 'http://'.$_SERVER['HTTP_HOST'].'/Recharge/email_verify/';
  200. $path1='http://'.$_SERVER['HTTP_HOST'].'/Recharge/webassets/images/logo.png';
  201. $subject = 'Email verification link';
  202. $mail_msg .= '
  203. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  204. <html xmlns="http://www.w3.org/1999/xhtml">
  205. <head>
  206. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  207. <title>Untitled Document</title>
  208. </head>
  209.  
  210. <body bgcolor="#f1f1f1">
  211. <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;">
  212. <thead class="header">
  213. <tr>
  214. <td style="background:#fff; height:62px; width:100%; padding:5px; border-bottom:1px solid #DDD;" valign="middle">
  215. <a href="#" style="margin-left:10px;"><img width="100" src="'.$path1.'" alt="..."/></a>
  216. </td>
  217. </tr>
  218. </thead>
  219. <tbody style=" border-bottom:1px solid #ddd;">
  220. <tr>
  221. <td style="padding:10px 15px;">
  222. <h1 style="margin-bottom:0px; color:#5BBE4F;">Dear ' . ucfirst($user_email) . '</h1>
  223. Thank you for registering with Us. Before we can activate your account one last step must be taken to complete your registration!<br/><br/>
  224. 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/>
  225. To complete your registration, click on the link below:<br/><br/>
  226. <div style="padding:20px; background-color: #70a93c; color:#fff; text-align:center;">
  227. <a href=' . $path . "verify_email.php?email=" . base64_encode($user_email) . '>Please click here activate your accout</a>
  228. </div>
  229. Price
  230. </td>
  231. </tr>
  232. <tr>
  233. <td style="padding:10px 15px;"></td>
  234. </tr>
  235. <tr>
  236. <td style="background:#ddd; height:1px; width:100%;"></td>
  237. </tr>
  238. </tbody>
  239.  
  240. <tfoot style="background:#fff; text-align:center; color:#333;">
  241. <tr>
  242. <td style="color:#666;">
  243. <p>Copyright © 2015 Your plate All right reserved - site by Ypsilon It Solution</p>
  244. </td>
  245. <tr>
  246. </tfoot>
  247. </table>
  248. </body>
  249. </html>
  250. ';
  251.  
  252. $headers = "Organization: OyaCharge\r\n";
  253. $headers .= "MIME-Version: 1.0\r\n";
  254. $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  255. $headers .= "X-Priority: 3\r\n";
  256. $headers .= "X-Mailer: PHP" . phpversion() . "\r\n";
  257. $header = "From:blm.ypsilon@gmail.com \r\n";
  258. $header .= "Cc:blm.ypsilon@gmail.com \r\n";
  259. $header .= "MIME-Version: 1.0\r\n";
  260. $header .= "Content-type: text/html\r\n";
  261. $this->sendElasticEmail($user_email, $subject, "OyaCharge", $mail_msg, "care@oyacharge.com", "OyaCharge");
  262. }
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. //envia um email depois de cadastrar o usuario
  272. function emailBoasVindas(){
  273. $email = "webv3@hotmail.com";
  274. $subject = "Bem vindo ao Buscars";
  275.  
  276. $headers = 'From: webmaster@example.com' . "\r\n" .
  277. 'Reply-To: webmaster@example.com' . "\r\n" .
  278. 'X-Mailer: PHP/' . phpversion();
  279.  
  280. $txt='
  281. <html>
  282. <head>
  283. <title> Cadastro bem sucedido!</title>
  284. </head>
  285.  
  286. <body style="" >
  287. <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;">
  288.  
  289. <tr>
  290. <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;">
  291. Cadastro bem sucedido
  292. </td>
  293. </tr>
  294. <tr>
  295. <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
  296. Bem vindo ao Buscars<br />
  297. O carro zero na palma da sua mão!
  298. </td>
  299. </tr>
  300. <tr>
  301. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  302. Qualquer dúvida entre em contato com nossa equipe no <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
  303. </td>
  304. </tr>
  305. <tr >
  306. <td style="text-align:center; padding:15px;">
  307. <img width="150" src="'.user_images.'logo1.png" />
  308. </td>
  309. </tr>
  310. </table>
  311. </body>
  312. </html>
  313. ';
  314.  
  315. mail($email, $subject, $txt, $headers);
  316. }
  317.  
  318.  
  319.  
  320.  
  321. //registra o usuario
  322. function registrarUsuario(){
  323.  
  324. if(
  325. !empty($_REQUEST['user_name']) &&
  326. !empty($_REQUEST['user_email']) &&
  327. !empty($_REQUEST['user_phone']) &&
  328. !empty($_REQUEST['user_password']) &&
  329. !empty($_REQUEST['user_city']) &&
  330. !empty($_REQUEST['user_state'])
  331. ){
  332. $user_name = $_REQUEST['user_name'];
  333. $user_email = $_REQUEST['user_email'];
  334. $user_phone = $_REQUEST['user_phone'];
  335. $user_password = md5($_REQUEST['user_password']);
  336. $user_city = $_REQUEST['user_city'];
  337. $user_state = $_REQUEST['user_state'];
  338. $current_date = date("Y-m-d h:i:s");
  339. //$email_records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
  340.  
  341. //verifica se ja existe um usuario com esse email registrado
  342. $sql = "SELECT * FROM tbl_user WHERE user_email= '".$user_email."'";
  343.  
  344. $email_existente = $this->mysqli->query($sql);
  345. $email_existente = $email_existente->num_rows;
  346.  
  347.  
  348.  
  349. //caso nao exista nenhum registro com esse email
  350. if( $email_existente == 0 ){
  351. $fields = "user_name, user_email, user_phone, user_state, user_city, user_password, user_login_type, user_created_date";
  352. $values = "'$user_name', '$user_email', '$user_phone', '$user_state', '$user_city', '$user_password', '1', '$current_date'";
  353. $query = "INSERT INTO tbl_user($fields) VALUES($values)";
  354.  
  355.  
  356. $query = $this->mysqli->query($query);
  357. if( $query ){
  358. $res = array(
  359. "status" => true,
  360. "message" => "Usuario registrado com sucesso!"
  361. );
  362.  
  363. //envia email de boas findas
  364. //$this->emailBoasVindas($user_email);
  365.  
  366. echo json_encode($res);
  367. exit;
  368. }
  369. }else{
  370. $res = array(
  371. "status" => false,
  372. "message" => "Este e-mail já está registado"
  373. );
  374. echo json_encode($res);
  375. exit;
  376. }
  377. }else{
  378. $res = array(
  379. 'status' => false,
  380. "message" => "Faltando parametro",
  381. 'user_name' => $_REQUEST['user_name'],
  382. 'user_email' => $_REQUEST['user_email'],
  383. 'user_phone' => $_REQUEST['user_phone'],
  384. 'user_password' => $_REQUEST['user_password'],
  385. 'user_city' => $_REQUEST['user_city'],
  386. 'user_state' => $_REQUEST['user_state']
  387. );
  388. echo json_encode($res);
  389. exit;
  390. }
  391.  
  392. }
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. function signup() {
  401. if(
  402. !empty($_REQUEST['user_name']) &&
  403. !empty($_REQUEST['user_email']) &&
  404. !empty($_REQUEST['user_mobile']) &&
  405. !empty($_REQUEST['user_pass']) &&
  406. !empty($_REQUEST['user_city']) &&
  407. !empty($_REQUEST['user_state']) &&
  408. !empty($_REQUEST['user_device_type'])&&
  409. // !empty($_REQUEST['user_device_token']) &&
  410. !empty($_REQUEST['user_device_id'])
  411. ){
  412.  
  413. $user_name = $_REQUEST['user_name'];
  414. $user_email = $_REQUEST['user_email'];
  415. $user_mobile = $_REQUEST['user_mobile'];
  416. $password = md5($_REQUEST['user_pass']);
  417. $user_city = $_REQUEST['user_city'];
  418. $user_state = $_REQUEST['user_state'];
  419. $device_type = $_REQUEST['user_device_type'];
  420. // $device_token = $_REQUEST['user_device_token'];
  421. $device_id = $_REQUEST['user_device_id'];
  422. $user_type = $_REQUEST['user_type'];
  423. $current_date = date("Y-m-d h:i:s");
  424. $email_records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
  425.  
  426. if (!empty($email_records)){
  427. $post = array(
  428. "status" => "false",
  429. "message" => "Este e-mail já está registado",
  430. "email" => $user_email
  431. );
  432. echo $this -> json($post);
  433. exit();
  434. } else {
  435. $user_image = '';
  436. if ($_FILES['user_img']['name']) {
  437. $user_image = $_FILES['user_img']['name'];
  438. }
  439.  
  440. $attachment = $_FILES['user_img']['name'];
  441.  
  442. if (!empty($attachment)) {
  443. $file_extension = explode(".", $_FILES["user_img"]["name"]);
  444. $new_extension = strtolower(end($file_extension));
  445. $today = time();
  446. $custom_name = "user_img" . $today;
  447. $file_name = $custom_name . "." . $new_extension;
  448.  
  449. if (
  450. $new_extension == 'png' ||
  451. $new_extension == 'jpeg' ||
  452. $new_extension == 'jpg' ||
  453. $new_extension == 'bmp')
  454. {
  455. move_uploaded_file($_FILES['user_img']['tmp_name'], "../uploads/user/" . $file_name);
  456.  
  457. }
  458. }
  459.  
  460. if (!empty($file_name)) {
  461. $user_profile_pic = $file_name;
  462. } else{
  463. $user_profile_pic = '';
  464. }
  465.  
  466. if($user_type==1){
  467. //print_r('here');
  468.  
  469. $insert = $this -> conn -> insertnewrecords(
  470. 'tbl_user',
  471. 'user_name,
  472. user_email,
  473. user_phone,
  474. user_state,
  475. user_city,
  476. user_password,
  477. user_login_type,
  478. user_device_type,
  479. user_device_id,
  480. user_created_date,
  481. user_profile_pic,
  482. user_type',
  483. '"' . $user_name . '",
  484. "' . $user_email . '",
  485. "' . $user_mobile . '",
  486. "' . $user_state . '",
  487. "' . $user_city . '",
  488. "' . $password . '",
  489. "1",
  490. "' . $device_type . '",
  491. "' . $device_id . '",
  492. "' . $current_date . '",
  493. "' . $user_profile_pic . '",
  494. "' . $user_type . '"'
  495.  
  496. // user_device_token,
  497. // "' . $device_token . '",
  498. );
  499.  
  500. //print_r($insert); die();
  501.  
  502. } else {
  503. $insert = $this -> conn -> insertnewrecords(
  504. 'tbl_user',
  505. 'user_name,
  506. user_email,
  507. user_phone,
  508. user_state,
  509. user_city,
  510. user_password,
  511. user_login_type,
  512. user_device_type,
  513. user_device_id,
  514. user_created_date,
  515. user_profile_pic,
  516. user_type,
  517. verified_status',
  518. '"' . $user_name . '",
  519. "' . $user_email . '",
  520. "' . $user_mobile . '",
  521. "' . $user_state . '",
  522. "' . $user_city . '",
  523. "' . $password . '",
  524. "1",
  525. "' . $device_type . '",
  526. "' . $device_id . '",
  527. "' . $current_date . '",
  528. "' . $user_profile_pic . '",
  529. "' . $user_type . '",
  530. "' . 2 . '"'
  531. // user_device_token,
  532. // "' . $device_token . '",
  533. );
  534. }
  535.  
  536. //print_r($insert); die();
  537.  
  538. if ($insert > 0) {
  539. $to = $user_email;
  540. $subject = "Bem vindo ao Buscars";
  541. $txt='
  542. <html>
  543. <head>
  544. <title> Cadastro bem sucedido!</title>
  545. </head>
  546.  
  547. <body style="" >
  548. <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;">
  549.  
  550. <tr>
  551. <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;">
  552. Cadastro bem sucedido
  553. </td>
  554. </tr>
  555. <tr>
  556. <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
  557. Bem vindo ao Buscars<br />
  558. O carro zero na palma da sua mão!
  559. </td>
  560. </tr>
  561. <tr>
  562. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  563. Qualquer dúvida entre em contato com nossa equipe no <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
  564. </td>
  565. </tr>
  566. <tr >
  567. <td style="text-align:center; padding:15px;">
  568. <img width="150" src="'.user_images.'logo1.png" />
  569. </td>
  570. </tr>
  571. </table>
  572. </body>
  573. </html>
  574. ';
  575.  
  576.  
  577. // $headers = "MIME-Version: 1.0" . "\r\n";
  578. // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  579. // // More headers
  580. // $headers .= 'From: "Buscar" <app@buscarsbr.com.brzz>' . "\r\n";
  581.  
  582. // $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
  583. $this->smtp_mail($to, $subject,"Buscar", $txt, " emerson@dopcomunicacao.com.br", "BusCar assinatura");
  584.  
  585. // mail($to,$subject,$txt,$headers);
  586.  
  587. $post = array(
  588. "status" => "true",
  589. "message" => Signup_successfully,
  590. 'user_id' => $insert,
  591. 'user_name' => $user_name,
  592. 'user_email' => $user_email,
  593. 'user_city' => $user_city,
  594. 'user_pic'=> user_images.$file_name,
  595. 'user_type'=> $user_type,
  596. 'verified_status'=>'2'
  597. );
  598.  
  599. echo $this -> json($post);
  600. }
  601. }
  602. } else {
  603. $error = array(
  604. 'status' => "Failed",
  605. "message" => Missing_Parameter,
  606. 'user_name' => $_REQUEST['user_name'],
  607. 'user_email' => $_REQUEST['user_email'],
  608. 'user_mobile' => $_REQUEST['user_mobile'],
  609. 'user_pass' => $_REQUEST['user_pass'],
  610. 'user_city' => $_REQUEST['user_city'],
  611. 'user_state' => $_REQUEST['user_state'],
  612. 'user_device_type' => $_REQUEST['user_device_type'],
  613. // 'user_device_token' => $_REQUEST['user_device_token'],
  614. 'user_device_id' => $_REQUEST['user_device_id']
  615. );
  616. }
  617.  
  618. echo $this -> json($error);
  619. }
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627. //Metodo que faz UPDATE dos dados do usuario
  628. //e faz upload de imagem de perfil
  629. function update() {
  630.  
  631. if(empty($_REQUEST['user_id'])){
  632. $post = array(
  633. 'status' => "Failed",
  634. "message" => "Parametro user_id nao encontrado",
  635. 'user_id' => $_POST['user_id']
  636. );
  637. // $this->response($this->json($error), 400);
  638. echo json_encode($post);
  639. exit;
  640. }
  641.  
  642. $user_id = $_REQUEST['user_id'];
  643. $user_name = $_REQUEST['user_name'];
  644. $user_email = $_REQUEST['user_email'];
  645. $user_mobile = $_REQUEST['user_phone'];
  646. $user_city = $_REQUEST['user_city'];
  647. $user_state = $_REQUEST['user_state'];
  648. $storage_image = $_REQUEST['storage_image'];
  649. $user_password = md5($_REQUEST['user_password']);
  650. $data_response = json_encode($_REQUEST);
  651.  
  652.  
  653. $sql="select * from tbl_user where user_id='".$user_id."'";
  654. //se encontrar algum registro com o id de usuario passado por parametro
  655. $usuario_encontrado = 0;
  656. //resultado do select de usuario com id passado
  657. $queryResult = false;
  658.  
  659. if ($this->mysqli->connect_errno) {
  660. $err = array(
  661. "status" => "false",
  662. "message" => "Erro conexão $this->mysqli->connect_error"
  663. );
  664. echo $this->json($err);
  665. exit;
  666. }else{
  667. $queryResult = $this->mysqli->query($sql);
  668. if ( $queryResult ) {
  669. $usuario_encontrado = $result->num_rows;
  670. }else{
  671. printf("Connect failed: %s\n", $this->mysqli->connect_error);
  672. exit;
  673. }
  674. }
  675.  
  676.  
  677. if( $usuario_encontrado ){
  678. $result=mysql_fetch_array($queryResult);
  679.  
  680.  
  681. //valida se email existe ja em outro usuario
  682. $query="select * from tbl_user where user_email='".$user_email."' and user_id !='".$user_id."'";
  683. $record=$this->conn->getData($query);
  684. if(!empty($record)){
  685. $post= array(
  686. "status" => "false",
  687. "message" => "Este e-mail já está registado",
  688. 'email' => $user_email
  689. );
  690. echo $this->json($post);
  691. exit();
  692. }
  693. }
  694.  
  695.  
  696.  
  697. //upload da imagem
  698. $attachment = $_FILES['user_img']['name'];
  699. if (!empty($attachment)) {
  700. $file_extension = explode(".", $_FILES["user_img"]["name"]);
  701. $file_extension = strtolower(end($file_extension));
  702.  
  703. $today = time();
  704. $custom_name = "user_img" . $today;
  705. $file_name = $custom_name . "." . $file_extension;
  706.  
  707. if (
  708. strtolower($file_extension) == 'png' ||
  709. strtolower($file_extension) == 'jpeg' ||
  710. strtolower($file_extension) == 'jpg' ||
  711. strtolower($file_extension) == 'bmp'
  712. ) {
  713. $uploaded = move_uploaded_file($_FILES['user_img']['tmp_name'], "./upload_images/".$file_name);
  714. $user_profile_pic = $file_name;
  715. }else{
  716. $post= array(
  717. "status" => "false",
  718. "message" => "Formato de imagem nao suportado"
  719. );
  720. echo $this->json($post);
  721. exit;
  722. }
  723. } else{
  724. $user_profile_pic = $storage_image;
  725. }
  726.  
  727.  
  728. //faz o update com os novos dados
  729. $updateSql="
  730. update tbl_user set user_name='".$user_name."',
  731. user_profile_pic='".$user_profile_pic."',
  732. user_email='".$user_email."',
  733. user_phone='".$user_mobile."',
  734. user_city='".$user_city."',
  735. user_state='".$user_state."',
  736. user_password='".$user_password."'
  737. where user_id='".$user_id."'
  738. ";
  739.  
  740. $updateResult = $this->mysqli->query($updateSql);
  741.  
  742. if ( $updateResult ) {
  743. $post= array(
  744. "status" => "true",
  745. "message" => "Dados atualizados!",
  746. "user_profile_pic" => $user_profile_pic
  747. );
  748. echo $this->json($post);
  749. exit;
  750. }else{
  751. printf("Erro ao fazer UPDATE no banco: %s\n", $this->mysqli->connect_error);
  752. exit;
  753. }
  754. }
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763. function social_login() {
  764. $user_email = $_REQUEST['user_email'];
  765. $user_firstname = $_REQUEST['user_firstname'];
  766. $user_lastname = $_REQUEST['user_lastname'];
  767. $user_name = $user_firstname." ".$user_lastname;
  768. $user_social_id = $_REQUEST['user_social_id'];
  769.  
  770.  
  771. //Social ID
  772. $login_type = 2;
  773. // 1-Facebook,2-Google+
  774. // if($login_type=='2'){
  775. // $log_type = 'Facebook'; }else if($login_type=='3') {
  776. // $log_type = 'Google+'; }
  777. $current_date = date("Y-m-d h:i:sa");
  778. $user_device_type = $_REQUEST['user_device_type'];
  779. $user_device_token = $_REQUEST['user_device_token'];
  780. $user_device_id = $_REQUEST['user_device_id'];
  781. $profile_pic = $_REQUEST['user_img'];
  782.  
  783. if (!empty($user_email) && !empty($user_social_id)) {
  784. $records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
  785. $user_id = $records[0]['user_id'];
  786. $user_email = $records[0]['user_email'];
  787. $user_contact_no = $records[0]['user_phone'];
  788. $user_login_type = $records[0]['user_login_type'];
  789. $user_city = $records[0]['user_city'];
  790. $user_state = $records[0]['user_state'];
  791.  
  792.  
  793. if (!empty($user_id)) {
  794. $status = $records[0]['user_status'];
  795. if ($status == '1') {
  796. $data['user_name'] = $user_name;
  797. $data['user_email'] = $user_email;
  798. $data['user_social_id'] = $user_social_id;
  799. $data['user_login_type'] = 2;
  800. $data['user_created_date'] = $current_date;
  801. $data['user_device_type'] = $user_device_type;
  802. $data['user_device_token'] = $user_device_token;
  803. $data['user_device_id'] = $user_device_id;
  804. $data['user_profile_pic'] = $profile_pic;
  805. $data['user_ip_address'] = $_SERVER['REMOTE_ADDR'];
  806.  
  807.  
  808. if(!empty($user_state) && !empty($user_city)) {
  809. $sql111="
  810. SELECT * FROM tbl_user
  811. LEFT join tbl_state on tbl_state.state_id=tbl_user.user_state
  812. LEFT join tbl_city on tbl_city.city_id =tbl_user.user_city
  813. where user_email='".$user_email."'
  814. ";
  815.  
  816. $record=$this->conn->getData($sql111);
  817. $user_state=$record[0]['user_state'];
  818. $user_city=$record[0]['user_city'];
  819. $city_name=html_entity_decode($record[0]['city_name']);
  820. $state_name=html_entity_decode($record[0]['state_name']);
  821. } else {
  822. $user_state="";
  823. $user_city="";
  824. $city_name="";
  825. $state_name="";
  826. }
  827.  
  828.  
  829. $update_toekn = $this -> conn -> updatetablebyid('tbl_user', 'user_id', $user_id, $data);
  830. $sql111="
  831. SELECT * FROM tbl_user
  832. LEFT join tbl_state on tbl_state.state_id=tbl_user.user_state
  833. LEFT join tbl_city on tbl_city.city_id =tbl_user.user_city
  834. where user_id='".$user_id."'
  835. ";
  836.  
  837. $record=$this->conn->getData($sql111);
  838. //$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']);
  839.  
  840. $post = array(
  841. "ResponseCode"=>"200",
  842. "status" => "true",
  843. "message" => Login_successfully,
  844. 'user_id' => $user_id,
  845. 'login_type' => $login_type,
  846. 'user_name' => $user_name,
  847. 'profile_pic' => $profile_pic,
  848. 'user_email' => $user_email,
  849. 'user_phone' =>$user_contact_no,
  850. 'user_login_type'=>$user_login_type,
  851. 'city_id'=>$user_city,
  852. 'city_name'=>$city_name,
  853. 'state_id'=>$user_state,
  854. 'state_name'=>$state_name
  855. );
  856. } else {
  857. $post = array(
  858. "ResponseCode"=>"500",
  859. "status" => "inactive",
  860. "message" => Inactive_account
  861. );
  862. }
  863. } else {
  864. //$reffer_code = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, 6);
  865. $user_email = $_POST['user_email'];
  866. $user_phone = $_POST['user_phone'];
  867. $user_login_type = 2;
  868.  
  869.  
  870. $insert = $this -> conn -> insertnewrecords(
  871. 'tbl_user',
  872. 'user_state,
  873. user_city,
  874. user_name,
  875. user_email,
  876. user_social_id,
  877. user_login_type,
  878. user_created_date,
  879. user_profile_pic,
  880. user_device_type,
  881. user_device_token,
  882. user_device_id,
  883. user_phone',
  884. '26,5341,"'
  885. . $user_name . '","'
  886. . $user_email . '","'
  887. . $user_social_id . '","'
  888. . $user_login_type . '","'
  889. . $current_date . '","'
  890. . $profile_pic . '","'
  891. . $user_device_type . '","'
  892. . $user_device_token . '","'
  893. . $user_device_id . '","'
  894. . $user_phone . '"'
  895. );
  896.  
  897. if ($insert) {
  898. $wallet_amount = 0;
  899. $sql111="select * from tbl_user where user_email='".$user_email."'";
  900. $record=$this->conn->getData($sql111);
  901. $user_state=$record[0]['user_state'];
  902. $user_city=$record[0]['user_state'];
  903.  
  904. if(!empty($user_state) && !empty($user_city)) {
  905. $sql111="
  906. SELECT * FROM tbl_user
  907. LEFT join tbl_state on tbl_state.state_id=tbl_user.user_state
  908. LEFT join tbl_city on tbl_city.city_id =tbl_user.user_city
  909. where user_email='".$user_email."'
  910. ";
  911.  
  912. $record=$this->conn->getData($sql111);
  913. $user_state=$record[0]['user_state'];
  914. $user_city=$record[0]['user_city'];
  915. $city_name=$record[0]['city_name'];
  916. $state_name=$record[0]['state_name'];
  917. } else {
  918. $user_state="";
  919. $user_city="";
  920. $city_name="";
  921. $state_name="";
  922. }
  923.  
  924.  
  925. $post=array(
  926. 'ResponseCode'=>'200',
  927. 'status'=>'true',
  928. 'message'=>Login_successfully,
  929. 'user_id'=>$record[0]['user_id'],
  930. 'user_name'=>$record[0]['user_name'],
  931. 'profile_pic'=>$img,
  932. 'user_phone'=>$record[0]['user_phone'],
  933. 'city_id'=>$user_city,
  934. 'city_name'=>$city_name,
  935. 'state_id'=>$user_state,
  936. 'state_name'=>$state_name,
  937. 'user_email'=>$record[0]['user_email'],
  938. 'verified_status'=>$record[0]['verified_status'],
  939. 'user_type'=>$record[0]['user_type'],
  940. 'user_password'=>$record[0]['user_password'],
  941. 'user_login_type'=>$record[0]['user_login_type']
  942. );
  943. // $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']);
  944. }
  945. }
  946. } else {
  947. $post = array(
  948. 'ResponseCode'=>'500',
  949. 'status' => "Failed",
  950. "message" => Missing_Parameter,
  951. 'user_email' => $user_email,
  952. 'user_social_id' => $user_social_id
  953. );
  954. }
  955. echo $this -> json($post);
  956. }
  957.  
  958. function forgot_passowrd() {
  959. $email = $_REQUEST['email'];
  960. if (!empty($email)) {
  961.  
  962. $records_user = $records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $email);
  963. if (!empty($records_user)) {
  964. $user_id = $records_user[0]['user_id'];
  965. $password = rand(111111111,999999999);
  966. $new_password = md5($password);
  967. $data['user_password'] = $new_password;
  968.  
  969. $update_password = $this -> conn -> updatetablebyid('tbl_user','user_id', $user_id, $data);
  970. $subject = 'Aviso de alteração de senha';
  971. $message .= '
  972. <html>
  973. <head>
  974. <title> Aviso de alteração de senha</title>
  975. </head>
  976. <body style="" >
  977. <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;">
  978. <tr>
  979. <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;">
  980. Aviso de alteração de senha
  981. </td>
  982. </tr>
  983. <tr>
  984. <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
  985. Este aviso confirma que a sua senha foi alterada em Buscars.
  986. </td>
  987. </tr>
  988. <tr>
  989. <td style="text-align:center; font-weight:600; font-size:18px">
  990. <span style="margin-right:15px"> E-mail :</span>
  991. <span> ' .$email.' </span>
  992. </td>
  993. </tr>
  994. <tr>
  995. <td style="text-align:center; font-weight:600; font-size:18px">
  996. <span style="margin-right:15px"> Senha :</span>
  997. <span>'.$password.' </span>
  998. </td>
  999. </tr>
  1000. <tr>
  1001. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  1002. 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>
  1003. </td>
  1004. </tr>
  1005. <tr >
  1006. <td style="text-align:center; padding:15px;"> <img width="150" src="'.user_images.'logo1.png" /> </td>
  1007. </tr>
  1008. </table>
  1009. </body>
  1010. </html>
  1011. ';
  1012.  
  1013. $this->smtp_mail($email, $subject,"Buscar", $message, " app@buscarsbr.com.br", "BusCar");
  1014. $post = array('status' => "true", "message" =>'Nova senha envia para o seu e-mail registrado');
  1015. } else {
  1016. $post = array('status' => "false", "message" => "Email inválido ou celular não");
  1017. }
  1018. echo $this -> json($post);
  1019. } else {
  1020. $post = array('status' => "false", "message" => "invalid parameter");
  1021. echo $this -> json($post);
  1022. }
  1023. }
  1024.  
  1025. function user_profile() {
  1026. header("Content-Type: text/html;charset=utf-8");
  1027. $user_id = $_REQUEST['user_id'];
  1028. if (!empty($user_id)) {
  1029. $records = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
  1030. if (!empty($records)) {
  1031. $user_id = $records['0']['user_id'];
  1032. $user_name = $records['0']['user_name'];
  1033. $user_email = $records['0']['user_email'];
  1034. $user_contact_no = $records['0']['user_contact_no'];
  1035. $login_type = $records['0']['user_login_type'];
  1036. $profile_pic = $records['0']['user_profile_pic'];
  1037. $self_reffer_code = $records['0']['user_refferal_code'];
  1038. $wallet_amount = $records[0]['wallet_amount'];
  1039. $pin_status = $records[0]['user_pin_status'];
  1040. $get_sms = $records['0']['get_sms'];
  1041. $total_sms = $records[0]['total_sms'];
  1042. if (!empty($profile_pic)) {
  1043. if (filter_var($profile_pic, FILTER_VALIDATE_URL)) {
  1044. $img = $profile_pic;
  1045. } else {
  1046. $img = self_img_url . $profile_pic;
  1047. }
  1048. } else {
  1049. $img = '';
  1050. }
  1051. $user_refferal_codel = $records['0']['user_refferal_code'];
  1052. $post = array(
  1053. "status" => "true",
  1054. "user_id" => $user_id,
  1055. 'user_name' => $user_name,
  1056. 'user_email' => $user_email,
  1057. "user_contact_no" => $user_contact_no,
  1058. 'user_login_type' => $login_type,
  1059. 'wallet_amount' => $wallet_amount,
  1060. 'profile_pic' => $img,
  1061. 'total_sms' => $get_sms,
  1062. 'remaining_sms' => $total_sms,
  1063. 'user_pin_status' => $pin_status,
  1064. 'reffer_code' => $self_reffer_code
  1065. );
  1066. } else {
  1067. $post = array('status' => "false", "message" => "Nenhum usuário existe", 'user_id' => $user_id);
  1068. }
  1069. } else {
  1070. $post = array('status' => "false", "message" => Missing_Parameter, 'user_id' => $user_id);
  1071. }
  1072. echo $this -> json($post);
  1073. }
  1074.  
  1075. function change_password() {
  1076. $user_id = $_POST['user_id'];
  1077. $old_password = $_POST['old_password'];
  1078. $new_password = $_POST['new_password'];
  1079. if (!empty($user_id)) {
  1080. $records = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
  1081. $old_user_password = $records['0']['user_password'];
  1082. $old_password = md5($old_password);
  1083. if ($old_password == $old_user_password){
  1084. $data['user_password'] = md5($new_password);
  1085. $update_toekn = $this -> conn -> updatetablebyid('user', 'user_id', $user_id, $data);
  1086. $post = array('status' => "true", "message" => "Senha alterada com sucesso", 'user_id' => $user_id);
  1087. } else {
  1088. $post = array('status' => "false", "message" => "Senha antiga inválida", 'user_id' => $user_id);
  1089. echo $this -> json($post);
  1090. exit();
  1091. }
  1092. } else {
  1093. $post = array('status' => "false", "message" => Missing_Parameter, 'user_id' => $user_id);
  1094. }
  1095. echo $this -> json($post);
  1096. }
  1097.  
  1098. function edit_profile() {
  1099. $user_id = $_POST['user_id'];
  1100. if (!empty($user_id)){
  1101. $user_name = $_POST['user_name'];
  1102. if (!empty($user_name)) {
  1103. $data['user_name'] = $user_name;
  1104. }
  1105.  
  1106. $user_email = $_REQUEST['user_email'];
  1107. if (!empty($user_email)) {
  1108. $records_user = $this -> conn -> get_table_field_doubles_not('user', 'user_email', $user_email,'user_id',$user_id);
  1109. if(empty($records_user)){
  1110. $data['user_email'] = $user_email;
  1111. }else{
  1112. $post = array('status' => "false", "message" => "Este e-mail já está registado", 'user_email' => $user_email);
  1113. echo $this -> json($post);
  1114. exit();
  1115. }
  1116. }
  1117.  
  1118. $new_password = $_POST['new_password'];
  1119. $old_password = $_POST['old_password'];
  1120. if (!empty($new_password) && !empty($old_password)) {
  1121. $records = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
  1122. $old_user_password = $records['0']['user_password'];
  1123.  
  1124. $old_password = md5($old_password);
  1125. if ($old_password == $old_user_password) {
  1126. $data['user_password'] = md5($new_password);
  1127. } else {
  1128. $post = array('status' => "false", "message" => "Senha antiga inválida", 'user_id' => $user_id);
  1129. echo $this -> json($post);
  1130. exit();
  1131. }
  1132. }
  1133.  
  1134. $user_image = '';
  1135. if ($_FILES['self_img']['name']) {
  1136. $user_image = $_FILES['self_img']['name'];
  1137. }
  1138.  
  1139. $attachment = $_FILES['self_img']['name'];
  1140. if (!empty($attachment)) {
  1141. $file_extension = explode(".", $_FILES["self_img"]["name"]);
  1142. $new_extension = strtolower(end($file_extension));
  1143. $today = time();
  1144. $custom_name = "self_img" . $today;
  1145. $file_name = $custom_name . "." . $new_extension;
  1146.  
  1147. if ($new_extension == 'png' || $new_extension == 'jpeg' || $new_extension == 'jpg' || $new_extension == 'bmp') {
  1148. move_uploaded_file($_FILES['self_img']['tmp_name'], "../uploads/self_img/" . $file_name);
  1149. }
  1150. }
  1151.  
  1152. if (!empty($file_name)) {
  1153. $data['user_profile_pic'] = $file_name;
  1154. }
  1155.  
  1156. $update_toekn = $this -> conn -> updatetablebyid('user', 'user_id', $user_id, $data);
  1157. $records_user = $this -> conn -> get_table_row_byidvalue('user', 'user_id', $user_id);
  1158. $name = $records_user['0']['user_name'];
  1159. $email = $records_user['0']['user_email'];
  1160. $user_login_type = $records_user['0']['user_login_type'];
  1161. $profile_pic = $records_user['0']['user_profile_pic'];
  1162. if($user_login_type=='1'){
  1163. $image = self_img_url . $profile_pic;
  1164. } else if($user_login_type!='1'){
  1165. $image=$profile_pic;
  1166. } else{
  1167. $image = '';
  1168. }
  1169.  
  1170. $post = array(
  1171. 'status' => "true",
  1172. "message" => "Atualização de perfil com sucesso",
  1173. 'user_id' => $user_id,
  1174. 'user_name' => $name,
  1175. 'user_email' => $email,
  1176. 'user_id' => $user_id,
  1177. 'user_profile_pic' => $image
  1178. );
  1179. } else{
  1180. $post = array('status' => "false", "message" => Missing_Parameter, 'user_id' => $user_id);
  1181. }
  1182.  
  1183. echo $this -> json($post);
  1184. }
  1185.  
  1186. function get_car_by_distance(){
  1187. header("Content-Type: text/html; charset=UTF-8",true);
  1188. header('Content-Type: application/json; charset=UTF-8',true);
  1189.  
  1190. $user_i = '23';
  1191. $mil = '205';
  1192. $lat = '-23.5506103';
  1193. $long = '-46.6472723';
  1194. $cidad = '5341';
  1195.  
  1196. if(!empty($user_i)){
  1197. $user_id = $user_i;
  1198. // if(!empty($_REQUEST['user_id'])){
  1199. // $user_id = $_REQUEST['user_id'];
  1200.  
  1201. if ($mil==0){
  1202. $mil=1;
  1203. }
  1204. // if ($_REQUEST['miles']==0){
  1205. // $_REQUEST['miles']=1;
  1206. // }
  1207.  
  1208. if((!empty($lat) || !empty($long) || !empty($mil)) || (!empty($cidad))){
  1209.  
  1210. if(!empty($lat) && !empty($long)){
  1211. $latitude = $lat;
  1212. $longitude = $long;
  1213. $miles = $mil;
  1214. }
  1215. // if((!empty($_REQUEST['latitude']) || !empty($_REQUEST['longitude']) || !empty($_REQUEST['miles'])) || (!empty($_REQUEST['city']))){
  1216.  
  1217. // if(!empty($_REQUEST['latitude']) && !empty($_REQUEST['longitude'])){
  1218. // $latitude = $_REQUEST['latitude'];
  1219. // $longitude = $_REQUEST['longitude'];
  1220. // $miles = $_REQUEST['miles'];
  1221. // }
  1222. else {
  1223. $city = $cidad;
  1224. // $city = $_REQUEST['city'];
  1225. $miles=200;
  1226. $query="select * from tbl_city where city_id='".$city."'";
  1227. $record = $this->mysqli->query($query) or die($this->mysqli->error.__LINE__);
  1228. // $record=$this->conn->getData($query);
  1229. // print_r($record); die();
  1230.  
  1231. if(empty($record)){
  1232. $post=array('status'=>'false','message'=>'Nenhum fornecedor de serviços encontrado');
  1233. echo $this -> json($post);
  1234. exit();
  1235. }
  1236.  
  1237. $latitude = $record[0]['city_lat'];
  1238. $longitude = $record[0]['city_long'];
  1239. $city_name=html_entity_decode($record[0]['city_name']);
  1240.  
  1241. if(!empty($latitude) && !empty($longitude)){
  1242. $latitude = $record[0]['city_lat'];
  1243. $longitude = $record[0]['city_long'];
  1244. } else{
  1245.  
  1246. $curl = curl_init();
  1247.  
  1248. curl_setopt_array($curl, array(
  1249. CURLOPT_URL => "https://maps.googleapis.com/maps/api/geocode/json?key=AIzaSyCcsjliFLtVzAeYAn0vdRrx3D8jV1FYpLo&address=".urlencode($city_name).",Brazil",
  1250. CURLOPT_RETURNTRANSFER => true,
  1251. CURLOPT_ENCODING => "",
  1252. CURLOPT_MAXREDIRS => 10,
  1253. CURLOPT_TIMEOUT => 30,
  1254. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  1255. CURLOPT_CUSTOMREQUEST => "GET",
  1256. CURLOPT_HTTPHEADER => array(
  1257. "cache-control: no-cache",
  1258. "postman-token: 6d979a5a-5977-52a4-02b0-2d1e2fcf869a"
  1259. ),
  1260. ));
  1261.  
  1262. $response = curl_exec($curl);
  1263. $err = curl_error($curl);
  1264.  
  1265. curl_close($curl);
  1266.  
  1267. if ($err) {
  1268. "cURL Error #:" . $err;
  1269. } else {
  1270. $response;
  1271. }
  1272.  
  1273. $result = json_decode($response, TRUE);
  1274.  
  1275. $latitude = $result['results'][0]['geometry']['location']['lat'];
  1276. $longitude = $result['results'][0]['geometry']['location']['lng'];
  1277. $insert = $this->conn->insertnewrecords('tbl_city', 'city_lat, city_long', '"' . $user_id . '","' . $service_provider_userid . '"');
  1278. $update="update tbl_city set city_lat='".$latitude."', city_long='".$longitude."' where city_id='".$city."'";
  1279.  
  1280. $result=mysql_query($update);
  1281. }
  1282. }
  1283.  
  1284. $sql = "
  1285. SELECT *,
  1286. (3959
  1287. * acos (cos (radians('$latitude') )
  1288. * cos( radians( car_latitude ) )
  1289. * cos( radians( car_longitude ) - radians('$longitude') )
  1290. + sin ( radians('$latitude') )
  1291. * sin( radians( car_latitude ) )
  1292. )
  1293. ) AS distance
  1294. FROM tbl_cars
  1295. LEFT JOIN tbl_carYear
  1296. on tbl_carYear.carYear_id = tbl_cars.car_Year
  1297. LEFT JOIN tbl_carFuel
  1298. on tbl_carFuel.carFuel_id = tbl_cars.car_Fuel
  1299. LEFT JOIN tbl_carGear
  1300. on tbl_carGear.carGear_id = tbl_cars.car_Gear
  1301. LEFT JOIN tbl_brand
  1302. on tbl_brand.brand_id = tbl_cars.car_Brand
  1303. LEFT JOIN tbl_carVersion
  1304. on tbl_carVersion.carVersion_id = tbl_cars.car_Version
  1305. LEFT JOIN tbl_blindagem
  1306. on tbl_blindagem.blindagem_id = tbl_cars.car_blindagem
  1307. LEFT JOIN tbl_carModel
  1308. on tbl_carModel.carModel_id = tbl_cars.car_model
  1309. WHERE car_user_id!=$user_id
  1310. AND tbl_cars.car_status = 1
  1311. AND tbl_carYear.carYear_status = 1
  1312. AND tbl_carFuel.carFuel_status = 1
  1313. AND tbl_carGear.carGear_status = 1
  1314. AND tbl_brand.brand_status = 1
  1315. AND tbl_carVersion.carVersion_status = 1
  1316. AND tbl_blindagem.blindagem_status = 1
  1317. AND tbl_carModel.car_Model_status = 1
  1318. HAVING distance < '$miles'
  1319. ORDER BY distance
  1320. ";
  1321.  
  1322. // $record=$this->conn->getData($sql);
  1323. $record_sql=$this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
  1324. while ($dados = $record_sql->fetch_assoc()) {
  1325. $dados[] = utf8_decode($dados);
  1326. $record[] = $dados;
  1327. }
  1328. // print_r($record); die();
  1329.  
  1330. foreach ($record as $key=>$value) {
  1331. if($value['car_featured']==1){
  1332. $car_user_id = $value['car_user_id'];
  1333. // print_r($car_user_id); die();
  1334.  
  1335. $query_subcription=" select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
  1336. $record_query=$this->mysqli->query($query_subcription) or die($this->mysqli->error.__LINE__);
  1337. while ($dados1 = $record_query->fetch_assoc()) {
  1338. $dados1[] = utf8_decode($dados1);
  1339. $record_subcription[] = $dados1;
  1340. if(!empty($record_subcription)){
  1341. $end_date=$record_subcription['end_date'];
  1342. $date=date("Y-m-d h:i:s a");
  1343.  
  1344. if(!($date<=$end_date)) {
  1345. $value['car_featured']='2';
  1346. } else {
  1347. $value['car_featured']='1';
  1348. }
  1349. // print_r($value['car_featured']); echo '<pre>'; print_r($record_subcription);
  1350. } else {
  1351. $value['car_featured']='2';
  1352. }
  1353. }
  1354. }
  1355.  
  1356. $car_id = $value['car_id'];
  1357. $car_name = utf8_encode($value['car_name']);
  1358. $car_fullname = utf8_encode($value['car_fullname']);
  1359. $car_price = $value['car_price'];
  1360. $car_model = $value['carYear_name'];
  1361. $carFuel_type = utf8_encode($value['carFuel_type']);
  1362. $carGear_type = $value['carGear_type'];
  1363. $car_featured = $value['car_featured'];
  1364. // $carVersion_name = html_entity_decode($value['carVersion_name']);
  1365. $carVersion_name = utf8_encode($value['carVersion_name']);
  1366. $car_images = explode(",",$value['car_images']);
  1367. $brand_images = brand_images.$value['brand_image'];
  1368. $Resellerprice = $value['car_Reseller_price'];
  1369. $favourite_status = $value['favourite_status'];
  1370. // $carFuel_type = html_entity_decode($carFuel_type);
  1371. // $car_name = $value['car_name'];
  1372. // $car_fullname = $value['car_fullname'];
  1373. // $car_price = $this->moneyFormatIndia($value['car_price']);
  1374. // $Resellerprice = $this->moneyFormatIndia($value['car_Reseller_price']);
  1375.  
  1376. $response = array();
  1377. $response = [
  1378. 'car_id' => $car_id,
  1379. 'car_name' => $car_name,
  1380. 'car_fullname'=>$car_fullname,
  1381. 'car_price'=>$car_price,
  1382. 'car_model'=>$car_model,
  1383. 'car_images'=>car_images.$car_images[0],
  1384. 'car_featured'=>$car_featured,
  1385. 'fuel_type'=>$carFuel_type,
  1386. 'gear_type'=>$carGear_type,
  1387. 'reseller_price'=>$Resellerprice,
  1388. 'favourite_status'=>$favourite_status,
  1389. 'brand_images'=>$brand_images,
  1390. 'carVersion_name'=>$carVersion_name
  1391. ];
  1392.  
  1393. // print_r($response);
  1394.  
  1395. $responseData= json_encode($response);
  1396. $postJson[]= json_decode($responseData);
  1397. }
  1398.  
  1399. if (!empty($postJson)) {
  1400. $post = array("status" => "true", "message" => count($postJson)." ".Car_found,'cars'=>$postJson);
  1401. } else {
  1402. $post = array('status' => "false", "message" => No_Record_Found);
  1403. }
  1404. } else {
  1405. $post=array('status'=>'false','message'=>Missing_Parameter);
  1406. }
  1407. } else {
  1408. $post=array('status'=>'false','message'=>Missing_Parameter);
  1409. }
  1410. // echo $this -> json($post);
  1411. echo $this->json($post);
  1412. }
  1413.  
  1414. function state_list() {
  1415. $state = $this -> conn -> get_table_row_byidvalue('tbl_state', 'state_status', 1);
  1416. foreach ($state as $key => $value) {
  1417. $state_id = $value['state_id'];
  1418. $state_name = html_entity_decode($value['state_name']);
  1419. $country_id = $value['country_ids'];
  1420. $response[] = array(
  1421. 'state_id' => $state_id,
  1422. 'state_name' => $state_name,
  1423. 'country_id'=>$country_id
  1424. );
  1425. }
  1426. if (!empty($response)) {
  1427. $post = array(
  1428. "status" => "true",
  1429. "message" => 'Lista de estados encontrada',
  1430. 'states'=>$response
  1431. );
  1432. } else {
  1433. $post = array(
  1434. 'status' => "false",
  1435. "message" => No_Record_Found
  1436. );
  1437. }
  1438. echo $this -> json($post);
  1439. }
  1440.  
  1441. function city_list() {
  1442. header("Content-Type: text/html; charset=UTF-8",true);
  1443. header('Content-Type: application/json; charset=UTF-8',true);
  1444.  
  1445. $state_id = $_REQUEST['state_id'];
  1446. // $state_id = '26';
  1447. if (!empty($state_id)) {
  1448. $city = $this -> conn -> get_table_field_doubles('tbl_city', 'city_status', 1, 'state_ids', $state_id);
  1449. foreach ($city as $key => $value) {
  1450. $city_id =$value['city_id'];
  1451. $city_name = html_entity_decode($value['city_name']);
  1452. $response[] = array(
  1453. 'city_id' => $city_id,
  1454. 'city_name' => $city_name,
  1455. 'state_id' => $state_id
  1456. );
  1457. }
  1458. if (!empty($response)) {
  1459. $post = array(
  1460. "status" => "true",
  1461. 'state_id' => $state_id,
  1462. "message" => 'Lista de cidades encontrada',
  1463. 'city'=>$response
  1464. );
  1465. } else {
  1466. $post = array(
  1467. 'status' => "false",
  1468. "message" => No_Record_Found
  1469. );
  1470. }
  1471.  
  1472. } else {
  1473. $post = array(
  1474. 'status' => "false",
  1475. "message" => Missing_Parameter,
  1476. 'state_id' => $state_id
  1477. );
  1478. }
  1479. echo $this -> json($post);
  1480. }
  1481.  
  1482.  
  1483.  
  1484.  
  1485. function car_list(){
  1486. header("Content-Type: text/html;charset=utf-8");
  1487. header('Content-Type: application/json;charset=utf-8');
  1488.  
  1489. $user_id= '23';
  1490. $state_id= '26';
  1491. $city_id= '5341';
  1492.  
  1493. // $user_id=$_REQUEST['user_id'];
  1494. // $state_id=$_REQUEST['state_id'];
  1495. // $city_id=$_REQUEST['city_id'];
  1496.  
  1497. if(!empty($state_id) && !empty($city_id)){
  1498. $sql="where car_state_id='".$state_id."' and car_city_id='".$city_id."' AND";
  1499. } elseif (!empty($state_id)){
  1500. $sql="where car_state_id='".$state_id."' AND ";
  1501. } else {
  1502. $sql='where';
  1503. }
  1504.  
  1505.  
  1506. $sql="
  1507. SELECT * FROM tbl_cars
  1508. JOIN tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
  1509. JOIN tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
  1510. JOIN tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
  1511. JOIN tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
  1512. JOIN tbl_carVersion on tbl_carVersion.carVersion_id=tbl_cars.car_Version
  1513. JOIN tbl_blindagem on tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
  1514. JOIN tbl_carModel on tbl_carModel.carModel_id=tbl_cars.car_model
  1515. ".$sql." tbl_cars.car_status=1
  1516. AND tbl_carYear.carYear_status=1
  1517. AND tbl_carFuel.carFuel_status=1
  1518. AND tbl_carGear.carGear_status=1
  1519. AND tbl_brand.brand_status=1
  1520. AND tbl_carVersion.carVersion_status=1
  1521. AND tbl_blindagem.blindagem_status=1
  1522. AND tbl_carModel.car_Model_status=1
  1523. ORDER BY RAND()
  1524. ";
  1525.  
  1526.  
  1527. $record=$this->conn->getData($sql);
  1528. foreach ($record as $key => $value) {
  1529. $car_id = $value['car_id'];
  1530. $sql1 = "select * from tbl_favourite where favourite_car_ID='".$car_id."' and favourite_user_ID='".$user_id."'";
  1531. $record1 = $this->conn->getData($sql1);
  1532.  
  1533. if (!empty($record1)){
  1534. $favourite_status=$record1[0]['favourite_status'];
  1535. if ($favourite_status='1'){
  1536. $favourite_status='1';
  1537. } else {
  1538. $favourite_status='2';
  1539. }
  1540. } else {
  1541. $favourite_status='2';
  1542. }
  1543.  
  1544.  
  1545. $car_user_id = $value['car_user_id'];
  1546. $query_subcription = "select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
  1547. $record_subcription = $this->conn->getData($query_subcription);
  1548.  
  1549. if (!empty($record_subcription)){
  1550. $end_date=$record_subcription[0]['end_date'];
  1551. $date=date("Y-m-d h:i:s a");
  1552. if (!($date<=$end_date)){
  1553. $value['car_featured']='2';
  1554. }
  1555. } else {
  1556. $value['car_featured']='2';
  1557. }
  1558.  
  1559.  
  1560. $car_name = $value['car_name'];
  1561. $car_name = html_entity_decode($car_name);
  1562. $car_fullname = $value['car_fullname'];
  1563. $car_fullname = html_entity_decode($car_fullname);
  1564. $car_price = $value['car_price'];
  1565. $car_model = $value['carYear_name'];
  1566. $car_featured = $value['car_featured'];
  1567. $carFuel_type = $value['carFuel_type'];
  1568. $carFuel_type = html_entity_decode($carFuel_type);
  1569. $carVersion_name = $value['carVersion_name'];
  1570. $carGear_type = $value['carGear_type'];
  1571. $car_featured = $value['car_featured'];
  1572. $brand_images = brand_images.$value['brand_image'];
  1573. $car_images = $value['car_profile_pick'];
  1574. $Resellerprice = $value['car_Reseller_price'];
  1575. // $car_price = $this->moneyFormatIndia($value['car_price']);
  1576. // $carVersion_name = html_entity_decode($carVersion_name );
  1577. // $car_images = explode(",",$value['car_images']);
  1578. //$Resellerprice = $this->moneyFormatIndia($value['car_Reseller_price']);
  1579.  
  1580. $response[] = array(
  1581. 'car_id' => $car_id,
  1582. 'car_name' => $car_name,
  1583. 'car_fullname'=>$car_fullname,
  1584. 'car_price'=>$car_price,
  1585. 'car_model'=>$car_model,
  1586. 'car_images'=>car_images.$car_images,
  1587. 'car_featured'=>$car_featured,
  1588. 'fuel_type'=>$carFuel_type,
  1589. 'gear_type'=>$carGear_type,
  1590. 'reseller_price'=>$Resellerprice,
  1591. 'carVersion_name'=>$carVersion_name,
  1592. 'favourite_status'=>$favourite_status,
  1593. 'brand_images'=>$brand_images
  1594. );
  1595. }
  1596.  
  1597.  
  1598. if (!empty($response)) {
  1599. $post = array("status" => "true", "message" => count($response)." ".Car_found,'cars'=>$response);
  1600. } else {
  1601. $post = array('status' => "false", "message" => No_Record_Found);
  1602. }
  1603.  
  1604.  
  1605. echo $this -> json($post);
  1606. }
  1607.  
  1608. function get_carDetails(){
  1609. header("Content-Type: text/html;charset=utf-8");
  1610. header('Content-Type: application/json;charset=utf-8');
  1611.  
  1612. if(!empty($_REQUEST['car_id'])){
  1613. $car_id=$_REQUEST['car_id'];
  1614. $user_id=$_REQUEST['user_id'];
  1615. // $carIdTeste = 3;
  1616. // $userIdTeste = 151;
  1617.  
  1618. // if(!empty($carIdTeste)){
  1619. // $car_id=$carIdTeste;
  1620. // $user_id=$userIdTeste;
  1621. // $car_city_id=$_REQUEST['car_city_id'];
  1622. // $car_state_id=$_REQUEST['car_state_id'];
  1623.  
  1624. $sql="
  1625. SELECT * FROM tbl_cars
  1626. JOIN tbl_user ON tbl_user.user_id=tbl_cars.car_user_id
  1627. JOIN tbl_state ON tbl_state.state_id=tbl_cars.car_state_id
  1628. JOIN tbl_city ON tbl_city.city_id=tbl_cars.car_city_id
  1629. JOIN tbl_brand ON tbl_brand.brand_id=tbl_cars.car_Brand
  1630. JOIN tbl_carFuel ON tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
  1631. JOIN tbl_carGear ON tbl_carGear.carGear_id=tbl_cars.car_Gear
  1632. JOIN tbl_carVersion ON tbl_carVersion.carVersion_id=tbl_cars.car_Version
  1633. JOIN tbl_carModel ON tbl_carModel.carModel_id=tbl_cars.car_model
  1634. JOIN tbl_carYear ON tbl_carYear.carYear_id=tbl_cars.car_Year
  1635. JOIN tbl_CarType on tbl_CarType.carType_id=tbl_cars.car_category_id
  1636. WHERE tbl_cars.car_id='".$car_id."'"
  1637. ;
  1638.  
  1639. // $record=$this->conn->getData($sql);
  1640. $record_sql=$this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
  1641. while ($dados = $record_sql->fetch_assoc()) {
  1642. $record[] = $dados;
  1643. }
  1644. // print_r($record); die();
  1645.  
  1646. if(!empty($record)){
  1647. $sql1="select * from tbl_interest where interest_car_ID='".$car_id."' and interest_user_ID='".$user_id."'";
  1648. // $record1=$this->conn->getData($sql1);
  1649. $record_sql1=$this->mysqli->query($sql1) or die($this->mysqli->error.__LINE__);
  1650. while ($dados1 = $record_sql1->fetch_assoc()) {
  1651. $record1[] = $dados1;
  1652. }
  1653. if(!empty($record1)){
  1654. $car_interest='1';
  1655. }
  1656. else{
  1657. $car_interest='2';
  1658. }
  1659.  
  1660. $sql1="select * from tbl_favourite where favourite_car_ID='".$car_id."' and favourite_user_ID='".$user_id."'";
  1661. // $record1=$this->conn->getData($sql1);
  1662. $record_sql1=$this->mysqli->query($sql1) or die($this->mysqli->error.__LINE__);
  1663. while ($dados1 = $record_sql1->fetch_assoc()) {
  1664. $record1[] = $dados1;
  1665. }
  1666. $favourite_status=$record1[0]['favourite_status'];
  1667. if($favourite_status==1){
  1668. $favourite_status='1';
  1669. }
  1670. else{
  1671. $favourite_status='2';
  1672. }
  1673. $favourite_status;
  1674.  
  1675. $sql_version="select * from tbl_carVersion where car_Model_id='".$record[0]['car_Version']."' and carVersion_status=1";
  1676. // $version=$this->conn->getData($sql_version);
  1677. $record_sql_version=$this->mysqli->query($sql_version) or die($this->mysqli->error.__LINE__);
  1678. while ($dados2 = $record_sql_version->fetch_assoc()) {
  1679. $version[] = $dados2;
  1680. }
  1681. $price=$record[0]['car_price'];
  1682. $car_user_id=$record[0]['car_user_id'];
  1683.  
  1684. // $sql1="select * from shop_profile where user_id ='".$car_user_id."' ";
  1685. // $record1=$this->conn->getData($sql1);
  1686. // $author_name=$record1[0]['author_name'];
  1687. // $profile_pick=user_images.$record1[0]['profile_pick'];
  1688. // $shop_name=$record1[0]['shop_name'];
  1689.  
  1690.  
  1691. $reseller = $record[0]['car_Reseller_price'];
  1692. $car_name = $record[0]['car_name'];
  1693. $car_name = utf8_encode($car_name);
  1694. $car_fullname = $record[0]['car_fullname'];
  1695. $car_fullname = utf8_encode($car_fullname);
  1696. // $car_name = $record[0]['car_name'];
  1697. // $car_fullname = $record[0]['car_fullname'];
  1698. $car_price = $p;
  1699. $car_model = $record[0]['carYear_name'];
  1700. $vendor_name = utf8_encode($record[0]['user_name']);
  1701. $vendor_email = $record[0]['user_email'];
  1702. $vendor_phone = $record[0]['user_phone'];
  1703. $state_name = utf8_encode($record[0]['state_name']);
  1704. $city_name = utf8_encode($record[0]['city_name']);
  1705. $car_latitude = $record[0]['car_latitude'];
  1706. $car_longitude = $record[0]['car_longitude'];
  1707. $car_Brand = utf8_encode($record[0]['brand_name']);
  1708. $brand_images = brand_images.$record[0]['brand_image'];
  1709. $car_Fuel = utf8_encode($record[0]['carFuel_type']);
  1710. $car_Gear = utf8_encode($record[0]['carGear_type']);
  1711. $car_color = $record[0]['car_color'];
  1712. $car_addr = utf8_encode($record[0]['car_address']);
  1713. $car_color = explode(",",$car_color);
  1714.  
  1715. foreach($car_color as $key => $value) {
  1716. $color_id=$value;
  1717. $query22="select * from tbl_carColor where carColor_id='".$color_id."'";
  1718. // $record2=$this->conn->getData($query22);
  1719. $record_query22=$this->mysqli->query($query22) or die($this->mysqli->error.__LINE__);
  1720. while ($record2 = $record_query22->fetch_assoc()) {
  1721. $carColor_name=$record2['carColor_name'];
  1722. $carColor_code=$record2['carColor_code'];
  1723. $carColor_id=$record2['carColor_id'];
  1724. }
  1725.  
  1726. $color_detail[$key]=array(
  1727. 'carColor_name'=>$carColor_name,
  1728. 'carColor_code'=>$carColor_code,
  1729. 'carColor_id'=>$carColor_id
  1730. );
  1731. }
  1732.  
  1733.  
  1734. $car_version = utf8_encode($record[0]['carVersion_name']);
  1735. $car_option = utf8_encode($record[0]['car_option']);
  1736. $car_blindagem = utf8_encode($record[0]['car_blindagem']);
  1737. $Resellerprice = $r;
  1738. $car_type = utf8_encode($record[0]['carType_name']);
  1739. $car_door = $record[0]['car_door'];
  1740. $car_posted = date("d/m/Y",strtotime($record[0]['car_created_date']));
  1741. $car_images = explode(",",$record[0]['car_images']);
  1742.  
  1743. if(!empty($car_images)){
  1744. foreach ($car_images as $value) {
  1745. $imagesCar[]=car_images.$value;
  1746. }
  1747. }else {
  1748. $imagesCar=array();
  1749. }
  1750.  
  1751. $sql1="select * from shop_profile where user_id ='".$car_user_id."' ";
  1752. // $record1=$this->conn->getData($sql1);
  1753. $record_sql1=$this->mysqli->query($sql1) or die($this->mysqli->error.__LINE__);
  1754. while ($dados1 = $record_sql1->fetch_assoc()) {
  1755. $record1[] = $dados1;
  1756. }
  1757. $author_name=$record1[0]['author_name'];
  1758. $profile_pick=user_images.$record1[0]['profile_pick'];
  1759. $shop_name=$record1[0]['shop_name'];
  1760. $email=$record1[0]['email'];
  1761. $phone=$record1[0]['phone'];
  1762.  
  1763. if(!empty($email)){
  1764. $vendor_email=$email;
  1765. }
  1766.  
  1767. if(!empty($phone)){
  1768. $vendor_phone=$phone;
  1769. }
  1770.  
  1771. // $post= ();
  1772. $post= [
  1773. 'status'=>'true',
  1774. 'message'=>Car_Details_Get_Successfully,
  1775. 'car_id'=>$car_id,
  1776. 'car_name'=>$car_name,
  1777. 'car_fullname'=>$car_fullname,
  1778. 'car_price'=> $price,
  1779. 'car_model'=>$car_model,
  1780. 'vendor_name'=>$vendor_name,
  1781. 'vendor_email'=>$vendor_email,
  1782. 'vendor_phone'=>$vendor_phone,
  1783. 'car_images'=>$imagesCar,
  1784. 'car_state'=>$state_name,
  1785. 'car_city'=>$city_name,
  1786. 'car_latitude'=>$car_latitude,
  1787. 'car_longitude'=>$car_longitude,
  1788. 'car_Brand'=>$car_Brand,
  1789. 'car_Fuel'=>$car_Fuel,
  1790. 'car_Gear'=>$car_Gear,
  1791. 'color_detail'=>$color_detail,
  1792. 'carVersion_name'=>$car_version,
  1793. 'car_posted'=>$car_posted,
  1794. 'interest'=>$car_interest,
  1795. 'reseller_price'=> $reseller,
  1796. 'car_type'=>$car_type,
  1797. 'car_door'=>$car_door,
  1798. 'car_option'=>$car_option,
  1799. 'favourite_status'=>$favourite_status,
  1800. 'car_blindagem'=>$car_blindagem,
  1801. 'brand_image'=>$brand_images,
  1802. 'author_name'=>utf8_encode($author_name),
  1803. 'profile_pick'=>$profile_pick,
  1804. 'shop_name'=>utf8_encode($shop_name),
  1805. 'version'=>utf8_encode($version),
  1806. 'car_addr'=>$car_addr
  1807. ];
  1808.  
  1809.  
  1810. } else {
  1811. $post=array('status'=>'false','message'=>No_CAR_FOUND,'car_id'=>$_REQUEST['car_id']);
  1812. }
  1813. } else {
  1814. $post=array('status'=>'false','message'=>Missing_Parameter,'car_id'=>$_REQUEST['car_id']);
  1815. }
  1816. // print_r($post);
  1817. echo $this->json($post);
  1818. }
  1819.  
  1820. function brand_carType() {
  1821. header("Content-Type: text/html;charset=utf-8");
  1822. header('Content-Type: application/json;charset=utf-8');
  1823.  
  1824. $sql="SELECT max(car_price) as max_carPRice from tbl_cars";
  1825.  
  1826. $pricerecord= $this->conn->getData($sql);
  1827. $brand = $this->conn->get_table_row_byidvalue('tbl_brand', 'brand_status', 1);
  1828.  
  1829.  
  1830. foreach ($brand as $key => $value) {
  1831. $brand_id = $value['brand_id'];
  1832. $brand_name = $value['brand_name'];
  1833. $brand_image = brand_images.$value['brand_image'];
  1834.  
  1835. $brand_response[] = array(
  1836. 'brand_id' => $brand_id,
  1837. 'brand_name' => $brand_name,
  1838. 'brand_image'=>$brand_image
  1839. );
  1840. }
  1841.  
  1842. $carType = $this->conn->get_table_row_byidvalue('tbl_CarType', 'carType_status', 1);
  1843.  
  1844. foreach ($carType as $key => $value) {
  1845. $carType_id = $value['carType_id'];
  1846. $carType_name = $value['carType_name'];
  1847. $carType_image = carType_images.$value['carType_image'];
  1848.  
  1849. $carType_response[] = array(
  1850. 'carType_id' => $carType_id,
  1851. 'carType_name' => $carType_name,
  1852. 'carType_image'=>$carType_image
  1853. );
  1854. }
  1855.  
  1856. $post = array(
  1857. "status" => "true",
  1858. "message" => 'Lista encontrada',
  1859. 'brand'=>$brand_response,
  1860. 'carType'=>$carType_response,
  1861. 'car_Maxprice'=>$pricerecord[0]['max_carPRice']
  1862. );
  1863. echo $this -> json($post);
  1864. }
  1865.  
  1866. function filter_type_list() {
  1867. $blindagemSql = $this-> conn -> get_table_row_byidvalue('tbl_blindagem', 'blindagem_status', 1);
  1868. if(!empty($blindagemSql)){
  1869. foreach ($blindagemSql as $key => $value) {
  1870. $blindagem_id = $value['blindagem_id'];
  1871. $blindagem_type = $value['blindagem_type'];
  1872. $blindagem[] = array(
  1873. 'blindagem_id' => $blindagem_id,
  1874. 'blindagem_type' => $blindagem_type
  1875. );
  1876. }
  1877. } else {
  1878. $blindagem=array();
  1879. }
  1880.  
  1881.  
  1882. $brandSql = $this -> conn -> get_table_row_byidvalue('tbl_brand', 'brand_status', 1);
  1883. if(!empty($brandSql)){
  1884. foreach ($brandSql as $key => $value) {
  1885. $brand_id = $value['brand_id'];
  1886. $brand_name = $value['brand_name'];
  1887. $brand_image = brand_images.$value['brand_image'];
  1888. $brand[] = array(
  1889. 'brand_id' => $brand_id,
  1890. 'brand_name' => $brand_name,
  1891. 'brand_image' => $brand_image
  1892. );
  1893. }
  1894. } else{
  1895. $brand=array();
  1896. }
  1897.  
  1898.  
  1899. $carColorSql = $this -> conn -> get_table_row_byidvalue('tbl_carColor', 'carColor_status', 1);
  1900. if(!empty($carColorSql)){
  1901. foreach ($carColorSql as $key => $value) {
  1902. $carColor_id = $value['carColor_id'];
  1903. $carColor_name = $value['carColor_name'];
  1904. $carColor_code = $value['carColor_code'];
  1905. $carColor[] = array(
  1906. 'carColor_id' => $carColor_id,
  1907. 'carColor_name' => $carColor_name,
  1908. 'carColor_code' => $carColor_code
  1909. );
  1910. }
  1911. }else{
  1912. $carColor=array();
  1913. }
  1914.  
  1915.  
  1916. $carFuelSql = $this -> conn -> get_table_row_byidvalue('tbl_carFuel', 'carFuel_status', 1);
  1917. if(!empty($carFuelSql)){
  1918. foreach ($carFuelSql as $key => $value) {
  1919. $carFuel_id = $value['carFuel_id'];
  1920. $carFuel_type = html_entity_decode($value['carFuel_type']);
  1921. $carFuel[] = array(
  1922. 'carFuel_id' => $carFuel_id,
  1923. 'carFuel_type' => $carFuel_type
  1924. );
  1925. }
  1926. } else{
  1927. $carFuel=array();
  1928. }
  1929.  
  1930.  
  1931. $carGearSql = $this -> conn -> get_table_row_byidvalue('tbl_carGear', 'carGear_status', 1);
  1932. if(!empty($carGearSql)){
  1933. foreach ($carGearSql as $key => $value) {
  1934. $carGear_id = $value['carGear_id'];
  1935. $carGear_type = $value['carGear_type'];
  1936. $carGear[] = array(
  1937. 'carGear_id' => $carGear_id,
  1938. 'carGear_type' => $carGear_type
  1939. );
  1940. }
  1941. } else{
  1942. $carGear=array();
  1943. }
  1944.  
  1945.  
  1946. //$carModelSql = $this -> conn -> get_table_row_byidvalue('tbl_carModel', 'car_Model_status', 1);
  1947. if(!empty($_REQUEST['brand_id'])){
  1948. $where=" AND car_Modal_brand=".$_REQUEST['brand_id'];
  1949. $where1=" AND car_Brand=".$_REQUEST['brand_id'];
  1950. } else{
  1951. $where="";
  1952. $where1="";
  1953. }
  1954.  
  1955. if(!empty($_REQUEST['modal_id'])){
  1956. $where2=" AND car_model=".$_REQUEST['modal_id'];
  1957. } else{
  1958. $where2="";
  1959. }
  1960.  
  1961.  
  1962. $carModelSql = $this -> conn -> getData("SELECT * FROM `tbl_carModel` WHERE car_Model_status=1 ".$where);
  1963. if(!empty($carModelSql)){
  1964. foreach ($carModelSql as $key => $value) {
  1965. $carModel_id = $value['carModel_id'];
  1966. $carModel_name = html_entity_decode($value['carModel_name']);
  1967. $caModel_category_id = $value['caModel_category_id'];
  1968. $caModel_brand_id = $value['car_Modal_brand'];
  1969. $carModel[] = array(
  1970. 'carModel_id' => $carModel_id,
  1971. 'carModel_name' => $carModel_name,
  1972. 'caModel_category_id' => $caModel_category_id,
  1973. 'car_Modal_brand'=>$caModel_brand_id
  1974. );
  1975. }
  1976. } else{
  1977. $carModel=array();
  1978. }
  1979.  
  1980. //$carVersionSql = $this -> conn -> get_table_row_byidvalue('tbl_carVersion', 'carVersion_status', 1);
  1981. $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);
  1982. if(!empty($carVersionSql)){
  1983. foreach ($carVersionSql as $key => $value) {
  1984. $carVersion_id = $value['carVersion_id'];
  1985. $carVersion_name = $value['carVersion_name'];
  1986. $carVersion_category = $value['carVersion_category'];
  1987. $car_Model_id = $value['car_Model_id'];
  1988. $carVersion[] = array(
  1989. 'carVersion_id' => $carVersion_id,
  1990. 'carVersion_name' => $carVersion_name,
  1991. 'carVersion_category' => $carVersion_category,
  1992. 'car_Model_id'=>$car_Model_id
  1993. );
  1994. }
  1995. } else{
  1996. $carVersion=array();
  1997. }
  1998.  
  1999.  
  2000. $carYearSql = $this -> conn -> get_table_row_byidvalue('tbl_carYear', 'carYear_status', 1);
  2001. if(!empty($carYearSql)){
  2002. foreach ($carYearSql as $key => $value) {
  2003. $carYear_id = $value['carYear_id'];
  2004. $carYear_name = $value['carYear_name'];
  2005. $carYear[] = array(
  2006. 'carYear_id' => $carYear_id,
  2007. 'carYear_name' => $carYear_name
  2008. );
  2009. }
  2010. } else{
  2011. $carYear=array();
  2012. }
  2013.  
  2014.  
  2015. $post=array(
  2016. 'status'=>'true',
  2017. 'blindagem'=>$blindagem,
  2018. 'carColor'=>$carColor,
  2019. 'carFuel'=>$carFuel,
  2020. 'carGear'=>$carGear,
  2021. 'carModel'=>$carModel,
  2022. 'carVersion'=>$carVersion,
  2023. 'carYear'=>$carYear,
  2024. 'carBrand'=>$brand
  2025. );
  2026.  
  2027. echo $this -> json($post);
  2028. }
  2029.  
  2030. function myfunction($products,$value){
  2031. // echo $value;
  2032. foreach($products as $key => $product){
  2033. if (
  2034. strtolower($product['car_name']) == $value ||
  2035. strtolower($product['car_fullname']) == $value ||
  2036. strtolower($product['car_price']) == $value ||
  2037. strtolower($product['car_latitude']) == $value ||
  2038. strtolower($product['car_latitude']) == $value ||
  2039. strtolower($product['car_address']) == $value ||
  2040. strtolower($product['car_Reseller_price']) == $value ||
  2041. preg_match('/\b' .$value. '\b/', strtolower($product['car_option'])) ||
  2042. strtolower($product['car_created_date']) == $value ||
  2043. strtolower($product['carYear_name']) == $value ||
  2044. strtolower($product['carFuel_type']) == $value ||
  2045. strtolower($product['carGear_type']) == $value ||
  2046. strtolower($product['brand_name']) == $value ||
  2047. strtolower($product['carVersion_name']) == $value ||
  2048. strtolower($product['carType_name']) == $value ||
  2049. strtolower($product['blindagem_type']) == $value ||
  2050. strtolower($product['carModel_name'])== $value ||
  2051. preg_match('/\b' .$value. '\b/', strtolower($product['car_color_name']))
  2052. ){
  2053. $key_info[]=$key;
  2054. }
  2055. }
  2056. return $key_info;
  2057. }
  2058.  
  2059.  
  2060.  
  2061.  
  2062. function remove_favourite(){
  2063. $car_id = $_REQUEST['car_id'];
  2064. $user_id = $_REQUEST['user_id'];
  2065.  
  2066. $sql = "DELETE FROM tbl_favourite WHERE favourite_user_ID = '".$user_id."' AND favourite_car_ID = '".$car_id."'";
  2067.  
  2068. $remover = $this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
  2069. }
  2070.  
  2071.  
  2072.  
  2073. function add_favourite(){
  2074. if(!empty($_REQUEST['car_id']) && !empty($_REQUEST['user_id']) && !empty($_REQUEST['favourite_status'])){
  2075. $carID = $_REQUEST['car_id'];
  2076. $userID = $_REQUEST['user_id'];
  2077. $favourite = $_REQUEST['favourite_status'];
  2078.  
  2079. $sql1="select car_user_id from tbl_cars where car_id='".$carID."'";
  2080. $recordcar=$this->conn->getData($sql1);
  2081. $car_user_id = $recordcar[0]['car_user_id'];
  2082.  
  2083. if($favourite=='1'){
  2084. $sql="select * from tbl_favourite where favourite_car_ID='".$carID."' and favourite_user_ID='".$userID."'";
  2085. $record=$this->conn->getData($sql);
  2086. if(!empty($record)){
  2087. $data['favourite_datetime'] = date("Y-m-d H:i:s");
  2088. $data['favourite_status'] = '1';
  2089.  
  2090. $this->conn->updatetabletwobyid('tbl_favourite','favourite_car_ID',$carID,'favourite_user_ID',$userID,$data);
  2091. $post=array('status'=>'true','message'=>add_favourite,'favourite_status'=>$favourite);
  2092. }else {
  2093. $datetime = date("Y-m-d H:i:s");
  2094. $insert = $this -> conn -> insertnewrecords(
  2095. 'tbl_favourite',
  2096. 'favourite_car_ID,
  2097. favourite_user_ID,
  2098. favourite_datetime,car_user_id',
  2099. '"' . $carID . '",
  2100. "' . $userID . '",
  2101. "' . $datetime . '",
  2102. "' . $car_user_id . '"
  2103. '
  2104. );
  2105. if($insert>0){
  2106. $post=array('status'=>'true','message'=>add_favourite,'favourite_status'=>$favourite);
  2107. } else{
  2108. $post=array('status'=>'false','message'=>Internal_server_error);
  2109. }
  2110. }
  2111. } else if($favourite=='2') {
  2112. $data['favourite_status']='2';
  2113. $this->conn->updatetabletwobyid('tbl_favourite','favourite_car_ID',$carID,'favourite_user_ID',$userID,$data);
  2114. $post=array(
  2115. 'status'=>'true',
  2116. 'message'=>"Adicionado aos favoritos com sucesso!",
  2117. 'favourite_status'=>$favourite
  2118. );
  2119. }
  2120. } else{
  2121. $post=array(
  2122. 'status'=>'false',
  2123. 'message'=>Missing_Parameter,
  2124. 'car_id'=>$_REQUEST['car_id'],
  2125. 'user_id'=>$_REQUEST['user_id'],
  2126. 'favourite_status'=>$_REQUEST['favourite_status']
  2127. );
  2128. }
  2129.  
  2130. echo $this -> json($post);
  2131. }
  2132.  
  2133. function filter_cars(){
  2134. header("Content-Type: text/html;charset=utf-8");
  2135. header('Content-Type: application/json;charset=utf-8');
  2136. // $carSearch= 'gasolina,preto,coupé';
  2137. // if(!empty($carSearch)){
  2138. if(!empty($_REQUEST['car_search'])){
  2139. $sql="
  2140. SELECT * FROM tbl_cars
  2141. jOIN tbl_carYear ON tbl_carYear.carYear_id=tbl_cars.car_Year
  2142. jOIN tbl_carFuel ON tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
  2143. jOIN tbl_carGear ON tbl_carGear.carGear_id=tbl_cars.car_Gear
  2144. jOIN tbl_brand ON tbl_brand.brand_id=tbl_cars.car_Brand
  2145. jOIN tbl_carVersion ON tbl_carVersion.carVersion_id=tbl_cars.car_Version
  2146. jOIN tbl_blindagem ON tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
  2147. jOIN tbl_carModel ON tbl_carModel.carModel_id=tbl_cars.car_model
  2148. JOIN tbl_CarType ON tbl_CarType.carType_id=tbl_cars.car_category_id
  2149. WHERE tbl_cars.car_status=1
  2150. AND tbl_carYear.carYear_status=1
  2151. AND tbl_carFuel.carFuel_status=1
  2152. AND tbl_carGear.carGear_status=1
  2153. AND tbl_brand.brand_status=1
  2154. AND tbl_carVersion.carVersion_status=1
  2155. AND tbl_blindagem.blindagem_status=1
  2156. AND tbl_carModel.car_Model_status=1
  2157. AND tbl_CarType.carType_status=1
  2158. ORDER BY RAND()
  2159. ";
  2160.  
  2161. $car_info=$this->conn->getData($sql);
  2162. foreach($car_info as $key1 => $product){
  2163. $car_color=$product['car_color'];
  2164. $car_color=explode(",",$car_color);
  2165. $car_color_string="";
  2166.  
  2167. foreach($car_color as $key => $value){
  2168. $color_id=$value;
  2169. $query22="select * from tbl_carColor where carColor_id='".$color_id."'";
  2170. $record2=$this->conn->getData($query22);
  2171. $car_color_string.=$record2[0]['carColor_name'].',';
  2172. }
  2173.  
  2174. $car_color_string = rtrim($car_color_string,',');
  2175. $car_info[$key1]['car_color_name']=$car_color_string;
  2176. }
  2177.  
  2178. // $car_search=$carSearch;
  2179. $car_search=$_REQUEST['car_search'];
  2180. $car_search=explode(",",$car_search);
  2181.  
  2182.  
  2183. foreach($car_search as $value){
  2184. $info=strtolower($value);
  2185. $key=$this->myfunction($car_info,$info);
  2186. $key_data[]=$key;
  2187. }
  2188.  
  2189.  
  2190. $countData = count($key_data);
  2191. if ($countData<= 1) {
  2192. $oneDimensionalArray = call_user_func_array('array_merge', $key_data);
  2193. } else{
  2194. $oneDimensionalArray = call_user_func_array('array_intersect', $key_data);
  2195. }
  2196. $oneDimensionalArray = array_unique($oneDimensionalArray);
  2197.  
  2198.  
  2199. foreach($oneDimensionalArray as $value){
  2200. $car_detail[]=$car_info[$value];
  2201. }
  2202.  
  2203. foreach ($car_detail as $key => $value) {
  2204. $car_id = $value['car_id'];
  2205. $car_user_id = $value['car_user_id'];
  2206. $query_subcription="select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
  2207. $record_subcription=$this->conn->getData($query_subcription);
  2208.  
  2209. if(!empty($record_subcription)){
  2210. $end_date=$record_subcription[0]['end_date'];
  2211. $date=date("Y-m-d h:i:s a");
  2212.  
  2213. if(!($date<=$end_date)){
  2214. $value['car_featured']='2';
  2215. }
  2216. } else {
  2217. $value['car_featured']='2';
  2218. }
  2219.  
  2220.  
  2221. $car_name = $value['car_name'];
  2222. $car_name = html_entity_decode($car_name);
  2223. $car_fullname = $value['car_fullname'];
  2224. $car_fullname = html_entity_decode($car_fullname);
  2225. $car_price = $value['car_price'];
  2226. $car_model = $value['carYear_name'];
  2227. $car_featured = $value['car_featured'];
  2228. $carFuel_type = $value['carFuel_type'];
  2229. $carFuel_type = html_entity_decode($carFuel_type);
  2230. $carVersion_name = $value['carVersion_name'];
  2231. $carType_name = $value['carType_name'];
  2232. $carType_name = html_entity_decode($carType_name);
  2233. $carGear_type = $value['carGear_type'];
  2234. $car_featured = $value['car_featured'];
  2235. $brand_images = brand_images.$value['brand_image'];
  2236. $car_images = $value['car_profile_pick'];
  2237. $car_color_name = $value['car_color_name'];
  2238. $carVersion_name = $value['carVersion_name'];
  2239. $Resellerprice = $value['car_Reseller_price'];
  2240.  
  2241. $response[] = array(
  2242. 'car_id' => $car_id,
  2243. 'car_name' => $car_name,
  2244. 'car_fullname'=>$car_fullname,
  2245. 'car_price'=>$car_price,
  2246. 'car_model'=>$car_model,
  2247. 'car_images'=>car_images.$car_images,
  2248. 'car_featured'=>$car_featured,
  2249. 'fuel_type'=>$carFuel_type,
  2250. 'gear_type'=>$carGear_type,
  2251. 'reseller_price'=>$Resellerprice,
  2252. 'carVersion_name'=>$carVersion_name,
  2253. 'favourite_status'=>$favourite_status,
  2254. 'brand_images'=>$brand_images,
  2255. 'car_color_name'=>$car_color_name,
  2256. 'carVersion_name'=>$carVersion_name,
  2257. 'carType_name'=>$carType_name
  2258. );
  2259. }
  2260.  
  2261. if (!empty($response)) {
  2262. $post = array("status" => 'true', "message" => count($response)." ".Car_found,'cars'=>$response);
  2263. } else {
  2264. $post = array('status' => "false", "message" => No_Record_Found);
  2265. }
  2266.  
  2267. echo $this -> json($post);
  2268. die();
  2269.  
  2270. }
  2271.  
  2272. if(
  2273. !empty($_REQUEST['brand_type'])
  2274. || !empty($_REQUEST['blindagem_filter'])
  2275. || !empty($_REQUEST['carColor_filter'])
  2276. || !empty($_REQUEST['carFuel_filter'])
  2277. || !empty($_REQUEST['carModel_filter'])
  2278. || !empty($_REQUEST['carVersion_filter'])
  2279. || !empty($_REQUEST['carGear_filter'])
  2280. || !empty($_REQUEST['carYear_filter'])
  2281. || !empty($_REQUEST['price_filter'])
  2282. ){
  2283.  
  2284.  
  2285. $user_id=$_REQUEST['user_id'];
  2286. $priceFilterType = $_REQUEST['priceFilterType'];
  2287. if($priceFilterType=='1'){
  2288. $orderBy="Asc";
  2289. } else if ($priceFilterType=='2'){
  2290. $orderBy="Desc";
  2291. }
  2292.  
  2293.  
  2294. $sql='';
  2295.  
  2296.  
  2297. $price_filter = $_REQUEST['price_filter'];
  2298. if($price_filter ==1) {
  2299. $low_price = $_REQUEST['low_price'];
  2300. $high_price = $_REQUEST['high_price'];
  2301. if(!empty($sql)){
  2302. $sql.='and car_price between "'.$low_price.'" and "'.$high_price.'"';
  2303. } else {
  2304. $sql.='car_price between "'.$low_price.'" and "'.$high_price.'"';
  2305. }
  2306. }
  2307.  
  2308.  
  2309. $brand_type = $_REQUEST['brand_type'];
  2310. if($brand_type=='1'){
  2311. $brand_id = $_REQUEST['brand_id'];
  2312. if(!empty($sql)){
  2313. $sql.='and car_Brand="'.$brand_id.'"';
  2314. } else {
  2315. $sql.='car_Brand="'.$brand_id.'"';
  2316. }
  2317. }
  2318.  
  2319.  
  2320. $car_type = $_REQUEST['car_type'];
  2321. if($car_type=='1'){
  2322. $car_type_id = $_REQUEST['car_type_id'];
  2323. if(!empty($sql)){
  2324. $sql.='and car_category_id="'.$car_type_id.'"';
  2325. } else {
  2326. $sql.='car_category_id="'.$car_type_id.'"';
  2327. }
  2328. }
  2329.  
  2330.  
  2331. $blindagem_filter = $_REQUEST['blindagem_filter'];
  2332. if($blindagem_filter=='1') {
  2333. $blindagem = $_REQUEST['blindagem'];
  2334. if(!empty($sql)){
  2335. $sql.='and car_blindagem="'.$blindagem.'"';
  2336. } else {
  2337. $sql.='car_blindagem="'.$blindagem.'"';
  2338. }
  2339. }
  2340.  
  2341.  
  2342. $carColor_filter = $_REQUEST['carColor_filter'];
  2343. if($carColor_filter=='1') {
  2344. $carColor = $_REQUEST['carColor'];
  2345. if(!empty($sql)){
  2346. $sql.='and car_color LIKE "'.'%'.$carColor.'%'.'"';
  2347. } else {
  2348. $sql.='car_color LIKE "'.'%'.$carColor.'%'.'"';
  2349. }
  2350. }
  2351.  
  2352.  
  2353. $carFuel_filter = $_REQUEST['carFuel_filter'];
  2354. if($carFuel_filter=='1'){
  2355. $carFuel = $_REQUEST['carFuel'];
  2356. if(!empty($sql)) {
  2357. $sql.='and car_Fuel="'.$carFuel.'"';
  2358. } else {
  2359. $sql.='car_Fuel="'.$carFuel.'"';
  2360. }
  2361. }
  2362.  
  2363.  
  2364. $carModel_filter = $_REQUEST['carModel_filter'];
  2365. if($carModel_filter=='1'){
  2366. $carModel = $_REQUEST['carModel'];
  2367. if(!empty($sql)){
  2368. $sql.='and car_model="'.$carModel.'"';
  2369. } else {
  2370. $sql.='car_model="'.$carModel.'"';
  2371. }
  2372. }
  2373.  
  2374.  
  2375. $carVersion_filter = $_REQUEST['carVersion_filter'];
  2376. if($carVersion_filter=='1'){
  2377. $carVersion = $_REQUEST['carVersion'];
  2378. if(!empty($sql)){
  2379. $sql.='and car_Version="'.$carVersion.'"';
  2380. } else {
  2381. $sql.='car_Version="'.$carVersion.'"';
  2382. }
  2383. }
  2384.  
  2385. $carGear_filter = $_REQUEST['carGear_filter'];
  2386. if($carGear_filter=='1'){
  2387. $carGear = $_REQUEST['carGear'];
  2388. if(!empty($sql)){
  2389. $sql.='and car_Gear="'.$carGear.'"';
  2390. } else {
  2391. $sql.='car_Gear="'.$carGear.'"';
  2392. }
  2393. }
  2394.  
  2395.  
  2396. $carYear_filter = $_REQUEST['carYear_filter'];
  2397. if($carYear_filter=='1'){
  2398. $carYear = $_REQUEST['carYear'];
  2399. if(!empty($sql)) {
  2400. $sql.='and car_Year="'.$carYear.'"';
  2401. } else {
  2402. $sql.='car_Year="'.$carYear.'"';
  2403. }
  2404. }
  2405.  
  2406.  
  2407. if(!empty($sql)){
  2408. $query="
  2409. SELECT * FROM tbl_cars
  2410. jOIN tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
  2411. jOIN tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
  2412. jOIN tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
  2413. jOIN tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
  2414. jOIN tbl_carVersion on tbl_carVersion.carVersion_id=tbl_cars.car_Version
  2415. jOIN tbl_blindagem on tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
  2416. jOIN tbl_carModel on tbl_carModel.carModel_id=tbl_cars.car_model
  2417. WHERE ".$sql."
  2418. AND tbl_cars.car_status=1
  2419. AND tbl_carYear.carYear_status=1
  2420. AND tbl_carFuel.carFuel_status=1
  2421. AND tbl_carGear.carGear_status=1
  2422. AND tbl_brand.brand_status=1
  2423. AND tbl_carVersion.carVersion_status=1
  2424. AND tbl_blindagem.blindagem_status=1
  2425. AND tbl_carModel.car_Model_status=1
  2426. ORDER BY car_price ".$orderBy
  2427. ;
  2428. } else {
  2429. $query="
  2430. SELECT * FROM tbl_cars
  2431. jOIN tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
  2432. jOIN tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
  2433. jOIN tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
  2434. jOIN tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
  2435. jOIN tbl_carVersion on tbl_carVersion.carVersion_id=tbl_cars.car_Version
  2436. jOIN tbl_blindagem on tbl_blindagem.blindagem_id=tbl_cars.car_blindagem
  2437. jOIN tbl_carModel on tbl_carModel.carModel_id=tbl_cars.car_model
  2438. WHERE tbl_cars.car_status=1
  2439. AND tbl_carYear.carYear_status=1
  2440. AND tbl_carFuel.carFuel_status=1
  2441. AND tbl_carGear.carGear_status=1
  2442. AND tbl_brand.brand_status=1
  2443. AND tbl_carVersion.carVersion_status=1
  2444. AND tbl_blindagem.blindagem_status=1
  2445. AND tbl_carModel.car_Model_status=1
  2446. ORDER BY car_price ".$orderBy
  2447. ;
  2448. }
  2449. // print_r($query); die();
  2450. // print_r($query);
  2451.  
  2452.  
  2453.  
  2454. $record=$this->conn->getData($query);
  2455. if(!empty($record)){
  2456. foreach ($record as $key => $value){
  2457. $car_id = $value['car_id'];
  2458. $sql1="select * from tbl_favourite where favourite_car_ID='".$car_id."' and favourite_user_ID='".$user_id."'";
  2459. $record1=$this->conn->getData($sql1);
  2460.  
  2461. if(!empty($record1)){
  2462. $favourite_status=$record1[0]['favourite_status'];
  2463. if($favourite_status==1){
  2464. $favourite_status='1';
  2465. } else {
  2466. $favourite_status='2';
  2467. }
  2468. } else {
  2469. $favourite_status='2';
  2470. }
  2471.  
  2472. $car_user_id = $value['car_user_id'];
  2473. $query_subcription="select * from tbl_subcription_payment where sub_pay_userID='".$car_user_id."' ORDER BY sub_payment_id DESC";
  2474. $record_subcription=$this->conn->getData($query_subcription);
  2475. if(!empty($record_subcription)) {
  2476. $end_date=$record_subcription[0]['end_date'];
  2477. $date=date("Y-m-d h:i:s a");
  2478.  
  2479. if(!($date<=$end_date)){
  2480. $value['car_featured']='2';
  2481. }
  2482. } else {
  2483. $value['car_featured']='2';
  2484. }
  2485.  
  2486.  
  2487. $car_id = $value['car_id'];
  2488. $car_name = html_entity_decode($value['car_name']);
  2489. $car_fullname = html_entity_decode($value['car_fullname']);
  2490. $car_price = $value['car_price'];
  2491. $car_model = $value['carYear_name'];
  2492. $car_featured = $value['car_featured'];
  2493. $carFuel_type = html_entity_decode($value['carFuel_type']);
  2494. $carGear_type = $value['carGear_type'];
  2495. $car_featured = $value['car_featured'];
  2496. $car_images = explode(",",$value['car_images']);
  2497. $Resellerprice = $value['car_Reseller_price'];
  2498. $carVersion_name = $value['carVersion_name'];
  2499. $brand_images = brand_images.$value['brand_image'];
  2500.  
  2501. // $r=number_format($Resellerprice);
  2502.  
  2503. $response[] = array(
  2504. 'car_id' => $car_id,
  2505. 'car_name' => $car_name,
  2506. 'car_fullname'=>$car_fullname,
  2507. 'car_price'=>$car_price,
  2508. 'car_model'=>$car_model,
  2509. 'car_images'=>car_images.$car_images[0],
  2510. 'car_featured'=>$car_featured,
  2511. 'fuel_type'=>$carFuel_type,
  2512. 'gear_type'=>$carGear_type,
  2513. 'reseller_price'=>$Resellerprice,
  2514. 'carVersion_name'=>$carVersion_name,
  2515. 'brand_images'=>$brand_images,
  2516. 'favourite_status'=>$favourite_status
  2517. );
  2518. }
  2519.  
  2520. $post=array(
  2521. 'status'=>'true',
  2522. 'message'=>count($response)." ".Car_found,
  2523. 'cars'=>$response
  2524. );
  2525.  
  2526. } else {
  2527. $post=array('status'=>'false','message'=>No_CAR_FOUND);
  2528. }
  2529. } else {
  2530. $post=array(
  2531. 'status'=>'false',
  2532. 'message'=>Missing_Parameter,
  2533. 'blindagem_filter'=>$_REQUEST['blindagem_filter'],
  2534. 'carColor_filter'=>$_REQUEST['carColor_filter'],
  2535. 'carFuel_filter'=>$_REQUEST['carFuel_filter'],
  2536. 'carModel_filter'=>$_REQUEST['carModel_filter'],
  2537. 'carVersion_filter'=>$_REQUEST[''],
  2538. 'carYear_filter'=>$_REQUEST['carYear_filter'],
  2539. 'reseller_price'=>$Resellerprice
  2540. );
  2541. }
  2542.  
  2543. echo $this -> json($post);
  2544. }
  2545.  
  2546. function favourite_car_list() {
  2547. header("Content-Type: text/html;charset=utf-8");
  2548. // setlocale(LC_MONETARY,"en_US");
  2549. // money_format($car_price);
  2550. $user_id=$_REQUEST['user_id'];
  2551.  
  2552. if(!empty($user_id)){
  2553. // $state = $this -> conn -> get_table_row_byidvalue('tbl_cars', 'car_status', 1);
  2554. $sql1="
  2555. SELECT * FROM tbl_cars
  2556. join tbl_carYear on tbl_carYear.carYear_id=tbl_cars.car_Year
  2557. join tbl_carFuel on tbl_carFuel.carFuel_id =tbl_cars.car_Fuel
  2558. join tbl_carGear on tbl_carGear.carGear_id=tbl_cars.car_Gear
  2559. join tbl_brand on tbl_brand.brand_id=tbl_cars.car_Brand
  2560. join tbl_favourite on tbl_favourite.favourite_car_ID=tbl_cars.car_id
  2561. where tbl_favourite.favourite_status = 1
  2562. AND favourite_user_ID ='".$user_id."'
  2563. ";
  2564.  
  2565. $record=$this->conn->getData($sql1);
  2566.  
  2567.  
  2568. foreach ($record as $key => $value){
  2569. $car_user_id = $value['car_user_id'];
  2570. $query_subcription ="
  2571. SELECT * FROM tbl_subcription_payment
  2572. where sub_pay_userID='".$car_user_id."'
  2573. ORDER BY sub_payment_id DESC
  2574. ";
  2575. $record_subcription=$this->conn->getData($query_subcription);
  2576. if(!empty($record_subcription)){
  2577. $end_date=$record_subcription[0]['end_date'];
  2578. $date=date("Y-m-d h:i:s a");
  2579.  
  2580. if(!($date<=$end_date)){
  2581. $value['car_featured']='2';
  2582. }
  2583. } else{
  2584. $value['car_featured']='2';
  2585. }
  2586.  
  2587. $car_id = $value['car_id'];
  2588. $car_name = $value['car_name'];
  2589. $car_name = html_entity_decode($car_name);
  2590. $car_fullname = $value['car_fullname'];
  2591. $car_fullname = html_entity_decode($car_fullname);
  2592. $car_price = $value['car_price'];
  2593. $car_model = $value['carYear_name'];
  2594. $car_featured = $value['car_featured'];
  2595. $carFuel_type = $value['carFuel_type'];
  2596. $carFuel_type = html_entity_decode($carFuel_type);
  2597. $carGear_type = $value['carGear_type'];
  2598. $car_featured = $value['car_featured'];
  2599. $favourite_status = $value['favourite_status'];
  2600. $car_images = explode(",",$value['car_images']);
  2601. $brand_images = brand_images.$value['brand_image'];
  2602. // $car_name = $value['car_name'];
  2603. // $car_fullname = $value['car_fullname'];
  2604. // $car_price = $this->moneyFormatIndia($value['car_price']);
  2605. // $Resellerprice = $this->moneyFormatIndia($value['car_Reseller_price']);
  2606.  
  2607. $Resellerprice = $value['car_Reseller_price'];
  2608. $response[] = array(
  2609. 'car_id' => $car_id,
  2610. 'car_name' => $car_name,
  2611. 'car_fullname'=>$car_fullname,
  2612. 'car_price'=>$car_price,
  2613. 'car_model'=>$car_model,
  2614. 'car_images'=>car_images.$car_images[0],
  2615. 'car_featured'=>$car_featured,
  2616. 'fuel_type'=>$carFuel_type,
  2617. 'gear_type'=>$carGear_type,
  2618. 'reseller_price'=>$Resellerprice,
  2619. 'favourite_status'=>$favourite_status,
  2620. 'brand_images'=>$brand_images
  2621. );
  2622. }
  2623.  
  2624. if (!empty($response)) {
  2625. $post = array("status" => "true", "message" => count($response)." ".Car_found,'cars'=>$response);
  2626. } else{
  2627. $post = array('status' => "false", "message" => No_Record_Found);
  2628. }
  2629. } else{
  2630. $post = array("status" => "false", "message" => "parâmetro faltando");
  2631. }
  2632.  
  2633. echo $this -> json($post);
  2634. }
  2635.  
  2636. function add_interest() {
  2637. if(!empty($_REQUEST['car_id']) && !empty($_REQUEST['user_id']) && !empty($_REQUEST['interest_status'])) {
  2638. $carID = $_REQUEST['car_id'];
  2639. $userID = $_REQUEST['user_id'];
  2640. $interest = $_REQUEST['interest_status'];
  2641. $sql1="select car_user_id from tbl_cars where car_id='".$carID."'";
  2642. $recordcar=$this->conn->getData($sql1);
  2643. $car_user_id = $recordcar[0]['car_user_id'];
  2644.  
  2645. $carname = $this -> conn -> get_table_row_byidvalue('tbl_cars', 'car_id',$carID);
  2646. $userData1 = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_id',$userID);
  2647. $unm=$userData1[0]['user_name'];
  2648. $uphn=$userData1[0]['user_phone'];
  2649. $carname=$carname[0]['car_name'];
  2650. // print_r($userData1[0]['user_name']); die();
  2651.  
  2652. if($interest=='1'){
  2653. $sql="select * from tbl_interest where interest_car_ID='".$carID."' and interest_user_ID='".$userID."'";
  2654. $record=$this->conn->getData($sql);
  2655. if(!empty($record)){
  2656. $data['interest_datetime'] = date("Y-m-d H:i:s");
  2657. $data['interest_status'] = '1';
  2658.  
  2659. $this->conn->updatetabletwobyid('tbl_interest','interest_car_ID',$carID,'interest_user_ID',$userID,$data);
  2660. $user = $this -> conn -> get_table_row_byidvalue('shop_profile', 'user_id',$car_user_id);
  2661.  
  2662. foreach ($user as $key => $value) {
  2663. $user_email = $value['email'];
  2664. $user_phone = $value['phone'];
  2665. }
  2666.  
  2667. $user_phone=$user_phone;
  2668. $sms_msg="Alguém está interessado em seu carro ".$carname.", por favor, verifique os detalhes em Admin,Comercial Nome:".$unm.",Comercial No:".$uphn.".";
  2669.  
  2670. $this->send_sms($user_phone,$sms_msg);
  2671. $to = $user_email;
  2672. $subject = "Interesse em Carro";
  2673. $txt = "Alguém interessado em seu carro.";
  2674. $txt='
  2675. <html>
  2676. <head>
  2677. <title> Email</title>
  2678. <style>
  2679. .button {
  2680. background-color: #ff6600;
  2681. border: none;
  2682. color: white;
  2683. padding: 12px 72px;
  2684. text-align: center;
  2685. text-decoration: none;
  2686. display: inline-block;
  2687. font-size: 16px;
  2688. margin: 25px 2px;
  2689. cursor: pointer;
  2690. }
  2691. </style>
  2692. </head>
  2693. <body style="" >
  2694. <table cellpadding="0" cellspacing="0" width="540px" align="center" style="border:1px solid #ccc;
  2695. border-top-left-radius: 18px;border-top-right-radius:18px;font-family:"Ubuntu",sans-serif!important; font-family:"Ubuntu",sans-serif!important;">
  2696. <tr>
  2697. <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;">
  2698. Interesse em Carro "'.$carname.'"
  2699. </td>
  2700. </tr>
  2701. <tr>
  2702. <td style="font-size: 25px;padding: 15px 55px;text-align: center; color:#777777;">
  2703. Uma pessoa se interessou em seu carro!
  2704. </td>
  2705. </tr>
  2706.  
  2707. <tr>
  2708. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  2709. Comercial Nome:"'.$unm.'",Comercial No:"'.$uphn.'" !
  2710. </td>
  2711. </tr>
  2712. <tr>
  2713. Comercial Nome:".$unm.",Comercial No:".$uphn."
  2714. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  2715. caso você não tenha alterado sua senha, contate a equipe de suporte
  2716. </td>
  2717. </tr>
  2718. <tr>
  2719. <th>
  2720. <a href="http://cms.buscarsbr.com.br/user_login" class="button">ACESSAR PAINEL</a>
  2721. </th>
  2722. </tr>
  2723. <tr >
  2724. <td style="text-align:center; padding:15px;">
  2725. <img width="150" src="'.user_images.'logo1.png" />
  2726. </td>
  2727. </tr>
  2728. </table>
  2729. </body>
  2730. </html>
  2731. ';
  2732.  
  2733. $headers = "MIME-Version: 1.0" . "\r\n";
  2734. $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  2735.  
  2736. // // More headers
  2737. $headers .= 'From: "Buscar" <app@buscarsbr.com.br>' . "\r\n";
  2738.  
  2739. $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
  2740. // mail($to,$subject,$txt,$headers);
  2741.  
  2742. $post=array('status'=>'true','message'=>add_interest,'interest'=>$interest);
  2743. } else{
  2744. $datetime = date("Y-m-d H:i:s");
  2745. $insert = $this -> conn -> insertnewrecords('tbl_interest', 'interest_car_ID, interest_user_ID, interest_datetime, car_user_id', '"' . $carID . '","' . $userID . '","' . $datetime . '","' . $car_user_id . '"');
  2746. if($insert>0){
  2747. $user = $this -> conn -> get_table_row_byidvalue('shop_profile', 'user_id',$car_user_id);
  2748.  
  2749. foreach ($user as $key => $value) {
  2750. $user_email = $value['email'];
  2751. $user_phone = $value['phone'];
  2752. }
  2753.  
  2754. $user_phone=$user_phone;
  2755. $sms_msg="Alguém está interessado em seu carro ".$carname.", por favor, verifique os detalhes em Admin,Comercial Nome:".$unm.",Comercial No:".$uphn.".";
  2756.  
  2757. $this->send_sms($user_phone,$sms_msg);
  2758. $to = $user_email;
  2759. $subject = "Interesse em Carro";
  2760. $txt = "intrest uma pessoa em seu carro";
  2761. $txt='
  2762. <html>
  2763. <head>
  2764. <title> Email</title>
  2765. <style>
  2766. .button {
  2767. background-color: #ff6600;
  2768. border: none;
  2769. color: white;
  2770. padding: 12px 72px;
  2771. text-align: center;
  2772. text-decoration: none;
  2773. display: inline-block;
  2774. font-size: 16px;
  2775. margin: 25px 2px;
  2776. cursor: pointer;
  2777. }
  2778. </style>
  2779. </head>
  2780.  
  2781. <body style="" >
  2782. <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;">
  2783. <tr>
  2784. <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;">
  2785. Interesse em Carro "'.$carname.'"
  2786. </td>
  2787. </tr>
  2788. <tr>
  2789. <td style="font-size: 25px;padding: 15px 55px;text-align: center; color:#777777;">
  2790. Uma pessoa se interessou em seu carro!
  2791. </td>
  2792. </tr>
  2793. <tr>
  2794. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  2795. Comercial Nome:"'.$unm.'",Comercial No:"'.$uphn.'" !
  2796. </td>
  2797. </tr>
  2798. <tr>
  2799. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  2800. caso você não tenha alterado sua senha, contate a equipe de suporte
  2801. </td>
  2802. </tr>
  2803. <tr>
  2804. <th>
  2805. <a href="http://cms.buscarsbr.com.br/user_login" class="button">ACESSAR PAINEL</a>
  2806. </th>
  2807. </tr>
  2808. <tr >
  2809. <td style="text-align:center; padding:15px;">
  2810. <img width="150" src="'.user_images.'logo1.png" />
  2811. </td>
  2812. </tr>
  2813. </table>
  2814. </body>
  2815. </html>
  2816. ';
  2817.  
  2818.  
  2819. // $headers = "MIME-Version: 1.0" . "\r\n";
  2820. // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  2821.  
  2822. // // More headers
  2823. // $headers .= 'From: "Buscar" <app@buscarsbr.com.br>' . "\r\n";
  2824.  
  2825. $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
  2826. $post=array('status'=>'true','message'=>add_interest,'interest'=>$interest);
  2827. } else{
  2828. $post=array('status'=>'false','message'=>Internal_server_error);
  2829. }
  2830. }
  2831. } else if($interest=='2'){
  2832. $data['interest_status']='2';
  2833. $this->conn->updatetabletwobyid('tbl_interest','interest_car_ID',$carID,'interest_user_ID',$userID,$data);
  2834. $post=array('status'=>'true','message'=>remove_interest,'interest'=>$interest);
  2835. }
  2836. } else{
  2837. $post=array(
  2838. 'status'=>'false',
  2839. 'message'=>Missing_Parameter,
  2840. 'car_id'=>$_REQUEST['car_id'],
  2841. 'user_id'=>$_REQUEST['user_id'],
  2842. 'interest_status'=>$_REQUEST['interest_status']
  2843. );
  2844. }
  2845.  
  2846. echo $this -> json($post);
  2847. }
  2848.  
  2849. function subscription_list() {
  2850. $state = $this -> conn -> get_table_row_byidvalue('tbl_subscription', 'subscription_status', 1);
  2851. foreach ($state as $key => $value) {
  2852. $subscription_id = $value['subscription_id'];
  2853. $subscription_type = $value['subscription_type'];
  2854. $subscription_name = $value['subscription_name'];
  2855. $subscription_name = html_entity_decode($subscription_name);
  2856. $subscription_amount = $value['subscription_amount'];
  2857. $subscription_validity = $value['subscription_validity'];
  2858. $subscription_desc = html_entity_decode($value['subscription_desc']);
  2859.  
  2860. $sub_pay_userID=$_REQUEST['sub_pay_userID'];
  2861. $query="select * from tbl_subcription_payment where sub_pay_userID='".$sub_pay_userID."' ORDER BY sub_payment_id DESC";
  2862. $record=$this->conn->getData($query);
  2863.  
  2864. $sub_planID=$record[0]['sub_planID'];
  2865. if($subscription_id ==$sub_planID){
  2866. $sub_pay_status = 1;
  2867. } else{
  2868. $sub_pay_status = 2;
  2869. }
  2870.  
  2871. $response[] = array(
  2872. 'subscription_id' => $subscription_id,
  2873. 'subscription_name' => $subscription_name,
  2874. 'subscription_amount'=>$subscription_amount,
  2875. 'subscription_validity'=>$subscription_validity,
  2876. 'subscription_desc'=>$subscription_desc,
  2877. 'subscription_type'=>$subscription_type,
  2878. 'sub_pay_status'=>$sub_pay_status
  2879. );
  2880. }
  2881.  
  2882. if (!empty($response)) {
  2883. $post = array("status" => "true", "message" => 'Lista de inscrição encontrada','subscription'=>$response);
  2884. } else {
  2885. $post = array('status' => "false", "message" => No_Record_Found);
  2886. }
  2887.  
  2888. echo $this -> json($post);
  2889. }
  2890.  
  2891.  
  2892.  
  2893. // estrutura para notificacao nativa
  2894. // tarefa :: integrar firebase cloud msg
  2895.  
  2896. function android_notification() {
  2897. // function android_notification($gcm_id, $msg) {
  2898. // $gcm_id = '15s158123';
  2899. // $msg = "Teste!!";
  2900. if (!empty($gcm_id)) {
  2901. $registrationIds = array($gcm_id);
  2902. $message = array("msg" => $msg);
  2903. $GOOGLE_API_KEY = Api_key;
  2904.  
  2905. $fields = array(
  2906. 'registration_ids' => $registrationIds,
  2907. 'data' => $message
  2908. );
  2909.  
  2910. $headers = array(
  2911. 'Authorization: key=' . $GOOGLE_API_KEY,
  2912. 'Content-Type: application/json'
  2913. );
  2914.  
  2915. $ch = curl_init();
  2916. curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
  2917. curl_setopt($ch, CURLOPT_POST, true);
  2918. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  2919. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2920. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  2921. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
  2922. $result = curl_exec($ch);
  2923. curl_close($ch);
  2924.  
  2925. print_r($result);die;
  2926.  
  2927. // return $result;
  2928. }
  2929. }
  2930.  
  2931. // processo de pagamento
  2932.  
  2933. function authentication() {
  2934. if(!empty($_REQUEST['authentication']) && !empty($_REQUEST['user_id']))
  2935. {
  2936.  
  2937. $current_date=date("Y-m-d H:i:s");
  2938. $authentication = $_REQUEST['authentication'];
  2939. $user_id = $_REQUEST['user_id'];
  2940. $data['authentication'] = $authentication;
  2941.  
  2942. $refresh_token=$this->payment_process($authentication);
  2943. $refresh_token_final=json_decode($refresh_token, True);
  2944. $data['payment_details']=$refresh_token;
  2945. $update_toekn = $this -> conn -> updatetablebyid('tbl_user', 'user_id', $user_id, $data);
  2946.  
  2947.  
  2948. $t_id=json_decode($refresh_token_final['transactionDetails'],TRUE);
  2949.  
  2950. //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']))
  2951.  
  2952. //$insert = $this -> conn -> insertnewrecords('tbl_payment_details', 'id,user_id,access_token,refresh_token,authentication_code,transaction_details', $vals);
  2953.  
  2954.  
  2955.  
  2956. $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']);
  2957.  
  2958. $sql2= " INSERT INTO tbl_payment_details_log (user_id, transaction_details, payment_date)
  2959. VALUES ('".$_REQUEST['user_id']."', '".$refresh_token."', '".$current_date."')";
  2960. $insert=$this->conn->insert($sql2);
  2961.  
  2962. $post=array('status'=>'true','message'=>'Update successfully','transaction_id'=>$t_id['id']);
  2963.  
  2964. }
  2965. else{
  2966. $post=array('status'=>'false','message'=>'Invalid peremeter');
  2967. }
  2968. echo $this -> json($post);
  2969. }
  2970.  
  2971.  
  2972. // pagamento recursivo.
  2973.  
  2974.  
  2975. function recursive_payment_process(){
  2976.  
  2977. $end_date = date('Y-m-d');
  2978.  
  2979. $current_date=date("Y-m-d H:i:s");
  2980. $new_end_date = date('Y-m-d', strtotime("+1 months", strtotime($current_date)));
  2981.  
  2982.  
  2983.  
  2984. //$sql="select * from tbl_subcription_payment GROUP BY `sub_pay_userID`
  2985. //ORDER BY `sub_payment_id` DESC";
  2986.  
  2987. /*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 (
  2988. SELECT MAX(`sub_payment_id`)
  2989. FROM `tbl_subcription_payment`
  2990. GROUP BY `sub_pay_userID`
  2991. ) AND `end_date`='".$end_date."' AND `sub_plan_pai_status`=1";
  2992. die();*/
  2993.  
  2994.  
  2995. $sql="select * from `tbl_subcription_payment` WHERE `sub_payment_id` IN (
  2996. SELECT MAX(`sub_payment_id`)
  2997. FROM `tbl_subcription_payment`
  2998. GROUP BY `sub_pay_userID`
  2999. ) AND `end_date`='".$end_date."' AND `sub_plan_pai_status`=1";
  3000.  
  3001.  
  3002. $records=$this->conn->getData($sql);
  3003. if(count($records) > 0){
  3004. foreach($records as $record){
  3005. $sqlu="SELECT * FROM `tbl_user` WHERE `user_id`='".$record['sub_pay_userID']."'";
  3006. $user_details=$this->conn->getData($sqlu);
  3007.  
  3008. //print_r($user_details);die();
  3009.  
  3010.  
  3011. if($record['refresh_token'] != ""){
  3012. //print_r($user_details[0]['user_email']);die();
  3013. //Refresh Token and payment
  3014.  
  3015. $token=$this->refresh_token($record['refresh_token']);
  3016. $response=$this->payment_init($token);
  3017.  
  3018.  
  3019. $final_res=array();
  3020. $final_res['token']=$token;
  3021. $final_res['refresh_token']=$record['refresh_token'];
  3022. //$final_res['authentication']=$authentication;
  3023. $final_res['transactionDetails']=$response;
  3024. $return_res=json_encode($final_res);
  3025.  
  3026. $data['payment_details']=$return_res;
  3027. $update_toekn = $this -> conn -> updatetablebyid('tbl_user', 'user_id', $record['sub_pay_userID'], $data);
  3028.  
  3029. $refresh_token_final=json_decode($return_res, True);
  3030. $t_id=json_decode($refresh_token_final['transactionDetails'],TRUE);
  3031. $data_sub['sub_pay_transID']=$t_id['id'];
  3032. $data_sub['sub_pay_status']=$t_id['state'];
  3033. $data_sub['refresh_token']=$record['refresh_token'];
  3034. $data_sub['end_date']=$new_end_date;
  3035. $data_sub['sub_pay_datetime']=$current_date;
  3036. $data_sub['payment_details']=$return_res;
  3037. $update_subscription = $this -> conn -> updatetablebyid('tbl_subcription_payment', 'sub_payment_id', $record['sub_payment_id'], $data_sub);
  3038.  
  3039. //$t_id['id'],$t_id['state']
  3040. //Update Logs table
  3041.  
  3042. $sql2= " INSERT INTO tbl_payment_details_log (user_id, transaction_details, payment_date)
  3043. VALUES ('".$record['sub_pay_userID']."', '".$return_res."', '".$current_date."')";
  3044. $insert=$this->conn->insert($sql2);
  3045.  
  3046.  
  3047. //$insert = $this -> conn -> insertnewrecords('tbl_payment_details_log','user_id,transaction_details,date', '"'.$record['sub_pay_userID'].'","'.$return_res.'","'.$current_date .'"');
  3048.  
  3049. //Update Logs table
  3050. //echo $insert.'kkk';
  3051.  
  3052. //print_r($return_res);
  3053.  
  3054. $to = $user_details[0]['user_email'];
  3055. $subject = "Renovação da inscrição";
  3056. $txt = "Seu plano de assinatura foi renovado com sucesso.";
  3057. $headers = "From:admin@gmail.com";
  3058. mail($to,$subject,$txt,$headers);
  3059.  
  3060. }
  3061.  
  3062. }
  3063.  
  3064. echo "Records Updated";
  3065. }else{
  3066.  
  3067. echo "No Records Found";
  3068. }
  3069.  
  3070. //print_r($records);
  3071. die();
  3072. }
  3073.  
  3074.  
  3075. //Processo de Pagamento
  3076.  
  3077. function payment_process($authentication)
  3078. {
  3079.  
  3080.  
  3081. //$authentication=$_REQUEST['authentication'];
  3082.  
  3083. $curl = curl_init();
  3084.  
  3085. curl_setopt_array($curl, array(
  3086. CURLOPT_URL => "https://api.sandbox.paypal.com/v1/oauth2/token",
  3087. CURLOPT_RETURNTRANSFER => true,
  3088. CURLOPT_ENCODING => "",
  3089. CURLOPT_MAXREDIRS => 10,
  3090. CURLOPT_TIMEOUT => 30,
  3091. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  3092. CURLOPT_CUSTOMREQUEST => "POST",
  3093. CURLOPT_POSTFIELDS => "grant_type=authorization_code&response_type=token&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&code=".$authentication,
  3094. CURLOPT_HTTPHEADER => array(
  3095. "authorization: Basic QVhyNTBOR0VnNFdqaV93X21mcmR4SzdoUGZXZzJFRGh6T3RsSW8tQ3pTaGVXX25IdFVKNEh4dVRjdEc3dVA5NU82NEk4X3RNOENxQTg5Qkw6RUNnQkgtMXZIdnB6M0hqaS1wbWFqeFdSUXMtS3RwQjFLakpoN3hoakpaV1RiUWZXMFAyMm16M09DaTRtTG1qTTdPV0dndUwxUUpKUkxXNjQ=",
  3096. "cache-control: no-cache",
  3097. "content-type: application/x-www-form-urlencoded",
  3098. "postman-token: 651e3443-9dc0-84da-0bcc-6522f9ed1c0d"
  3099. ),
  3100. ));
  3101.  
  3102. $response = curl_exec($curl);
  3103. $err = curl_error($curl);
  3104.  
  3105. curl_close($curl);
  3106.  
  3107. if ($err) {
  3108. echo "cURL Error #:" . $err;
  3109. } else {
  3110.  
  3111. $res=json_decode($response);
  3112.  
  3113. $res->refresh_token;
  3114. $token=$this->refresh_token($res->refresh_token);
  3115.  
  3116. //echo $token;die();
  3117.  
  3118. $response=$this->payment_init($token);
  3119. //$final_res=json_decode($response);
  3120. $final_res=array();
  3121. $final_res['token']=$token;
  3122. $final_res['refresh_token']=$res->refresh_token;
  3123. $final_res['authentication']=$authentication;
  3124. $final_res['transactionDetails']=$response;
  3125. $return_res=json_encode($final_res);
  3126.  
  3127.  
  3128.  
  3129. //$insert = $this -> conn -> insertnewrecords('tbl_payment_details','id,user_id,access_token,refresh_token,authentication_code,transaction_details', 'NULL,1,uuu,rrr,lll,ggg');
  3130. //echo $return_res .'</br>';
  3131. //echo $this->db->last_query();die();
  3132. //echo $return_res;die();
  3133. //print_r($final_res);die();
  3134. return $return_res;
  3135. }
  3136. }
  3137.  
  3138.  
  3139. // Atualizacao Token
  3140.  
  3141. function refresh_token($r_token) {
  3142.  
  3143. $curl = curl_init();
  3144.  
  3145. curl_setopt_array($curl, array(
  3146. CURLOPT_URL => "https://api.sandbox.paypal.com/v1/oauth2/token",
  3147. CURLOPT_RETURNTRANSFER => true,
  3148. CURLOPT_ENCODING => "",
  3149. CURLOPT_MAXREDIRS => 10,
  3150. CURLOPT_TIMEOUT => 30,
  3151. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  3152. CURLOPT_CUSTOMREQUEST => "POST",
  3153. CURLOPT_POSTFIELDS => "grant_type=refresh_token&refresh_token=".$r_token,
  3154. CURLOPT_HTTPHEADER => array(
  3155. "authorization: Basic QVhyNTBOR0VnNFdqaV93X21mcmR4SzdoUGZXZzJFRGh6T3RsSW8tQ3pTaGVXX25IdFVKNEh4dVRjdEc3dVA5NU82NEk4X3RNOENxQTg5Qkw6RUNnQkgtMXZIdnB6M0hqaS1wbWFqeFdSUXMtS3RwQjFLakpoN3hoakpaV1RiUWZXMFAyMm16M09DaTRtTG1qTTdPV0dndUwxUUpKUkxXNjQ=",
  3156. "cache-control: no-cache",
  3157. "content-type: application/x-www-form-urlencoded",
  3158. "postman-token: f37c7027-0774-23fb-de41-43ed3456732d"
  3159. ),
  3160. ));
  3161.  
  3162. $response = curl_exec($curl);
  3163. $err = curl_error($curl);
  3164.  
  3165. curl_close($curl);
  3166.  
  3167. if ($err) {
  3168. echo "cURL Error #:" . $err;
  3169. } else {
  3170. $get_token=json_decode($response);
  3171. return $get_token->access_token;
  3172. //return $response;
  3173. //$access_token=$get_token['access_token'];
  3174. }
  3175.  
  3176.  
  3177. }
  3178.  
  3179. // estrutura do pagamento - inicio da mesma --__--
  3180. function payment_init($token){
  3181.  
  3182. $curl = curl_init();
  3183.  
  3184. curl_setopt_array($curl, array(
  3185. CURLOPT_URL => "https://api.sandbox.paypal.com/v1/payments/payment",
  3186. CURLOPT_RETURNTRANSFER => true,
  3187. CURLOPT_ENCODING => "",
  3188. CURLOPT_MAXREDIRS => 10,
  3189. CURLOPT_TIMEOUT => 30,
  3190. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  3191. CURLOPT_CUSTOMREQUEST => "POST",
  3192. 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 }",
  3193. CURLOPT_HTTPHEADER => array(
  3194. "authorization: Bearer ".$token,
  3195. "cache-control: no-cache",
  3196. "content-type: application/json",
  3197. "paypal-client-metadata-id: c2edbd6e97b14ff2b19ddb8eec9d264c",
  3198. "postman-token: ac31ba6c-58fd-ca3e-92ef-d5e950f82003"
  3199. ),
  3200. ));
  3201.  
  3202. $response = curl_exec($curl);
  3203. $err = curl_error($curl);
  3204.  
  3205. curl_close($curl);
  3206.  
  3207.  
  3208. if ($err) {
  3209. echo "cURL Error #:" . $err;
  3210.  
  3211. } else {
  3212. return $response;
  3213.  
  3214.  
  3215. }
  3216. }
  3217.  
  3218.  
  3219.  
  3220. function update_feedback() {
  3221. if(!empty($_REQUEST['feedback_id'])){
  3222. $feedback_id = $_REQUEST['feedback_id'];
  3223. $feedback_name = $_REQUEST['feedback_name'];
  3224. $feedback_email = $_REQUEST['feedback_email'];
  3225. $feedback_subject = $_REQUEST['feedback_subject'];
  3226. $feedback_message = $_REQUEST['feedback_message'];
  3227. $sql="select * from tbl_feedback where feedback_id='".$feedback_id."'";
  3228. $res=mysql_query($sql);
  3229. $row=mysql_num_rows($res);
  3230.  
  3231. if($row>0)
  3232. {
  3233. $result=mysql_fetch_array($res);
  3234.  
  3235.  
  3236.  
  3237. if(!empty($feedback_name))
  3238. {
  3239. $feedback_name=$feedback_name;
  3240. }else{
  3241. $feedback_name=$result['feedback_name'];;
  3242. }
  3243. if(!empty($feedback_email))
  3244. {
  3245. $feedback_email=$feedback_email;
  3246. }else{
  3247. $feedback_email=$result['feedback_email'];
  3248. }
  3249. if(!empty($feedback_subject))
  3250. {
  3251. $feedback_subject=$feedback_subject;
  3252. }else{
  3253. $feedback_subject=$result['feedback_subject'];
  3254. }
  3255. if(!empty($feedback_message))
  3256. {
  3257. $feedback_message=$feedback_message;
  3258. }else{
  3259. $feedback_message=$result['feedback_message'];
  3260. }
  3261.  
  3262.  
  3263. $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."'";
  3264. $result=mysql_query($update);
  3265.  
  3266.  
  3267. $sql111="select * from tbl_feedback where feedback_id='".$feedback_id."'";
  3268. $record=$this->conn->getData($sql111);
  3269.  
  3270. $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']);
  3271. }else{
  3272. $post=array('status'=>'flase','message'=>No_Record_Found);
  3273. }
  3274. echo json_encode($post);
  3275. }else{
  3276. $post = array('status' => "Failed", "message" => Missing_parameter, 'feedback_id' => $_POST['feedback_id']);
  3277. // $this->response($this->json($error), 400);
  3278. echo json_encode($post);
  3279. }
  3280.  
  3281. }
  3282.  
  3283.  
  3284. function add_feedback()
  3285. {
  3286. if(!empty($_REQUEST['feedback_name']) && !empty($_REQUEST['feedback_email'])&& !empty($_REQUEST['feedback_subject'])&& !empty($_REQUEST['feedback_message'])) // service provider category_id
  3287. {
  3288. $feedback_name = $_REQUEST['feedback_name'];
  3289. $feedback_email = $_REQUEST['feedback_email'];
  3290. $feedback_subject = $_REQUEST['feedback_subject'];
  3291. $feedback_message = $_REQUEST['feedback_message'];
  3292.  
  3293. $insert = $this -> conn -> insertnewrecords('tbl_feedback', 'feedback_name,feedback_email,feedback_subject,feedback_message', '"' . $feedback_name . '","' . $feedback_email . '","' . $feedback_subject . '","' . $feedback_message . '"');
  3294.  
  3295. if ($insert > 0)
  3296. {
  3297. $post = array("status" => "true", "message" => Feedback_sent_successfully,'feedback_name' => $feedback_name,'feedback_email' => $feedback_email,'feedback_subject' => $feedback_subject, 'feedback_message' => $feedback_message);
  3298. echo $this -> json($post);
  3299. }
  3300. else
  3301. {
  3302. $post = array("status" => "false", "message" => 'O feedback falhou');
  3303. echo $this -> json($post);
  3304. }
  3305. }
  3306. else
  3307. {
  3308. $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']);
  3309. echo $this -> json($error);
  3310. }
  3311.  
  3312. }
  3313.  
  3314.  
  3315.  
  3316.  
  3317.  
  3318. function email_verification2($user_email){
  3319. $path = 'http://'.$_SERVER['HTTP_HOST'].'/Recharge/email_verify/';
  3320. $path1='http://'.$_SERVER['HTTP_HOST'].'/Recharge/webassets/images/logo.png';
  3321. $subject = 'Email verification link';
  3322. $mail_msg .= '
  3323. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3324. <html xmlns="http://www.w3.org/1999/xhtml">
  3325. <head>
  3326. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  3327. <title>Untitled Document</title>
  3328. </head>
  3329.  
  3330. <body bgcolor="#f1f1f1">
  3331. <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;">
  3332. <thead class="header">
  3333. <tr>
  3334. <td style="background:#fff; height:62px; width:100%; padding:5px; border-bottom:1px solid #DDD;" valign="middle">
  3335. <a href="#" style="margin-left:10px;"><img width="100" src="'.$path1.'" alt="..."/></a>
  3336. </td>
  3337. </tr>
  3338. </thead>
  3339. <tbody style=" border-bottom:1px solid #ddd;">
  3340. <tr>
  3341. <td style="padding:10px 15px;">
  3342. <h1 style="margin-bottom:0px; color:#5BBE4F;">Dear ' . ucfirst($user_email) . '</h1>
  3343. Thank you for registering with Us. Before we can activate your account one last step must be taken to complete your registration!<br/><br/>
  3344. 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/>
  3345. To complete your registration, click on the link below:<br/><br/>
  3346. <div style="padding:20px; background-color: #70a93c; color:#fff; text-align:center;">
  3347. <a href=' . $path . "verify_email.php?email=" . base64_encode($user_email) . '>Please click here activate your accout</a>
  3348. </div>
  3349. Price
  3350. </td>
  3351. </tr>
  3352. <tr>
  3353. <td style="padding:10px 15px;"></td>
  3354. </tr>
  3355. <tr>
  3356. <td style="background:#ddd; height:1px; width:100%;"></td>
  3357. </tr>
  3358. </tbody>
  3359.  
  3360. <tfoot style="background:#fff; text-align:center; color:#333;">
  3361. <tr>
  3362. <td style="color:#666;">
  3363. <p>Copyright © 2015 Your plate All right reserved - site by Ypsilon It Solution</p>
  3364. </td>
  3365. <tr>
  3366. </tfoot>
  3367. </table>
  3368. </body>
  3369. </html>
  3370. ';
  3371.  
  3372. $headers = "Organization: OyaCharge\r\n";
  3373. $headers .= "MIME-Version: 1.0\r\n";
  3374. $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  3375. $headers .= "X-Priority: 3\r\n";
  3376. $headers .= "X-Mailer: PHP" . phpversion() . "\r\n";
  3377. $header = "From:blm.ypsilon@gmail.com \r\n";
  3378. $header .= "Cc:blm.ypsilon@gmail.com \r\n";
  3379. $header .= "MIME-Version: 1.0\r\n";
  3380. $header .= "Content-type: text/html\r\n";
  3381. $this->sendElasticEmail($user_email, $subject, "OyaCharge", $mail_msg, "care@oyacharge.com", "OyaCharge");
  3382. }
  3383.  
  3384. function signup2() {
  3385. if(
  3386. !empty($_REQUEST['user_name']) &&
  3387. !empty($_REQUEST['user_email']) &&
  3388. !empty($_REQUEST['user_mobile']) &&
  3389. !empty($_REQUEST['user_pass']) &&
  3390. !empty($_REQUEST['user_city']) &&
  3391. !empty($_REQUEST['user_state']) &&
  3392. !empty($_REQUEST['user_device_type'])&&
  3393. // !empty($_REQUEST['user_device_token']) &&
  3394. !empty($_REQUEST['user_device_id'])
  3395. ){
  3396.  
  3397. $user_name = $_REQUEST['user_name'];
  3398. $user_email = $_REQUEST['user_email'];
  3399. $user_mobile = $_REQUEST['user_mobile'];
  3400. $password = md5($_REQUEST['user_pass']);
  3401. $user_city = $_REQUEST['user_city'];
  3402. $user_state = $_REQUEST['user_state'];
  3403. $device_type = $_REQUEST['user_device_type'];
  3404. // $device_token = $_REQUEST['user_device_token'];
  3405. $device_id = $_REQUEST['user_device_id'];
  3406. $user_type = $_REQUEST['user_type'];
  3407. $current_date = date("Y-m-d h:i:s");
  3408. $email_records = $this -> conn -> get_table_row_byidvalue('tbl_user', 'user_email', $user_email);
  3409.  
  3410. if (!empty($email_records)){
  3411. $post = array(
  3412. "status" => "false",
  3413. "message" => "Este e-mail já está registado",
  3414. "email" => $user_email
  3415. );
  3416. echo $this -> json($post);
  3417. exit();
  3418. } else {
  3419. $user_image = '';
  3420. if ($_FILES['user_img']['name']) {
  3421. $user_image = $_FILES['user_img']['name'];
  3422. }
  3423.  
  3424. $attachment = $_FILES['user_img']['name'];
  3425.  
  3426. if (!empty($attachment)) {
  3427. $file_extension = explode(".", $_FILES["user_img"]["name"]);
  3428. $new_extension = strtolower(end($file_extension));
  3429. $today = time();
  3430. $custom_name = "user_img" . $today;
  3431. $file_name = $custom_name . "." . $new_extension;
  3432.  
  3433. if (
  3434. $new_extension == 'png' ||
  3435. $new_extension == 'jpeg' ||
  3436. $new_extension == 'jpg' ||
  3437. $new_extension == 'bmp')
  3438. {
  3439. move_uploaded_file($_FILES['user_img']['tmp_name'], "../uploads/user/" . $file_name);
  3440.  
  3441. }
  3442. }
  3443.  
  3444. if (!empty($file_name)) {
  3445. $user_profile_pic = $file_name;
  3446. } else{
  3447. $user_profile_pic = '';
  3448. }
  3449.  
  3450. if($user_type==1){
  3451. //print_r('here');
  3452.  
  3453. $insert = $this -> conn -> insertnewrecords(
  3454. 'tbl_user',
  3455. 'user_name,
  3456. user_email,
  3457. user_phone,
  3458. user_state,
  3459. user_city,
  3460. user_password,
  3461. user_login_type,
  3462. user_device_type,
  3463. user_device_id,
  3464. user_created_date,
  3465. user_profile_pic,
  3466. user_type',
  3467. '"' . $user_name . '",
  3468. "' . $user_email . '",
  3469. "' . $user_mobile . '",
  3470. "' . $user_state . '",
  3471. "' . $user_city . '",
  3472. "' . $password . '",
  3473. "1",
  3474. "' . $device_type . '",
  3475. "' . $device_id . '",
  3476. "' . $current_date . '",
  3477. "' . $user_profile_pic . '",
  3478. "' . $user_type . '"'
  3479.  
  3480. // user_device_token,
  3481. // "' . $device_token . '",
  3482. );
  3483.  
  3484. //print_r($insert); die();
  3485.  
  3486. } else {
  3487. $insert = $this -> conn -> insertnewrecords(
  3488. 'tbl_user',
  3489. 'user_name,
  3490. user_email,
  3491. user_phone,
  3492. user_state,
  3493. user_city,
  3494. user_password,
  3495. user_login_type,
  3496. user_device_type,
  3497. user_device_id,
  3498. user_created_date,
  3499. user_profile_pic,
  3500. user_type,
  3501. verified_status',
  3502. '"' . $user_name . '",
  3503. "' . $user_email . '",
  3504. "' . $user_mobile . '",
  3505. "' . $user_state . '",
  3506. "' . $user_city . '",
  3507. "' . $password . '",
  3508. "1",
  3509. "' . $device_type . '",
  3510. "' . $device_id . '",
  3511. "' . $current_date . '",
  3512. "' . $user_profile_pic . '",
  3513. "' . $user_type . '",
  3514. "' . 2 . '"'
  3515. // user_device_token,
  3516. // "' . $device_token . '",
  3517. );
  3518. }
  3519.  
  3520. //print_r($insert); die();
  3521.  
  3522. if ($insert > 0) {
  3523. $to = $user_email;
  3524. $subject = "Bem vindo ao Buscars";
  3525. $txt='
  3526. <html>
  3527. <head>
  3528. <title> Cadastro bem sucedido!</title>
  3529. </head>
  3530.  
  3531. <body style="" >
  3532. <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;">
  3533.  
  3534. <tr>
  3535. <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;">
  3536. Cadastro bem sucedido
  3537. </td>
  3538. </tr>
  3539. <tr>
  3540. <td style="font-size: 25px;padding: 15px 71px;text-align: center; color:#777777;">
  3541. Bem vindo ao Buscars<br />
  3542. O carro zero na palma da sua mão!
  3543. </td>
  3544. </tr>
  3545. <tr>
  3546. <td style="text-align:center; font-size:18px; padding:15px 71px;color:#777777;">
  3547. Qualquer dúvida entre em contato com nossa equipe no <a style="color:#777777;" href="mailto:"> contato@buscarsbr.com.br </a>
  3548. </td>
  3549. </tr>
  3550. <tr >
  3551. <td style="text-align:center; padding:15px;">
  3552. <img width="150" src="'.user_images.'logo1.png" />
  3553. </td>
  3554. </tr>
  3555. </table>
  3556. </body>
  3557. </html>
  3558. ';
  3559.  
  3560.  
  3561. // $headers = "MIME-Version: 1.0" . "\r\n";
  3562. // $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  3563. // // More headers
  3564. // $headers .= 'From: "Buscar" <app@buscarsbr.com.brzz>' . "\r\n";
  3565.  
  3566. // $this->smtp_mail($to, $subject,"Buscar", $txt, " app@buscarsbr.com.br", "BusCar");
  3567. $this->smtp_mail($to, $subject,"Buscar", $txt, " emerson@dopcomunicacao.com.br", "BusCar assinatura");
  3568.  
  3569. // mail($to,$subject,$txt,$headers);
  3570.  
  3571. $post = array(
  3572. "status" => "true",
  3573. "message" => Signup_successfully,
  3574. 'user_id' => $insert,
  3575. 'user_name' => $user_name,
  3576. 'user_email' => $user_email,
  3577. 'user_city' => $user_city,
  3578. 'user_pic'=> user_images.$file_name,
  3579. 'user_type'=> $user_type,
  3580. 'verified_status'=>'2'
  3581. );
  3582.  
  3583. echo $this -> json($post);
  3584. }
  3585. }
  3586. } else {
  3587. $error = array(
  3588. 'status' => "Failed",
  3589. "message" => Missing_Parameter,
  3590. 'user_name' => $_REQUEST['user_name'],
  3591. 'user_email' => $_REQUEST['user_email'],
  3592. 'user_mobile' => $_REQUEST['user_mobile'],
  3593. 'user_pass' => $_REQUEST['user_pass'],
  3594. 'user_city' => $_REQUEST['user_city'],
  3595. 'user_state' => $_REQUEST['user_state'],
  3596. 'user_device_type' => $_REQUEST['user_device_type'],
  3597. // 'user_device_token' => $_REQUEST['user_device_token'],
  3598. 'user_device_id' => $_REQUEST['user_device_id']
  3599. );
  3600. }
  3601.  
  3602. echo $this -> json($error);
  3603. }
  3604.  
  3605.  
  3606. private function json($data){
  3607. if(is_array($data)){
  3608. return json_encode($data);
  3609. }
  3610. }
  3611. }
  3612.  
  3613. // Initiiate Library
  3614.  
  3615. $api = new API;
  3616. $api->processApi();
  3617.  
  3618.  
  3619. ?>
Add Comment
Please, Sign In to add comment