Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
PHP 8.0 Support, PHP7.x no longer compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBack committed Apr 29, 2021
1 parent ffa04dd commit f481972
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ steps:
- php /tmp/ci/composer install
- php bin/cli.php migrate
- php bin/cli.php theme install crisp
- vendor/bin/twig-linter lint themes/crisp/templates/
# - vendor/bin/twig-linter lint themes/crisp/templates/
# - vendor/bin/phpunit tests --bootstrap pixelcatproductions/crisp.php
- rm /tmp/ci/composer

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"phpmailer/phpmailer": "^6.4"
},
"require-dev": {
"phpunit/phpunit": "9",
"sserbin/twig-linter": "@dev"
"phpunit/phpunit": "^9.5"
}
}
5 changes: 1 addition & 4 deletions pixelcatproductions/class/crisp/api/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static function hasApiPermissions($BitmaskFlag) {

$keyDetails = self::getAPIKeyDetails($apikey);


if (!$keyDetails) {
return false;
}
Expand All @@ -63,7 +62,6 @@ public static function getAPIKeyDetails($ApiKey) {

$statement->execute([":key" => $ApiKey]);


if ($statement->rowCount() > 0) {
return $statement->fetch(\PDO::FETCH_ASSOC);
}
Expand All @@ -85,7 +83,6 @@ public static function getAPIKey() {
}
$statement->execute([":key" => $apikey]);


if ($statement->rowCount() > 0) {
return true;
}
Expand Down Expand Up @@ -121,7 +118,7 @@ public static function getLocale() {
}


if (!in_array($Locale, array_keys(array_column(\crisp\api\lists\Languages::fetchLanguages(false), null, "Code")))) {
if (!in_array($Locale, array_keys(array_column(\crisp\api\lists\Languages::fetchLanguages(false), null, "code")))) {
$Locale = "en";
}

Expand Down
17 changes: 1 addition & 16 deletions pixelcatproductions/crisp.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class core {
/* Some important constants */

const CRISP_VERSION = "2.0.0";
const CRISP_VERSION = "3.0.0";

/**
* This is my autoloader.
Expand All @@ -47,7 +47,6 @@ public static function bootstrap() {
spl_autoload_register(function ($class) {
$file = __DIR__ . "/class/" . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';


if (file_exists($file)) {
require $file;
return true;
Expand Down Expand Up @@ -80,10 +79,8 @@ public static function bootstrap() {
$GLOBALS['navbar_right'] = array();
$GLOBALS["render"] = array();


session_start();


$CurrentTheme = \crisp\api\Config::get("theme");
$CurrentFile = substr(substr($_SERVER['PHP_SELF'], 1), 0, -4);
$CurrentPage = $GLOBALS["route"]->Page;
Expand All @@ -100,7 +97,6 @@ public static function bootstrap() {
define("CURRENT_UNIVERSE", Universe::getUniverse($_COOKIE[core\Config::$Cookie_Prefix . "universe"]));
define("CURRENT_UNIVERSE_NAME", Universe::getUniverseName(CURRENT_UNIVERSE));


$ThemeLoader = new \Twig\Loader\FilesystemLoader(array(__DIR__ . "/../themes/$CurrentTheme/templates/", __DIR__ . "/../plugins/"));
$TwigTheme;

Expand Down Expand Up @@ -165,7 +161,6 @@ public static function bootstrap() {
$TwigTheme->addFunction(new \Twig\TwigFunction('includeResource', [new \crisp\core\Themes(), 'includeResource']));
$TwigTheme->addFunction(new \Twig\TwigFunction('generateLink', [new \crisp\api\Helper(), 'generateLink']));


$Translation = new \crisp\api\Translation($Locale);

$TwigTheme->addFilter(new \Twig\TwigFilter('date', 'date'));
Expand All @@ -179,10 +174,8 @@ public static function bootstrap() {
$TwigTheme->addFilter(new \Twig\TwigFilter('getlang', [new \crisp\api\lists\Languages(), 'getLanguageByCode']));
$TwigTheme->addFilter(new \Twig\TwigFilter('truncateText', [new \crisp\api\Helper(), 'truncateText']));


$EnvFile = parse_ini_file(__DIR__ . "/../.env");


$RedisClass = new \crisp\core\Redis();
$rateLimiter = new \RateLimit\RedisRateLimiter($RedisClass->getDBConnector());

Expand All @@ -194,7 +187,6 @@ public static function bootstrap() {
header('Access-Control-Allow-Origin: *');
header("Cache-Control: max-age=600, public, must-revalidate");


if (!isset($_SERVER['HTTP_USER_AGENT']) || empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == "i am not valid") {
http_response_code(403);
echo $TwigTheme->render("errors/nginx/403.twig", ["error_msg" => "Request forbidden by administrative rules. Please make sure your request has a User-Agent header"]);
Expand All @@ -214,7 +206,6 @@ public static function bootstrap() {
if (isset(apache_request_headers()["Authorization"])) {
$keyDetails = api\Helper::getAPIKeyDetails(apache_request_headers()["Authorization"]);


if ($keyDetails["expires_at"] !== null && strtotime($keyDetails["expires_at"]) < time()) {
header("X-APIKey: expired");
} elseif ($keyDetails["revoked"]) {
Expand All @@ -237,13 +228,10 @@ public static function bootstrap() {
$IndicatorHour = "h_" . \crisp\api\Helper::getRealIpAddr();
$IndicatorDay = "d_" . \crisp\api\Helper::getRealIpAddr();


$LimitSecond = \RateLimit\Rate::perSecond(15);
$LimitHour = \RateLimit\Rate::perHour(1000);
$LimitDay = \RateLimit\Rate::perHour(15000);



if (CURRENT_UNIVERSE == \crisp\Universe::UNIVERSE_TOSDR || in_array(\crisp\api\Helper::getRealIpAddr(), \crisp\api\Config::get("office_ips"))) {

$LimitSecond = \RateLimit\Rate::perSecond(15000);
Expand Down Expand Up @@ -290,7 +278,6 @@ public static function bootstrap() {
$statusHour = $rateLimiter->limitSilently($IndicatorHour, $LimitHour);
$statusDay = $rateLimiter->limitSilently($IndicatorDay, $LimitDay);


header("X-CMS-CDN: " . api\Config::get("cdn"));
header("X-CMS-SHIELDS: " . api\Config::get("shield_cdn"));
header("X-RateLimit-Benefit: " . $Benefit);
Expand All @@ -311,8 +298,6 @@ public static function bootstrap() {
core\Themes::loadAPI($TwigTheme, $GLOBALS["route"]->Page, $Query);
core\Plugins::loadAPI($GLOBALS["route"]->Page, $QUERY);



exit;
}

Expand Down
3 changes: 0 additions & 3 deletions themes/crisp/includes/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const TEMPLATE_VARIABLES = array(
"variable1" => "I am a Var"
);
16 changes: 9 additions & 7 deletions themes/crisp/includes/downloads.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/*
* Copyright (C) 2021 Justin René Back <justin@tosdr.org>
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -21,13 +21,15 @@

$_vars["extensions"] = \crisp\api\Config::get("extensions");

if (CURRENT_UNIVERSE >= crisp\Universe::UNIVERSE_PUBLIC) {
foreach ($_vars["extensions"] as $Key => $Extension) {
if (strpos($Extension->browser, get_browser(null, true)["browser"]) !== false) {
$FeaturedExtension = $Extension;
unset($_vars["extensions"][$Key]);
if (ini_get('browscap') !== "") {
if (CURRENT_UNIVERSE >= crisp\Universe::UNIVERSE_PUBLIC) {
foreach ($_vars["extensions"] as $Key => $Extension) {
if (strpos($Extension->browser, get_browser(null, true)["browser"]) !== false) {
$FeaturedExtension = $Extension;
unset($_vars["extensions"][$Key]);
}
}
}
}
}

$_vars["featured"] = $FeaturedExtension;
17 changes: 6 additions & 11 deletions themes/crisp/templates/components/extensiongrid/grid.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% for Extension in Extensions %}
{% if loop.first or loop.index0 is divisible by(columns) %}
<div class="row mb-5">
{% endif %}

{% include "components/extensiongrid/addon.twig" with {'extension': Extension, 'col': (12 /columns)} %}
{% if loop.first or loop.index0 is divisible by(columns) %}
<div class="row mb-5">
{% endif %}

{% if loop.last and loop.index is not divisible by(columns) %}
{% for n in range(low=columns - (loop.index % columns), high=1, step=-1) %}
{% include "components/extensiongrid/addon.twig" with {'extension': Extension, 'col': (12 /columns)} %}

{% endfor %}
{% if loop.last or loop.index is divisible by(columns) %}
</div>
{% endif %}
{% if loop.last or loop.index is divisible by(columns) %}
</div>
{% endif %}
{% endfor %}
7 changes: 0 additions & 7 deletions themes/crisp/templates/components/servicegrid/grid.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,8 @@
<div class="row mb-5">
{% endif %}



{% include "components/servicegrid/service.twig" with {'service': Service, 'col': (12 /columns)} %}

{% if loop.last and loop.index is not divisible by(columns) %}
{% for n in range(low=columns - (loop.index % columns), high=1, step=-1) %}

{% endfor %}
{% endif %}
{% if loop.last or loop.index is divisible by(columns) %}
</div>
{% endif %}
Expand Down
5 changes: 0 additions & 5 deletions themes/crisp/templates/components/teamgrid/grid.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

{% include "components/teamgrid/member.twig" with {'member': Member, 'col': (12 /columns)} %}

{% if loop.last and loop.index is not divisible by(columns) %}
{% for n in range(low=columns - (loop.index % columns), high=1, step=-1) %}

{% endfor %}
{% endif %}
{% if loop.last or loop.index is divisible by(columns) %}
</div>
{% endif %}
Expand Down
5 changes: 0 additions & 5 deletions themes/crisp/templates/components/thanksgrid/grid.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@

{% include "components/thanksgrid/person.twig" with {'person': Person, 'col': (12 /columns)} %}

{% if loop.last and loop.index is not divisible by(columns) %}
{% for n in range(low=columns - (loop.index % columns), high=1, step=-1) %}

{% endfor %}
{% endif %}
{% if loop.last or loop.index is divisible by(columns) %}
</div>
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions themes/crisp/templates/views/downloads.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

{% extends "base.twig" %}



{% block content %}
{{ include("components/navbar.twig") }}

Expand Down

0 comments on commit f481972

Please sign in to comment.