Login<?php
class Login
{
protected $id;
public function Login()
{
include_once 'init.php';
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION['email'])) {
$email = isset($_POST['email']) ? $_POST['email'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$email = htmlspecialchars($email);
$password = htmlspecialchars($password);
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$json = $firebase->get(DEFAULT_PATH . "/ARCusers/", array('activation' => '"true"'));
$error = false;
$conn = false;
if (isset($_POST['submit'])) {
if (!empty($email) && !empty($password)) {
//check if it matches
/*$email = '"' . $email . '"';
$password = '"' . $password . '"';*/
$json_ary = json_decode($json, true);
foreach ($json_ary as $this->id => $val) {
if ($email == $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/email") && $password == $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/password")) {
$activation = $firebase->get(DEFAULT_PATH . "ARCusers/$this->id/activation");
if ($activation == 'true') {
$conn = true;
} else {
echo "<br>";
echo "<br>";
echo "Verify your email";
echo "<br>";
}
}
}
if ($conn == true) {
$error = false;
} else {
$error = true;
}
if ($error) {
echo "Error in email or/and password.";
}
if (!$error) {
//login
$_SESSION['email'] = $email;
echo "Logged in.";
header("Location: welcome.php");
}
} else {
echo "Fill in all the details.";
}
}
}
}
}
LicenseKey<?php
include_once "Login.php";
if (!isset($_SESSION)) {
session_start();
}
class LicenseKey extends Login
{
private $getId;
public function LicenseKey()
{
$this->getId = $this->id;
echo $this->getId;
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$license_key = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key");
// $license_key_activation = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key activation ");
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;
}
}
}
}