/* Decoded by unphp.net */ test() class Api extends CI_Controller { public $conn; public function __construct() { $this->conn = mysqli_connect('localhost','onlineteerplay_u755589020', 'bK!vWM~1~','onlineteerplay_u755589020') or die("Error in connection."); parent::__construct(); $this->load->database(); $this->load->helper("sms_helper"); } public function test2() { error_reporting(-1); ini_set('display_errors', 1); ini_set('memory_limit', -1); set_time_limit(-1); $this->load->model('Game_model'); $this->Game_model->test(); echo $q = "SELECT * FROM history WHERE bid_id>10"; $q1 = "SELECT * FROM tblgamedata"; //print_r(range(0, 100000)); foreach(range(1, 1000) as $resC): foreach(range(1, 1000) as $res): //sleep(1); echo $q; $resX = $this->db->query($q)->result(); foreach($resX as $resXx) { $this->db->query($q1); } endforeach; endforeach; } public function getIndex() { $data = array(); $res = $this->db->query("select * from app_setting"); $data["responce"] = true; $data["data"] = $res->result(); echo json_encode($data); } public function getLoginStatus() { $data = array(); $uid = $this->input->post("user_id"); $login_stat = $this->db->select("login_status")->where("id", $uid)->get("user_profile")->row(); $data["responce"] = true; $data["login_status"] = $login_stat->login_status; echo json_encode($data); } public function getMobileData() { $data = array(); $res = $this->db->query("select * from site_config"); $data["responce"] = true; $data["data"] = $res->result(); echo json_encode($data); } public function password_details() { $data = array(); $res = $this->db->get("forgotpassword")->result(); echo json_encode($res); } public function get_sliders() { $q = $this->db->query("SELECT * FROM `sliders_img`"); $status = "success"; $data = $q->result(); $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } public function sign_up() { $data = array(); $_POST = $_REQUEST; $this->load->library("form_validation"); $this->load->model("user_model"); $this->form_validation->set_rules("key", "KEY", "trim|required"); if ($this->form_validation->run() == FALSE) { $data["responce"] = false; $data["error"] = strip_tags($this->form_validation->error_string()); } else { $key = $this->input->post("key"); $date = date("d/m/y"); if ($key == 1) { $q = $this->db->query("select * from user_profile where mobileno='" . $this->input->post("mobile") . "' "); if ($q->num_rows() > 0) { $data["responce"] = false; $data["error"] = "Mobile Number Already Registered"; } else { $reffered_code = ''; $ref_code = $this->input->post("refer_code"); $check_ref_code = $this->db->where("user_reference_code", $ref_code)->where("login_status", 0)->get("user_profile"); if ($ref_code != '' && $check_ref_code->num_rows() > 0) { $reffered_code = $ref_code; } $array = array("username" => $this->input->post("username"), "name" => $this->input->post("name"), "mobileno" => $this->input->post("mobile"), "mid" => $this->input->post("mpin"), "password" => $this->input->post("password"), "login_status" => 0, "reffered_code" => $reffered_code); $array["user_reference_code"] = $this->user_model->isExistingUserRef(); $this->db->insert("user_profile", $array); $user_id = $this->db->insert_id(); $this->db->insert("tblwallet", array("user_id" => (int) $user_id, "wallet_points" => 0)); $data["responce"] = true; $data["message"] = "User Register Sucessfully.."; } } else { if ($key == 2) { $this->load->model("common_model"); $this->common_model->data_update("user_profile", array("address" => $this->input->post("address"), "city" => $this->input->post("city"), "pincode" => $this->input->post("pin")), array("id" => $this->input->post("user_id"))); $data["responce"] = true; $data["message"] = "Address Updated successfully.."; } else { if ($key == 3) { $this->load->model("common_model"); $this->common_model->data_update("user_profile", array("accountno" => $this->input->post("accountno"), "bank_name" => $this->input->post("bankname"), "ifsc_code" => $this->input->post("ifsc"), "account_holder_name" => $this->input->post("accountholder")), array("id" => $this->input->post("user_id"))); $data["responce"] = true; $data["message"] = "Bank Details Updated successfully.."; } else { if ($key == 4) { $this->load->model("common_model"); $q = $this->common_model->data_update("user_profile", array("tez_no" => $this->input->post("tez"), "paytm_no" => $this->input->post("paytm"), "phonepay_no" => $this->input->post("phonepay")), array("id" => $this->input->post("user_id"))); if ($q) { $data["responce"] = true; $data["message"] = "Pyment Details Updated successfully.."; } else { $data["responce"] = false; $data["error"] = "Something went wrong"; } } else { if ($key == 5) { $this->load->model("common_model"); $this->common_model->data_update("user_profile", array("email" => $this->input->post("email"), "dob" => $this->input->post("dob")), array("id" => $this->input->post("user_id"))); $data["responce"] = true; $data["message"] = " Details Updated successfully.."; } } } } } } echo json_encode($data); } public function getMatkas() { $q = $this->db->query("select * from matka where status='active' ORDER BY matka_order"); echo json_encode($q->result()); } public function getStarline() { $q = "select * from tblStarline where s_game_time !=''"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { $i = 0; while ($row = $result->fetch_assoc()) { $data[$i]["id"] = $row["id"]; $data[$i]["s_game_time"] = $row["s_game_time"]; if (strtotime(date("Y-m-d")) == strtotime(date("Y-m-d", strtotime($row["updated_at"])))) { $data[$i]["s_game_number"] = $row["s_game_number"]; } else { $data[$i]["s_game_number"] = "***"; } $i++; } } else { $data = "0"; } echo json_encode($data); } public function get_matka_with_id() { $q = $this->db->query("select * from matka where id='" . $this->input->post("id") . "'"); $status = "success"; $data = $q->row(); $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } function how_to_play() { $hto = "Value1 is here ....."; $hto2 = "https://www.youtube.com/"; $x["data"] = $hto; $x["link"] = $hto2; $obj = array($x); echo json_encode($obj); } public function login() { $data = array(); $_POST = $_REQUEST; $this->load->library("form_validation"); $this->form_validation->set_rules("mobileno", "Mobile No", "trim|required"); $this->form_validation->set_rules("password", "Password", "trim|required"); if ($this->form_validation->run() == FALSE) { $data["responce"] = false; $data["error"] = strip_tags($this->form_validation->error_string()); } else { $q = $this->db->query("select * from user_profile where (mobileno='" . $this->input->post("mobileno") . "' ) Limit 1"); if ($q->num_rows() > 0) { $row = $q->row(); $db_pass = $row->password; $pass = $this->input->post("password"); if ($pass == $db_pass) { if ($row->is_blocked == "1") { $data["responce"] = false; $data["error"] = "Account Blocked."; } else { if ($row->login_status == "2") { $data["responce"] = false; $data["error"] = "Your account currently inactive.Please Contact Admin"; } else { $data["responce"] = true; $user_id = $row->id; $temp = array(); $temp["id"] = $row->id; $temp["name"] = $row->name; $temp["username"] = $row->username; $temp["mobileno"] = $row->mobileno; $temp["password"] = $row->password; $temp["email"] = $row->email; $temp["address"] = $row->address; $temp["city"] = $row->city; $temp["pincode"] = $row->pincode; $temp["password"] = $row->password; $temp["accountno"] = $row->accountno; $temp["bank_name"] = $row->bank_name; $temp["ifsc_code"] = $row->ifsc_code; $temp["account_holder_name"] = $row->account_holder_name; $temp["paytm_no"] = $row->paytm_no; $temp["tez_no"] = $row->tez_no; $temp["phonepay_no"] = $row->phonepay_no; $temp["dob"] = $row->dob; $temp["refer_code"] = $row->user_reference_code; $temp["refered_from_code"] = $row->reffered_code; $qw = $this->db->query("select * FROM `tblwallet` where user_id='" . $user_id . "' Limit 1"); $wrow = $qw->row(); $temp["wallet"] = $wrow->wallet_points; $data["data"] = $temp; } } } else { $data["responce"] = false; $data["error"] = "Wrong Password"; } } else { $data["responce"] = false; $data["error"] = "Mobile Number does not exist"; } } echo json_encode($data); } public function setAsLogin() { $email = $_POST["email"]; $q1 = "update user_profile set login_status='1' where email='{$email}'"; if (mysqli_query($this->conn, $q1)) { echo json_encode(array("status" => "success")); } } public function setAsLogout() { $email = $_POST["email"]; $q1 = "update user_profile set login_status='0' where email='{$email}'"; if (mysqli_query($this->conn, $q1)) { echo json_encode(array("status" => "success")); } } public function getNotice() { $q = $this->db->query("Select * from tblNotice ORDER BY `tblNotice`.`id` ASC"); $status = "success"; $data = $q->result(); $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } public function getWalletAmount() { $q = $this->db->query("SELECT * FROM tblwallet where user_id='" . $this->input->post("user_id") . "' LIMIT 1"); echo json_encode($q->result()); } public function test() { $m = 21; $q1 = "select * from tblStarline where id = '{$m}'"; $result = mysqli_query($this->conn, $q1) or die("some err"); $row = mysqli_fetch_assoc($result); $st = $et = "s_game_time"; $time = $row[$st]; echo strtotime(date("h:i A")) . "
" . time(); } public function insert_data() { $status = ''; $result = mysqli_query($this->conn, "SELECT MAX(id) as c FROM tblgamedata") or die("some err"); if ($row = mysqli_fetch_assoc($result)) { $maxid = $row["c"]++; } $jsonArr = $_POST["data"]; if (empty($jsonArr)) { $status = "failed1"; } else { $json = json_decode($jsonArr); foreach ($json as $js) { $ponts = $i = $e = 0; $points = json_decode($js->points); $digits = json_decode($js->digits); $bettype = json_decode($js->bettype); $u = $js->user_id; $m = $js->matka_id; $dx = date("d/m/Y"); $gm = $js->game_id; if ($gm == 16 || $gm == 17) { $gm = 2; } if ($m <= 14) { $q1 = "select * from matka where id = '{$m}'"; $st = "start_time"; $et = "end_time"; } else { $q1 = "select * from tblStarline where id = '{$m}'"; $st = $et = "s_game_time"; } $dd = mysqli_query($this->conn, $q1) or die("some err1"); if ($row1 = mysqli_fetch_assoc($dd)) { $a_time = strtotime(date("h:i A")); $time1 = $bettype[$i] == 0 ? $row1[$st] : $row1[$et]; $time = date("h:i A", strtotime($time1)); if ($a_time <= strtotime($time)) { $q2 = "select * from tblwallet where user_id = '{$u}'"; $dd1 = mysqli_query($this->conn, $q2) or die("some err2"); $row2 = mysqli_fetch_assoc($dd1); if (count($row2) > 0) { $wallet_amt = $row2["wallet_points"]; foreach ($points as $pa) { $p = $points[$i]; $wallet_amt = $wallet_amt - $p; if ($wallet_amt >= 0) { $ponts += $p; $d = (string) $digits[$i]; $bt = $bettype[$i] == 0 ? "open" : "close"; $q = "insert into tblgamedata (user_id,matka_id,points,digits,date,bet_type,game_id) values('{$u}', '{$m}', '{$p}', '{$d}', '{$dx}', '{$bt}','{$gm}')"; $dd = mysqli_query($this->conn, $q) or die("some err3"); $maxid++; $qs = "insert into history (user_id,matka_id,amt,digits,bid_id,date,type,game_id) values('{$u}', '{$m}', '{$p}', '{$d}','{$maxid}', '{$dx}', 'd','{$gm}')"; $dds = mysqli_query($this->conn, $qs) or die("some err4"); $i++; } } } } else { $status = "timeout"; } } if ($ponts > 0) { if (count($row2) > 0) { $q = "update tblwallet set wallet_points = wallet_points-{$ponts} where user_id = '{$u}'"; } else { $q = "insert into tblwallet (wallet_points, user_id) VALUES (0, '{$u}')"; } $dd = mysqli_query($this->conn, $q) or die("some err5"); } } if ($dds === TRUE && $status != "timeout") { $status = "success"; $dt = array("status" => $status); echo json_encode($dt); return false; } elseif ($status == null) { $status = "failed"; } elseif ($status == "timeout") { $status = "timeout"; } } $dt = array("status" => $status); echo json_encode($dt); } public function getMobile() { $q = "select mobile from site_config"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { $data = $result->fetch_assoc(); $data["count"] = 22; $data["starline"] = "https://www.binplus.in"; $data["chart1"] = "https://serveradda.com/billing"; $data["chart2"] = "https://www.google.com"; } else { $data["mobile"] = "XXXXXXXXXXXX"; $data["count"] = 22; $data["starline"] = "https://www.binplus.in"; $data["chart1"] = "https://serveradda.com/billing"; $data["chart2"] = "https://www.google.com"; } echo json_encode($data); } public function insert_sangam_data() { $result = mysqli_query($this->conn, "SELECT MAX(id) as c FROM tblgamedata") or die("some err"); $a_time = strtotime(date("h:i A")); if ($row = mysqli_fetch_assoc($result)) { $maxid = $row["c"]++; } $jsonArr = $_POST["data"]; if (empty($jsonArr)) { $status = "failed1"; } else { $json = json_decode($jsonArr); foreach ($json as $js) { $ponts = $i = $e = 0; $points = json_decode($js->points); $digits = json_decode($js->digits); $bettype = json_decode($js->bettype); $u = $js->user_id; $m = $js->matka_id; $dx = date("d/m/Y"); $gm = $js->game_id; $q1 = "select * from matka where id = '{$m}'"; $dd = mysqli_query($this->conn, $q1) or die("some err1"); $st = date("D") === "Sat" ? "sat_start_time" : (date("D") === "Sun" ? "start_time" : "bid_start_time"); $et = date("D") === "Sat" ? "sat_end_time" : (date("D") === "Sun" ? "end_time" : "bid_end_time"); if ($row1 = mysqli_fetch_assoc($dd)) { $time1 = $bettype[$i] == 0 ? $row1[$st] : $row1[$et]; $time = date("h:i A", strtotime($time1)); if ($a_time <= strtotime($time) || strtotime(date("Y-m-d")) < strtotime($dx)) { $q2 = "select * from tblwallet where user_id = '{$u}'"; $dd1 = mysqli_query($this->conn, $q2) or die("some err2"); $row2 = mysqli_fetch_assoc($dd1); if (count($row2) > 0) { $wallet_amt = $row2["wallet_points"]; foreach ($points as $pa) { $p = $points[$i]; $wallet_amt = $wallet_amt - $p; if ($wallet_amt >= 0) { $ponts += $p; $d = (string) $digits[$i]; $bt = (string) $bettype[$i]; $q = "insert into tblgamedata (user_id,matka_id,points,digits,date,bet_type,game_id) values('{$u}', '{$m}', '{$p}', '{$d}', '{$dx}', '{$bt}','{$gm}')"; $dd = mysqli_query($this->conn, $q) or die("some err3"); $maxid++; $qs = "insert into history (user_id,matka_id,amt,digits,bid_id,date,type,game_id) values('{$u}', '{$m}', '{$p}', '{$d}','{$maxid}', {$dx}, 'd','{$gm}')"; $dds = mysqli_query($this->conn, $qs) or die("some err4"); $i++; } } } } else { $status = "timeout"; } } if ($ponts > 0) { if (count($row2) > 0) { $q = "update tblwallet set wallet_points = wallet_points-{$ponts} where user_id = '{$u}'"; } else { $q = "insert into tblwallet (wallet_points, user_id) VALUES (0, '{$u}')"; } $dd = mysqli_query($this->conn, $q) or die("some err5"); } } if ($dds === TRUE && $status != "timeout") { $status = "success"; $dt = array("status" => $status); echo json_encode($dt); return false; } elseif ($status == null) { $status = "failed"; } elseif ($status == "timeout") { $status = "timeout"; } } $dt = array("status" => $status); echo json_encode($dt); } public function get_history() { $data = array(); $user_id = $this->input->post("user_id"); $page = $this->input->post("page"); $page_limit = 10; $limit = ''; if ($page != '') { $limit .= " limit " . ($page - 1) * $page_limit . "," . $page_limit . " "; } $data["responce"] = true; $q = $this->db->query("SELECT tblgamedata.*,matka.name FROM `tblgamedata` JOIN matka ON matka.id=tblgamedata.matka_id WHERE user_id='" . $user_id . "'ORDER BY `id` DESC {$limit} "); $data["data"] = $q->result(); $q1 = $this->db->query("SELECT tblgamedata.*,matka.name FROM `tblgamedata` JOIN matka ON matka.id=tblgamedata.matka_id WHERE user_id='" . $user_id . "'ORDER BY `id` DESC"); $data["total_data"] = $q1->num_rows(); echo json_encode($data); } public function getBidHistory() { $us_id = $_POST["us_id"]; $matka_id = $_POST["matka_id"]; $play_for = date("Y-m-d"); $play_on = ''; if ($matka_id < 14) { $odd_even = "tblgamedata.id,tblgamedata.user_id,tblgamedata.matka_id,tblgamedata.points,tblgamedata.bet_type,tblgamedata.date,tblgamedata.time,tblgamedata.digits,tblgamedata.game_id,tblgamedata.status,matka.name "; $q = "select " . $odd_even . " from tblgamedata JOIN matka ON matka.id=tblgamedata.matka_id where tblgamedata.user_id={$us_id} and tblgamedata.matka_id={$matka_id} ORDER BY time DESC"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $x["play_for"] = $row["time"]; $x["play_on"] = $row["time"]; $newDate = date("l", strtotime($x["play_on"])); $x["day"] = $newDate; $r = array_merge($row, $x); $data[] = $r; } } else { $data[] = null; } } else { $d = "select tblgamedata.id,tblgamedata.user_id,tblgamedata.matka_id,tblgamedata.points,tblgamedata.bet_type,tblgamedata.date,tblgamedata.time,tblgamedata.digits,tblgamedata.game_id,tblgamedata.status,tblStarline.s_game_time from tblgamedata,tblStarline where tblgamedata.user_id={$us_id} AND tblgamedata.matka_id=tblStarline.id AND matka_id>'15' ORDER BY time DESC"; $result1 = mysqli_query($this->conn, $d); if ($result1->num_rows > 0) { while ($row1 = $result1->fetch_assoc()) { $x["play_for"] = $row1["time"]; $x["play_on"] = $row1["time"]; $newDate = date("l", strtotime($x["play_on"])); $x["day"] = $newDate; $r = array_merge($row1, $x); $data[] = $r; } } else { $data[] = null; } } echo json_encode($data); } public function insert_withdraw_request() { $user_id = $_POST["user_id"]; $points = -$_POST["points"]; $date = $_POST["date"]; $request_status = $_POST["request_status"]; $req_limit = $_POST["req_limit"]; $type = "Withdrawal"; $d = "select * from tblRequest where user_id={$user_id} and type='Withdrawal'"; $result1 = mysqli_query($this->conn, $d); if ($result1->num_rows > 0) { while ($row = $result1->fetch_assoc()) { $newDate = date("d-m-Y", strtotime($row["time"])); $row1[] = $newDate; } $limit_exceed = false; if (in_array($date, $row1)) { $req_count = count($row1); if ($req_count > $req_limit) { $limit_exceed = true; } } if ($limit_exceed) { $status = "failed"; $data = "Daily Withdraw limit Exceeded"; } else { $q = "insert into tblRequest (request_points,user_id,request_status,type) values('{$points}', '{$user_id}', '{$request_status}','{$type}')"; $dd = $this->conn->query($q); if ($dd === TRUE) { $status = "success"; $data = "Request Successfull.."; } else { $status = "failed"; $data = "Something Went Wrong"; } } } else { $q = "insert into tblRequest (request_points,user_id,request_status,type) values('{$points}', '{$user_id}', '{$request_status}','{$type}')"; $dd = $this->conn->query($q); if ($dd === TRUE) { $status = "success"; $data = "Request Successfull.."; } else { $status = "failed"; $data = "Something Went Wrong"; } } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function generate_otp() { $mobile = $this->input->post("mobile"); $otp = $this->input->post("otp"); $q = $this->db->query("select * from user_profile where (mobileno='" . $mobile . "') Limit 1"); if ($q->num_rows() > 0) { $status = "success"; $msg = "Your OnlineTeerPlay One Time Password (OTP) is {$otp}. Don't share it with anyone. We don't call/email you to verify OTP. OTP is valid for 15 mins."; @send_sms($mobile, $msg); $data = "Code sent to your registered mobile number"; } else { $status = "failed"; $data = "Mobile number not registered."; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function mobile_verification() { $mobile = $this->input->post("mobile"); $otp = $this->input->post("otp"); $q = $this->db->query("select * from user_profile where (mobileno='" . $mobile . "') Limit 1"); if ($q->num_rows() > 0) { $status = "failed"; $data = "Mobile number already registered try another number"; } else { $msg = "Your OnlineTeerPlay One Time Password (OTP) is {$otp}. Don't share it with anyone. We don't call/email you to verify OTP. OTP is valid for 15 mins."; send_sms($mobile, $msg); $status = "success"; $data = "verification"; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function forgot_password() { $this->load->model("common_model"); $dd = $this->common_model->data_update("user_profile", array("password" => $this->input->post("password")), array("mobileno" => $this->input->post("mobile"))); if ($dd) { $status = "success"; $data = "Password updated successfully."; } else { $status = "failed"; $data = "Something went wrong"; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function create_mpin() { $user_id = $_POST["user_id"]; $mpin = $_POST["mpin"]; $q = "update user_profile set mid='" . $mpin . "' where id='" . $user_id . "'"; $dd = $this->conn->query($q); if ($dd === TRUE) { $status = "success"; $data = "MPIN gnerated successfully.."; } else { $status = "failed"; $data = "Something went wrong"; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function generate_login_otp() { $mobile = $_POST["mobile"]; $pass = $_POST["password"]; $otp = $_POST["otp"]; $q = "select * from user_profile where mobileno='{$mobile}'"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $db_pass = $row["password"]; if ($pass == $db_pass) { $status = "success"; $msg = "Your login OTP is " . $otp . " for OnlineTeerPlay"; $id = $row["id"]; $u_otp = "update user_profile set otp='{$otp}' where id='{$id}'"; $dd = $this->conn->query($u_otp); if ($dd === TRUE) { $status = "success"; $data = "OTP sent to your registered mobile number"; } else { $status = "failed"; $data = "Something went wrong"; } } else { $status = "failed"; $data = "Password is incorrect"; } } else { $status = "failed"; $data = "Mobile Number not registered."; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function get_starline() { $q = "select * from tblStarline where s_game_time !=''"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { $i = 0; while ($row = $result->fetch_assoc()) { $data[$i]["id"] = $row["id"]; $data[$i]["s_game_time"] = $row["s_game_time"]; $data[$i]["s_game_end_time"] = $row["s_game_end_time"]; if (strtotime(date("Y-m-d")) == strtotime(date("Y-m-d", strtotime($row["updated_at"])))) { $data[$i]["s_game_number"] = $row["s_game_number"]; } else { $data[$i]["s_game_number"] = "***"; } $i++; } } else { $data = "0"; } echo json_encode($data); } public function getSpMotor() { $s = $_POST["arr"]; $a = str_split($s); $arr = implode($a, ","); $numArray = explode(",", $arr); $arr = array_map("intval", $numArray); $data = array(array(137, 128, 146, 236, 245, 290), array(380, 470, 489, 560, 678, 579), array(129, 138, 147, 156, 237, 246), array(345, 390, 480, 570, 589, 679), array(120, 139, 148, 157, 238, 247), array(256, 346, 490, 580, 670, 689), array(130, 149, 158, 167, 239, 248), array(257, 347, 356, 590, 680, 789), array(140, 159, 168, 230, 249, 258), array(267, 348, 357, 456, 690, 780), array(123, 150, 169, 178, 240, 259), array(268, 349, 358, 367, 457, 790), array(124, 160, 179, 250, 269, 278), array(340, 359, 368, 458, 467, 890), array(125, 134, 170, 189, 260, 279), array(350, 369, 378, 459, 468, 567), array(126, 135, 180, 234, 270, 289), array(360, 379, 450, 469, 478, 568), array(127, 136, 145, 190, 235, 280), array(370, 389, 460, 479, 569, 578)); $a = 0; $b = 0; $a = 0; $k = 0; $t = 0; $m = array(); $final = array(); for ($i = 0; $i < count($data); $i++) { for ($j = 0; $j < count($data[$i]); $j++) { $k = 0; $b = 0; $num = $data[$i][$j]; while ($num != 0) { $d = $num % 10; $b++; if ($b < 4) { if (!in_array($d, $arr, false)) { $k = 1; break; } } $num = (int) $num / 10; } if ($k == 0) { $m[$a++] = $data[$i][$j]; } } } for ($i = 0; $i < count($m); $i++) { $b = 0; $c = 0; $num = $m[$i]; while ($num != 0) { $d = $num % 10; $arr2[$b++] = $d; $num = (int) $num / 10; } $final[$t++] = $m[$i]; } echo json_encode(array("status" => "success", "data" => $final)); } public function get_dpmotor() { $s = $_POST["arr"]; $a = str_split($s); $arr = implode($a, ","); $numArray = explode(",", $arr); $arr = array_map("intval", $numArray); $data = array(118, 226, 244, 299, 334, 488, 550, 668, 677, 100, 119, 155, 227, 335, 344, 399, 588, 669, 110, 200, 228, 255, 336, 499, 660, 688, 778, 166, 229, 300, 337, 355, 445, 599, 779, 788, 112, 220, 266, 338, 400, 446, 455, 699, 770, 113, 122, 177, 339, 366, 447, 500, 799, 889, 600, 114, 277, 330, 448, 466, 556, 880, 899, 115, 133, 188, 223, 377, 449, 557, 566, 700, 116, 224, 233, 288, 440, 477, 558, 800, 990, 117, 144, 199, 225, 388, 559, 577, 667, 900); $a = 0; $b = 0; $a = 0; $k = 0; $t = 0; $m = array(); $final = array(); for ($i = 0; $i < count($data); $i++) { $k = 0; $b = 0; $num = $data[$i]; while ($num != 0) { $d = $num % 10; $b++; if ($b < 4) { if (!in_array($d, $arr, false)) { $k = 1; break; } } $num = (int) $num / 10; } if ($k == 0) { $m[$a++] = $data[$i]; } } for ($i = 0; $i < count($m); $i++) { $b = 0; $c = 0; $num = $m[$i]; while ($num != 0) { $d = $num % 10; $arr2[$b++] = $d; $num = (int) $num / 10; } for ($j = 0; $j < 2; $j++) { if ($arr2[$j] <= $arr2[$j + 1]) { $c = 1; break; } } if ($c == 1) { $final[$t++] = $m[$i]; } } echo json_encode(array("status" => "success", "data" => $final)); } public function get_matkas() { $row_dt = ''; $matka = array(); $q = "select * from matka where status='active' ORDER BY matka_order"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { $i = 0; $curr_time = strtotime(date("H:i:s")); while ($row = $result->fetch_assoc()) { if (date("D") === "Sat") { $bid_start_time = $row["sat_start_time"]; $bid_end_time = $row["sat_end_time"]; } if (date("D") === "Sun") { $bid_start_time = $row["start_time"]; $bid_end_time = $row["end_time"]; } else { $bid_start_time = $row["start_time"]; $bid_end_time = $row["end_time"]; } $type = $curr_time >= strtotime($bid_start_time) && $curr_time <= strtotime($bid_end_time) ? "live" : "old"; $data[$i] = $row; $data[$i]["bid_start_time"] = $bid_start_time; $data[$i]["bid_end_time"] = $bid_end_time; $data[$i]["type"] = $type; $i++; } } else { $data = "0"; } echo json_encode($data); } public function matka_with_id() { $us_id = $_POST["id"]; $q = "select * from matka where id={$us_id} "; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $status = "success"; $data = $row; } } else { $status = "success"; $data[] = "0"; } $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } public function starline_data() { $q = $this->db->query("select * from tblStarline where id='" . $this->input->post("id") . "'"); if ($q->num_rows() > 0) { echo json_encode($q->row()); } else { echo json_encode("0"); } } public function add_request() { $data = array(); $_POST = $_REQUEST; $this->load->library("form_validation"); $this->form_validation->set_rules("user_id", "User Id", "trim|required"); $this->form_validation->set_rules("points", "Points", "trim|required"); if ($this->form_validation->run() == FALSE) { $data["responce"] = false; $data["error"] = strip_tags($this->form_validation->error_string()); } else { $user_id = $this->input->post("user_id"); $points = $this->input->post("points"); $request_status = $this->input->post("request_status"); $type = $this->input->post("type"); $q = $this->db->insert("tblRequest", array("user_id" => $user_id, "request_points" => $points, "request_status" => $request_status, "type" => $type)); if ($q) { if ($type == "Withdrawal") { $remainAmount = $this->input->post("wallet"); $qupdate = $this->db->query("update tblwallet set wallet_points='" . $remainAmount . "' where user_id='" . $user_id . "'"); } $data["responce"] = true; $data["message"] = "Request Added.."; } else { $data["responce"] = false; $data["error"] = "Something Went Wrong"; } } echo json_encode($data); } public function withdraw_request() { $user_id = $_POST["user_id"]; $points = $_POST["points"]; $request_status = $_POST["request_status"]; $q = "insert into tblWithdrawRequest (withdraw_points,user_id,withdraw_status) values('{$points}', '{$user_id}', '{$request_status}');"; $dd = $this->conn->query($q); if ($dd === TRUE) { $status = "success"; $dt = array("status" => $status); echo json_encode($dt); } else { $status = "failed"; $dt = array("status" => $status); echo json_encode($dt); } } public function request_history() { $data = array(); $_POST = $_REQUEST; $this->load->library("form_validation"); $this->form_validation->set_rules("user_id", "User Id", "trim|required"); if ($this->form_validation->run() == FALSE) { $data["responce"] = false; $data["error"] = strip_tags($this->form_validation->error_string()); } else { $user_id = $this->input->post("user_id"); $data["responce"] = true; $q = $this->db->query("select * from tblRequest where user_id='" . $user_id . "' ORDER BY time DESC"); $data["data"] = $q->result(); } echo json_encode($data); } public function withdraw_history() { $us_id = $_POST["user_id"]; $q = "select * from tblWithdrawRequest where user_id={$us_id} ORDER BY time DESC"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $status = "success"; $data[] = $row; } } else { $status = "failed"; $data = "No Withdraw History"; } $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } public function notifications() { $email = $_POST["mobile"]; $ds = "SELECT * FROM user_profile where mobileno='{$email}'"; $results = mysqli_query($this->conn, $ds); if ($results->num_rows > 0) { while ($row2 = $results->fetch_assoc()) { $data_time = $row2["time"]; } $d = "SELECT * FROM tblNotification where time>='{$data_time}' ORDER BY notification_id DESC"; $result1 = mysqli_query($this->conn, $d); if ($result1->num_rows > 0) { while ($row1 = $result1->fetch_assoc()) { $data[] = $row1; } $status = "success"; } else { $data = "There is no new notification"; $status = "unsuccessfull"; } $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } else { $data_time = "Nothing"; } } public function transaction() { $us_id = $_POST["us_id"]; $q = "select * from history where user_id='{$us_id}' ORDER BY time DESC"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $data[] = $row; } $status = "success"; } else { $status = "failed"; $data = "No History for you"; } $obj = array("status" => $status, "msg" => $data); echo json_encode($obj); } function mpin_login() { global $conn; $mpin = $_POST["mpin"]; $mobile = $_POST["mobile"]; $q = "select * from user_profile where mid='{$mpin}' and mobileno='{$mobile}'"; $result = mysqli_query($this->conn, $q); if (mysqli_num_rows($result) == 1) { $row = mysqli_fetch_assoc($result); $status = "success"; $data["id"] = $row["id"]; $data["name"] = $row["name"]; $data["username"] = $row["username"]; $data["mobileno"] = $row["mobileno"]; $data["password"] = $row["password"]; $data["email"] = $row["email"]; $data["dob"] = $row["dob"]; $data["address"] = $row["address"]; $data["city"] = $row["city"]; $data["pincode"] = $row["pincode"]; $data["password"] = $row["password"]; $data["accountno"] = $row["accountno"]; $data["bank_name"] = $row["bank_name"]; $data["ifsc_code"] = $row["ifsc_code"]; $data["account_holder_name"] = $row["account_holder_name"]; $data["paytm_no"] = $row["paytm_no"]; $data["tez_no"] = $row["tez_no"]; $data["phonepay_no"] = $row["phonepay_no"]; $qw = "select * from tblwallet where user_id='" . $row["id"] . "'"; $resw = mysqli_query($this->conn, $qw); $roww = mysqli_fetch_assoc($resw); $data["wallet"] = $roww["wallet_points"]; } else { $status = "failed"; $data = "Invalid MPIN"; } $obj = array("status" => $status, "data" => $data); echo json_encode($obj); } function request_points() { $user_id = $_POST["user_id"]; $points = $_POST["points"]; if ($_POST["upi_name"] == "PHONE_PE") { $request_status = "pending"; } else { $request_status = $_POST["request_status"]; } $txn_id = $_POST["txn_id"]; $type = $_POST["type"]; $wallet = $_POST["wallet"]; $q = "insert into tblRequest (request_points,user_id,request_status,type,txn_id) values('{$points}', '{$user_id}', '{$request_status}','{$type}','{$txn_id}')"; if ($_POST["upi_name"] != "PHONE_PE") { $total = $wallet + $points; $u_otp = "update tblwallet set wallet_points='{$total}' where user_id='{$user_id}'"; } $udd = $this->conn->query($u_otp); $dd = $this->conn->query($q); if ($dd === TRUE) { $status = "success"; $dt = array("status" => $status); echo json_encode($dt); } else { $status = "failed"; $dt = array("status" => $status); echo json_encode($dt); } } function get_time_slots() { $data = array(); $q = "select * from timeslots"; $result = mysqli_query($this->conn, $q); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $row_data[] = $row; } $q1 = "select * from app_setting"; $result1 = mysqli_query($this->conn, $q1); $row1 = $result1->fetch_assoc(); $data["responce"] = true; $data["data"] = $row_data; $data["min_amount"] = $row1["w_amount"]; $data["withdraw_limit"] = $row1["withdraw_limit"]; $data["w_saturday"] = $row1["w_saturday"]; $data["w_sunday"] = $row1["w_sunday"]; } else { $data["responce"] = false; $data["message"] = "No time slots available"; } echo json_encode($data); } function forgot_mpin() { $mpin = $_POST["mpin"]; $mobile = $_POST["mobile"]; $q = "update user_profile set mid='{$mpin}' where mobileno='{$mobile}'"; $dd = $this->conn->query($q); if ($dd === TRUE) { $status = "success"; $data = "MPIN updated successfully."; } else { $status = "failed"; $data = "Something went wrong"; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function text_chat() { $data = array(); $_POST = $_REQUEST; $this->load->library("form_validation"); $this->form_validation->set_rules("user_id", "User Id", "trim|required"); $this->form_validation->set_rules("message", "Message", "required"); if ($this->form_validation->run() == FALSE) { $data["responce"] = false; $data["error"] = strip_tags($this->form_validation->error_string()); } else { $user_id = $this->input->post("user_id"); $message = $this->input->post("message"); $from = $this->input->post("from"); $type = "text"; $q = $this->db->insert("chat", array("user_id" => $user_id, "message" => $message, "from" => $from, "type" => $type)); if ($q) { $data["responce"] = true; $data["message"] = "Message Sent."; } else { $data["responce"] = false; $data["error"] = "Message Not Sent"; } } echo json_encode($data); } public function image_chat() { $data = array(); $_POST = $_REQUEST; $this->load->library("form_validation"); $this->form_validation->set_rules("user_id", "User Id", "trim|required"); if ($this->form_validation->run() == FALSE) { $data["responce"] = false; $data["error"] = strip_tags($this->form_validation->error_string()); } else { $user_id = $this->input->post("user_id"); $from = $this->input->post("from"); $type = "image"; if (isset($_FILES["image"]) && $_FILES["image"]["size"] > 0) { $config["upload_path"] = "./img/chats/"; $config["allowed_types"] = "gif|jpg|png|jpeg"; $config["encrypt_name"] = TRUE; $this->load->library("upload", $config); if (!$this->upload->do_upload("image")) { $data["responce"] = false; $data["error"] = "Error! : " . $this->upload->display_errors(); } else { $img_data = $this->upload->data(); $img_name = $img_data["file_name"]; $this->load->model("Common_model"); $q = $this->db->insert("chat", array("user_id" => $user_id, "message" => $img_data["file_name"], "from" => $from, "type" => $type)); if ($q) { $data["responce"] = true; $data["data"] = $img_name; $data["message"] = "Message Sent."; } else { $data["responce"] = false; $data["error"] = "Message Not Sent"; } } } } echo json_encode($data); } public function get_chat() { $data = array(); $user_id = $this->input->post("user_id"); $q = $this->db->where("user_id", $user_id)->get("chat"); $data["data"] = $q->result(); echo json_encode($data); } public function update_token() { $data = array(); $user_id = $this->input->post("user_id"); $token = $this->input->post("token"); $q = $this->db->query("update user_profile set token='" . $token . "' where id='" . $user_id . "'"); if ($q) { $data["responce"] = true; $data["message"] = "Token Updated!"; } else { $data["responce"] = false; $data["error"] = "Token Updation Failed"; } echo json_encode($data); } public function change_password() { $user_id = $this->input->post("user_id"); $old_pw = $this->input->post("old_pass"); $new_pw = $this->input->post("new_pass"); $org_pw = $this->db->select("password")->where("id", $user_id)->get("user_profile")->row(); if ($old_pw == $org_pw->password) { $this->load->model("common_model"); $dd = $this->common_model->data_update("user_profile", array("password" => $new_pw), array("id" => $this->input->post("user_id"))); if ($dd) { $status = "success"; $data = "Password updated successfully."; } else { $status = "failed"; $data = "Something went wrong"; } } else { $status = "failed"; $data = "Old Password does not matched"; } $obj = array("status" => $status, "message" => $data); echo json_encode($obj); } public function check_block_user() { $user_id = $this->input->post("user_id"); if ($user_id != '') { $q = $this->db->select("is_blocked")->where("id", $user_id)->get("user_profile")->row(); $status = "success"; $data = $q; } else { $status = "failed"; $message = "Invalid User Id"; $data = ''; } $obj = array("status" => $status, "message" => $message, "data" => $data); echo json_encode($obj); } public function user_transfer_request() { $data = array(); $this->form_validation->set_rules("user_id", "User Id", "required"); $this->form_validation->set_rules("request_amount", "Request_amount", "required"); $this->form_validation->set_rules("commission", "Commission", "required"); $this->form_validation->set_rules("transfer_userid", "Transfer_userid", "required|trim"); $this->form_validation->set_rules("type", "Type", "required"); if ($this->form_validation->run() == TRUE) { $commission = $this->input->post("commission"); $request_amount = $this->input->post("request_amount"); $mobile = $this->input->post("transfer_userid"); $user_id = $this->input->post("user_id"); $type = $this->input->post("type"); $user_data_no = $this->db->where("mobileno", $mobile)->get("user_profile")->num_rows(); if ($user_data_no > 0) { $user_data = $this->db->where("mobileno", $mobile)->get("user_profile")->row(); $transfer_userid = $user_data->id; $wallet = $this->db->where("user_id", $transfer_userid)->get("tblwallet")->row()->wallet_points; $wallet_main = $this->db->where("user_id", $transfer_userid)->get("tblwallet")->row()->main_wallet_points; if ($request_amount > $wallet) { $data["response"] = false; $data["message"] = "insufficient Balance !!"; } if ($request_amount > $wallet_main) { $data["response"] = false; $data["message"] = "insufficient Balance !!"; } if ($user_data_no > 0) { $user_data = $this->db->where("mobileno", $mobile)->get("user_profile")->row(); $user_data2 = $this->db->where("id", $user_id)->get("user_profile")->row(); $mobile2 = $user_data2->mobileno; $transfer_userid = $user_data->id; $fee = $this->db->select("transfer_fee,wining_transfer_fee")->get("app_setting")->row(); $charge2 = $fee->transfer_fee; $charge3 = $fee->wining_transfer_fee; $winning_charge = $request_amount * $charge3 / 100; $main_charge = $request_amount * $charge2 / 100; if ($type == 1) { if ($commission == 0) { $ar_commission = $commission; } else { if ($winning_charge == $commission) { $ar_commission = $commission; } else { $data["response"] = false; $data["message"] = "Somthing went wrong"; } } } else { if ($commission == 0) { $ar_commission = $commission; } else { if ($main_charge == $commission) { $ar_commission = $commission; } else { $data["response"] = false; $data["message"] = "Somthing went wrong"; } } } $array = array("user_id" => $user_id, "request_amount" => $request_amount, "transfer_userid" => $transfer_userid, "commission" => $ar_commission, "status" => 1); $x = $this->db->insert("tbltransfer_request", $array); $array2 = array("user_id" => $this->input->post("user_id"), "request_points" => $request_amount, "type" => "send", "remark" => "Send to {$mobile}", "request_status" => "approved"); $array4 = array("user_id" => $transfer_userid, "request_points" => $request_amount, "type" => "received", "remark" => "Received From {$mobile2}", "request_status" => "approved"); $x = $this->db->insert("tblRequest", $array2); $x = $this->db->insert("tblRequest", $array4); $array3 = array("user_id" => $this->input->post("user_id"), "request_points" => $request_amount, "type" => "add"); $x = $this->db->insert("tblRequest2", $array3); $total = $request_amount; if ($type == 1) { $total_transfer_amount = $request_amount - $commission; $this->Administrator_Model->add_wallet2($user_id, -$total, "wallet_points"); $this->Administrator_Model->add_wallet2($transfer_userid, $total_transfer_amount, "main_wallet_points"); } else { $total_transfer_amount = $request_amount - $commission; $this->Administrator_Model->add_wallet2($user_id, -$total, "main_wallet_points"); $this->Administrator_Model->add_wallet2($transfer_userid, $total_transfer_amount, "main_wallet_points"); } $data["response"] = true; $data["message"] = "Success"; } else { $data["response"] = false; $data["message"] = "Mobile Number Does Not Exits"; } } else { $data["response"] = false; $data["message"] = "Mobile Number Does Not Exits"; } } else { $data["response"] = false; $data["message"] = strip_tags($this->form_validation->error_string()); } echo json_encode($data); } public function get_user_name() { $data = array(); $this->form_validation->set_rules("mobile", "Mobile", "required"); if ($this->form_validation->run() == TRUE) { $mobile = $this->input->post("mobile"); $user_data_no = $this->db->where("mobileno", $mobile)->get("user_profile")->num_rows(); if ($user_data_no > 0) { $user_data = $this->db->where("mobileno", $mobile)->get("user_profile")->row(); $array = array("name" => $user_data->name, "username" => $user_data->username); $data["response"] = true; $data["data"] = $array; } else { $data["response"] = false; $data["data"] = array(); $data["message"] = "Mobile Number Does Not Exits"; } } else { $data["response"] = false; $data["message"] = strip_tags($this->form_validation->error_string()); } echo json_encode($data); } } ?>