public static function get() { $driver = Config::get('queue', 'driver'); $provider = Config::get('queue', 'connections.' . $driver . '.class'); $provider = new $provider(); return $provider; }
/** * ### Pushes a job to the failed array * * @param $job */ public function failJob($job) { $prefix = Config::get('queue', 'failed_prefix'); $now = new \DateTime(); $id = $prefix . $now->format('Y-m-d_H:i:s') . microtime(); $this->connection->set($id, $job); }
/** * ### Creates a new driver instance * * @return FileCacheProvider|FileCacheProvider|null */ private static function driver() { if (!isset(self::$driver)) { $driver = Config::get('cache', 'driver'); } else { $driver = self::$driver; } $class = Config::get('cache', 'providers.' . $driver . '.class'); $class = new $class(); return $class; }
/** * ### Gets the driver instance * * @return DBAuthProvider|mixed */ public static function driver() { if (!isset(self::$driver)) { $driver = Config::get('auth', 'driver'); } else { $driver = self::$driver; } $provider = Config::get('auth', 'providers.' . $driver . '.class'); $provider = new $provider(); return $provider; }
public function __construct($message, $code = 500, Exception $previous = null, $traits = []) { parent::__construct($message, $code, $previous); $this->registerLogging(); $txt = $message . ' in ' . parent::getFile() . ':' . parent::getLine() . "\n" . $this->generateBacktrace(); $this->exceptionLog($txt); if (Config::get('app', 'debug') == 1) { $this->setErrorTraits($traits); } else { die('Whoops, looks like we encountered an error!'); } }
/** * ### Initialises a session, sets the cookie parameters * ### and generates a CSRF-Token */ private function initSession() { $lifetime = 60 * Config::get('auth', 'session_lifetime'); $hostname = Config::get('app', 'hostname'); if (filter_var($hostname, FILTER_VALIDATE_IP)) { $cookie_host = $hostname; } else { $cookie_host = '.' . $hostname; } ini_set('session.cookie_lifetime', $lifetime); session_set_cookie_params($lifetime, '/', $cookie_host, false); session_start(); if (!isset($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = hash("sha512", mt_rand(0, mt_getrandmax())); } if (!isset($_SESSION['blivy_redirect']) || $_SESSION['blivy_redirect'] !== true) { if (isset($_SESSION['flash'])) { unset($_SESSION['flash']); } } else { unset($_SESSION['blivy_redirect']); } }
/** * ### Sets the protcol to be used by PHPMailer * * @param string $protocol */ private function protocol($protocol) { switch ($protocol) { case 'smtp': if (Config::get('mail', 'username')) { $this->mailer->SMTPAuth = true; } else { $this->mailer->SMTPAuth = false; } $this->mailer->isSMTP(); break; case 'php': $this->mailer->isSendmail(); break; default: if (Config::get('mail', 'username')) { $this->mailer->SMTPAuth = true; } else { $this->mailer->SMTPAuth = false; } $this->mailer->isSMTP(); } }
<?php /** * @author Jan Foerste <*****@*****.**> */ return ['driver' => env('CACHE_DRIVER', 'file'), 'providers' => ['redis' => ['class' => '\\Blivy\\Cache\\RedisCacheProvider', 'server' => \Blivy\Support\Config::get('database', 'connections.redis')], 'file' => ['class' => '\\Blivy\\Cache\\FileCacheProvider']], 'key_prefix' => 'cache_'];
/** * ### Flushes the map and removes all cache files * * @return bool * @throws Exception */ public function flush() { file_put_contents(filecachedir() . 'cachemap', '{}'); $files = glob(filecachedir() . Config::get('cache', 'key_prefix') . '*', GLOB_BRACE); foreach ($files as $file) { $this->writable($file); unlink($file); } return true; }
/** * ### Checks if remmeber token can auth user * * @return bool */ private static function attemptWithToken() { if (!isset($_COOKIE['remember_token'])) { return false; } $token = $_COOKIE['remember_token']; $explode = explode('.', $token); $model = Config::get('auth', 'providers.db.auth_model'); $query = new $model(); $find = $query->findPk($explode[0]); if (!$find) { return false; } $stored = $find->getRemember(); if (!$stored || $stored !== $explode[1]) { return false; } $_SESSION['logged_in'] = true; $_SESSION['userdata'] = $find; return true; }
/** * ### Prints the help */ public function handle() { echo "Welcome to the Blivy command line interface.\n"; echo "This tool can handle pre-installed and custom commands.\n"; echo "To find out how to customize it, check out our wiki:\n"; echo "https://github.com/JanFoerste/blivy/wiki\n\n"; echo "The following commands are available:\n\n"; $padding = 15; $commands = Config::get('console', 'commands'); foreach ($commands as $command => $conf) { $sp = $padding - strlen($command); $pad = $sp > 0 ? str_repeat(' ', $sp) : ' '; echo $command . $pad . '=> ' . $conf['description'] . "\n"; } }
/** * ### Returns the value belonging to the given key * * @param string $key * @return mixed */ public function get($key) { $prefix = Config::get('cache', 'key_prefix'); return unserialize($this->conn->get($prefix . $key)); }