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

Commit

Permalink
add wget support
Browse files Browse the repository at this point in the history
  • Loading branch information
satouriko committed Jul 22, 2017
1 parent 0c8df12 commit 002c273
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
NEU-IPGW(Linux)
=

[![GitHub stars](https://img.shields.io/github/stars/2645Corp/neu-ipgw_linux.svg)](https://github.com/2645Corp/neu-ipgw_linux/stargazers)
[![GitHub release](https://img.shields.io/github/release/2645Corp/neuipgw_linux.svg?maxAge=2592000)](https://github.com/2645Corp/neuipgw_linux/releases)
[![2645 Studio](https://img.shields.io/badge/Powered%20by-2645%20Studio-yellowgreen.svg)](http://www.cool2645.com/)

Expand All @@ -26,4 +27,4 @@ You may change the configuration of the installed program by editing `~/.neuipgw

**If you prefer not to install it,**

Just sh the ipgw.sh, it will also work okay. The configuration will be sourced from the file `user.cfg` under the same directory as the program.
Just run the ipgw.sh, it will also work okay. The configuration will be sourced from the file `user.cfg` under the same directory as the program.
42 changes: 37 additions & 5 deletions ipgw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ requireuinfo()
disconnect()
{
requireuinfo
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" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" 2>&1`
if [ ! -x "$(command -v curl)" ]; then
if [ ! -x "$(command -v wget)" ]; then
echo "Error: Neither curl nor wget is installed"
else
LOGOUT=`wget -q --post-data="action=logout&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" -O - 2>&1`
fi
else
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" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" 2>&1`
fi
if [[ "$LOGOUT" =~ "网络已断开" ]];
then
echo "断开连接成功!"
Expand All @@ -57,7 +65,15 @@ disconnect()
connectasphone()
{
requireuinfo
LOGIN=`curl -H "Content-type: application/x-www-form-urlencoded" -A "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4" -s -d "action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" 2>&1`
if [ ! -x "$(command -v curl)" ]; then
if [ ! -x "$(command -v wget)" ]; then
echo "Error: Neither curl nor wget is installed"
else
LOGIN=`wget --header="Content-type: application/x-www-form-urlencoded" --header="User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4" -q --post-data="action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" -O - 2>&1`
fi
else
LOGIN=`curl -H "Content-type: application/x-www-form-urlencoded" -A "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A366 Safari/600.1.4" -s -d "action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" 2>&1`
fi
if [[ "$LOGIN" =~ "网络已连接" ]];
then
echo "网络连接成功!"
Expand All @@ -71,7 +87,15 @@ connectasphone()
connect()
{
requireuinfo
LOGIN=`curl -H "Content-type: application/x-www-form-urlencoded" -A "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -s -d "action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" 2>&1`
if [ ! -x "$(command -v curl)" ]; then
if [ ! -x "$(command -v wget)" ]; then
echo "Error: Neither curl nor wget is installed"
else
LOGIN=`wget --header="Content-type: application/x-www-form-urlencoded" --header="User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -q --post-data="action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" -O - 2>&1`
fi
else
LOGIN=`curl -H "Content-type: application/x-www-form-urlencoded" -A "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36" -s -d "action=login&ac_id=1&user_ip=&nas_ip=&user_mac=&url=&username=$USER_NAME&password=$USER_PASS&save_me=0" "https://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&" 2>&1`
fi
if [[ "$LOGIN" =~ "网络已连接" ]];
then
echo "网络连接成功!"
Expand All @@ -84,7 +108,15 @@ connect()
}
query()
{
INFO=`curl -s -d "action=get_online_info&key=$k" "https://ipgw.neu.edu.cn/include/auth_action.php?k=$k" 2>&1`
if [ ! -x "$(command -v curl)" ]; then
if [ ! -x "$(command -v wget)" ]; then
echo "Error: Neither curl nor wget is installed"
else
INFO=`wget -q --post-data="action=get_online_info&key=$k" "https://ipgw.neu.edu.cn/include/auth_action.php?k=$k" -O - 2>&1`
fi
else
INFO=`curl -s -d "action=get_online_info&key=$k" "https://ipgw.neu.edu.cn/include/auth_action.php?k=$k" 2>&1`
fi
#echo $k;
#echo $INFO;
DATA=${INFO%%,*}
Expand Down Expand Up @@ -203,5 +235,5 @@ fi
#echo $LOGOUT
#echo $LOGIN

sleep 3s
sleep 2s

0 comments on commit 002c273

Please sign in to comment.