Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
initially
Browse files Browse the repository at this point in the history
  • Loading branch information
satouriko committed May 21, 2016
1 parent 935e11a commit 55bab80
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
53 changes: 53 additions & 0 deletions ipgw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#########################################################################
# File Name: ipgw.sh
# Author: Li Jiahao
# ###############
# mail: [email protected]
# Created Time: Sat 21 May 2016 10:50:21 AM CST
#########################################################################
#!/bin/bash

source ./user.cfg

LOGOUT=`curl -s -d "action=logout&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "http://ipgw.neu.edu.cn:803/srun_portal_pc.php?ac_id=1&" 2>&1`
LOGIN=`curl -s -d "action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "http://ipgw.neu.edu.cn:803/srun_portal_pc.php?ac_id=1&" 2>&1`

k=$RANDOM


if [[ "$LOGIN" =~ "网络已连接" ]];
then
echo "连接成功!"
INFO=`curl -s -d "action=get_online_info&key=$k" "http://ipgw.neu.edu.cn:803/include/auth_action.php?k=$k" 2>&1`
#echo $k;
#echo $INFO;
DATA=${INFO%%,*}
DATAG=$[$DATA/(1024*1024*1024)]
DATAM=$[$DATA%(1024*1024*1024)/(1024*1024)]
if [ $DATAG != 0 ];
then
echo "已用流量:$DATAG GiB $DATAM MiB"
else
echo "已用流量:$DATAM MiB"
fi
TEMP=${INFO#*,}
TIME=${TEMP%%,*}
TIMEH=$[$TIME/(60*60)]
TIMEM=$[$TIME%(60*60)/(60)]
TIMES=$[$TIME%60]
echo "已用时长:$TIMEH:$TIMEM:$TIMES"
TEMP=${TEMP#*,}
BALANCE=${TEMP%%,*}
echo "账户余额:$BALANCE"
IP=${INFO##*,}
echo "IP地址:$IP"

else
echo "连接失败!"
TEMP=${LOGIN#*<p>}
echo ${TEMP%%</p>*}
fi

#echo $LOGOUT
#echo $LOGIN

3 changes: 3 additions & 0 deletions user.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
USER_NAME=
USER_PASS=

0 comments on commit 55bab80

Please sign in to comment.