내가 일하고 있어요 스크립트에 약간의 문제가있어를 사용하여 파일로, 이것은 내가 실행 해요 무엇 : 어떻게 스크립트 작품에 대해 모든 비트의저장 PHP 코드에 fwrite
우선 . 실제로 WordPress (플러그인 임)를 사용하며 백엔드에서 변경할 수있는 다양한 설정을 기반으로 동적 페이지를 만듭니다. 플러그인으로 페이지를 이미 만든 후 해당 페이지의 정적 버전을 만들 수있는 HTML로 내보내기 기능을 추가하고 있습니다.
내 보낸이 페이지에서 파일의 맨 위에 PHP 함수를 저장하고 다른 페이지에 다른 PHP 함수를 저장해야합니다.
$fbscript=file_get_contents('fbscript.txt');
$newcontent=str_replace('<!-- dont erase this line -->',$fbscript,$newcontent);
$fbscript2=file_get_contents('fbscript2.txt');
$newcontent=str_replace('<!-- dont erase this line 2 -->',$fbscript2,$newcontent);
2 개의 dont erase this line
가지가 스크립트를 넣을 필요가 동적 페이지에 어딘가에 : 이것은 내가 할 노력하고있어 것입니다. 이 보낸 페이지에 어딘가에 보여주는 것입니다 :
<br />
<b>Notice</b>: Undefined index: signed_request in <b>C:\xampp\htdocs\wp\wp-content\plugins\easyfanpagedesign\default.theme\htmlpost-31345.php</b> on line <b>82</b><br />
<br />
<b>Notice</b>: Undefined offset: 1 in <b>C:\xampp\htdocs\wp\wp-content\plugins\easyfanpagedesign\default.theme\htmlpost-31345.php</b> on line <b>3</b><br />
그래서 내가 정말 물어 노력하고있어 생각 나는 .php
확장자에 fwrite 사용하여 파일을 저장하고 내부의 PHP 스크립트를 가질 수있는 방법입니다 저장된 파일.
<?php
$content=$_POST['efpd_page_content'];
$uistyle=$_POST['efpd_ui_style'];
$app_id=$_POST['efpd_appid'];
$the_fscripts=$_POST['efpd_fscripts'];
$the_hscripts=$_POST['efpd_hscripts'];
$bgstuff=$_POST['efpd_bgstuff'];
$jquery=$_POST['efpd_jquery'];
$jqueryui=$_POST['efpd_jqueryui'];
$cycle=$_POST['efpd_cycle'];
$copytext=$_POST['efpd_copytext'];
$affstr=$_POST['efpd_affstr'];
$the_style=$_POST['efpd_style'];
$the_gwf=$_POST['efpd_gwfstyle'];
$secret=$_POST['efpd_secret'];
if(empty($secret)){$secret=999999;}
$newcontent=file_get_contents($_POST['efpd_refurl']);
$fbscript=file_get_contents('fbscript.txt');
$newcontent=str_replace('<!-- dont erase this line -->',$fbscript,$newcontent);
$fbscript2=file_get_contents('fbscript2.txt');
$newcontent=str_replace('<!-- dont erase this line 2 -->',$fbscript2,$newcontent);
$newcontent=str_replace('THE_SECRET',$secret,$newcontent);
//die(var_dump($newcontent));
$int=rand(1,99999);
$savefile = "htmlpost-$int.php";
$handle = fopen($savefile, 'w') or die("can't open file");
fwrite($handle,$newcontent);
fclose($handle);
echo "<a href='$savefile'>Right Click > Save As to download the generated HTML page.</a>";
?>
:이 모든 것을 수행 내 전체 export.php 파일이
<?php
function parsePageSignedRequesttt($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
return null;
}
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
?>
입니다 : 이것은 내가에 fwrite (페이스 북의 PHP SDK)를 사용하여 저장된 페이지에 추가 할 노력하고있어 PHP 스크립트의 예입니다
코드의 어느 부분이'$ _REQUEST [ 'signed_request']'여야합니다. 맞습니까? – Niko
페이지 중간에 추가 된 두 번째 스크립트 (fbscript2.txt) – Jared
그래, 그게 바로이 오류가 표시되는 이유입니다. 그 페이지는 페이 스북 (Facebook)의 앱으로 의도 된 것 같고 실제로 거기서 실행하지 마십시오 (지금까지?). – Niko