From 6bad0902f2527a78fe717d7f939a5544ad329afa Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 21 Jul 2017 17:14:47 +0200 Subject: [PATCH] Added ap/ip (network identity) scripts to [api:fetch] --- lib/api/source/fetch.php | 4 ++-- lib/netid/ap | 9 +++++++++ lib/netid/ip | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 lib/netid/ap create mode 100755 lib/netid/ip diff --git a/lib/api/source/fetch.php b/lib/api/source/fetch.php index 8163c7b..cba02fc 100755 --- a/lib/api/source/fetch.php +++ b/lib/api/source/fetch.php @@ -12,8 +12,8 @@ 'default' => [], 'feature' => [], 'identity' => [ - 'ap' => preg_replace('/\s+/', '', file_get_contents(TMP_DIR.'/net.ap')), - 'ip' => preg_replace('/\s+/', '', file_get_contents(TMP_DIR.'/net.ip')) + 'ap' => syscall(TMP_DIR.'/net.ap'), + 'ip' => syscall(TMP_DIR.'/net.ip') ] ]; diff --git a/lib/netid/ap b/lib/netid/ap new file mode 100755 index 0000000..7e12f65 --- /dev/null +++ b/lib/netid/ap @@ -0,0 +1,9 @@ +#!/bin/bash + +# (1) Get wireless iface # +IFACE=`ifconfig | grep -o -P "^w\w+"`; + +# (2) Get Access Point ID # +AP=`iwconfig $IFACE | grep -o -P 'ESSID:"SATS_.+"' | sed 's/ESSID:"SATS_//' | sed 's/"$//'`; + +echo $AP; diff --git a/lib/netid/ip b/lib/netid/ip new file mode 100755 index 0000000..05734a3 --- /dev/null +++ b/lib/netid/ip @@ -0,0 +1,9 @@ +#!/bin/bash + +# (1) Get wireless iface # +IFACE=`ifconfig | grep -o -P "^w\w+"`; + +# (2) Get Access Point ID # +IP=`ifconfig $IFACE | grep -o -P 'inet addr:[\d\.]+' | sed 's/inet addr://'`; + +echo $IP;