如何在Laravel Ckeditor中包含PHP文件?

发布于 2025-01-27 09:40:58 字数 1622 浏览 3 评论 0原文

嘿,我想在我的larvel博客页面中使用CKEditor,将PHP文件包括在我的Larvel博客页面中。当我添加标签时,我有两个问题,它们会被评论,并且HTML标签仅在数据库中过滤。当我将数据库中的<?php代码或脚本直接添加到数据库中的正文时,代码仍然存在,但是<???????????php代码仍然不会解析/执行,但它会显示在博客页面中。

只要我是使用php eart()函数,我就可以从数据库中执行PHP,但是评估不是在CKEditor源代码中解析。任何解决方案都将不胜感激。 我使用larvel 5.7和ckeditor 4+

是图像 db image

db中插入php

博客文章 ckeditor output

ck source img 查看ckeditor源代码img

参考此处参考此处是php eval()的图片,而无需使用larvel ckeditor db img

工作php评估参考

输出IMG output img

代码到输出/参考的工作示例 '''

$servername = "";
$username = "";
$password = "";
$dbname = "";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM e.g.";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
  while($row = $result->fetch_assoc()) {
    
    $row1 = $row['middle_name']; //would be changed to row['body'] for larvel blog

    eval($row1);
    
  }
} else {
  echo "0 results";
}
$conn->close();
?>

'''

Hey I would like to include a php file into my larvel blog page using, ckeditor. I have 2 problems when I add in tags they are commented out and html tags are just filtered out in the database. When I just add the <?php code or script in the database directly to the body in database the code is still there but the <?php code still does not parse/execute but it will show up in the blog page.

I can execute php from my database as long as I am the using php eval() function, but the eval is not parsing in ckeditor source code. Any solution would be greatly appreciated.
Im using larvel 5.7 and ckeditor 4+

Here are the images
db image

inserted php in db

blog post img
ckeditor output

ck source img
view ckeditor source code img

For reference here are pics of php eval() without using larvel ckeditor db img

working php eval reference

output img
output img

code to output/ reference for working example
'''

$servername = "";
$username = "";
$password = "";
$dbname = "";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM e.g.";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
  // output data of each row
  while($row = $result->fetch_assoc()) {
    
    $row1 = $row['middle_name']; //would be changed to row['body'] for larvel blog

    eval($row1);
    
  }
} else {
  echo "0 results";
}
$conn->close();
?>

'''

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狂之美人 2025-02-03 09:40:58

NVM我找到了旁路。

您可以使用html onload =“”;

<div id="topBar"> <a href ="#" onload="load_home()"> HOME </a> </div>
<div id ="content"> </div>
<script>


function load_home() {
document.getElementById("content").innerHTML='<object type="text/html" data="sometthing.html" ></object>';
</script>
}

您也可以在CKEditor中使用AN&lt; iframe src =“”或直接添加到数据库中以在该文件上添加PHP代码

<iframe onload="function()" src="...eg page you want to load"></iframe>

nvm I found a bypass.

you can use an html onload="";

<div id="topBar"> <a href ="#" onload="load_home()"> HOME </a> </div>
<div id ="content"> </div>
<script>


function load_home() {
document.getElementById("content").innerHTML='<object type="text/html" data="sometthing.html" ></object>';
</script>
}

You can also use an <iframe src="" in the ckeditor or add directly to the database to add php code on that file

<iframe onload="function()" src="...eg page you want to load"></iframe>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文