-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapplications_model.php
executable file
·103 lines (87 loc) · 3.08 KB
/
applications_model.php
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
<?php
use CFPropertyList\CFPropertyList;
class Applications_model extends \Model {
function __construct($serial='')
{
parent::__construct('id', 'applications'); //primary key, tablename
$this->rs['id'] = '';
$this->rs['serial_number'] = $serial;
$this->rs['name'] = '';
$this->rs['path'] = '';
$this->rs['last_modified'] = 0;
$this->rs['obtained_from'] = '';
$this->rs['runtime_environment'] = '';
$this->rs['version'] = '';
$this->rs['info'] = '';
$this->rs['signed_by'] = '';
$this->rs['has64bit'] = 0; // True or False
$this->rs['bundle_version'] = '';
$this->serial_number = $serial;
}
// ------------------------------------------------------------------------
/**
* Process data sent by postflight
*
* @param string data
* @author tuxudo
**/
function process($plist)
{
// Check if we have data
if ( ! $plist){
throw new Exception("Error Processing Request: No property list found", 1);
}
// Delete previous set
$this->deleteWhere('serial_number=?', $this->serial_number);
$parser = new CFPropertyList();
$parser->parse($plist, CFPropertyList::FORMAT_XML);
$myList = $parser->toArray();
$typeList = array(
'name' => '',
'last_modified' => '',
'obtained_from' => 'unknown',
'path' => '',
'runtime_environment' => '',
'version' => '',
'info' => '',
'signed_by' => '',
'has64bit' => 0, // Yes or No
'bundle_version' => '' // Yes or No
);
// List of paths to ignore
$bundlepath_ignorelist = is_array(conf('bundlepath_ignorelist')) ? conf('bundlepath_ignorelist') : array();
$path_regex = ':^'.implode('|', $bundlepath_ignorelist).'$:';
// Process each app
foreach ($myList as $app) {
// Check if we have a name
if( ! array_key_exists("name", $app)){
continue;
}
// Skip path
if (preg_match($path_regex, $app['path'])) {
continue;
}
// Fix signed_by entries
if (array_key_exists("signed_by",$app)) {
$app['signed_by'] = str_replace(array('Developer ID Application: '), array(''), $app['signed_by']);
}
// Fix last_modified date
if (array_key_exists("last_modified",$app)) {
$temptime = $app['last_modified'];
$date = new DateTime("@$temptime");
$app['last_modified'] = $date->format('U');
}
// Process each app for saving
foreach ($typeList as $key => $value) {
$this->rs[$key] = $value;
if(array_key_exists($key, $app))
{
$this->rs[$key] = $app[$key];
}
}
// Save application
$this->id = '';
$this->save();
}
}
}