| verzia 1.3, 2002/06/20 14:53:55 |
verzia 1.4, 2002/09/03 13:44:25 |
|
|
| #!/bin/sh |
#!/bin/sh |
| |
|
| # |
# |
| # sms.sh - sity.sk SMS sender |
# add-profile-line.sh - simple Atlantis.SK profile appender |
| # |
# |
| # Written by Martin Karas. |
# Written by Martin Karas. |
| # Adds input line to current profile |
# Multiple lines feature by Ondrej Jombik [03/09/2002] |
| |
# Adds input data to current Atlantis.SK profile |
| # Copyright (c) 2002 Platon SDG, http://www.platon.sk/ |
# Copyright (c) 2002 Platon SDG, http://www.platon.sk/ |
| |
# Licensed under GNU GPL. |
| # |
# |
| |
|
| # $Id$ |
# $Id$ |
| Riadok 46 if [ -z "$PASS" ]; then |
|
| Riadok 48 if [ -z "$PASS" ]; then |
|
| exit 1; |
exit 1; |
| fi |
fi |
| |
|
| echo 'Enter LOGLINE to be appended:'; |
echo -n 'Enter lines to be appended'; |
| IF= read text; |
echo ' (empty data removes whole profile; use ^c to abort):'; |
| text=`echo "$text" | sed 's/%/%25/g; s/\+/%2B/g; s/ /+/g; s/&/%26/g'`; |
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 |
# download the file via special wget which stores session cookie to a file |
| # debug |
# debug |
| Riadok 57 GET http://www.atlantis.sk/profile/index |
|
| Riadok 68 GET http://www.atlantis.sk/profile/index |
|
| |
|
| PHPSESSID=`grep '<input type="hidden" name="PHPSESSID" value="[a-f0-9]*" \/><' tmp.html | head -n 1 | sed 's/.*<input type="hidden" name="PHPSESSID" value="\([a-f0-9]\+\)" \/>.*/\1/'` |
PHPSESSID=`grep '<input type="hidden" name="PHPSESSID" value="[a-f0-9]*" \/><' tmp.html | head -n 1 | sed 's/.*<input type="hidden" name="PHPSESSID" value="\([a-f0-9]\+\)" \/>.*/\1/'` |
| ORIG_PROFILE=`awk 'BEGIN { haluz=0;} /<textarea/ { haluz=1; gsub(/^.*textarea([^>]*)>/ , ""); print; next; } /^<\/textarea/ {haluz=0; next;} // { if (haluz==1) print; } ' tmp.html` |
ORIG_PROFILE=`awk 'BEGIN { haluz=0;} /<textarea/ { haluz=1; gsub(/^.*textarea([^>]*)>/ , ""); print; next; } /^<\/textarea/ {haluz=0; next;} // { if (haluz==1) print; } ' tmp.html` |
| NEW_PROFILE=`echo "$ORIG_PROFILE" | sed 's/%/%25/g; s/\+/%2B/g; s/ /+/g; s/&/%26/g'`; |
|
| NEW_PROFILE=`echo -e "$NEW_PROFILE\n$text"`; |
|
| |
|
| # debug |
if [ "X$text" = "X" ]; then |
| #echo "NEW_PROFILE=$NEW_PROFILE"; |
echo "Empty data, removing whole profile."; |
| |
NEW_PROFILE=""; |
| |
else |
| |
NEW_PROFILE=`echo -n "$ORIG_PROFILE" \ |
| |
| awk 'BEGIN { ORS="\n" } \ |
| |
{ gsub(/%/, "%25"); \ |
| |
gsub(/\+/, "%2B"); \ |
| |
gsub(/[ ]/, "+"); \ |
| |
gsub(/\&/, "%26"); \ |
| |
print; }' \ |
| |
| perl -wpe 's/\n/%0A/g;s/\r/%0D/g'`; |
| |
NEW_PROFILE="$NEW_PROFILE$text"; |
| |
fi |
| |
|
| |
#echo "NEW_PROFILE=[$NEW_PROFILE]"; |
| |
|
| GET -H "Cookie: PHPSESSID=$PHPSESSID" \ |
GET -H "Cookie: PHPSESSID=$PHPSESSID" \ |
| http://www.atlantis.sk/profile/index.php?PHPSESSID="$PHPSESSID"\&action=save\&pro="$NEW_PROFILE" \ |
http://www.atlantis.sk/profile/index.php?PHPSESSID="$PHPSESSID"\&action=save\&pro="$NEW_PROFILE" \ |
| Riadok 69 GET -H "Cookie: PHPSESSID=$PHPSESSID" \ |
|
| Riadok 92 GET -H "Cookie: PHPSESSID=$PHPSESSID" \ |
|
| |
|
| rm tmp.html |
rm tmp.html |
| rm tmp2.html |
rm tmp2.html |
| |
|