ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
URLSafeSplitPathTransport.php
Go to the documentation of this file.
1 <?php
2 
20 
25 {
26  public function __construct(private int $max_length = 128)
27  {
28  }
29 
30  public function prepareForTransport(string $compressed_token): string
31  {
32  $string = rtrim(str_replace(['+', '/'], ['-', '_'], base64_encode($compressed_token)), '=');
33  // split string into chunks of 255 characters and separate them with a slash
34  $string = chunk_split($string, $this->max_length, "/");
35 
36  return $string;
37  }
38 
39  public function readFromTransport(string $compressed_token): string
40  {
41  // combine chunks
42  $compressed_token = str_replace("/", "", $compressed_token);
43 
44  $string = base64_decode(str_replace(['-', '_'], ['+', '/'], $compressed_token . '=='));
45 
46  return $string;
47  }
48 
49 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...