mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Improved image testing. File class mime-detection improvements. Fix for use of e107_ini_set() which is only declared during installation. gSitemap typo fix.
This commit is contained in:
@@ -560,8 +560,8 @@ class e_marketplace_adapter_wsdl extends e_marketplace_adapter_abstract
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
e107_ini_set('soap.wsdl_cache_enabled', 0);
|
||||
e107_ini_set('soap.wsdl_cache_ttl', 0);
|
||||
ini_set('soap.wsdl_cache_enabled', 0);
|
||||
ini_set('soap.wsdl_cache_ttl', 0);
|
||||
|
||||
$options = array(
|
||||
"trace" => true,
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -525,7 +525,7 @@ class language{
|
||||
{
|
||||
$detect_language = (e_SUBDOMAIN) ? $this->isValid(e_SUBDOMAIN) : $pref['sitelanguage'];
|
||||
// Done in session handler now, based on MULTILANG_SUBDOMAIN value
|
||||
//e107_ini_set("session.cookie_domain", ".".e_DOMAIN); // Must be before session_start()
|
||||
//ini_set("session.cookie_domain", ".".e_DOMAIN); // Must be before session_start()
|
||||
$this->_cookie_domain = ".".e_DOMAIN;
|
||||
define('MULTILANG_SUBDOMAIN',true);
|
||||
}
|
||||
@@ -558,7 +558,7 @@ class language{
|
||||
}
|
||||
|
||||
// Done in session handler now
|
||||
// e107_ini_set("session.cookie_path", e_HTTP);
|
||||
// ini_set("session.cookie_path", e_HTTP);
|
||||
|
||||
$this->detect = $detect_language;
|
||||
return $detect_language;
|
||||
|
@@ -542,7 +542,7 @@ class gsitemap
|
||||
'gsitemap_id' => 0,
|
||||
'gsitemap_name' => $tp->toDB($name),
|
||||
'gsitemap_url' => $tp->toDB($url),
|
||||
'gsitemap_table' => $tp->toDB($id),
|
||||
'gsitemap_table' => $tp->toDB($table),
|
||||
'gsitemap_table_id' => (int) $id,
|
||||
'gsitemap_lastmod' => time(),
|
||||
'gsitemap_freq' => $_POST['import_freq'],
|
||||
|
@@ -850,7 +850,7 @@ class private_message
|
||||
|
||||
|
||||
@set_time_limit(10 * 60);
|
||||
@e107_ini_set("max_execution_time", 10 * 60);
|
||||
@ini_set("max_execution_time", 10 * 60);
|
||||
while (@ob_end_clean()); // kill all output buffering else it eats server resources
|
||||
if (connection_status() == 0)
|
||||
{
|
||||
|
@@ -88,6 +88,25 @@ class e_fileTest extends \Codeception\Test\Unit
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testGetMime()
|
||||
{
|
||||
$test = array(
|
||||
array('path'=> 'somefile', 'expected' => false), // no extension
|
||||
array('path'=> 'somefile.bla', 'expected' => 'application/octet-stream'), // unknown
|
||||
array('path'=> "{e_PLUGIN}filetypes.xml", 'expected' => 'application/xml'),
|
||||
array('path'=> "gallery/images/butterfly.jpg", 'expected' => 'image/jpeg'),
|
||||
array('path'=> "image.webp", 'expected' => 'image/webp'),
|
||||
);
|
||||
|
||||
foreach($test as $var)
|
||||
{
|
||||
$actual = $this->fl->getMime($var['path']);
|
||||
|
||||
$this->assertSame($var['expected'], $actual);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIsAllowedType()
|
||||
{
|
||||
|
||||
@@ -235,25 +254,49 @@ class e_fileTest extends \Codeception\Test\Unit
|
||||
|
||||
}*/
|
||||
|
||||
public function testGet_file_info()
|
||||
public function testGetFileInfo()
|
||||
{
|
||||
$tests = array(
|
||||
0 => array('input' => "e107_web/lib/font-awesome/4.7.0/fonts/fontawesome-webfont.svg", 'expected'=>'image/svg+xml'),
|
||||
1 => array('input' => "e107_plugins/gallery/images/beach.webp", 'expected'=>'image/webp'),
|
||||
2 => array('input' => "e107_tests/tests/_data/fileTest/corrupted_image.webp", 'expected'=>false),
|
||||
0 => array(
|
||||
'input' => "e107_web/lib/font-awesome/4.7.0/fonts/fontawesome-webfont.svg",
|
||||
'imgchk' => false,
|
||||
'expected' => ['mime'=>'image/svg+xml']
|
||||
),
|
||||
1 => array(
|
||||
'input' => "e107_plugins/gallery/images/beach.webp",
|
||||
'imgchk' => true,
|
||||
'expected' => ['mime'=>'image/webp', 'img-width'=>1920, 'img-height'=>1440]
|
||||
),
|
||||
2 => array(
|
||||
'input' => "e107_tests/tests/_data/fileTest/corrupted_image.webp",
|
||||
'imgchk' => false,
|
||||
'expected' => ['mime' => false]
|
||||
),
|
||||
3 => array(
|
||||
'input' => "none-existent-file.png",
|
||||
'imgchk' => false,
|
||||
'expected' => ['mime' => false]
|
||||
),
|
||||
);
|
||||
|
||||
foreach($tests as $item)
|
||||
{
|
||||
$path = APP_PATH.'/'.$item['input'];
|
||||
$ret = $this->fl->get_file_info($path);
|
||||
$ret = $this->fl->getFileInfo($path);
|
||||
|
||||
if($ret === false)
|
||||
{
|
||||
$ret = array('mime'=>false);
|
||||
}
|
||||
|
||||
$this->assertEquals($item['expected'], $ret['mime']);
|
||||
var_dump($ret);
|
||||
$this->assertEquals($item['expected']['mime'], $ret['mime']);
|
||||
|
||||
if($item['imgchk'])
|
||||
{
|
||||
$this->assertEquals($item['expected']['img-width'], $ret['img-width']);
|
||||
$this->assertEquals($item['expected']['img-height'], $ret['img-height']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -262,12 +305,84 @@ class e_fileTest extends \Codeception\Test\Unit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testGetFileExtension()
|
||||
{
|
||||
$test = array(
|
||||
'application/ecmascript' => '.es',
|
||||
'application/epub+zip' => '.epub',
|
||||
'application/java-archive' => '.jar',
|
||||
'application/javascript' => '.js',
|
||||
'application/json' => '.json',
|
||||
'application/msword' => '.doc',
|
||||
'application/octet-stream' => '.bin',
|
||||
'application/ogg' => '.ogx',
|
||||
'application/pdf' => '.pdf',
|
||||
'application/rtf' => '.rtf',
|
||||
'application/typescript' => '.ts',
|
||||
'application/vnd.amazon.ebook' => '.azw',
|
||||
'application/vnd.apple.installer+xml' => '.mpkg',
|
||||
'application/vnd.mozilla.xul+xml' => '.xul',
|
||||
'application/vnd.ms-excel' => '.xls',
|
||||
'application/vnd.ms-fontobject' => '.eot',
|
||||
'application/vnd.ms-powerpoint' => '.ppt',
|
||||
'application/vnd.oasis.opendocument.presentation' => '.odp',
|
||||
'application/vnd.oasis.opendocument.spreadsheet' => '.ods',
|
||||
'application/vnd.oasis.opendocument.text' => '.odt',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => '.pptx',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => '.xlsx',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => '.docx',
|
||||
'application/vnd.visio' => '.vsd',
|
||||
'application/x-7z-compressed' => '.7z',
|
||||
'application/x-abiword' => '.abw',
|
||||
'application/x-bzip' => '.bz',
|
||||
'application/x-bzip2' => '.bz2',
|
||||
'application/x-csh' => '.csh',
|
||||
'application/x-rar-compressed' => '.rar',
|
||||
'application/x-sh' => '.sh',
|
||||
'application/x-shockwave-flash' => '.swf',
|
||||
'application/x-tar' => '.tar',
|
||||
'application/xhtml+xml' => '.xhtml',
|
||||
'application/xml' => '.xml',
|
||||
'application/zip' => '.zip',
|
||||
'audio/aac' => '.aac',
|
||||
'audio/midi' => '.midi',
|
||||
'audio/mpeg' => '.mp3',
|
||||
'audio/ogg' => '.oga',
|
||||
'audio/wav' => '.wav',
|
||||
'audio/webm' => '.weba',
|
||||
'font/otf' => '.otf',
|
||||
'font/ttf' => '.ttf',
|
||||
'font/woff' => '.woff',
|
||||
'font/woff2' => '.woff2',
|
||||
'image/bmp' => '.bmp',
|
||||
'image/gif' => '.gif',
|
||||
'image/jpeg' => '.jpg',
|
||||
'image/png' => '.png',
|
||||
'image/svg+xml' => '.svg',
|
||||
'image/tiff' => '.tiff',
|
||||
'image/webp' => '.webp',
|
||||
'image/x-icon' => '.ico',
|
||||
'text/calendar' => '.ics',
|
||||
'text/css' => '.css',
|
||||
'text/csv' => '.csv',
|
||||
'text/html' => '.html',
|
||||
'text/plain' => '.txt',
|
||||
'video/mp4' => '.mp4',
|
||||
'video/mpeg' => '.mpeg',
|
||||
'video/ogg' => '.ogv',
|
||||
'video/webm' => '.webm',
|
||||
'video/x-msvideo' => '.avi',
|
||||
);
|
||||
|
||||
foreach($test as $mime=>$ext)
|
||||
{
|
||||
$actual = $this->fl->getFileExtension($mime);
|
||||
|
||||
$this->assertSame($ext, $actual);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public function testRmtree()
|
||||
{
|
||||
|
||||
|
@@ -997,9 +997,10 @@ while($row = $sql->fetch())
|
||||
<img class="img-responsive img-fluid" src="thumb.php?src=e_PLUGIN%2Fgallery%2Fimages%2Fbutterfly.jpg&w=80&h=80" alt="butterfly.jpg" width="80" height="80" />
|
||||
</picture>';
|
||||
|
||||
$tempDir = str_replace(['C:','\\'],['','/'], sys_get_temp_dir()).'/'; // FIXME
|
||||
// $tempDir = str_replace(['C:','\\'],['','/'], sys_get_temp_dir()).'/'; // FIXME
|
||||
$result6 = preg_replace('/"([^"]*)thumb.php/','"thumb.php', $result6);
|
||||
|
||||
$result6 = str_replace($tempDir, '', $result6);
|
||||
// $result6 = str_replace($tempDir, '', $result6);
|
||||
|
||||
$this->assertSame($expected,$result6);
|
||||
$this->tp->setConvertToWebP(false);
|
||||
|
Reference in New Issue
Block a user