0

Aloha 伙计们,我有一个 Fangate,它的用户,取决于它是否是粉丝,fan.php 或输出 nofan.php。fangate 工作正常,nofan.php 也正常工作。在 fan.php 中有一个基于 PHP 的联系表格。当我直接调用此文件时,它可以工作。当我通过我的 Facebook 应用程序运行该文件时,不会解析 PHP 代码。

在 PHP 短标签上它不是,我试过了。我想我可能只使用了错误版本的 PHP。但是,当我写入addHandler php5-cgi. php我的。Htaccess 似乎仅此而已。

这是我的方门(工作没有问题):

<?php

require 'facebook.php';
$app_id = "blablabla";
$app_secret = "blablabla";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));

$signed_request = $facebook->getSignedRequest();

$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];

// If a fan is on your page
if ($like_status) {
$a = file_get_contents("fan.php");
echo ($a);
} else {
// If a non-fan is on your page
$a = file_get_contents("nofan.php");
echo ($a);
}

?>

这是我的fan.php:

<?php


// Receiver E-Mail Adress
$receiver = "test@test.de";

if ((isset($_POST["action"])) && ($_POST["action"] == "sendform"))
{
    include($this_module_path."phpmailer/class.phpmailer.php");
    $mail = new PHPMailer();
    $mail->From = $_POST["email"];
    $mail->FromName = $_POST["vorname"."name"];
    $mail->AddAddress($receiver);
    $mail->Subject = "SCHWERIN live - Formular Facebook";

    $mail_msg = $mod_lang["de"][12]." \n";
                $mail_msg = $_POST["message"]." \n";
                $mail_msg .= " \n";
                $mail_msg .= "Antwort       : ". $_POST["antwort"]." \n";
                $mail_msg .= "Name          : ". $_POST["vorname"]." ".$_POST["name"]." \n";
                $mail_msg .= "Telefonnummer : ". $_POST["telefon"]." \n";
                $mail_msg .= "Mail-Adresse  : ". $_POST["email"]." \n";
                $mail_msg .= " \n";
                $mail_msg .= " \n";
                $mail_msg .= "Gewinnspiel";
    $mail->Body = $mail_msg;
    if($mail->Send())
    {
        echo "<p>Hallo ". $_POST["vorname"]."!</p>";
    }
    else
    {
        echo "<p><b>FEHLER: mail server problem.</b></p>";
    }
}
else
{
?>
<script language="Javascript">

function regexmail(mail)
{
    var regexist = false;
    var res = false;
    if(typeof(RegExp) == 'function')
    {
        var testregex = new RegExp('abc');
        if(testregex.test('abc') == true)
        {
            regexist = true;
        }
    }

    if(regexist == true)
    {
        reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$');
        res = (reg.test(mail));
    }
    else
    {
        res = (mail.search('@') >= 1 && mail.lastIndexOf('.') > mail.search('@') && mail.lastIndexOf('.') >= mail.length-5)
    }
    return(res);
}

function sendForm()
{
    if ((document.contactform.email.value != "") && (document.contactform.vorname.value != "") && (document.contactform.name.value != "") && (document.contactform.telefon.value !="") && (regexmail(document.contactform.email.value)))
    {
        document.contactform.submit();
    }
    else
    {
        document.getElementById("checkEmail").innerHTML = "";
        document.getElementById("checkVorname").innerHTML = "";
        document.getElementById("checkName").innerHTML = "";
        document.getElementById("checkTelefon").innerHTML = "";
        if (document.contactform.email.value == "")
        {
            document.getElementById("checkEmail").innerHTML = "<li class='clearfix'><fehler for='fehler1'>Fehler</fehler><fehlerscript for='fehler1'>Ung&uuml;ltige E-Mail Adresse!</fehlerscript></li>";
        }
        else
        {
            if (!regexmail(document.contactform.email.value))
            {
                document.getElementById("checkEmail").innerHTML = "<li class='clearfix'><fehler for='fehler2'>Fehler</fehler><fehlerscript for='fehler2'>Die Mail-Adresse fehlt!</fehlerscript></li>";
            }
        }
        if (document.contactform.vorname.value == "")
        {
            document.getElementById("checkVorname").innerHTML = "<li class='clearfix'><fehler for='fehler3'>Fehler</fehler><fehlerscript for='fehler3'>Der Vorname fehlt</fehlerscript></li>";
        }
        if (document.contactform.name.value == "")
        {
            document.getElementById("checkName").innerHTML = "<li class='clearfix'><fehler for='fehler4'>Fehler</fehler><fehlerscript for='fehler3'>Der Nachname fehlt</fehlerscript></li>";
        }
        if (document.contactform.telefon.value == "")
        {
            document.getElementById("checkTelefon").innerHTML = "<li class='clearfix'><fehler for='fehler8'>Fehler</fehler><fehlerscript for='fehler3'>Die Telefonnummer fehlt</fehlerscript></li>";
        }
    }
}
</script>

<form name="contactform" method="POST" id='contact_form' />
<ul>
  <li class="clearfix"> 
  <input type="hidden" name="action" value="sendform">
<label for="antwort">Antwort*</label>
<input type='text' name='antwort' id='vorname' /></li>
<li class="clearfix">
<label for="vorname">Vorname</label>
<input type='text' name='vorname' id='vorname' /></li>
<li class="clearfix"> 
<label for="nachname">Nachname</label>
<input type='text' name='name' id='name' /></li>
<li class="clearfix"> 
<label for="email">E-Mail</label>
<input type='text' name='email' id='email' /></li>
<li class="clearfix"> 
<label for="telefon">Telefon</label>
<input type='text' name='telefon' id='telefon' /></li>
<li class="clearfix"> 
<label for="datenschutz">Bestätigen!</label>
<input type="button" class="datenschutzbutton" value="Ja!" onClick="return toggleMe('para02')" href="javascript:void(0)">
</li>
<div id="checkVorname"></div>
<div id="checkName"></div>
<div id="checkEmail"></div>
<div id="checkTelefon"></div>
<div style="display:none;" id="para02"><li class="clearfix"><label for="nachricht">&nbsp;</label><input type="button" class="kontaktbutton" value="Meine Daten absenden" onClick="sendForm()"></div>
</li> 
</ul> 
</form>
<?php
}
?>

有任何想法吗?

4

1 回答 1

2

file_get_contents() 是错误的函数。这会将文件包含为纯字符串。请改用 include(FILENAME)。

//编辑:

if ($like_status) {
include("fan.php");
} else {
// If a non-fan is on your page
include("nofan.php");
}
于 2013-04-10T16:12:53.973 回答