3v4l.org

run code in 300+ PHP versions simultaneously
<?php include_once"ui/connectdb.php"; session_start(); // License check function $licenseKey = "1fde8ca4875c8f65b47a3ad8c54f8c372e4125fcd4398ce6065a48161af5ef3f"; // Replace with your actual license key $systemIdentifier = gethostname(); // Or use another method to get a unique system identifier $expirationDate = "2026-03-21"; // Set your expiration date $currentDate = time(); $expirationTimestamp = strtotime($expirationDate); $remainingDays = ceil(($expirationTimestamp - $currentDate) / (60 * 60 * 24)); // Display Remaining Days echo "<p>Days remaining for license expiration: $remainingDays</p>"; // Call the license check at the beginning of the script $select = $pdo->prepare("SELECT * FROM tbl_user LIMIT 1"); $select->execute(); $row = $select->fetch(PDO::FETCH_ASSOC); if (!$row) { // No user found, display a message and redirect to registration page $_SESSION['status'] = "No user found for this app,Register an account as Admin to continue."; $_SESSION['status_code'] = "warning"; header("Location: ui/registration.php"); exit(); } if(isset($_POST["btn_login"])) { $useremail = $_POST["txt_email"]; $password= $_POST["txt_password"]; $select = $pdo->prepare("select * from tbl_user where useremail='$useremail' and userpassword='$password'"); $select->execute(); $row = $select->fetch(PDO::FETCH_ASSOC); if(is_array($row)){ if ($licenseKey !== hash('sha256', $systemIdentifier)) { if ($licenseKey !== hash('sha256', $systemIdentifier)) { // License key is invalid $_SESSION['status'] = "License key is invalid for this system."; $_SESSION['status_code'] = "error"; } // Check if the current date is before the expiration date if (strtotime($expirationDate) < time()) { // License is expired $_SESSION['status'] = "License has expired. Please renew or contact support."; $_SESSION['status_code'] = "error"; } } elseif($row['useremail']==$useremail AND $row['userpassword']==$password and $row['role']=="Admin"){ $_SESSION['status']="login successfull By Admin"; $_SESSION['status_code']="success"; header('refresh: 1; ui/dashboard.php'); $_SESSION['userid']=$row['userid']; $_SESSION['username'] = $row['username']; $_SESSION['useremail'] = $row['useremail']; $_SESSION['role'] = $row['role']; } elseif($row['useremail']==$useremail AND $row['userpassword']==$password and $row['role']=="User"){ $_SESSION['status']="login successfull By User"; $_SESSION['status_code']="success"; header('refresh: 1; ui/user.php'); $_SESSION['userid']=$row['userid']; $_SESSION['username'] = $row['username']; $_SESSION['useremail'] = $row['useremail']; $_SESSION['role'] = $row['role']; } }else{ $_SESSION['status']="Wrong Email or password"; $_SESSION['status_code']="error"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>STORE | Log in</title> <!-- Google Font: Source Sans Pro --> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback"> <!-- Font Awesome --> <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css"> <!-- icheck bootstrap --> <!-- <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css"> --> <!-- Theme style --> <!-- SweetAlert2 --> <link rel="stylesheet" href="plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css"> <!-- Toastr --> <link rel="stylesheet" href="plugins/toastr/toastr.min.css"> <link rel="stylesheet" href="dist/css/adminlte.min.css"> </head> <body class="hold-transition login-page"> <div class="login-box"> <!-- /.login-logo --> <div class="card card-outline card-primary"> <div class="card-header text-center"> <a href="index.php" class="h1"><b>STORE</b> <br></a> <h2>T.M OKI VENTURE</h2> </div> <div class="card-body"> <p class="login-box-msg">Sign in to start your session</p> <form action="" method="post"> <div class="input-group mb-3"> <input type="email" class="form-control" placeholder="Email" name="txt_email" required> <div class="input-group-append"> <div class="input-group-text"> <span class="fas fa-envelope"></span> </div> </div> </div> <div class="input-group mb-3"> <input type="password" class="form-control" placeholder="Password" name="txt_password" required> <div class="input-group-append"> <div class="input-group-text"> <span class="fas fa-lock"></span> </div> </div> </div> <div class="row"> <div class="col-8"> <div class="icheck-primary"> <!-- <a href="ui/changepassword.php">Forgot Password</a> --> </div> </div> <!-- /.col --> <div class="col-4"> <button type="submit" class="btn btn-primary btn-block" name="btn_login" >Log In</button> </div> <!-- /.col --> </div> </form> <!-- /.social-auth-links --> <p class="mb-1"> </p> <p class="mb-0"> </p> </div> <!-- /.card-body --> </div> <!-- /.card --> </div> <!-- /.login-box --> </body> </html> <!-- jQuery --> <script src="plugins/jquery/jquery.min.js"></script> <!-- Bootstrap 4 --> <script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- SweetAlert2 --> <script src="plugins/sweetalert2/sweetalert2.min.js"></script> <!-- Toastr --> <script src="plugins/toastr/toastr.min.js"></script> <!-- AdminLTE App --> <script src="dist/js/adminlte.min.js"></script> <?php if(isset($_SESSION['status']) && $_SESSION['status']!='') { ?> <script> $(function() { var Toast = Swal.mixin({ toast: true, position: 'top', showConfirmButton: false, timer: 5000 }); Toast.fire({ icon: '<?php echo $_SESSION['status_code'];?>', title: '<?php echo $_SESSION['status'];?>' }) }); </script> <?php unset($_SESSION['status']); } ?>
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.21, 8.4.1 - 8.4.7
Warning: include_once(): open_basedir restriction in effect. File(ui/connectdb.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/WNrcF on line 2 Warning: include_once(ui/connectdb.php): Failed to open stream: Operation not permitted in /in/WNrcF on line 2 Warning: include_once(): Failed opening 'ui/connectdb.php' for inclusion (include_path='.:') in /in/WNrcF on line 2 Warning: session_start(): Session cannot be started after headers have already been sent in /in/WNrcF on line 3 <p>Days remaining for license expiration: 315</p> Warning: Undefined variable $pdo in /in/WNrcF on line 25 Fatal error: Uncaught Error: Call to a member function prepare() on null in /in/WNrcF:25 Stack trace: #0 {main} thrown in /in/WNrcF on line 25
Process exited with code 255.

preferences:
44.96 ms | 407 KiB | 5 Q