2013-04-10 70 views
0

阿羅哈傢伙, 我有一個Fangate,其中的用戶,根據它是否是粉絲,fan.php或輸出nofan.php。正確的工作,也nofan.php工作沒有問題。在fan.php中有一個基於PHP的聯繫表單。當我直接調用這個文件時,它可以工作。當我通過我的Facebook應用運行該文件時,PHP代碼不會被解析。PHP不在Facebook中解析

在PHP短標籤上它不是,我試過了。我想我可能只使用PHP的錯誤版本。但是,當我寫入addHandler php5-cgi. php到我的。 Htaccess什麼都沒有。

這裏是我的Fangate(工作沒有問題):

<?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 = "[email protected]"; 

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 
} 
?> 

什麼想法?

+0

什麼是fangate – 2013-04-10 16:09:59

回答

2

file_get_contents()是錯誤的函數。這將包括文件作爲純字符串。 改用include(FILENAME)。

//編輯:

if ($like_status) { 
include("fan.php"); 
} else { 
// If a non-fan is on your page 
include("nofan.php"); 
} 
+0

絕對太棒了!謝謝,那是錯誤的......下一杯啤酒就在我身上;) – 2013-04-10 16:47:48