3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Main Class */ namespace projectcleverweb\lastautoindex; /** * Main Class (controller) * ======================= * This is the "controller" of LAI's MVC framework * * Here is a visual representation the "chain of command" within this system * //===VISUAL MAP=====================\\ * || || * || [Controller] || * || | | || * || -------- | || * || | V || * || | ---[Model]<--->[Database] || * || | | ^ || * || V V | || * || [View-Model]-- || * || | || * || V || * || [View] || * || || * \\==================================// * * @see http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller */ class main { public static $error; public static $config_file = __DIR__.'/../config.php'; public static $config; public static $base_dir; public static $public_dir; public static $system_dir; public static $themes_dir; public static $theme_dir; public static $base_uri; public static $public_uri; public static $themes_uri; public static $theme_uri; public static $db = FALSE; public static $server; public static function init ($config_file = '') { self::$error = new error(); self::$config = self::_get_config($config_file); self::_check_config(self::$config); self::set_vars(self::$config); debug::init(); theme::init(); } private static function _get_config($config_file = '') { if (!empty($config_file)) { if (is_file($config_file)) { self::$config_file = realpath($config_file); return require_once $config_file; } self::$error->standard('Configuration file "'.$config_file.'" doesn\'t exist!'); } if (!is_file(self::$config_file)) { self::$error->fatal('No configuration file exists!'); } self::$config_file = realpath(self::$config_file); return require_once self::$config_file; } private static function _check_config($config) { $required_configs = array( 'use_login' ); $error_fmt = 'Configuration Option "%1$s" doesn\'t exist!'; $errors = 0; foreach ($required_configs as $required_config) { if (!isset($config[$required_config])) { self::$error->standard(sprintf($error_fmt, $required_config)); } } if ($errors) { self::$error->fatal('Configuration file is broken! (options are missing)'); } } protected static function set_vars($config) { self::$server = $_SERVER; self::$base_dir = self::get_base_dir(); self::$system_dir = self::$base_dir.DIRECTORY_SEPARATOR.'system'; self::$public_dir = self::$base_dir.DIRECTORY_SEPARATOR.'public'; self::$themes_dir = self::$public_dir.DIRECTORY_SEPARATOR.'themes'; self::$theme_dir = self::$themes_dir.DIRECTORY_SEPARATOR.$config['theme']; if (empty($config['theme'])) { self::$theme_uri = self::$themes_uri.DIRECTORY_SEPARATOR.'default'; } self::$base_uri = self::get_base_uri(); self::$public_uri = self::$base_uri.'/public'; self::$themes_uri = self::$public_uri.'/themes'; self::$theme_uri = self::$themes_uri.'/'.$config['theme']; if (empty($config['theme'])) { self::$theme_uri = self::$themes_uri.'/default'; } if ($config['use_login']) { if (!isset($config['database_host'], $config['database_user'], $config['database_pass'], $config['database_name'])) { self::$error->fatal('Database var(s) are not set'); } self::$db = new database($config['database_host'], $config['database_user'], $config['database_pass'], $config['database_name']); } } protected static function get_base_dir() { return realpath(__DIR__.'/..'); } protected static function get_base_uri() { $uri = substr(self::$base_dir, strlen($_SERVER['DOCUMENT_ROOT'])); return sprintf( '%1$s://%2$s%3$s%4$s', self::$server['REQUEST_SCHEME'], self::$server['HTTP_HOST'], ((int) self::$server['SERVER_PORT'] == 80 ? '' : ':'.self::$server['SERVER_PORT']), str_replace('\\', '/', $uri) ); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jRU1m
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  135     0  E > > RETURN                                                   1

Class projectcleverweb\lastautoindex\main:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jRU1m
function name:  init
number of ops:  25
compiled vars:  !0 = $config_file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV_INIT                                        !0      ''
   53     1        NEW                                              $2      'projectcleverweb%5Clastautoindex%5Cerror'
          2        DO_FCALL                                      0          
          3        ASSIGN_STATIC_PROP                                       'error'
          4        OP_DATA                                                  $2
   54     5        INIT_STATIC_METHOD_CALL                                  '_get_config'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $5      
          8        ASSIGN_STATIC_PROP                                       'config'
          9        OP_DATA                                                  $5
   55    10        INIT_STATIC_METHOD_CALL                                  '_check_config'
         11        CHECK_FUNC_ARG                                           
         12        FETCH_STATIC_PROP_FUNC_ARG   unknown             $6      'config'
         13        SEND_FUNC_ARG                                            $6
         14        DO_FCALL                                      0          
   56    15        INIT_STATIC_METHOD_CALL                                  'set_vars'
         16        CHECK_FUNC_ARG                                           
         17        FETCH_STATIC_PROP_FUNC_ARG   unknown             $8      'config'
         18        SEND_FUNC_ARG                                            $8
         19        DO_FCALL                                      0          
   57    20        INIT_STATIC_METHOD_CALL                                  'projectcleverweb%5Clastautoindex%5Cdebug', 'init'
         21        DO_FCALL                                      0          
   58    22        INIT_STATIC_METHOD_CALL                                  'projectcleverweb%5Clastautoindex%5Ctheme', 'init'
         23        DO_FCALL                                      0          
   59    24      > RETURN                                                   null

End of function init

Function _get_config:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 21
filename:       /in/jRU1m
function name:  _get_config
number of ops:  43
compiled vars:  !0 = $config_file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   RECV_INIT                                        !0      ''
   62     1        ISSET_ISEMPTY_CV                                 ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->21
   63     4    >   INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Cis_file'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $3      
          7      > JMPZ                                                     $3, ->15
   64     8    >   INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Crealpath'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $5      
         11        ASSIGN_STATIC_PROP                                       'config_file'
         12        OP_DATA                                                  $5
   65    13        INCLUDE_OR_EVAL                                  $6      !0, REQUIRE_ONCE
         14      > RETURN                                                   $6
   67    15    >   FETCH_STATIC_PROP_R          unknown             ~7      'error'
         16        INIT_METHOD_CALL                                         ~7, 'standard'
         17        CONCAT                                           ~8      'Configuration+file+%22', !0
         18        CONCAT                                           ~9      ~8, '%22+doesn%27t+exist%21'
         19        SEND_VAL_EX                                              ~9
         20        DO_FCALL                                      0          
   70    21    >   INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Cis_file'
         22        CHECK_FUNC_ARG                                           
         23        FETCH_STATIC_PROP_FUNC_ARG   unknown             $11     'config_file'
         24        SEND_FUNC_ARG                                            $11
         25        DO_FCALL                                      0  $12     
         26        BOOL_NOT                                         ~13     $12
         27      > JMPZ                                                     ~13, ->32
   71    28    >   FETCH_STATIC_PROP_R          unknown             ~14     'error'
         29        INIT_METHOD_CALL                                         ~14, 'fatal'
         30        SEND_VAL_EX                                              'No+configuration+file+exists%21'
         31        DO_FCALL                                      0          
   73    32    >   INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Crealpath'
         33        CHECK_FUNC_ARG                                           
         34        FETCH_STATIC_PROP_FUNC_ARG   unknown             $17     'config_file'
         35        SEND_FUNC_ARG                                            $17
         36        DO_FCALL                                      0  $18     
         37        ASSIGN_STATIC_PROP                                       'config_file'
         38        OP_DATA                                                  $18
   74    39        FETCH_STATIC_PROP_R          unknown             ~19     'config_file'
         40        INCLUDE_OR_EVAL                                  $20     ~19, REQUIRE_ONCE
         41      > RETURN                                                   $20
   75    42*     > RETURN                                                   null

End of function _get_config

Function _check_config:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 17
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 18
filename:       /in/jRU1m
function name:  _check_config
number of ops:  25
compiled vars:  !0 = $config, !1 = $required_configs, !2 = $error_fmt, !3 = $errors, !4 = $required_config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   RECV                                             !0      
   78     1        ASSIGN                                                   !1, <array>
   82     2        ASSIGN                                                   !2, 'Configuration+Option+%22%251%24s%22+doesn%27t+exist%21'
   83     3        ASSIGN                                                   !3, 0
   84     4      > FE_RESET_R                                       $8      !1, ->18
          5    > > FE_FETCH_R                                               $8, !4, ->18
   85     6    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !0, !4
          7        BOOL_NOT                                         ~10     ~9
          8      > JMPZ                                                     ~10, ->17
   86     9    >   FETCH_STATIC_PROP_R          unknown             ~11     'error'
         10        INIT_METHOD_CALL                                         ~11, 'standard'
         11        INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Csprintf'
         12        SEND_VAR_EX                                              !2
         13        SEND_VAR_EX                                              !4
         14        DO_FCALL                                      0  $12     
         15        SEND_VAR_NO_REF_EX                                       $12
         16        DO_FCALL                                      0          
   84    17    > > JMP                                                      ->5
         18    >   FE_FREE                                                  $8
   89    19      > JMPZ                                                     !3, ->24
   90    20    >   FETCH_STATIC_PROP_R          unknown             ~14     'error'
         21        INIT_METHOD_CALL                                         ~14, 'fatal'
         22        SEND_VAL_EX                                              'Configuration+file+is+broken%21+%28options+are+missing%29'
         23        DO_FCALL                                      0          
   92    24    > > RETURN                                                   null

End of function _check_config

Function set_vars:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 41
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 65
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 99
Branch analysis from position: 67
2 jumps found. (Code = 46) Position 1 = 69, Position 2 = 71
Branch analysis from position: 69
2 jumps found. (Code = 46) Position 1 = 72, Position 2 = 74
Branch analysis from position: 72
2 jumps found. (Code = 46) Position 1 = 75, Position 2 = 77
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 79, Position 2 = 83
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 83
Branch analysis from position: 77
Branch analysis from position: 74
Branch analysis from position: 71
Branch analysis from position: 99
Branch analysis from position: 65
Branch analysis from position: 41
filename:       /in/jRU1m
function name:  set_vars
number of ops:  100
compiled vars:  !0 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   RECV                                             !0      
   95     1        FETCH_R                      global              ~2      '_SERVER'
          2        ASSIGN_STATIC_PROP                                       'server'
          3        OP_DATA                                                  ~2
   96     4        INIT_STATIC_METHOD_CALL                                  'get_base_dir'
          5        DO_FCALL                                      0  $4      
          6        ASSIGN_STATIC_PROP                                       'base_dir'
          7        OP_DATA                                                  $4
   97     8        FETCH_STATIC_PROP_R          unknown             ~6      'base_dir'
          9        FETCH_CONSTANT                                   ~7      'projectcleverweb%5Clastautoindex%5CDIRECTORY_SEPARATOR'
         10        CONCAT                                           ~8      ~6, ~7
         11        CONCAT                                           ~9      ~8, 'system'
         12        ASSIGN_STATIC_PROP                                       'system_dir'
         13        OP_DATA                                                  ~9
   98    14        FETCH_STATIC_PROP_R          unknown             ~11     'base_dir'
         15        FETCH_CONSTANT                                   ~12     'projectcleverweb%5Clastautoindex%5CDIRECTORY_SEPARATOR'
         16        CONCAT                                           ~13     ~11, ~12
         17        CONCAT                                           ~14     ~13, 'public'
         18        ASSIGN_STATIC_PROP                                       'public_dir'
         19        OP_DATA                                                  ~14
   99    20        FETCH_STATIC_PROP_R          unknown             ~16     'public_dir'
         21        FETCH_CONSTANT                                   ~17     'projectcleverweb%5Clastautoindex%5CDIRECTORY_SEPARATOR'
         22        CONCAT                                           ~18     ~16, ~17
         23        CONCAT                                           ~19     ~18, 'themes'
         24        ASSIGN_STATIC_PROP                                       'themes_dir'
         25        OP_DATA                                                  ~19
  100    26        FETCH_STATIC_PROP_R          unknown             ~21     'themes_dir'
         27        FETCH_CONSTANT                                   ~22     'projectcleverweb%5Clastautoindex%5CDIRECTORY_SEPARATOR'
         28        CONCAT                                           ~23     ~21, ~22
         29        FETCH_DIM_R                                      ~24     !0, 'theme'
         30        CONCAT                                           ~25     ~23, ~24
         31        ASSIGN_STATIC_PROP                                       'theme_dir'
         32        OP_DATA                                                  ~25
  101    33        ISSET_ISEMPTY_DIM_OBJ                         1          !0, 'theme'
         34      > JMPZ                                                     ~26, ->41
  102    35    >   FETCH_STATIC_PROP_R          unknown             ~28     'themes_uri'
         36        FETCH_CONSTANT                                   ~29     'projectcleverweb%5Clastautoindex%5CDIRECTORY_SEPARATOR'
         37        CONCAT                                           ~30     ~28, ~29
         38        CONCAT                                           ~31     ~30, 'default'
         39        ASSIGN_STATIC_PROP                                       'theme_uri'
         40        OP_DATA                                                  ~31
  104    41    >   INIT_STATIC_METHOD_CALL                                  'get_base_uri'
         42        DO_FCALL                                      0  $33     
         43        ASSIGN_STATIC_PROP                                       'base_uri'
         44        OP_DATA                                                  $33
  105    45        FETCH_STATIC_PROP_R          unknown             ~35     'base_uri'
         46        CONCAT                                           ~36     ~35, '%2Fpublic'
         47        ASSIGN_STATIC_PROP                                       'public_uri'
         48        OP_DATA                                                  ~36
  106    49        FETCH_STATIC_PROP_R          unknown             ~38     'public_uri'
         50        CONCAT                                           ~39     ~38, '%2Fthemes'
         51        ASSIGN_STATIC_PROP                                       'themes_uri'
         52        OP_DATA                                                  ~39
  107    53        FETCH_STATIC_PROP_R          unknown             ~41     'themes_uri'
         54        CONCAT                                           ~42     ~41, '%2F'
         55        FETCH_DIM_R                                      ~43     !0, 'theme'
         56        CONCAT                                           ~44     ~42, ~43
         57        ASSIGN_STATIC_PROP                                       'theme_uri'
         58        OP_DATA                                                  ~44
  108    59        ISSET_ISEMPTY_DIM_OBJ                         1          !0, 'theme'
         60      > JMPZ                                                     ~45, ->65
  109    61    >   FETCH_STATIC_PROP_R          unknown             ~47     'themes_uri'
         62        CONCAT                                           ~48     ~47, '%2Fdefault'
         63        ASSIGN_STATIC_PROP                                       'theme_uri'
         64        OP_DATA                                                  ~48
  111    65    >   FETCH_DIM_R                                      ~49     !0, 'use_login'
         66      > JMPZ                                                     ~49, ->99
  112    67    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~50     !0, 'database_host'
         68      > JMPZ_EX                                          ~50     ~50, ->71
         69    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~51     !0, 'database_user'
         70        BOOL                                             ~50     ~51
         71    > > JMPZ_EX                                          ~50     ~50, ->74
         72    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~52     !0, 'database_pass'
         73        BOOL                                             ~50     ~52
         74    > > JMPZ_EX                                          ~50     ~50, ->77
         75    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~53     !0, 'database_name'
         76        BOOL                                             ~50     ~53
         77    >   BOOL_NOT                                         ~54     ~50
         78      > JMPZ                                                     ~54, ->83
  113    79    >   FETCH_STATIC_PROP_R          unknown             ~55     'error'
         80        INIT_METHOD_CALL                                         ~55, 'fatal'
         81        SEND_VAL_EX                                              'Database+var%28s%29+are+not+set'
         82        DO_FCALL                                      0          
  115    83    >   NEW                                              $58     'projectcleverweb%5Clastautoindex%5Cdatabase'
         84        CHECK_FUNC_ARG                                           
         85        FETCH_DIM_FUNC_ARG                               $59     !0, 'database_host'
         86        SEND_FUNC_ARG                                            $59
         87        CHECK_FUNC_ARG                                           
         88        FETCH_DIM_FUNC_ARG                               $60     !0, 'database_user'
         89        SEND_FUNC_ARG                                            $60
         90        CHECK_FUNC_ARG                                           
         91        FETCH_DIM_FUNC_ARG                               $61     !0, 'database_pass'
         92        SEND_FUNC_ARG                                            $61
         93        CHECK_FUNC_ARG                                           
         94        FETCH_DIM_FUNC_ARG                               $62     !0, 'database_name'
         95        SEND_FUNC_ARG                                            $62
         96        DO_FCALL                                      0          
         97        ASSIGN_STATIC_PROP                                       'db'
         98        OP_DATA                                                  $58
  117    99    > > RETURN                                                   null

End of function set_vars

Function get_base_dir:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jRU1m
function name:  get_base_dir
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  120     0  E >   INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Crealpath'
          1        SEND_VAL_EX                                              '%2Fin%2F..'
          2        DO_FCALL                                      0  $0      
          3      > RETURN                                                   $0
  121     4*     > RETURN                                                   null

End of function get_base_dir

Function get_base_uri:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jRU1m
function name:  get_base_uri
number of ops:  44
compiled vars:  !0 = $uri
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  124     0  E >   INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Csubstr'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_STATIC_PROP_FUNC_ARG   unknown             $1      'base_dir'
          3        SEND_FUNC_ARG                                            $1
          4        INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Cstrlen'
          5        CHECK_FUNC_ARG                                           
          6        FETCH_FUNC_ARG               global              $2      '_SERVER'
          7        FETCH_DIM_FUNC_ARG                               $3      $2, 'DOCUMENT_ROOT'
          8        SEND_FUNC_ARG                                            $3
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR_NO_REF_EX                                       $4
         11        DO_FCALL                                      0  $5      
         12        ASSIGN                                                   !0, $5
  125    13        INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Csprintf'
  126    14        SEND_VAL_EX                                              '%251%24s%3A%2F%2F%252%24s%253%24s%254%24s'
         15        CHECK_FUNC_ARG                                           
  127    16        FETCH_STATIC_PROP_FUNC_ARG   unknown             $7      'server'
         17        FETCH_DIM_FUNC_ARG                               $8      $7, 'REQUEST_SCHEME'
         18        SEND_FUNC_ARG                                            $8
         19        CHECK_FUNC_ARG                                           
  128    20        FETCH_STATIC_PROP_FUNC_ARG   unknown             $9      'server'
         21        FETCH_DIM_FUNC_ARG                               $10     $9, 'HTTP_HOST'
         22        SEND_FUNC_ARG                                            $10
  129    23        FETCH_STATIC_PROP_R          unknown             ~11     'server'
         24        FETCH_DIM_R                                      ~12     ~11, 'SERVER_PORT'
         25        CAST                                          4  ~13     ~12
         26        IS_EQUAL                                                 ~13, 80
         27      > JMPZ                                                     ~14, ->30
         28    >   QM_ASSIGN                                        ~15     ''
         29      > JMP                                                      ->34
         30    >   FETCH_STATIC_PROP_R          unknown             ~16     'server'
         31        FETCH_DIM_R                                      ~17     ~16, 'SERVER_PORT'
         32        CONCAT                                           ~18     '%3A', ~17
         33        QM_ASSIGN                                        ~15     ~18
         34    >   SEND_VAL_EX                                              ~15
  130    35        INIT_NS_FCALL_BY_NAME                                    'projectcleverweb%5Clastautoindex%5Cstr_replace'
         36        SEND_VAL_EX                                              '%5C'
         37        SEND_VAL_EX                                              '%2F'
         38        SEND_VAR_EX                                              !0
         39        DO_FCALL                                      0  $19     
         40        SEND_VAR_NO_REF_EX                                       $19
         41        DO_FCALL                                      0  $20     
         42      > RETURN                                                   $20
  132    43*     > RETURN                                                   null

End of function get_base_uri

End of class projectcleverweb\lastautoindex\main.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.37 ms | 1420 KiB | 25 Q