[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
Backup
/
05122024
/
htdocs
/
sifeeder
/
[
Home
]
File: createToken.inc.php
<?php $id = ""; $kode = ""; $userf = ""; $pwdf = ""; $buton = "Simpan"; $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']; } $ip = "http://".$ip.":3003/ws/live2.php?=&="; echo $ip; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $ip, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "act":"GetToken", "username":"admin@stikesbpi.ac.id", "password":"Khzwa8awaA" }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); //echo $response; $json_array =json_decode($response, true); $newtoken = $json_array['data']['token']; $kode = $json_array['data']['token']; } if(isset($_GET["deleteID"])) { $sql = "delete from set_session where id = ".$_GET["deleteID"]; if (mysqli_query($conn, $sql)) { echo "<script>window.alert('Data Sudah Terhapus');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } if(isset($_GET["setaktif"])) { $setz = mysqli_query($conn, "update set_session set aktif = 0"); $sql = "update set_session set aktif = 1 where id = ".$_GET["setaktif"]; if (mysqli_query($conn, $sql)) { echo "<script>window.alert('Set Aktif');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } if(isset($_POST["Simpan"]) || isset($_POST["Koreksi"])) { if(isset($_POST["kode"])) $kode = $_POST["kode"]; if(isset($_POST["id"])) $id = $_POST["id"]; $tbField[0] = "kode"; $tbIsi[0] = "'".$kode."'"; if(isset($_POST["Simpan"])) { $nmField = compile_array($tbField); $isiField = compile_array($tbIsi); $sql = "insert into set_session (".$nmField.") values (".$isiField.")"; $notif = $ssm; } if(isset($_POST["Koreksi"])) { $compileSet = compile_array2($tbField,$tbIsi); $sql = "update set_session set ".$compileSet." where id = ".$id; $notif = $sum; } if (mysqli_query($conn, $sql)) { echo "<script>window.alert('".$notif."');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } ?> <h1 class="h3 mb-4 text-gray-800">Create Token</h1> <div class="row"> <div class="col-lg-12"> <div class="p-5"> <form class="user" action="dashboard.php?createToken" accept-charset="utf-8" method="post"> <div class="form-group"> <input value="<?php echo $id;?>" name="id" type="hidden"> <input value="<?php echo $kode;?>" name="kode" type="text" class="form-control form-control-user" id="exampleInputEmail" placeholder="kode token"> </div> <div class="form-group row"> <div class="col-sm-3 mb-3 mb-sm-0"> <button name="<?php echo $buton;?>" type="submit" class="btn btn-primary btn-user btn-block"><?php echo $buton;?></button> </div> <div class="col-sm-3"> <button name="Cancel" type="submit" class="btn btn-primary btn-user btn-block">Cancel</button> </div> </div> </form> </div> </div> </div> <div class="container-fluid"> <!-- Page Heading --> <!-- DataTales Example --> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 font-weight-bold text-primary">DataTables</h6> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>Aksi</th> <th>Timestamp</th> <th>Tokens</th> </tr> </thead> <tfoot> <tr> <th>Aksi</th> <th>Timestamp</th> <th>Tokens</th> </tr> </tfoot> <tbody> <?php $sql = "SELECT * FROM set_session order by id desc"; echo $sql; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { ?> <tr> <td> <a class="btn btn-primary btn-danger" href="dashboard.php?createToken&deleteID=<?php echo $row['id'];?>"><i class="fas fa-trash"></i></a> </td> <td><?php echo $row['tgl'];?></td> <td><?php echo $row['kode'];?></td> </tr> <?php } } ?> </tbody> </table> </div> </div> </div> </div>