Viewing file: Api.php (17.16 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
defined('BASEPATH') OR exit('No direct script access allowed'); function unique_multidimensional_array($array, $key) { $temp_array = array(); $i = 0; $key_array = array();
foreach($array as $val) { if (!in_array($val[$key], $key_array)) { $key_array[$i] = $val[$key]; $temp_array[$i] = $val; } $i++; } return $temp_array; }
class Api extends CI_Controller { public function getOnlineSim(){ $services = [ ["name" => "Telegram", "value" => "telegram"], ["name" => "Whatsapp", "value" => "whatsapp"], ["name" => "Facebook", "value" => "3223"], ["name" => "Mail.ru", "value" => "mailru"], ["name" => "Google (Youtube, Gmail)", "value" => "google"], ["name" => "yandex", "value" => "yandex"], ["name" => "viber", "value" => "viber"], ["name" => "instagram", "value" => "instagram"], ["name" => "wechat", "value" => "wechat"], ["name" => "discord", "value" => "discord"], ["name" => "netflix", "value" => "netflix"], ["name" => "microsoft", "value" => "microsoft"], ["name" => "yahoo", "value" => "yahoo"], ["name" => "steam", "value" => "steam"], ["name" => "linkedin", "value" => "linkedin"], ["name" => "amazon", "value" => "amazon"], ["name" => "happn", "value" => "happn"], ["name" => "ebay", "value" => "ebay"], ["name" => "viber", "value" => "viber"], ["name" => "snapchat", "value" => "snapchat"], ["name" => "vkcom", "value" => "vkcom"], ["name" => "linemessenger", "value" => "linemessenger"], ["name" => "proton", "value" => "proton"], ["name" => "tinder", "value" => "tinder"], ["name" => "naver", "value" => "naver"], ["name" => "ozon", "value" => "ozon"], ["name" => "getir", "value" => "getir"], ["name" => "yemeksepeti", "value" => "yemeksepeti"], ["name" => "tencentqq", "value" => "tencentqq"], ["name" => "icq", "value" => "icq"], ["name" => "ininal", "value" => "ininal"], ["name" => "coinbase", "value" => "coinbase"], ["name" => "apple", "value" => "apple"], ["name" => "nttgame", "value" => "nttgame"], ["name" => "twitter", "value" => "twitter"] ]; echo json_encode($services); } public function getServerTimestamp() {
echo time();
} public function getCategoryLastest($id) { $this->load->model("api_model"); /* $services = $this->api_model->db->where('category', $id)->get('services')->result(); $orders = $this->api_model->db->order_by('id', 'DESC')->limit(100)->where('status', '1')->get('activations')->result(); $last = array(); $diff = array_udiff($services, $orders, function ($obj_a, $obj_b) { return $obj_a->id - $obj_b->service_id; } ); */ $array = array(); $query = $this->db->query("SELECT activations.*, services.name as service_name,categories.id as cat, categories.name as category_name FROM activations LEFT JOIN services ON services.id = activations.service_id LEFT JOIN categories ON categories.id = services.category ORDER BY activations.time DESC LIMIT 500"); foreach ($query->result() as $row) { if (count($array) > 4){ break; } else { if ($row->status == '1' && $row->cat == $id){ $array[] = ['name' => $row->service_name]; $array = unique_multidimensional_array($array, 'name'); } } } echo json_encode($array); }
public function getBalance($api_key) {
$this->load->model("api_model");
echo(json_encode(array("balance" => $this->api_model->getUserByApiKey($api_key)["balance"])));
} public function getServicesWithMaxPrice($id)
{
$this->load->model("api_model"); $maxPrice = $_GET['max']; $services = $this->api_model->getServicesMaxPrice($id, $maxPrice);
for($i = 0; $i < count($services);$i++) {
//unset($services[$i]["price"]); unset($services[$i]["auto_price"]); unset($services[$i]["rate"]);
unset($services[$i]["callback"]);
}
echo json_encode($services);
} public function getServices($id)
{
$this->load->model("api_model");
$services = $this->api_model->getServices($id);
for($i = 0; $i < count($services);$i++) {
//unset($services[$i]["price"]); unset($services[$i]["auto_price"]); unset($services[$i]["rate"]);
unset($services[$i]["callback"]);
}
echo json_encode($services);
}
public function getCategories()
{
$this->load->model("api_model");
$categories = $this->api_model->getCategories();
for($i = 0; $i < count($categories);$i++) {
unset($categories[$i]["icon"]);
unset($categories[$i]["color"]);
}
echo json_encode($categories);
} public function getDiscountRate($category_id)
{
$this->load->model("api_model");
$category = $this->api_model->getCategoryById($category_id);
echo json_encode([ 'category' => $category['id'], 'rate' => intval($category['bayi']) ]);
}
public function getServiceDetails($id) {
$this->load->model("api_model");
$service = $this->api_model->getServiceById($id);
if(isset($service["id"])) { $this->load->library("provider_api"); $service_callback = explode(",",$service["callback"]); echo json_encode(array( "id" => $service["id"], "price" => $service["price"], "name" => $service['name'], "stock" => $this->provider_api->get_service_stock($service_callback[0],$service_callback[1],$service_callback[2])
));
}
}
public function getAllServices()
{
$this->load->model("api_model");
$services = $this->api_model->getServices();
for($i = 0; $i < count($services);$i++) {
unset($services[$i]["callback"]);
}
echo json_encode($services);
}
public function getNumber($api_key,$service_id) {
$this->load->model("api_model");
$this->lang->load("api");
$user = $this->api_model->getUserByApiKey($api_key);
if(isset($user["id"])) {
$this->load->library("provider_api");
$service = $this->api_model->getServiceById($service_id);
$service_callback = explode(",",$service["callback"]); $_opex = explode(",",$servis['operator']); if ($user['type'] == 2){ $this->load->model("admin_model"); $cat = $this->admin_model->getCategory($service['category']); $service['price'] = $service['price']- (($service['price'] / 100) * $cat['bayi']); } if($user["balance"] < $service["price"]) { echo json_encode(array( "success" => false, "title" => $this->lang->line("number_not_purchased"), "message" => $this->lang->line("balance_not_enough_message") )); } else if(!isset($service["price"]) || $service["price"] === '0'){ echo json_encode(array( "success" => false, "title" => "Numara alınamaz!", "message" => "Bu numara satışa kapalıdır, detayl bilgi için iletişime geçiniz." )); } else { $ch = curl_init(); $product = $service_callback[2];
curl_setopt($ch, CURLOPT_URL, 'https://5sim.net/v1/guest/prices?product=' . $product."&country=".$service_callback[1]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array(); $headers[] = 'Accept: application/json'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$resultxxx = curl_exec($ch);
curl_close($ch); $_ox = json_decode($resultxxx,true); $_oxx = $_ox[$service_callback[1]][$service_callback[2]]; function opsec($data) { $s = 0; $co = count($data); $rand = rand(0,($co-1)); $i = 0; foreach ($data as $row => $value) { if ($s == 0) { if ($rand == $i) { $donus = $row; $s++; } } $i++; } return $donus; } $aewr = opsec($_oxx); $varsor = $this->db->limit(1)->order_by('id', 'DESC')->get_where('activations', array('service_id' => $service_id, 'status' => 1))->result_array();
if (count($varsor) > 0) { $varsorx = $this->db->limit(1)->order_by('id', 'DESC')->get_where('activations', array('service_id' => $service_id, 'operator' => $varsor[0]['operator']))->result_array(); if ($varsorx[0]['status'] == 1) { $aewr = $varsor[0]['operator']; } else { $aewr = $aewr; } } else { $aewr = $aewr; }
$result = $this->provider_api->get_number($service_callback[0],$service_callback[1],$service_callback[2],$aewr);
if($result["error_code"] == 200) {
$s_id = $this->api_model->insertNumber($result["number"],$result["id"],$service_id, $service["price"], $user["id"],$aewr, $service['price']);
echo json_encode(array(
"success" => true,
"title" => $this->lang->line("number_purchased"),
"message" => $this->lang->line("number_purchased_message"),
"number_id" => $s_id,
"number" => $result["number"]
));
}
else {
if($result["error_code"] == 103) {
echo json_encode(array(
"success" => false,
"title" => $this->lang->line("number_not_purchased"),
"message" => $this->lang->line("number_stock_message")
));
}
else {
echo json_encode(array(
"success" => false,
"title" => $this->lang->line("number_not_purchased"),
"message" => $this->lang->line("internal_error_message")
));
}
}
}
}
}
public function getMessage($api_key,$id) {
$this->load->model("api_model");
$this->lang->load("api");
$user = $this->api_model->getUserByApiKey($api_key);
if(isset($user["id"])) {
$this->load->library("provider_api");
$activation = $this->api_model->getActivationById($id);
if($activation["status"] != -1) {
if($activation["message"] == "" && 600 < (time()-$activation["time"])) {
$this->api_model->cancel_number($activation["id"], $user['id']);
echo json_encode(array(
"code" => null,
"id" => $id,
"status" => -1
));
}
else {
if($activation["message"] == "") {
$message = $this->provider_api->get_message(explode(",",$activation["callback"])[0], $activation["number_id"]);
if(!is_null($message["code"])) {
$this->api_model->updateActivationCode($message["code"], $activation["id"]);
}
$message["id"] = $id;
$message["status"] = 0;
echo json_encode($message);
}
else {
echo json_encode(array(
"code" => $activation["message"],
"id" => $id,
"status" => 1
));
}
}
}
else {
echo json_encode(array(
"code" => null,
"id" => $id,
"status" => -1
));
}
}
}
public function cancelNumber($api_key, $id) {
$this->load->model("api_model");
$this->lang->load("api");
$user = $this->api_model->getUserByApiKey($api_key);
if(isset($user["id"])) {
$this->load->library("provider_api");
$activation = $this->api_model->getActivationById($id);
if($activation["status"] == 0 && 600 > (time()-$activation["time"])) {
$this->provider_api->cancel_number(explode(",",$activation["callback"])[0], $activation["number_id"]);
$this->api_model->cancelNumber($id, $user["id"]);
echo json_encode(array(
"success" => true,
"title" => $this->lang->line("number_canceled"),
"message" => $this->lang->line("number_canceled_message")
));
}
}
}
public function getActivations($api_key) {
$this->load->model("api_model");
$user = $this->api_model->getUserByApiKey($api_key);
if(isset($user["id"])) {
$activations = $this->api_model->getActivations($user["id"]);
for($i = 0; $i < count($activations); $i++) {
unset($activations[$i]["number_id"]);
unset($activations[$i]["user"]);
} $this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file')); if (!$cache_activations = $this->cache->get('activations_' . $api_key)) { $this->cache->save('activations_' . $api_key, $activations, 3600); }
$isChanged = false; $newNumber = false; foreach($activations as $i => $activation){ $cacheVal = array_filter($cache_activations, function($cacheActivation) use ($activation){ return $cacheActivation["id"] == $activation["id"]; }); if (count($cacheVal) == 0) { $newNumber = true; continue; } $cacheVal = array_values($cacheVal)[0]; if ($cacheVal["status"] != $activation["status"] && ($activation["status"] == 1 || $activation["message"] != $cacheVal["message"])) { $isChanged = true; break; } } if ($isChanged || $newNumber) { $this->cache->save('activations_' . $api_key, $activations, 3600); } echo json_encode(array("changed" => $isChanged, "data" => $activations));
}
}
public function getRentCountries() { $api = 'GetCountries'; $_LANG = [ 'tr' => [ 'Russia' => 'Rusya', 'Ukraine' => 'Ukrayna', 'Kazakhstan' => 'Kazakistan', 'Indonesia' => 'Endonezya', 'HongKong' => 'Hong Kong', 'England' => 'İngiltere', 'Estonia' => 'Estonya', 'Germany' => 'Almanya', 'Lithuania' => 'Litvanya', 'Sweden' => 'sveç', 'Latvia' => 'Letonya' ], 'en' => [ 'Yunanistan' => 'Greece' ] ]; include './application/libraries/rent_module.php'; }
public function getRentServices($country_id = null, $time = 0) { if($country_id !== null && intval($country_id) > -1) { $api = 'GetServices'; include './application/libraries/rent_module.php'; } }
public function getRentNumber($user_api_key = null, $country_id = null, $service_id = null, $time = 0) { if($user_api_key !== null && $service_id !== null && intval($country_id) > -1) { $api = 'GetNumber'; include './application/libraries/rent_module.php'; } }
public function getRentActivations($user_api_key = null) { if($user_api_key !== null) { $this->load->model('api_model'); $user = $this->api_model->getUserByApiKey($user_api_key); if(isset($user["id"])) { header('Content-Type: application/json'); $activations = $this->api_model->db->order_by('id', 'DESC')->get_where('rent_activations', array('user' => $user['id']))->result_array(); foreach($activations as $i => $activation) { // unset($activations[$i]['number_id']); unset($activations[$i]['user']); $activations[$i]['isExpired'] = $activations[$i]['end_time'] < time(); } echo json_encode(array('data' => $activations)); } } }
public function getRentMessage($user_api_key = null, $number_id = null) { if($user_api_key !== null && intval($number_id) > 0) { $api = 'GetMessage'; include './application/libraries/rent_module.php'; } } public function cancelRentNumber($user_api_key, $number_id){ if($user_api_key !== null && $number_id !== null) { $api = 'CancelNumber'; header('Content-Type: application/json'); include './application/libraries/rent_module.php'; } }
}
|