本文整理汇总了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);
}
}
}