$message, 'status' => $status ); } /** * create a short string based on a integer * * @see https://www.jwz.org/base64-shortlinks/ * @return string */ static function b64sl_pack_id(string $id): string { $id = intval($id); $ida = ($id > 0xFFFFFFFF ? $id >> 32 : 0); // 32 bit big endian, top $idb = ($id & 0xFFFFFFFF); // 32 bit big endian, bottom $id = pack ('N', $ida) . pack ('N', $idb); $id = preg_replace('/^\000+/', '', "$id"); // omit high-order NUL bytes $id = base64_encode ($id); $id = str_replace ('+', '-', $id); // encode URL-unsafe "+" "/" $id = str_replace ('/', '_', $id); $id = preg_replace ('/=+$/', '', $id); // omit trailing padding bytes return $id; } /** * Decode a base64-encoded big-endian integer of up to 64 bits. * * @see https://www.jwz.org/base64-shortlinks/ * @param string $id * @return int */ static function b64sl_unpack_id(string $id): int { $id = str_replace ('-', '+', $id); // decode URL-unsafe "+" "/" $id = str_replace ('_', '/', $id); $id = base64_decode ($id); while (strlen($id) < 8) { $id = "\000$id"; } // pad with leading NULs $a = unpack ('N*', $id); // 32 bit big endian $id = ($a[1] << 32) | $a[2]; // pack top and bottom word return $id; } /** * create based on the given string a path * each char in string is a dir * asdef -> a/s/d/e/f/ * * @param string $string * @return string */ static function forwardslashStringToPath(string $string): string { $ret = ''; if(!empty($string)) { for ($i = 0; $i < strlen($string); $i++) { $ret .= $string[$i] . "/"; } } return $ret; } }