<?php/** * This little script implements the [oembed format](https://oembed.com) to * make it easy for us to make pages and viewers we create embeddable in * Wordpress. * Just paste the following code in the head of the HTML to allow it to be * embedded: * * <link rel="alternate" type="application/json+oembed" * href="https://server1.geodienst.xyz/oembed.php" * title="Straatnamen Groningen oEmbed Profile"> * * Made by Jelmer van der Linde, 2018 */functionabort($message,$code=500){header('Status: 500 Internal Server Error');die($message);}functionget_page_title($url){$html=file_get_contents($url);if(!preg_match('{<title>(.+?)</title>}i',$html,$match))returnnull;returnhtml_entity_decode($match[1]);}functionget_iframe_html($url,$width=null,$height=null){$attributes=['sandbox'=>'allow-scripts','security'=>'restricted','src'=>$url,'frameborder'=>0,'marginwidth'=>0,'marginheight'=>0];if($width)$attributes['width']=$width;if($height)$attributes['height']=$height;$html_attributes='';foreach($attributesas$name=>$value)$html_attributes.=sprintf(' %s="%s"',$name,htmlspecialchars($value,ENT_QUOTES));returnsprintf('<iframe%s></iframe>',$html_attributes);}functionmain(){if(!isset($_GET['url']))abort('url parameter missing');$title=get_page_title($_GET['url']);$html=get_iframe_html($_GET['url'],isset($_GET['maxwidth'])?(int)$_GET['maxwidth']:null,isset($_GET['maxheight'])?(int)$_GET['maxheight']:null);header('Content-Type: application/json');echojson_encode(['version'=>'1.0','type'=>'iframe','provider_name'=>'Geodienst oEmbed provider','provider_url'=>'https://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'],'author_name'=>'Geodienst Rijksuniversiteit Groningen','author_url'=>'https://www.geodienst.xyz/','title'=>$title,'type'=>'rich','html'=>$html]);}main();
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.