/**
  * Override the default index method of the settings controller in the
  * dashboard application to render new statistics.
  */
 public function StatsDashboard($Sender)
 {
     $StatsUrl = $this->AnalyticsServer;
     if (!StringBeginsWith($StatsUrl, 'http:') && !StringBeginsWith($StatsUrl, 'https:')) {
         $StatsUrl = Gdn::Request()->Scheme() . "://{$StatsUrl}";
     }
     // Tell the page where to find the Vanilla Analytics provider
     $Sender->AddDefinition('VanillaStatsUrl', $StatsUrl);
     $Sender->SetData('VanillaStatsUrl', $StatsUrl);
     // Load javascript & css, check permissions, and load side menu for this page.
     $Sender->AddJsFile('settings.js');
     $Sender->Title(T('Dashboard'));
     $Sender->RequiredAdminPermissions[] = 'Garden.Settings.Manage';
     $Sender->RequiredAdminPermissions[] = 'Garden.Users.Add';
     $Sender->RequiredAdminPermissions[] = 'Garden.Users.Edit';
     $Sender->RequiredAdminPermissions[] = 'Garden.Users.Delete';
     $Sender->RequiredAdminPermissions[] = 'Garden.Users.Approve';
     $Sender->FireEvent('DefineAdminPermissions');
     $Sender->Permission($Sender->RequiredAdminPermissions, '', FALSE);
     $Sender->AddSideMenu('dashboard/settings');
     if (!Gdn_Statistics::CheckIsEnabled() && Gdn_Statistics::CheckIsLocalhost()) {
         $Sender->Render('dashboardlocalhost', '', 'plugins/VanillaStats');
     } else {
         $Sender->AddJsFile('plugins/VanillaStats/js/vanillastats.js');
         $Sender->AddJsFile('plugins/VanillaStats/js/picker.js');
         $Sender->AddCSSFile('plugins/VanillaStats/design/picker.css');
         $this->ConfigureRange($Sender);
         $VanillaID = Gdn::InstallationID();
         $Sender->SetData('VanillaID', $VanillaID);
         $Sender->SetData('VanillaVersion', APPLICATION_VERSION);
         $Sender->SetData('SecurityToken', $this->SecurityToken());
         // Render the custom dashboard view
         $Sender->Render('dashboard', '', 'plugins/VanillaStats');
     }
 }
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 Controller_Cookie($Sender)
 {
     $ExplodedDomain = explode('.', Gdn::Request()->RequestHost());
     if (sizeof($ExplodedDomain) == 1) {
         $GuessedCookieDomain = '';
     } else {
         $GuessedCookieDomain = '.' . implode('.', array_slice($ExplodedDomain, -2, 2));
     }
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->SetField(array('Plugin.ProxyConnect.NewCookieDomain'));
     // Set the model on the form.
     $Sender->Form->SetModel($ConfigurationModel);
     if ($Sender->Form->AuthenticatedPostBack()) {
         $NewCookieDomain = $Sender->Form->GetValue('Plugin.ProxyConnect.NewCookieDomain', '');
         SaveToConfig('Garden.Cookie.Domain', $NewCookieDomain);
     } else {
         $NewCookieDomain = $GuessedCookieDomain;
     }
     $Sender->SetData('GuessedCookieDomain', $GuessedCookieDomain);
     $CurrentCookieDomain = C('Garden.Cookie.Domain');
     $Sender->SetData('CurrentCookieDomain', $CurrentCookieDomain);
     $Sender->Form->SetData(array('Plugin.ProxyConnect.NewCookieDomain' => $NewCookieDomain));
     $Sender->Form->SetFormValue('Plugin.ProxyConnect.NewCookieDomain', $NewCookieDomain);
     return $this->GetView('cookie.php');
 }
Example #4
0
    /**
     * Show buttons after OP message body.
     */
    public function DiscussionController_AfterDiscussionBody_Handler($Sender)
    {
        $PublisherNumber = C('Plugin.ShareThis.PublisherNumber', 'Publisher Number');
        $ViaHandle = C('Plugin.ShareThis.ViaHandle', '');
        $CopyNShare = C('Plugin.ShareThis.CopyNShare', false);
        $doNotHash = $CopyNShare ? 'false' : 'true';
        $doNotCopy = $CopyNShare ? 'false' : 'true';
        $Domain = Gdn::Request()->Scheme() == 'https' ? 'https://ws.sharethis.com' : 'http://w.sharethis.com';
        echo <<<SHARETHIS
      <script type="text/javascript">var switchTo5x=true;</script>
      <script type="text/javascript" src="{$Domain}/button/buttons.js"></script>
      <script type="text/javascript">stLight.options({
         publisher: "{$PublisherNumber}",
         doNotHash: {$doNotHash},
         doNotCopy: {$doNotCopy},
         hashAddressBar: false
      });</script>
      <div class="ShareThisButtonWrapper Right">
         <span class="st_twitter_hcount ShareThisButton" st_via="{$ViaHandle}" displayText="Tweet"></span>
         <span class="st_facebook_hcount ShareThisButton" displayText="Facebook"></span>
         <span class="st_linkedin_hcount ShareThisButton Hidden" displayText="LinkedIn"></span>
         <span class="st_googleplus_hcount ShareThisButton Hidden" displayText="Google +"></span>
         <span class="st_reddit_hcount ShareThisButton Hidden" displayText="Reddit"></span>
         <span class="st_pinterest_hcount ShareThisButton Hidden" displayText="Pinterest"></span>
         <span class="st_email_hcount ShareThisButton" displayText="Email"></span>
         <span class="st_sharethis_hcountShareThisButton" displayText="ShareThis"></span>
      </div>
SHARETHIS;
    }
Example #5
0
 /**
  * Builds and returns an anchor tag.
  */
 function Anchor($Text, $Destination = '', $CssClass = '', $Attributes = '', $ForceAnchor = FALSE)
 {
     if (!is_array($CssClass) && $CssClass != '') {
         $CssClass = array('class' => $CssClass);
     }
     if ($Destination == '' && $ForceAnchor === FALSE) {
         return $Text;
     }
     if ($Attributes == '') {
         $Attributes = array();
     }
     $SSL = GetValue('SSL', $Attributes, NULL);
     if ($SSL) {
         unset($Attributes['SSL']);
     }
     $WithDomain = GetValue('WithDomain', $Attributes, FALSE);
     if ($WithDomain) {
         unset($Attributes['WithDomain']);
     }
     $Prefix = substr($Destination, 0, 7);
     if (!in_array($Prefix, array('https:/', 'http://', 'mailto:')) && ($Destination != '' || $ForceAnchor === FALSE)) {
         $Destination = Gdn::Request()->Url($Destination, $WithDomain, $SSL);
     }
     return '<a href="' . htmlspecialchars($Destination, ENT_COMPAT, 'UTF-8') . '"' . Attribute($CssClass) . Attribute($Attributes) . '>' . $Text . '</a>';
 }
 public function Authenticate()
 {
     $ForeignIdentityUrl = C('Garden.Authenticator.AuthenticateURL');
     if (!$ForeignIdentityUrl) {
         return FALSE;
     }
     try {
         $Response = $this->_GetForeignCredentials($ForeignIdentityUrl);
         if (!$Response) {
             throw new Exception();
         }
         $SQL = Gdn::Database()->SQL();
         $Provider = $SQL->Select('uap.AuthenticationKey, uap.AssociationSecret')->From('UserAuthenticationProvider uap')->Get()->FirstRow(DATASET_TYPE_ARRAY);
         if (!$Provider) {
             throw new Exception();
         }
         // Got a response from the remote identity provider
         $UserEmail = ArrayValue('Email', $Response);
         $UserName = ArrayValue('Name', $Response);
         $UserName = trim(preg_replace('/[^a-z0-9-]+/i', '', $UserName));
         $AuthResponse = $this->ProcessAuthorizedRequest($Provider['AuthenticationKey'], $UserEmail, $UserName);
         if ($AuthResponse == Gdn_Authenticator::AUTH_SUCCESS) {
             Gdn::Request()->WithRoute('DefaultController');
         } elseif ($AuthResponse == Gdn_Authenticator::AUTH_PARTIAL) {
             Redirect(Url('/entry/handshake/proxy', TRUE), 302);
         } else {
             Gdn::Request()->WithRoute('DefaultController');
             throw new Exception('authentication failed');
         }
     } catch (Exception $e) {
         // Fallback to defer checking until the next session
         $this->SetIdentity(-1, FALSE);
     }
 }
   /**
    * Check whether or not the record is spam.
    * @param string $RecordType By default, this should be one of the following:
    *  - Comment: A comment.
    *  - Discussion: A discussion.
    *  - User: A user registration.
    * @param array $Data The record data.
    * @param array $Options Options for fine-tuning this method call.
    *  - Log: Log the record if it is found to be spam.
    */
   public static function IsSpam($RecordType, $Data, $Options = array()) {
      // Set some information about the user in the data.
      TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
      
      if ($RecordType == 'User') {
         TouchValue('Username', $Data, $Data['Name']);
      } else {
         TouchValue('Username', $Data, Gdn::Session()->User->Name);
         TouchValue('Email', $Data, Gdn::Session()->User->Email);
      }

      $Sp = self::_Instance();
      
      $Sp->EventArguments['RecordType'] = $RecordType;
      $Sp->EventArguments['Data'] = $Data;
      $Sp->EventArguments['Options'] = $Options;
      $Sp->EventArguments['IsSpam'] = FALSE;

      $Sp->FireEvent('CheckSpam');
      $Spam = $Sp->EventArguments['IsSpam'];

      // Log the spam entry.
      if ($Spam && GetValue('Log', $Options, TRUE)) {
         LogModel::Insert('Spam', $RecordType, $Data);
      }

      return $Spam;
   }
Example #8
0
 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function IsSpam($RecordType, $Data, $Options = array())
 {
     // Set some information about the user in the data.
     TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
     if ($RecordType == 'Registration') {
         TouchValue('Username', $Data, $Data['Name']);
     } else {
         TouchValue('Username', $Data, Gdn::Session()->User->Name);
         TouchValue('Email', $Data, Gdn::Session()->User->Email);
     }
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = FALSE;
     $Sp->FireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && GetValue('Log', $Options, TRUE)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::Insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
 /**
  * If the Garden.PrivateCommunity config setting is enabled,
  * then bypass the sign-in redirection and let the Basic Pages
  * view permission logic handle the redirection for
  * pages requested by guests.
  *
  * @param $Sender Gdn_Dispatcher
  */
 public function Gdn_Dispatcher_BeforeBlockDetect_Handler($Sender)
 {
     if (C('Garden.PrivateCommunity', false)) {
         $BlockExceptions =& $Sender->EventArguments['BlockExceptions'];
         $PathRequest = Gdn::Request()->Path();
         $PageModel = new PageModel();
         // Handle path requests that match "page/urlcode"
         $PathMatch = 'page/';
         if (substr($PathRequest, 0, strlen($PathMatch)) === $PathMatch) {
             $Page = $PageModel->GetByUrlCode(substr($PathRequest, strlen($PathMatch), strlen($PathRequest)));
             // Only bypass Garden.PrivateCommunity redirection if custom page view permission is enabled.
             if (isset($Page->ViewPermission) && (bool) $Page->ViewPermission) {
                 $BlockExceptions['/^page(\\/.*)?$/'] = Gdn_Dispatcher::BLOCK_NEVER;
             }
         } else {
             if (!strstr($PathRequest, '/')) {
                 // NOTE: Increases overhead every time the Dispatch method is called.
                 //       There is room for optimization to be done here.
                 //
                 // Handle path requests which don't contain a forward slash
                 // because the request could possibly be for a page with
                 // a path of "urlcode"
                 $Page = $PageModel->GetByUrlCode($PathRequest);
                 // Only bypass Garden.PrivateCommunity redirection if custom page view permission is enabled.
                 if (isset($Page->ViewPermission) && (bool) $Page->ViewPermission) {
                     $BlockExceptions['/^' . $PathRequest . '(\\/.*)?$/'] = Gdn_Dispatcher::BLOCK_NEVER;
                 }
             }
         }
     }
 }
 function ValidateCaptcha($Value = NULL)
 {
     require_once PATH_LIBRARY . '/vendors/recaptcha/functions.recaptchalib.php';
     $CaptchaPrivateKey = C('Garden.Registration.CaptchaPrivateKey', '');
     $Response = recaptcha_check_answer($CaptchaPrivateKey, Gdn::Request()->IpAddress(), Gdn::Request()->Post('recaptcha_challenge_field', ''), Gdn::Request()->Post('recaptcha_response_field', ''));
     return $Response->is_valid ? TRUE : 'The reCAPTCHA value was not entered correctly. Please try again.';
 }
Example #11
0
 public function GetWebResource($Filepath)
 {
     $WebResource = $this->GetResource($Filename, FALSE, FALSE);
     if (Gdn::Request()->WebRoot()) {
         $WebResource = Gdn::Request()->WebRoot() . '/' . $WebResource;
     }
     return '/' . $WebResource;
 }
Example #12
0
 /**
  * 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)
 {
     $Result = Gdn::Request()->Path();
     if ($WithWebRoot) {
         $Result = self::WebRoot($WithDomain) . '/' . $Result;
     }
     return $Result;
 }
Example #13
0
 function __construct()
 {
     $this->trustRoot = Gdn::Request()->Scheme() . '://' . Gdn::Request()->Host();
     $uri = rtrim(preg_replace('#((?<=\\?)|&)openid\\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
     $this->returnUrl = $this->trustRoot . $uri;
     $this->data = $_POST + $_GET;
     # OPs may send data as POST or GET.
 }
Example #14
0
 protected function _AttachBadge(&$Sender)
 {
     $badge = ArrayValue($Sender->EventArguments['Author']->UserID, $Sender->Data('Plugin-Badge-Counts'));
     if ($badge > 0) {
         $icon = file_exists('plugins/TopPosters/badges/' . $badge . '.png') ? $badge . '.png' : 'medal-icon.png';
         echo '<span><img src="' . str_replace("index.php?p=", "", Gdn::Request()->Domain() . Url('plugins/TopPosters/badges/' . $icon)) . '" style="width:16px;height:16px;vertical-align:middle"></span>';
     }
 }
 public function Base_BeforeDispatch_Handler($Sender)
 {
     $Request = Gdn::Request();
     $Folder = ltrim($Request->RequestFolder(), '/');
     $Uri = ltrim($_SERVER['REQUEST_URI'], '/');
     // Fix the url in the request for routing.
     if (preg_match("`^{$Folder}index.php/`", $Uri)) {
         $Request->PathAndQuery(substr($Uri, strlen($Folder)));
     }
 }
 public function Base_Render_Before(&$Sender) {
    if (($Filename = Gdn::Request()->Filename()) && $Filename != 'default') {
       $Parts = explode('.',$Filename);
       $Prefix = array_shift($Parts); $Suffix = array_pop($Parts);
       if ($Prefix == 'sitemap' && $Suffix == 'xml') {
          $this->RenderMap($Sender, $Filename);
          exit();
       }
    }
 }
   /**
    * Render the given view.
    *
    * @param string $Path The path to the view's file.
    * @param Controller $Controller The controller that is rendering the view.
    */
   public function Render($Path, $Controller) {
      $Smarty = $this->Smarty();

      // Get a friendly name for the controller.
      $ControllerName = get_class($Controller);
      if (StringEndsWith($ControllerName, 'Controller', TRUE)) {
         $ControllerName = substr($ControllerName, 0, -10);
      }

      // Get an ID for the body.
      $BodyIdentifier = strtolower($Controller->ApplicationFolder.'_'.$ControllerName.'_'.Gdn_Format::AlphaNumeric(strtolower($Controller->RequestMethod)));
      $Smarty->assign('BodyID', $BodyIdentifier);
      //$Smarty->assign('Config', Gdn::Config());

      // Assign some information about the user.
      $Session = Gdn::Session();
      if($Session->IsValid()) {
         $User = array(
            'Name' => $Session->User->Name,
            'CountNotifications' => (int)GetValue('CountNotifications', $Session->User->CountNotifications, 0),
            'CountUnreadConversations' => (int)GetValue('CountUnreadConversations', $Session->User, 0),
            'SignedIn' => TRUE);
      } else {
         $User = FALSE; /*array(
            'Name' => '',
            'CountNotifications' => 0,
            'SignedIn' => FALSE);*/
      }
      $Smarty->assign('User', $User);

      // Make sure that any datasets use arrays instead of objects.
      foreach($Controller->Data as $Key => $Value) {
         if($Value instanceof Gdn_DataSet) {
            $Controller->Data[$Key] = $Value->ResultArray();
         } elseif($Value instanceof stdClass) {
            $Controller->Data[$Key] = (array)$Value;
         }
      }
     
      $Controller->Data['BodyClass'] = GetValue('CssClass', $Controller->Data, '', TRUE);

      $Smarty->assign('Assets', (array)$Controller->Assets);
      $Smarty->assign('Path', Gdn::Request()->Path());

      // Assigign the controller data last so the controllers override any default data.
      $Smarty->assign($Controller->Data);

      $Smarty->Controller = $Controller; // for smarty plugins
      $Smarty->security = TRUE;
      $Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'],
         array('CheckPermission', 'GetValue', 'SetValue', 'Url'));
      $Smarty->secure_dir = array($Path);
      $Smarty->display($Path);
   }
 /**
  * Use 404 handler to look for a SimplePage.
  */
 public function gdn_dispatcher_notFound_handler($dispatcher, $args)
 {
     $requestUri = Gdn::Request()->Path();
     $discussionModel = new DiscussionModel();
     $result = $discussionModel->GetWhere(array('Type' => 'SimplePage', 'ForeignID' => $requestUri))->FirstRow(DATASET_TYPE_ARRAY);
     // Page exists with requested slug, so dispatch; no redirect.
     if ($discussionID = val('DiscussionID', $result)) {
         SaveToConfig('SimplePage.Found', true, false);
         Gdn::Dispatcher()->Dispatch('/discussion/' . $discussionID);
         exit;
     }
 }
Example #19
0
    public function SettingsController_Render_Before($Sender)
    {
        // Have they visited their dashboard?
        if (strtolower($Sender->RequestMethod) != 'index') {
            $this->SaveStep('Plugins.GettingStarted.Dashboard');
        }
        // Save the action if editing registration settings
        if (strcasecmp($Sender->RequestMethod, 'registration') == 0 && $Sender->Form->AuthenticatedPostBack() === TRUE) {
            $this->SaveStep('Plugins.GettingStarted.Registration');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'plugins') == 0) {
            $this->SaveStep('Plugins.GettingStarted.Plugins');
        }
        // Save the action if they reviewed plugins
        if (strcasecmp($Sender->RequestMethod, 'managecategories') == 0) {
            $this->SaveStep('Plugins.GettingStarted.Categories');
        }
        // Add messages & their css on dashboard
        if (strcasecmp($Sender->RequestMethod, 'index') == 0) {
            $Sender->AddCssFile('plugins/GettingStarted/style.css');
            $Session = Gdn::Session();
            $WelcomeMessage = '<div class="GettingStarted">' . Anchor('×', '/dashboard/plugin/dismissgettingstarted/' . $Session->TransientKey(), 'Dismiss') . "<h1>" . T("Here's how to get started:") . "</h1>" . '<ul>
      <li class="One' . (C('Plugins.GettingStarted.Dashboard', '0') == '1' ? ' Done' : '') . '">
	 <strong>' . Anchor(T('Welcome to your Dashboard'), 'settings') . '</strong>
         <p>' . T('This is the administrative dashboard for your new community. Check out the configuration options to the left: from here you can configure how your community works. <b>Only users in the "Administrator" role can see this part of your community.</b>') . '</p>
      </li>
      <li class="Two' . (C('Plugins.GettingStarted.Discussions', '0') == '1' ? ' Done' : '') . '">
	 <strong>' . Anchor(T("Where is your Community Forum?"), '/') . '</strong>
         <p>' . T('Access your community forum by clicking the "Visit Site" link on the top-left of this page, or by ') . Anchor(T('clicking here'), '/') . T('. The community forum is what all of your users &amp; customers will see when they visit ') . Anchor(Gdn::Request()->Url('/', TRUE), Gdn::Request()->Url('/', TRUE)) . '.</p>
      </li>
      <li class="Three' . (C('Plugins.GettingStarted.Categories', '0') == '1' ? ' Done' : '') . '">
         <strong>' . Anchor(T('Organize your Categories'), 'vanilla/settings/managecategories') . '</strong>
         <p>' . T('Discussion categories are used to help your users organize their discussions in a way that is meaningful for your community.') . '</p>
      </li>
      <li class="Four' . (C('Plugins.GettingStarted.Profile', '0') == '1' ? ' Done' : '') . '">
         <strong>' . Anchor(T('Customize your Public Profile'), 'profile') . '</strong>
         <p>' . T('Everyone who signs up for your community gets a public profile page where they can upload a picture of themselves, manage their profile settings, and track cool things going on in the community. You should ') . Anchor(T('customize your profile now'), 'profile') . '.</p>
      </li>
      <li class="Five' . (C('Plugins.GettingStarted.Discussion', '0') == '1' ? ' Done' : '') . '">
         <strong>' . Anchor(T('Start your First Discussion'), 'post/discussion') . '</strong>
	 <p>' . T('Get the ball rolling in your community by ') . Anchor(T('starting your first discussion'), 'post/discussion') . T(' now.') . '</p>
      </li>
      <li class="Six' . (C('Plugins.GettingStarted.Plugins', '0') == '1' ? ' Done' : '') . '">
         <strong>' . Anchor(T('Manage your Plugins'), 'settings/plugins') . '</strong>
         <p>' . T('Change the way your community works with plugins. We\'ve bundled popular plugins with the software, and there are more available online.') . '</p>
      </li>
   </ul>
</div>';
            $Sender->AddAsset('Messages', $WelcomeMessage, 'WelcomeMessage');
        }
    }
 public function __construct()
 {
     // If geoip values do not exist, just set default "VF," vanilla forum
     // country code, i.e., unknown.
     $this->user_country = Gdn::Request()->GetValueFrom(Gdn_Request::INPUT_SERVER, 'GEOIP_COUNTRY_CODE', $this->default_country_code);
     // If country code was set to VF, it's most likely because the GeoIP module
     // is not installed, or it's running on a local machine, so let user know.
     if ($this->user_country !== $this->default_country_code) {
         $this->geoip_installed = true;
     }
     // This option was commented out in Gdn_Format (ToTimestamp, line 1150),
     // so just use function call
     $this->time_now = time();
 }
 protected function _AuthorizeHref($Popup = FALSE)
 {
     $Url = Url('/entry/openid', TRUE);
     $UrlParts = explode('?', $Url);
     parse_str(GetValue(1, $UrlParts, ''), $Query);
     $Query['url'] = 'https://www.google.com/accounts/o8/id';
     $Path = '/' . Gdn::Request()->Path();
     $Query['Target'] = GetValue('Target', $_GET, $Path ? $Path : '/');
     if ($Popup) {
         $Query['display'] = 'popup';
     }
     $Result = $UrlParts[0] . '?' . http_build_query($Query);
     return $Result;
 }
 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function IsSpam($RecordType, $Data, $Options = array())
 {
     if (self::$Disabled) {
         return FALSE;
     }
     // Set some information about the user in the data.
     if ($RecordType == 'Registration') {
         TouchValue('Username', $Data, $Data['Name']);
     } else {
         TouchValue('InsertUserID', $Data, Gdn::Session()->UserID);
         $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY);
         if ($User) {
             if (GetValue('Verified', $User)) {
                 // The user has been verified and isn't a spammer.
                 return FALSE;
             }
             TouchValue('Username', $Data, $User['Name']);
             TouchValue('Email', $Data, $User['Email']);
             TouchValue('IPAddress', $Data, $User['LastIPAddress']);
         }
     }
     if (!isset($Data['Body']) && isset($Data['Story'])) {
         $Data['Body'] = $Data['Story'];
     }
     TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = FALSE;
     $Sp->FireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && GetValue('Log', $Options, TRUE)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
             case 'Activity':
             case 'ActivityComment':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::Insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
Example #23
0
 public function ProfileController_AfterAddSideMenu_Handler($Sender, $Args)
 {
     if (!$Sender->User->Photo) {
         $Email = GetValue('Email', $Sender->User);
         $Protocol = Gdn::Request()->Scheme() == 'https' ? 'https://secure.' : 'http://www.';
         $Url = $Protocol . 'gravatar.com/avatar.php?' . 'gravatar_id=' . md5(strtolower($Email)) . '&amp;size=' . C('Garden.Profile.MaxWidth', 200);
         if (C('Plugins.Gravatar.UseVanillicon', TRUE)) {
             $Url .= '&default=' . urlencode(Gdn::Request()->Scheme() . '://vanillicon.com/' . md5($Email) . '_200.png');
         } else {
             $Url .= '&default=' . urlencode(Asset(C('Plugins.Gravatar.DefaultAvatar', 'plugins/Gravatar/default_250.png'), TRUE));
         }
         $Sender->User->Photo = $Url;
     }
 }
Example #24
0
 public function Execute()
 {
     $SliceArgs = func_get_args();
     switch (count($SliceArgs)) {
         case 1:
             $Request = Gdn::Request()->Create()->FromEnvironment()->WithURI($SliceArgs[0])->WithDeliveryType(DELIVERY_TYPE_VIEW);
             ob_start();
             $this->Dispatcher->Dispatch($Request, FALSE);
             return ob_get_clean();
             break;
         case 2:
             break;
     }
 }
 protected function _AuthorizeHref($Popup = FALSE)
 {
     $Url = Url('/entry/sinaauthorize', TRUE);
     $UrlParts = explode('?', $Url);
     parse_str(GetValue(1, $UrlParts, ''), $Query);
     $Path = Gdn::Request()->Path();
     $Query['Target'] = GetValue('Target', $_GET, $Path ? $Path : '/');
     //      if (isset($_GET['Target']))
     //         $Query['Target'] = $_GET['Target'];
     if ($Popup) {
         $Query['display'] = 'popup';
     }
     $Result = $UrlParts[0] . '?' . http_build_query($Query);
     return $Result;
 }
 private function PrepareDiscussionList($Sender)
 {
     // Make the table view render just the inner content, similar to the modern view.
     if (C('Vanilla.Discussions.Layout') == 'table' && Gdn::Request()->Get('InnerList')) {
         $Sender->View = $this->GetView('inner_table.php');
     }
     $Page = (int) filter_var($Sender->Data('_Page'), FILTER_SANITIZE_NUMBER_INT);
     $Page = $Page > 1 ? $Page : 1;
     $CountDiscussions = $Sender->Data('CountDiscussions');
     $TotalPages = CalculateNumberOfPages($CountDiscussions, C('Vanilla.Discussions.PerPage', 30));
     $Sender->AddDefinition('InfiniteScroll.CountItems', $CountDiscussions);
     $Sender->AddDefinition('InfiniteScroll.Page', $Page);
     $Sender->AddDefinition('InfiniteScroll.TotalPages', $TotalPages);
     $Sender->AddDefinition('InfiniteScroll.PerPage', (int) C('Vanilla.Discussions.PerPage', 30));
     $this->BuildNavigation($Sender, $CountDiscussions, $TotalPages);
 }
 public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender)
 {
     // Admins not affected
     if (Gdn::Session()->IsValid() && Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
         return;
     }
     // Allow signing in
     $PathRequest = Gdn::Request()->Path();
     if (preg_match('/entry(\\/.*)?$/', $PathRequest)) {
         return;
     }
     // Send proper headers
     header('Status: 503 Service Unavailable', TRUE, 503);
     header('Retry-After: Wed, 18 Jan 2012 23:59:59 GMT', TRUE);
     Gdn::Request()->WithURI("/plugin/stopsopa");
 }
 /**
  * Set the preference in the user's session.
  */
 public function SetToggle()
 {
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     $ShowAllCategories = GetIncomingValue('ShowAllCategories', '');
     if ($ShowAllCategories != '') {
         $ShowAllCategories = $ShowAllCategories == 'true' ? TRUE : FALSE;
         $ShowAllCategoriesPref = $Session->GetPreference('ShowAllCategories');
         if ($ShowAllCategories != $ShowAllCategoriesPref) {
             $Session->SetPreference('ShowAllCategories', $ShowAllCategories);
         }
         Redirect('/' . ltrim(Gdn::Request()->Path(), '/'));
     }
 }
Example #29
0
 /**
  * @return Akismet
  */
 public static function Akismet()
 {
     static $Akismet;
     if (!$Akismet) {
         $Key = C('Plugins.Akismet.Key', C('Plugins.Akismet.MasterKey'));
         if (!$Key) {
             return NULL;
         }
         $Akismet = new Akismet(Gdn::Request()->Url('/', TRUE), $Key);
         $Server = C('Plugins.Akismet.Server');
         if ($Server) {
             $Akismet->setAkismetServer($Server);
         }
     }
     return $Akismet;
 }
 protected function _AuthorizeHref($Popup = FALSE)
 {
     $Url = Url('/entry/twauthorize', TRUE);
     $UrlParts = explode('?', $Url);
     parse_str(GetValue(1, $UrlParts, ''), $Query);
     $Path = Gdn::Request()->Path();
     $Target = GetValue('Target', $_GET, $Path ? $Path : '/');
     if (ltrim($Target, '/') == 'entry/signin') {
         $Target = '/';
     }
     $Query['Target'] = $Target;
     if ($Popup) {
         $Query['display'] = 'popup';
     }
     $Result = $UrlParts[0] . '?' . http_build_query($Query);
     return $Result;
 }