Skip to content

Commit

Permalink
addDev
Browse files Browse the repository at this point in the history
  • Loading branch information
IoTcat committed Dec 30, 2020
1 parent 4e877a9 commit 1d19d8d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
include '/mnt/config/dbKeys/auth.php';
include '/mnt/config/dbKeys/log.php';
include '/mnt/config/php/config.php';
/**database connection**/

Expand Down
35 changes: 35 additions & 0 deletions getOnlineDevices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

include './functions.php';

$hash = $_GET['hash'];
if(!isset($hash)) die();


header('Access-Control-Allow-Origin:https://user.yimian.xyz');
header("Content-Type: application/json;charset=utf-8");

$cnn = db__connect();
$cnnLog = db__connect('log');
$res = db__getData($cnn, "token", 'hash', $hash);


$o = array();

foreach($res as $item){
if($item['state']){
$data = db__getData($cnn, 'fip', 'token', $item['token']);
$t = array();
foreach($data as $r) array_push($t, $r['created_at']);
array_multisort($t, $data);
$item['fp'] = $data[count($data)-1]['fp'];
$item['ip'] = $data[count($data)-1]['ip'];
$log = db__getData($cnnLog, 'log_iis', 'fp', $item['fp'], 'ip', ip2long($item['ip']));
if($log != 404){
$item['log'] = $log;
}
array_push($o, $item);
}
}

echo json_encode($o);
23 changes: 23 additions & 0 deletions logoutDevices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

include './functions.php';

$hash = $_GET['hash'];
$token = $_GET['token'];
if(!isset($hash) || !isset($token)) die();


header('Access-Control-Allow-Origin:https://user.yimian.xyz');
header("Content-Type: application/json;charset=utf-8");

$cnn = db__connect();

db__pushData($cnn, "token", array(
"state" => 0,
"updated_at" => date("Y-m-d H:i:s")
), array(
"token" => $token,
"hash" => $hash
));

echo json_encode(array("status"=>true));

0 comments on commit 1d19d8d

Please sign in to comment.