Failed Conditions
Push — dependabot/composer/php8/smart... ( dccc0a )
by
unknown
18:26 queued 03:11
created

includes/Offline.php (1 issue)

Labels
Severity
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 * ACC Development Team. Please see team.json for a list of contributors.     *
5
 *                                                                            *
6
 * This is free and unencumbered software released into the public domain.    *
7
 * Please see LICENSE.md for the full licencing statement.                    *
8
 ******************************************************************************/
9
10
namespace Waca;
11
12
use Smarty;
13
use SmartyException;
0 ignored issues
show
The type SmartyException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Waca\DataObjects\User;
15
16
/**
17
 * Handles the tool offline messages
18
 */
19
class Offline
20
{
21
    /**
22
     * Determines if the tool is offline
23
     * @return bool
24
     */
25
    public static function isOffline(SiteConfiguration $configuration): bool
26
    {
27
        return (bool)$configuration->getOffline()['offline'];
28
    }
29
30
    /**
31
     * Gets the offline message
32
     *
33
     * @throws SmartyException
34
     */
35
    public static function getOfflineMessage(bool $external, SiteConfiguration $configuration, ?string $message = null): string
36
    {
37
        $baseurl = $configuration->getBaseUrl();
38
        $culprit = $configuration->getOffline()['culprit'];
39
        $reason = $configuration->getOffline()['reason'];
40
41
        $smarty = new Smarty();
42
        $smarty->assign("baseurl", $baseurl);
43
        $smarty->assign("resourceCacheEpoch", 0);
44
        $smarty->assign("alerts", []);
45
        $smarty->assign("toolversion", Environment::getToolVersion());
46
47
        if (!headers_sent()) {
48
            header("HTTP/1.1 503 Service Unavailable");
49
        }
50
51
        if ($external) {
52
            return $smarty->fetch("offline/external.tpl");
53
        }
54
        else {
55
            $hideCulprit = true;
56
57
            // Use the provided message if possible
58
            if ($message === null) {
59
                $hideCulprit = false;
60
                $message = $reason;
61
            }
62
63
            $smarty->assign("hideCulprit", $hideCulprit);
64
            $smarty->assign("dontUseDbCulprit", $culprit);
65
            $smarty->assign("dontUseDbReason", $message);
66
            $smarty->assign("alerts", []);
67
            $smarty->assign('currentUser', User::getCommunity());
68
            $smarty->assign('skin', 'main');
69
            $smarty->assign('currentDomain', null);
70
71
            return $smarty->fetch("offline/internal.tpl");
72
        }
73
    }
74
}
75