Skip to content

Commit 3171670

Browse files
authored
Merge pull request #172 from Steffen-MLR/master
PHP8 Support
2 parents e0ff612 + f942c49 commit 3171670

19 files changed

+146
-67
lines changed

404.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
define("NAME", "");
3+
define("TITLE", "");
4+
define("WEB_URL", "");
25
require_once("template.php");
36
if (!file_exists("config.php"))
47
{

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM php:8.2-apache
2+
RUN docker-php-ext-install mysqli
3+
RUN docker-php-ext-enable mysqli
4+
RUN apt-get update
5+
RUN apt-get install libzip-dev -y
6+
RUN docker-php-ext-install zip
7+
RUN docker-php-ext-enable zip
8+
RUN a2enmod rewrite
9+
RUN touch /usr/local/etc/php/conf.d/ssp.ini
10+
RUN echo "output_buffering = 16384" >> /usr/local/etc/php/conf.d/ssp.ini
11+
RUN echo "display_errors = off" >> /usr/local/etc/php/conf.d/ssp.ini
12+
RUN echo "error_reporting = E_ERROR" >> /usr/local/etc/php/conf.d/ssp.ini
13+
RUN apt install git -y
14+
WORKDIR /var/www/html
15+
RUN docker-php-ext-install gettext
16+
RUN docker-php-ext-install pdo_mysql
17+
RUN apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype --with-jpeg && docker-php-ext-install -j$(nproc) gd
18+
RUN apt-get install -y locales
19+
RUN locale-gen en_GB.UTF-8
20+
RUN sed -i '/en_GB.UTF-8/s/^# //g' /etc/locale.gen && \
21+
locale-gen
22+
RUN apt-get install -y curl
23+
# And clean up the image
24+
RUN rm -rf /var/lib/apt/lists/*
25+
26+
RUN curl -Lsf 'https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz' | tar -C '/usr/local' -xvzf -
27+
ENV PATH /usr/local/go/bin:$PATH
28+
RUN go get github.com/mailhog/mhsendmail
29+
RUN cp /root/go/bin/mhsendmail /usr/bin/mhsendmail
30+
RUN echo 'sendmail_path = /usr/bin/mhsendmail --smtp-addr mailhog:1025' > /usr/local/etc/php/php.ini
31+
32+

admin/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
?>
4848
<div class="text-center">
4949
<h1><?php
50-
if ($_SESSION['user'] == $_GET['id'])
50+
if (isset($_GET['id']) && isset($_SESSION['user']) && $_SESSION['user'] == $_GET['id'])
5151
{
5252
echo _("User settings");
5353
}else{

classes/constellation.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function render_incidents($future=false, $offset=0, $limit = 5, $admin =
6969
* @param boolean $admin
7070
* @return array of services
7171
*/
72-
public function render_status($admin = false, $heading = true){
72+
public function render_status($admin = false, $heading = true): array{
7373
global $mysqli;
7474

7575
//$query = $mysqli->query("SELECT id, name, description FROM services");
@@ -104,27 +104,12 @@ public function render_status($admin = false, $heading = true){
104104
}
105105
if (!$admin)
106106
{
107-
?>
108-
<script>
109-
$(document).ready(function(){
110-
$('[data-toggle="tooltip"]').tooltip();
111-
});
112-
</script>
113-
<?php
114-
//echo '<div id="status-container" class="clearfix">';
115-
//$arrCompletedGroups = array();
107+
116108
foreach($array as $service){
117-
//print_r($service);
118-
//if ( !empty($service->group_name) && !in_array($service->group_name, $arrCompletedGroups)) {
119-
//print $service->name;
120-
// $arrCompletedGroups[] = $service['group_name'];
121-
// $service->render(true);
122-
//} else {
123109
$service->render();
124-
//}
125110
}
126111
echo '</ul>';
127-
//echo '</div>';
112+
return $array;
128113
}
129114
else{
130115
return $array;

classes/incident.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public function render($admin=0){
223223
<?php
224224
}
225225

226-
public function jsonSerialize() {
226+
public function jsonSerialize():mixed {
227227
return [
228228
"id" => $this->id,
229229
"date" => $this->timestamp,

classes/locale-negotiator.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ class LocaleNegotiator
150150
'nl_BE' => 'Nederlands',
151151
'nl_NL' => 'Nederlands',
152152
'nn_NO' => 'Nynorsk',
153-
'nb_NO' => 'Norsk Bokmål',
154153
'nso_ZA' => 'Northern sotho',
155154
'oc_FR' => 'Occitan',
156155
'or_IN' => 'ଓଡ଼ିଆ',

classes/notification.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function notify_subscribers()
6060
$sql = "SELECT DISTINCT subscriberIDFK FROM services_subscriber WHERE serviceIDFK IN (" . $this->serviceids . ")";
6161
$query = $mysqli->query($sql);
6262

63+
if (0 === $query->num_rows) {
64+
// skip processing if no one needs to be notified
65+
return;
66+
}
67+
6368
// Create the queue tasks for email/telegram notifications
6469
$queue = new Queue();
6570
$queue->status = $queue->all_status['populating'];
@@ -125,7 +130,7 @@ public function notify_subscribers()
125130
* @param string $msg Body of message
126131
* @return boolean true = Sent / False = failed
127132
*/
128-
public function submit_queue_telegram($userID, $firstname, $msg)
133+
public static function submit_queue_telegram($userID, $firstname, $msg)
129134
{
130135
// TODO Handle limitations (Max 30 different subscribers per second)
131136
// TODO Error handling
@@ -150,7 +155,7 @@ public function submit_queue_telegram($userID, $firstname, $msg)
150155
* @param String $uthkey Users token for managing subscription
151156
* @return void
152157
*/
153-
public function submit_queue_email($subscriber, $subject, $msg)
158+
public static function submit_queue_email($subscriber, $subject, $msg): bool
154159
{
155160
// TODO Error handling
156161
$mailer = new Mailer();

classes/queue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function add_task() {
4949
* Remove task from the queue
5050
* @return void
5151
*/
52-
public function delete_task($task_id){
52+
public static function delete_task($task_id){
5353
global $mysqli;
5454
$stmt = $mysqli->prepare("DELETE FROM queue_task WHERE id = ?");
5555
$stmt->bind_param("i", $task_id);
@@ -98,14 +98,14 @@ public function add_notification($arr_data) {
9898
$this->set_task_status($this->all_status['ready']); // Make task available for release
9999
}
100100

101-
public function update_notification_retries($task_id, $subscriber_id) {
101+
public static function update_notification_retries($task_id, $subscriber_id) {
102102
global $mysqli;
103103
$stmt = $mysqli->prepare("UPDATE queue_notify SET retries = retries+1 WHERE task_id = ? AND subscriber_id = ?");
104104
$stmt->bind_param("ii", $task_id, $subscriber_id);
105105
$stmt->execute();
106106
}
107107

108-
public function delete_notification($task_id, $subscriber_id) {
108+
public static function delete_notification($task_id, $subscriber_id) {
109109
global $mysqli;
110110
$stmt = $mysqli->prepare("DELETE FROM queue_notify WHERE task_id = ? AND subscriber_id = ?");
111111
$stmt->bind_param("ii", $task_id, $subscriber_id);
@@ -114,7 +114,7 @@ public function delete_notification($task_id, $subscriber_id) {
114114
}
115115

116116
// TODO: Fix max attempts for notifications
117-
public function process_queue(){
117+
public static function process_queue(){
118118
global $mysqli;
119119
$stmt = $mysqli->query("SELECT qn.id, qn.task_id, qn.status, qn.subscriber_id, qn.retries, sub.firstname, sub.userID, sub.token FROM queue_notify AS qn INNER JOIN subscribers AS sub ON qn.subscriber_id = sub.subscriberID WHERE qn.status NOT LIKE 2 AND sub.active=1");
120120
while ( $result = $stmt->fetch_assoc() ) {

classes/service-group.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ServiceGroup
88
private $name;
99
private $description;
1010
private $visibility_id;
11+
private $status;
1112

1213
/**
1314
* Constructs servicegroup from its data.
@@ -16,7 +17,7 @@ class ServiceGroup
1617
* @param String $description tooltip text
1718
* @param int $visibility_id how to display group items
1819
*/
19-
function __construct($id, $name, $description, $visibility_id)
20+
function __construct($id, $name, $description, $visibility_id, $status)
2021

2122
{
2223
//TODO: Maybe get data from ID?
@@ -153,7 +154,7 @@ public static function delete()
153154
* Get list of services groups.
154155
* @return array $groups
155156
*/
156-
public function get_groups() {
157+
public static function get_groups() {
157158
global $mysqli;
158159
$stmt = $mysqli->query("SELECT id, name FROM services_groups ORDER by name ASC");
159160

classes/service.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static function delete()
180180
* @param Service[] $array array of services
181181
* @return void
182182
*/
183-
public static function current_status($array){
183+
public static function current_status($array): void{
184184
global $all, $some, $classes;
185185
$statuses = array(0,0,0,0);
186186
$worst = 5;
@@ -258,7 +258,7 @@ public function render(){
258258
}
259259
}
260260

261-
public function jsonSerialize() {
261+
public function jsonSerialize(): mixed {
262262
global $statuses;
263263
return [
264264
"id" => $this->id,

0 commit comments

Comments
 (0)