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


PHP Gdn_AuthenticationProviderModel::Save方法代码示例

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


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

示例1: Controller_Index

 public function Controller_Index($Sender)
 {
     $this->AddSliceAsset($this->GetResource('css/wordpress.css', FALSE, FALSE));
     $ProviderModel = new Gdn_AuthenticationProviderModel();
     $LastState = NULL;
     $State = NULL;
     do {
         $LastState = $State;
         $State = $this->State($this->ProxyConnect->Provider);
         $Sender->SetData('IntegrationState', $State);
         switch ($State) {
             case 'Address':
                 // Gather remote address from user.
                 // User has submitted the form and provided a URL
                 if ($Sender->Form->AuthenticatedPostBack()) {
                     // Address supplied. Query the remote blog.
                     $Address = $Sender->Form->GetValue('WordpressUrl', NULL);
                     if (empty($Address)) {
                         $Sender->Form->AddError("Please enter the URL for your blog.");
                         return $this->GetView('wordpress.php');
                     }
                     $this->ProxyConnect->Provider['URL'] = $Address;
                     $Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Check', NULL, FALSE);
                     if (GetValue('X-ProxyConnect-Enabled', $Response) == 'yes') {
                         // Proxyconnect is enabled at the provided URL.
                         $ProviderModel->Save($this->ProxyConnect->Provider);
                     } else {
                         unset($this->ProxyConnect->Provider['URL']);
                         $Sender->Form->AddError("Unable to contact remote plugin. Perhaps your blog URL was incorrect?");
                         return $this->GetView('wordpress.php');
                     }
                 } else {
                     // break out of the loop and let the form render
                     break 2;
                 }
                 break;
             case 'Exchange':
                 if ($LastState == $State) {
                     // exchanging again.
                     $Sender->Form->AddError("Unable to poll remote plugin for all required information. Switch to manual integration.");
                     return $this->GetView('wordpress.php');
                 }
                 // 1: push challenge key to remote.
                 // 2: gather urls
                 // 3: set cookie domain
                 // 1 - push challenge key
                 $Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Secure', array('Challenge' => GetValue('AssociationSecret', $this->ProxyConnect->Provider, 'flam')));
                 $ChallengeSet = GetValue('X-Autoconfigure-Challenge', $Response);
                 if ($ChallengeSet != 'set') {
                     $Sender->Form->AddError("Could not set Challenge key on remote. Reason was: challenge {$ChallengeSet}");
                     return $this->GetView('wordpress.php');
                 }
                 // 2 - gather URLs
                 $Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Exchange', NULL, TRUE, TRUE);
                 $Result = json_decode($Response);
                 $CheckURLs = array('AuthenticateUrl', 'RegisterUrl', 'SignInUrl', 'SignOutUrl', 'PasswordUrl', 'ProfileUrl');
                 foreach ($CheckURLs as $CheckURL) {
                     $Value = GetValue($CheckURL, $Result, NULL);
                     if (!is_null($Value)) {
                         $this->ProxyConnect->Provider[$CheckURL] = $Value;
                     }
                 }
                 // save the provider data
                 $ProviderModel->Save($this->ProxyConnect->Provider);
                 // 3 - set cookie domain
                 $ExplodedDomain = explode('.', Gdn::Request()->RequestHost());
                 if (sizeof($ExplodedDomain) == 1) {
                     $GuessedCookieDomain = '';
                 } else {
                     $GuessedCookieDomain = '.' . implode('.', array_slice($ExplodedDomain, -2, 2));
                 }
                 $Response = $this->QueryRemote($this->ProxyConnect->Provider, 'Cookie', array('CookieDomain' => $GuessedCookieDomain), TRUE, TRUE);
                 if (GetValue('X-Autoconfigure-Cookie', $Response, NULL) == 'set') {
                     // Set local cookie domain too
                     SaveToConfig('Garden.Cookie.Domain', $GuessedCookieDomain);
                 }
                 break;
             case NULL:
                 // provider is fully configured.
                 $Sender->SetData('BlogURL', GetValue('URL', $this->ProxyConnect->Provider));
                 break;
             case 'Error':
                 return $this->GetView('providerfailed.php');
                 break;
         }
     } while (!is_null($State));
     return $this->GetView('wordpress.php');
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:88,代码来源:class.proxyconnectwordpress.plugin.php


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