当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Url::Domain方法代码示例

本文整理汇总了PHP中Gdn_Url::Domain方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Url::Domain方法的具体用法?PHP Gdn_Url::Domain怎么用?PHP Gdn_Url::Domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Url的用法示例。


在下文中一共展示了Gdn_Url::Domain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: WebRoot

 /**
  * Returns the path to the application's dispatcher. Optionally with the
  * domain prepended.
  *  ie. http://domain.com/[web_root]/index.php/request
  *
  * @param boolean $WithDomain Should it include the domain with the WebRoot? Default is FALSE.
  * @return string
  */
 public static function WebRoot($WithDomain = FALSE)
 {
     static $WebRoot = NULL;
     if (is_null($WebRoot)) {
         // Attempt to get the webroot from the configuration array
         $WebRoot = Gdn::Config('Garden.WebRoot');
         // Attempt to get the webroot from the server
         if ($WebRoot === FALSE) {
             $WebRoot = explode('/', ArrayValue('PHP_SELF', $_SERVER, ''));
             // Look for index.php to figure out where the web root is.
             $Key = array_search('index.php', $WebRoot);
             if ($Key !== FALSE) {
                 $WebRoot = implode('/', array_slice($WebRoot, 0, $Key));
             } else {
                 $WebRoot = '';
             }
         }
     }
     if (is_string($WebRoot) && $WebRoot != '') {
         // Strip forward slashes from the beginning of webroot
         return ($WithDomain ? Gdn_Url::Domain() : '') . preg_replace('/(^\\/+)/', '', $WebRoot);
     } else {
         return $WithDomain ? Gdn_Url::Domain() : '';
     }
 }
开发者ID:Aetasiric,项目名称:Garden,代码行数:33,代码来源:class.url.php

示例2: Configure

 /**
  * Allows the configuration of basic setup information in Garden. This
  * should not be functional after the application has been set up.
  */
 public function Configure($RedirectUrl = '')
 {
     $Config = Gdn::Factory(Gdn::AliasConfig);
     $ConfigFile = PATH_CONF . DS . 'config.php';
     // Create a model to save configuration settings
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel('Configuration', $ConfigFile, $Validation);
     $ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password'));
     // Set the models on the forms.
     $this->Form->SetModel($ConfigurationModel);
     // Load the locales for the locale dropdown
     // $Locale = Gdn::Locale();
     // $AvailableLocales = $Locale->GetAvailableLocaleSources();
     // $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales);
     // If seeing the form for the first time...
     if (!$this->Form->IsPostback()) {
         // Force the webroot using our best guesstimates
         $ConfigurationModel->Data['Database.Host'] = 'localhost';
         $this->Form->SetData($ConfigurationModel->Data);
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->AddRule('Connection', 'function:ValidateConnection');
         $ConfigurationModel->Validation->ApplyRule('Database.Name', 'Connection');
         $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
         $ConfigurationFormValues = $this->Form->FormValues();
         if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE) {
             // Apply the validation results to the form(s)
             $this->Form->SetValidationResults($ConfigurationModel->ValidationResults());
         } else {
             $Host = Gdn_Url::Host();
             $Domain = Gdn_Url::Domain();
             // Set up cookies now so that the user can be signed in.
             $ConfigurationFormValues['Garden.Cookie.Salt'] = RandomString(10);
             $ConfigurationFormValues['Garden.Cookie.Domain'] = strpos($Host, '.') === FALSE ? '' : $Host;
             // Don't assign the domain if it is a non .com domain as that will break cookies.
             $ConfigurationModel->Save($ConfigurationFormValues);
             // If changing locale, redefine locale sources:
             $NewLocale = 'en-CA';
             // $this->Form->GetFormValue('Garden.Locale', FALSE);
             if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) {
                 $ApplicationManager = new Gdn_ApplicationManager();
                 $PluginManager = Gdn::Factory('PluginManager');
                 $Locale = Gdn::Locale();
                 $Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), $PluginManager->EnabledPluginFolders(), TRUE);
             }
             // Set the instantiated config object's db params and make the database use them (otherwise it will use the default values from conf/config-defaults.php).
             $Config->Set('Database.Host', $ConfigurationFormValues['Database.Host']);
             $Config->Set('Database.Name', $ConfigurationFormValues['Database.Name']);
             $Config->Set('Database.User', $ConfigurationFormValues['Database.User']);
             $Config->Set('Database.Password', $ConfigurationFormValues['Database.Password']);
             $Config->ClearSaveData();
             Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_Database', PATH_LIBRARY . DS . 'database' . DS . 'class.database.php', Gdn::FactorySingleton, array(Gdn::Config('Database')));
             // Install db structure & basic data.
             $Database = Gdn::Database();
             $Drop = FALSE;
             // Gdn::Config('Garden.Version') === FALSE ? TRUE : FALSE;
             $Explicit = FALSE;
             try {
                 include PATH_APPLICATIONS . DS . 'garden' . DS . 'settings' . DS . 'structure.php';
             } catch (Exception $ex) {
                 $this->Form->AddError(strip_tags($ex->getMessage()));
             }
             if ($this->Form->ErrorCount() > 0) {
                 return FALSE;
             }
             // Create the administrative user
             $UserModel = Gdn::UserModel();
             $UserModel->DefineSchema();
             $UserModel->Validation->ApplyRule('Name', 'Username', 'Admin username can only contain letters, numbers, and underscores.');
             $UserModel->Validation->ApplyRule('Password', 'Required');
             $UserModel->Validation->ApplyRule('Password', 'Match');
             if (!$UserModel->SaveAdminUser($ConfigurationFormValues)) {
                 $this->Form->SetValidationResults($UserModel->ValidationResults());
             } else {
                 // The user has been created successfully, so sign in now
                 $Authenticator = Gdn::Authenticator();
                 $AuthUserID = $Authenticator->Authenticate(array('Name' => $this->Form->GetValue('Name'), 'Password' => $this->Form->GetValue('Password'), 'RememberMe' => TRUE));
             }
             if ($this->Form->ErrorCount() > 0) {
                 return FALSE;
             }
             // Assign some extra settings to the configuration file if everything succeeded.
             $ApplicationInfo = array();
             include CombinePaths(array(PATH_APPLICATIONS . DS . 'garden' . DS . 'settings' . DS . 'about.php'));
             $Config->Load($ConfigFile, 'Save');
             $Config->Set('Garden.Version', ArrayValue('Version', ArrayValue('Garden', $ApplicationInfo, array()), 'Undefined'));
             $Config->Set('Garden.WebRoot', Gdn_Url::WebRoot());
             $Config->Set('Garden.RewriteUrls', function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) ? TRUE : FALSE);
             $Config->Set('Garden.Domain', $Domain);
             $Config->Set('Garden.CanProcessImages', function_exists('gd_info'));
             $Config->Set('Garden.Messages.Cache', 'arr:["Garden\\/Settings\\/Index"]');
             // Make sure that the "welcome" message is cached for viewing
             $Config->Set('EnabledPlugins.HTMLPurifier', 'HtmlPurifier');
             // Make sure html purifier is enabled so html has a default way of being safely parsed
             $Config->Save();
         }
//.........这里部分代码省略.........
开发者ID:Valooo,项目名称:Garden,代码行数:101,代码来源:gardensetup.php


注:本文中的Gdn_Url::Domain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。