";
read_terms();
flush();
write_log();
}
function write_log() {
# In this example we have decided to log all clients who are granted access
# Note: the web server daemon must have read and write permissions to the folder defined in $logpath
# By default $logpath is null so the logfile will be written to the folder this script resides in,
# or the /tmp directory if on the NDS router
if (file_exists("/etc/config/opennds")) {
$logpath="/tmp/";
} elseif (file_exists("/etc/opennds/opennds.conf")) {
$logpath="/run/";
} else {
$logpath="";
}
if (!file_exists("$logpath"."ndslog")) {
mkdir("$logpath"."ndslog", 0700);
}
$me=$_SERVER['SCRIPT_NAME'];
$script=basename($me, '.php');
$host=$_SERVER['HTTP_HOST'];
$user_agent=$_SERVER['HTTP_USER_AGENT'];
$clientip=$GLOBALS["clientip"];
$clientmac=$GLOBALS["clientmac"];
$client_type=$GLOBALS["client_type"];
$gatewayname=$GLOBALS["gatewayname"];
$gatewayaddress=$GLOBALS["gatewayaddress"];
$gatewaymac=$GLOBALS["gatewaymac"];
$clientif=$GLOBALS["clientif"];
$originurl=$GLOBALS["originurl"];
$redir=rawurldecode($originurl);
$fullname=$_GET["fullname"];
$email=$_GET["email"];
$password=$_GET["password"];
$log=date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']).
", $script, $gatewayname, $fullname, $email,$password, $clientip, $clientmac, $client_type, $clientif, $user_agent, $redir\n";
if ($logpath == "") {
$logfile="ndslog/ndslog_log.php";
if (!file_exists($logfile)) {
@file_put_contents($logfile, "\n");
}
} else {
$logfile="$logpath"."ndslog/ndslog.log";
}
@file_put_contents($logfile, $log, FILE_APPEND );
}
function checkRouterExistence($gatewayMAC)
{
$user = "povosdafloresta";
$password = "@Povosd4Floresta@";
$database = "povosfloresta";
$hostname = "vpn.povosdafloresta.solved.eco.br";
$conn = new mysqli($hostname, $user, $password,$database) or die( ' Erro na conexão ' );
$query = "SELECT id,throughput FROM antennas WHERE mac_address = '$gatewayMAC'";
$resultado = $conn->query($query);
if ($resultado->num_rows > 0) {
$row = $resultado->fetch_row();
$GLOBALS['throughput'] = $row[1];
return true;
} else {
die('Gateway MAC address not found: '. $gatewayMAC);
return false;
}
}
function validationUser($username,$pass,$gatewayMAC)
{
//var_dump($pass); die();
# Substitua abaixo os dados, de acordo com o banco criado
$user = "povosdafloresta";
$password = "@Povosd4Floresta@";
$database = "povosfloresta";
# O hostname deve ser sempre localhost
$hostname = "vpn.povosdafloresta.solved.eco.br";
# Conecta com o servidor de banco de dados
$conn = new mysqli($hostname, $user, $password,$database) or die( ' Erro na conexão ' );
//mysqli_select_db($mysql, ) or die( 'Erro na seleção do banco' );
$query = "SELECT users.id,profiles.id,profiles.name,profiles.preference_level,communities.id,communities.name,antennas.enable,antennas.mac_address FROM users_platform users INNER JOIN users_has_profile_has_community ON
users.ID = users_has_profile_has_community.users_id
INNER JOIN profiles ON profiles.ID = users_has_profile_has_community.profile_id
INNER JOIN communities ON communities.ID = profiles.community_id
INNER JOIN antennas ON antennas.communities_id = communities.ID
WHERE email = '$username' and password = '$pass' and users_has_profile_has_community.enable = 1 and antennas.mac_address = '$gatewayMAC';";
//die($query);
$resultado = $conn->query($query);
//$resultado = mysqli_execute_query($conn, $query);
//die($resultado->num_rows);
if ($resultado->num_rows > 0) {
$row = $resultado->fetch_row();
if($row[3] == 1){
$GLOBALS['downloadSpeed'] = 2000000000;
} else {
$GLOBALS['downloadSpeed'] = intval($GLOBALS['throughput'] / $row[3])+1000;
}
return true;
} else {
return false;
}
}
function login_page() {
$fullname=$password=$email="";
$me=$_SERVER['SCRIPT_NAME'];
$fas=$_GET["fas"];
$clientip=$GLOBALS["clientip"];
$clientmac=$GLOBALS["clientmac"];
$gatewayname=$GLOBALS["gatewayname"];
$gatewayaddress=$GLOBALS["gatewayaddress"];
$gatewaymac=$GLOBALS["gatewaymac"];
$clientif=$GLOBALS["clientif"];
$client_zone=$GLOBALS["client_zone"];
$originurl=$GLOBALS["originurl"];
if (isset($_GET["fullname"])) {
$fullname=ucwords($_GET["fullname"]);
}
if (isset($_GET["password"])) {
$password=$_GET["password"];
}
if (isset($_GET["email"])) {
$email=$_GET["email"];
}
checkRouterExistence($gatewaymac);
$validation = validationUser($email,$password,$gatewaymac);
if ($fullname == "" or $email == "" or (!$validation)) {
// echo "
//
Bem Vindo!
// Ponto de Acesso $client_zone
// Entre com seu Usuario e Senha
// ";
echo "
Bem Vindo!
";
if (! isset($_GET['fas'])) {
echo " ERROR! Incomplete data passed from NDS\n";
} else {
if ($fullname != "" and !$validation) {
echo " Por favor, confira Usuario e Senha\n";
}
echo "
";
read_terms();
flush();
}
} else {
thankyou_page();
}
}
function status_page() {
$me=$_SERVER['SCRIPT_NAME'];
var_dump($me);
$clientip=$GLOBALS["clientip"];
$clientmac=$GLOBALS["clientmac"];
$gatewayname=$GLOBALS["gatewayname"];
$gatewayaddress=$GLOBALS["gatewayaddress"];
$gatewaymac=$GLOBALS["gatewaymac"];
$clientif=$GLOBALS["clientif"];
$client_zone=$GLOBALS["client_zone"];
$originurl=$GLOBALS["originurl"];
$redir=rawurldecode($originurl);
// Is the client already logged in?
if ($_GET["status"] == "authenticated") {
echo "
You are connected to $client_zone
You are already logged in and have access to the Internet.
You can use your Browser, Email and other network Apps as you normally would.
";
read_terms();
echo "
Your device originally requested $redir
Click or tap Continue to go to there.
";
} else {
echo "
ERROR 404 - Page Not Found.
The requested resource could not be found.
";
}
flush();
}
function landing_page() {
$me=$_SERVER['SCRIPT_NAME'];
//var_dump($me);
$fas=$_GET["fas"];
$originurl=$GLOBALS["originurl"];
$gatewayaddress=$GLOBALS["gatewayaddress"];
$gatewayname=$GLOBALS["gatewayname"];
$gatewayurl=$GLOBALS["gatewayurl"];
$clientif=$GLOBALS["clientif"];
$client_zone=$GLOBALS["client_zone"];
$redir=rawurldecode($originurl);
echo "
You are connected to $client_zone
You are now logged in and have been granted access to the Internet.
You can use your Browser, Email and other network Apps as you normally would.
(Your device originally requested $redir)
Click or tap Continue to show the status of your account.
";
read_terms();
flush();
}
function splash_header() {
$gatewayname=$GLOBALS["gatewayname"];
$imagepath=$GLOBALS["imagepath"];
$gatewayname=htmlentities(rawurldecode($gatewayname), ENT_HTML5, "UTF-8", FALSE);
// Add headers to stop browsers from cacheing
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
// Output the common header html
echo "\n\n
$gatewayname
";
exit(0);
}
function read_terms() {
#terms of service button
$me=$_SERVER['SCRIPT_NAME'];
$fas=$GLOBALS["fas"];
// echo "
//
// ";
}
function display_terms () {
# This is the all important "Terms of service"
# Edit this long winded generic version to suit your requirements.
####
# WARNING #
# It is your responsibility to ensure these "Terms of Service" are compliant with the REGULATIONS and LAWS of your Country or State.
# In most locations, a Privacy Statement is an essential part of the Terms of Service.
####
#Privacy
echo "
Privacy.
Ao fazer login no sistema, você concede sua permissão para que este sistema armazene quaisquer dados que você fornecer
as finalidades de login, juntamente com os parâmetros de rede do seu dispositivo que o sistema requer para funcionar.
Todas as informações são armazenadas para sua conveniência e para sua proteção e a nossa.
Todas as informações coletadas por este sistema são armazenadas de forma segura e não são acessíveis a terceiros.
Em troca, concedemos a você acesso GRATUITO à Internet.
";
# Terms of Service
echo "
Termos de Serviço para este Hotspot. O acesso é concedido com base na confiança de que você NÃO usará ou abusará desse acesso de forma alguma.Role para baixo para ler os Termos de Serviço na íntegra ou clique no botão Continuar para retornar à Página de Aceitação
";
# Proper Use
echo "
Uso adequado
Este Hotspot fornece uma rede sem fio que permite conectar-se à Internet. O uso desta conexão com a Internet é fornecido em troca de sua aceitação TOTAL destes Termos de Serviço.
Voce Concorda that you are responsible for providing security measures that are suited for your intended use of the Service.
For example, you shall take full responsibility for taking adequate measures to safeguard your data from loss.
While the Hotspot uses commercially reasonable efforts to provide a secure service,
the effectiveness of those efforts cannot be guaranteed.
You may use the technology provided to you by this Hotspot for the sole purpose
of using the Service as described here.
You must immediately notify the Owner of any unauthorized use of the Service or any other security breach.
We will give you an IP address each time you access the Hotspot, and it may change.
You shall not program any other IP or MAC address into your device that accesses the Hotspot.
You may not use the Service for any other reason, including reselling any aspect of the Service.
Other examples of improper activities include, without limitation:
downloading or uploading such large volumes of data that the performance of the Service becomes
noticeably degraded for other users for a significant period;
attempting to break security, access, tamper with or use any unauthorized areas of the Service;
removing any copyright, trademark or other proprietary rights notices contained in or on the Service;
attempting to collect or maintain any information about other users of the Service
(including usernames and/or email addresses) or other third parties for unauthorized purposes;
logging onto the Service under false or fraudulent pretenses;
creating or transmitting unwanted electronic communications such as SPAM or chain letters to other users
or otherwise interfering with other user's enjoyment of the service;
transmitting any viruses, worms, defects, Trojan Horses or other items of a destructive nature; or
using the Service for any unlawful, harassing, abusive, criminal or fraudulent purpose.
";
# Content Disclaimer
echo "
Content Disclaimer
The Hotspot Owners do not control and are not responsible for data, content, services, or products
that are accessed or downloaded through the Service.
The Owners may, but are not obliged to, block data transmissions to protect the Owner and the Public.
The Owners, their suppliers and their lic ensors expressly disclaim to the fullest extent permitted by law,
all express, implied, and statutary warranties, including, without limitation, the warranties of merchantability
or fitness for a particular purpose.
The Owners, their suppliers and their licensors expressly disclaim to the fullest extent permitted by law
any liability for infringement of proprietory rights and/or infringement of Copyright by any user of the system.
Login details and device identities may be stored and be used as evidence in a Court of Law against such users.
";
# Limitation of Liability
echo "
Limitation of Liability
Under no circumstances shall the Owners, their suppliers or their licensors be liable to any user or
any third party on account of that party's use or misuse of or reliance on the Service.
Changes to Terms of Service and Termination
We may modify or terminate the Service and these Terms of Service and any accompanying policies,
for any reason, and without notice, including the right to terminate with or without notice,
without liability to you, any user or any third party. Please review these Terms of Service
from time to time so that you will be apprised of any changes.
We reserve the right to terminate your use of the Service, for any reason, and without notice.
Upon any such termination, any and all rights granted to you by this Hotspot Owner shall terminate.
";
# Inemnity
echo "
Indemnity
You agree to hold harmless and indemnify the Owners of this Hotspot,
their suppliers and licensors from and against any third party claim arising from
or in any way related to your use of the Service, including any liability or expense arising from all claims,
losses, damages (actual and consequential), suits, judgments, litigation costs and legal fees, of every kind and nature.