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


PHP JFactory::getInput方法代码示例

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


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

示例1: submitPost

 /**
  * Method for submitting the post
  *
  * @param   JInput     $post  The filtered post superglobal.
  *
  * @return  mixed  Integer of the post inserted on success, false on failure.
  *
  * @since   __DEPLOY_VERSION__
  * @throws  RuntimeException
  */
 private function submitPost($post)
 {
     // Get the user instance
     $user = JFactory::getUser();
     $displayName = $this->params->get('loginname', 'user');
     $securityType = $this->params->get('securitytype', 0);
     $securityHide = $this->params->get('security-hide', 0);
     $swearCounter = $this->params->get('swearingcounter');
     $swearNumber = $this->params->get('swearingnumber');
     // If we submitted by PHP check for a session token
     if ($this->ajax || $_SESSION['token'] == $post['token']) {
         JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
         if ($securityType == 1) {
             if ($securityHide == 0 || $user->guest && $securityHide == 1) {
                 // Recaptcha fields aren't in the JJ post space so we have to grab these separately
                 $input = JFactory::getApplication()->input;
                 $challengeField = $input->get('g-recaptcha-response', '', 'string');
                 // Require Recaptcha Library
                 spl_autoload_register(function ($class) {
                     // Project-specific namespace prefix
                     $prefix = 'ReCaptcha\\';
                     // Base directory for the namespace prefix
                     $base_dir = JPATH_ROOT . '/media/mod_shoutbox/recaptcha/';
                     // Does the class use the namespace prefix?
                     $len = strlen($prefix);
                     if (strncmp($prefix, $class, $len) !== 0) {
                         // No, move to the next registered autoloader
                         return;
                     }
                     // Get the relative class name
                     $relative_class = substr($class, $len);
                     /**
                      * replace the namespace prefix with the base directory, replace namespace
                      * separators with directory separators in the relative class name, append
                      * with .php
                      */
                     $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
                     // if the file exists, require it
                     if (file_exists($file)) {
                         require $file;
                     }
                 });
                 $recaptcha = new ReCaptcha\ReCaptcha($this->params->get('recaptcha-private'));
                 $resp = $recaptcha->verify($challengeField, JFactory::getInput()->server->get('REMOTE_ADDR'));
                 if ($resp->isSuccess()) {
                     return $this->postFiltering($post, $user, $swearCounter, $swearNumber, $displayName, $this->params);
                 }
                 // Invalid submission of post. Throw an error.
                 $error = '';
                 foreach ($resp->getErrorCodes() as $code) {
                     $error .= $code;
                 }
                 throw new RuntimeException($error);
             } else {
                 return $this->postFiltering($post, $user, $swearCounter, $swearNumber, $displayName, $this->params);
             }
         } elseif ($securityType == 2) {
             if ($securityHide == 0 || $user->guest && $securityHide == 1) {
                 // Our maths security question is on
                 if (isset($post['sum1']) && isset($post['sum2'])) {
                     $que_result = $post['sum1'] + $post['sum2'];
                     if (isset($post['human'])) {
                         if ($post['human'] != $que_result) {
                             throw new RuntimeException(JText::_('SHOUT_ANSWER_INCORRECT'));
                         }
                         return $this->postFiltering($post, $user, $swearCounter, $swearNumber, $displayName, $this->params);
                     }
                 }
             } else {
                 return $this->postFiltering($post, $user, $swearCounter, $swearNumber, $displayName, $this->params);
             }
         } else {
             return $this->postFiltering($post, $user, $swearCounter, $swearNumber, $displayName, $this->params);
         }
     }
 }
开发者ID:MATsxm,项目名称:shoutbox,代码行数:86,代码来源:helper.php


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