<?php
require_once("config.php");
require_login();
if (isadmin()) {
$from = "http://www.moodle.fi";
$to = "https://www.moodle.fi";
$block = get_record("block", "name", "html");
$htmls = get_records("block_instance", "blockid", $block->id);
foreach ($htmls as $html) {
if ($html->configdata != "") {
$read = unserialize(base64_decode($html->configdata));
if ($change = str_replace($from, $to, $read->text)) {
print($change);
$read->text = $change;
$up->configdata = base64_encode(serialize($read));
$up->id = $html->id;
update_record("block_instance", $up);
}
}
}
} else {
error("Admin users only");
}
?>
Teemu, you are a legend! Thanks for this code. I've been writing something similar for the last day or so but was struggling with the unserialize(base64_decode part for some reason.
Cheers buddy
Hi,
Thanks for this code ! Is it still true in Moodle 2.2 ?
Our institutional are moving the Moodle 1.9 resources to another respository. What I did was to replace some string in the HTML block (CONFIGDATA) using the base64 encode/decode in the moodle.xml.
However after these change, the HTML block went missing after I restored the backup to the same Moodle 1.9. I have verified the CONFIGDATA content with online encoder/decoder, both the content were exactly same apart from the hyperlink that I changed to.
Any one can shed light on this? Appreciate any help. Thanks.