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;
    }
}
 /**
  * Unpatch file using .diff file in unified diff format.
  *
  * @param	string			Content of unified .diff file to process
  * @param	string			Otional path which is prepended to the source name found in the .diff
  * @return	array/string	If patching was sucessful, an array containing the patched file (data), an optional comment (comment), the source file name (source) and the destination file name (destination).
  *							If patching failed, a string is returned, containing the error msg.
  */
 public static function unpatch($diffFile, $path = '')
 {
     return pmkpatcher::patch($diffFile, $path, true);
 }