コード例 #1
0
ファイル: Multisite.php プロジェクト: tobiasziegler/platform
 protected function parseHost($host)
 {
     if (!$this->domain && !$this->subdomain) {
         // Load the default domain
         $domain = Kohana::$config->load('multisite.domain');
         // If no host passed in, check the for HOST in environment
         if (!$host) {
             $host = getenv('HOST');
         }
         // If we still don't have a host
         if (!$host) {
             // .. parse the current URL
             $url = Url::createFromServer($_SERVER);
             // .. and grab the host
             $host = $url->getHost()->toUnicode();
         }
         // If $domain is set and we're at a subdomain of $domain..
         if ($domain and substr($host, strlen($domain) * -1) == $domain) {
             // .. grab just the subdomain
             $subdomain = substr($host, 0, strlen($domain) * -1 - 1);
         } else {
             // .. otherwise grab the whole domain
             $domain = $host;
             $subdomain = '';
         }
         $this->domain = $domain;
         $this->subdomain = $subdomain;
     }
 }
コード例 #2
0
ファイル: FactoryTest.php プロジェクト: subtonix/aouka_lunch
 public function testCreateFromServerWithoutRequestUri()
 {
     $server = array('PHP_SELF' => '/toto?foo=bar', 'SERVER_ADDR' => '127.0.0.1', 'HTTPS' => 'on', 'SERVER_PROTOCOL' => 'HTTP', 'SERVER_PORT' => 23);
     $url = Url::createFromServer($server);
     $this->assertSame('https://127.0.0.1:23/toto?foo=bar', (string) $url);
     $server = array('SERVER_ADDR' => '127.0.0.1', 'HTTPS' => 'on', 'SERVER_PROTOCOL' => 'HTTP', 'SERVER_PORT' => 23);
     $url = Url::createFromServer($server);
     $this->assertSame('https://127.0.0.1:23/', (string) $url);
 }
コード例 #3
0
ファイル: TokenFactory.php プロジェクト: eamador/Payum
 /**
  * @param StorageInterface         $tokenStorage
  * @param StorageRegistryInterface $storageRegistry
  * @param string                   $baseUrl
  */
 public function __construct(StorageInterface $tokenStorage, StorageRegistryInterface $storageRegistry, $baseUrl = null)
 {
     parent::__construct($tokenStorage, $storageRegistry);
     if ($baseUrl) {
         $this->baseUrl = $baseUrl;
     } else {
         $this->baseUrl = Url::createFromServer($_SERVER)->getBaseUrl();
     }
 }
コード例 #4
0
ファイル: Controller.php プロジェクト: GetHobbit/Philo_Unity
 /**
  * Génère l'URL correspondant à une route nommée
  * @param  string $routeName Le nom de route
  * @param  mixed  $params    Tableau de paramètres optionnel de cette route
  * @param  boolean $absolute Retourne une url absolue si true (relative si false)
  * @return L'URL correspondant à la route
  */
 public static function generateUrl($routeName, $params = array(), $absolute = false)
 {
     $params = empty($params) ? array() : $params;
     $app = getApp();
     $router = $app->getRouter();
     $routeUrl = $router->generate($routeName, $params);
     $url = $routeUrl;
     if ($absolute) {
         $u = \League\Url\Url::createFromServer($_SERVER);
         $url = $u->getBaseUrl() . $routeUrl;
     }
     return $url;
 }
コード例 #5
0
ファイル: Mailer.php プロジェクト: gjorgiev/platform
 protected function send_resetpassword($to, $params)
 {
     $site_name = Kohana::$config->load('site.name');
     $site_email = Kohana::$config->load('site.email');
     $multisite_email = Kohana::$config->load('multisite.email');
     $client_url = Kohana::$config->load('site.client_url');
     // @todo make this more robust
     if ($multisite_email) {
         $from_email = $multisite_email;
     } elseif ($site_email) {
         $from_email = $site_email;
     } else {
         $url = Url::createFromServer($_SERVER);
         $host = $url->getHost()->toUnicode();
         $from_email = 'noreply@' . $host;
     }
     $view = View::factory('email/forgot-password');
     $view->site_name = $site_name;
     $view->token = $params['token'];
     $view->client_url = $client_url;
     $message = $view->render();
     $subject = $site_name . ': Password reset';
     $email = Email::factory($subject, $message, 'text/html')->to($to)->from($from_email, $site_name)->send();
 }
コード例 #6
0
ファイル: Multisite.php プロジェクト: nolanglee/platform
 public function getDbConfig($host = NULL)
 {
     // Load the default domain
     $domain = Kohana::$config->load('multisite.domain');
     // If no host passed in, check the for HOST in environment
     if (!$host) {
         $host = getenv('HOST');
     }
     // If we still don't have a host
     if (!$host) {
         // .. parse the current URL
         $url = Url::createFromServer($_SERVER);
         // .. and grab the host
         $host = $url->getHost()->toUnicode();
     }
     // If $domain is set and we're at a subdomain of $domain..
     if ($domain and substr_compare($host, $domain, strlen($domain) * -1) !== FALSE) {
         // .. grab just the subdomain
         $subdomain = substr($host, 0, strlen($domain) * -1 - 1);
     } else {
         // .. otherwise grab the whole domain
         $domain = $host;
         $subdomain = '';
     }
     // .. and find the current deployment credentials
     $result = DB::select()->from('deployments')->where('subdomain', '=', $subdomain)->where('domain', '=', $domain)->limit(1)->offset(0)->execute($this->db);
     $deployment = $result->current();
     // No deployment? throw a 404
     if (!count($deployment)) {
         throw new HTTP_Exception_404("Deployment not found");
     }
     // Set new database config
     $config = Kohana::$config->load('database')->default;
     $config['connection'] = ['hostname' => $deployment['dbhost'], 'database' => $deployment['dbname'], 'username' => $deployment['dbuser'], 'password' => $deployment['dbpassword'], 'persistent' => $config['connection']['persistent']];
     return $config;
 }
コード例 #7
0
ファイル: Request.php プロジェクト: jwslink/restfulapi
 /**
  * Set Default Uri
  *
  * @return void
  */
 protected function setDefaultUri()
 {
     $this->uri = Url::createFromServer($_SERVER);
 }
コード例 #8
0
ファイル: App.php プロジェクト: mizzencms/core
 /**
  * @todo redo
  * @param  Directory $basePath
  */
 public function init(\Directory $basePath)
 {
     /**
      * @todo  create a default bag and only override if something 
      * special needed
      */
     $bag = Container::getInstance();
     $bag->add('basePath', function () use($basePath) {
         return $basePath;
     });
     /**
      * @todo  move to config class and create a set up
      */
     $bag->add('config', function () use($basePath) {
         $configPath = $basePath->path . '/config/config.json';
         if (is_readable($configPath)) {
             $config = ArrayHelper::configArrayToObject(json_decode(file_get_contents($configPath), true));
             if (!isset($config->baseDir)) {
                 $config->baseDir = '';
             }
         } else {
             $config = new \StdClass();
             $config->url = isset($_SERVER['SERVER_NAME']) ? 'http://' . $_SERVER['SERVER_NAME'] . '/' : 'http://mizzencms.net/';
             $config->siteName = 'MizzenLite';
             $config->baseDir = '';
         }
         return $config;
     });
     $bag->add('url', function () use($bag) {
         $url = Url::createFromServer($_SERVER);
         /**
          * Remove index.php if exists
          */
         $url->getPath()->remove('index.php');
         /**
          * remove base dir (for when we are installed in a dir)
          */
         if (!empty($bag->get('config')->baseDir)) {
             $url->getPath()->remove($bag->get('config')->baseDir);
         }
         /**
          * home needs to be converted to index
          */
         if ((string) $url->getPath() === '') {
             $url->setPath('index');
         }
         return $url;
     });
     $bag->add('metaParser', function () {
         return new MetaParser();
     });
     $bag->add('pageRepository', function () {
         $prp = new PageRepositoryGenerator(new PageRepository(), new Finder());
         $prp->populateRepository();
         return $prp->getPageRepository();
     });
     $bag->add('navigation', function () {
         return (new Navigation())->createPageMenu();
     });
     $bag->add('eventManager', function () {
         return new EventManager();
     });
     $bag->add('view', function () {
         return new View();
     });
 }
コード例 #9
0
ファイル: index.php プロジェクト: rohanabraham/lxHive
    // Add config
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.production.yml');
    // Set up logging
    $logger = new Logger\MonologWriter(['handlers' => [new StreamHandler($appRoot . '/storage/logs/production.' . date('Y-m-d') . '.log')]]);
    $app->config('log.writer', $logger);
});
// Only invoked if mode is "development"
$app->configureMode('development', function () use($app, $appRoot) {
    // Add config
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.development.yml');
    // Set up logging
    $logger = new Logger\MonologWriter(['handlers' => [new StreamHandler($appRoot . '/storage/logs/development.' . date('Y-m-d') . '.log')]]);
    $app->config('log.writer', $logger);
});
if (PHP_SAPI !== 'cli') {
    $app->url = Url::createFromServer($_SERVER);
}
// Error handling
$app->error(function (\Exception $e) {
    $code = $e->getCode();
    if ($code < 100) {
        $code = 500;
    }
    Resource::error($code, $e->getMessage());
});
// Database layer setup
$app->hook('slim.before', function () use($app) {
    $app->container->singleton('mongo', function () use($app) {
        $client = new Client($app->config('database')['host_uri']);
        $client->map([$app->config('database')['db_name'] => '\\API\\Collection']);
        $client->useDatabase($app->config('database')['db_name']);
コード例 #10
0
ファイル: bootstrap.php プロジェクト: kunal981/php-oauth
<?php

/**
 * Bootstrap the library
 */
require_once __DIR__ . '/../vendor/autoload.php';
/**
 * Setup error reporting
 */
error_reporting(E_ALL);
ini_set('display_errors', 1);
/**
 * Setup the timezone
 */
ini_set('date.timezone', 'Europe/Amsterdam');
/**
 * Create a new instance of the URL class with the current URI, stripping the query string
 */
$currentUri = \League\Url\Url::createFromServer($_SERVER);
$currentUri->setQuery('');
function inline_image($rawData)
{
    return '<img src="' . 'data:image/' . Gregwar\Image\Image::fromData($rawData)->guessType() . ';' . 'base64,' . base64_encode($rawData) . '">';
}
/**
 * Load the credential for the different services
 */
require_once __DIR__ . '/init.php';
コード例 #11
0
ファイル: site.php プロジェクト: tobiasziegler/platform
defined('SYSPATH') or die('No direct access allowed.');
/**
 * Kohana Site Config
 *
 * @author     Ushahidi Team <*****@*****.**>
 * @package    Ushahidi\Application\Config
 * @copyright  2013 Ushahidi
 * @license    https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
 */
/**
 * Site settings
 *
 * The following options are available:
 *
 * - string   name          Display name of the site.
 * - string   description   A brief description of the site.
 * - string   email         Site contact email.
 * - string   timezone      Default timezone for the site. See http://php.net/manual/en/timezones.php
 * - string   language      Native language for the site in ISO 639-1 format. See http://en.wikipedia.org/wiki/ISO_639-1
 * - string   date_format   Set format in which to return dates. See http://php.net/manual/en/datetime.createfromformat.php
 */
$clientUrl = getenv('CLIENT_URL');
if (!empty(getenv("MULTISITE_DOMAIN"))) {
    try {
        $host = \League\Url\Url::createFromServer($_SERVER)->getHost()->toUnicode();
        $clientUrl = str_replace(getenv("MULTISITE_DOMAIN"), getenv("MULTISITE_CLIENT_DOMAIN"), $host);
    } catch (Exception $e) {
    }
}
return array('name' => '', 'description' => '', 'email' => '', 'timezone' => 'UTC', 'language' => 'en-US', 'date_format' => 'n/j/Y', 'client_url' => $clientUrl ?: false, 'first_login' => true, 'tier' => 'free', 'private' => false);