EventView.php
[Pman.Admin] / EventView.php
1 <?php
2
3
4 require_once 'Pman.php';
5
6 class Pman_Admin_EventView extends Pman
7 {
8     
9     function getAuth()
10     {
11         parent::getAuth();
12         $au = $this->getAuthUser();
13         if (!$au || $au->company()->comptype != 'OWNER') {
14             $this->jerrAuth();
15         }
16         return true;
17         
18         
19     }
20     
21     function get($id)
22     {
23         $ev = DB_DataObject::Factory('Events');
24         if (!$ev->get((int)$id)) {
25             $this->jerr("invalid id");
26         }
27         
28         // verify if not admin, then they should 
29         $g = DB_DataObject::Factory('group_members');
30         if (is_a($g, 'DB_DataObject')) {
31             $grps = $g->listGroupMembership($this->authUser);
32            //var_dump($grps);
33             $isAdmin = $g->inAdmin;
34             
35             if (!$isAdmin && $ev->person_id != $this->authUser->id) {
36                 $this->jerrAuth();
37             }
38         }
39         // we have 2 bits of data available at present:
40         // core_event_audit
41         // the event file..
42         $d= DB_DataObject::factory('core_event_audit');
43         if (is_a($d,'DB_DataObject')) {
44             echo "<H2>Changed Data:</H2>";
45             $d->event_id = $ev->id;
46             foreach($d->fetchAll() as $d) {
47                 echo "{$d->name} SET TO: " . htmlspecialchars($d->newvalue) . "<br/>\n";
48             }
49         }
50         echo "<HR><H2>Posted Data:</H2>";
51         $fn =  
52         
53         
54         
55         $ff  = HTML_FlexyFramework::get();
56         if (empty($ff->Pman['event_log_dir'])) {
57             echo "not available (not configured)";
58             exit;
59         }
60         if (function_exists('posix_getpwuid')) {
61             $uinfo = posix_getpwuid( posix_getuid () ); 
62          
63             $user = $uinfo['name'];
64         } else {
65             $user = getenv('USERNAME'); // windows.
66         }
67          
68         
69         $file = $ff->Pman['event_log_dir']. "/{$user}" . date('/Y/m/d/',strtotime($ev->event_when)). $ev->id . ".json"; 
70         if (!file_exists($file)) {
71             echo "not available (missing file) $file";
72             exit;
73         }
74         echo '<PRE>' . htmlspecialchars(file_get_contents($file)) . '</PRE>';
75         
76         echo '<BR/><PRE>'. htmlspecialchars($ev->remarks) . '</PRE>';
77         
78         $filesJ = json_decode(file_get_contents($file));
79         echo '<br /><PRE>Images Preview</PRE>';
80         
81                 //$path = $ff->baseURL. "Images/Thumb/150/{$filesJ->POST->onid}";
82         foreach($filesJ->FILES as $f){
83             $ip = $ff->Pman['event_log_dir']. "/{$user}" . date('/Y/m/d/',strtotime($ev->event_when)). $f->tmp_name;
84             $img = getimagesize($ip);
85             header("Content-type: image/jpeg");
86             readfile($ip);
87 //            addslashes($ip);
88             echo "<img src=\"".readfile($ip)."\" $attr alt=\"getimagesize() example\" />";
89             //$path = $ff->baseURL. "Images/Thumb/150/$ff->Pman['event_log_dir']. "/{$user}" . date('/Y/m/d/',strtotime($ev->event_when)). $f->tmp_name;
90             //echo '<img src="'.$path.'" />';
91 //            print_r($f->type);
92         }
93         
94         
95         
96         exit;
97         
98     }
99     
100     
101 }