Exemplo n.º 1
0
 /**
  * Standalone installation function.  Installs given modules with given configuration
  *
  */
 public static function install(array $modules = null, array $configuration = [])
 {
     if ($modules == null) {
         $modules = self::getLoadedModules();
     }
     $missingModules = [];
     foreach ($modules as $path) {
         if (!is_dir($path)) {
             $missingModules[] = $path;
         }
     }
     if ($missingModules) {
         $error = "The following modules are missing:\n";
         $error .= implode("\n", $missingModules);
         trigger_error($error, E_USER_ERROR);
     }
     foreach ($modules as $path) {
         self::loadConfiguration($path);
     }
     Configuration::set($configuration);
     foreach ($modules as $path) {
         self::runInitialization($path);
     }
     /* Run installation scripts */
     $installers = [];
     foreach ($modules as $path) {
         $installer = new Installer($path);
         $installer->install();
         $installers[] = $installer;
     }
     /* Step 4: run all modules postInstallation */
     foreach ($installers as $installer) {
         $installer->finalize();
     }
 }
Exemplo n.º 2
0
<?php

use Phidias\Oauth\Token;
use Phidias\Utilities\Configuration;
Token::setSecret(Configuration::get("phidias.oauth.secret"));
Exemplo n.º 3
0
 private static function getTokenFromGoogleAuthorizationCode($code)
 {
     $userInfoUrl = "https://www.googleapis.com/oauth2/v4/token";
     $parameters = ["code" => $code, "client_id" => Configuration::get("phidias.oauth.google.client_id"), "client_secret" => Configuration::get("phidias.oauth.google.client_secret"), "redirect_uri" => Configuration::get("phidias.oauth.google.redirect_uri"), "grant_type" => "authorization_code"];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $userInfoUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($parameters));
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters));
     $response = curl_exec($ch);
     curl_close($ch);
     $responseData = json_decode($response);
     if (!isset($responseData->id_token)) {
         throw new Exception\InvalidRequest("google says: " . json_encode($responseData));
     }
     // Quick and dirty extraction of the token payload (following JWT specification)
     $tokenData = json_decode(base64_decode(explode(".", $responseData->id_token)[1]));
     if (!isset($tokenData->email)) {
         throw new Exception\InvalidRequest("could not obtain email from google token");
     }
     $payload = self::validateEmail($tokenData->email);
     return new Token("bearer", $payload);
 }
Exemplo n.º 4
0
<?php

use Phidias\Utilities\Configuration;
use Phidias\Db\Db;
// Obtain DB connection identifiers from configuration
Db::configure(function ($identifier = null) {
    $base = $identifier === null ? "phidias.db" : "phidias.db.{$identifier}";
    if (!Configuration::get("{$base}.host")) {
        return null;
    }
    return array("host" => Configuration::get("{$base}.host"), "username" => Configuration::get("{$base}.username"), "password" => Configuration::get("{$base}.password"), "database" => Configuration::get("{$base}.database"), "charset" => Configuration::get("{$base}.charset"));
});