Skip to content

fix: iframes

Fix iframes using external php.

Contents of alexanderdunkel.com/iframe_ioer.php:

<!DOCTYPE html><html>
<?php

$context = stream_context_create(
  array(
    'http' => array(
      'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0',
    ),
));

$allowed = array(
'http://www.ioer.de/',
'https://stadtklima-ioer-fdz-984dec570cb501cea92b3d4306028ac78273785c632.gp.hrz.tu-chemnitz.de/',
'https://landusedashboard-ioer-fdz-78cea03ed634871060afd2a44d00bc9aaef9b.gp.hrz.tu-chemnitz.de',
'https://ioer-isbe.de/ressourcen/bauwerksdaten/wohngebaeude/efh-deutschland',
'https://www.data-to-viz.com/');

$name = $_GET['name'];

if (empty($name)) {
    $url = 'http://www.ioer.de/';
} elseif (in_array($name, $allowed)) {
    $url = $name;
}     

//$site = file_get_contents($url, false, $context);
$site = file_get_contents($url);

if ($url == 'http://www.ioer.de/') {

$site = str_replace('/typo3conf/', 'http://www.ioer.de/typo3conf/', $site);
$site = str_replace('/typo3temp/', 'http://www.ioer.de/typo3temp/', $site);
$site = str_replace('/fileadmin/', 'http://www.ioer.de/fileadmin/', $site);
} elseif ($url == 'https://stadtklima-ioer-fdz-984dec570cb501cea92b3d4306028ac78273785c632.gp.hrz.tu-chemnitz.de/') {
    $site = str_replace('styles.css', $name.'styles.css', $site);
} elseif ($url == 'https://landusedashboard-ioer-fdz-78cea03ed634871060afd2a44d00bc9aaef9b.gp.hrz.tu-chemnitz.de') {
    $site = str_replace('style.css', $name.'/style.css', $site);
} elseif ($url == 'https://ioer-isbe.de/ressourcen/bauwerksdaten/wohngebaeude/efh-deutschland') {
    $site = str_replace('/typo3conf/', 'https://ioer-isbe.de/typo3conf/', $site);
    $site = str_replace('/typo3temp/', 'https://ioer-isbe.de/typo3temp/', $site);
    $site = str_replace('/fileadmin/', 'https://ioer-isbe.de/fileadmin/', $site);
} elseif ($url == 'https://www.data-to-viz.com/') {
    $site = str_replace('"css/', '"'.$url.'/css/', $site);
    $site = str_replace('"vendor/', '"'.$url.'/vendor/', $site);
}


header('Access-Control-Allow-Origin: *');


$site = str_replace('</head>', '<base href="'. $name .'"></head>', $site );


// $site = preg_replace('~<\s*\bscript\b[^>]*>(.*?)<\s*\/\s*script\s*>~is', ' ', $site);
// reset to original link
// $site = preg_replace('#<a href="/questions/5710867/downloading-and-unzipping-a-zip-file-without-writing-to-disk"#s', '<a href="'.$url.'"', $site);

echo $site;

?>
</html>

Use with (e.g.): https://alexanderdunkel.com/iframe_ioer.php?name=https://stadtklima-ioer-fdz-984dec570cb501cea92b3d4306028ac78273785c632.gp.hrz.tu-chemnitz.de/

..very laborious solution..!

Merge request reports