DataObjects/Core_ip_access.php
[Pman.Core] / DataObjects / Core_ip_access.php
1 <?php
2
3 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
4
5 class Pman_Core_DataObjects_Core_ip_access extends DB_DataObject 
6 {
7     ###START_AUTOCODE
8     /* the code below is auto generated do not remove the above tag */
9
10     public $__table = 'core_ip_access';
11     public $id;
12     public $ip;
13     public $created_dt;
14     public $status;
15     public $authorized_by;
16     public $authorized_key;
17     public $email;
18     public $expire_dt;
19     public $user_agent;
20
21     /* the code above is auto generated do not remove the tag below */
22     ###END_AUTOCODE
23     
24     function applyFilters($q, $au)
25     {
26         
27     }
28     
29     function sendXMPP()
30     {
31         $ff = HTML_FlexyFramework::get();
32         
33         if(
34                 empty($ff->Pman['ip_management']) || 
35                 empty($ff->Pman['XMPP']) ||
36                 empty($ff->Pman['XMPP']['username']) ||
37                 empty($ff->Pman['XMPP']['password']) ||
38                 empty($ff->Pman['XMPP']['to'])
39         ) {
40             return;
41         }
42         
43         require_once 'Net/XMPP.php';
44             
45         $conn = new Net_XMPP('talk.google.com', 5222, $ff->Pman['XMPP']['username'], $ff->Pman['XMPP']['password'], 'xmpphp', 'gmail.com', $printlog=false, $loglevel=Net_XMPP_Log::LEVEL_VERBOSE);
46
47         $url = "{$ff->baseURL}/Core/VerifyAccess/{$this->id}/{$this->authorized_key}";
48         
49         $message = <<<EOF
50             
51 EOF;
52         
53         try {
54             $conn->connect();
55             $conn->processUntil('session_start');
56             $conn->presence();
57             $conn->message($ff->Pman['XMPP']['to'], "
58                 New IP Login Required\n
59                 {$url}
60             ");
61             $conn->disconnect();
62             
63         } catch(XMPPHP_Exception $e) {
64             $ff->page->jerr($e->getMessage());
65         }
66
67         return;
68         
69     }
70     
71     
72 }