Cách Chạy Code PHP Trong Post Và Page
Installation
copy code ở dưới đây
.*<\\/phpcode>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
$stop = count($textarr);// loop stuff
for ($phpexec_i = 0; $phpexec_i < $stop; $phpexec_i++) {
$content = $textarr[$phpexec_i];
if (preg_match("/^(.*)<\\/phpcode>/Us", $content, $code)) { // If it's a phpcode
$content = '[phpcode]' . base64_encode($code[1]) . '[/phpcode]';
}
$output .= $content;
}
return $output;
}
### unmask code after balanceTags ###
function php_exec_post($text) {
$textarr = preg_split("/(\\[phpcode\\].*\\[\\/phpcode\\])/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
$stop = count($textarr);// loop stuff
for ($phpexec_i = 0; $phpexec_i < $stop; $phpexec_i++) {
$content = $textarr[$phpexec_i];
if (preg_match("/^\\[phpcode\\](.*)\\[\\/phpcode\\]/Us", $content, $code)) { // If it's a phpcode
$content = '' . base64_decode($code[1]) . '';
}
$output .= $content;
}
return $output;
}
### main routine ###
function php_exec_process($phpexec_text) {
$phpexec_userdata = get_userdatabylogin(the_author('login',false));
if($phpexec_userdata->user_level >= php_exec_getuserlevel()){
$phpexec_doeval = true;
}
$phpexec_textarr = preg_split("/(.*<\\/phpcode>)/Us", $phpexec_text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between
$phpexec_stop = count($phpexec_textarr);// loop stuff
for ($phpexec_i = 0; $phpexec_i < $phpexec_stop; $phpexec_i++) {
$phpexec_content = $phpexec_textarr[$phpexec_i];
if (preg_match("/^(.*)<\\/phpcode>/Us", $phpexec_content, $phpexec_code)) { // If it's a phpcode
$phpexec_php = $phpexec_code[1];
if ($phpexec_doeval) {
ob_start();
eval("?>". $phpexec_php . "
User level saved successfully.
';
}
?>
PHPExec Options
Minimum User Level
Sets the minimum level to allow users to run PHP code in posts. If option is not set, then defaults to 9.
User Level:
Ở trong các bài viết post hoặc page, bạn thêm code "" rồi tới code php của bạn, nhớ có dấu đóng mở php đàng hoàng nhé rồi tới .
Chú ý là các code này được viết trong phần "text" chứ không phải là visual nhé.
Bạn copy đoạn code dưới đây và chạy xem nó xuất hiện gì?
[codesyntax lang="php"]
Security
Nếu trang web của bạn có nhiều user, bận nên cấu hình quyền để chạy được php trong post và page để đảm bảo an toàn nhé. Nếu cấu hình các bạn vào settings -> PHPExec