【问题标题】:joomla - JFactory::getApplication()->input troublejoomla - JFactory::getApplication()->输入问题
【发布时间】:2014-05-03 20:11:47
【问题描述】:

我在我的项目中使用 joomla 3.0。然后我尝试开发自己的模块...

在模块主代码中我有这样的部分:

`<?php
defined('_JEXEC') or die('Direct Access to this location is not allowed.');

require_once('helper.php');

JHTML::stylesheet('styles.css','modules/mod_get_call/css/');

//require_once('recaptchalib.php');
$privatekey = "6Ldc2_ISAAAAAABrb****Gr9c_";
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field2"] );

$input = JFactory::getApplication()->input; // only once on each method
$form_send = $input->get('form_send', 'notsend');

    switch($form_send){
        case 'send':
            $organization = $input->get('organization', 'No organization entered');
            $phone = $input->get('phone', 'No phone entered');
            $e_mail = $input->get('e_mail', 'No e_mail entered');
            $skype = $input->get('skype', 'No skype entered');
            $comment = $input->get('comment', 'No comment entered');
            //JFactory::getApplication()->enqueueMessage(JText::_($organization), 'error');
            if ($resp->is_valid == true)
                $send = ModGetCallHelper::SendMail($organization, $phone, $e_mail, $skype, $comment);
            else{
                require(JModuleHelper::getLayoutPath('mod_get_call', 'wrong_input_tmplc'));
                break; 
            }****`

一切正常,就在我提交 $e_mail 时,它没有 @ 符号,当我输入俄语字母时 - 我看到空变量。当我尝试写$_POST["e_mail"] - 一切都好。但是如何在 JFactory::getApplication()-&gt;input 中使用俄罗斯符号呢?我做错了什么?

【问题讨论】:

    标签: joomla http-post


    【解决方案1】:

    当您没有输入类型时,您将默认使用 Word 作为输入过滤器。你真的不应该像现在这样使用$input-&gt;get(),使用$input-&gt;getString()$input-&gt;getInt()之类的东西。这将为您提供正确的输入过滤。阅读 JInput 类文档块了解更多详细信息。

    同时不要像那样硬编码你的私钥,它是不可维护的,如果你需要生成一个新的密钥怎么办?

    【讨论】:

    • "如果需要生成新密钥怎么办?"将去代码和更改
    • @brabertaser1992 没错,Elin 的想法太超前了……为未来的自己努力生活。
    猜你喜欢
    • 2016-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多