uuid() . "}" . "1"; } else { if(preg_match('/^s{0,1}\{([a-fA-F0-9-]+)\}([0-9]+)$/', $synckey, $matches)) { $n = $matches[2]; $n++; return "{" . $matches[1] . "}" . $n; } else return false; } } // Writes the sync state to a new synckey function setSyncState($synckey, $syncstate) { // Check if synckey is allowed if(!preg_match('/^s{0,1}\{[0-9A-Za-z-]+\}[0-9]+$/', $synckey)) { return false; } return file_put_contents(BASE_PATH . STATE_DIR . "/$synckey", $syncstate); } function uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0x0fff ) | 0x4000, mt_rand( 0, 0x3fff ) | 0x8000, mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); } }; ?>