3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* receive form data: $username = (!empty(POST['username']))? POST['username'] : null; $password = (!empty(POST['password']))? POST['password'] : null; $user_hash = (!empty(POST['user_hash']))? POST['user_hash'] : null; By Prince Adeyemi */ //Login with received data $username = "myLogin"; $password = "letmein"; $user_hash = "hash123451"; // Alter this hash to Prompt for Verification. $user = new login($username, $password, $user_hash); Class login { private $_loggedIn = false; private $_username = null; private $_password = null; private $_userhash = null; function __construct(string $user, string $password, string $user_hash) { $this->_username = trim($user); $this->_password = trim($password); $this->_userhash = trim($user_hash); $this->login_user($this->_username, $this->password); } private function login_user(string $user, string $pass) { $this->login($this->_username, $this->password); } private function login(string $username, string $password) : bool { echo "Login using Username $this->_username and password $this->_password"; $this->_loggedIn = $this->isloggedIn(); if($this->_loggedIn) { echo "\nLogin Successfully"; $this->compare($this->_userhash); } else{ echo "\nLogin failed!"; } return $this->__get($this->_username); } private function compare($new_hash) { $stored_hash = "hash12345"; $hashed_verify = ($new_hash === $stored_hash) ? true : false; if(!$hashed_verify) { $this->_loggedIn = false; $this->_doSecurity($this->_username); } else{ echo"\nHash matched sending user : $this->_username to USER_DASHBOAD"; } } private function _doSecurity($user) { echo "\nHash not matched, commencing security verification for $this->_username"; } private function isLoggedIn():bool { //..check if logged in, or set loggedIn to false. $this->_loggedIn = (($this->_username == "myLogin") && ($this->_password=="letmein") ) ? true : $this->_loggedIn ; return $this->__get($this->_username); } public function __get($userLoggedIn) :bool { return $this->_loggedIn; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R9UQg
function name:  (null)
number of ops:  10
compiled vars:  !0 = $username, !1 = $password, !2 = $user_hash, !3 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 'myLogin'
   15     1        ASSIGN                                                   !1, 'letmein'
   16     2        ASSIGN                                                   !2, 'hash123451'
   18     3        NEW                                              $7      'login'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !3, $7
   92     9      > RETURN                                                   1

Class login:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R9UQg
function name:  __construct
number of ops:  27
compiled vars:  !0 = $user, !1 = $password, !2 = $user_hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   30     3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        ASSIGN_OBJ                                               '_username'
          7        OP_DATA                                                  $4
   31     8        INIT_FCALL                                               'trim'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ASSIGN_OBJ                                               '_password'
         12        OP_DATA                                                  $6
   32    13        INIT_FCALL                                               'trim'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $8      
         16        ASSIGN_OBJ                                               '_userhash'
         17        OP_DATA                                                  $8
   34    18        INIT_METHOD_CALL                                         'login_user'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_OBJ_FUNC_ARG                               $9      '_username'
         21        SEND_FUNC_ARG                                            $9
         22        CHECK_FUNC_ARG                                           
         23        FETCH_OBJ_FUNC_ARG                               $10     'password'
         24        SEND_FUNC_ARG                                            $10
         25        DO_FCALL                                      0          
   35    26      > RETURN                                                   null

End of function __construct

Function login_user:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R9UQg
function name:  login_user
number of ops:  11
compiled vars:  !0 = $user, !1 = $pass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   39     2        INIT_METHOD_CALL                                         'login'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $2      '_username'
          5        SEND_FUNC_ARG                                            $2
          6        CHECK_FUNC_ARG                                           
          7        FETCH_OBJ_FUNC_ARG                               $3      'password'
          8        SEND_FUNC_ARG                                            $3
          9        DO_FCALL                                      0          
   40    10      > RETURN                                                   null

End of function login_user

Function login:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R9UQg
function name:  login
number of ops:  32
compiled vars:  !0 = $username, !1 = $password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   44     2        ROPE_INIT                                     4  ~5      'Login+using+Username+'
          3        FETCH_OBJ_R                                      ~2      '_username'
          4        ROPE_ADD                                      1  ~5      ~5, ~2
          5        ROPE_ADD                                      2  ~5      ~5, '+and+password+'
          6        FETCH_OBJ_R                                      ~3      '_password'
          7        ROPE_END                                      3  ~4      ~5, ~3
          8        ECHO                                                     ~4
   46     9        INIT_METHOD_CALL                                         'isloggedIn'
         10        DO_FCALL                                      0  $8      
         11        ASSIGN_OBJ                                               '_loggedIn'
         12        OP_DATA                                                  $8
   48    13        FETCH_OBJ_R                                      ~9      '_loggedIn'
         14      > JMPZ                                                     ~9, ->22
   50    15    >   ECHO                                                     '%0ALogin+Successfully'
   51    16        INIT_METHOD_CALL                                         'compare'
         17        CHECK_FUNC_ARG                                           
         18        FETCH_OBJ_FUNC_ARG                               $10     '_userhash'
         19        SEND_FUNC_ARG                                            $10
         20        DO_FCALL                                      0          
         21      > JMP                                                      ->23
   54    22    >   ECHO                                                     '%0ALogin+failed%21'
   57    23    >   INIT_METHOD_CALL                                         '__get'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_OBJ_FUNC_ARG                               $12     '_username'
         26        SEND_FUNC_ARG                                            $12
         27        DO_FCALL                                      0  $13     
         28        VERIFY_RETURN_TYPE                                       $13
         29      > RETURN                                                   $13
   58    30*       VERIFY_RETURN_TYPE                                       
         31*     > RETURN                                                   null

End of function login

Function compare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
Branch analysis from position: 18
filename:       /in/R9UQg
function name:  compare
number of ops:  24
compiled vars:  !0 = $new_hash, !1 = $stored_hash, !2 = $hashed_verify
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
   62     1        ASSIGN                                                   !1, 'hash12345'
   63     2        IS_IDENTICAL                                             !0, !1
          3      > JMPZ                                                     ~4, ->6
          4    >   QM_ASSIGN                                        ~5      <true>
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~5      <false>
          7    >   ASSIGN                                                   !2, ~5
   65     8        BOOL_NOT                                         ~7      !2
          9      > JMPZ                                                     ~7, ->18
   67    10    >   ASSIGN_OBJ                                               '_loggedIn'
         11        OP_DATA                                                  <false>
   68    12        INIT_METHOD_CALL                                         '_doSecurity'
         13        CHECK_FUNC_ARG                                           
         14        FETCH_OBJ_FUNC_ARG                               $9      '_username'
         15        SEND_FUNC_ARG                                            $9
         16        DO_FCALL                                      0          
         17      > JMP                                                      ->23
   71    18    >   ROPE_INIT                                     3  ~13     '%0AHash+matched+sending+user+%3A+'
         19        FETCH_OBJ_R                                      ~11     '_username'
         20        ROPE_ADD                                      1  ~13     ~13, ~11
         21        ROPE_END                                      2  ~12     ~13, '+to+USER_DASHBOAD'
         22        ECHO                                                     ~12
   73    23    > > RETURN                                                   null

End of function compare

Function _dosecurity:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R9UQg
function name:  _doSecurity
number of ops:  6
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   75     0  E >   RECV                                             !0      
   77     1        NOP                                                      
          2        FETCH_OBJ_R                                      ~1      '_username'
          3        FAST_CONCAT                                      ~2      '%0AHash+not+matched%2C+commencing+security+verification+for+', ~1
          4        ECHO                                                     ~2
   78     5      > RETURN                                                   null

End of function _dosecurity

Function isloggedin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/R9UQg
function name:  isLoggedIn
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   FETCH_OBJ_R                                      ~1      '_username'
          1        IS_EQUAL                                         ~2      ~1, 'myLogin'
          2      > JMPZ_EX                                          ~2      ~2, ->6
          3    >   FETCH_OBJ_R                                      ~3      '_password'
          4        IS_EQUAL                                         ~4      ~3, 'letmein'
          5        BOOL                                             ~2      ~4
          6    > > JMPZ                                                     ~2, ->9
          7    >   QM_ASSIGN                                        ~5      <true>
          8      > JMP                                                      ->11
          9    >   FETCH_OBJ_R                                      ~6      '_loggedIn'
         10        QM_ASSIGN                                        ~5      ~6
         11    >   ASSIGN_OBJ                                               '_loggedIn'
         12        OP_DATA                                                  ~5
   85    13        INIT_METHOD_CALL                                         '__get'
         14        CHECK_FUNC_ARG                                           
         15        FETCH_OBJ_FUNC_ARG                               $7      '_username'
         16        SEND_FUNC_ARG                                            $7
         17        DO_FCALL                                      0  $8      
         18        VERIFY_RETURN_TYPE                                       $8
         19      > RETURN                                                   $8
   86    20*       VERIFY_RETURN_TYPE                                       
         21*     > RETURN                                                   null

End of function isloggedin

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/R9UQg
function name:  __get
number of ops:  6
compiled vars:  !0 = $userLoggedIn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   RECV                                             !0      
   90     1        FETCH_OBJ_R                                      ~1      '_loggedIn'
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   91     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __get

End of class login.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.02 ms | 1408 KiB | 15 Q