<?php
class Login
{
protected $id;
function Login()
{
require 'init.php';
session_start();
if (!isset($_SESSION['email'])) {
$email = isset($_POST['email']) ? $_POST['email'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$password = htmlspecialchars($password);
$email = '"' . $email . '"';
$password = '"' . $password . '"';
$error = false;
if (isset($_POST['submit'])) {
if (!empty($email) && !empty($password)) {
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$json = $firebase->get(DEFAULT_PATH . "/ARCusers/");
$json_ary = json_decode($json, true);
foreach ($json_ary as $this->id => $val) {
$getEmail = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/email");
$getPassword = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/password");
$activation = $firebase->get(DEFAULT_PATH . "ARCusers/$this->id/activation");
if ($email == $getEmail && $password == $getPassword) {
$error = false;
} else {
$error = true;
}
if ($error) {
echo "Error in email or/and password.";
}
if (!$error) {
//login
if ($activation == 'true') {
$_SESSION['email'] = $email;
echo "Logged in.";
header("Location: LicenseKey.php?);
} else {
echo "verify your email";
}
}
}
} else {
echo "Fill in all the details.";
}
}
}
}
}
$Login = new Login();
?>
<b><?php
if (isset($_SESSION['email'])) {
// echo 'You are already logged in.';
} else {
echo 'Log in:';
?></b>
<br>
<br>
<form action="login.php" method="post">
Email address:
<br>
<input type="text" name="email" maxlength="128">
<br>
<br>
Password:
<br>
<input type="password" name="password" maxlength="128">
<br>
<br>
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>
<?php
include "Login.php";
class LicenseKey extends Login
{
private $getId;
function LicenseKey()
{
$this->getId = $this->id;
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$license_key = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key");
if (isset($_GET['LicenseKey'])) {
if ($license_key == '"' . $_GET['addlicensekey'] . '"') {
$firebase->set(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key activation", true);
} else {
echo "false";
echo $this->getId;
}
}
}
}
$licensekey = new LicenseKey();
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Firebase</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<form class="pure-form" method="get">
<h2>License key</h2>
<input name="addlicensekey" placeholder="put your license key" type="text">
<br><br><br>
<button type="submit" onclick="" name="LicenseKey" class="pure-button pure-button-primary">
Submit
</button>
<br>
<hr>
<br>
</form>
</body>
</html>