50 lines
933 B
PHP
50 lines
933 B
PHP
<?php
|
|
//header("Content-type: image/svg+xml");
|
|
//ob_start();
|
|
require_once("../../config.php");
|
|
|
|
global $CFG;
|
|
global $DB;
|
|
|
|
$skillid = required_param('skillid', PARAM_INT);
|
|
$skill = $DB->get_record('block_gradelevel_levelset', array('id' => $skillid));
|
|
|
|
if(is_object($skill))
|
|
{
|
|
$image = $skill->icon;
|
|
|
|
if(strncmp($image,"data:",5) == 0)
|
|
{
|
|
$parts = explode(",",ltrim(substr($image,5)),2);
|
|
$typeinfo = explode(";",$parts[0]);
|
|
if(count($typeinfo) > 1 && $typeinfo[1] == "base64")
|
|
{
|
|
$binary = base64_decode($parts[1]);
|
|
}
|
|
else
|
|
{
|
|
$binary = $parts[0];
|
|
}
|
|
$mime = $typeinfo[0];
|
|
|
|
// set header
|
|
header("Content-type: {$mime}");
|
|
header("Pragma:");
|
|
// Allow cache for 5 seconds
|
|
header("Cache-Control: public, max-age=5");
|
|
// print data
|
|
print $binary;
|
|
}
|
|
else
|
|
{
|
|
// redirect to specified url
|
|
header("Location: {$image}",true,302);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
http_response_code(404);
|
|
print "Image not found";
|
|
}
|