public function AfterImport()
 {
     // Set up the routes to redirect from their older counterparts.
     $Router = Gdn::Router();
     // Categories
     $Router->SetRoute('forumdisplay\\.php\\?f=(\\d+)', 'categories/$1', 'Permanent');
     $Router->SetRoute('archive\\.php/f-(\\d+)\\.html', 'categories/$1', 'Permanent');
     // Discussions & Comments
     $Router->SetRoute('showthread\\.php\\?t=(\\d+)', 'discussion/$1', 'Permanent');
     //$Router->SetRoute('showthread\.php\?p=(\d+)', 'discussion/comment/$1#Comment_$1', 'Permanent');
     //$Router->SetRoute('showpost\.php\?p=(\d+)', 'discussion/comment/$1#Comment_$1', 'Permanent');
     $Router->SetRoute('archive\\.php/t-(\\d+)\\.html', 'discussion/$1', 'Permanent');
     // Profiles
     $Router->SetRoute('member\\.php\\?u=(\\d+)', 'profile/$1/x', 'Permanent');
     $Router->SetRoute('usercp\\.php', 'profile', 'Permanent');
     $Router->SetRoute('profile\\.php', 'profile', 'Permanent');
     // Other
     $Router->SetRoute('attachment\\.php\\?attachmentid=(\\d+)', 'discussion/download/$1', 'Permanent');
     $Router->SetRoute('search\\.php', 'discussions', 'Permanent');
     $Router->SetRoute('private\\.php', 'messages/all', 'Permanent');
     $Router->SetRoute('subscription\\.php', 'discussions/bookmarked', 'Permanent');
     // Make different sizes of avatars
     $this->ProcessAvatars();
     // Prep config for ProfileExtender plugin based on imported fields
     $this->ProfileExtenderPrep();
     // Set guests to System user to prevent security issues
     $SystemUserID = Gdn::UserModel()->GetSystemUserID();
     $this->SQL->Update('Discussion')->Set('InsertUserID', $SystemUserID)->Where('InsertUserID', 0)->Put();
     $this->SQL->Update('Comment')->Set('InsertUserID', $SystemUserID)->Where('InsertUserID', 0)->Put();
 }
Example #2
0
 public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender)
 {
     $Request = Gdn::Request();
     $RequestUri = $Request->RequestUri();
     if (Gdn::Router()->GetRoute($RequestUri) === False) {
         $RequestArgs = SplitUpString($RequestUri, '/', 'strtolower');
         if (array_key_exists(0, $RequestArgs)) {
             $ApplicationFolders = $Sender->EnabledApplicationFolders();
             $bFoundApplication = in_array($RequestArgs[0], $ApplicationFolders);
             if ($bFoundApplication === False) {
                 $PathParts = array('controllers', 'class.' . $RequestArgs[0] . 'controller.php');
                 $ControllerFileName = CombinePaths($PathParts);
                 $ControllerPath = Gdn_FileSystem::FindByMapping('controller', PATH_APPLICATIONS, $ApplicationFolders, $ControllerFileName);
                 if (!$ControllerPath || !file_exists($ControllerPath)) {
                     $Sender->EventArguments['RequestUri'] =& $RequestUri;
                     $Sender->FireEvent('BeforeGetRoute');
                     $NewRequest = CandyModel::GetRouteRequestUri($RequestUri);
                     if ($NewRequest) {
                         $Request->WithURI($NewRequest);
                     }
                 }
             }
         }
     }
 }
 public function AfterImport()
 {
     // Set up the routes to redirect from their older counterparts.
     $Router = Gdn::Router();
     $Router->SetRoute('forumdisplay\\.php\\?f=(\\d+)', 'vanilla/categories/$1', 'Permanent');
     $Router->SetRoute('showthread\\.php\\?t=(\\d+)', 'vanilla/discussion/$1', 'Permanent');
     $Router->SetRoute('member\\.php\\?u=(\\d+)', 'dashboard/profile/$1/x', 'Permanent');
 }
Example #4
0
 public function Setup()
 {
     $matchroute = '^members(/.*)?$';
     $target = 'plugin/MembersListEnh$1';
     if (!Gdn::Router()->MatchRoute($matchroute)) {
         Gdn::Router()->SetRoute($matchroute, $target, 'Internal');
     }
 }
 public function AfterImport() {
    // Set up the routes to redirect from their older counterparts.
    $Router = Gdn::Router();
    $Router->SetRoute('forumdisplay\.php\?f=(\d+)', 'vanilla/categories/$1', 'Permanent');
    $Router->SetRoute('showthread\.php\?t=(\d+)', 'vanilla/discussion/$1', 'Permanent');
    $Router->SetRoute('member\.php\?u=(\d+)', 'dashboard/profile/$1/x', 'Permanent');
    // Make different sizes of avatars
    $this->ProcessAvatars();
 }
 public function AfterImport()
 {
     // Set up the routes to redirect from their older counterparts.
     $Router = Gdn::Router();
     $Router->SetRoute('\\?CategoryID=(\\d+)(?:&page=(\\d+))?', 'categories/$1/p$2', 'Permanent');
     $Router->SetRoute('\\?page=(\\d+)', 'discussions/p$1', 'Permanent');
     $Router->SetRoute('comments\\.php\\?DiscussionID=(\\d+)', 'discussion/$1/x', 'Permanent');
     $Router->SetRoute('comments\\.php\\?DiscussionID=(\\d+)&page=(\\d+)', 'discussion/$1/x/p$2', 'Permanent');
     $Router->SetRoute('account\\.php\\?u=(\\d+)', 'dashboard/profile/$1/x', 'Permanent');
 }
 public function Delete($RouteIndex = FALSE, $TransientKey = FALSE)
 {
     $this->Permission('Garden.Routes.Manage');
     $this->DeliveryType(DELIVERY_TYPE_BOOL);
     $Session = Gdn::Session();
     // If seeing the form for the first time...
     if ($TransientKey !== FALSE && $Session->ValidateTransientKey($TransientKey)) {
         Gdn::Router()->DeleteRoute($RouteIndex);
     }
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         Redirect('dashboard/routes');
     }
     $this->Render();
 }
 public function Setup()
 {
     $OldFormat = C('Garden.InputFormatter');
     if ($OldFormat != 'BBCode') {
         SaveToConfig(array('Garden.InputFormatter' => 'BBCode', 'Garden.InputFormatterBak' => $OldFormat));
     }
     // Setup the default routes.
     $Router = Gdn::Router();
     $Router->SetRoute('\\?board=(\\d+).*$', 'categories/$1', 'Permanent');
     $Router->SetRoute('index\\.php/topic,(\\d+).(\\d+)\\.html.*$', 'discussion/$1/x/$2lim', 'Permanent');
     $Router->SetRoute('index\\.php/board,(\\d+)\\.(\\d+)\\.html.*$', 'categories/$1/$2lim', 'Permanent');
     $Router->SetRoute('\\?action=profile%3Bu%3D(\\d+).*$', 'profile/$1/x', 'Permanent');
     $Router->SetRoute('index\\.php/topic,(\\d+)\\.msg(\\d+)\\.html.*$', 'discussion/comment/$2/#Comment_$2', 'Permanent');
     $Router->SetRoute('\\?topic=(\\d+).*$', 'discussion/$1/x/p1', 'Permanent');
 }
 /**
  * Parses the query string looking for supplied request parameters. Places
  * anything useful into this object's Controller properties.
  *
  * @param int $FolderDepth
  */
 protected function AnalyzeRequest(&$Request)
 {
     // Here is the basic format of a request:
     // [/application]/controller[/method[.json|.xml]]/argn|argn=valn
     // Here are some examples of what this method could/would receive:
     // /application/controller/method/argn
     // /controller/method/argn
     // /application/controller/argn
     // /controller/argn
     // /controller
     // Clear the slate
     $this->_ApplicationFolder = '';
     $this->ControllerFolder = '';
     $this->ControllerName = '';
     $this->ControllerMethod = 'index';
     $this->_ControllerMethodArgs = array();
     $this->Request = $Request->Path(FALSE);
     $PathAndQuery = $Request->PathAndQuery();
     $MatchRoute = Gdn::Router()->MatchRoute($PathAndQuery);
     // We have a route. Take action.
     if ($MatchRoute !== FALSE) {
         switch ($MatchRoute['Type']) {
             case 'Internal':
                 $Request->PathAndQuery($MatchRoute['FinalDestination']);
                 $this->Request = $Request->Path(FALSE);
                 break;
             case 'Temporary':
                 header("HTTP/1.1 302 Moved Temporarily");
                 header("Location: " . Url($MatchRoute['FinalDestination']));
                 exit;
                 break;
             case 'Permanent':
                 header("HTTP/1.1 301 Moved Permanently");
                 header("Location: " . Url($MatchRoute['FinalDestination']));
                 exit;
                 break;
             case 'NotAuthorized':
                 header("HTTP/1.1 401 Not Authorized");
                 $this->Request = $MatchRoute['FinalDestination'];
                 break;
             case 'NotFound':
                 header("HTTP/1.1 404 Not Found");
                 $this->Request = $MatchRoute['FinalDestination'];
                 break;
             case 'Test':
                 $Request->PathAndQuery($MatchRoute['FinalDestination']);
                 $this->Request = $Request->Path(FALSE);
                 decho($MatchRoute, 'Route');
                 decho(array('Path' => $Request->Path(), 'Get' => $Request->Get()), 'Request');
                 die;
         }
     }
     switch ($Request->OutputFormat()) {
         case 'rss':
             $this->_SyndicationMethod = SYNDICATION_RSS;
             break;
         case 'atom':
             $this->_SyndicationMethod = SYNDICATION_ATOM;
             break;
         case 'default':
         default:
             $this->_SyndicationMethod = SYNDICATION_NONE;
             break;
     }
     if ($this->Request == '') {
         $DefaultController = Gdn::Router()->GetRoute('DefaultController');
         $this->Request = $DefaultController['Destination'];
     }
     $Parts = explode('/', str_replace('\\', '/', $this->Request));
     /**
      * The application folder is either the first argument or is not provided. The controller is therefore
      * either the second argument or the first, depending on the result of the previous statement. Check that.
      */
     try {
         // if the 1st argument is a valid application, check if it has a controller matching the 2nd argument
         if (in_array($Parts[0], $this->EnabledApplicationFolders())) {
             $this->FindController(1, $Parts);
         }
         // if no match, see if the first argument is a controller
         $this->FindController(0, $Parts);
         // 3] See if there is a plugin trying to create a root method.
         list($MethodName, $DeliveryMethod) = $this->_SplitDeliveryMethod(GetValue(0, $Parts), TRUE);
         if ($MethodName && Gdn::PluginManager()->HasNewMethod('RootController', $MethodName, TRUE)) {
             $this->_DeliveryMethod = $DeliveryMethod;
             $Parts[0] = $MethodName;
             $Parts = array_merge(array('root'), $Parts);
             $this->FindController(0, $Parts);
         }
         throw new GdnDispatcherControllerNotFoundException();
     } catch (GdnDispatcherControllerFoundException $e) {
         switch ($this->_DeliveryMethod) {
             case DELIVERY_METHOD_JSON:
             case DELIVERY_METHOD_XML:
                 $this->_DeliveryType = DELIVERY_TYPE_DATA;
                 break;
             case DELIVERY_METHOD_TEXT:
                 $this->_DeliveryType = DELIVERY_TYPE_VIEW;
                 break;
             case DELIVERY_METHOD_XHTML:
                 break;
             default:
                 $this->_DeliveryMethod = DELIVERY_METHOD_XHTML;
                 break;
         }
         return TRUE;
     } catch (GdnDispatcherControllerNotFoundException $e) {
         $this->EventArguments['Handled'] = FALSE;
         $Handled =& $this->EventArguments['Handled'];
         $this->FireEvent('NotFound');
         if (!$Handled) {
             header("HTTP/1.1 404 Not Found");
             $Request->WithRoute('Default404');
             return $this->AnalyzeRequest($Request);
         }
     }
 }
 /**
  * Default all discussions view: chronological by most recent comment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $Page Multiplied by PerPage option to determine offset.
  */
 public function Index($Page = FALSE)
 {
     // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
     $Layout = C('Vanilla.Discussions.Layout');
     switch ($Layout) {
         case 'table':
             if ($this->SyndicationMethod == SYNDICATION_NONE) {
                 $this->View = 'table';
             }
             break;
         default:
             // $this->View = 'index';
             break;
     }
     Gdn_Theme::Section('DiscussionList');
     // Determine offset from $Page
     list($Offset, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
     $Page = PageNumber($Offset, $Limit);
     // Allow page manipulation
     $this->EventArguments['Page'] =& $Page;
     $this->EventArguments['Offset'] =& $Offset;
     $this->EventArguments['Limit'] =& $Limit;
     $this->FireEvent('AfterPageCalculation');
     // Set canonical URL
     $this->CanonicalUrl(Url(ConcatSep('/', 'discussions', PageNumber($Offset, $Limit, TRUE, FALSE)), TRUE));
     // We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
     $MaxPages = C('Vanilla.Discussions.MaxPages');
     if ($MaxPages && $Page > $MaxPages) {
         throw NotFoundException();
     }
     // Setup head.
     if (!$this->Data('Title')) {
         $Title = C('Garden.HomepageTitle');
         $DefaultControllerRoute = val('Destination', Gdn::Router()->GetRoute('DefaultController'));
         if ($Title && $DefaultControllerRoute == 'discussions') {
             $this->Title($Title, '');
         } else {
             $this->Title(T('Recent Discussions'));
         }
     }
     if (!$this->Description()) {
         $this->Description(C('Garden.Description', NULL));
     }
     if ($this->Head) {
         $this->Head->AddRss(Url('/discussions/feed.rss', TRUE), $this->Head->Title());
     }
     // Add modules
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $this->AddModule('BookmarkedModule');
     $this->SetData('Breadcrumbs', array(array('Name' => T('Recent Discussions'), 'Url' => '/discussions')));
     // Set criteria & get discussions data
     $this->SetData('Category', FALSE, TRUE);
     $DiscussionModel = new DiscussionModel();
     $DiscussionModel->Watching = TRUE;
     // Get Discussion Count
     $CountDiscussions = $DiscussionModel->GetCount();
     if ($MaxPages) {
         $CountDiscussions = min($MaxPages * $Limit, $CountDiscussions);
     }
     $this->SetData('CountDiscussions', $CountDiscussions);
     // Get Announcements
     $this->AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements() : FALSE;
     $this->SetData('Announcements', $this->AnnounceData !== FALSE ? $this->AnnounceData : array(), TRUE);
     // Get Discussions
     $this->DiscussionData = $DiscussionModel->GetWhere(FALSE, $Offset, $Limit);
     $this->SetData('Discussions', $this->DiscussionData, TRUE);
     $this->SetJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'Pager';
     $this->FireEvent('BeforeBuildPager');
     $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/%1$s');
     if (!$this->Data('_PagerUrl')) {
         $this->SetData('_PagerUrl', 'discussions/{Page}');
     }
     $this->SetData('_Page', $Page);
     $this->SetData('_Limit', $Limit);
     $this->FireEvent('AfterBuildPager');
     // Deliver JSON data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'discussions';
     }
     $this->Render();
 }
 public function Structure()
 {
     Gdn::Router()->SetRoute('sitemapindex.xml', '/utility/sitemapindex.xml', 'Internal');
     Gdn::Router()->SetRoute('sitemap-(.+)', '/utility/sitemap/$1', 'Internal');
     Gdn::Router()->SetRoute('robots.txt', '/utility/robots', 'Internal');
 }
Example #12
0
 public function WithRoute($Route)
 {
     $ParsedURI = Gdn::Router()->GetDestination($Route);
     if ($ParsedURI) {
         $this->_EnvironmentElement('URI', $ParsedURI);
     }
     return $this;
 }
Example #13
0
 /**
  * Homepage management screen.
  *
  * @since 2.0.0
  * @access public
  */
 public function Homepage()
 {
     $this->Permission('Garden.Settings.Manage');
     // Page setup
     $this->AddSideMenu('dashboard/settings/homepage');
     $this->Title(T('Homepage'));
     $this->AddJsFile('homepage.js');
     if (!$this->Form->AuthenticatedPostBack()) {
         $this->Route = Gdn::Router()->GetRoute('DefaultController');
         $this->Form->SetData(array('Target' => $this->Route['Destination']));
     } else {
         Gdn::Router()->DeleteRoute('DefaultController');
         Gdn::Router()->SetRoute('DefaultController', ArrayValue('Target', $this->Form->FormValues()), 'Internal');
         $this->InformMessage(T("The homepage was saved successfully."));
     }
     $this->Render();
 }
Example #14
0
<?php 
echo $this->Form->Open();
echo $this->Form->Errors();
?>
<ul>
   <li>
      <?php 
echo $this->Form->Label('Route Expression', 'Route');
$Attributes = array();
if ($this->Route['Reserved']) {
    //$Attributes['value'] = $this->Route;
    $Attributes['disabled'] = 'disabled';
}
echo $this->Form->TextBox('Route', $Attributes);
?>
   </li>
   <li>
      <?php 
echo $this->Form->Label('Target', 'Target');
echo $this->Form->TextBox('Target');
?>
   </li>
   <li>
      <?php 
echo $this->Form->Label('Type', 'Route Type');
echo $this->Form->DropDown('Type', Gdn::Router()->GetRouteTypes());
?>
   </li>
</ul>
<?php 
echo $this->Form->Close('Save');
   /**
    * Parses the query string looking for supplied request parameters. Places
    * anything useful into this object's Controller properties.
    *
    * @param int $FolderDepth
    */
   protected function AnalyzeRequest(&$Request) {
   
      // Here is the basic format of a request:
      // [/application]/controller[/method[.json|.xml]]/argn|argn=valn

      // Here are some examples of what this method could/would receive:
      // /application/controller/method/argn
      // /controller/method/argn
      // /application/controller/argn
      // /controller/argn
      // /controller

      // Clear the slate
      $this->_ApplicationFolder = '';
      $this->_ControllerFolder = '';
      $this->_ControllerName = '';
      $this->_ControllerMethod = 'index';
      $this->_ControllerMethodArgs = array();
      $this->Request = $Request->Path(FALSE);

      $PathAndQuery = $Request->PathAndQuery();
      $MatchRoute = Gdn::Router()->MatchRoute($PathAndQuery);

      // We have a route. Take action.
      if ($MatchRoute !== FALSE) {
         switch ($MatchRoute['Type']) {
            case 'Internal':
               $Request->PathAndQuery($MatchRoute['FinalDestination']);
               $this->Request = $Request->Path(FALSE);
               break;

            case 'Temporary':
               header("HTTP/1.1 302 Moved Temporarily" );
               header("Location: ".Url($MatchRoute['FinalDestination']));
               exit();
               break;

            case 'Permanent':
               header("HTTP/1.1 301 Moved Permanently" );
               header("Location: ".Url($MatchRoute['FinalDestination']));
               exit();
               break;

            case 'NotAuthorized':
               header("HTTP/1.1 401 Not Authorized" );
               $this->Request = $MatchRoute['FinalDestination'];
               break;

            case 'NotFound':
               header("HTTP/1.1 404 Not Found" );
               $this->Request = $MatchRoute['FinalDestination'];
               break;
         }
      }
      
      switch ($Request->OutputFormat()) {
         case 'rss':
            $this->_SyndicationMethod = SYNDICATION_RSS;
            break;
         case 'atom':
            $this->_SyndicationMethod = SYNDICATION_ATOM;
            break;
         case 'default':
         default:
            $this->_SyndicationMethod = SYNDICATION_NONE;
            break;
      }

      if ($this->Request == '') {
         $DefaultController = Gdn::Router()->GetRoute('DefaultController');
         $this->Request = $DefaultController['Destination'];
      }
      
      $Parts = explode('/', str_replace('\\', '/', $this->Request));
      
      /**
       * The application folder is either the first argument or is not provided. The controller is therefore
       * either the second argument or the first, depending on the result of the previous statement. Check that.
       */
      
      try {
      
         // 1] if the 1st argument is a valid application, check if it has a controller matching the 2nd argument
         if (in_array($Parts[0], $this->EnabledApplicationFolders()))
            $this->FindController(1, $Parts);
         
         // 2] if no match, see if the first argument is a controller
         $this->FindController(0, $Parts);
         
         throw new GdnDispatcherControllerNotFoundException();
         
      } catch (GdnDispatcherControllerFoundException $e) {

         // Success!
         if (in_array($this->_DeliveryMethod, array(DELIVERY_METHOD_JSON, DELIVERY_METHOD_XML)))
            $this->_DeliveryType = DELIVERY_TYPE_DATA;
         
         return TRUE;
      } catch (GdnDispatcherControllerNotFoundException $e) {
         header("HTTP/1.1 404 Not Found" );
         $Request->WithRoute('Default404');
         return $this->AnalyzeRequest($Request);
      }
   }
Example #16
0
 /**
  * Checks that the user has the specified permissions. If the user does not, they are redirected to the DefaultPermission route.
  * @param mixed $Permission A permission or array of permission names required to access this resource.
  * @param bool $FullMatch If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions.
  * @param string $JunctionTable The name of the junction table for a junction permission.
  * @param in $JunctionID The ID of the junction permission.
  */
 public function Permission($Permission, $FullMatch = TRUE, $JunctionTable = '', $JunctionID = '')
 {
     $Session = Gdn::Session();
     // TODO: Make this work with different delivery types.
     if (!$Session->CheckPermission($Permission, $FullMatch, $JunctionTable, $JunctionID)) {
         if (!$Session->IsValid()) {
             Redirect(Gdn::Authenticator()->SignInUrl($this->SelfUrl));
         } else {
             Redirect(Gdn::Router()->GetDestination('DefaultPermission'));
         }
     }
 }
Example #17
0
 protected function _GetURL($URLType, $Redirect)
 {
     $SessionAuthenticator = Gdn::Session()->GetPreference('Authenticator');
     $AuthenticationScheme = $SessionAuthenticator ? $SessionAuthenticator : 'default';
     try {
         $Authenticator = $this->GetAuthenticator($AuthenticationScheme);
     } catch (Exception $e) {
         $Authenticator = $this->GetAuthenticator();
     }
     if (!is_null($Redirect) && ($Redirect == '' || $Redirect == '/')) {
         $Redirect = Gdn::Router()->GetDestination('DefaultController');
     }
     if (is_null($Redirect)) {
         $Redirect = '';
     }
     // Ask the authenticator for this URLType
     $Return = $Authenticator->GetURL($URLType);
     // If it doesn't know, get the default from our config file
     if (!$Return) {
         $Return = Gdn::Config('Garden.Authenticator.' . $URLType);
     }
     $ExtraReplacementParameters = array('Path' => $Redirect, 'Scheme' => $AuthenticationScheme);
     // Extended return type, allows provider values to be replaced into final URL
     if (is_array($Return)) {
         $ExtraReplacementParameters = array_merge($ExtraReplacementParameters, $Return['Parameters']);
         $Return = $Return['URL'];
     }
     $FullRedirect = $Redirect != '' ? Url($Redirect, TRUE) : '';
     $ExtraReplacementParameters['Redirect'] = $FullRedirect;
     $ExtraReplacementParameters['CurrentPage'] = $FullRedirect;
     // Support legacy sprintf syntax
     $Return = sprintf($Return, $AuthenticationScheme, urlencode($Redirect), $FullRedirect);
     // Support new named parameter '{}' syntax
     $Return = $this->ReplaceAuthPlaceholders($Return, $ExtraReplacementParameters);
     if ($this->Protocol() == 'https') {
         $Return = str_replace('http:', 'https:', Url($Return, TRUE));
     }
     return $Return;
 }
 /**
  * Remove route.
  */
 public function OnDisable()
 {
     Gdn::Router()->DeleteRoute('apple-touch-icon.png');
 }
Example #19
0
// To run queries.
$Construct = $Database->Structure();
// To modify and add database tables.
$Validation = new Gdn_Validation();
// To validate permissions (if necessary).
include_once PATH_APPLICATIONS . '/candy/models/class.sectionmodel.php';
include_once PATH_APPLICATIONS . '/candy/settings/bootstrap.php';
Gdn::Structure()->Table('Chunk')->PrimaryKey('ChunkID', 'usmallint')->Column('Name', 'varchar(80)')->Column('Body', 'text', True)->Column('Format', 'varchar(20)', True)->Column('Url', 'varchar(80)', True)->Column('InsertUserID', 'int', False)->Column('DateInserted', 'datetime')->Column('UpdateUserID', 'int', True)->Column('DateUpdated', 'datetime', True)->Engine('MyISAM')->Set($Explicit, $Drop);
Gdn::Structure()->Table('Route')->Column('URI', 'char(80)', False, 'primary')->Column('RequestUri', 'char(120)')->Engine('MyISAM')->Set($Explicit, $Drop);
$SectionModel = Gdn::Factory('SectionModel');
$HasRoot = False;
Gdn::Structure()->Table($SectionModel->Name)->PrimaryKey('SectionID', 'usmallint')->Column('TreeLeft', 'usmallint', 0)->Column('TreeRight', 'usmallint', 0)->Column('Depth', 'utinyint', 0)->Column('ParentID', 'usmallint', 0)->Column('Name', 'varchar(120)')->Column('InTopMenu', 'tinyint(1)', 0)->Column('Url', 'varchar(80)', True)->Column('URI', 'varchar(80)', True)->Column('RequestUri', 'char(120)', True)->Column('Mask', 'uint', True)->Engine('InnoDB')->Set($Explicit, $Drop);
try {
    $HasRoot = $SQL->GetCount($SectionModel->Name, array('SectionID' => 1)) > 0;
} catch (Exception $Ex) {
}
if (!$HasRoot) {
    $SQL->Insert($SectionModel->Name, array('SectionID' => 1, 'TreeLeft' => 1, 'TreeRight' => 2, 'Depth' => 0, 'Name' => T('Home')));
}
Gdn::Structure()->Table('Page')->PrimaryKey('PageID', 'usmallint')->Column('SectionID', 'usmallint', True, 'index')->Column('Title', 'varchar(200)')->Column('Body', 'text', True)->Column('Format', 'varchar(20)', 'xHtml')->Column('Visible', 'tinyint(1)', 0)->Column('URI', 'varchar(80)', True)->Column('Tags', 'varchar(250)', True)->Column('MasterView', 'varchar(30)', True)->Column('View', 'varchar(30)', True)->Column('Sort', 'smallint', 0)->Column('InsertUserID', 'int')->Column('DateInserted', 'datetime')->Column('UpdateUserID', 'int', True)->Column('DateUpdated', 'datetime', True)->Column('MetaDescription', 'varchar(500)', True)->Column('MetaKeywords', 'varchar(250)', True)->Column('MetaRobots', 'varchar(150)', True)->Column('MetaTitle', 'varchar(255)', True)->Column('CustomCss', 'text', True)->Column('CustomJs', 'text', True)->Engine('MyISAM')->Set($Explicit, $Drop);
// Set route
if (!Gdn::Router()->GetRoute('map')) {
    Gdn::Router()->SetRoute('map', 'candy/content/map', 'Internal');
}
$PermissionModel = Gdn::PermissionModel();
$PermissionModel->Define(array('Candy.Settings.View', 'Candy.Sections.Edit', 'Candy.Sections.Add', 'Candy.Sections.Delete', 'Candy.Sections.Move', 'Candy.Sections.Swap', 'Candy.Pages.Add', 'Candy.Pages.Edit', 'Candy.Pages.Delete', 'Candy.Pages.Raw', 'Candy.Pages.Meta', 'Candy.Chunks.Edit', 'Candy.Chunks.Delete', 'Candy.Routes.Manage'));
$PermissionModel->Save(array('RoleID' => 16, 'Candy.Settings.View' => 1));
if (!isset($CaptureOnly) || $CaptureOnly == False) {
    $Version = Gdn::ApplicationManager()->GetApplicationInfo('Candy', 'Version');
    SaveToConfig('Candy.Version', $Version);
}
 /**
  * Return a url for a page.
  *
  * @param object $UrlCode ; Page URL code.
  * @param object $WithDomain ; Return with domain in URL.
  * @return string; The URL to the page.
  */
 public static function PageUrl($UrlCode, $WithDomain = true)
 {
     if (is_array($UrlCode)) {
         $UrlCode = $UrlCode['UrlCode'];
     } else {
         if (is_object($UrlCode)) {
             $UrlCode = $UrlCode->UrlCode;
         }
     }
     $PageModel = new PageModel();
     if (Gdn::Router()->MatchRoute($UrlCode . $PageModel->RouteExpressionSuffix)) {
         $Result = rawurlencode($UrlCode);
     } else {
         $Result = '/page/' . rawurlencode($UrlCode);
     }
     return Url($Result, $WithDomain);
 }
Example #21
0
 /**
  * Render the entire head module.
  */
 public function ToString()
 {
     // Add the canonical Url if necessary.
     if (method_exists($this->_Sender, 'CanonicalUrl') && !C('Garden.Modules.NoCanonicalUrl', FALSE)) {
         $CanonicalUrl = $this->_Sender->CanonicalUrl();
         if (!preg_match('`^https?://`', $CanonicalUrl)) {
             $CanonicalUrl = Gdn::Router()->ReverseRoute($CanonicalUrl);
         }
         $this->_Sender->CanonicalUrl($CanonicalUrl);
         //            $CurrentUrl = Url('', TRUE);
         //            if ($CurrentUrl != $CanonicalUrl) {
         $this->AddTag('link', array('rel' => 'canonical', 'href' => $CanonicalUrl));
         //            }
     }
     // Include facebook open-graph meta information.
     if ($FbAppID = C('Plugins.Facebook.ApplicationID')) {
         $this->AddTag('meta', array('property' => 'fb:app_id', 'content' => $FbAppID));
     }
     $SiteName = C('Garden.Title', '');
     if ($SiteName != '') {
         $this->AddTag('meta', array('property' => 'og:site_name', 'content' => $SiteName));
     }
     $Title = Gdn_Format::Text($this->Title('', TRUE));
     if ($Title != '') {
         $this->AddTag('meta', array('property' => 'og:title', 'itemprop' => 'name', 'content' => $Title));
     }
     if (isset($CanonicalUrl)) {
         $this->AddTag('meta', array('property' => 'og:url', 'content' => $CanonicalUrl));
     }
     if ($Description = $this->_Sender->Description()) {
         $this->AddTag('meta', array('name' => 'description', 'property' => 'og:description', 'itemprop' => 'description', 'content' => $Description));
     }
     // Default to the site logo if there were no images provided by the controller.
     if (count($this->_Sender->Image()) == 0) {
         $Logo = C('Garden.ShareImage', C('Garden.Logo', ''));
         if ($Logo != '') {
             // Fix the logo path.
             if (StringBeginsWith($Logo, 'uploads/')) {
                 $Logo = substr($Logo, strlen('uploads/'));
             }
             $Logo = Gdn_Upload::Url($Logo);
             $this->AddTag('meta', array('property' => 'og:image', 'itemprop' => 'image', 'content' => $Logo));
         }
     } else {
         foreach ($this->_Sender->Image() as $Img) {
             $this->AddTag('meta', array('property' => 'og:image', 'itemprop' => 'image', 'content' => $Img));
         }
     }
     $this->FireEvent('BeforeToString');
     $Tags = $this->_Tags;
     // Make sure that css loads before js (for jquery)
     usort($this->_Tags, array('HeadModule', 'TagCmp'));
     // "link" comes before "script"
     $Tags2 = $this->_Tags;
     // Start with the title.
     $Head = '<title>' . Gdn_Format::Text($this->Title()) . "</title>\n";
     $TagStrings = array();
     // Loop through each tag.
     foreach ($this->_Tags as $Index => $Attributes) {
         $Tag = $Attributes[self::TAG_KEY];
         // Inline the content of the tag, if necessary.
         if (GetValue('_hint', $Attributes) == 'inline') {
             $Path = GetValue('_path', $Attributes);
             if (!StringBeginsWith($Path, 'http')) {
                 $Attributes[self::CONTENT_KEY] = file_get_contents($Path);
                 if (isset($Attributes['src'])) {
                     $Attributes['_src'] = $Attributes['src'];
                     unset($Attributes['src']);
                 }
                 if (isset($Attributes['href'])) {
                     $Attributes['_href'] = $Attributes['href'];
                     unset($Attributes['href']);
                 }
             }
         }
         // If we set an IE conditional AND a "Not IE" condition, we will need to make a second pass.
         do {
             // Reset tag string
             $TagString = '';
             // IE conditional? Validates condition.
             $IESpecific = isset($Attributes['_ie']) && preg_match('/((l|g)t(e)? )?IE [0-9\\.]/', $Attributes['_ie']);
             // Only allow $NotIE if we're not doing a conditional this loop.
             $NotIE = !$IESpecific && isset($Attributes['_notie']);
             // Open IE conditional tag
             if ($IESpecific) {
                 $TagString .= '<!--[if ' . $Attributes['_ie'] . ']>';
             }
             if ($NotIE) {
                 $TagString .= '<!--[if !IE]> -->';
             }
             // Build tag
             $TagString .= '<' . $Tag . Attribute($Attributes, '_');
             if (array_key_exists(self::CONTENT_KEY, $Attributes)) {
                 $TagString .= '>' . $Attributes[self::CONTENT_KEY] . '</' . $Tag . '>';
             } elseif ($Tag == 'script') {
                 $TagString .= '></script>';
             } else {
                 $TagString .= ' />';
             }
             // Close IE conditional tag
             if ($IESpecific) {
                 $TagString .= '<![endif]-->';
             }
             if ($NotIE) {
                 $TagString .= '<!-- <![endif]-->';
             }
             // Cleanup (prevent infinite loop)
             if ($IESpecific) {
                 unset($Attributes['_ie']);
             }
             $TagStrings[] = $TagString;
         } while ($IESpecific && isset($Attributes['_notie']));
         // We need a second pass
     }
     //endforeach
     $Head .= implode("\n", array_unique($TagStrings));
     foreach ($this->_Strings as $String) {
         $Head .= $String;
         $Head .= "\n";
     }
     return $Head;
 }
Example #22
0
?>
</th>
         <th class="Alt"><?php 
echo T('Type');
?>
</th>
      </tr>
   </thead>
   <tbody>
<?php 
$i = 0;
$Alt = FALSE;
foreach ($this->MyRoutes as $Route => $RouteData) {
    $Alt = !$Alt;
    $Target = $RouteData['Destination'];
    $RouteType = T(Gdn::Router()->RouteTypes[$RouteData['Type']]);
    $Reserved = $RouteData['Reserved'];
    ?>
   <tr<?php 
    echo $Alt ? ' class="Alt"' : '';
    ?>
>
      <td class="Info">
         <strong><?php 
    echo $Route;
    ?>
</strong>
         <div>
         <?php 
    echo Anchor('Edit', '/dashboard/routes/edit/' . trim($RouteData['Key'], '='), 'EditRoute SmallButton');
    if (!$Reserved) {
Example #23
0
 /**
  * @param SiteLinkMenuModule $sender
  */
 public function SiteNavModule_default_handler($sender)
 {
     // Grab the default route so that we don't add a link to it twice.
     $home = trim(GetValue('Destination', Gdn::Router()->GetRoute('DefaultController')), '/');
     // Add the site discussion links.
     if ($home !== 'categories') {
         $sender->addLink('main.categories', array('text' => t('All Categories', 'Categories'), 'url' => '/categories', 'icon' => icon('th-list'), 'sort' => 1));
     }
     if ($home !== 'discussions') {
         $sender->addLink('main.discussions', array('text' => t('Recent Discussions'), 'url' => '/discussions', 'icon' => icon('discussion'), 'sort' => 1));
     }
     // Add favorites.
     $sender->addGroup('favorites', array('text' => t('Favorites')));
     if (Gdn::Session()->IsValid()) {
         $sender->addLink('favorites.bookmarks', array('text' => t('My Bookmarks'), 'url' => '/discussions/bookmarked', 'icon' => icon('star'), 'badge' => countString(Gdn::Session()->User->CountBookmarks, Url('/discussions/userbookmarkcount'))));
         $sender->addLink('favorites.discussions', array('text' => t('My Discussions'), 'url' => '/discussions/mine', 'icon' => icon('discussion'), 'badge' => countString(Gdn::Session()->User->CountDiscussions)));
         $sender->addLink('favorites.drafts', array('text' => t('Drafts'), 'url' => '/drafts', 'icon' => icon('compose'), 'badge' => countString(Gdn::Session()->User->CountDrafts)));
     }
 }
Example #24
0
 public static function Link($Path, $Text = FALSE, $Format = NULL, $Options = array())
 {
     $Session = Gdn::Session();
     $Class = GetValue('class', $Options, '');
     $WithDomain = GetValue('WithDomain', $Options);
     $Target = GetValue('Target', $Options, '');
     if ($Target == 'current') {
         $Target = trim(Url('', TRUE), '/ ');
     }
     if (is_null($Format)) {
         $Format = '<a href="%url" class="%class">%text</a>';
     }
     switch ($Path) {
         case 'activity':
             TouchValue('Permissions', $Options, 'Garden.Activity.View');
             break;
         case 'category':
             $Breadcrumbs = Gdn::Controller()->Data('Breadcrumbs');
             if (is_array($Breadcrumbs) && count($Breadcrumbs) > 0) {
                 $Last = array_pop($Breadcrumbs);
                 $Path = GetValue('Url', $Last);
                 $DefaultText = GetValue('Name', $Last, T('Back'));
             } else {
                 $Path = '/';
                 $DefaultText = C('Garden.Title', T('Back'));
             }
             if (!$Text) {
                 $Text = $DefaultText;
             }
             break;
         case 'dashboard':
             $Path = 'dashboard/settings';
             TouchValue('Permissions', $Options, array('Garden.Settings.Manage', 'Garden.Settings.View'));
             if (!$Text) {
                 $Text = T('Dashboard');
             }
             break;
         case 'home':
             $Path = '/';
             if (!$Text) {
                 $Text = T('Home');
             }
             break;
         case 'inbox':
             $Path = 'messages/inbox';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('Inbox');
             }
             if ($Session->IsValid() && $Session->User->CountUnreadConversations) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountUnreadConversations . '</span>';
             }
             if (!$Session->IsValid()) {
                 $Text = FALSE;
             }
             break;
         case 'forumroot':
             $Route = Gdn::Router()->GetDestination('DefaultForumRoot');
             if (is_null($Route)) {
                 $Path = '/';
             } else {
                 $Path = CombinePaths(array('/', $Route));
             }
             break;
         case 'profile':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $Text = $Session->User->Name;
             }
             if ($Session->IsValid() && $Session->User->CountNotifications) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountNotifications . '</span>';
             }
             break;
         case 'user':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $Text = $Session->User->Name;
             }
             break;
         case 'photo':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://';
                 $PhotoUrl = $IsFullPath ? $Session->User->Photo : Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'n%s'));
                 $Text = Img($PhotoUrl, array('alt' => htmlspecialchars($Session->User->Name)));
             }
             break;
         case 'drafts':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Drafts');
             }
             if ($Session->IsValid() && $Session->User->CountDrafts) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountDrafts . '</span>';
             }
             break;
         case 'discussions/bookmarked':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Bookmarks');
             }
             if ($Session->IsValid() && $Session->User->CountBookmarks) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Count">' . $Session->User->CountBookmarks . '</span>';
             }
             break;
         case 'discussions/mine':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Discussions');
             }
             if ($Session->IsValid() && $Session->User->CountDiscussions) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Count">' . $Session->User->CountDiscussions . '</span>';
             }
             break;
         case 'signin':
         case 'signinout':
             // The destination is the signin/signout toggle link.
             if ($Session->IsValid()) {
                 if (!$Text) {
                     $Text = T('Sign Out');
                 }
                 $Path = SignOutUrl($Target);
                 $Class = ConcatSep(' ', $Class, 'SignOut');
             } else {
                 if (!$Text) {
                     $Text = T('Sign In');
                 }
                 $Attribs = array();
                 $Path = SignInUrl($Target);
                 if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE) {
                     $Class = ConcatSep(' ', $Class, 'SignInPopup');
                 }
             }
             break;
     }
     if ($Text == FALSE && strpos($Format, '%text') !== FALSE) {
         return '';
     }
     if (GetValue('Permissions', $Options) && !$Session->CheckPermission($Options['Permissions'], FALSE)) {
         return '';
     }
     $Url = Gdn::Request()->Url($Path, $WithDomain);
     if ($TK = GetValue('TK', $Options)) {
         if (in_array($TK, array(1, 'true'))) {
             $TK = 'TransientKey';
         }
         $Url .= (strpos($Url, '?') === FALSE ? '?' : '&') . $TK . '=' . urlencode(Gdn::Session()->TransientKey());
     }
     if (strcasecmp(trim($Path, '/'), Gdn::Request()->Path()) == 0) {
         $Class = ConcatSep(' ', $Class, 'Selected');
     }
     // Build the final result.
     $Result = $Format;
     $Result = str_replace('%url', $Url, $Result);
     $Result = str_replace('%text', $Text, $Result);
     $Result = str_replace('%class', $Class, $Result);
     return $Result;
 }
 /**
  * Homepage management screen.
  *
  * @since 2.0.0
  * @access public
  */
 public function Homepage()
 {
     $this->Permission('Garden.Settings.Manage');
     // Page setup
     $this->AddSideMenu('dashboard/settings/homepage');
     $this->Title(T('Homepage'));
     $CurrentRoute = GetValue('Destination', Gdn::Router()->GetRoute('DefaultController'), '');
     $this->SetData('CurrentTarget', $CurrentRoute);
     if (!$this->Form->AuthenticatedPostBack()) {
         $this->Form->SetData(array('Target' => $CurrentRoute));
     } else {
         $NewRoute = GetValue('Target', $this->Form->FormValues(), '');
         Gdn::Router()->DeleteRoute('DefaultController');
         Gdn::Router()->SetRoute('DefaultController', $NewRoute, 'Internal');
         $this->SetData('CurrentTarget', $NewRoute);
         // Save the preferred layout setting
         SaveToConfig(array('Vanilla.Discussions.Layout' => GetValue('DiscussionsLayout', $this->Form->FormValues(), ''), 'Vanilla.Categories.Layout' => GetValue('CategoriesLayout', $this->Form->FormValues(), '')));
         $this->InformMessage(T("Your changes were saved successfully."));
     }
     $this->Render();
 }
 /**
  * Complete callback once credentials validated.
  */
 protected function social_login_redirect($error_message, $user_id, $user_data, $custom_redirect, $registration)
 {
     // Display an error message
     if (isset($error_message)) {
         trigger_error($error_message);
     } else {
         if (is_numeric($user_id)) {
             // Update statistics:
             $this->incr_login_count_identity_token($user_data['identity_token']);
             // Login:
             Gdn::Session()->Start($user_id, TRUE);
             if (!Gdn::Session()->CheckPermission('Garden.SignIn.Allow')) {
                 //$this->Form->AddError('ErrorPermission');
                 Gdn::Session()->End();
             }
             if ($registration === TRUE) {
                 Gdn::UserModel()->FireEvent('RegistrationSuccessful');
             } else {
                 Gdn::UserModel()->FireEvent('AfterSignIn');
             }
             // Redirection:
             if (!empty($custom_redirect)) {
                 SafeRedirect($custom_redirect);
             }
             // This was set in the callback_uri (JS):
             $target = Gdn::Request()->Get('Target');
             $target = empty($target) ? Gdn::Router()->GetDestination('DefaultController') : $target;
             SafeRedirect(Url($target, TRUE));
         }
     }
 }
 /**
  * Go to requested Target() or the default controller if none was set.
  *
  * @access public
  * @since 2.0.0
  *
  * @return string URL.
  */
 public function RedirectTo()
 {
     $Target = $this->Target();
     return $Target == '' ? Gdn::Router()->GetDestination('DefaultController') : $Target;
 }
Example #28
0
 /**
  * Searches through the /cache/controller_mappings.php file for the requested
  * controller. If it doesn't find it, it searches through the entire
  * application's folders for the requested controller. If it finds the
  * controller, it adds the mapping to /cache/controller_mappings.php so it
  * won't need to search again. If it doesn't find the controller file
  * anywhere, it throws a fatal error.
  *
  * @param boolean $ThrowErrorOnFailure
  * @todo $ThrowErrorOnFailure needs a description.
  */
 private function _FetchController($ThrowErrorOnFailure = FALSE)
 {
     $ControllerWhiteList = $this->EnabledApplicationFolders();
     // Don't include it if it's already been included
     if (!class_exists($this->ControllerName())) {
         $PathParts = array('controllers');
         if ($this->_ControllerFolder != '') {
             $PathParts[] = $this->_ControllerFolder;
         }
         $PathParts[] = 'class.' . strtolower($this->_ControllerName) . 'controller.php';
         $ControllerFileName = CombinePaths($PathParts);
         // Limit the white list to the specified application folder if it was in the request
         if ($this->_ApplicationFolder != '' && InArrayI($this->_ApplicationFolder, $ControllerWhiteList)) {
             $ControllerWhiteList = array($this->_ApplicationFolder);
         }
         $ControllerPath = Gdn_FileSystem::FindByMapping('controller', PATH_APPLICATIONS, $ControllerWhiteList, $ControllerFileName);
         if ($ControllerPath !== FALSE) {
             // Strip the "Application Folder" from the controller path (this is
             // used by the controller for various purposes. ie. knowing which
             // application to search in for a view file).
             $this->_ApplicationFolder = explode(DS, str_replace(PATH_APPLICATIONS . DS, '', $ControllerPath));
             $this->_ApplicationFolder = $this->_ApplicationFolder[0];
             $AppControllerName = ucfirst(strtolower($this->_ApplicationFolder)) . 'Controller';
             // Load the application's master controller
             if (!class_exists($AppControllerName)) {
                 require_once CombinePaths(array(PATH_APPLICATIONS, $this->_ApplicationFolder, 'controllers', 'class.' . strtolower($this->_ApplicationFolder) . 'controller.php'));
             }
             // Now load the library (no need to check for existence - couldn't
             // have made it here if it didn't exist).
             require_once $ControllerPath;
         }
     }
     if (!class_exists($this->ControllerName())) {
         if ($ThrowErrorOnFailure === TRUE) {
             if (ForceBool(Gdn::Config('Garden.Debug'))) {
                 trigger_error(ErrorMessage('Controller not found: ' . $this->ControllerName(), 'Dispatcher', '_FetchController'), E_USER_ERROR);
             } else {
                 $MissingRoute = Gdn::Router()->GetRoute('Default404');
                 // Return a 404 message
                 list($this->_ApplicationFolder, $this->_ControllerName, $this->_ControllerMethod) = explode('/', $MissingRoute['Destination']);
                 $ControllerFileName = CombinePaths(array('controllers', 'class.' . strtolower($this->_ControllerName) . 'controller.php'));
                 $ControllerPath = Gdn_FileSystem::FindByMapping('controller', PATH_APPLICATIONS, $ControllerWhiteList, $ControllerFileName);
                 $this->_ApplicationFolder = explode(DS, str_replace(PATH_APPLICATIONS . DS, '', $ControllerPath));
                 $this->_ApplicationFolder = $this->_ApplicationFolder[0];
                 require_once CombinePaths(array(PATH_APPLICATIONS, $this->_ApplicationFolder, 'controllers', 'class.' . strtolower($this->_ApplicationFolder) . 'controller.php'));
                 require_once $ControllerPath;
             }
         }
         return FALSE;
     } else {
         return TRUE;
     }
 }
Example #29
0
 public function RedirectTo()
 {
     $IncomingTarget = $this->Form->GetValue('Target', '');
     return $IncomingTarget == '' ? Gdn::Router()->GetDestination('DefaultController') : $IncomingTarget;
 }
 public function EntryController_Register_Handler(&$Sender) {
    if (!Gdn::Authenticator()->IsPrimary('proxy')) return;
    
    $Redirect = Gdn::Request()->GetValue('HTTP_REFERER');
    $RegisterURL = Gdn::Authenticator()->GetURL(Gdn_Authenticator::URL_REMOTE_REGISTER, $Redirect);
    $RealUserID = Gdn::Authenticator()->GetRealIdentity();
    $Authenticator = Gdn::Authenticator()->GetAuthenticator('proxy');
    
    if ($RealUserID > 0) {
       // The user is already signed in. Send them to the default page.
       Redirect(Gdn::Router()->GetDestination('DefaultController'), 302);
    } else {
       // We have no cookie for this user. Send them to the remote registration page.
       $Authenticator->SetIdentity(NULL);
       Redirect($RegisterURL,302);
    }
 }