-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.php
56 lines (42 loc) · 1.5 KB
/
app.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
<?php
function addLine($line, &$xmlArray) {
$indent = str_replace('</dict>', ' ', $xmlArray[$line]);
array_splice( $xmlArray, $line, 0, array($indent . '<key>IOPCITunnelCompatible</key>'));
array_splice( $xmlArray, $line + 1, 0, array($indent . '<true/>'));
}
function parseFile($file, $output) {
$xmlstring = file_get_contents($file);
$xmlArray = explode(PHP_EOL, $xmlstring);
$diff = 0;
$prevPos = 0;
foreach ($xmlArray as $key => $value) {
if(strpos($value, '<key>IOPCITunnelCompatible</key>') !== false) {
echo sprintf('%s has already been modified'.PHP_EOL, $file);
return;
}
}
foreach ($xmlArray as $key => $value) {
$pos = strpos($value, '<key>CFBundleIdentifier</key>');
if($pos > 1) {
$prevKey = $key;
$prevPos = $pos-1; // identify the level
}
if($prevKey) {
if (strpos($value, '</dict>') === $prevPos) {
addLine($key + $diff, $xmlArray);
$diff += 2;
$prevKey = null;
}
}
}
// backup
if(!is_dir('backup'.time())) {
mkdir('backup'.time());
}
file_put_contents('backup'.time().'/'.$output, $xmlstring);
file_put_contents($file, implode(PHP_EOL, $xmlArray));
}
parseFile('/System/Library/Extensions/NVDAStartup.kext/Contents/Info.plist', 'NVDAStartup.kext');
parseFile('/System/Library/Extensions/IONDRVSupport.kext/Info.plist', 'IONDRVSupport.kext');
parseFile('/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAController.kext/Contents/Info.plist', 'AppleHDA.kext');
?>