Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for scripts/shell/sms/sity.sk/sms.sh between version 1.40 and 1.41

version 1.40, 2002/07/31 23:21:44 version 1.41, 2002/09/06 21:55:24
Line 6 
Line 6 
 # Written by Martin Karas.  # Written by Martin Karas.
 # Alias support by Ondrej Jombik [20/06/2002]  # Alias support by Ondrej Jombik [20/06/2002]
 # Alias support simplification by Lubomir Host [21/06/2002]  # Alias support simplification by Lubomir Host [21/06/2002]
   # Other changes by Lubomir Host [06-09/2002]
 # Based on script flash.sh by Ondrej Jombik  # Based on script flash.sh by Ondrej Jombik
 # Copyright (c) 2002 Platon SDG, http://www.platon.sk/  # Copyright (c) 2002 Platon SDG, http://www.platon.sk/
 #  #
Line 23  GET="make_http_request_GET" # use build-
Line 24  GET="make_http_request_GET" # use build-
 CONFIG_FILE="$HOME/.sms.sh.conf";  CONFIG_FILE="$HOME/.sms.sh.conf";
 ALIAS_FILE="$HOME/.sms.sh.alias";  ALIAS_FILE="$HOME/.sms.sh.alias";
   
 WWW="http://www.sity.sk/pls/sity"  WWW="http://www.sity.sk"
 # Function usage() {{{  # Function usage() {{{
 usage()  usage()
 {  {
Line 59  do
Line 60  do
   
                 -*) ;; # ignore                  -*) ;; # ignore
   
                 Cookie:*) cookies=`echo $option | sed 's/^Cookie: //;'` ;;                  Cookie:*) cookies="`echo $option | sed 's/^Cookie: //;'`" ;;
                 http:*)   http="$option" ;;                  http:*)   http="$option" ;;
   
         esac          esac
 done  done
   if [ ! -z "$DEBUG" ]; then
           echo "GET -H 'Cookie: $cookies' '$http'" > /dev/stderr
   fi
 echo "$cookies $http" | perl -w -e '  echo "$cookies $http" | perl -w -e '
 #!/usr/bin/perl -w  #!/usr/bin/perl -w
   
Line 111  sub http_get
Line 115  sub http_get
   
   
     $sock->flush();      $sock->flush();
     while (<$sock>) {  
           while (<$sock>) {
         print;          print;
     }      }
     $sock->close();      $sock->close();
Line 124  while (<STDIN>) {
Line 129  while (<STDIN>) {
     my $url;      my $url;
         my $cookies = "";          my $cookies = "";
   
         chop;          chomp;
         ($cookies, $http) = split / /, $_, 2;          ($cookies, $http) = split /http:\/\//, $_, 2;
         $http =~ s|^http://||;          #$http =~ s|^http://||;
         ($server, $url) = split /\//, $http, 2;          ($server, $url) = split /\//, $http, 2;
         substr($cookies, 0, 0) = "Cookie: "; # put string at begin          substr($cookies, 0, 0) = "Cookie: "; # put string at begin
         substr($url, 0, 0) = "/";          substr($url, 0, 0) = "/";
Line 137  while (<STDIN>) {
Line 142  while (<STDIN>) {
 exit;'  exit;'
 }  }
 # make_http_request_GET() }}}  # make_http_request_GET() }}}
   # implementation of img2text {{{
   img2text()
   {
   
   awk '#!/usr/bin/awk -f
   
   # $Id$
   
   # Author:  Lubomir Host rajo <rajo AT host.sk>
   # License: GNU GPL
   
   # Script for converting images to text files.
   # Usefull for script, which will send SMS message over public SMS gateway. ;)
   
   # Usage: cat img.png | convert - text:- | ./img2text
   # Enjoy flooding sms gateway! ;))
   
   BEGIN {
           FS="[,:# \t]+"
           prev_line = 0;
           line   = 1;
           column = 0;
           color  = "";
           start_char = 41;
   }
   
   {
           n = split($0, a, FS);
   
           column = a[1];
           line   = a[2];
           color  = a[6];
           if (colormap[color] == 0) {
                   #printf "adding color %s to colormap\n", color;
                   colormap[color] = ++start_char;
           }
           if (column == 0 && line == 0) {
                   # first pixel 0,0 is probably background color,
                   # we will background filled with spaces
                   colormap[color] = 32;
           }
           output[line] = sprintf("%s%c", output[line], colormap[color]);
   }
   
   END {
           for (i = 0; i <= line; i++) {
                   if (output[i] !~ /^ +$/)
                           printf "%s\n", output[i];
           }
   }'
   
   } # }}}
   
 if [ $# -lt 1 ]; then  if [ $# -lt 1 ]; then
         usage          usage
Line 342  if [ -z "$PASS" ]; then
Line 399  if [ -z "$PASS" ]; then
 fi  fi
 # }}}  # }}}
   
 # Read message from stdin {{{  
 echo 'Enter your message (max 420 chars, end with CTRL-D):';  
 text=`cat` # text from stdin, multiple lines  
 text="`echo \"$text\" \  
         | awk 'BEGIN { ORS="+" } \  
         {   gsub(/%/,  "%25"); \  
                 gsub(/\+/, "%2B"); \  
                 gsub(/ /,  "+"); \  
                 gsub(/\&/, "%26"); \  
                 print; }'`"  
 # }}}  
   
 if [ "x$text" == "x+" ]; then  
         echo "Empty message is not allowed.";  
         exit 1;  
 fi  
   
 # Get cookies {{{  # Get cookies {{{
 # 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
 # Cookies format:  # Cookies format:
   # ^Set-Cookie: id=0a06b40e84a780fa;expires=Saturday, 07-Sep-2002 07:43:41 GMT
 # ^Set-Cookie: SITY=32E0DDB9AF9293E774AA1C0B5BCC0992;path=/$  # ^Set-Cookie: SITY=32E0DDB9AF9293E774AA1C0B5BCC0992;path=/$
 echo 'Logging in...';  echo 'Logging in...';
 COOKIE=`$GET -P -e -H "Cookie: SITY=SITY" \  COOKIE=`$GET -P -e -H "Cookie: SITY=SITY" \
         $WWW/u_registrate2.login2?NAME="$NAME"\&PASSWD="$PASS"\&ASERVICE=0\&CMD=%21u_sms.home\&SERVICE=0 \          $WWW/pls/sity/u_registrate2.login2?NAME="$NAME"\&PASSWD="$PASS"\&ASERVICE=0\&CMD=%21u_sms.home\&SERVICE=0 \
         | awk 'BEGIN { FS="[=;]" } /^Set-Cookie:/ { print $2; }'`;          | awk 'BEGIN { FS="[ ;]+" } /^Set-Cookie:/ { print $2; }'`;
 # }}}  
   
 # Checking number of free SMSs {{{  
 echo -n 'Checking number of free SMSs... ';  
 smss_sent=`$GET -P -H "Cookie: SITY=$COOKIE" \  
         $WWW/u_profil.show_stat \  
         | awk '/^<TD>[0-9]+<\/TD>$/ { gsub(/[><]/, " "); print $2;  exit; } '`;  
   
 echo "100-$smss_sent" | bc;  
 # }}}  # }}}
   
 # Retrieving submit forms... {{{  # Retrieving submit forms... {{{
Line 390  else
Line 422  else
 fi  fi
   
 #we now extract textarea name, which will be used later  #we now extract textarea name, which will be used later
 request=` $GET -P -H "Cookie: SITY=$COOKIE" \  request=` $GET -P -H "Cookie: $COOKIE" \
         $WWW/\!u_sms.home $SAVE_DEBUG_OUTPUT \          $WWW/pls/sity/\!u_sms.home $SAVE_DEBUG_OUTPUT \
         | awk -v number="$number" '          | awk -v number="$number" '
 BEGIN { printf "&SMSMsgLen=480&SMScount=&"; }  BEGIN { printf "&SMSMsgLen=480&SMScount=&"; }
 /textarea cols/ {  /textarea cols/ {
         sub(/^.*name="/, "");          sub(/^.*name="/, "");
         gsub(/".*$/, "");          sub(/".*$/, "");
         printf "%s=%s&BT.x=0&BT.y=0&DETAIL=", $0, number;          printf "%s=%s&BT.x=0&BT.y=0&DETAIL=", $0, number;
 }  }
 /DETAIL/ {  /DETAIL/ {
         sub(/^.*value="/, "");          sub(/^.*value="/, "");
         gsub(/".*$/, "");          sub(/".*$/, "");
         printf "%s", $0 ;          printf "%s", $0;
   }
   
   /CHECK/ { # kontrolny retazec
           sub(/^.*src="/, "");
           sub(/>.*$/, "");
           printf "CHECK=%s", $0;
   
 } '`  } '`
 echo 'Hold still, we need to wait 4 seconds.';  
 sleep 4;  # }}}
   
   # Getting check code {{{
   url=`echo $request | sed 's/.*CHECK=\([^"]\+\)".*$/\1/;'`
   # we must set id=... also as cookies :-)
   COOKIE=`echo "$url; $COOKIE" | sed 's/^[^?]*?//g;'`
   
   if [ ! -z "$DEBUG" ]; then
           echo "image URL: $WWW$url"
   fi
   while [ -z "$checkcode" ]; do
           $GET -P -H "Cookie: $COOKIE" "$WWW$url" \
                   | perl -e 'while (<STDIN>) { chomp; last unless (m/\S/); } my $haluz=<STDIN>; while (<STDIN>) { print; }' \
                   | convert - txt:- | img2text | head -n 15
   
           echo -en "Please enter CHECK code (or press Ctrl+d to obtain another version): "
           read checkcode;
   done
   request=`echo $request | sed "s/CHECK=[^\"]\+\"\(.*\)$/CHECK=$checkcode\&\1/g;"`
   
   echo 'Hold still, please wait at least 4 seconds to submit form.';
   # sleep 4;
   # }}}
   
   # Checking number of free SMSs {{{
   echo -n 'Checking number of free SMSs... ';
   smss_sent=`$GET -P -H "Cookie: $COOKIE" \
           $WWW/pls/sity/u_profil.show_stat \
           | awk '/^<TD>[0-9]+<\/TD>$/ { gsub(/[><]/, " "); print $2;  exit; } '`;
   
   echo "100-$smss_sent" | bc;
   # }}}
   
   # Read message from stdin {{{
   echo 'Enter your message (max 420 chars, end with CTRL-D):';
   text=`cat` # text from stdin, multiple lines
   text="`echo \"$text\" \
           | awk 'BEGIN { ORS="+" } \
           {   gsub(/%/,  "%25"); \
                   gsub(/\+/, "%2B"); \
                   gsub(/ /,  "+"); \
                   gsub(/\&/, "%26"); \
                   print; }'`"
 # }}}  # }}}
   
   if [ "x$text" == "x+" ]; then
           echo "Empty message is not allowed.";
           exit 1;
   fi
   
 # Submitting SMS... {{{  # Submitting SMS... {{{
 echo 'Submitting SMS...';  echo 'Submitting SMS...';
 smss_left=`$GET -P -H "Cookie: SITY=$COOKIE" \  smss_left=`$GET -P -H "Cookie: $COOKIE" \
         $WWW/\!u_sms.send_sms?MSG_TEXT="$text""$request" \          $WWW/pls/sity/\!u_sms.send_sms?MSG_TEXT="$text""$request" \
         | grep "Tento mesiac" \          | grep "Tento mesiac" \
         | sed 's/.*va \([0-9]*\) spr.*/\1/'` ;          | sed 's/.*va \([0-9]*\) spr.*/\1/'` ;
 # }}}  # }}}

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top