<?php
require_once("restricted/mysql.php");
require_once("helper.php");
$mysql = new mysqli($mysql_server,$mysql_user,$mysql_pass,$mysql_db);
if(!mysqli_query($mysql,"DELETE FROM addUser WHERE datetime < DATE_SUB(NOW(), INTERVAL 1 MINUTE);")){
    echo mysqli_error($mysql);
}
if(isLocal()){
    $accessKey = strval(random_int(0,99999999));
    if(!mysqli_query($mysql,"INSERT INTO addUser SET accesskey=".$accessKey.", datetime=NOW();")){
        echo mysqli_error($mysql);
    }
    header('Location: https://nas.el-wa.org/smart?addUser='.$accessKey);
    echo 'https://nas.el-wa.org/smart?addUser='.$accessKey;
}
?>