Issues (994)

src/MVC/loader.php (1 issue)

1
<?php
2
3
include __DIR__ . '/function.php';
4
5
$zone_division = null;
6
/**
7
 * Session zones.
8
 */
9
$folder_session = null;
10
$uri = \MVC\helper::get_clean_uri();
11
12
//ev(fetch_zone(true));
13
14
/**
15
 * Get zone.
16
 *
17
 * @example https://localhost/THIS_IS_ZONE/path/etc/file
18
 *
19
 * @return string|null
20
 */
21
function get_zone()
22
{
23
  global $zone_division;
24
  for ($i = 0; $i < 5; ++$i) {
25
    if (!$zone_division) {
26
      $zone_division = fetch_zone();
27
    }
28
    if ($zone_division) {
29
      break;
30
    } else {
31
      fetch_zone();
32
    }
33
  }
34
35
  return $zone_division;
36
}
37
38
/**
39
 * Get folder session.
40
 *
41
 * @return string|null
42
 */
43
function folder_session()
44
{
45
  global $folder_session, $zone_division;
46
47
  return $folder_session;
48
}
49
50
$GLOBALS['fetch_zone'] = null;
51
function fetch_zone(bool $dump = false)
52
{
53
  if (isset($GLOBALS['fetch_zone'])) {
54
    if ($dump) {
55
      var_dump('from global');
0 ignored issues
show
Security Debugging Code introduced by
var_dump('from global') looks like debug code. Are you sure you do not want to remove it?
Loading history...
56
    }
57
    return $GLOBALS['fetch_zone'];
58
  }
59
  $uri = \MVC\helper::get_clean_uri();
60
  $zone = \MVC\helper::parse_url2(\MVC\helper::geturl());
61
  if (isset($zone['path'])) {
62
    $zone = $zone['path'];
63
    $zone = array_values(array_filter(explode('/', $zone)));
64
    if (isset($zone[0])) {
65
      \Cookie\helper::hours("zone{$uri}", $zone[0], 24, $uri);
66
      $GLOBALS['fetch_zone'] = $zone[0];
67
      if ($dump) {
68
        var_dump('from fetch');
69
      }
70
    }
71
72
    return $GLOBALS['fetch_zone'];
73
  }
74
}
75