SHARE
TWEET

api.php

a guest Sep 20th, 2019 318 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once "/home/xapicode/iptv_xapicode/wwwdir/_system/config/config.main.php";
  3. require_once "/home/xapicode/iptv_xapicode/wwwdir/_system/class/class.pdo.php";
  4. $DBPASS = decrypt(PASSWORD);
  5. $db = new Db(HOST, DATABASE, USER, $DBPASS);
  6. $line_user = $_GET["line"];
  7. $line_password = $_GET["password"];
  8. $stream_id = isset($_GET["streamid"]) ? $_GET["streamid"] : "";
  9. $token = $_GET["token"];
  10. $checker = $_GET["checker"];
  11. $remote_ip = $_SERVER["REMOTE_ADDR"];
  12. $user_agent = $_SERVER["HTTP_USER_AGENT"];
  13. $query_string = $_SERVER["QUERY_STRING"];
  14. if (check_flood_dedection()) {
  15.     if (($checker != "stream" || $checker != "line_info") && !check_line_user($line_user)) {
  16.         $set_bann_array = [$remote_ip];
  17.         $set_bann = $db->query("SELECT bann_id FROM cms_bannlist WHERE bann_ip = ?", $set_bann_array);
  18.         if (count($set_bann) == 0) {
  19.             insert_into_loglist($remote_ip, $user_agent, $query_string);
  20.             $set_log_array = [$remote_ip, SERVER];
  21.             $set_log = $db->query("SELECT log_ip FROM cms_log WHERE log_ip = ? AND log_server = ?", $set_log_array);
  22.             if (5 <= count($set_log)) {
  23.                 $bann_title = "Flood Protection";
  24.                 $bann_note = "line not exists";
  25.                 insert_into_bannlist(0, $set_log[0]["log_ip"], $bann_title, $bann_note);
  26.                 iptables_add($set_log[0]["log_ip"]);
  27.             }
  28.         }
  29.         exit;
  30.     }
  31.     if (!check_security_token($token)) {
  32.         $set_bann_array = [$remote_ip];
  33.         $set_bann = $db->query("SELECT bann_id FROM cms_bannlist WHERE bann_ip = ?", $set_bann_array);
  34.         if (count($set_bann) == 0) {
  35.             insert_into_loglist($remote_ip, $user_agent, $query_string);
  36.             $set_log_array = [$remote_ip, SERVER];
  37.             $set_log = $db->query("SELECT log_ip FROM cms_log WHERE log_ip = ? AND log_server = ?", $set_log_array);
  38.             if (5 <= count($set_log)) {
  39.                 $bann_title = "Flood Protection";
  40.                 $bann_note = "API Token failed";
  41.                 insert_into_bannlist(0, $set_log[0]["log_ip"], $bann_title, $bann_note);
  42.                 iptables_add($set_log[0]["log_ip"]);
  43.             }
  44.         }
  45.         exit;
  46.     }
  47.     if (isset($line_user) && check_line_is_expired($line_user)) {
  48.         exit;
  49.     }
  50. }
  51. if ($checker == "stream") {
  52.     if ($stream_id != "all") {
  53.         $set_stream_array = [$stream_id];
  54.         $set_stream = $db->query("SELECT stream_status, stream_name FROM cms_streams WHERE stream_id = ?", $set_stream_array);
  55.         $status = "";
  56.         $stream_status = json_decode($set_stream[0]["stream_status"], true);
  57.         foreach ($stream_status[0] as $key => $value) {
  58.             switch ($value) {
  59.                 case 0:
  60.                     $status = "offline";
  61.                 case 1:
  62.                     $status = "online";
  63.                 case 2:
  64.                     $status = "paused";
  65.                 case 3:
  66.                     $status = "starting";
  67.                 case 4:
  68.                     $status = "restarting";
  69.                 default:
  70.                     $status = $status;
  71.                     echo $status;
  72.             }
  73.         }
  74.     } else {
  75.         $status_array = [];
  76.         $set_stream = $db->query("SELECT stream_id, stream_status, stream_name FROM cms_streams");
  77.         foreach ($set_stream as $get_stream) {
  78.             $stream_status = json_decode($get_stream["stream_status"], true);
  79.             foreach ($stream_status[0] as $key => $value) {
  80.                 switch ($value) {
  81.                     case 0:
  82.                         $status = "offline";
  83.                     case 1:
  84.                         $status = "online";
  85.                     case 2:
  86.                         $status = "paused";
  87.                     case 3:
  88.                         $status = "starting";
  89.                     case 4:
  90.                         $status = "restarting";
  91.                     default:
  92.                         $status_array[$get_stream["stream_id"]] = ["stream_name" => $get_stream["stream_name"], "stream_status" => $status];
  93.                 }
  94.             }
  95.         }
  96.         echo json_encode($status_array);
  97.     }
  98. }
  99. if ($checker == "line_info") {
  100.     $set_line_array = [$line_user, $line_password];
  101.     $set_line = $db->query("SELECT cms_lines.*, Count(cms_stream_activity.stream_activity_id) AS connected_streams FROM cms_lines LEFT OUTER JOIN cms_stream_activity ON cms_lines.line_id = cms_stream_activity.stream_activity_line_id AND cms_stream_activity.stream_activity_kill = 0 WHERE line_user = ? AND line_pass = ?", $set_line_array);
  102.     if ($set_line[0]["line_status"] == "3") {
  103.         $status = "banned";
  104.     } else {
  105.         if ($set_line[0]["line_status"] == "2") {
  106.             $status = "expired";
  107.         } else {
  108.             if ($set_line[0]["line_status"] == "4") {
  109.                 $status = "kicked";
  110.             } else {
  111.                 if (0 < $set_line[0]["connected_streams"]) {
  112.                     $status = "active";
  113.                 } else {
  114.                     $status = "inactive";
  115.                 }
  116.             }
  117.         }
  118.     }
  119.     $output_array = ["allowed_connection" => $set_line[0]["line_connection"], "used_connection" => $set_line[0]["connected_streams"], "allowed_hls_connection" => $set_line[0]["line_allowed_hls"], "expire_date" => date("d.m.Y", $set_line[0]["line_expire_date"]), "restreamer" => $set_line[0]["line_is_restreamer"] == 1 ? "YES" : "NO", "status" => $status];
  120.     echo json_encode($output_array);
  121. }
  122.  
  123. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top