VerifyAccess.php
[Pman.Core] / VerifyAccess.php
1 <?php
2
3 require_once 'Pman.php';
4
5 class Pman_Core_VerifyAccess extends Pman
6 {
7     var $masterTemplate = 'master-verify-ip-access.html';
8     
9     /*
10      * This is a public page
11      */
12     function getAuth() 
13     {
14         return true;
15     }
16     
17     function get($id)
18     {
19         
20         
21         return;
22         
23     }
24     
25     function validate($id)
26     {
27         $ret = array(
28             'is_valid' => true,
29             'errorMsg' => ''
30         );
31         
32         @list($id, $key) = explode('/', $id);
33         
34         if(empty($id) || empty($key)){
35             return false;
36         }
37         
38         $core_ip_access = DB_DataObject::factory('core_ip_access');
39         
40         
41         $ff = HTML_FlexyFramework::get();
42         
43         $core_person = DB_DataObject::factory('core_person');
44         
45         
46         $ff->Pman['XMPP']['to'] = 'edward@roojs.com'; // testing...
47         
48         if(
49                 empty($id) ||
50                 empty($key) ||
51                 empty($ff->Pman['ip_management']) || 
52                 empty($ff->Pman['XMPP']) ||
53                 empty($ff->Pman['XMPP']['to']) ||
54                 !$core_person->get('email', $ff->Pman['XMPP']['to']) ||
55                 !$core_ip_access->get($id) ||
56                 $core_ip_access->authorized_key != $key
57         ) {
58             $this->jerr('Invalid URL');
59         }
60     }
61     
62 }