mirror of https://github.com/MISP/MISP
commit
43bfbbe6dc
|
@ -4238,7 +4238,6 @@ class AppModel extends Model
|
||||||
$newImageDir = APP . 'files/img';
|
$newImageDir = APP . 'files/img';
|
||||||
$oldOrgDir = new Folder($oldImageDir . '/orgs');
|
$oldOrgDir = new Folder($oldImageDir . '/orgs');
|
||||||
$oldCustomDir = new Folder($oldImageDir . '/custom');
|
$oldCustomDir = new Folder($oldImageDir . '/custom');
|
||||||
$result = false;
|
|
||||||
$result = $oldOrgDir->copy([
|
$result = $oldOrgDir->copy([
|
||||||
'from' => $oldImageDir . '/orgs',
|
'from' => $oldImageDir . '/orgs',
|
||||||
'to' => $newImageDir . '/orgs',
|
'to' => $newImageDir . '/orgs',
|
||||||
|
|
|
@ -2595,33 +2595,33 @@ class Server extends AppModel
|
||||||
|
|
||||||
public function getFileRules()
|
public function getFileRules()
|
||||||
{
|
{
|
||||||
return array(
|
return [
|
||||||
'orgs' => array(
|
'orgs' => [
|
||||||
'name' => __('Organisation logos'),
|
'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.'),
|
'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'),
|
'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' => '.*\.(png|svg)$',
|
||||||
'regex_error' => __('Filename must be in the following format: *.png or *.svg'),
|
'regex_error' => __('Filename must be in the following format: *.png or *.svg'),
|
||||||
'files' => array(),
|
'files' => [],
|
||||||
),
|
],
|
||||||
'img' => array(
|
'img' => [
|
||||||
'name' => __('Additional image files'),
|
'name' => __('Additional image files'),
|
||||||
'description' => __('Image files uploaded into this directory can be used for various purposes, such as for the login page logos'),
|
'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.footer_logo' => Configure::read('MISP.footer_logo'),
|
||||||
'MISP.home_logo' => Configure::read('MISP.home_logo'),
|
'MISP.home_logo' => Configure::read('MISP.home_logo'),
|
||||||
'MISP.welcome_logo' => Configure::read('MISP.welcome_logo'),
|
'MISP.welcome_logo' => Configure::read('MISP.welcome_logo'),
|
||||||
'MISP.welcome_logo2' => Configure::read('MISP.welcome_logo2'),
|
'MISP.welcome_logo2' => Configure::read('MISP.welcome_logo2'),
|
||||||
),
|
],
|
||||||
'valid_format' => __('PNG or SVG file'),
|
'valid_format' => __('PNG or SVG file'),
|
||||||
'path' => APP . 'webroot' . DS . 'img' . DS . 'custom',
|
'path' => APP . 'files' . DS . 'img' . DS . 'custom',
|
||||||
'regex' => '.*\.(png|svg)$',
|
'regex' => '.*\.(png|svg)$',
|
||||||
'regex_error' => __('Filename must be in the following format: *.png or *.svg'),
|
'regex_error' => __('Filename must be in the following format: *.png or *.svg'),
|
||||||
'files' => array(),
|
'files' => array(),
|
||||||
),
|
],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function grabFiles()
|
public function grabFiles()
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<div class="pull-right" style="position:relative;padding-top:9px;z-index:2;">
|
<div class="pull-right" style="position:relative;padding-top:9px;z-index:2;">
|
||||||
<?php
|
<?php
|
||||||
if (Configure::read('MISP.footer_logo')) {
|
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>
|
</div>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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']));
|
$link = $baseurl . '/organisations/view/' . (empty($organisation['Organisation']['id']) ? h($organisation['Organisation']['name']) : h($organisation['Organisation']['id']));
|
||||||
}
|
}
|
||||||
if ($orgImgName) {
|
if ($orgImgName) {
|
||||||
$orgImgUrl = $baseurl . '/img/orgs/' . $orgImgName;
|
$base64 = $this->_View->Image->base64(self::IMG_PATH . $orgImgName);
|
||||||
return sprintf('<a href="%s" style="background-image: url(\'%s\')" class="orgImg">%s</a>', $link, $orgImgUrl, h($organisation['Organisation']['name']));
|
return sprintf('<a href="%s" style="background-image: url(\'%s\')" class="orgImg">%s</a>', $link, $base64, h($organisation['Organisation']['name']));
|
||||||
} else {
|
} else {
|
||||||
return sprintf('<a href="%s">%s</a>', $link, h($organisation['Organisation']['name']));
|
return sprintf('<a href="%s">%s</a>', $link, h($organisation['Organisation']['name']));
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,8 @@ class OrgImgHelper extends AppHelper
|
||||||
if ($orgImgName) {
|
if ($orgImgName) {
|
||||||
$size = !empty($options['size']) ? $options['size'] : 48;
|
$size = !empty($options['size']) ? $options['size'] : 48;
|
||||||
$result = sprintf(
|
$result = sprintf(
|
||||||
'<img src="data:image/%s;base64,%s" title="%s" width="%s" height="%s">',
|
'<img src="%s" title="%s" width="%s" height="%s">',
|
||||||
'png',
|
$this->_View->Image->base64(self::IMG_PATH . $orgImgName),
|
||||||
base64_encode(FileAccessTool::readFromFile(self::IMG_PATH . $orgImgName)),
|
|
||||||
isset($options['name']) ? h($options['name']) : h($options['id']),
|
isset($options['name']) ? h($options['name']) : h($options['id']),
|
||||||
(int)$size,
|
(int)$size,
|
||||||
(int)$size
|
(int)$size
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
</span><br /><br />
|
</span><br /><br />
|
||||||
<div>
|
<div>
|
||||||
<?php if (Configure::read('MISP.main_logo') && file_exists(APP . '/webroot/img/custom/' . Configure::read('MISP.main_logo'))): ?>
|
<?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: ?>
|
<?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;?>
|
<?php endif;?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue