[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
Backup
/
14082024
/
Data
/
htdocs
/
htdocs
/
simkeu
/
sia
/
[
Home
]
File: feeder_ws.php
<?php function runWs($data) { $conn = mysqli_connect('localhost','root','','enzo')or die('gagal, database tidak ditemukan'); $sql = "SELECT * FROM set_feeder where aktif = 1"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $ip = $row['ip']; $userf = $row['userf']; $pwdf = $row['pwdf']; } $url = "http://".$ip.":3003/ws/live2.php?=&="; } // $url="http://192.168.1.69:3003/ws/live2.php?=&="; $ch = curl_init(); if ($data) { $data = json_encode($data); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); } $headers = array(); $headers[]='Content-Type: application/json'; $headers[]='Content-Length: '.strlen($data); curl_setopt($ch,CURLOPT_HTTPHEADER,$headers); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout in seconds $result = curl_exec($ch); if(curl_errno($ch)){ $salah = curl_error($ch); $hasil = [ "error_code" => 1, "error_desc" => $salah, "data" => $data ]; $result = (object) $hasil; curl_close($ch); return json_encode($result); exit(); } curl_close($ch); return $result; } function token() { $conn = mysqli_connect('localhost','root','','enzo')or die('gagal, database tidak ditemukan'); $sql = "SELECT * FROM set_feeder where aktif = 1"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $ip = $row['ip']; $userf = $row['userf']; $pwdf = $row['pwdf']; } $url = "http://".$ip.":3003/ws/live2.php?=&="; } $data['act']="GetToken"; $data['username']=$userf; $data['password']=$pwdf; $token = json_decode(runWs($data)); $_SESSION['feeder_token'] = $token->data->token; return $token; }