Commit db7db832 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

removed usages of env function

parent 6a2a2cd5
......@@ -23,3 +23,5 @@ package-lock.json
local.log
browserstack.err
.npm
.composer
\ No newline at end of file
FROM debian:10
# syntax = docker/dockerfile:experimental
FROM debian:10 AS dependencies
WORKDIR /html
EXPOSE 8080
# Install System Components
RUN apt update \
......@@ -11,10 +15,10 @@ RUN apt update \
curl \
zip
# Install PHP Components
RUN curl -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
# Install PHP Components
RUN apt update \
&& apt install -y \
php7.4 \
......@@ -32,9 +36,26 @@ RUN apt update \
php7.4-json \
php7.4-opcache
WORKDIR /html
# Install Composer
COPY ./helpers/installComposer.sh /usr/bin/installComposer
RUN chmod +x /usr/bin/installComposer && \
/usr/bin/installComposer && \
rm /usr/bin/installComposer
RUN mkdir -p /run/php && \
# Install Nodejs
COPY ./helpers/installNodejs.sh /usr/bin/installNodejs
RUN chmod +x /usr/bin/installNodejs && \
/usr/bin/installNodejs && \
rm /usr/bin/installNodejs
ENV PATH /usr/local/lib/nodejs/bin:$PATH
# Install Minio Client
RUN curl -o /usr/bin/mc "https://dl.min.io/client/mc/release/linux-amd64/mc" &&\
chmod +x /usr/bin/mc
FROM dependencies AS development
RUN sed -i 's/pid = \/run\/php\/php7.4-fpm.pid/;pid = \/run\/php\/php7.4-fpm.pid/g' /etc/php/7.4/fpm/php-fpm.conf && \
sed -i 's/error_log = \/var\/log\/php7.4-fpm.log/error_log = \/dev\/stderr/g' /etc/php/7.4/fpm/php-fpm.conf && \
sed -i 's/;daemonize = yes/daemonize = no/g' /etc/php/7.4/fpm/php-fpm.conf && \
sed -i 's/listen = \/run\/php\/php7.4-fpm.sock/listen = 9000/g' /etc/php/7.4/fpm/pool.d/www.conf && \
......@@ -47,40 +68,66 @@ RUN mkdir -p /run/php && \
sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 5/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 50/g' /etc/php/7.4/fpm/pool.d/www.conf && \
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/7.4/fpm/php.ini && \
# Opcache configuration
echo "xdebug.mode = debug" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.start_with_request = yes" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.discover_client_host = true" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
echo "xdebug.idekey=VSCODE" >> /etc/php/7.4/fpm/conf.d/20-xdebug.ini && \
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 30M/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/post_max_size = 8M/post_max_size = 30M/g' /etc/php/7.4/fpm/php.ini && \
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
echo "Europe/Berlin" > /etc/timezone
# (crontab -l ; echo "* * * * * php /html/artisan schedule:run >> /dev/null 2>&1") | crontab - # TODO: Fix crontab
# Using image as non-root
RUN groupadd -g 1000 metager-proxy && \
useradd -b /home/metager-proxy -g 1000 -u 1000 -M -s /bin/bash metager-proxy
RUN chown -R 1000:1000 /var/lib/nginx /var/log/nginx
RUN mkdir -p /home/metager-proxy &&\
chown 1000:1000 /home/metager-proxy
RUN touch /run/nginx.pid && \
chown 1000:1000 /run/nginx.pid
USER 1000:1000
CMD /entrypoint.sh
FROM development AS production
USER 0:0
# Opcache configuration
RUN apt purge -y php7.4-xdebug
RUN sed -i 's/expose_php = On/expose_php = Off/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.enable=1/opcache.enable=1/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.memory_consumption=128/opcache.memory_consumption=128/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=8/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.max_accelerated_files=10000/opcache.max_accelerated_files=10000/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.max_wasted_percentage=5/opcache.max_wasted_percentage=5/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.validate_timestamps=1/opcache.validate_timestamps=1/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=300/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 30M/g' /etc/php/7.4/fpm/php.ini && \
sed -i 's/post_max_size = 8M/post_max_size = 30M/g' /etc/php/7.4/fpm/php.ini && \
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
echo "Europe/Berlin" > /etc/timezone && \
(crontab -l ; echo "* * * * * php /html/artisan schedule:run >> /dev/null 2>&1") | crontab -
sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=300/g' /etc/php/7.4/fpm/php.ini
COPY config/nginx.conf /etc/nginx/nginx.conf
COPY config/nginx-default.conf /etc/nginx/sites-available/default
RUN sed -i 's/fastcgi_pass phpfpm:9000;/fastcgi_pass localhost:9000;/g' /etc/nginx/sites-available/default
COPY --chown=root:www-data . /html
COPY ./helpers/installComposer.sh /usr/bin/installComposer
RUN chmod +x /usr/bin/installComposer && \
/usr/bin/installComposer && \
rm /usr/bin/installComposer && \
composer install --no-dev
# Install Entrypoint
COPY ./helpers/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
WORKDIR /html
EXPOSE 80
CMD cp /root/.env .env && \
sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env && \
if [ "$GITLAB_ENVIRONMENT_NAME" = "production" ]; then sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env; else sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env; fi && \
cp database/useragents.sqlite.example database/useragents.sqlite && \
chown -R root:www-data storage/logs/metager bootstrap/cache && \
chmod -R g+w storage/logs/metager bootstrap/cache && \
cron -L /dev/stdout && \
php artisan spam:load && \
php-fpm7.4
COPY --chown=1000:1000 . /html
# Install packages
RUN --mount=type=secret,id=auto-devops-build-secrets . /run/secrets/auto-devops-build-secrets && \
chmod +x ./helpers/installPackages.sh && \
/bin/sh -c ./helpers/installPackages.sh
USER 1000:1000
#CMD cp /root/.env .env && \
# sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env && \
# if [ "$GITLAB_ENVIRONMENT_NAME" = "production" ]; then sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env; else sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env; fi && \
# cp database/useragents.sqlite.example database/useragents.sqlite && \
# chown -R root:www-data storage/logs/metager bootstrap/cache && \
# chmod -R g+w storage/logs/metager bootstrap/cache && \
# cron -L /dev/stdout && \
# php artisan spam:load && \
# php-fpm7.4
......@@ -48,9 +48,9 @@ class AppendLogs extends Command
{
$redis = null;
if (env("REDIS_CACHE_DRIVER", "redis") === "redis") {
if (config("database.redis.cache.driver", "redis") === "redis") {
$redis = Redis::connection('cache');
} elseif (env("REDIS_CACHE_DRIVER", "redis") === "redis-sentinel") {
} elseif (config("database.redis.cache.driver", "redis") === "redis-sentinel") {
$redis = RedisSentinel::connection('cache');
}
if ($redis === null) {
......
......@@ -38,10 +38,10 @@ class RequestFetcher extends Command
{
parent::__construct();
$this->multicurl = curl_multi_init();
$this->proxyhost = env("PROXY_HOST", "");
$this->proxyport = env("PROXY_PORT", "");
$this->proxyuser = env("PROXY_USER", "");
$this->proxypassword = env("PROXY_PASSWORD", "");
$this->proxyhost = config("metager.metager.fetcher.proxy.host");
$this->proxyport = config("metager.metager.fetcher.proxy.port");
$this->proxyuser = config("metager.metager.fetcher.proxy.user");
$this->proxypassword = config("metager.metager.fetcher.proxy.password");
}
/**
......
......@@ -60,7 +60,7 @@ class AdgoalTestController extends Controller
return redirect('admin/adgoal');
}
$url = route('resultpage', ["eingabe" => $eingabe, "out" => "api", "key" => env("mainz_key")]);
$url = route('resultpage', ["eingabe" => $eingabe, "out" => "api", "key" => config("metager.metager.keys.uni_mainz")]);
$hash = md5($url);
$mission = [
......
......@@ -17,14 +17,14 @@ class Assoziator extends Controller
$params = [
"eingabe" => $eingabe,
"out" => "atom10",
"key" => env("ASSO_KEY", "test"),
"key" => config("metager.metager.keys.assoziator"),
];
$url = route("resultpage", $params);
# Special Case for local development as the port forwarding does not work within docker
if(env("APP_ENV", "") === "local" && stripos($url, "http://localhost:8080") === 0){
if(\App::environment() === "local" && stripos($url, "http://localhost:8080") === 0){
$url = str_replace("http://localhost:8080", "http://nginx", $url);
}
......
......@@ -92,18 +92,18 @@ class HumanVerification extends Controller
}
public static function logCaptcha(Request $request){
$fail2banEnabled = config("metager.metager.fail2ban_enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !env("fail2banurl", false) || !env("fail2banuser") || !env("fail2banpassword")){
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")){
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => env("fail2banurl") . "/captcha/",
"url" => config("metager.metager.fail2ban.url") . "/captcha/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => env("fail2banuser"),
"password" => env("fail2banpassword"),
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => $request->ip()
],
......@@ -132,7 +132,7 @@ class HumanVerification extends Controller
{
$url = base64_decode(str_replace("<<SLASH>>", "/", $url));
# If the user is correct and the password is we will delete any entry in the database
$requiredPass = md5($mm . Carbon::NOW()->day . $url . env("PROXY_PASSWORD"));
$requiredPass = md5($mm . Carbon::NOW()->day . $url . config("metager.metager.proxy.password"));
if (HumanVerification::checkId($request, $mm) && $requiredPass === $password) {
HumanVerification::removeUser($request, $mm);
......@@ -335,7 +335,7 @@ class HumanVerification extends Controller
* If someone that uses a bot finds this out we
* might have to change it at some point.
*/
if ($request->filled('password') || $request->filled('key') || Cookie::get('key') !== null || $request->filled('appversion') || !env('BOT_PROTECTION', false)) {
if ($request->filled('password') || $request->filled('key') || Cookie::get('key') !== null || $request->filled('appversion') || !config('metager.metager.botprotection.enabled')) {
$update = false;
return $next($request);
}
......
......@@ -98,7 +98,7 @@ class KeyController extends Controller
$format = "Y-m-d H:i:s";
$data = [
"validUntil" => $validUntil->format($format),
"password" => hash_hmac("sha256", $validUntil->format($format), env("APP_KEY", "WEAK_KEY")),
"password" => hash_hmac("sha256", $validUntil->format($format), config("app.key")),
];
$targetUrl = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('changeKeyTwo', $data));
$redirUrl = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('removeCookie', [
......@@ -129,7 +129,7 @@ class KeyController extends Controller
}
if($valid){
// Check if hash matches
$expectedHash = hash_hmac("sha256", $validUntil->format($format), env("APP_KEY", "WEAK_KEY"));
$expectedHash = hash_hmac("sha256", $validUntil->format($format), config("app.key"));
if(!hash_equals($expectedHash, $password)){
$valid = false;
}
......@@ -174,7 +174,7 @@ class KeyController extends Controller
}
if($valid){
// Check if hash matches
$expectedHash = hash_hmac("sha256", $validUntil->format($format), env("APP_KEY", "WEAK_KEY"));
$expectedHash = hash_hmac("sha256", $validUntil->format($format), config("app.key"));
if(!hash_equals($expectedHash, $password)){
$valid = false;
}
......@@ -189,7 +189,7 @@ class KeyController extends Controller
if($validator->fails()) {
$data = [
"validUntil" => $validUntil->format($format),
"password" => hash_hmac("sha256", $validUntil->format($format), env("APP_KEY", "WEAK_KEY")),
"password" => hash_hmac("sha256", $validUntil->format($format), config("app.key")),
"newkey" => $request->input('newkey', ''),
];
$targetUrl = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('changeKeyTwo', $data));
......@@ -215,7 +215,7 @@ class KeyController extends Controller
}
$data = [
"validUntil" => $validUntil->format($format),
"password" => hash_hmac("sha256", $validUntil->format($format), env("APP_KEY", "WEAK_KEY")),
"password" => hash_hmac("sha256", $validUntil->format($format), config("app.key")),
];
$targetUrl = LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('changeKeyTwo', $data));
return redirect($targetUrl);
......
......@@ -93,12 +93,12 @@ class MailController extends Controller
$mission = [
"resulthash" => $resulthash,
"url" => env("TICKET_URL", "https://metager.de"),
"url" => config("metager.metager.ticketsystem.url"),
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => null,
"password" => null,
"headers" => [
"X-API-Key" => env("TICKET_APIKEY", ""),
"X-API-Key" => config("metager.metager.ticketsystem.apikey"),
"Content-Type" => "application/json",
"Content-Length" => strlen($postdata)
],
......@@ -121,7 +121,7 @@ class MailController extends Controller
// Fehlerfall
if(empty($answer) || (is_array($answer) && sizeof($answer) === 2 && $answer[1] === "no-result")){
$messageType = "error";
$returnMessage = trans('kontakt.error.2', ["email" => env("MAIL_USERNAME", "support+46521@metager.de")]);
$returnMessage = trans('kontakt.error.2', ["email" => config("mail.mailers.smtp.username")]);
}else{
$returnMessage = trans('kontakt.success.1', ["email" => $replyTo]);
$messageType = "success";
......@@ -226,8 +226,8 @@ class MailController extends Controller
$postdata = [
"entity" => "Contribution",
"action" => "mgcreate",
"api_key" => env("CIVICRM_API_KEY", ''),
"key" => env("CIVICRM_SITE_KEY", ''),
"api_key" => config("metager.metager.civicrm.apikey"),
"key" => config("metager.metager.civicrm.sitekey"),
"json" => 1,
"iban" => $iban->MachineFormat(),
"bic" => $bic,
......@@ -251,7 +251,7 @@ class MailController extends Controller
$mission = [
"resulthash" => $resulthash,
"url" => env("CIVICRM_URL", "https://metager.de"),
"url" => config("metager.metager.civicrm.url"),
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => null,
"password" => null,
......
......@@ -334,7 +334,7 @@ class MetaGerSearch extends Controller
public function tips(Request $request)
{
$tipserver = '';
if (env('APP_ENV') === "development") {
if (\App::environment() === "development") {
$tipserver = "https://dev.quicktips.metager.de/1.1/tips.xml";
} else {
$tipserver = "https://quicktips.metager.de/1.1/tips.xml";
......
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Log;
use Carbon;
class ServiceDesk extends Controller
{
private $accessToken = null;
private $apiUrl = "https://gitlab.metager.de/api/v4/projects";
public function webhook(Request $request)
{
// Validate Token match
$token = $request->header("X-Gitlab-Token");
if ($token !== env("gitlab_webhook_token", "")) {
Log::info("Webhook Action not taken. Token mismatch: " . $token);
return;
}
$this->accessToken = env("gitlab_access_token", "");
$event = json_decode($request->getContent(), true);
if ($event["user"]["username"] === "support-bot" && $event["issue"]["author_id"] === 301 && $event["issue"]["state"] === "closed") {
$closedAt = new Carbon($event["issue"]["closed_at"]);
$createdAt = new Carbon($event["object_attributes"]["created_at"]);
if ($createdAt->isAfter($closedAt)) {
// Reopen the issues
$getParameter = [
"state_event" => "reopen"
];
$url = $this->apiUrl . "/2/issues/" . $event["issue"]["iid"] . "?" . http_build_query($getParameter);
$response = file_get_contents($url, false, stream_context_create([
"http" => [
"method" => "PUT",
"header" => "Authorization: Bearer " . $this->accessToken . "\r\n"
]
]));
Log::info("reopened issue " . $event["issue"]["iid"]);
}
}
return response("");
}
}
......@@ -96,7 +96,7 @@ class StartpageController extends Controller
$link = "";
$password = "";
if ($request->filled('eingabe')) {
$password = getenv('berlin');
$password = config("metager.metager.keys.berlin");
$password = md5($request->input('eingabe') . " -host:userpage.fu-berlin.de" . $password);
$link = "/meta/meta.ger3?eingabe=" . $request->input('eingabe') . " -host:userpage.fu-berlin.de&focus=web&password=" . $password . "&encoding=utf8&lang=all&site=fu-berlin.de&quicktips=off&out=results-with-style";
}
......
......@@ -92,18 +92,18 @@ class BrowserVerification
}
public static function logBrowserverification(Request $request) {
$fail2banEnabled = config("metager.metager.fail2ban_enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !env("fail2banurl", false) || !env("fail2banuser") || !env("fail2banpassword")){
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")){
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => env("fail2banurl") . "/browserverification/",
"url" => config("metager.metager.fail2ban.url") . "/browserverification/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => env("fail2banuser"),
"password" => env("fail2banpassword"),
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => $request->ip()
],
......
......@@ -48,7 +48,7 @@ class HumanVerification
*/
//use parameter for middleware to skip this when using associator
if (!env('BOT_PROTECTION', false) || app('App\Models\Key')->getStatus()) {
if (!config("metager.metager.botprotection.enabled") || app('App\Models\Key')->getStatus()) {
$update = false;
return $next($request);
}
......
......@@ -20,7 +20,7 @@ class LocalizationRedirect
$host = $request->getHttpHost();
// We only redirect to the TLDs in the production version and exclude our onion domain
if (env("APP_ENV", "") !== "production" || $host === "metagerv65pwclop2rsfzg4jwowpavpwd6grhhlvdgsswvo6ii4akgyd.onion" || $request->is('metrics')) {
if (\App::environment() !== "production" || $host === "metagerv65pwclop2rsfzg4jwowpavpwd6grhhlvdgsswvo6ii4akgyd.onion" || $request->is('metrics')) {
return $next($request);
}
......
......@@ -30,18 +30,18 @@ class LogFailedAuthenticationAttempt
{
// Authentication failed Let's log the user
$fail2banEnabled = config("metager.metager.fail2ban_enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !env("fail2banurl", false) || !env("fail2banuser") || !env("fail2banpassword")){
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if(empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")){
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => env("fail2banurl") . "/mgadmin/",
"url" => config("metager.metager.fail2ban.url") . "/mgadmin/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => env("fail2banuser"),
"password" => env("fail2banpassword"),
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => Request::ip()
],
......
......@@ -450,9 +450,9 @@ class MetaGer
foreach ($results as $result) {
$link = $result->link;
$day = Carbon::now()->day;
$pw = md5($this->verificationId . $day . $link . env("PROXY_PASSWORD"));
$pw = md5($this->verificationId . $day . $link . config("metager.metager.proxy.password"));
$url = route('humanverification', ['mm' => $this->verificationId, 'pw' => $pw, "url" => urlencode(str_replace("/", "<<SLASH>>", base64_encode($link)))]);
$proxyPw = md5($this->verificationId . $day . $result->proxyLink . env("PROXY_PASSWORD"));
$proxyPw = md5($this->verificationId . $day . $result->proxyLink . config("metager.metager.proxy.password"));
$proxyUrl = route('humanverification', ['mm' => $this->verificationId, 'pw' => $proxyPw, "url" => urlencode(str_replace("/", "<<SLASH>>", base64_encode($result->proxyLink)))]);
$result->link = $url;
$result->proxyLink = $proxyUrl;
......@@ -1012,7 +1012,7 @@ class MetaGer
} else {
$this->newtab = "_self";
}
if ($request->filled("key") && $request->input('key') === getenv("mainz_key")) {
if ($request->filled("key") && $request->input('key') === config("metager.metager.keys.uni_mainz")) {
$this->newtab = "_blank";
}
# Theme
......@@ -1513,9 +1513,9 @@ class MetaGer
$logEntry = preg_replace("/\n+/", " ", $logEntry);
if (env("REDIS_CACHE_DRIVER", "redis") === "redis") {
if (config("database.redis.cache.driver", "redis") === "redis") {
Redis::connection('cache')->rpush(\App\Console\Commands\AppendLogs::LOGKEY, $logEntry);
} elseif (env("REDIS_CACHE_DRIVER", "redis") === "redis-sentinel") {
} elseif (config("database.redis.cache.driver", "redis") === "redis-sentinel") {
RedisSentinel::connection('cache')->rpush(\App\Console\Commands\AppendLogs::LOGKEY, $logEntry);
}
} catch (\Exception $e) {
......
......@@ -38,8 +38,8 @@ class Adgoal
public function __construct(&$metager)
{
$this->startTime = microtime(true);
$publicKey = getenv('adgoal_public');
$privateKey = getenv('adgoal_private');
$publicKey = config("metager.metager.adgoal.public_key");
$privateKey = config("metager.metager.adgoal.private_key");
if ($publicKey === false) {
return true;
}
......
......@@ -53,7 +53,7 @@ class Admitad
$this->hash = md5($requestData);
$url = "https://direct.metager.de/check";
$token = env("ADMITAD_TOKEN", "");
$token = config("metager.metager.admitad.token");
// Submit fetch job to worker
$mission = [
......
......@@ -18,7 +18,7 @@ class Key
{
$this->key = $key;
$this->status = $status;
if (getenv("APP_ENV") !== "production") {
if (\App::environment() !== "production") {
$this->keyserver = "https://dev.key.metager.de/";
}
}
......@@ -30,15 +30,15 @@ class Key
$this->updateStatus();
if($this->status === null){
// The user provided an invalid key which we will log to fail2ban
$fail2banEnabled = config("metager.metager.fail2ban_enabled");
if (!empty($fail2banEnabled) && $fail2banEnabled && !empty(env("fail2banurl", false)) && !empty(env("fail2banuser")) && !empty(env("fail2banpassword"))) {
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if (!empty($fail2banEnabled) && $fail2banEnabled && !config("metager.metager.fail2ban.url") && !config("metager.metager.fail2ban.user") && !config("metager.metager.fail2ban.password")) {
// Submit fetch job to worker
$mission = [
"resulthash" => "captcha",
"url" => env("fail2banurl") . "/mgkeytry/",
"url" => config("metager.metager.fail2ban.url") . "/mgkeytry/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => env("fail2banuser"),
"password" => env("fail2banpassword"),
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => Request::ip()
],
......@@ -55,7 +55,7 @@ class Key
public function updateStatus()
{
$authKey = base64_encode(env("KEY_USER", "test") . ':' . env("KEY_PASSWORD", "test"));
$authKey = base64_encode(config("metager.metager.keyserver.user") . ':' . config("metager.metager.keyserver.password"));
$opts = array(
'http' => array(
......@@ -86,7 +86,7 @@ class Key
public function requestPermission()
{
$authKey = base64_encode(env("KEY_USER", "test") . ':' . env("KEY_PASSWORD", "test"));
$authKey = base64_encode(config("metager.metager.keyserver.user") . ':' . config("metager.metager.keyserver.password"));
$postdata = http_build_query(array(
'dummy' => 0,
));
......@@ -118,7 +118,7 @@ class Key
}
public function generateKey($payment = null, $adFreeSearches = null, $key = null, $notes = "")
{
$authKey = base64_encode(env("KEY_USER", "test") . ':' . env("KEY_PASSWORD", "test"));
$authKey = base64_encode(config("metager.metager.keyserver.user") . ':' . config("metager.metager.keyserver.password"));
$postdata = array(
'apiAccess' => 'normal',
'expiresAfterDays' => 365,
......@@ -160,7 +160,7 @@ class Key
}