| verzia 1.18, 2001/10/24 19:24:49 |
verzia 1.19, 2001/10/25 09:37:57 |
|
|
| /* |
/* |
| * Author: rajo <host8@kepler.fmph.uniba.sk> |
* Author: rajo <host8@kepler.fmph.uniba.sk> |
| * $Log$ |
* $Log$ |
| |
* Revision 1.19 2001/10/25 09:37:57 host8 |
| |
* Added support for selection only some sms-gates. |
| |
* |
| * Revision 1.18 2001/10/24 19:24:49 host8 |
* Revision 1.18 2001/10/24 19:24:49 host8 |
| * Added parameter -p (look for password). |
* Added parameter -p (look for password). |
| * |
* |
|
|
| #include <getopt.h> |
#include <getopt.h> |
| //#include <netdb.h> |
//#include <netdb.h> |
| |
|
| |
#include "config.h" |
| #include "mail2sms.h" |
#include "mail2sms.h" |
| #include "http.h" |
#include "http.h" |
| #include "strings.h" |
#include "strings.h" |
| Riadok 45 char *message, *scratch, *keybd; |
|
| Riadok 49 char *message, *scratch, *keybd; |
|
| GLOB g; |
GLOB g; |
| WWW www; |
WWW www; |
| SERVER servers[] = { |
SERVER servers[] = { |
| |
#ifdef ENABLE_AZET |
| { AZET, "azet", "62.168.116.69", 80, 420 }, |
{ AZET, "azet", "62.168.116.69", 80, 420 }, |
| |
#endif |
| |
#ifdef ENABLE_WHIZDIARY |
| { WHIZDIARY, "whizdiary", "196.38.82.17", 80, 0 }, |
{ WHIZDIARY, "whizdiary", "196.38.82.17", 80, 0 }, |
| |
#endif |
| |
#ifdef ENABLE_SPISNET |
| { SPISNET, "spisnet", "195.168.233.131", 80, 132 }, |
{ SPISNET, "spisnet", "195.168.233.131", 80, 132 }, |
| |
#endif |
| |
#ifdef ENABLE_GLOBTELNET |
| { GLOBTELNET, "globtelnet", "213.151.200.27", 80, 0 }, |
{ GLOBTELNET, "globtelnet", "213.151.200.27", 80, 0 }, |
| |
#endif |
| |
#ifdef ENABLE_MTNSMS |
| { MTNSMS, "mtnsms", "196.36.119.197", 80, 0 }, |
{ MTNSMS, "mtnsms", "196.36.119.197", 80, 0 }, |
| |
#endif |
| { 0, NULL, NULL, 0, 0 } |
{ 0, NULL, NULL, 0, 0 } |
| }; |
}; |
| int id=-1; /* index to servers[] */ |
int id=-1; /* index to servers[] */ |
| Riadok 89 int sendsms(char *str, int show_info) |
|
| Riadok 103 int sendsms(char *str, int show_info) |
|
| //int info=show_info; |
//int info=show_info; |
| |
|
| // GET http request {{{ |
// GET http request {{{ |
| |
#ifdef ENABLE_AZET |
| if (id == AZET) { |
if (id == AZET) { |
| http_request(HTTP_GET, "/index.phtml?", "sms.azet.sk", NULL); |
http_request(HTTP_GET, "/index.phtml?", "sms.azet.sk", NULL); |
| http_set_referer("sms2.azet.sk", "/"); |
http_set_referer("sms2.azet.sk", "/"); |
| Riadok 99 int sendsms(char *str, int show_info) |
|
| Riadok 114 int sendsms(char *str, int show_info) |
|
| strlen(str), str); |
strlen(str), str); |
| |
|
| } |
} |
| else if (id == WHIZDIARY) { |
else |
| |
#endif |
| |
#ifdef ENABLE_WHIZDIARY |
| |
if (id == WHIZDIARY) { |
| http_request(HTTP_GET, "/home.asp", "www.whizdiary.com", NULL); |
http_request(HTTP_GET, "/home.asp", "www.whizdiary.com", NULL); |
| http_request(HTTP_GET, "/noCookies.asp", "www.whizdiary.com", NULL); |
http_request(HTTP_GET, "/noCookies.asp", "www.whizdiary.com", NULL); |
| http_request(HTTP_GET, "/default.asp", "www.whizdiary.com", NULL); |
http_request(HTTP_GET, "/default.asp", "www.whizdiary.com", NULL); |
| Riadok 111 int sendsms(char *str, int show_info) |
|
| Riadok 129 int sendsms(char *str, int show_info) |
|
| "Content-length: %d\r\n\r\n%s", |
"Content-length: %d\r\n\r\n%s", |
| strlen(str), str); |
strlen(str), str); |
| } |
} |
| else if (id == SPISNET) { |
else |
| |
#endif |
| |
#ifdef ENABLE_SPISNET |
| |
if (id == SPISNET) { |
| http_request(HTTP_GET, "/top.php3", "sms.spisnet.sk", NULL); |
http_request(HTTP_GET, "/top.php3", "sms.spisnet.sk", NULL); |
| http_request(HTTP_POST, "/smssend.php3", "sms.spisnet.sk", |
http_request(HTTP_POST, "/smssend.php3", "sms.spisnet.sk", |
| "Content-type: " |
"Content-type: " |
| Riadok 121 int sendsms(char *str, int show_info) |
|
| Riadok 142 int sendsms(char *str, int show_info) |
|
| strlen(str), str); |
strlen(str), str); |
| // "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
// "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
| } |
} |
| else if (id == GLOBTELNET) { |
else |
| |
#endif |
| |
#ifdef ENABLE_GLOBTELNET |
| |
if (id == GLOBTELNET) { |
| /* Begin of frames * |
/* Begin of frames * |
| http_request(HTTP_GET, "/get/guest/app.php3.html", |
http_request(HTTP_GET, "/get/guest/app.php3.html", |
| "www.globtelnet.sk", NULL); |
"www.globtelnet.sk", NULL); |
| Riadok 141 int sendsms(char *str, int show_info) |
|
| Riadok 165 int sendsms(char *str, int show_info) |
|
| "charset=windows-1250\r\n" |
"charset=windows-1250\r\n" |
| "Content-length: 51\r\n\r\n"" |
"Content-length: 51\r\n\r\n"" |
| form_name=login" |
form_name=login" |
| "&next_page=&wa_na=*****&wa_pa=*****"); |
"&next_page=&wa_na=%s&wa_pa=%s", |
| |
g.login, g.pass); |
| http_request(HTTP_POST, "/sms/do_sms_send.php3", "www.globtelnet.sk", |
http_request(HTTP_POST, "/sms/do_sms_send.php3", "www.globtelnet.sk", |
| "Content-type: " |
"Content-type: " |
| "application/x-www-form-urlencoded; " |
"application/x-www-form-urlencoded; " |
| Riadok 151 int sendsms(char *str, int show_info) |
|
| Riadok 176 int sendsms(char *str, int show_info) |
|
| http_request(HTTP_GET, "/comm/message.php3?readsess=1", |
http_request(HTTP_GET, "/comm/message.php3?readsess=1", |
| "www.globtelnet.sk", NULL); |
"www.globtelnet.sk", NULL); |
| } |
} |
| else if (id == MTNSMS) { |
else |
| |
#endif |
| |
#ifdef ENABLE_MTNSMS |
| |
if (id == MTNSMS) { |
| http_request(HTTP_GET, "/", "www.mtnsms.com", NULL); |
http_request(HTTP_GET, "/", "www.mtnsms.com", NULL); |
| http_request(HTTP_POST, "/session.asp", "www.mtnsms.com", |
http_request(HTTP_POST, "/session.asp", "www.mtnsms.com", |
| "Content-type: " |
"Content-type: " |
| "application/x-www-form-urlencoded; " |
"application/x-www-form-urlencoded; " |
| "Content-length: 77\r\n\r\n%s", |
"Content-length: 77\r\n\r\n%s", |
| "username=********&" |
"username=%s&" |
| "password=********&email=&" |
"password=%s&email=&" |
| "joinusclick=no&returl=&x=40&y=39"); |
"joinusclick=no&returl=&x=40&y=39", |
| |
g.login, g.pass); |
| } |
} |
| |
#endif |
| // }}} |
// }}} |
| |
|
| fprintf(stderr, "text to sms [%d chars]:'%s'\n", |
fprintf(stderr, "text to sms [%d chars]:'%s'\n", |
| Riadok 170 int sendsms(char *str, int show_info) |
|
| Riadok 200 int sendsms(char *str, int show_info) |
|
| // Function analyze_mail() {{{ |
// Function analyze_mail() {{{ |
| void analyze_mail(char *str) |
void analyze_mail(char *str) |
| { |
{ |
| int j; |
|
| char *pom; |
char *pom; |
| |
|
| if (str == NULL) return; |
if (str == NULL) return; |
| Riadok 254 void print_usage(char *argv0) |
|
| Riadok 283 void print_usage(char *argv0) |
|
| { |
{ |
| fprintf(stderr, "Usage: %s [OPTIONS] [MESSAGE] ...\n", argv0); |
fprintf(stderr, "Usage: %s [OPTIONS] [MESSAGE] ...\n", argv0); |
| fprintf(stderr, " --number povinne tel. cislo [421903838302]\n"); |
fprintf(stderr, " --number povinne tel. cislo [421903838302]\n"); |
| fprintf(stderr, " --gate " |
fprintf(stderr, " --gate [" |
| "[azet|whizdiary|spisnet|globtelnet|mtnsms]\n"); |
#ifdef ENABLE_AZET |
| |
"azet|" |
| |
#endif |
| |
#ifdef ENABLE_WHIZDIARY |
| |
"whizdiary|" |
| |
#endif |
| |
#ifdef ENABLE_SPISNET |
| |
"spisnet|" |
| |
#endif |
| |
#ifdef ENABLE_GLOBTELNET |
| |
"globtelnet|" |
| |
#endif |
| |
#ifdef ENABLE_MTNSMS |
| |
"mtnsms" |
| |
#endif |
| |
"]\n"); |
| fprintf(stderr, " --mail standardny vstup je mail\n"); |
fprintf(stderr, " --mail standardny vstup je mail\n"); |
| fprintf(stderr, " --nomail standardny vstup nie je mail\n"); |
fprintf(stderr, " --nomail standardny vstup nie je mail\n"); |
| fprintf(stderr, " --reverse zmena poradia smsiek [123] -> [321]\n"); |
fprintf(stderr, " --reverse zmena poradia smsiek [123] -> [321]\n"); |
| Riadok 373 int main(int argc, char *argv[]) |
|
| Riadok 417 int main(int argc, char *argv[]) |
|
| scratch = (char *) malloc(SCRATCH_LEN*sizeof(char)); |
scratch = (char *) malloc(SCRATCH_LEN*sizeof(char)); |
| keybd = (char *) malloc(KEYBD_LEN*sizeof(char)); |
keybd = (char *) malloc(KEYBD_LEN*sizeof(char)); |
| |
|
| |
// Preprocessing message {{{ |
| |
#ifdef ENABLE_AZET |
| if (id == AZET) { |
if (id == AZET) { |
| //komu=0903&predvolba=0903&cislo=838302&sprava=caf+pokus1%0adaskfjkadf+%3Csipky%3E%0ahalo&oslovenie=Ahoj+Milacik%21+&velkost=420&odoslat=Ok&odoslat.x=0&odoslat.y=0", |
//komu=0903&predvolba=0903&cislo=838302&sprava=caf+pokus1%0adaskfjkadf+%3Csipky%3E%0ahalo&oslovenie=Ahoj+Milacik%21+&velkost=420&odoslat=Ok&odoslat.x=0&odoslat.y=0", |
| strcpy(message, "komu="); |
strcpy(message, "komu="); |
| Riadok 383 int main(int argc, char *argv[]) |
|
| Riadok 429 int main(int argc, char *argv[]) |
|
| strncat(message, g.number + 4, (strlen(g.number) - 4) ); |
strncat(message, g.number + 4, (strlen(g.number) - 4) ); |
| strcat(message, "&sprava="); |
strcat(message, "&sprava="); |
| } |
} |
| else if (id == WHIZDIARY) { |
else |
| |
#endif |
| |
#ifdef ENABLE_WHIZDIARY |
| |
if (id == WHIZDIARY) { |
| strcpy(message, "theAction=Send+Message&cellnum=%2B"); |
strcpy(message, "theAction=Send+Message&cellnum=%2B"); |
| strncat(message, g.number, strlen(g.number)); |
strncat(message, g.number, strlen(g.number)); |
| strcat(message, "&message="); |
strcat(message, "&message="); |
| } |
} |
| else if (id == SPISNET) { |
else |
| |
#endif |
| |
#ifdef ENABLE_SPISNET |
| |
if (id == SPISNET) { |
| strcpy(message, "smsn="); |
strcpy(message, "smsn="); |
| strncat(message, g.number, strlen(g.number)); |
strncat(message, g.number, strlen(g.number)); |
| strcat(message, "&chars=0"); |
strcat(message, "&chars=0"); |
| strcat(message, "&smsm="); |
strcat(message, "&smsm="); |
| } |
} |
| else if (id == GLOBTELNET) { |
else |
| |
#endif |
| |
#ifdef ENABLE_GLOBTELNET |
| |
if (id == GLOBTELNET) { |
| strcpy(message, "f_Slot_num=&f_Redirect=%2Fsms%2Fsms.php3" |
strcpy(message, "f_Slot_num=&f_Redirect=%2Fsms%2Fsms.php3" |
| "&f_TelNumber="); |
"&f_TelNumber="); |
| strncat(message, g.number, strlen(g.number)); |
strncat(message, g.number, strlen(g.number)); |
| strcat(message, "&x=25&y=10"); |
strcat(message, "&x=25&y=10"); |
| strcat(message, "&f_SMSBody="); |
strcat(message, "&f_SMSBody="); |
| } |
} |
| else if (id == MTNSMS) { |
else |
| |
#endif |
| |
#ifdef ENABLE_MTNSMS |
| |
if (id == MTNSMS) { |
| } |
} |
| |
#endif |
| |
// }}} Preprocessing message |
| |
|
| if (optind < argc) { |
if (optind < argc) { |
| |
#ifdef DEBUG |
| if (g.debug) |
if (g.debug) |
| fprintf (stderr, "non-option ARGV-elements:\n"); |
fprintf (stderr, "non-option ARGV-elements:\n"); |
| |
#endif |
| while (optind < argc) { |
while (optind < argc) { |
| |
#ifdef DEBUG |
| if (g.debug) |
if (g.debug) |
| fprintf (stderr, "%s ", argv[optind]); |
fprintf (stderr, "%s ", argv[optind]); |
| |
#endif |
| strcat(message, argv[optind++]); |
strcat(message, argv[optind++]); |
| if (argv[optind] != NULL) strcat(message, "+"); |
if (argv[optind] != NULL) strcat(message, "+"); |
| } |
} |
| fprintf(stderr, "\n"); |
#ifdef DEBUG |
| if (g.debug) |
if (g.debug) |
| fprintf (stderr, "\n"); |
fprintf (stderr, "\n"); |
| |
#endif |
| } |
} |
| fprintf(stderr, "message: %s\n", message); |
fprintf(stderr, "message: %s\n", message); |
| |
|
| Riadok 443 int main(int argc, char *argv[]) |
|
| Riadok 508 int main(int argc, char *argv[]) |
|
| } // end switch ( select() ) |
} // end switch ( select() ) |
| } // end while (!koniec) |
} // end while (!koniec) |
| strcat(message, g.text); |
strcat(message, g.text); |
| |
// Postprocessing message {{{ |
| |
#ifdef ENABLE_AZET |
| if (id == AZET) { |
if (id == AZET) { |
| strcat(message, "&oslovenie=Ahoj+Milacik%21+&velkost=420" |
strcat(message, "&oslovenie=Ahoj+Milacik%21+&velkost=420" |
| "&odoslat=Ok&odoslat.x=0&odoslat.y=0"); |
"&odoslat=Ok&odoslat.x=0&odoslat.y=0"); |
| } |
} |
| else if (id == WHIZDIARY) { |
else |
| |
#endif |
| |
#ifdef ENABLE_WHIZDIARY |
| |
if (id == WHIZDIARY) { |
| strcat(message, "&charsLeft="); |
strcat(message, "&charsLeft="); |
| strcat(message, "130&theNetwork=NONE&I4.x=0&I4.y=0"); |
strcat(message, "130&theNetwork=NONE&I4.x=0&I4.y=0"); |
| } |
} |
| else if (id == SPISNET) { |
else |
| |
#endif |
| |
#ifdef ENABLE_SPISNET |
| |
if (id == SPISNET) { |
| // "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
// "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
| strcat(message, "&submit=Odoslat+SMS+spr%E1vu"); |
strcat(message, "&submit=Odoslat+SMS+spr%E1vu"); |
| } |
} |
| else if (id == GLOBTELNET) { |
else |
| |
#endif |
| |
#ifdef ENABLE_GLOBTELNET |
| |
if (id == GLOBTELNET) { |
| /* empty */ |
/* empty */ |
| } |
} |
| else if (id == MTNSMS) { |
else |
| |
#endif |
| |
#ifdef ENABLE_MTNSMS |
| |
if (id == MTNSMS) { |
| /* empty */ |
/* empty */ |
| } |
} |
| |
#endif |
| |
// }}} Postprocessing message |
| |
|
| if (sendsms(message, g.debug-1) != 0) { |
if (sendsms(message, g.debug-1) != 0) { |
| sleep(1); |
sleep(1); |
| fprintf(stderr, "Zlyhalo posielanie SMSky, " |
fprintf(stderr, "Zlyhalo posielanie SMSky, " |