3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Session starten session_start(); // Variablen deklarieren $_SESSION['angemeldet'] = false; $benutzername = ''; $passwort = ''; $fehlermeldung = ''; // Funktion zum verbinden zur Datenbank function db_connect() { // Zugangsdaten für die DB $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'testlogin'; // Verbindung herstellen und Verbindungskennung zurückgeben $conid = mysql_connect( $dbhost, $dbuser, $dbpass ) or die( 'Verbindungsfehler!' ); if (is_resource( $conid )) { mysql_select_db( $dbname, $conid ) or die( 'Datenbankfehler!' ); } return $conid; } // Prüfen ob ein Cookie existiert und zu einem gültigen User gehört if (isset( $_COOKIE['UserLogin'] )) { // Wert aus dem Cookie mit dem Wert in der Datenbank vergleichen $conid = db_connect(); $sql = "SELECT `id` FROM `login_fortgeschritten` WHERE `cookie_hash` = '" .mysql_real_escape_string( $_COOKIE['UserLogin'] ). "' AND `aktiviert` = 1"; $ergebnis = mysql_query( $sql, $conid ); // Stimmt der Cookie Hash überein, wurde 1 Datensatz gefunden if (mysql_num_rows($ergebnis) == 1) { // Wenn der Hash aus dem Cookie mit dem aus der DB übereinstimmt, // Session Variable setzen und auf die geheime Seite weiterleiten $_SESSION['angemeldet'] = true; header( 'location: geheim_fortgeschritten.php' ); exit; } } // Wenn das Formular abgeschickt wurde if (isset( $_POST['login'] )) { // Maskierende Slashes aus POST Array entfernen if (get_magic_quotes_gpc()) { $_POST = array_map( 'stripslashes', $_POST ); } // Benutzereingabe umladen, von Leerzeichen befreien und $benutzername = strtolower( trim( $_POST['benutzer'] ) ); $passwort = md5( trim( $_POST['passwort'] ) ); // Benutzereingabe mit User in der Datenbank vergleichen $conid = db_connect(); $sql = "SELECT `cookie_hash` FROM `login_fortgeschritten` WHERE LOWER(`benutzername`) = '" .mysql_real_escape_string( $benutzername ). "' AND `passwort` = '" .mysql_real_escape_string( $passwort ). "' AND `aktiviert` = 1"; $ergebnis = mysql_query( $sql, $conid ); // Stimmen die Benutzereingaben überein, wurde 1 Datensatz gefunden if (mysql_num_rows($ergebnis) == 1) { // Abfrageergebnis fetchen $usercookie = mysql_fetch_assoc( $ergebnis ); // Wenn die Anmeldung korrekt war Session Variable setzen, // COOKIE an Browser schicken und auf die geheime Seite weiterleiten $_SESSION['angemeldet'] = true; setcookie( 'UserLogin', $usercookie['cookie_hash'], time()+600 ); header( 'location: geheim_fortgeschritten.php' ); exit; } else { $fehlermeldung = '<h3>Die Anmeldung war fehlerhaft!</h3>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>phpBuddy.eu - Login Script</title> </head> <body> <?php // Falls die Fehlermeldung gesetzt ist if ($fehlermeldung) echo $fehlermeldung; ?> <form id="loginform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="benutzer">Benutzer: </label><input type="text" name="benutzer" id="benutzer" value="" /><br /> <label for="passwort">Passwort: </label><input type="password" name="passwort" id="passwort" value="" /><br /> <input type="submit" name="login" id="login" value="Anmelden" /> </form> </body> </html>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 40
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 117
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 95, Position 2 = 116
Branch analysis from position: 95
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 116
2 jumps found. (Code = 43) Position 1 = 119, Position 2 = 120
Branch analysis from position: 119
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 120
Branch analysis from position: 53
Branch analysis from position: 117
Branch analysis from position: 40
filename:       /in/VtkK3
function name:  (null)
number of ops:  126
compiled vars:  !0 = $benutzername, !1 = $passwort, !2 = $fehlermeldung, !3 = $conid, !4 = $sql, !5 = $ergebnis, !6 = $usercookie
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                                 
    7     2        FETCH_W                      global              $8      '_SESSION'
          3        ASSIGN_DIM                                               $8, 'angemeldet'
          4        OP_DATA                                                  <false>
    8     5        ASSIGN                                                   !0, ''
    9     6        ASSIGN                                                   !1, ''
   10     7        ASSIGN                                                   !2, ''
   31     8        FETCH_IS                                         ~13     '_COOKIE'
          9        ISSET_ISEMPTY_DIM_OBJ                         0          ~13, 'UserLogin'
         10      > JMPZ                                                     ~14, ->40
   34    11    >   INIT_FCALL                                               'db_connect'
         12        DO_FCALL                                      0  $15     
         13        ASSIGN                                                   !3, $15
   40    14        INIT_FCALL_BY_NAME                                       'mysql_real_escape_string'
         15        CHECK_FUNC_ARG                                           
         16        FETCH_FUNC_ARG               global              $17     '_COOKIE'
         17        FETCH_DIM_FUNC_ARG                               $18     $17, 'UserLogin'
         18        SEND_FUNC_ARG                                            $18
         19        DO_FCALL                                      0  $19     
         20        CONCAT                                           ~20     'SELECT%0A++++++++++++++++%60id%60%0A++++++++++++FROM%0A++++++++++++++++%60login_fortgeschritten%60%0A++++++++++++WHERE%0A++++++++++++++++%60cookie_hash%60+%3D+%27', $19
         21        CONCAT                                           ~21     ~20, '%27+AND%0A++++++++++++++++%60aktiviert%60+%3D+1'
   35    22        ASSIGN                                                   !4, ~21
   43    23        INIT_FCALL_BY_NAME                                       'mysql_query'
         24        SEND_VAR_EX                                              !4
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0  $23     
         27        ASSIGN                                                   !5, $23
   46    28        INIT_FCALL_BY_NAME                                       'mysql_num_rows'
         29        SEND_VAR_EX                                              !5
         30        DO_FCALL                                      0  $25     
         31        IS_EQUAL                                                 $25, 1
         32      > JMPZ                                                     ~26, ->40
   50    33    >   FETCH_W                      global              $27     '_SESSION'
         34        ASSIGN_DIM                                               $27, 'angemeldet'
         35        OP_DATA                                                  <true>
   51    36        INIT_FCALL                                               'header'
         37        SEND_VAL                                                 'location%3A+geheim_fortgeschritten.php'
         38        DO_ICALL                                                 
   52    39      > EXIT                                                     
   57    40    >   FETCH_IS                                         ~30     '_POST'
         41        ISSET_ISEMPTY_DIM_OBJ                         0          ~30, 'login'
         42      > JMPZ                                                     ~31, ->117
   60    43    >   INIT_FCALL_BY_NAME                                       'get_magic_quotes_gpc'
         44        DO_FCALL                                      0  $32     
         45      > JMPZ                                                     $32, ->53
   62    46    >   INIT_FCALL                                               'array_map'
         47        SEND_VAL                                                 'stripslashes'
         48        FETCH_R                      global              ~34     '_POST'
         49        SEND_VAL                                                 ~34
         50        DO_ICALL                                         $35     
         51        FETCH_W                      global              $33     '_POST'
         52        ASSIGN                                                   $33, $35
   66    53    >   INIT_FCALL                                               'strtolower'
         54        INIT_FCALL                                               'trim'
         55        FETCH_R                      global              ~37     '_POST'
         56        FETCH_DIM_R                                      ~38     ~37, 'benutzer'
         57        SEND_VAL                                                 ~38
         58        DO_ICALL                                         $39     
         59        SEND_VAR                                                 $39
         60        DO_ICALL                                         $40     
         61        ASSIGN                                                   !0, $40
   67    62        INIT_FCALL                                               'md5'
         63        INIT_FCALL                                               'trim'
         64        FETCH_R                      global              ~42     '_POST'
         65        FETCH_DIM_R                                      ~43     ~42, 'passwort'
         66        SEND_VAL                                                 ~43
         67        DO_ICALL                                         $44     
         68        SEND_VAR                                                 $44
         69        DO_ICALL                                         $45     
         70        ASSIGN                                                   !1, $45
   70    71        INIT_FCALL                                               'db_connect'
         72        DO_FCALL                                      0  $47     
         73        ASSIGN                                                   !3, $47
   76    74        INIT_FCALL_BY_NAME                                       'mysql_real_escape_string'
         75        SEND_VAR_EX                                              !0
         76        DO_FCALL                                      0  $49     
         77        CONCAT                                           ~50     'SELECT%0A++++++++++++++++%60cookie_hash%60%0A++++++++++++FROM%0A++++++++++++++++%60login_fortgeschritten%60%0A++++++++++++WHERE%0A++++++++++++++++LOWER%28%60benutzername%60%29+%3D+%27', $49
         78        CONCAT                                           ~51     ~50, '%27+AND%0A++++++++++++++++%60passwort%60+%3D+%27'
   77    79        INIT_FCALL_BY_NAME                                       'mysql_real_escape_string'
         80        SEND_VAR_EX                                              !1
         81        DO_FCALL                                      0  $52     
         82        CONCAT                                           ~53     ~51, $52
         83        CONCAT                                           ~54     ~53, '%27+AND%0A++++++++++++++++%60aktiviert%60+%3D+1'
   71    84        ASSIGN                                                   !4, ~54
   80    85        INIT_FCALL_BY_NAME                                       'mysql_query'
         86        SEND_VAR_EX                                              !4
         87        SEND_VAR_EX                                              !3
         88        DO_FCALL                                      0  $56     
         89        ASSIGN                                                   !5, $56
   83    90        INIT_FCALL_BY_NAME                                       'mysql_num_rows'
         91        SEND_VAR_EX                                              !5
         92        DO_FCALL                                      0  $58     
         93        IS_EQUAL                                                 $58, 1
         94      > JMPZ                                                     ~59, ->116
   86    95    >   INIT_FCALL_BY_NAME                                       'mysql_fetch_assoc'
         96        SEND_VAR_EX                                              !5
         97        DO_FCALL                                      0  $60     
         98        ASSIGN                                                   !6, $60
   90    99        FETCH_W                      global              $62     '_SESSION'
        100        ASSIGN_DIM                                               $62, 'angemeldet'
        101        OP_DATA                                                  <true>
   91   102        INIT_FCALL                                               'setcookie'
        103        SEND_VAL                                                 'UserLogin'
        104        FETCH_DIM_R                                      ~64     !6, 'cookie_hash'
        105        SEND_VAL                                                 ~64
        106        INIT_FCALL                                               'time'
        107        DO_ICALL                                         $65     
        108        ADD                                              ~66     $65, 600
        109        SEND_VAL                                                 ~66
        110        DO_ICALL                                                 
   92   111        INIT_FCALL                                               'header'
        112        SEND_VAL                                                 'location%3A+geheim_fortgeschritten.php'
        113        DO_ICALL                                                 
   93   114      > EXIT                                                     
        115*       JMP                                                      ->117
   97   116    >   ASSIGN                                                   !2, '%3Ch3%3EDie+Anmeldung+war+fehlerhaft%21%3C%2Fh3%3E'
  102   117    >   ECHO                                                     '%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+XHTML+1.0+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-transitional.dtd%22%3E%0A%3Chtml+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22+xml%3Alang%3D%22de%22+lang%3D%22de%22%3E%0A%3Chead%3E%0A%3Cmeta+http-equiv%3D%22Content-Type%22+content%3D%22text%2Fhtml%3B+charset%3Dutf-8%22+%2F%3E%0A%3Ctitle%3EphpBuddy.eu+-+Login+Script%3C%2Ftitle%3E%0A%3C%2Fhead%3E%0A%0A%3Cbody%3E%0A%0A'
  113   118      > JMPZ                                                     !2, ->120
        119    >   ECHO                                                     !2
  115   120    >   ECHO                                                     '%0A%3Cform+id%3D%22loginform%22+method%3D%22post%22+action%3D%22'
  116   121        FETCH_R                      global              ~70     '_SERVER'
        122        FETCH_DIM_R                                      ~71     ~70, 'PHP_SELF'
        123        ECHO                                                     ~71
        124        ECHO                                                     '%22%3E%0A++++%3Clabel+for%3D%22benutzer%22%3EBenutzer%3A+%3C%2Flabel%3E%3Cinput+type%3D%22text%22+name%3D%22benutzer%22+id%3D%22benutzer%22+value%3D%22%22+%2F%3E%3Cbr+%2F%3E%0A++++%3Clabel+for%3D%22passwort%22%3EPasswort%3A+%3C%2Flabel%3E%3Cinput+type%3D%22password%22+name%3D%22passwort%22+id%3D%22passwort%22+value%3D%22%22+%2F%3E%3Cbr+%2F%3E%0A++++%3Cinput+type%3D%22submit%22+name%3D%22login%22+id%3D%22login%22+value%3D%22Anmelden%22+%2F%3E%0A%3C%2Fform%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
  123   125      > RETURN                                                   1

Function db_connect:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/VtkK3
function name:  db_connect
number of ops:  24
compiled vars:  !0 = $dbhost, !1 = $dbuser, !2 = $dbpass, !3 = $dbname, !4 = $conid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, 'localhost'
   17     1        ASSIGN                                                   !1, 'root'
   18     2        ASSIGN                                                   !2, ''
   19     3        ASSIGN                                                   !3, 'testlogin'
   22     4        INIT_FCALL_BY_NAME                                       'mysql_connect'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAR_EX                                              !1
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                           ~10     !4, $9
         10      > JMPNZ_EX                                         ~10     ~10, ->13
         11    > > EXIT                                                     'Verbindungsfehler%21'
         12*       BOOL                                             ~10     <true>
   23    13    >   TYPE_CHECK                                  512          !4
         14      > JMPZ                                                     ~11, ->22
   25    15    >   INIT_FCALL_BY_NAME                                       'mysql_select_db'
         16        SEND_VAR_EX                                              !3
         17        SEND_VAR_EX                                              !4
         18        DO_FCALL                                      0  $12     
         19      > JMPNZ_EX                                         ~13     $12, ->22
         20    > > EXIT                                                     'Datenbankfehler%21'
         21*       BOOL                                             ~13     <true>
   27    22    > > RETURN                                                   !4
   28    23*     > RETURN                                                   null

End of function db_connect

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
324.4 ms | 1415 KiB | 35 Q