Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
phpbb-auto-login.sh
#!/bin/sh
# phpbb-auto-login.sh copyleft Fabio Z 2009
# login & logout user to phpBB forum boards
# http://www.zoros.org/wiki/index.php?title=A_script_to_login_phpbb_forum_using_wget
if [ $# -le 1 ] || [ $# -gt 3 ]; then
echo "Usage $0 URL user pass --> to login"
echo "Usage $0 URL user --> to logout"
fi
PHPBB_URL=http://$1
USER=$2
PASS=$3
#--------------------------- login ---------------------------
if [ $# -eq 3 ] ; then
wget --save-cookies=./session-cookies-$USER $PHPBB_URL/ucp.php?mode=login -O - 1> /dev/null 2> /dev/null
SID=`cat ./session-cookies-$USER | grep _sid | cut -d$'\011' -f7`
echo "Login $USER --> $PHPBB_URL SID=$SID"
wget --save-cookies=./session-cookies-$USER \
--post-data="username=$USER&password=$PASS&redirect=index.php&sid=$SID&login=Login" \
$PHPBB_URL/ucp.php?mode=login --referer="$PHPBB_URL/ucp.php?mode=login" \
-O - 1> /dev/null 2> /dev/null
fi
#-------------------------- logout --------------------------
if [ $# -eq 2 ] ; then
SID=`cat ./session-cookies-$USER | grep _sid | cut -d$'\011' -f7`
echo "Logout $USER <-- $PHPBB_URL SID=$SID"
wget --load-cookies=./session-cookies-$USER "$PHPBB_URL/ucp.php?mode=logout&sid=$SID" --referer="$PHPBB_URL/index.php" -O - 1> /dev/null 2> /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.