#!/bin/sh # # add-profile-line.sh - simple Atlantis.SK profile appender # # Written by Martin Karas # Multiple lines feature by Ondrej Jombik [03/09/2002] # Adds input data to current Atlantis.SK profile # Copyright (c) 2002-2003 Platon SDG, http://www.platon.sk/ # Licensed under terms of GNU General Public License. # # $Platon: add-profile-line.sh,v 1.4 2002/09/03 13:44:25 nepto Exp $ CONFIG_FILE="$HOME/.atlantis.conf"; if [ -f "$CONFIG_FILE" ]; then NAME=`grep -E '^username[ ]*=[ ]*' $CONFIG_FILE \ | sed 's/^username[ ]*=[ ]*\(.*\)$/\1/' \ | head -n 1`; PASS=`grep -E '^password[ ]*=[ ]*' $CONFIG_FILE \ | sed 's/^password[ ]*=[ ]*\(.*\)$/\1/' \ | head -n 1`; fi if [ -z "$NAME" ]; then echo -n 'Enter username: '; IF= read NAME; else echo "Using username '$NAME' from configuration file '$CONFIG_FILE'."; fi if [ -z "$NAME" ]; then echo "Empty username is not allowed."; exit 1; fi if [ -z "$PASS" ]; then echo -n 'Enter password: '; stty -echo; IF= read PASS; stty echo; echo ""; # to write newline on output fi if [ -z "$PASS" ]; then echo "Empty password is not allowed."; exit 1; fi echo -n 'Enter lines to be appended'; echo ' (empty data removes whole profile; use ^c to abort):'; text=`cat` # text from stdin, multiple lines text=`echo -n "$text" \ | awk 'BEGIN { ORS="\n" } \ { gsub(/%/, "%25"); \ gsub(/\+/, "%2B"); \ gsub(/[ ]/, "+"); \ gsub(/\&/, "%26"); \ print; }' \ | perl -wpe 's/\n/%0A/g;s/\r/%0D/g'`; text="$text"; # download the file via special wget which stores session cookie to a file # debug #echo "Logging in as '$NAME':'$PASS'"; GET http://www.atlantis.sk/profile/index.php?username="$NAME"\&password="$PASS"\&action=login >tmp.html; PHPSESSID=`grep '<' tmp.html | head -n 1 | sed 's/.*.*/\1/'` ORIG_PROFILE=`awk 'BEGIN { haluz=0;} /