<?php
date_default_timezone_set('America/Chicago');

$db = new SQLite3('./.user.db');
$ret = $db->query("SELECT * 
				FROM users 
				WHERE user='".@$_GET['username']."'");
while($row = $ret->fetchArray() ){
	$id=$row['id'];
	$username=$row['user'];
	$password=$row['pass'];
	$expired = $row['expire'];
}

$expiredT = (time() > strtotime(@$expired));
if ($expiredT) {$expired = 0;}else{$expired = 1;}

/* Dont change anything else below*/
if (!empty($_SERVER['HTTP'])) {$proto = 'http';}else{$proto = 'http';}

//Call file
if (@$_GET['action'] == 'geturlarr') {
	$current = "$proto://".$_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], "/"));
	echo "{\"status\":true,\"message\":[\"{$current}\"]}";
}

//Call API_KEY
if (@$_REQUEST['action'] == 'getpremiumize') {
	$res = $db->query('SELECT * FROM key'); 
	$rows = array();
	$row = $res->fetchArray(SQLITE3_ASSOC);
	echo "{\"token\": \"{$row['api']}\"}";
}

//Call User
if (@$_GET['username']) {
	
	if ($_GET['username'] == $username && $_GET['password'] == $password && $expired == 1) {
		echo '{"user_info":{"username":"'.$username.'","password":"'.$password.'.","auth":1,"status":"Active","exp_date":"1674254085","is_trial":"0","active_cons":"1","created_at":"1591763513",
"max_connections":"3"},"server_info":{"url":"","port":"","https_port":""}}';

	}else{
		echo '{"user_info":{"null"}';
	}
}
?>