Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
d6743760
Commit
d6743760
authored
9 years ago
by
Giovannoni Laurent
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #2681
parent
cca81d08
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/trunk/core/class/class_alert_engine.php
+8
-6
8 additions, 6 deletions
core/trunk/core/class/class_alert_engine.php
core/trunk/core/class/class_db_pdo.php
+106
-30
106 additions, 30 deletions
core/trunk/core/class/class_db_pdo.php
with
114 additions
and
36 deletions
core/trunk/core/class/class_alert_engine.php
+
8
−
6
View file @
d6743760
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* @license GPL
* @license GPL
* @author Laurent Giovannoni <dev@maarch.org>
* @author Laurent Giovannoni <dev@maarch.org>
*/
*/
class
alert_engine
extends
dbquery
class
alert_engine
extends
Database
{
{
/**
/**
* Redefinition of the alert_engine object constructor
* Redefinition of the alert_engine object constructor
...
@@ -71,9 +71,11 @@ class alert_engine extends dbquery
...
@@ -71,9 +71,11 @@ class alert_engine extends dbquery
'11_11'
,
'11_11'
,
'25_12'
'25_12'
);
);
$this
->
connect
();
require_once
'core/class/class_db_pdo.php'
;
$this
->
query
(
"select * from parameters where id like 'alert_stop%'"
);
while
(
$result
=
$this
->
fetch_object
())
{
$db
=
new
Database
();
$stmt
=
$db
->
query
(
"select * from parameters where id like 'alert_stop%'"
);
while
(
$result
=
$stmt
->
fetchObject
())
{
if
(
$result
->
param_value_date
<>
''
)
{
if
(
$result
->
param_value_date
<>
''
)
{
$compare
=
$this
->
compare_date
(
$result
->
param_value_date
,
date
(
"d-m-Y"
));
$compare
=
$this
->
compare_date
(
$result
->
param_value_date
,
date
(
"d-m-Y"
));
//take the alert stop only if > now
//take the alert stop only if > now
...
@@ -86,9 +88,9 @@ class alert_engine extends dbquery
...
@@ -86,9 +88,9 @@ class alert_engine extends dbquery
//var_dump($Hollidays);
//var_dump($Hollidays);
if
(
function_exists
(
'easter_date'
))
{
if
(
function_exists
(
'easter_date'
))
{
$WhenEasterCelebrates
=
easter_date
((
int
)
date
(
'Y'
),
$Date
);
$WhenEasterCelebrates
=
easter_date
((
int
)
date
(
'Y'
),
$Date
);
}
else
{
}
else
{
$WhenEasterCelebrates
=
$this
->
getEaster
((
int
)
date
(
'Y'
),
$Date
);
$WhenEasterCelebrates
=
$this
->
getEaster
((
int
)
date
(
'Y'
),
$Date
);
}
}
$Hollidays
[]
=
date
(
'j_n'
,
$WhenEasterCelebrates
);
$Hollidays
[]
=
date
(
'j_n'
,
$WhenEasterCelebrates
);
$Hollidays
[]
=
date
(
'j_n'
,
$WhenEasterCelebrates
+
(
86400
*
39
));
$Hollidays
[]
=
date
(
'j_n'
,
$WhenEasterCelebrates
+
(
86400
*
39
));
...
...
This diff is collapsed.
Click to expand it.
core/trunk/core/class/class_db_pdo.php
+
106
−
30
View file @
d6743760
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*
*
* @package Core
* @package Core
*/
*/
class
Database
class
Database
extends
functions
{
{
/**
/**
* Prepared statements indexed by dsn and queryString
* Prepared statements indexed by dsn and queryString
...
@@ -49,39 +49,115 @@ class Database
...
@@ -49,39 +49,115 @@ class Database
*/
*/
public
function
__construct
()
public
function
__construct
()
{
{
if
(
isset
(
$_SESSION
[
'config'
][
'databaseserver'
]))
{
$args
=
func_get_args
();
$this
->
server
=
$_SESSION
[
'config'
][
'databaseserver'
];
if
(
count
(
$args
)
<
1
)
{
}
if
(
isset
(
$_SESSION
[
'config'
][
'databaseserver'
]))
{
if
(
isset
(
$_SESSION
[
'config'
][
'databaseserverport'
]))
{
$this
->
server
=
$_SESSION
[
'config'
][
'databaseserver'
];
$this
->
port
=
$_SESSION
[
'config'
][
'databaseserverport'
];
}
}
if
(
isset
(
$_SESSION
[
'config'
][
'databaseserverport'
]))
{
if
(
isset
(
$_SESSION
[
'config'
][
'databaseuser'
]))
{
$this
->
port
=
$_SESSION
[
'config'
][
'databaseserverport'
];
$this
->
user
=
$_SESSION
[
'config'
][
'databaseuser'
];
}
}
if
(
isset
(
$_SESSION
[
'config'
][
'databaseuser'
]))
{
if
(
isset
(
$_SESSION
[
'config'
][
'databasepassword'
]))
{
$this
->
user
=
$_SESSION
[
'config'
][
'databaseuser'
];
$this
->
password
=
$_SESSION
[
'config'
][
'databasepassword'
];
}
}
if
(
isset
(
$_SESSION
[
'config'
][
'databasepassword'
]))
{
if
(
isset
(
$_SESSION
[
'config'
][
'databasename'
]))
{
$this
->
password
=
$_SESSION
[
'config'
][
'databasepassword'
];
$this
->
database
=
$_SESSION
[
'config'
][
'databasename'
];
}
}
if
(
isset
(
$_SESSION
[
'config'
][
'databasename'
]))
{
if
(
isset
(
$_SESSION
[
'config'
][
'databasetype'
]))
{
$this
->
database
=
$_SESSION
[
'config'
][
'databasename'
];
switch
(
$_SESSION
[
'config'
][
'databasetype'
])
{
}
case
'POSTGRESQL'
:
if
(
isset
(
$_SESSION
[
'config'
][
'databasetype'
]))
{
$this
->
driver
=
'pgsql'
;
switch
(
$_SESSION
[
'config'
][
'databasetype'
])
{
break
;
case
'POSTGRESQL'
:
case
'MYSQL'
:
$this
->
driver
=
'pgsql'
;
$this
->
driver
=
'mysql'
;
break
;
break
;
case
'MYSQL'
:
$this
->
driver
=
'mysql'
;
break
;
case
'ORACLE'
:
$this
->
driver
=
'oci'
;
break
;
default
:
print_r
(
'DRIVER ERROR: Unknown database driver '
.
$_SESSION
[
'config'
][
'databasetype'
]);
}
}
}
else
{
$errorArgs
=
true
;
if
(
is_array
(
$args
[
0
]))
{
if
(
!
isset
(
$args
[
0
][
'server'
]))
{
$this
->
server
=
'127.0.0.1'
;
}
else
{
$this
->
server
=
$args
[
0
][
'server'
];
}
switch
(
$args
[
0
][
'databasetype'
])
{
case
'POSTGRESQL'
:
$this
->
driver
=
'pgsql'
;
break
;
case
'MYSQL'
:
$this
->
driver
=
'mysql'
;
break
;
case
'ORACLE'
:
case
'ORACLE'
:
$this
->
driver
=
'oci'
;
$this
->
driver
=
'oci'
;
break
;
break
;
default
:
default
:
print_r
(
'DRIVER ERROR: Unknown database driver '
.
$_SESSION
[
'config'
][
'databasetype'
]);
print_r
(
'DRIVER ERROR: Unknown database driver '
.
$_SESSION
[
'config'
][
'databasetype'
]);
}
if
(
!
isset
(
$args
[
0
][
'port'
]))
{
$this
->
port
=
'5432'
;
}
else
{
$this
->
port
=
$args
[
0
][
'port'
];
}
if
(
!
isset
(
$args
[
0
][
'user'
]))
{
$this
->
user
=
'postgres'
;
}
else
{
$this
->
user
=
$args
[
0
][
'user'
];
}
if
(
!
isset
(
$args
[
0
][
'password'
]))
{
$this
->
password
=
'postgres'
;
}
else
{
$this
->
password
=
$args
[
0
][
'pass'
];
}
if
(
!
isset
(
$args
[
0
][
'base'
]))
{
$this
->
database
=
''
;
}
else
{
$this
->
database
=
$args
[
0
][
'base'
];
}
$errorArgs
=
false
;
}
else
if
(
is_string
(
$args
[
0
])
&&
file_exists
(
$args
[
0
]))
{
$xmlconfig
=
simplexml_load_file
(
$args
[
0
]);
$config
=
$xmlconfig
->
CONFIG_BASE
;
$this
->
server
=
(
string
)
$config
->
databaseserver
;
$this
->
port
=
(
string
)
$config
->
databaseserverport
;
$this
->
driver
=
(
string
)
$config
->
databasetype
;
switch
(
$this
->
driver
)
{
case
'POSTGRESQL'
:
$this
->
driver
=
'pgsql'
;
break
;
case
'MYSQL'
:
$this
->
driver
=
'mysql'
;
break
;
case
'ORACLE'
:
$this
->
driver
=
'oci'
;
break
;
default
:
print_r
(
'DRIVER ERROR: Unknown database driver '
.
$_SESSION
[
'config'
][
'databasetype'
]);
}
$this
->
database
=
(
string
)
$config
->
databasename
;
$this
->
user
=
(
string
)
$config
->
databaseuser
;
$this
->
password
=
(
string
)
$config
->
databasepassword
;
$errorArgs
=
false
;
}
}
}
}
// Set DSN
// Set DSN
$this
->
dsn
=
$this
->
driver
$this
->
dsn
=
$this
->
driver
.
':host='
.
$this
->
server
.
':host='
.
$this
->
server
...
...
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