function applyPatch($text, $name, $rev = false)
{
    include_once "Lib/class.pmkpatcher.php";
    file_put_contents(_amoddir . "Data/{$name}.patch", $text);
    if ($text == "") {
        return 0;
    }
    if ($rev == true) {
        $x = pmkpatcher::unpatch($text, _amoddir . _apatdir);
    } else {
        $x = pmkpatcher::patch($text, _amoddir . _apatdir);
    }
    if (!is_string($x)) {
        foreach ($x['data'] as $file) {
            file_put_contents(_amoddir . _apatdir . $file['sourcefile'], $file['patcheddata']);
        }
        return 1;
    } else {
        return $x;
    }
}