File: era.cc

package info (click to toggle)
sms-pl 1.8.9i-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 356 kB
  • ctags: 294
  • sloc: cpp: 1,837; ansic: 625; perl: 272; makefile: 101; sh: 29
file content (73 lines) | stat: -rw-r--r-- 2,001 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <string.h>
#include <iostream.h>
#include "request.h"
#include "headers.h"
#include "sms.h"

int WyslijSMS_Era(SMS_packet *sms)
{
	char *value, *anc, code[5], *anc_end;
	const char *cookie;
	int ret_val;
	char *telefon = sms->telefon;
	char *wiadomosc = sms->wiadomosc;
	char *ok_msg = sms->potwierdzenie;
	
	while (1) {
	// teraz dostaniemy strone z formularzem do wyslania SMSow
	Headers *form = new Headers();
	form->Add("sms", "1");
	HTTP_Request *s = new HTTP_Request("boa.eragsm.com.pl", 80,
					konfig.w3cache_host, konfig.w3cache_port);
	s->AddHeader("Host","boa.eragsm.com.pl");

	Headers *h2 = s->PostData("/sms/sendsms.asp", *form);
	delete form;
	
    // teraz musimy znalezc sekretny kod ukryty na stronie
    anc = strstr(s->GetBody(), "\"Code\"");
    if (anc) {
        strncpy(code, anc+14, 4);
        code[4] = 0;
        anc_end = strchr(code, '"');
        if (anc_end) *anc_end = 0;
    } else break;

	// tak samo musimy od nowa odczytac cookie
	cookie = h2->Header("Set-Cookie");
	if (!(value = strchr(cookie, ';'))) break;
	*value = 0;
	s->AddHeader("Cookie", cookie);
	delete h2;

    debug_stream->Log(LOG_INFO, "Sekretny kod Ery: %s", code); 

    // teraz zbudujemy liste naglowkow do wyslania i wyslemy wiadomosc
    s->ReplaceHeader("Referer","http://boa.eragsm.com.pl/sms/sendsms.asp");

    form = new Headers();
    form->Add("numer",telefon);
    form->Add("bookopen","");
    form->Add("ksiazka","ksika telefoniczna");
    form->Add("message",wiadomosc);
    form->Add("messagebis",wiadomosc);
    form->Add("podpis","");
    form->Add("kontakt","");
    form->Add("Nadaj","  tak-nada  ");
    form->Add("Code", code);
    form->Add("Kasuj","nie-skasowa");
    form->Add("Telefony","Telefony");

    delete s->PostData("/sms/sendsms.asp", *form);
    delete form;

    ret_val = poprawna_odpowiedz(ok_msg, telefon, s->GetBody());

    delete s;

    return ret_val;
    }

    throw new Exception("Blad obslugi strony www.eragsm.pl");
    return 0;
}