3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Class OneFileLoginApplication * * An entire php application with user registration, login and logout in one file. * Uses very modern password hashing via the PHP 5.5 password hashing functions. * This project includes a compatibility file to make these functions available in PHP 5.3.7+ and PHP 5.4+. * * @author Panique * @link https://github.com/panique/php-login-one-file/ * @license http://opensource.org/licenses/MIT MIT License */ class OneFileLoginApplication { /** * @var string Type of used database (currently only SQLite, but feel free to expand this with mysql etc) */ private $db_type = "sqlite"; // /** * @var string Path of the database file (create this with _install.php) */ private $db_sqlite_path = "./users.db"; /** * @var object Database connection */ private $db_connection = null; /** * @var bool Login status of user */ private $user_is_logged_in = false; /** * @var string System messages, likes errors, notices, etc. */ public $feedback = ""; /** * Does necessary checks for PHP version and PHP password compatibility library and runs the application */ public function __construct() { if ($this->performMinimumRequirementsCheck()) { $this->runApplication(); } } /** * Performs a check for minimum requirements to run this application. * Does not run the further application when PHP version is lower than 5.3.7 * Does include the PHP password compatibility library when PHP version lower than 5.5.0 * (this library adds the PHP 5.5 password hashing functions to older versions of PHP) * @return bool Success status of minimum requirements check, default is false */ private function performMinimumRequirementsCheck() { if (version_compare(PHP_VERSION, '5.3.7', '<')) { echo "Sorry, Simple PHP Login does not run on a PHP version older than 5.3.7 !"; } elseif (version_compare(PHP_VERSION, '5.5.0', '<')) { require_once("libraries/password_compatibility_library.php"); return true; } elseif (version_compare(PHP_VERSION, '5.5.0', '>=')) { return true; } // default return return false; } /** * This is basically the controller that handles the entire flow of the application. */ public function runApplication() { // check is user wants to see register page (etc.) if (isset($_GET["action"]) && $_GET["action"] == "register") { $this->doRegistration(); $this->showPageRegistration(); } else { // start the session, always needed! $this->doStartSession(); // check for possible user interactions (login with session/post data or logout) $this->performUserLoginAction(); // show "page", according to user's login status if ($this->getUserLoginStatus()) { $this->showPageLoggedIn(); } else { $this->showPageLoginForm(); } } } /** * Creates a PDO database connection (in this case to a SQLite flat-file database) * @return bool Database creation success status, false by default */ private function createDatabaseConnection() { try { $this->db_connection = new PDO($this->db_type . ':' . $this->db_sqlite_path); return true; } catch (PDOException $e) { $this->feedback = "PDO database connection problem: " . $e->getMessage(); } catch (Exception $e) { $this->feedback = "General problem: " . $e->getMessage(); } return false; } /** * Handles the flow of the login/logout process. According to the circumstances, a logout, a login with session * data or a login with post data will be performed */ private function performUserLoginAction() { if (isset($_GET["action"]) && $_GET["action"] == "logout") { $this->doLogout(); } elseif (!empty($_SESSION['user_name']) && ($_SESSION['user_is_logged_in'])) { $this->doLoginWithSessionData(); } elseif (isset($_POST["login"])) { $this->doLoginWithPostData(); } } /** * Simply starts the session. * It's cleaner to put this into a method than writing it directly into runApplication() */ private function doStartSession() { session_start(); } /** * Set a marker (NOTE: is this method necessary ?) */ private function doLoginWithSessionData() { $this->user_is_logged_in = true; // ? } /** * Process flow of login with POST data */ private function doLoginWithPostData() { if ($this->checkLoginFormDataNotEmpty()) { if ($this->createDatabaseConnection()) { $this->checkPasswordCorrectnessAndLogin(); } } } /** * Logs the user out */ private function doLogout() { $_SESSION = array(); session_destroy(); $this->user_is_logged_in = false; $this->feedback = "You were just logged out."; } /** * The registration flow * @return bool */ private function doRegistration() { if ($this->checkRegistrationData()) { if ($this->createDatabaseConnection()) { $this->createNewUser(); } } // default return return false; } /** * Validates the login form data, checks if username and password are provided * @return bool Login form data check success state */ private function checkLoginFormDataNotEmpty() { if (!empty($_POST['user_name']) && !empty($_POST['user_password'])) { return true; } elseif (empty($_POST['user_name'])) { $this->feedback = "Username field was empty."; } elseif (empty($_POST['user_password'])) { $this->feedback = "Password field was empty."; } // default return return false; } /** * Checks if user exits, if so: check if provided password matches the one in the database * @return bool User login success status */ private function checkPasswordCorrectnessAndLogin() { // remember: the user can log in with username or email address $sql = 'SELECT user_name, user_email, user_password_hash FROM users WHERE user_name = :user_name OR user_email = :user_name LIMIT 1'; $query = $this->db_connection->prepare($sql); $query->bindValue(':user_name', $_POST['user_name']); $query->execute(); // Btw that's the weird way to get num_rows in PDO with SQLite: // if (count($query->fetchAll(PDO::FETCH_NUM)) == 1) { // Holy! But that's how it is. $result->numRows() works with SQLite pure, but not with SQLite PDO. // This is so crappy, but that's how PDO works. // As there is no numRows() in SQLite/PDO (!!) we have to do it this way: // If you meet the inventor of PDO, punch him. Seriously. $result_row = $query->fetchObject(); if ($result_row) { // using PHP 5.5's password_verify() function to check password if (password_verify($_POST['user_password'], $result_row->user_password_hash)) { // write user data into PHP SESSION [a file on your server] $_SESSION['user_name'] = $result_row->user_name; $_SESSION['user_email'] = $result_row->user_email; $_SESSION['user_is_logged_in'] = true; $this->user_is_logged_in = true; return true; } else { $this->feedback = "Wrong password."; } } else { $this->feedback = "This user does not exist."; } // default return return false; } /** * Validates the user's registration input * @return bool Success status of user's registration data validation */ private function checkRegistrationData() { // if no registration form submitted: exit the method if (!isset($_POST["register"])) { return false; } // validating the input if (!empty($_POST['user_name']) && strlen($_POST['user_name']) <= 64 && strlen($_POST['user_name']) >= 2 && preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name']) && !empty($_POST['user_email']) && strlen($_POST['user_email']) <= 64 && filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL) && !empty($_POST['user_password_new']) && !empty($_POST['user_password_repeat']) && ($_POST['user_password_new'] === $_POST['user_password_repeat']) ) { // only this case return true, only this case is valid return true; } elseif (empty($_POST['user_name'])) { $this->feedback = "Empty Username"; } elseif (empty($_POST['user_password_new']) || empty($_POST['user_password_repeat'])) { $this->feedback = "Empty Password"; } elseif ($_POST['user_password_new'] !== $_POST['user_password_repeat']) { $this->feedback = "Password and password repeat are not the same"; } elseif (strlen($_POST['user_password_new']) < 6) { $this->feedback = "Password has a minimum length of 6 characters"; } elseif (strlen($_POST['user_name']) > 64 || strlen($_POST['user_name']) < 2) { $this->feedback = "Username cannot be shorter than 2 or longer than 64 characters"; } elseif (!preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) { $this->feedback = "Username does not fit the name scheme: only a-Z and numbers are allowed, 2 to 64 characters"; } elseif (empty($_POST['user_email'])) { $this->feedback = "Email cannot be empty"; } elseif (strlen($_POST['user_email']) > 64) { $this->feedback = "Email cannot be longer than 64 characters"; } elseif (!filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) { $this->feedback = "Your email address is not in a valid email format"; } else { $this->feedback = "An unknown error occurred."; } // default return return false; } /** * Creates a new user. * @return bool Success status of user registration */ private function createNewUser() { // remove html code etc. from username and email $user_name = htmlentities($_POST['user_name'], ENT_QUOTES); $user_email = htmlentities($_POST['user_email'], ENT_QUOTES); $user_password = $_POST['user_password_new']; // crypt the user's password with the PHP 5.5's password_hash() function, results in a 60 char hash string. // the constant PASSWORD_DEFAULT comes from PHP 5.5 or the password_compatibility_library $user_password_hash = password_hash($user_password, PASSWORD_DEFAULT); $sql = 'SELECT * FROM users WHERE user_name = :user_name OR user_email = :user_email'; $query = $this->db_connection->prepare($sql); $query->bindValue(':user_name', $user_name); $query->bindValue(':user_email', $user_email); $query->execute(); // As there is no numRows() in SQLite/PDO (!!) we have to do it this way: // If you meet the inventor of PDO, punch him. Seriously. $result_row = $query->fetchObject(); if ($result_row) { $this->feedback = "Sorry, that username / email is already taken. Please choose another one."; } else { $sql = 'INSERT INTO users (user_name, user_password_hash, user_email) VALUES(:user_name, :user_password_hash, :user_email)'; $query = $this->db_connection->prepare($sql); $query->bindValue(':user_name', $user_name); $query->bindValue(':user_password_hash', $user_password_hash); $query->bindValue(':user_email', $user_email); // PDO's execute() gives back TRUE when successful, FALSE when not // @link http://stackoverflow.com/q/1661863/1114320 $registration_success_state = $query->execute(); if ($registration_success_state) { $this->feedback = "Your account has been created successfully. You can now log in."; return true; } else { $this->feedback = "Sorry, your registration failed. Please go back and try again."; } } // default return return false; } /** * Simply returns the current status of the user's login * @return bool User's login status */ public function getUserLoginStatus() { return $this->user_is_logged_in; } /** * Simple demo-"page" that will be shown when the user is logged in. * In a real application you would probably include an html-template here, but for this extremely simple * demo the "echo" statements are totally okay. */ private function showPageLoggedIn() { if ($this->feedback) { echo $this->feedback . "<br/><br/>"; } echo 'Hello ' . $_SESSION['user_name'] . ', you are logged in.<br/><br/>'; echo '<a href="' . $_SERVER['SCRIPT_NAME'] . '?action=logout">Log out</a>'; } /** * Simple demo-"page" with the login form. * In a real application you would probably include an html-template here, but for this extremely simple * demo the "echo" statements are totally okay. */ private function showPageLoginForm() { if ($this->feedback) { echo $this->feedback . "<br/><br/>"; } echo '<h2>Login</h2>'; echo '<form method="post" action="' . $_SERVER['SCRIPT_NAME'] . '" name="loginform">'; echo '<label for="login_input_username">Username (or email)</label> '; echo '<input id="login_input_username" type="text" name="user_name" required /> '; echo '<label for="login_input_password">Password</label> '; echo '<input id="login_input_password" type="password" name="user_password" required /> '; echo '<input type="submit" name="login" value="Log in" />'; echo '</form>'; echo '<a href="' . $_SERVER['SCRIPT_NAME'] . '?action=register">Register new account</a>'; } /** * Simple demo-"page" with the registration form. * In a real application you would probably include an html-template here, but for this extremely simple * demo the "echo" statements are totally okay. */ private function showPageRegistration() { if ($this->feedback) { echo $this->feedback . "<br/><br/>"; } echo '<h2>Registration</h2>'; echo '<form method="post" action="' . $_SERVER['SCRIPT_NAME'] . '?action=register" name="registerform">'; echo '<label for="login_input_username">Username (only letters and numbers, 2 to 64 characters)</label>'; echo '<input id="login_input_username" type="text" pattern="[a-zA-Z0-9]{2,64}" name="user_name" required />'; echo '<label for="login_input_email">User\'s email</label>'; echo '<input id="login_input_email" type="email" name="user_email" required />'; echo '<label for="login_input_password_new">Password (min. 6 characters)</label>'; echo '<input id="login_input_password_new" class="login_input" type="password" name="user_password_new" pattern=".{6,}" required autocomplete="off" />'; echo '<label for="login_input_password_repeat">Repeat password</label>'; echo '<input id="login_input_password_repeat" class="login_input" type="password" name="user_password_repeat" pattern=".{6,}" required autocomplete="off" />'; echo '<input type="submit" name="register" value="Register" />'; echo '</form>'; echo '<a href="' . $_SERVER['SCRIPT_NAME'] . '">Homepage</a>'; } } // run the application $application = new OneFileLoginApplication();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jYppt
function name:  (null)
number of ops:  4
compiled vars:  !0 = $application
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  417     0  E >   NEW                                              $1      'OneFileLoginApplication'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
          3      > RETURN                                                   1

Class OneFileLoginApplication:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/jYppt
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   INIT_METHOD_CALL                                         'performMinimumRequirementsCheck'
          1        DO_FCALL                                      0  $0      
          2      > JMPZ                                                     $0, ->5
   48     3    >   INIT_METHOD_CALL                                         'runApplication'
          4        DO_FCALL                                      0          
   50     5    > > RETURN                                                   null

End of function __construct

Function performminimumrequirementscheck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/jYppt
function name:  performMinimumRequirementsCheck
number of ops:  26
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   INIT_FCALL                                               'version_compare'
          1        SEND_VAL                                                 '8.0.0'
          2        SEND_VAL                                                 '5.3.7'
          3        SEND_VAL                                                 '%3C'
          4        DO_ICALL                                         $0      
          5      > JMPZ                                                     $0, ->8
   62     6    >   ECHO                                                     'Sorry%2C+Simple+PHP+Login+does+not+run+on+a+PHP+version+older+than+5.3.7+%21'
          7      > JMP                                                      ->24
   63     8    >   INIT_FCALL                                               'version_compare'
          9        SEND_VAL                                                 '8.0.0'
         10        SEND_VAL                                                 '5.5.0'
         11        SEND_VAL                                                 '%3C'
         12        DO_ICALL                                         $1      
         13      > JMPZ                                                     $1, ->17
   64    14    >   INCLUDE_OR_EVAL                                          'libraries%2Fpassword_compatibility_library.php', REQUIRE_ONCE
   65    15      > RETURN                                                   <true>
         16*       JMP                                                      ->24
   66    17    >   INIT_FCALL                                               'version_compare'
         18        SEND_VAL                                                 '8.0.0'
         19        SEND_VAL                                                 '5.5.0'
         20        SEND_VAL                                                 '%3E%3D'
         21        DO_ICALL                                         $3      
         22      > JMPZ                                                     $3, ->24
   67    23    > > RETURN                                                   <true>
   70    24    > > RETURN                                                   <false>
   71    25*     > RETURN                                                   null

End of function performminimumrequirementscheck

Function runapplication:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/jYppt
function name:  runApplication
number of ops:  26
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   79     0  E >   FETCH_IS                                         ~0      '_GET'
          1        ISSET_ISEMPTY_DIM_OBJ                         0  ~1      ~0, 'action'
          2      > JMPZ_EX                                          ~1      ~1, ->7
          3    >   FETCH_R                      global              ~2      '_GET'
          4        FETCH_DIM_R                                      ~3      ~2, 'action'
          5        IS_EQUAL                                         ~4      ~3, 'register'
          6        BOOL                                             ~1      ~4
          7    > > JMPZ                                                     ~1, ->13
   80     8    >   INIT_METHOD_CALL                                         'doRegistration'
          9        DO_FCALL                                      0          
   81    10        INIT_METHOD_CALL                                         'showPageRegistration'
         11        DO_FCALL                                      0          
         12      > JMP                                                      ->25
   84    13    >   INIT_METHOD_CALL                                         'doStartSession'
         14        DO_FCALL                                      0          
   86    15        INIT_METHOD_CALL                                         'performUserLoginAction'
         16        DO_FCALL                                      0          
   88    17        INIT_METHOD_CALL                                         'getUserLoginStatus'
         18        DO_FCALL                                      0  $9      
         19      > JMPZ                                                     $9, ->23
   89    20    >   INIT_METHOD_CALL                                         'showPageLoggedIn'
         21        DO_FCALL                                      0          
         22      > JMP                                                      ->25
   91    23    >   INIT_METHOD_CALL                                         'showPageLoginForm'
         24        DO_FCALL                                      0          
   94    25    > > RETURN                                                   null

End of function runapplication

Function createdatabaseconnection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 11
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 107) Position 1 = 19, Position 2 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 18
Branch analysis from position: 18
filename:       /in/jYppt
function name:  createDatabaseConnection
number of ops:  26
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  103     0  E >   NEW                                              $2      'PDO'
          1        FETCH_OBJ_R                                      ~3      'db_type'
          2        CONCAT                                           ~4      ~3, '%3A'
          3        FETCH_OBJ_R                                      ~5      'db_sqlite_path'
          4        CONCAT                                           ~6      ~4, ~5
          5        SEND_VAL_EX                                              ~6
          6        DO_FCALL                                      0          
          7        ASSIGN_OBJ                                               'db_connection'
          8        OP_DATA                                                  $2
  104     9      > RETURN                                                   <true>
         10*       JMP                                                      ->24
  105    11  E > > CATCH                                                    'PDOException', ->18
  106    12    >   INIT_METHOD_CALL                                         !0, 'getMessage'
         13        DO_FCALL                                      0  $9      
         14        CONCAT                                           ~10     'PDO+database+connection+problem%3A+', $9
         15        ASSIGN_OBJ                                               'feedback'
         16        OP_DATA                                                  ~10
         17      > JMP                                                      ->24
  107    18  E > > CATCH                                       last         'Exception'
  108    19    >   INIT_METHOD_CALL                                         !0, 'getMessage'
         20        DO_FCALL                                      0  $12     
         21        CONCAT                                           ~13     'General+problem%3A+', $12
         22        ASSIGN_OBJ                                               'feedback'
         23        OP_DATA                                                  ~13
  110    24    > > RETURN                                                   <false>
  111    25*     > RETURN                                                   null

End of function createdatabaseconnection

Function performuserloginaction:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/jYppt
function name:  performUserLoginAction
number of ops:  28
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  119     0  E >   FETCH_IS                                         ~0      '_GET'
          1        ISSET_ISEMPTY_DIM_OBJ                         0  ~1      ~0, 'action'
          2      > JMPZ_EX                                          ~1      ~1, ->7
          3    >   FETCH_R                      global              ~2      '_GET'
          4        FETCH_DIM_R                                      ~3      ~2, 'action'
          5        IS_EQUAL                                         ~4      ~3, 'logout'
          6        BOOL                                             ~1      ~4
          7    > > JMPZ                                                     ~1, ->11
  120     8    >   INIT_METHOD_CALL                                         'doLogout'
          9        DO_FCALL                                      0          
         10      > JMP                                                      ->27
  121    11    >   FETCH_IS                                         ~6      '_SESSION'
         12        ISSET_ISEMPTY_DIM_OBJ                         1  ~7      ~6, 'user_name'
         13        BOOL_NOT                                         ~8      ~7
         14      > JMPZ_EX                                          ~8      ~8, ->18
         15    >   FETCH_R                      global              ~9      '_SESSION'
         16        FETCH_DIM_R                                      ~10     ~9, 'user_is_logged_in'
         17        BOOL                                             ~8      ~10
         18    > > JMPZ                                                     ~8, ->22
  122    19    >   INIT_METHOD_CALL                                         'doLoginWithSessionData'
         20        DO_FCALL                                      0          
         21      > JMP                                                      ->27
  123    22    >   FETCH_IS                                         ~12     '_POST'
         23        ISSET_ISEMPTY_DIM_OBJ                         0          ~12, 'login'
         24      > JMPZ                                                     ~13, ->27
  124    25    >   INIT_METHOD_CALL                                         'doLoginWithPostData'
         26        DO_FCALL                                      0          
  126    27    > > RETURN                                                   null

End of function performuserloginaction

Function dostartsession:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jYppt
function name:  doStartSession
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  134     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                                 
  135     2      > RETURN                                                   null

End of function dostartsession

Function dologinwithsessiondata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jYppt
function name:  doLoginWithSessionData
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  142     0  E >   ASSIGN_OBJ                                               'user_is_logged_in'
          1        OP_DATA                                                  <true>
  143     2      > RETURN                                                   null

End of function dologinwithsessiondata

Function dologinwithpostdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 8
filename:       /in/jYppt
function name:  doLoginWithPostData
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  150     0  E >   INIT_METHOD_CALL                                         'checkLoginFormDataNotEmpty'
          1        DO_FCALL                                      0  $0      
          2      > JMPZ                                                     $0, ->8
  151     3    >   INIT_METHOD_CALL                                         'createDatabaseConnection'
          4        DO_FCALL                                      0  $1      
          5      > JMPZ                                                     $1, ->8
  152     6    >   INIT_METHOD_CALL                                         'checkPasswordCorrectnessAndLogin'
          7        DO_FCALL                                      0          
  155     8    > > RETURN                                                   null

End of function dologinwithpostdata

Function dologout:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jYppt
function name:  doLogout
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  162     0  E >   FETCH_W                      global              $0      '_SESSION'
          1        ASSIGN                                                   $0, <array>
  163     2        INIT_FCALL                                               'session_destroy'
          3        DO_ICALL                                                 
  164     4        ASSIGN_OBJ                                               'user_is_logged_in'
          5        OP_DATA                                                  <false>
  165     6        ASSIGN_OBJ                                               'feedback'
          7        OP_DATA                                                  'You+were+just+logged+out.'
  166     8      > RETURN                                                   null

End of function dologout

Function doregistration:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 8
filename:       /in/jYppt
function name:  doRegistration
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  174     0  E >   INIT_METHOD_CALL                                         'checkRegistrationData'
          1        DO_FCALL                                      0  $0      
          2      > JMPZ                                                     $0, ->8
  175     3    >   INIT_METHOD_CALL                                         'createDatabaseConnection'
          4        DO_FCALL                                      0  $1      
          5      > JMPZ                                                     $1, ->8
  176     6    >   INIT_METHOD_CALL                                         'createNewUser'
          7        DO_FCALL                                      0          
  180     8    > > RETURN                                                   <false>
  181     9*     > RETURN                                                   null

End of function doregistration

Function checkloginformdatanotempty:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 8
filename:       /in/jYppt
function name:  checkLoginFormDataNotEmpty
number of ops:  24
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  189     0  E >   FETCH_IS                                         ~0      '_POST'
          1        ISSET_ISEMPTY_DIM_OBJ                         1  ~1      ~0, 'user_name'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ_EX                                          ~2      ~2, ->8
          4    >   FETCH_IS                                         ~3      '_POST'
          5        ISSET_ISEMPTY_DIM_OBJ                         1  ~4      ~3, 'user_password'
          6        BOOL_NOT                                         ~5      ~4
          7        BOOL                                             ~2      ~5
          8    > > JMPZ                                                     ~2, ->11
  190     9    > > RETURN                                                   <true>
         10*       JMP                                                      ->22
  191    11    >   FETCH_IS                                         ~6      '_POST'
         12        ISSET_ISEMPTY_DIM_OBJ                         1          ~6, 'user_name'
         13      > JMPZ                                                     ~7, ->17
  192    14    >   ASSIGN_OBJ                                               'feedback'
         15        OP_DATA                                                  'Username+field+was+empty.'
         16      > JMP                                                      ->22
  193    17    >   FETCH_IS                                         ~9      '_POST'
         18        ISSET_ISEMPTY_DIM_OBJ                         1          ~9, 'user_password'
         19      > JMPZ                                                     ~10, ->22
  194    20    >   ASSIGN_OBJ                                               'feedback'
         21        OP_DATA                                                  'Password+field+was+empty.'
  197    22    > > RETURN                                                   <false>
  198    23*     > RETURN                                                   null

End of function checkloginformdatanotempty

Function checkpasswordcorrectnessandlogin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 45
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 42
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jYppt
function name:  checkPasswordCorrectnessAndLogin
number of ops:  49
compiled vars:  !0 = $sql, !1 = $query, !2 = $result_row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  207     0  E >   ASSIGN                                                   !0, 'SELECT+user_name%2C+user_email%2C+user_password_hash%0A++++++++++++++++FROM+users%0A++++++++++++++++WHERE+user_name+%3D+%3Auser_name+OR+user_email+%3D+%3Auser_name%0A++++++++++++++++LIMIT+1'
  211     1        FETCH_OBJ_R                                      ~4      'db_connection'
          2        INIT_METHOD_CALL                                         ~4, 'prepare'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
  212     6        INIT_METHOD_CALL                                         !1, 'bindValue'
          7        SEND_VAL_EX                                              '%3Auser_name'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_FUNC_ARG               global              $7      '_POST'
         10        FETCH_DIM_FUNC_ARG                               $8      $7, 'user_name'
         11        SEND_FUNC_ARG                                            $8
         12        DO_FCALL                                      0          
  213    13        INIT_METHOD_CALL                                         !1, 'execute'
         14        DO_FCALL                                      0          
  221    15        INIT_METHOD_CALL                                         !1, 'fetchObject'
         16        DO_FCALL                                      0  $11     
         17        ASSIGN                                                   !2, $11
  222    18      > JMPZ                                                     !2, ->45
  224    19    >   INIT_FCALL                                               'password_verify'
         20        FETCH_R                      global              ~13     '_POST'
         21        FETCH_DIM_R                                      ~14     ~13, 'user_password'
         22        SEND_VAL                                                 ~14
         23        FETCH_OBJ_R                                      ~15     !2, 'user_password_hash'
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26      > JMPZ                                                     $16, ->42
  226    27    >   FETCH_OBJ_R                                      ~19     !2, 'user_name'
         28        FETCH_W                      global              $17     '_SESSION'
         29        ASSIGN_DIM                                               $17, 'user_name'
         30        OP_DATA                                                  ~19
  227    31        FETCH_OBJ_R                                      ~22     !2, 'user_email'
         32        FETCH_W                      global              $20     '_SESSION'
         33        ASSIGN_DIM                                               $20, 'user_email'
         34        OP_DATA                                                  ~22
  228    35        FETCH_W                      global              $23     '_SESSION'
         36        ASSIGN_DIM                                               $23, 'user_is_logged_in'
         37        OP_DATA                                                  <true>
  229    38        ASSIGN_OBJ                                               'user_is_logged_in'
         39        OP_DATA                                                  <true>
  230    40      > RETURN                                                   <true>
         41*       JMP                                                      ->44
  232    42    >   ASSIGN_OBJ                                               'feedback'
         43        OP_DATA                                                  'Wrong+password.'
         44      > JMP                                                      ->47
  235    45    >   ASSIGN_OBJ                                               'feedback'
         46        OP_DATA                                                  'This+user+does+not+exist.'
  238    47    > > RETURN                                                   <false>
  239    48*     > RETURN                                                   null

End of function checkpasswordcorrectnessandlogin

Function checkregistrationdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 47
Branch analysis from position: 40
2 jumps found. (Code = 46) Position 1 = 48, Position 2 = 52
Branch analysis from position: 48
2 jumps found. (Code = 46) Position 1 = 53, Position 2 = 57
Branch analysis from position: 53
2 jumps found. (Code = 46) Position 1 = 58, Position 2 = 64
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 67
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 73
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
2 jumps found. (Code = 47) Position 1 = 76, Position 2 = 79
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 83
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 89, Position 2 = 92
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 92
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 100
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 100
2 jumps found. (Code = 47) Position 1 = 105, Position 2 = 110
Branch analysis from position: 105
2 jumps found. (Code = 43) Position 1 = 111, Position 2 = 114
Branch analysis from position: 111
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 114
2 jumps found. (Code = 43) Position 1 = 122, Position 2 = 125
Branch analysis from position: 122
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 125
2 jumps found. (Code = 43) Position 1 = 128, Position 2 = 131
Branch analysis from position: 128
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 131
2 jumps found. (Code = 43) Position 1 = 136, Position 2 = 139
Branch analysis from position: 136
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 139
2 jumps found. (Code = 43) Position 1 = 147, Position 2 = 150
Branch analysis from position: 147
1 jumps found. (Code = 42) Position 1 = 152
Branch analysis from position: 152
Branch analysis from position: 150
1 jumps found. (Code = 6

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.84 ms | 1428 KiB | 21 Q