function showKextsLog($InstallData)
{
    global $workPath, $svnpackPath, $edp_db;
    if ($InstallData[categ] != "Ethernet") {
        echoPageItemTOP("icons/big/{$InstallData['icon']}", "{$InstallData['name']}");
    } else {
        echoPageItemTOP("icons/big/{$InstallData['icon']}", "{$InstallData['foldername']}");
    }
    echo "<body onload=\"JavaScript:timedRefresh(8000);\">";
    echo "<div class='pageitem_bottom'\">";
    $buildLogPath = "{$workPath}/logs/build";
    if (is_file("{$buildLogPath}/Success_{$InstallData['foldername']}.txt") || is_file("{$buildLogPath}/Fail_{$InstallData['foldername']}.txt")) {
        //
        // Install the downloaded kext
        //
        if (file_exists("{$buildLogPath}/Success_{$InstallData['foldername']}.txt")) {
            // Download kext
            switch ($InstallData[categ]) {
                case "PS2Touchpad":
                    // Remove installed kexts which might cause problems
                    if (is_dir("{$InstallData['path']}/VoodooPS2Controller.kext")) {
                        system_call("rm -rf {$InstallData['path']}/VoodooPS2Controller.kext");
                    }
                    if (is_dir("{$InstallData['path']}/ApplePS2Controller.kext")) {
                        system_call("rm -rf {$InstallData['path']}/ApplePS2Controller.kext");
                    }
                    if (is_dir("{$InstallData['path']}/AppleACPIPS2Nub.kext")) {
                        system_call("rm -rf {$InstallData['path']}/AppleACPIPS2Nub.kext");
                    }
                    if (is_dir("{$InstallData['path']}/ApplePS2ElanTouchpad.kext")) {
                        system_call("rm -rf {$InstallData['path']}/ApplePS2ElanTouchpad.kext");
                    }
                    $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['foldername']}";
                    break;
                case "Audio":
                    $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['foldername']}";
                    // Copy prefpane and settings loader
                    if (is_file("{$buildLogPath}/Success_Settings.txt") || is_file("{$buildLogPath}/Fail_Settings.txt")) {
                        system_call("cp -rf {$svnpackPath}/{$InstallData['categ']}/Settings/VoodooHdaSettingsLoader.app /Applications/; cp -f {$svnpackPath}/{$InstallData['categ']}/Settings/com.restore.voodooHDASettings.plist /Library/LaunchAgents/; cp -rf {$svnpackPath}/{$InstallData['categ']}/Settings/VoodooHDA.prefPane /Library/PreferencePanes/;");
                    } else {
                        echo "<center><b>Please wait for few minutes while we download and install the kext... which will take approx 1 to 10 minutes depending on your internet speed.</b></center>";
                        echo "<img src=\"icons/big/loading.gif\" style=\"width:200px;height:30px;position:relative;left:50%;top:50%;margin:15px 0 0 -100px;\">";
                        echo "<script type=\"text/JavaScript\"> function timedRefresh(timeoutPeriod) { logVar = setTimeout(\"location.reload(true);\",timeoutPeriod); } function stopRefresh() { clearTimeout(logVar); } </script>\n";
                        echo "</div>";
                        return;
                    }
                    break;
                case "USB":
                    // Generic XHCI USB3.0
                    if ($InstallData[id] == "5") {
                        // Choose new version
                        if (getMacOSXVersion() >= "10.8.5") {
                            $kPath = "{$svnpackPath}/{$InstallData['categ']}/GenericXHCIUSB3_New";
                        } else {
                            if (getMacOSXVersion() < "10.8.5") {
                                $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['foldername']}";
                            }
                        }
                    } else {
                        $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['foldername']}";
                    }
                    break;
                case "Ethernet":
                    // New Realtek kext
                    if ($InstallData[id] == "11") {
                        // Choose 10.8+ version
                        if (getMacOSXVersion() >= "10.8") {
                            $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['name']}/RealtekRTL8111";
                        } else {
                            if (getMacOSXVersion() == "10.7") {
                                $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['name']}/RealtekRTL8111_Lion";
                            }
                        }
                    } else {
                        $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['name']}/{$InstallData['foldername']}";
                    }
                    break;
                default:
                    $kPath = "{$svnpackPath}/{$InstallData['categ']}/{$InstallData['foldername']}";
                    break;
            }
            system_call("cp -rf {$kPath}/*.kext {$InstallData['path']}/");
            if ($InstallData[path] == "/Extra/Extensions") {
                myHackCheck();
                ProcessKextConflicts("{$buildLogPath}/kextInstall.log");
                KextsPermissionsAndKernelCacheFix("{$buildLogPath}/kextInstall.log", "EE");
                // system_call("sudo myfix -q -t / >> $buildLogPath/myFix.log &");
            } else {
                myHackCheck();
                ProcessKextConflicts("{$buildLogPath}/kextInstall.log");
                KextsPermissionsAndKernelCacheFix("{$buildLogPath}/kextInstall.log", "SLE");
            }
            echo "<ul class='pageitem'>";
            echo "<img src=\"icons/big/success.png\" style=\"width:80px;height:80px;position:relative;left:50%;top:50%;margin:15px 0 0 -35px;\">";
            echo "<b><center> Installation finished.</b><br><br><b> You can see the changes in action from your next boot.</center></b>";
            echo "<br></ul>";
        } else {
            echo "<ul class='pageitem'>";
            echo "<img src=\"icons/big/fail.png\" style=\"width:80px;height:80px;position:relative;left:50%;top:50%;margin:15px 0 0 -35px;\">";
            echo "<b><center> Installation failed.</b><br><br><b> Check the log for the reason.</center></b>";
            echo "<br></ul>";
            echo "<b>Log:</b>\n";
            echo "<pre>";
            if (is_file("{$buildLogPath}/kextInstall.log")) {
                include "{$buildLogPath}/kextInstall.log";
            }
            echo "</pre>";
        }
        echo "</div>";
        exit;
    } else {
        echo "<center><b>Please wait for few minutes while we download and install the kext... which will take approx 1 to 10 minutes depending on your internet speed.</b></center>";
        echo "<img src=\"icons/big/loading.gif\" style=\"width:200px;height:30px;position:relative;left:50%;top:50%;margin:15px 0 0 -100px;\">";
    }
    echo "<script type=\"text/JavaScript\"> function timedRefresh(timeoutPeriod) { logVar = setTimeout(\"location.reload(true);\",timeoutPeriod); } function stopRefresh() { clearTimeout(logVar); } </script>\n";
    echo "</div>";
}
function patchWiFiBTBCM4352($log, $pathToPatch, $genCache)
{
    global $slePath, $workPath;
    writeToLog("{$log}", " Applying WiFi patches for BCM4352 card...<br>");
    if (!file_exists("{$slePath}/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/Info.plist")) {
        writeToLog("{$log}", "  IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext kext not found<br>");
        system_call("cd {$workPath}/logs/fixes; touch patchFail.txt;");
        return;
    }
    switch ($pathToPatch) {
        case "SLE":
            // Binary patches
            system_call('sudo perl -pi -e \'s|\\x01\\x58\\x54|\\x01\\x55\\x53|g\' /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360');
            // region code change to US
            system_call('sudo perl -pi -e \'s|\\x6B\\x10\\x00\\x00\\x75|\\x6B\\x10\\x00\\x00\\x74|g\' /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360');
            // skipping binary checks of apple device id to work Appple card
            system_call('sudo perl -pi -e \'s|\\x6B\\x10\\x00\\x00\\x0F\\x85|\\x6B\\x10\\x00\\x00\\x0F\\x84|g\' /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360');
            // skipping binary checks of apple device id to work Appple card
            // Kext patch
            system_call("sudo /usr/libexec/PlistBuddy -c \"add IOKitPersonalities:Broadcom\\ 802.11\\ PCI:IONameMatch:0 string \"pci14e4,43b1\"\" /System/Library/Extensions/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/Info.plist");
            // touch for kernel cache
            if ($genCache == "yes") {
                KextsPermissionsAndKernelCacheFix($log, "SLE");
                // system_call("sudo touch /System/Library/Extensions/ >> $log &");
            }
            break;
        case "EE":
            system_call("cp -a {$slePath}/IO80211Family.kext /Extra/Extensions.EDPFix/");
            system_call("cp -a {$slePath}/IO80211Family.kext/Contents/PlugIns/. /Extra/Extensions.EDPFix/");
            system_call("rm -rf /Extra/Extensions.EDPFix/IO80211Family.kext/Contents/PlugIns");
            // Binary patches
            system_call('sudo perl -pi -e \'s|\\x01\\x58\\x54|\\x01\\x55\\x53|g\' /Extra/Extensions.EDPFix/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360');
            // region code change to US
            system_call('sudo perl -pi -e \'s|\\x6B\\x10\\x00\\x00\\x75|\\x6B\\x10\\x00\\x00\\x74|g\' /Extra/Extensions.EDPFix/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360');
            // skipping binary checks of apple device id to work Appple card
            system_call('sudo perl -pi -e \'s|\\x6B\\x10\\x00\\x00\\x0F\\x85|\\x6B\\x10\\x00\\x00\\x0F\\x84|g\' /Extra/Extensions.EDPFix/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/MacOS/AirPortBrcm4360');
            // skipping binary checks of apple device id to work Appple card
            // Kext patch
            system_call("sudo /usr/libexec/PlistBuddy -c \"add IOKitPersonalities:Broadcom\\ 802.11\\ PCI:IONameMatch:0 string \"pci14e4,43b1\"\" /Extra/Extensions.EDPFix/IO80211Family.kext/Contents/PlugIns/AirPortBrcm4360.kext/Contents/Info.plist");
            UpdateKextVersions("{$workPath}/logs/build/build.log");
            if ($genCache == "yes") {
                myHackCheck();
                KextsPermissionsAndKernelCacheFix($log, "EE");
                // system_call("sudo myfix -q -t / >> $log &");
            }
            break;
    }
    writeToLog("{$log}", "  WiFi kext/binary patched successfullly for BCM4352 card<br>");
    system_call("touch {$workPath}/logs/fixes/patchSuccess.txt;");
}