Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
303c0370
Commit
303c0370
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add mysqli support to installer and minor improvements
parent
577e2c46
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/mysqli.php
+14
-7
14 additions, 7 deletions
include/mysqli.php
main.inc.php
+3
-2
3 additions, 2 deletions
main.inc.php
setup/inc/class.installer.php
+8
-8
8 additions, 8 deletions
setup/inc/class.installer.php
setup/setup.inc.php
+6
-1
6 additions, 1 deletion
setup/setup.inc.php
with
31 additions
and
18 deletions
include/mysqli.php
+
14
−
7
View file @
303c0370
...
...
@@ -22,22 +22,24 @@ function db_connect($host, $user, $passwd, $options) {
global
$__db
;
//Assert
if
(
!
strlen
(
$user
)
||
!
strlen
(
$passwd
)
||
!
strlen
(
$host
))
if
(
!
strlen
(
$user
)
||
!
strlen
(
$host
))
return
NULL
;
if
(
!
(
$__db
=
mysqli_init
()))
return
NULL
;
// Setup SSL if enabled
if
(
isset
(
$options
[
'
certs
'
]))
$__db
->
s
et_ssl
(
$options
[
'
certs
'
][
'key'
],
$options
[
'
certs
'
][
'cert'
],
$options
[
'
certs
'
][
'ca'
],
if
(
isset
(
$options
[
'
ssl
'
]))
$__db
->
s
sl_set
(
$options
[
'
ssl
'
][
'key'
],
$options
[
'
ssl
'
][
'cert'
],
$options
[
'
ssl
'
][
'ca'
],
null
,
null
);
elseif
(
!
$passwd
)
return
NULL
;
//Connectr
if
(
!
$__db
->
real_connect
(
$host
,
$user
,
$passwd
))
if
(
!
@
$__db
->
real_connect
(
$host
,
$user
,
$passwd
))
return
NULL
;
//Select the database, if any.
...
...
@@ -214,6 +216,11 @@ function db_input($var, $quote=true) {
return
db_real_escape
(
$var
,
$quote
);
}
function
db_connect_error
()
{
global
$__db
;
return
$__db
->
connect_error
;
}
function
db_error
()
{
global
$__db
;
return
$__db
->
error
;
...
...
This diff is collapsed.
Click to expand it.
main.inc.php
+
3
−
2
View file @
303c0370
...
...
@@ -195,12 +195,13 @@
$ferror
=
null
;
$options
=
array
();
if
(
defined
(
'DBSSLCA'
))
$options
[
'
certs
'
]
=
array
(
$options
[
'
ssl
'
]
=
array
(
'ca'
=>
DBSSLCA
,
'cert'
=>
DBSSLCERT
,
'key'
=>
DBSSLKEY
);
if
(
!
db_connect
(
DBHOST
,
DBUSER
,
DBPASS
,
$options
)
if
(
!
db_connect
(
DBHOST
,
DBUSER
,
DBPASS
,
$options
)
||
!
db_select_database
(
DBNAME
))
{
$ferror
=
'Unable to connect to the database'
;
}
elseif
(
!
(
$ost
=
osTicket
::
start
(
1
))
||
!
(
$cfg
=
$ost
->
getConfig
()))
{
...
...
This diff is collapsed.
Click to expand it.
setup/inc/class.installer.php
+
8
−
8
View file @
303c0370
...
...
@@ -44,7 +44,7 @@ class Installer extends SetupWizard {
function
install
(
$vars
)
{
$this
->
errors
=
$f
=
array
();
$f
[
'name'
]
=
array
(
'type'
=>
'string'
,
'required'
=>
1
,
'error'
=>
'Name required'
);
$f
[
'email'
]
=
array
(
'type'
=>
'email'
,
'required'
=>
1
,
'error'
=>
'Valid email required'
);
$f
[
'fname'
]
=
array
(
'type'
=>
'string'
,
'required'
=>
1
,
'error'
=>
'First name required'
);
...
...
@@ -58,7 +58,7 @@ class Installer extends SetupWizard {
$f
[
'dbname'
]
=
array
(
'type'
=>
'string'
,
'required'
=>
1
,
'error'
=>
'Database name required'
);
$f
[
'dbuser'
]
=
array
(
'type'
=>
'string'
,
'required'
=>
1
,
'error'
=>
'Username required'
);
$f
[
'dbpass'
]
=
array
(
'type'
=>
'string'
,
'required'
=>
1
,
'error'
=>
'password required'
);
if
(
!
Validator
::
process
(
$f
,
$vars
,
$this
->
errors
)
&&
!
$this
->
errors
[
'err'
])
$this
->
errors
[
'err'
]
=
'Missing or invalid data - correct the errors and try again.'
;
...
...
@@ -67,14 +67,14 @@ class Installer extends SetupWizard {
//Staff's email can't be same as system emails.
if
(
$vars
[
'admin_email'
]
&&
$vars
[
'email'
]
&&
!
strcasecmp
(
$vars
[
'admin_email'
],
$vars
[
'email'
]))
$this
->
errors
[
'admin_email'
]
=
'Conflicts with system email above'
;
//Admin's pass confirmation.
//Admin's pass confirmation.
if
(
!
$this
->
errors
&&
strcasecmp
(
$vars
[
'passwd'
],
$vars
[
'passwd2'
]))
$this
->
errors
[
'passwd2'
]
=
'passwords to not match!'
;
//Check table prefix underscore required at the end!
if
(
$vars
[
'prefix'
]
&&
substr
(
$vars
[
'prefix'
],
-
1
)
!=
'_'
)
$this
->
errors
[
'prefix'
]
=
'Bad prefix. Must have underscore (_) at the end. e.g \'ost_\''
;
//Make sure admin username is not very predictable. XXX: feels dirty but necessary
//Make sure admin username is not very predictable. XXX: feels dirty but necessary
if
(
!
$this
->
errors
[
'username'
]
&&
in_array
(
strtolower
(
$vars
[
'username'
]),
array
(
'admin'
,
'admins'
,
'username'
,
'osticket'
)))
$this
->
errors
[
'username'
]
=
'Bad username'
;
...
...
@@ -123,7 +123,7 @@ class Installer extends SetupWizard {
$this
->
errors
[
'err'
]
=
'Unable to open config file for writing. Permission denied! (#3)'
;
elseif
(
!
$this
->
load_sql_file
(
$schemaFile
,
$vars
[
'prefix'
],
true
,
$debug
))
$this
->
errors
[
'err'
]
=
'Error parsing SQL schema! Get help from developers (#4)'
;
if
(
!
$this
->
errors
)
{
//Create admin user.
$sql
=
'INSERT INTO '
.
PREFIX
.
'staff SET created=NOW() '
...
...
@@ -178,7 +178,7 @@ class Installer extends SetupWizard {
.
",(2,1,'osTicket Alerts','alerts@
$domain
',NOW(),NOW())"
.
",(3,1,'','noreply@
$domain
',NOW(),NOW())"
;
@
mysql_query
(
$sql
);
//Create a ticket to make the system warm and happy.
$sql
=
'INSERT INTO '
.
PREFIX
.
'ticket SET created=NOW(), status="open", source="Web" '
.
' ,priority_id=2, dept_id=1, topic_id=1 '
...
...
@@ -189,7 +189,7 @@ class Installer extends SetupWizard {
if
(
mysql_query
(
$sql
)
&&
(
$tid
=
mysql_insert_id
()))
{
if
(
!
(
$msg
=
file_get_contents
(
INC_DIR
.
'msg/installed.txt'
)))
$msg
=
'Congratulations and Thank you for choosing osTicket!'
;
$sql
=
'INSERT INTO '
.
PREFIX
.
'ticket_thread SET created=NOW()'
.
', source="Web" '
.
', thread_type="M" '
...
...
@@ -199,7 +199,7 @@ class Installer extends SetupWizard {
@
mysql_query
(
$sql
);
}
//TODO: create another personalized ticket and assign to admin??
//Log a message.
$msg
=
"Congratulations osTicket basic installation completed!
\n\n
Thank you for choosing osTicket!"
;
$sql
=
'INSERT INTO '
.
PREFIX
.
'syslog SET created=NOW(), updated=NOW(), log_type="Debug" '
...
...
This diff is collapsed.
Click to expand it.
setup/setup.inc.php
+
6
−
1
View file @
303c0370
...
...
@@ -66,5 +66,10 @@ require_once(INCLUDE_DIR.'class.validator.php');
require_once
(
INCLUDE_DIR
.
'class.passwd.php'
);
require_once
(
INCLUDE_DIR
.
'class.format.php'
);
require_once
(
INCLUDE_DIR
.
'class.misc.php'
);
require_once
(
INCLUDE_DIR
.
'mysql.php'
);
if
(
extension_loaded
(
'mysqli'
))
require_once
INCLUDE_DIR
.
'mysqli.php'
;
else
require
(
INCLUDE_DIR
.
'mysql.php'
);
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment