Commit acbad240 by Tobin

registration

parent 35b13554
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
if (isset($_SERVER['HTTP_ORIGIN'])) { if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); header('Access-Control-Max-Age: 86400');
} }
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}"); if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])){
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
}
exit(0); if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])){
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
} }
exit(0);
}
class Api extends CI_Controller { class Api extends CI_Controller {
...@@ -44,7 +45,6 @@ class Api extends CI_Controller { ...@@ -44,7 +45,6 @@ class Api extends CI_Controller {
public function index() { public function index() {
$res = $this->Validation_model->validation_check('login',array('email_id'=>'adarsh')); $res = $this->Validation_model->validation_check('login',array('email_id'=>'adarsh'));
} }
public function response($data) { public function response($data) {
...@@ -516,8 +516,7 @@ class Api extends CI_Controller { ...@@ -516,8 +516,7 @@ class Api extends CI_Controller {
$res = $this->Api_model->checker_login($data); $res = $this->Api_model->checker_login($data);
if($res['status']!=0){ if($res['status']!=0){
$this->response($res['data']); $this->response($res['data']);
} } else {
else{
$this->errorResponse($res['code'],$res['message']); $this->errorResponse($res['code'],$res['message']);
} }
} }
......
...@@ -36,7 +36,7 @@ class Api_model extends CI_Model { ...@@ -36,7 +36,7 @@ class Api_model extends CI_Model {
try{ try{
$email = $data['email_id']; $email = $data['email_id'];
$phone = $data['phone']; $phone = $data['phone'];
$res_count = $this->db->query("SELECT * FROM customer INNER JOIN `users` ON users.id = customer.customer_id AND users.user_type = 3 WHERE users.status = 1 AND (customer.email = '$email' OR customer.phone = '$phone')")->row(); $res_count = $this->db->query("SELECT * FROM customer INNER JOIN `users` ON users.id = customer.customer_id AND users.user_type = 3 WHERE users.status = 1 AND (customer.email = '$email' OR customer.phone LIKE '%$phone')")->row();
//$res_count = $this->db->where('email',$data['email_id'])->where()->or_where('phone',$data['phone'])->get('customer')->row(); //$res_count = $this->db->where('email',$data['email_id'])->where()->or_where('phone',$data['phone'])->get('customer')->row();
if(count($res_count) > 0) { if(count($res_count) > 0) {
if($res_count->email == $data['email_id'] && $res_count->phone == $data['phone']){ if($res_count->email == $data['email_id'] && $res_count->phone == $data['phone']){
...@@ -58,6 +58,13 @@ class Api_model extends CI_Model { ...@@ -58,6 +58,13 @@ class Api_model extends CI_Model {
$this->db->insert('users',$user_data); $this->db->insert('users',$user_data);
$id = $this->db->insert_id(); $id = $this->db->insert_id();
if($id) { if($id) {
if(strpos($data['phone'],'+') === true){
$data['phone'] = str_replace('+','',$data['phone']);
}
if(strpos($data['phone'],'966') !== true){
$data['phone'] = '966'.$data['phone'];
}
$customer_data = array( $customer_data = array(
'customer_id'=>$id, 'customer_id'=>$id,
'phone'=>$data['phone'], 'phone'=>$data['phone'],
...@@ -519,7 +526,6 @@ class Api_model extends CI_Model { ...@@ -519,7 +526,6 @@ class Api_model extends CI_Model {
} }
function recommend($data) { function recommend($data) {
try { try {
$per_page = 10; $per_page = 10;
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
...@@ -1006,4 +1012,4 @@ class Api_model extends CI_Model { ...@@ -1006,4 +1012,4 @@ class Api_model extends CI_Model {
return $res; return $res;
} }
} }
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment