Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelepaiano authored Jan 31, 2018
1 parent 927ff86 commit ac09c48
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 68 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ I'm coding a jquery-mobile backend for administrate database.
#### WARNING: Some countries' laws, require a logging data for guests activities from wifi hotspots. This tool does not collect any data or logs, so use it at your risk. If required in your country, install a logging system by yourself. I'm not responsible for law violations!

### FEATURES
- Mac address authentication for free limited-time wifi access;
- Mac address/email authentication for free limited-time wifi access;
- Registered users authentication (support limited time login from single mac address);
- Remaining time counter for users (you can show them fake values, hiding minutes from
remaining time);
- Blocking expired session's mac-address for minutes (or hours / days);
- Multilanguage and language browser detection (italian/english);
- Single customizable frontend theme.
- Mail login supports for guests, with logging useful for signing up to newsletters - NEW
- Disabling registered users login (set hotspot for guests only) - NEW
- Permanent login support - NEW

***

Expand All @@ -32,7 +35,7 @@ I'm coding a jquery-mobile backend for administrate database.

### INSTALL

1) Prepare your system installing the unifi controller, a web server (Nginx/Apache) with PHP/PDO and a DBMS (Mysql or Sqlite3);
1) Prepare your system installing the unifi controller, a web server (Nginx/Apache) with PHP/PDO CURL and a DBMS (Mysql or Sqlite3);

2) Put guest/ directory into webserver root (like /var/www/html) and change permissions to access www-data webserver user;

Expand All @@ -42,11 +45,15 @@ I'm coding a jquery-mobile backend for administrate database.

6) If you use mysql, import hotspot.sql file into database (you can use PhpMyAdmin). If you prefer sqlite, set $GLOBALS['dbms']='sqlite' and $GLOBALS['sqliteFile'] to hotspot.sqlite file. For backend you can use sqliteweb (https://github.com/coleifer/sqlite-web).

7) Read DATABASE.TXT for tables description (writing in progress)
7) Log in in Unifi Controller and set External Hotspot (from Guest Policies) to redirect to custom captive ip address.

8) Log in in Unifi Controller and set External Hotspot (from Guest Policies) to redirect to custom captive ip address.
8) All access will be logged into access_logs database table (set $GLOBALS['logAccessEnabled']) to false for disabling logging)

9) Enjoy
9) Set $GLOBALS['GuestMailAccess'] to true to enable guest authentication by email address (useful for signing up to newsletter)

10) Set $GLOBALS['showHomeRegistered'] to false to hide disable registered accounts (guest only)

11) Enjoy

***

Expand Down
6 changes: 6 additions & 0 deletions guest/s/default/authorized.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@

/* Filtering user and password for SQL Injection attacks */

if ($_POST["email"]!="")
$_SESSION["email"]=escape_sql($_POST["email"]);
else
$_SESSION["email"]=" ";


if ($_POST["user"]!="")
$_SESSION["user"]=escape_sql($_POST["user"]);
else
Expand Down
24 changes: 20 additions & 4 deletions guest/s/default/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
*/

// error_reporting(E_ALL);
// ini_set('display_errors', '1');
//error_reporting(E_ALL);
//ini_set('display_errors', '1');



Expand Down Expand Up @@ -65,6 +65,19 @@
$GLOBALS['errorRedirect']=15;


/* If true, guest user, must insert mail to starting surf */
$GLOBALS['GuestMailAccess']=false;


/* If true, show "Do you have an account?" on home */
$GLOBALS['showHomeRegistered']=true;


/* If true, all sessions will be logged into database table
specified by $GLOBALS['LogSessionsTable'] */
$GLOBALS['logAccessEnabled']=true;


/* If true the portal will disconnect an expired guest from wifi after expired page loaded */
$GLOBAL['kickass']=true;

Expand Down Expand Up @@ -102,7 +115,7 @@
$GLOBALS['mysqlServer']= "localhost";

/* Mysql User */
$GLOBALS['mysqlUser']="user";
$GLOBALS['mysqlUser']="mysql";

/* Mysql Pass */
$GLOBALS['mysqlPass']="password";
Expand All @@ -111,8 +124,11 @@
/* Mysql Database Name */
$GLOBALS['mysqlName']="hotspot";

/* Mysql Database Name */
/* Mysql Session Table Name */
$GLOBALS['mysqlSessionTable']="sessions";

/* Mysql Log Session Table Name */
$GLOBALS['LogSessionsTable']="access_logs";

/* Mysql port */
$GLOBALS['mysqlServerPort']=3306;
Expand Down
38 changes: 35 additions & 3 deletions guest/s/default/core.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,12 @@ function registerClient()

$newId=$GLOBALS["database"]->max("sessions", "id")+1;

echo $newId;
$userMail=$_SESSION['email'];

//echo $newId;

$sql="INSERT INTO " . $GLOBALS['mysqlSessionTable'] . " (id, device, ip, ap, lastlog, expire, remove, browser, os, user_id)
VALUES ($newId, '$id', '$ip', '$ap', '$datetime', '$to_time', '$unlock', '$userBrowser', '$userOS', '" . getUserVal($_SESSION["user"], "id") ."')";
//$sql="INSERT INTO " . $GLOBALS['mysqlSessionTable'] . " (id, device, ip, ap, lastlog, expire, remove, browser, os, user_id)
//VALUES ($newId, '$id', '$ip', '$ap', '$datetime', '$to_time', '$unlock', '$userBrowser', '$userOS', '" . getUserVal($_SESSION["user"], "id") ."')";

$GLOBALS["database"]->insert($GLOBALS['mysqlSessionTable'], [

Expand All @@ -570,6 +572,36 @@ function registerClient()

]);


if ($GLOBALS['logAccessEnabled']){
$GLOBALS["database"]->insert($GLOBALS['LogSessionsTable'], [

"id"=>$newId,

"device"=>$id,

"ip"=>$ip,

"ap"=>$ap,

"lastlog"=>$datetime,

"expire"=>$to_time,

"remove"=>$unlock,

"browser"=>$userBrowser,

"os"=>$userOS,

"email"=>$userMail,

"user_id"=>getUserVal($_SESSION["user"], "id")

]);
}


}


Expand Down
Loading

0 comments on commit ac09c48

Please sign in to comment.