Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
eac7cdde
Commit
eac7cdde
authored
Jun 16, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
captive portal: address recent paranoia of Sqlite(); fixes #215
parent
1454f5da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
DB.php
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/DB.php
+25
-24
No files found.
src/opnsense/mvc/app/models/OPNsense/CaptivePortal/DB.php
View file @
eac7cdde
...
@@ -126,34 +126,36 @@ class DB
...
@@ -126,34 +126,36 @@ class DB
try
{
try
{
$this
->
handle
=
new
Sqlite
(
array
(
"dbname"
=>
$db_path
));
$this
->
handle
=
new
Sqlite
(
array
(
"dbname"
=>
$db_path
));
$sql
=
array
();
// create structure on new database
// create structure on new database
$sql
=
"CREATE TABLE IF NOT EXISTS captiveportal ("
.
# table used for authenticated users
$sql
[]
=
"CREATE TABLE IF NOT EXISTS captiveportal ("
.
# table used for authenticated users
"allow_time INTEGER, pipeno_in INTEGER, pipeno_out INTEGER, ip TEXT, mac TEXT, username TEXT, "
.
"allow_time INTEGER, pipeno_in INTEGER, pipeno_out INTEGER, ip TEXT, mac TEXT, username TEXT, "
.
"sessionid TEXT, bpassword TEXT, session_timeout INTEGER, idle_timeout INTEGER, "
.
"sessionid TEXT, bpassword TEXT, session_timeout INTEGER, idle_timeout INTEGER, "
.
"session_terminate_time INTEGER, interim_interval INTEGER, radiusctx TEXT); "
.
"session_terminate_time INTEGER, interim_interval INTEGER, radiusctx TEXT)"
;
"CREATE UNIQUE INDEX IF NOT EXISTS idx_active ON captiveportal (sessionid, username); "
.
$sql
[]
=
"CREATE UNIQUE INDEX IF NOT EXISTS idx_active ON captiveportal (sessionid, username)"
;
"CREATE INDEX IF NOT EXISTS user ON captiveportal (username); "
.
$sql
[]
=
"CREATE INDEX IF NOT EXISTS user ON captiveportal (username)"
;
"CREATE INDEX IF NOT EXISTS ip ON captiveportal (ip); "
.
$sql
[]
=
"CREATE INDEX IF NOT EXISTS ip ON captiveportal (ip)"
;
"CREATE INDEX IF NOT EXISTS starttime ON captiveportal (allow_time);"
.
$sql
[]
=
"CREATE INDEX IF NOT EXISTS starttime ON captiveportal (allow_time)"
;
"CREATE TABLE IF NOT EXISTS captiveportal_mac ("
.
# table used for static mac's
$sql
[]
=
"CREATE TABLE IF NOT EXISTS captiveportal_mac ("
.
# table used for static mac's
"mac TEXT, ip TEXT,pipeno_in INTEGER, pipeno_out INTEGER, last_checked INTEGER );"
.
"mac TEXT, ip TEXT,pipeno_in INTEGER, pipeno_out INTEGER, last_checked INTEGER )"
;
"CREATE UNIQUE INDEX IF NOT EXISTS idx_mac ON captiveportal_mac (mac) ;"
.
$sql
[]
=
"CREATE UNIQUE INDEX IF NOT EXISTS idx_mac ON captiveportal_mac (mac)"
;
"CREATE TABLE IF NOT EXISTS captiveportal_ip ("
.
# table used for static ip's
$sql
[]
=
"CREATE TABLE IF NOT EXISTS captiveportal_ip ("
.
# table used for static ip's
"ip TEXT,pipeno_in INTEGER, pipeno_out INTEGER, last_checked INTEGER );"
.
"ip TEXT,pipeno_in INTEGER, pipeno_out INTEGER, last_checked INTEGER )"
;
"CREATE UNIQUE INDEX IF NOT EXISTS idx_ip ON captiveportal_ip (ip) "
;
$sql
[]
=
"CREATE UNIQUE INDEX IF NOT EXISTS idx_ip ON captiveportal_ip (ip)"
;
if
(
!
$this
->
handle
->
execute
(
$sql
))
{
foreach
(
$sql
as
$cmd
)
{
$logger
=
new
Syslog
(
"logportalauth"
,
array
(
if
(
!
$this
->
handle
->
execute
(
$cmd
))
{
'option'
=>
LOG_PID
,
$logger
=
new
Syslog
(
"logportalauth"
,
array
(
'facility'
=>
LOG_LOCAL4
'option'
=>
LOG_PID
,
));
'facility'
=>
LOG_LOCAL4
$msg
=
"Error during table
{
$this
->
zone
}
creation. Error message:
{
$this
->
handle
->
lastErrorMsg
()
}
"
;
));
$logger
->
error
(
$msg
);
$msg
=
"Error during table
{
$this
->
zone
}
creation. Error message:
{
$this
->
handle
->
lastErrorMsg
()
}
"
;
$this
->
handle
=
null
;
$logger
->
error
(
$msg
);
$this
->
handle
=
null
;
break
;
}
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$logger
=
new
Syslog
(
"logportalauth"
,
array
(
$logger
=
new
Syslog
(
"logportalauth"
,
array
(
'option'
=>
LOG_PID
,
'option'
=>
LOG_PID
,
...
@@ -164,7 +166,6 @@ class DB
...
@@ -164,7 +166,6 @@ class DB
}
}
return
$this
->
handle
;
return
$this
->
handle
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment