File: plus.cc

package info (click to toggle)
sms-pl 1.9.2m-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 620 kB
  • ctags: 355
  • sloc: cpp: 2,143; ansic: 1,046; perl: 272; makefile: 113; sh: 97
file content (79 lines) | stat: -rw-r--r-- 1,765 bytes parent folder | download | duplicates (2)
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
74
75
76
77
78
79
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "vsprintf.h"
#include "request.h"
#include "headers.h"
#include "sms.h"

int WyslijSMS_Plus(SMS_packet *sms)
{
	char tel[20], email_addr[80];
	char *telefon = sms->telefon;
	char *wiadomosc = sms->wiadomosc;
	char *ok = sms->potwierdzenie;

	strncat(strcpy(tel, "48"), telefon, 9);

	pobierz_adres_email(email_addr, sizeof(email_addr), 
		(konfig.mailaddr) ? konfig.mailaddr : "sms@text.plusgsm.pl");

	if (konfig.plus_mail) {

	char cmd[255];
	FILE *pf;

	snprintf(cmd, sizeof(cmd)-1, "%s -f \"%s\" -t", SENDMAIL_PATH,  email_addr);
	cmd[sizeof(cmd)-1] = 0;

	if (pf = popen(cmd, "w")) {
	    fprintf(pf, "From: %s\nTo: +%s@text.plusgsm.pl\n\n%s\n.\n",
			    email_addr, tel, wiadomosc);
	    pclose(pf);
	} else throw new Exception("Blad wywolywania sendmaila");
	return 1;

	} else { //plusmail
	
	int ret_val;

	while(1) {
	HTTP_Request *s = new HTTP_Request("www.text.plusgsm.pl", 80,
					konfig.w3cache_host, konfig.w3cache_port);
	char tprefix[4];

	// do tablicy tprefix kopiujemy prefix Plusa
	strncpy(tprefix, (tel+2), 3);
	tprefix[3] = 0;

	// te dane beda w kazdym odwolaniu sie do serwera
	s->AddHeader("Host","www.text.plusgsm.pl");

	Headers *form = new Headers();

	form->Add("tprefix", tprefix);
	form->Add("numer", (tel+5));
	form->Add("odkogo", email_addr);	
	form->Add("tekst", wiadomosc);
	form->Add("dzien", "2003-01-30");
	form->Add("godz", "12");
	form->Add("min", "15");
	form->Add("charno","159");
	form->Add("smsno","1");

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

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

	delete s;

	return ret_val;
	}

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

	} // plusmail
}