mirror of https://github.com/MISP/MISP
commit
43bfbbe6dc
|
@ -4238,7 +4238,6 @@ class AppModel extends Model
|
|||
$newImageDir = APP . 'files/img';
|
||||
$oldOrgDir = new Folder($oldImageDir . '/orgs');
|
||||
$oldCustomDir = new Folder($oldImageDir . '/custom');
|
||||
$result = false;
|
||||
$result = $oldOrgDir->copy([
|
||||
'from' => $oldImageDir . '/orgs',
|
||||
'to' => $newImageDir . '/orgs',
|
||||
|
|
|
@ -2595,33 +2595,33 @@ class Server extends AppModel
|
|||
|
||||
public function getFileRules()
|
||||
{
|
||||
return array(
|
||||
'orgs' => array(
|
||||
return [
|
||||
'orgs' => [
|
||||
'name' => __('Organisation logos'),
|
||||
'description' => __('The logo used by an organisation on the event index, event view, discussions, proposals, etc. Make sure that the filename is in the org.png format, where org is the case-sensitive organisation name.'),
|
||||
'expected' => array(),
|
||||
'expected' => [],
|
||||
'valid_format' => __('48x48 pixel .png files or .svg file'),
|
||||
'path' => APP . 'webroot' . DS . 'img' . DS . 'orgs',
|
||||
'path' => APP . 'files' . DS . 'img' . DS . 'orgs',
|
||||
'regex' => '.*\.(png|svg)$',
|
||||
'regex_error' => __('Filename must be in the following format: *.png or *.svg'),
|
||||
'files' => array(),
|
||||
),
|
||||
'img' => array(
|
||||
'files' => [],
|
||||
],
|
||||
'img' => [
|
||||
'name' => __('Additional image files'),
|
||||
'description' => __('Image files uploaded into this directory can be used for various purposes, such as for the login page logos'),
|
||||
'expected' => array(
|
||||
'expected' => [
|
||||
'MISP.footer_logo' => Configure::read('MISP.footer_logo'),
|
||||
'MISP.home_logo' => Configure::read('MISP.home_logo'),
|
||||
'MISP.welcome_logo' => Configure::read('MISP.welcome_logo'),
|
||||
'MISP.welcome_logo2' => Configure::read('MISP.welcome_logo2'),
|
||||
),
|
||||
],
|
||||
'valid_format' => __('PNG or SVG file'),
|
||||
'path' => APP . 'webroot' . DS . 'img' . DS . 'custom',
|
||||
'path' => APP . 'files' . DS . 'img' . DS . 'custom',
|
||||
'regex' => '.*\.(png|svg)$',
|
||||
'regex_error' => __('Filename must be in the following format: *.png or *.svg'),
|
||||
'files' => array(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function grabFiles()
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<div class="pull-right" style="position:relative;padding-top:9px;z-index:2;">
|
||||
<?php
|
||||
if (Configure::read('MISP.footer_logo')) {
|
||||
echo $this->Html->image('custom/' . h(Configure::read('MISP.footer_logo')), array('alt' => 'Footer Logo', 'onerror' => "this.style.display='none';", 'style' => 'height:24px'));
|
||||
echo '<img src="' . $this->Image->base64(APP . 'files/img/custom/' . Configure::read('MISP.footer_logo')) . '" alt="' . __('Footer logo') . '" style="height:24px" onerror="this.style.display=\'none\';">';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
<?php
|
||||
if (!empty($me)) {
|
||||
if (Configure::read('MISP.home_logo')) {
|
||||
$logoPath = APP . 'files/img/custom/' . Configure::read('MISP.home_logo');
|
||||
if (file_exists($logoPath)) {
|
||||
$logoHtml = '<img src="' . $this->Image->base64($logoPath) . '" style="height:24px;" alt="' . __('Home') . '">';
|
||||
} else {
|
||||
$logoHtml = __('Home');
|
||||
}
|
||||
} else {
|
||||
$logoHtml = __('Home');
|
||||
}
|
||||
|
||||
// New approach how to define menu requirements. It takes ACLs from ACLComponent.
|
||||
$menu = array(
|
||||
array(
|
||||
'type' => 'root',
|
||||
'url' => empty($homepage['path']) ? $baseurl .'/' : $baseurl . h($homepage['path']),
|
||||
'html' => Configure::read('MISP.home_logo') ? '<img src="' . $baseurl . '/img/custom/' . Configure::read('MISP.home_logo') . '" style="height:24px;" alt="' . __('Home') . '">' : __('Home'),
|
||||
'html' => $logoHtml
|
||||
),
|
||||
array(
|
||||
'type' => 'root',
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
App::uses('AppHelper', 'View/Helper');
|
||||
App::uses('FileAccessTool', 'Lib/Tools');
|
||||
|
||||
class ImageHelper extends AppHelper
|
||||
{
|
||||
/** @var array */
|
||||
private $imageCache = [];
|
||||
|
||||
/**
|
||||
* @param string $imagePath Path to file
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function base64($imagePath)
|
||||
{
|
||||
if (isset($this->imageCache[$imagePath])) {
|
||||
return $this->imageCache[$imagePath];
|
||||
}
|
||||
|
||||
$ext = pathinfo($imagePath, PATHINFO_EXTENSION);
|
||||
if ($ext === 'svg') {
|
||||
$mime = 'image/svg+xml';
|
||||
} else if ($ext === 'png') {
|
||||
$mime = 'image/png';
|
||||
} else {
|
||||
throw new InvalidArgumentException("Only SVG and PNG images are supported");
|
||||
}
|
||||
|
||||
$fileContent = base64_encode(FileAccessTool::readFromFile($imagePath));
|
||||
$base64 = "data:$mime;base64,$fileContent";
|
||||
|
||||
return $this->imageCache[$imagePath] = $base64;
|
||||
}
|
||||
}
|
|
@ -22,8 +22,8 @@ class OrgImgHelper extends AppHelper
|
|||
$link = $baseurl . '/organisations/view/' . (empty($organisation['Organisation']['id']) ? h($organisation['Organisation']['name']) : h($organisation['Organisation']['id']));
|
||||
}
|
||||
if ($orgImgName) {
|
||||
$orgImgUrl = $baseurl . '/img/orgs/' . $orgImgName;
|
||||
return sprintf('<a href="%s" style="background-image: url(\'%s\')" class="orgImg">%s</a>', $link, $orgImgUrl, h($organisation['Organisation']['name']));
|
||||
$base64 = $this->_View->Image->base64(self::IMG_PATH . $orgImgName);
|
||||
return sprintf('<a href="%s" style="background-image: url(\'%s\')" class="orgImg">%s</a>', $link, $base64, h($organisation['Organisation']['name']));
|
||||
} else {
|
||||
return sprintf('<a href="%s">%s</a>', $link, h($organisation['Organisation']['name']));
|
||||
}
|
||||
|
@ -56,9 +56,8 @@ class OrgImgHelper extends AppHelper
|
|||
if ($orgImgName) {
|
||||
$size = !empty($options['size']) ? $options['size'] : 48;
|
||||
$result = sprintf(
|
||||
'<img src="data:image/%s;base64,%s" title="%s" width="%s" height="%s">',
|
||||
'png',
|
||||
base64_encode(FileAccessTool::readFromFile(self::IMG_PATH . $orgImgName)),
|
||||
'<img src="%s" title="%s" width="%s" height="%s">',
|
||||
$this->_View->Image->base64(self::IMG_PATH . $orgImgName),
|
||||
isset($options['name']) ? h($options['name']) : h($options['id']),
|
||||
(int)$size,
|
||||
(int)$size
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
</span><br /><br />
|
||||
<div>
|
||||
<?php if (Configure::read('MISP.main_logo') && file_exists(APP . '/webroot/img/custom/' . Configure::read('MISP.main_logo'))): ?>
|
||||
<img src="<?php echo $baseurl?>/img/custom/<?php echo h(Configure::read('MISP.main_logo'));?>" style=" display:block; margin-left: auto; margin-right: auto;" />
|
||||
<img src="<?= $this->Image->base64(APP . 'files/img/custom/' . Configure::read('MISP.home_logo')) ?>" style=" display:block; margin-left: auto; margin-right: auto;">
|
||||
<?php else: ?>
|
||||
<img src="<?php echo $baseurl?>/img/misp-logo-s-u.png" style="display:block; margin-left: auto; margin-right: auto;"/>
|
||||
<img src="<?php echo $baseurl?>/img/misp-logo-s-u.png" style="display:block; margin-left: auto; margin-right: auto;">
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue