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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
<?php
header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
//require("../classes/email.php");
global $ADEI;
global $ADEI_ROOTDIR;
$ADEI->RequireClass("email");
$EMAIL = new EMAIL();
function genEmailContent($props) {
$host = $_SERVER['HTTP_HOST'];
$location = $props['url'];
$query;
$i=1;
foreach($props as $key => $value)
{
if ($key != 'from' && $key != 'to' && $key != 'message' && $key != 'attachement' && $key != 'adei_session' && $key != 'task' && $key != 'service' && $key != 'url') {
$query .= "&". $key . "=" . $value;
}
}
$filearray = explode('/',$props['attachement']);
$file = $filearray[count($file)-1];
$url ="$location". "#" ."$query";
$message = "<html><head><title>Adei Graph</title></head><body><p>";
$message .= "<p>". $props['message'] ."</p>";
$message .= "<p><a href='". $url ."'>Link to Graph</a></p>";
$message .= "<p><img src='$file' /></p>";
$message .="</body></html>";
return $message;
}
if (isset($_GET['task'])) {
switch ($_GET['task']) {
case "Send":
if (isset($_GET['to']) && isset($_GET['message']) && isset($_GET['from']) && isset($_GET['attachement'])) {
$mail = $_GET['to'];
$path = $_GET['attachement'];
$from = $_GET['from'];
foreach($_GET as $key => $value)
{
$props[$key] = $value;
}
$msg = genEmailContent($props);
$vlues = array('email' => $mail, 'message'=>$msg, 'attachement'=>$path, 'from' => $from);
$result = $EMAIL->sendMail($vlues);
echo $result;
if ($result != 'phpmailerException' || $result != 'exception') unlink($path);
}
break;
case "genpic":
$pic .= $_GET['picname'];
foreach($_GET as $key => $value)
{
$props[$key] = $value;
}
$r = $EMAIL->createFolder();
if ($r!="Success") echo "FAIL";
else {
$result = $EMAIL->createPNG($props);
if ($result!="FAILED") echo $ADEI_ROOTDIR ."". $result;
else echo "FAIL";
}
break;
case "getSensorList":
foreach($_GET as $key => $value) {
$opts[$key]= $value;
}
$details = $EMAIL->listSensors($opts);
$return = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><result>";
if ($error = $details['error'])
{
$return .= "<value>". $details['error'] ."</value>";
}
else {
// $return .= "<value>Success</value></result>";
foreach($details['groups'] as $gid => $itemlist) {
$return .= "<value><groupname>". $gid ."</groupname>";
foreach($itemlist as $item => $info) {
$return .= "<item><itemid>". $info['id'] ."</itemid><itemname>". $info['name'] ."</itemname></item>";
}
$return .= "</value>";
}
}
$return .="</result>";
echo $return;
break;
default:
$return = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><result>";
$return .= "<heading>Emaili</heading>";
$return .= "<value name='From' id='from'/>";
$return .= "<value name='Recipient' id='tomail'/>";
$return .= "<value name='Message' id='message'/>";
$return .= "<value name=\"$result\" id='ressu'/>";
$return .= "</result>";
echo $return;
break;
}
} else {
$return = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><result>";
$return .= "<heading>Email</heading>";
$return .= "<value name='From' id='from'/>";
$return .= "<value name='Recipient' id='tomail'/>";
$return .= "<value name='Message' id='message'/>";
$return .= "</result>";
echo $return;
}
?>
|