diff --git a/.drone.yml b/.drone.yml index 8dc4c05e..87d1a304 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/composer.json b/composer.json index 052a3788..912445b3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "phpmailer/phpmailer": "^6.4" }, "require-dev": { - "phpunit/phpunit": "9", - "sserbin/twig-linter": "@dev" + "phpunit/phpunit": "^9.5" } } diff --git a/pixelcatproductions/class/crisp/api/Helper.php b/pixelcatproductions/class/crisp/api/Helper.php index ac07e5ec..b062767d 100644 --- a/pixelcatproductions/class/crisp/api/Helper.php +++ b/pixelcatproductions/class/crisp/api/Helper.php @@ -45,7 +45,6 @@ public static function hasApiPermissions($BitmaskFlag) { $keyDetails = self::getAPIKeyDetails($apikey); - if (!$keyDetails) { return false; } @@ -63,7 +62,6 @@ public static function getAPIKeyDetails($ApiKey) { $statement->execute([":key" => $ApiKey]); - if ($statement->rowCount() > 0) { return $statement->fetch(\PDO::FETCH_ASSOC); } @@ -85,7 +83,6 @@ public static function getAPIKey() { } $statement->execute([":key" => $apikey]); - if ($statement->rowCount() > 0) { return true; } @@ -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"; } diff --git a/pixelcatproductions/crisp.php b/pixelcatproductions/crisp.php index d7cea940..aeb9c66d 100644 --- a/pixelcatproductions/crisp.php +++ b/pixelcatproductions/crisp.php @@ -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. @@ -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; @@ -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; @@ -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; @@ -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')); @@ -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()); @@ -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"]); @@ -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"]) { @@ -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); @@ -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); @@ -311,8 +298,6 @@ public static function bootstrap() { core\Themes::loadAPI($TwigTheme, $GLOBALS["route"]->Page, $Query); core\Plugins::loadAPI($GLOBALS["route"]->Page, $QUERY); - - exit; } diff --git a/themes/crisp/includes/about.php b/themes/crisp/includes/about.php index 8b801a3b..2685bcfd 100644 --- a/themes/crisp/includes/about.php +++ b/themes/crisp/includes/about.php @@ -17,6 +17,3 @@ * along with this program. If not, see . */ -const TEMPLATE_VARIABLES = array( - "variable1" => "I am a Var" -); diff --git a/themes/crisp/includes/downloads.php b/themes/crisp/includes/downloads.php index 93d4dc95..895ec377 100644 --- a/themes/crisp/includes/downloads.php +++ b/themes/crisp/includes/downloads.php @@ -1,6 +1,6 @@ * * This program is free software: you can redistribute it and/or modify @@ -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; diff --git a/themes/crisp/templates/components/extensiongrid/grid.twig b/themes/crisp/templates/components/extensiongrid/grid.twig index 2a49c707..7b02144c 100644 --- a/themes/crisp/templates/components/extensiongrid/grid.twig +++ b/themes/crisp/templates/components/extensiongrid/grid.twig @@ -15,18 +15,13 @@ # along with this program. If not, see . #} {% for Extension in Extensions %} - {% if loop.first or loop.index0 is divisible by(columns) %} -
- {% endif %} - - {% include "components/extensiongrid/addon.twig" with {'extension': Extension, 'col': (12 /columns)} %} + {% if loop.first or loop.index0 is divisible by(columns) %} +
+ {% 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) %} +
{% endif %} - {% if loop.last or loop.index is divisible by(columns) %} -
- {% endif %} {% endfor %} \ No newline at end of file diff --git a/themes/crisp/templates/components/servicegrid/grid.twig b/themes/crisp/templates/components/servicegrid/grid.twig index ac6c93b2..f354d02e 100644 --- a/themes/crisp/templates/components/servicegrid/grid.twig +++ b/themes/crisp/templates/components/servicegrid/grid.twig @@ -20,15 +20,8 @@
{% 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) %}
{% endif %} diff --git a/themes/crisp/templates/components/teamgrid/grid.twig b/themes/crisp/templates/components/teamgrid/grid.twig index 4f4688c5..f7ccc4ad 100644 --- a/themes/crisp/templates/components/teamgrid/grid.twig +++ b/themes/crisp/templates/components/teamgrid/grid.twig @@ -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) %} {% endif %} diff --git a/themes/crisp/templates/components/thanksgrid/grid.twig b/themes/crisp/templates/components/thanksgrid/grid.twig index a87c73dd..a78ad6d6 100644 --- a/themes/crisp/templates/components/thanksgrid/grid.twig +++ b/themes/crisp/templates/components/thanksgrid/grid.twig @@ -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) %} {% endif %} diff --git a/themes/crisp/templates/views/downloads.twig b/themes/crisp/templates/views/downloads.twig index b89ac400..dda48844 100644 --- a/themes/crisp/templates/views/downloads.twig +++ b/themes/crisp/templates/views/downloads.twig @@ -23,6 +23,8 @@ {% extends "base.twig" %} + + {% block content %} {{ include("components/navbar.twig") }}