| verzia 1.21, 2001/10/25 20:05:28 |
verzia 1.22, 2001/10/27 20:32:43 |
|
|
| /* |
/* |
| * Author: Lubomir Host 'rajo' <host8@kepler.fmph.uniba.sk> |
* Author: Lubomir Host 'rajo' <host8@kepler.fmph.uniba.sk> |
| * $Log$ |
* $Log$ |
| |
* Revision 1.22 2001/10/27 20:32:43 host8 |
| |
* mail2sms.c splited to multiple files. |
| |
* Little improvements in Makefile.in. |
| |
* |
| * Revision 1.21 2001/10/25 20:05:28 host8 |
* Revision 1.21 2001/10/25 20:05:28 host8 |
| * First implementation of login with password. |
* First implementation of login with password. |
| * |
* |
|
|
| #include "http.h" |
#include "http.h" |
| #include "strings.h" |
#include "strings.h" |
| #include "passwd.h" |
#include "passwd.h" |
| |
#include "sendsms.h" |
| |
#include "mail.h" |
| |
|
| #if defined(ENABLE_AZET) || defined(ENABLE_WHIZDIARY) || defined(ENABLE_SPISNET) || defined(ENABLE_GLOBTELNET) || defined(ENABLE_MTNSMS) |
#if defined(ENABLE_AZET) || defined(ENABLE_WHIZDIARY) || defined(ENABLE_SPISNET) || defined(ENABLE_GLOBTELNET) || defined(ENABLE_MTNSMS) |
| /* empty */ |
/* empty */ |
| Riadok 68 SERVER servers[] = { |
|
| Riadok 74 SERVER servers[] = { |
|
| { GLOBTELNET, "globtelnet", "213.151.200.27", 80, 0 }, |
{ GLOBTELNET, "globtelnet", "213.151.200.27", 80, 0 }, |
| #endif |
#endif |
| #ifdef ENABLE_MTNSMS |
#ifdef ENABLE_MTNSMS |
| { MTNSMS, "mtnsms", "196.36.119.197", 80, 0 }, |
// { MTNSMS, "mtnsms", "196.36.119.197", 80, 0 }, |
| |
{ MTNSMS, "mtnsms", "196.36.119.186", 80, 0 }, |
| #endif |
#endif |
| { 0, NULL, NULL, 0, 0 } |
{ 0, NULL, NULL, 0, 0 } |
| }; |
}; |
| Riadok 103 void void_read_at_exit(void) |
|
| Riadok 110 void void_read_at_exit(void) |
|
| free(keybd); |
free(keybd); |
| exit(0); |
exit(0); |
| } // }}} |
} // }}} |
| // Function sendsms() {{{ |
|
| int sendsms(char *str, int show_info) |
|
| { |
|
| //int info=show_info; |
|
| |
|
| // GET http request {{{ |
|
| switch (id) { |
|
| #ifdef ENABLE_AZET |
|
| case AZET: |
|
| http_request(HTTP_GET, "/index.phtml?", "sms.azet.sk", NULL); |
|
| http_set_referer("sms2.azet.sk", "/"); |
|
| http_request(HTTP_POST, "/index.phtml", "sms.azet.sk", |
|
| "Content-type: " |
|
| "application/x-www-form-urlencoded\r\n" |
|
| "Content-length: %d\r\n\r\n%s", |
|
| strlen(str), str); |
|
| |
|
| break; |
|
| #endif |
|
| #ifdef ENABLE_WHIZDIARY |
|
| case WHIZDIARY: |
|
| http_request(HTTP_GET, "/home.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, "/home.asp", "www.whizdiary.com", NULL); |
|
| http_request(HTTP_GET, "/sms.asp", "www.whizdiary.com", NULL); |
|
| http_request(HTTP_POST, "/sms.asp", "www.whizdiary.com", |
|
| "Content-type: " |
|
| "application/x-www-form-urlencoded\r\n" |
|
| "Content-length: %d\r\n\r\n%s", |
|
| strlen(str), str); |
|
| break; |
|
| #endif |
|
| #ifdef ENABLE_SPISNET |
|
| case SPISNET: |
|
| http_request(HTTP_GET, "/top.php3", "sms.spisnet.sk", NULL); |
|
| http_request(HTTP_POST, "/smssend.php3", "sms.spisnet.sk", |
|
| "Content-type: " |
|
| "application/x-www-form-urlencoded; " |
|
| "charset=windows-1250\r\n" |
|
| "Content-length: %d\r\n\r\n%s", |
|
| strlen(str), str); |
|
| // "smsn=421903123123&chars=0&smsm=sorry%2C+test&submit=Odoslat+SMS+spr%E1vu" |
|
| break; |
|
| #endif |
|
| #ifdef ENABLE_GLOBTELNET |
|
| case GLOBTELNET: |
|
| /* Begin of frames * |
|
| http_request(HTTP_GET, "/get/guest/app.php3.html", |
|
| "www.globtelnet.sk", NULL); |
|
| http_request(HTTP_GET, "/get/guest/core/core.php3.html", |
|
| "www.globtelnet.sk", NULL); |
|
| http_request(HTTP_GET, "/get/guest/app.php3:_navigator:.html", |
|
| "www.globtelnet.sk", NULL); |
|
| http_request(HTTP_GET, "/get/all/app.php3:_linkbar.html", |
|
| "www.globtelnet.sk", NULL); |
|
| * End of frames */ |
|
| http_request(HTTP_GET, "/get/all/core/register.php3.html", |
|
| "www.globtelnet.sk", NULL); |
|
| /* login */ |
|
| http_request(HTTP_POST, "/core/do_user.php3", "www.globtelnet.sk", |
|
| "Content-type: " |
|
| "application/x-www-form-urlencoded; " |
|
| "charset=windows-1250\r\n" |
|
| //"Content-length: 51\r\n\r\n" |
|
| "Content-length: %d\r\n\r\n" |
|
| "form_name=login" |
|
| "&next_page=&wa_na=%s&wa_pa=%s", |
|
| strlen(my_getlogin()) + |
|
| strlen(my_getpass()) + 41, |
|
| my_getlogin(), my_getpass()); |
|
| http_request(HTTP_POST, "/sms/do_sms_send.php3", "www.globtelnet.sk", |
|
| "Content-type: " |
|
| "application/x-www-form-urlencoded; " |
|
| "charset=windows-1250\r\n" |
|
| "Content-length: %d\r\n\r\n%s", |
|
| strlen(str), str); |
|
| http_request(HTTP_GET, "/comm/message.php3?readsess=1", |
|
| "www.globtelnet.sk", NULL); |
|
| break; |
|
| #endif |
|
| #ifdef ENABLE_MTNSMS |
|
| case MTNSMS: |
|
| http_request(HTTP_GET, "/", "www.mtnsms.com", NULL); |
|
| http_request(HTTP_POST, "/session.asp", "www.mtnsms.com", |
|
| "Content-type: " |
|
| "application/x-www-form-urlencoded; " |
|
| //"Content-length: 77\r\n\r\n%s", |
|
| "Content-length: %d\r\n\r\n" |
|
| "username=%s&" |
|
| "password=%s&email=&" |
|
| "joinusclick=no&returl=&x=40&y=39", |
|
| strlen(my_getlogin()) + |
|
| strlen(my_getpass()) + 59, |
|
| my_getlogin(), my_getpass()); |
|
| break; |
|
| #endif |
|
| default: |
|
| fprintf(stderr, "Somethings go wrong, " |
|
| "invalid id in sendsms()!\n"); |
|
| exit(1); |
|
| break; |
|
| } /* end switch (id) */ |
|
| // }}} |
|
| |
|
| fprintf(stderr, "text to sms [%d chars]:'%s'\n", |
|
| strlen(str), str); |
|
| return(0); |
|
| } // }}} |
|
| // Function analyze_mail() {{{ |
|
| void analyze_mail(char *str) |
|
| { |
|
| char *pom; |
|
| |
|
| if (str == NULL) return; |
|
| if (str == strstr(str, "> ")) return; // reply part |
|
| |
|
| if (str == strstr(str, "From:") && ! g.skipped_header) { |
|
| strncat(g.text, |
|
| compress_str(str + strlen("From:")), |
|
| SMS_LEN - strlen(g.text)); |
|
| strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text)); |
|
| g.text[SMS_LEN] = '\0'; |
|
| |
|
| g.skipped_header = 0; |
|
| g.is_header = 1; |
|
| return; |
|
| } |
|
| |
|
| if (str == strstr(str, "Subject:") && ! g.skipped_header) { |
|
| strncat(g.text, |
|
| compress_str(str + strlen("Subject:")), |
|
| SMS_LEN - strlen(g.text)); |
|
| strncat(g.text, SMS_SEPARATOR, SMS_LEN - strlen(g.text)); |
|
| g.text[SMS_LEN] = '\0'; |
|
| |
|
| g.skipped_header = 0; |
|
| g.is_header = 1; |
|
| return; |
|
| } |
|
| |
|
| pom = (char *) malloc((strlen(str)+1)*sizeof(char)); |
|
| strcpy(pom, str); |
|
| strtolower(pom); |
|
| if (pom == strstr(pom, "content-transfer-encoding: ") |
|
| && g.is_header) { |
|
| if (pom == strstr(pom, "content-transfer-encoding: 8bit") |
|
| || pom == strstr(pom, "content-transfer-encoding:" |
|
| " 7bit")) { |
|
| } |
|
| else { |
|
| fprintf(stderr, "NO SMS SEND: '%s'\n", str); |
|
| free(pom); |
|
| void_read_at_exit(); |
|
| exit(0); |
|
| } |
|
| } |
|
| |
|
| if (pom == strstr(pom, "content-type: ") && g.is_header&&1) { |
|
| if (pom != strstr(pom, "content-type: text/plain;")) { |
|
| fprintf(stderr, "NO SMS SEND: '%s'\n", str); |
|
| free(pom); |
|
| void_read_at_exit(); |
|
| exit(0); |
|
| } |
|
| } |
|
| |
|
| free(pom); |
|
| |
|
| if (str == strstr(str, "---------- Forwarded message ----------")) { |
|
| g.is_header=1; |
|
| g.skipped_header=0; |
|
| g.is_forwarded=1; |
|
| return; |
|
| } |
|
| |
|
| if ((! strcmp(str,"\n")) && g.is_header) { |
|
| fprintf(stderr, "END OF HEADER\n"); |
|
| g.is_header=0; |
|
| g.skipped_header=1; |
|
| return; |
|
| } |
|
| |
|
| if (g.skipped_header) { |
|
| add_str_to_sms(str); |
|
| return; |
|
| } |
|
| |
|
| return; |
|
| } // }}} |
|
| // Function print_usage() {{{ |
// Function print_usage() {{{ |
| void print_usage(char *argv0) |
void print_usage(char *argv0) |
| { |
{ |