是否可以在iframe中显示moodle网站?

时间:2013-07-26 08:38:42

标签: iframe moodle

我正在尝试将moodle与我自己的PHP应用程序集成。是否可以在iframe中显示moodle网站?

2 个答案:

答案 0 :(得分:3)

在您的站点管理中,查看配置变量“allowframembedding”。它是在站点管理>安全> HTTP安全性。

默认情况下,“允许帧嵌入”设置为“否”,只需单击复选框即可将Moodle嵌入到iframe中。

答案 1 :(得分:0)

我的问题是我可以在编辑器中保存一个iframe,但是在以后的编辑中删除了该iframe。 如果您在将iframe嵌入博客或论坛中时遇到问题,请参考以下在我的3.9.1中使用的代码段: 编辑config.php,搜索

require_once(__DIR__ . '/lib/setup.php');

然后在其下方放上以下代码:

$script_file = realpath($_SERVER['SCRIPT_FILENAME']);
if($script_file){
    $script_file_rel_path = substr($script_file,strlen(__DIR__));
    if(strpos($script_file_rel_path,'/edit.php') !== false){
        $sitecontext = context_system::instance();
        if(has_capability('moodle/site:trustcontent',$sitecontext)){
            require_once __DIR__ . '/lib/htmlpurifier/HTMLPurifier.safe-includes.php';
            require_once __DIR__ . '/lib/htmlpurifier/HTMLPurifier/ConfigSchema.php';
            $definition = HTMLPurifier_ConfigSchema::instance();
            $definition->add('HTML.SafeIframe', true, 'bool', true);
            // Only allow urls from subdomains of google.com and youtube.com
            $definition->add('URI.SafeIframeRegexp', '/:\/\/([^\/]*?)(\.(google|youtube)\.com)\//','string', true);
            // Uncomment the following and remove previous line in order to allow any url in the "src" attribute
            // $definition->add('URI.SafeIframeRegexp', '//','string', true);
        }
    }
}

这是什么:在访问edit.php链接(编辑页面)时,具有以下功能的用户:系统中的moodle / site:trustcontent将能够将iframe与来自特定域的url嵌入到其文本编辑器中。 / p>

相关问题