/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to classes/email.php

  • Committer: Suren A. Chilingaryan
  • Date: 2011-01-26 02:48:39 UTC
  • mto: This revision was merged to the branch mainline in revision 212.
  • Revision ID: csa@dside.dyndns.org-20110126024839-nv6qp2ie9stmd2dn
Support of Appled devices by Toni Pirhonen

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
class EMAIL{
 
3
    function __construct() {
 
4
        global $ADEI_ROOTDIR;
 
5
        require_once($ADEI_ROOTDIR .'/includes/PHPMailer-Lite_v5.1/class.phpmailer-lite.php');
 
6
    }
 
7
    
 
8
    function createPNG($props){
 
9
        try {
 
10
            $req = new DATARequest();
 
11
            $fullpath = $ADEI_ROOTDIR . "tmp/tmpimg/";
 
12
            //$fullpath .= $pic;
 
13
            $picname;
 
14
            foreach($props as $key => $value)
 
15
            {
 
16
                $req->SetProp($key,$value);
 
17
                if ($key=='db_server' || $key=='db_name' || $key == 'window')
 
18
                {
 
19
                    $picname .= $value ."-";
 
20
                }
 
21
            }
 
22
            $picname .= rand(1,200);
 
23
            $picname .= ".png";
 
24
            $fullpath .= $picname;
 
25
 
 
26
            $draw = $req->CreatePlotter();
 
27
            $draw->Create();
 
28
            $draw->Save($fullpath);
 
29
            return $fullpath;
 
30
        }
 
31
        catch (ADEIException $ex) {
 
32
            $ex->logInfo(NULL, $draw);
 
33
            return "FAILED";
 
34
        }
 
35
    }
 
36
    
 
37
    function listSensors($opts){
 
38
        $req = new DATARequest($opts);
 
39
        $reader = $req->CreateReader();
 
40
        $groups = $reader->GetGroups();
 
41
        $grouplist = $reader->GetGroupList();
 
42
        $mask = new MASK($opts);
 
43
        $i=0;
 
44
        foreach($grouplist as $group => $details){
 
45
            $itemlist[$det['gid']] = $reader->GetItemList($groups[$i],$mask);
 
46
            $i++;
 
47
        }
 
48
        foreach($itemlist as $gid => $items) {
 
49
            if (!is_numeric($gid)) {
 
50
                foreach($items as $key => $item ) {
 
51
                    $details['groups'][$gid][$key] = array("id" =>"{$item['id']}", "name" => "{$item['name']}");
 
52
                }
 
53
            }
 
54
        }
 
55
        return $details;
 
56
    }
 
57
    
 
58
    function createFolder(){
 
59
        $dir = $ADEI_ROOTDIR .'tmp/tmpimg';
 
60
        if (!@is_dir($dir)) {
 
61
            if (@mkdir($dir, 0777, true)){
 
62
                @chmod($dir, 0777);
 
63
                return "Success";
 
64
            }
 
65
            else return "Failure";
 
66
        }
 
67
        else return "Success";
 
68
    }
 
69
    
 
70
    function sendMail($props){
 
71
        $mail = new PHPMailerLite(); // defaults to using php "Sendmail" (or Qmail, depending on availability)
 
72
        $mail->IsMail(); // telling the class to use native PHP mail()
 
73
        try {
 
74
            $mail->SetFrom('adei@adei.com', 'Adei User');
 
75
            $mail->AddAddress($props['email'], 'User');
 
76
            $mail->Subject = 'Adei Graph';
 
77
            $mail->MsgHTML($props['message']);
 
78
            $mail->AddAttachment($props['attachement']); // attachment
 
79
            $mail->Send();
 
80
            return $props['message'];
 
81
        } catch (phpmailerException $e) {
 
82
            return 'phpmailerException';//$e->errorMessage(); //Pretty error messages from PHPMailer
 
83
        } catch (Exception $e) {
 
84
            return 'exception';//$e->getMessage();//Boring error messages from anything else!
 
85
        }
 
86
    }
 
87
}
 
88
?>
 
 
b'\\ No newline at end of file'