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


PHP Gdn_Url::WebRoot方法代码示例

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


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

示例1: Comment

 public function Comment()
 {
     $Session = Gdn::Session();
     $this->Form->SetModel($this->ActivityModel);
     $NewActivityID = 0;
     if ($this->Form->AuthenticatedPostBack()) {
         $Body = $this->Form->GetValue('Body', '');
         $ActivityID = $this->Form->GetValue('ActivityID', '');
         if ($Body != '' && is_numeric($ActivityID) && $ActivityID > 0) {
             $NewActivityID = $this->ActivityModel->Add($Session->UserID, 'ActivityComment', $Body, '', $ActivityID, '', TRUE);
         }
     }
     // Redirect back to the sending location if this isn't an ajax request
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         Redirect($this->Form->GetValue('Return', Gdn_Url::WebRoot()));
     } else {
         // Load the newly added comment
         $this->Comment = $this->ActivityModel->GetID($NewActivityID);
         $this->Comment->ActivityType .= ' Hidden';
         // Hide it so jquery can reveal it
         // Set it in the appropriate view
         $this->View = 'comment';
         // And render
         $this->Render();
     }
 }
开发者ID:nbudin,项目名称:Garden,代码行数:26,代码来源:activity.php

示例2: Settings

 /**
  * Manage the current ranks and add new ones
  */
 public function Settings()
 {
     $this->Permission('Yaga.Ranks.Manage');
     $this->AddSideMenu('rank/settings');
     $this->Title(T('Yaga.Ranks.Manage'));
     // Get list of ranks from the model and pass to the view
     $this->SetData('Ranks', $this->RankModel->Get());
     if ($this->Form->IsPostBack() == TRUE) {
         // Handle the photo upload
         $Upload = new Gdn_Upload();
         $TmpImage = $Upload->ValidateUpload('PhotoUpload', FALSE);
         if ($TmpImage) {
             // Generate the target image name
             $TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS);
             $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
             // Save the uploaded image
             $Parts = $Upload->SaveAs($TmpImage, 'yaga' . DS . $ImageBaseName);
             $RelativeUrl = StringBeginsWith($Parts['Url'], Gdn_Url::WebRoot(TRUE), TRUE, TRUE);
             SaveToConfig('Yaga.Ranks.Photo', $RelativeUrl);
             if (C('Yaga.Ranks.Photo') == $Parts['SaveName']) {
                 $this->InformMessage(T('Yaga.Rank.PhotoUploaded'));
             }
         }
     }
     include_once $this->FetchViewLocation('helper_functions', 'rank');
     $this->Render();
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:30,代码来源:class.rankcontroller.php

示例3: Check

 public function Check($Type = '', $Name = '')
 {
     if ($Type != '' && $Name != '') {
         $this->AddItem($Type, $Name);
     }
     if (count($this->_Items) > 0) {
         // TODO: Use garden update check url instead of this:
         $UpdateUrl = Url('/lussumo/update', TRUE, TRUE);
         $Host = Gdn_Url::Host();
         $Path = CombinePaths(array(Gdn_Url::WebRoot(), 'lussumo', 'update'), '/');
         $Port = 80;
         /*
         $UpdateUrl = Gdn::Config('Garden.UpdateCheckUrl', '');
         $UpdateUrl = parse_url($UpdateUrl);
         $Host = ArrayValue('host', $UpdateUrl, 'www.lussumo.com');
         $Path = ArrayValue('path', $UpdateUrl, '/');
         $Port = ArrayValue('port', $UpdateUrl, '80');
         */
         $Path .= '?Check=' . urlencode(Format::Serialize($this->_Items));
         $Locale = Gdn::Config('Garden.Locale', 'Undefined');
         $Referer = Gdn_Url::WebRoot(TRUE);
         if ($Referer === FALSE) {
             $Referer = 'Undefined';
         }
         $Timeout = 10;
         $Response = '';
         // Connect to the update server.
         $Pointer = @fsockopen($Host, '80', $ErrorNumber, $Error, $Timeout);
         if (!$Pointer) {
             throw new Exception(sprintf(Gdn::Translate('Encountered an error when attempting to connect to the update server (%1$s): [%2$s] %3$s'), $UpdateUrl, $ErrorNumber, $Error));
         } else {
             // send the necessary headers to get the file
             fputs($Pointer, "GET {$Path} HTTP/1.0\r\n" . "Host: {$Host}\r\n" . "User-Agent: Lussumo Garden/1.0\r\n" . "Accept: */*\r\n" . "Accept-Language: " . $Locale . "\r\n" . "Accept-Charset: utf-8;\r\n" . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: {$Referer}\r\n\r\n");
             // Retrieve the response from the remote server
             while ($Line = fread($Pointer, 4096)) {
                 $Response .= $Line;
             }
             fclose($Pointer);
             // Remove response headers
             $Response = substr($Response, strpos($Response, "\r\n\r\n") + 4);
         }
         $Result = Format::Unserialize($Response);
         // print_r($Result);
         if (is_array($Result)) {
             $this->_Items = $Result;
         } else {
             $Result = FALSE;
         }
         return $Result;
     }
 }
开发者ID:kidmax,项目名称:Garden,代码行数:51,代码来源:class.updatemanager.php

示例4: Request

 /**
  * Returns the Request part of the current url. ie. "/controller/action/" in
  * "http://localhost/garden/index.php/controller/action/".
  *
  * @param boolean $WithWebRoot
  * @param boolean $WithDomain
  * @param boolean $RemoveSyndication
  * @return string
  */
 public static function Request($WithWebRoot = FALSE, $WithDomain = FALSE, $RemoveSyndication = FALSE)
 {
     $Return = '';
     // TODO: Test this on various platforms/browsers. Very breakable.
     // Try PATH_INFO
     $Request = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
     if ($Request) {
         $Return = $Request;
     }
     // Try ORIG_PATH_INFO
     if (!$Return) {
         $Request = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');
         if ($Request != '') {
             $Return = $Request;
         }
     }
     // Try with PHP_SELF
     if (!$Return) {
         $PhpSelf = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : @getenv('PHP_SELF');
         $ScriptName = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : @getenv('SCRIPT_NAME');
         if ($PhpSelf && $ScriptName) {
             $Return = substr($PhpSelf, strlen($ScriptName));
         }
     }
     $Return = trim($Return, '/');
     if (strcasecmp(substr($Return, 0, 9), 'index.php') == 0) {
         $Return = substr($Return, 9);
     }
     $Return = trim($Return, '/');
     if ($RemoveSyndication) {
         $Prefix = strtolower(substr($Return, 0, strpos($Return, '/')));
         if ($Prefix == 'rss') {
             $Return = substr($Return, 4);
         } else {
             if ($Prefix == 'atom') {
                 $Return = substr($Return, 5);
             }
         }
     }
     if ($WithWebRoot) {
         $WebRoot = Gdn_Url::WebRoot($WithDomain);
         if (substr($WebRoot, -1, 1) != '/') {
             $WebRoot .= '/';
         }
         $Return = $WebRoot . $Return;
     }
     return $Return;
 }
开发者ID:Aetasiric,项目名称:Garden,代码行数:57,代码来源:class.url.php

示例5: 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);
     // Create a model to save configuration settings
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($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->ApplyRule('Database.Name', 'Required', 'You must specify the name of the database in which you want to set up Vanilla.');
         // Let's make some user-friendly custom errors for database problems
         $DatabaseHost = $this->Form->GetFormValue('Database.Host', '~~Invalid~~');
         $DatabaseName = $this->Form->GetFormValue('Database.Name', '~~Invalid~~');
         $DatabaseUser = $this->Form->GetFormValue('Database.User', '~~Invalid~~');
         $DatabasePassword = $this->Form->GetFormValue('Database.Password', '~~Invalid~~');
         $ConnectionString = GetConnectionString($DatabaseName, $DatabaseHost);
         try {
             $Connection = new PDO($ConnectionString, $DatabaseUser, $DatabasePassword);
         } catch (PDOException $Exception) {
             switch ($Exception->getCode()) {
                 case 1044:
                     $this->Form->AddError(T('The database user you specified does not have permission to access the database. Have you created the database yet? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 1045:
                     $this->Form->AddError(T('Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 1049:
                     $this->Form->AddError(T('It appears as though the database you specified does not exist yet. Have you created it yet? Did you mistype the name? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                     break;
                 case 2005:
                     $this->Form->AddError(T("Are you sure you've entered the correct database host name? Maybe you mistyped it? The database reported: <code>%s</code>"), strip_tags($Exception->getMessage()));
                     break;
                 default:
                     $this->Form->AddError(sprintf(T('ValidateConnection'), strip_tags($Exception->getMessage())));
                     break;
             }
         }
         $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
         $ConfigurationFormValues = $this->Form->FormValues();
         if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE || $this->Form->ErrorCount() > 0) {
             // Apply the validation results to the form(s)
             $this->Form->SetValidationResults($ConfigurationModel->ValidationResults());
         } else {
             $Host = array_shift(explode(':', Gdn::Request()->RequestHost()));
             $Domain = Gdn::Request()->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 . 'dashboard' . 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', self::UsernameError);
             $UserModel->Validation->ApplyRule('Name', 'Required', T('You must specify an admin username.'));
             $UserModel->Validation->ApplyRule('Password', 'Required', T('You must specify an admin password.'));
//.........这里部分代码省略.........
开发者ID:sheldon,项目名称:Garden,代码行数:101,代码来源:class.setupcontroller.php

示例6: DefinitionList

    /**
     * Undocumented method.
     *
     * @todo Method DefinitionList() needs a description.
     */
    public function DefinitionList()
    {
        $Session = Gdn::Session();
        if (!array_key_exists('TransportError', $this->_Definitions)) {
            $this->_Definitions['TransportError'] = Gdn::Translate('A fatal error occurred while processing the request.<br />The server returned the following response: %s');
        }
        if (!array_key_exists('TransientKey', $this->_Definitions)) {
            $this->_Definitions['TransientKey'] = $Session->TransientKey();
        }
        if (!array_key_exists('WebRoot', $this->_Definitions)) {
            $this->_Definitions['WebRoot'] = Gdn_Url::WebRoot(TRUE);
        }
        if (!array_key_exists('ConfirmHeading', $this->_Definitions)) {
            $this->_Definitions['ConfirmHeading'] = Gdn::Translate('Confirm');
        }
        if (!array_key_exists('ConfirmText', $this->_Definitions)) {
            $this->_Definitions['ConfirmText'] = Gdn::Translate('Are you sure you want to do that?');
        }
        if (!array_key_exists('Okay', $this->_Definitions)) {
            $this->_Definitions['Okay'] = Gdn::Translate('Okay');
        }
        if (!array_key_exists('Cancel', $this->_Definitions)) {
            $this->_Definitions['Cancel'] = Gdn::Translate('Cancel');
        }
        $Return = '<!-- Various definitions for Javascript //-->
<div id="Definitions" style="display: none;">
';
        foreach ($this->_Definitions as $Term => $Definition) {
            $Return .= '<input type="hidden" id="' . $Term . '" value="' . $Definition . '" />' . "\n";
        }
        return $Return . '</div>';
    }
开发者ID:robi-bobi,项目名称:Garden,代码行数:37,代码来源:class.controller.php

示例7: GetHandshakeData

 public function GetHandshakeData()
 {
     if (is_array($this->_HandshakeData)) {
         return $this->_HandshakeData;
     }
     $UrlParts = parse_url($this->AuthenticateUrl);
     $Host = $UrlParts['host'];
     $Port = ArrayValue('port', $UrlParts, '80');
     $Path = $UrlParts['path'];
     $Referer = Gdn_Url::WebRoot(TRUE);
     $Query = ArrayValue('query', $UrlParts, '');
     // Make a request to the authenticated Url to see if we are logged in.
     $Pointer = @fsockopen($Host, $Port, $ErrorNumber, $Error);
     if (!$Pointer) {
         throw new Exception(sprintf(Gdn::Translate('Encountered an error when attempting to authenticate handshake (%1$s): [%2$s] %3$s'), $this->AuthenticateUrl, $ErrorNumber, $Error));
     }
     // Get the cookie.
     $Cookie = '';
     foreach ($_COOKIE as $Key => $Value) {
         if (strncasecmp($Key, 'XDEBUG', 6) == 0) {
             continue;
         }
         if (strlen($Cookie) > 0) {
             $Cookie .= '; ';
         }
         $Cookie .= $Key . '=' . urlencode($Value);
     }
     if (strlen($Cookie) > 0) {
         $Cookie = "Cookie: {$Cookie}\r\n";
     }
     $Header = "GET {$Path}?{$Query} HTTP/1.1\r\n" . "Host: {$Host}\r\n" . "User-Agent: Vanilla/2.0\r\n" . "Accept: */*\r\n" . "Accept-Charset: utf-8;\r\n" . "Referer: {$Referer}\r\n" . "Connection: close\r\n" . $Cookie . "\r\n\r\n";
     // Send the necessary headers to get the file
     fputs($Pointer, $Header);
     // echo '<br /><textarea style="height: 400px; width: 700px;">'.$Header.'</textarea>';
     // Retrieve the response from the remote server
     $Response = '';
     $InBody = FALSE;
     while ($Line = fread($Pointer, 4096)) {
         $Response .= $Line;
     }
     fclose($Pointer);
     // echo '<br /><textarea style="height: 400px; width: 700px;">'.$Response.'</textarea>';
     // exit();
     // Remove response headers
     $Response = trim(substr($Response, strpos($Response, "\r\n\r\n") + 4));
     switch ($this->Encoding) {
         case 'json':
             $Result = json_decode($Response, TRUE);
             break;
         case 'ini':
         default:
             $Result = parse_ini_string($Response);
             break;
     }
     $this->_HandshakeData = $Result;
     return $Result;
 }
开发者ID:Aetasiric,项目名称:Garden,代码行数:57,代码来源:class.handshakeauthenticator.php

示例8: C

<?php

if (!defined('APPLICATION')) {
    exit;
}
$UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE);
$Year = $this->Data('Year');
$Month = $this->Data('Month');
$MonthFirst = $this->Data('MonthFirst');
$MonthLast = $this->Data('MonthLast');
$Domain = Gdn_Url::WebRoot(TRUE);
$Events = $this->Data('Events');
$Event = array_shift($Events);
$EventDay = $Event['EventCalendarDay'];
/*
<div class="Tabs HeadingTabs CalendarTabs">
   <div class="SubTab"><?php echo date(T('F Y'), $this->Data('MonthFirst'));?></div>
</div>
*/
?>

<h1 class="CalendarDate">
<a href="<?php 
echo "{$Domain}eventcalendar/{$this->Data('PreviousMonth')}";
?>
">«</a>
<?php 
echo date(T('F Y'), $this->Data('MonthFirst'));
?>
<a href="<?php 
echo "{$Domain}eventcalendar/{$this->Data('NextMonth')}";
开发者ID:shumoo,项目名称:EventCalendar,代码行数:31,代码来源:month.php

示例9: Setup

    /**
     * Create table if not exists and create a dbinfo.php file for ajax use
     */
    public function Setup()
    {
        $commentsTable = 'GDN_tInfoBar_comments';
        $file_dbinfo = $this->GetPluginFolder() . '/dbinfo.php';
        $file_globals = $this->GetPluginFolder() . '/globals.js';
        $Structure = Gdn::Structure();
        $Structure->Query("\n\t\t\tCREATE TABLE IF NOT EXISTS `{$commentsTable}` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `context` varchar(256) NOT NULL,\n\t\t\t  `wordID` text NOT NULL,\n\t\t\t  `user` varchar(60) NOT NULL,\n\t\t\t  `text` text NOT NULL,\n\t\t\t  PRIMARY KEY (`id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;\n\t\t");
        $dbinfo = '<?php
	$table_comments = "' . $commentsTable . '";

	$db_host 	= \'' . Gdn::Config('Database.Host') . '\';
	$db_user		= \'' . Gdn::Config('Database.User') . '\';
	$db_pass		= \'' . Gdn::Config('Database.Password') . '\';
	$db_database= \'' . Gdn::Config('Database.Name') . '\';

	$con = mysql_connect($db_host, $db_user, $db_pass) or die ("Could not connect to Data Base!");
	mysql_select_db($db_database, $con) or die ("Failed to select Data Base");
?>
';
        $globals = '
// Some global vars for use in the main.js file
var GdnWebRoot			= "' . Gdn_Url::WebRoot(true) . '";
var GgnPluginFolder	= "' . $this->GetPluginFolder() . '";
';
        //		if( !file_put_contents($file_dbinfo, $dbinfo))
        //			exit("Unable to create database info file. Check if you have writing permissions on: <b>".$this->GetPluginFolder()."</b>");
        //		if( !file_put_contents($file_globals, $globals))
        //			exit("Unable to create database info file. Check if you have writing permissions on: <b>".$this->GetPluginFolder()."</b>");
        //		chmod($file_dbinfo, 0777);
        //		chmod($file_globals, 0777);
        Gdn::Structure()->Table('Discussion')->Column('ArticleID', 'int', NULL)->Column('ItemID', 'varchar(256)', NULL)->Set();
    }
开发者ID:holtzermann17,项目名称:drupal_planetary,代码行数:35,代码来源:default.php

示例10: ErrorHandler

/**
 * A custom error handler that displays much more, very useful information when
 * errors are encountered in Garden.
 *
 * @param int The level of the error raised.
 * @param string The error message.
 * @param string The filename that the error was raised in.
 * @param string The line number the error was raised at.
 * @param string An array of every variable that existed in the scope the error was triggered in.
 */
function ErrorHandler($ErrorNumber, $Message, $File, $Line, $Arguments)
{
    // Ignore errors that have a @ before them (ie. @function();)
    if (error_reporting() == 0) {
        return FALSE;
    }
    // Clean the output buffer in case an error was encountered in-page.
    @ob_end_clean();
    header('Content-Type: text/html; charset=utf-8');
    $SenderMessage = $Message;
    $SenderObject = 'PHP';
    $SenderMethod = 'ErrorHandler';
    $SenderCode = FALSE;
    $MessageInfo = explode('|', $Message);
    $MessageCount = count($MessageInfo);
    if ($MessageCount == 4) {
        list($SenderMessage, $SenderObject, $SenderMethod, $SenderCode) = $MessageInfo;
    } else {
        if ($MessageCount == 3) {
            list($SenderMessage, $SenderObject, $SenderMethod) = $MessageInfo;
        }
    }
    $SenderMessage = strip_tags($SenderMessage);
    $Master = FALSE;
    // The parsed master view
    $CssPath = FALSE;
    // The web-path to the css file
    $ErrorLines = FALSE;
    // The lines near the error's line #
    $DeliveryType = DELIVERY_TYPE_ALL;
    if (array_key_exists('DeliveryType', $_POST)) {
        $DeliveryType = $_POST['DeliveryType'];
    } else {
        if (array_key_exists('DeliveryType', $_GET)) {
            $DeliveryType = $_GET['DeliveryType'];
        }
    }
    // Make sure all of the required custom functions and variables are defined.
    $PanicError = FALSE;
    // Should we just dump a message and forget about the master view?
    if (!defined('DS')) {
        $PanicError = TRUE;
    }
    if (!defined('PATH_ROOT')) {
        $PanicError = TRUE;
    }
    if (!defined('APPLICATION')) {
        define('APPLICATION', 'Garden');
    }
    if (!defined('APPLICATION_VERSION')) {
        define('APPLICATION_VERSION', 'Unknown');
    }
    $WebRoot = class_exists('Url', FALSE) ? Gdn_Url::WebRoot() : '';
    // Try and rollback a database transaction.
    if (class_exists('Gdn', FALSE)) {
        $Database = Gdn::Database();
        if (is_object($Database)) {
            $Database->RollbackTransaction();
        }
    }
    if ($PanicError === FALSE) {
        // See if we can get the file that caused the error
        if (is_string($File) && is_numeric($ErrorNumber)) {
            $ErrorLines = @file($File);
        }
        // If this error was encountered during an ajax request, don't bother gettting the css or theme files
        if ($DeliveryType == DELIVERY_TYPE_ALL) {
            $CssPaths = array();
            // Potential places where the css can be found in the filesystem.
            $MasterViewPaths = array();
            $MasterViewName = 'error.master.php';
            $MasterViewCss = 'error.css';
            if (class_exists('Gdn', FALSE)) {
                $CurrentTheme = '';
                // The currently selected theme
                $CurrentTheme = Gdn::Config('Garden.Theme', '');
                $MasterViewName = Gdn::Config('Garden.Errors.MasterView', $MasterViewName);
                $MasterViewCss = substr($MasterViewName, 0, strpos($MasterViewName, '.'));
                if ($MasterViewCss == '') {
                    $MasterViewCss = 'error';
                }
                $MasterViewCss .= '.css';
                if ($CurrentTheme != '') {
                    // Look for CSS in the theme folder:
                    $CssPaths[] = PATH_THEMES . DS . $CurrentTheme . DS . 'design' . DS . $MasterViewCss;
                    // Look for Master View in the theme folder:
                    $MasterViewPaths[] = PATH_THEMES . DS . $CurrentTheme . DS . 'views' . DS . $MasterViewName;
                }
            }
            // Look for CSS in the garden design folder.
//.........这里部分代码省略.........
开发者ID:jeastwood,项目名称:Garden,代码行数:101,代码来源:functions.error.php

示例11: GetWebResource

 public function GetWebResource($Filepath)
 {
     $WebResource = $this->GetResource($Filepath, FALSE, FALSE);
     if (Gdn_Url::WebRoot()) {
         $WebResource = CombinePaths(array(Gdn_Url::WebRoot(), $WebResource));
     }
     return '/' . $WebResource;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:8,代码来源:class.plugin.php

示例12: Asset

 function Asset($Destination = '', $WithDomain = FALSE)
 {
     if (substr($Destination, 0, 7) == 'http://') {
         return $Destination;
     } else {
         return CombinePaths(array('/', Gdn_Url::WebRoot($WithDomain), $Destination), '/');
     }
 }
开发者ID:jhampha,项目名称:Garden,代码行数:8,代码来源:functions.general.php

示例13: 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

示例14: ProxyRequest

 /**
  * Uses curl or fsock to make a request to a remote server. Returns the
  * response.
  *
  * @param string $Url The full url to the page being requested (including http://)
  */
 function ProxyRequest($Url, $Timeout = FALSE)
 {
     if (!$Timeout) {
         $Timeout = C('Garden.SocketTimeout', 1.0);
     }
     $UrlParts = parse_url($Url);
     $Scheme = GetValue('scheme', $UrlParts, 'http');
     $Host = GetValue('host', $UrlParts, '');
     $Port = GetValue('port', $UrlParts, '80');
     $Path = GetValue('path', $UrlParts, '');
     $Query = GetValue('query', $UrlParts, '');
     // Get the cookie.
     $Cookie = '';
     $EncodeCookies = C('Garden.Cookie.Urlencode', TRUE);
     foreach ($_COOKIE as $Key => $Value) {
         if (strncasecmp($Key, 'XDEBUG', 6) == 0) {
             continue;
         }
         if (strlen($Cookie) > 0) {
             $Cookie .= '; ';
         }
         $EValue = $EncodeCookies ? urlencode($Value) : $Value;
         $Cookie .= "{$Key}={$EValue}";
     }
     $Response = '';
     if (function_exists('curl_init')) {
         //$Url = $Scheme.'://'.$Host.$Path;
         $Handler = curl_init();
         curl_setopt($Handler, CURLOPT_URL, $Url);
         curl_setopt($Handler, CURLOPT_PORT, $Port);
         curl_setopt($Handler, CURLOPT_HEADER, 0);
         curl_setopt($Handler, CURLOPT_RETURNTRANSFER, 1);
         if ($Cookie != '') {
             curl_setopt($Handler, CURLOPT_COOKIE, $Cookie);
         }
         // TIM @ 2010-06-28: Commented this out because it was forcing all requests with parameters to be POST. Same for the $Url above
         //
         //if ($Query != '') {
         //   curl_setopt($Handler, CURLOPT_POST, 1);
         //   curl_setopt($Handler, CURLOPT_POSTFIELDS, $Query);
         //}
         $Response = curl_exec($Handler);
         if ($Response == FALSE) {
             $Response = curl_error($Handler);
         }
         curl_close($Handler);
     } else {
         if (function_exists('fsockopen')) {
             $Referer = Gdn_Url::WebRoot(TRUE);
             // Make the request
             $Pointer = @fsockopen($Host, $Port, $ErrorNumber, $Error);
             if (!$Pointer) {
                 throw new Exception(sprintf(T('Encountered an error while making a request to the remote server (%1$s): [%2$s] %3$s'), $Url, $ErrorNumber, $Error));
             }
             if (strlen($Cookie) > 0) {
                 $Cookie = "Cookie: {$Cookie}\r\n";
             }
             $HostHeader = $Host . ($Post != 80) ? ":{$Port}" : '';
             $Header = "GET {$Path}?{$Query} HTTP/1.1\r\n" . "Host: {$HostHeader}\r\n" . "User-Agent: Vanilla/2.0\r\n" . "Accept: */*\r\n" . "Accept-Charset: utf-8;\r\n" . "Referer: {$Referer}\r\n" . "Connection: close\r\n";
             if ($Cookie != '') {
                 $Header .= $Cookie;
             }
             $Header .= "\r\n";
             // Send the headers and get the response
             fputs($Pointer, $Header);
             while ($Line = fread($Pointer, 4096)) {
                 $Response .= $Line;
             }
             @fclose($Pointer);
             $Response = trim(substr($Response, strpos($Response, "\r\n\r\n") + 4));
             return $Response;
         } else {
             throw new Exception(T('Encountered an error while making a request to the remote server: Your PHP configuration does not allow curl or fsock requests.'));
         }
     }
     return $Response;
 }
开发者ID:BradA1878,项目名称:Garden,代码行数:83,代码来源:functions.general.php

示例15: GetWebResource

 public function GetWebResource($Filepath, $WithDomain = FALSE)
 {
     $WebResource = $this->GetResource($Filepath, FALSE, FALSE);
     if ($WithDomain === '/') {
         return $WebResource;
     }
     if (Gdn_Url::WebRoot()) {
         $WebResource = '/' . CombinePaths(array(Gdn_Url::WebRoot(), $WebResource));
     }
     if ($WithDomain === '//') {
         $WebResource = '//' . Gdn::Request()->HostAndPort() . $WebResource;
     } elseif ($WithDomain) {
         $WebResource = Gdn::Request()->Scheme() . '//' . Gdn::Request()->HostAndPort() . $WebResource;
     }
     return $WebResource;
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:16,代码来源:class.plugin.php


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