Jump to content

Recommended Posts

Posted
<?php
echo '<pre>', var_dump(getenv('MAGIC')), '</pre>';

отвечает bool(false)

как его настроить? что бы побороть ошибки. где эту базу брать.

mime_content_type(): Failed identify data 0:bad magic in `(null)'
mime_content_type(): Failed to load magic database.

Posted (edited)
~ # 
~ # env | grep ^MAG
~ # 
~ # php -i | grep MAGIC
~ # 
~ # export MAGIC="/opt/share/misc/magic"
~ # 
~ # env | grep ^MAG
MAGIC=/opt/share/misc/magic
~ # 
~ # php -i | grep MAGIC
MAGIC => /opt/share/misc/magic
$_SERVER['MAGIC'] => /opt/share/misc/magic
$_ENV['MAGIC'] => /opt/share/misc/magic
~ # 
~ #

---

~ # 
~ # cat fileinfo.php 
<?php
echo '<pre>', var_dump(getenv('MAGIC')), '</pre>';
~ # 
~ # php ./fileinfo.php 
<pre>string(21) "/opt/share/misc/magic"
</pre>~ # 
~ #

 

Edited by TheBB
add
  • Upvote 1
Posted
8 часов назад, Meccep45 сказал:

где эту базу брать.

opkg install file

-

https://www.php.net/manual/ru/book.fileinfo.php

Цитата

... Если не указан полный путь, будет использована переменная окружения MAGIC. Если переменная окружения не указана, то будет использоваться встроенная в PHP магическая база данных...

 

Posted (edited)

базу нашёл сам. я не лодырь. export MAGIC="/opt/share/misc/magic" что то не записался. ручонками вписал в \etc\profile

и прописал в php.ini

[mime_magic]
mime_magic.magicfile = "/opt/share/misc/magic"
;mime_magic.debug = On

 

Edited by Meccep45
  • Upvote 1
Posted
45 минут назад, Meccep45 сказал:

export MAGIC="/opt/share/misc/magic" что то не записался. ручонками вписал в \etc\profile

Ессно, при перезагрузке будет сброшено, да и до входа в систему, окружение другое. Можно экспорт вписать в стартовый скрипт (сервера или php).

49 минут назад, Meccep45 сказал:

и прописал в php.ini

При `opkg install --force-overwrite php7` конфиг будет полностью перезаписан, лучше вписать в свой, напр., `/opt/etc/php7/user.ini` (пользовательский конфиг (user.ini) можно обзывать по своему усмотрению).

Posted

что-то не завелось. и 7 не 8.  как протестировать  встроенный в php? кто шалит приложение, модуль или мои ручонки.  склонен к третьему.

Скрытый текст
2021/07/04 08:28:31 [error] 25715#0: *65 FastCGI sent in stderr: "PHP message: PHP Fatal error: 
Uncaught ValueError: Path cannot be empty in /opt/share/nginx/html/Sources/Subs.php:5617
Stack trace:
#0 /opt/share/nginx/html/Sources/Subs.php(5617): mime_content_type('/opt/share/ngin...')
#1 /opt/share/nginx/html/Sources/Subs.php(5667): get_mime_type('/opt/share/ngin...', true)
#2 /opt/share/nginx/html/Sources/Profile-Modify.php(3530): check_mime_type('/opt/share/ngin...', 'image/', true)
#3 /opt/share/nginx/html/Sources/Profile-Modify.php(822): profileSaveAvatarData('upload')
#4 /opt/share/nginx/html/Sources/Profile.php(725): saveProfileFields()
#5 /opt/share/nginx/html/index.php(187): ModifyProfile()
#6 {main}
  thrown in /opt/share/nginx/html/Sources/Subs.php on line 5617" while reading response header from upstream,
  client: 00.00.00.00, server: 00.00.00.00,
  request: "POST /index.php?action=profile;area=forumprofile;u=1 HTTP/2.0",
  upstream: "fastcgi://unix:/opt/var/run/php8-fpm/php8-fpm.sock:", host: "00.00.00.00",
  referrer: "https://00.00.00.00/index.php?action=profile;area=forumprofile;u=1"

2021/07/04 11:04:28 [error] 25715#0: *301 FastCGI sent in stderr: "PHP message: PHP Fatal error: 
Uncaught ValueError: Path cannot be empty in /opt/share/nginx/html/Sources/Subs.php:5617
Stack trace:
#0 /opt/share/nginx/html/Sources/Subs.php(5617): mime_content_type('/opt/tmp/phphjX...')
#1 /opt/share/nginx/html/Sources/Attachments.php(329): get_mime_type('/opt/tmp/phphjX...', true)
#2 /opt/share/nginx/html/Sources/Attachments.php(201): Attachments->processAttachments()
#3 /opt/share/nginx/html/Sources/Attachments.php(139): Attachments->add()
#4 /opt/share/nginx/html/index.php(187): Attachments->call()
#5 {main}
  thrown in /opt/share/nginx/html/Sources/Subs.php on line 5617" while reading response header from upstream,
  client: 00.00.00.00, server: 00.00.00.00,
  request: "POST /index.php?action=uploadAttach;sa=add;d490270f=de07bc1d1822120817ef6a193a8ea7b1;board=1 HTTP/2.0",
  upstream: "fastcgi://unix:/opt/var/run/php8-fpm/php8-fpm.sock:", host: "00.00.00.00",
  referrer: "https://00.00.00.00/index.php?action=post;topic=1.0;last_msg=1"

 

 

Posted

Что это за проект такой? Где брали php8?

Скрытый текст
~ # 
~ # php fileinfo.php 

Warning: finfo_open(): Failed to load magic database at "(null)" in /opt/root/fileinfo.php on line 2

Fatal error: Uncaught ValueError: Path cannot be empty in /opt/root/fileinfo.php:2
Stack trace:
#0 /opt/root/fileinfo.php(2): finfo_open(16)
#1 {main}
  thrown in /opt/root/fileinfo.php on line 2
~ # 
~ # 
~ # export MAGIC="/opt/share/misc/magic"
~ # 
~ # 
~ # php fileinfo.php 
directory
application/octet-stream
text/x-shellscript
text/plain
text/x-php
text/plain
application/octet-stream
directory
application/gzip
application/gzip
application/gzip
application/gzip
application/x-executable
text/plain
text/plain
application/x-executable
text/plain
application/gzip
application/gzip
text/x-php
application/gzip
application/gzip
text/x-php
text/html
directory
application/gzip
text/x-php
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
text/x-php
application/gzip
application/gzip
application/x-bzip2
text/plain
application/json
directory
directory
directory
directory
application/gzip
application/gzip
application/gzip
directory
directory
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
directory
application/x-empty
application/gzip
~ # 
~ # 
~ # cat fileinfo.php 
<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // возвращает mime-тип
foreach (glob("*") as $filename) {
    echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>
~ # 
~ # 
~ # strace -ffff -vvvv -e openat php fileinfo.php 
openat(AT_FDCWD, "/opt/lib/tls/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/lib/libcrypt.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libxml2.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libpcre2-8.so.0", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/lib/libiconv.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/opt/bin/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/etc/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/etc/php.ini", O_RDONLY) = 3
openat(AT_FDCWD, "/opt/etc/php8", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/opt/etc/php8/20_fileinfo.ini", O_RDONLY) = 3
openat(AT_FDCWD, "/opt/lib/php/fileinfo.so", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "fileinfo.php", O_RDONLY) = 3
openat(AT_FDCWD, "/opt/share/misc/magic", O_RDONLY) = 3
openat(AT_FDCWD, "/opt/share/misc/magic", O_RDONLY) = 3
openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/opt/root/Downloads", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/GeoLiteCity.dat", O_RDONLY) = 3
application/octet-stream
openat(AT_FDCWD, "/opt/root/S80oc", O_RDONLY) = 3
text/x-shellscript
openat(AT_FDCWD, "/opt/root/after.log", O_RDONLY) = 3
text/plain
openat(AT_FDCWD, "/opt/root/apc.php", O_RDONLY) = 3
text/x-php
openat(AT_FDCWD, "/opt/root/before.log", O_RDONLY) = 3
text/plain
openat(AT_FDCWD, "/opt/root/composer.phar", O_RDONLY) = 3
application/octet-stream
openat(AT_FDCWD, "/opt/root/configuration.yaml", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/coreutils-rs_0.0.2-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/coturn_4.5.2-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/dbus-utils_1.13.18-2_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/dbus_1.13.18-2_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/dnsproxy", O_RDONLY) = 3
application/x-executable
openat(AT_FDCWD, "/opt/root/dnsproxy.log", O_RDONLY) = 3
text/plain
openat(AT_FDCWD, "/opt/root/dnsproxy_2.log", O_RDONLY) = 3
text/plain
openat(AT_FDCWD, "/opt/root/dnsproxy_a", O_RDONLY) = 3
application/x-executable
openat(AT_FDCWD, "/opt/root/entw.txt", O_RDONLY) = 3
text/plain
openat(AT_FDCWD, "/opt/root/filebrowser_2.15.0-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/filebrowser_2.15.0-2_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/fileinfo.php", O_RDONLY) = 3
text/x-php
openat(AT_FDCWD, "/opt/root/gcc_7.4.0-6a_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/gcc_7.4.0-6b_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/geoip.inc", O_RDONLY) = 3
text/x-php
openat(AT_FDCWD, "/opt/root/geoip2.phar", O_RDONLY) = 3
text/html
openat(AT_FDCWD, "/opt/root/hb", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/homeassistant_2021.4.4-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/installer", O_RDONLY) = 3
text/x-php
openat(AT_FDCWD, "/opt/root/libdbus_1.13.18-2_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/libevent2-extra_2.1.11-2_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/libndm_1.1.15-1_mipsel-3.4_kn.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/libp11_0.4.11-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/libsocket_2.5.0-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/lua.php", O_RDONLY) = 3
text/x-php
openat(AT_FDCWD, "/opt/root/ndmq_1.0.2-7_mipsel-3.4_kn.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/odoh-client-go_0-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/owncloud-10.5.0.tar.bz2", O_RDONLY) = 3
application/x-bzip2
openat(AT_FDCWD, "/opt/root/owrt.txt", O_RDONLY) = 3
text/plain
openat(AT_FDCWD, "/opt/root/package-lock.json", O_RDONLY) = 3
application/json
openat(AT_FDCWD, "/opt/root/pkg", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/pkg2", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/pkg3", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/pkg4", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/poorbox_1.33.0-2_mipsel-3.4_kn.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/python3-aiohomekit_0.2.61-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/qbittorrent_4.3.4.1-2_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/rust", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/startup", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/stun-client_0.97-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/stunclient_1.2.16-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/stund_0.97-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/stunserver_1.2.16-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/stuntestcode_1.2.16-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
openat(AT_FDCWD, "/opt/root/test-hg", O_RDONLY) = 3
directory
openat(AT_FDCWD, "/opt/root/test.file", O_RDONLY) = 3
application/x-empty
openat(AT_FDCWD, "/opt/root/xupnpd-live_2020-01-25-1_mipsel-3.4.ipk", O_RDONLY) = 3
application/gzip
+++ exited with 0 +++
~ # 

 

 

4 часа назад, Meccep45 сказал:

как протестировать  встроенный в php?

не сисадмин, не сетевик... для проверки беру примеры из (напр.) https://www.php.net/manual/ru/function.finfo-file.php

 

Posted
2 часа назад, Meccep45 сказал:

пытаюсь поставить smf forum. но вся загвоздка в этом модуле.

какую версию, т.к. https://wiki.simplemachines.org/smf/SMF2.0:Requirements_and_recommendations

Цитата

РНР 4.1.0 or higher. Please note that PHP 8 is not supported at this time.

  • Versions of SMF below 2.0.7 will not work on PHP 5.5. If you use PHP 5.5 it is necessary to use SMF 2.0.7 or greater.
  • Versions of SMF from 2.0.16 require a version of PHP between 5.3 and 7.3. If you use PHP 5.3 or lower, it is necessary to use SMF 2.0.13 or lower or SMF 2.0.16 or higher. This is because 2.0.14 and 2.0.15 do not support PHP 5.3. PHP 7.4 is supported by SMF 2.0.17 or higher.

 

Posted
2 часа назад, TheBB сказал:
Цитата

Please note that PHP 8 is not supported at this time.

 

Нас снова обманули...

~ # ls smf*
smf_2-0-18_install.tar.gz       smf_2-0-18_russian-utf8.tar.gz
~ # 
Скрытый текст
~ # 
~ # php -v
PHP 8.0.3 (cli) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
~ # 
~ # php -m
[PHP Modules]
Core
date
fileinfo
filter
hash
json
libxml
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
posix
Reflection
session
SPL
standard
zlib

[Zend Modules]

~ # 

 

screen_2021-07-06_17:37:47_smf.png

...
[06-Jul-2021 17:36:03 Europe/Moscow] PHP Deprecated:  Required parameter $table follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:03 Europe/Moscow] PHP Deprecated:  Required parameter $columns follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:03 Europe/Moscow] PHP Deprecated:  Required parameter $data follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:03 Europe/Moscow] PHP Deprecated:  Required parameter $keys follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:09 Europe/Moscow] PHP Deprecated:  Required parameter $table follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:09 Europe/Moscow] PHP Deprecated:  Required parameter $columns follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:09 Europe/Moscow] PHP Deprecated:  Required parameter $data follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456
[06-Jul-2021 17:36:09 Europe/Moscow] PHP Deprecated:  Required parameter $keys follows optional parameter $method in /opt/share/www/smf/Sources/Subs-Db-mysql.php on line 1456

 

  • Upvote 1
Posted

PHP 7.4 поддерживается SMF 2.0.17 и выше. я взял 2.1rc3 с github. русский не ставил (сам делаю потихоньку) кривой он у них.  от этого бывают проблемы.

Posted

[07-Jul-2021 14:10:30 Europe/Moscow] PHP Warning:  mime_content_type(): Failed to load magic database in /opt/share/nginx/html/fileinfo.php on line 2
[07-Jul-2021 14:10:30 Europe/Moscow] PHP Warning:  mime_content_type(): Failed identify data 0:bad magic in `(null)' in /opt/share/nginx/html/fileinfo.php on line 2
[07-Jul-2021 14:10:30 Europe/Moscow] PHP Fatal error:  Uncaught ValueError: Path cannot be empty in /opt/share/nginx/html/fileinfo.php:2
Stack trace:
#0 /opt/share/nginx/html/fileinfo.php(2): mime_content_type('apple-touch-ico...')
#1 {main}
  thrown in /opt/share/nginx/html/fileinfo.php on line 2

похоже нет базы в самом phpX-mod-fileinfo или плохая. то есть встроенное в php работать не будет. я думал поставил модуль и вот оно счастье.

~ # php-cli ./fileinfo.php
~ #
~ # cat ./fileinfo.php
<?php
echo(mime_content_type('apple-touch-icon.png')); // returns image/png
?> ~ #

 

Posted

вот как должен был ответить рабочий phpX-mod-fileinfo. эхехе.

C:\Users\Mecce\Downloads\php-7.4.21-nts-Win32-vc15-x64>php fileinfo.php

image/png


C:\Users\Mecce\Downloads\php-7.4.21-nts-Win32-vc15-x64>

Posted

Благодарю TheBB направил в нужное русло. может починят в PHP 7 и в текущем тестовом PHP 8.0.3

Posted

opkg install php8-mod-fileinfo

opkg install file без него у fileinfo базы видимо нет.

echo export MAGIC="/opt/share/misc/magic" >> /opt/etc/profile записал переменную.

php.ini  изменил memory_limit = 32M на 8, 16 ругался. мозги говорит мозги.

открываю файл в консоли.

~ # cat /opt/share/nginx/html/fileinfo.php
<?php
echo(mime_content_type('/opt/share/nginx/html/apple-touch-icon.png')); // returns image/png
?>~ #

~ # php-cli /opt/share/nginx/html/fileinfo.php
image/png~ #

ответ верный php распознал.

если по http открыть снова здравствуйте.

2021/07/08 00:49:53 [error] 574#0: *12 FastCGI sent in stderr: "PHP message: PHP Warning:  mime_content_type(): Failed to load magic database in /opt/share/nginx/html/fileinfo.php on line 2PHP message: PHP Warning:  mime_content_type(): Failed identify data 0:bad magic in `(null)' in /opt/share/nginx/html/fileinfo.php on line 2PHP message: PHP Fatal error:  Uncaught ValueError: Path cannot be empty in /opt/share/nginx/html/fileinfo.php:2
Stack trace:
#0 /opt/share/nginx/html/fileinfo.php(2): mime_content_type('/opt/share/ngin...')
#1 {main}

где то переменную искать. nginx, php-fpm

Posted (edited)

http://bin.entware.net/mipselsf-k3.4/test/php8/ (coming soon ))))

пытайте

Скрытый текст
~/resources # 
~/resources # env | grep ^MAG
~/resources # 
~/resources # ls -al
drwxr-xr-x    2 root     root          4096 Jul  8 01:06 .
drwxr-xr-x   24 root     root         12288 Jul  8 01:05 ..
-rw-r--r--    1 root     root        144810 Jun  1 21:43 67647.mov
-rw-r--r--    1 root     root         10752 Jun  1 21:43 bug79756.xls
-rw-r--r--    1 root     root           392 Jun  1 21:43 dir.zip
-rw-r--r--    1 root     root           191 Jul  8 01:06 fileinfo.php
-rw-r--r--    1 root     root            24 Jun  1 21:43 test.awk
-rw-r--r--    1 root     root            58 Jun  1 21:43 test.bmp
-rw-r--r--    1 root     root            43 Jun  1 21:43 test.gif
-rw-r--r--    1 root     root           160 Jun  1 21:43 test.jpg
-rw-r--r--    1 root     root           185 Jun  1 21:43 test.json
-rw-r--r--    1 root     root         25801 Jun  1 21:43 test.mp3
-rw-r--r--    1 root     root          1605 Jun  1 21:43 test.pdf
-rw-r--r--    1 root     root            93 Jun  1 21:43 test.png
-rw-r--r--    1 root     root         99840 Jun  1 21:43 test.ppt
-rw-r--r--    1 root     root            19 Jun  1 21:43 test.tga
-rw-r--r--    1 root     root          4837 Jun  1 21:43 test.webm
~/resources # 
~/resources # php fileinfo.php 
video/quicktime
application/vnd.ms-excel
application/zip
text/x-php
text/plain
image/x-ms-bmp
image/gif
image/jpeg
application/json
audio/mpeg
application/pdf
image/png
application/vnd.ms-powerpoint
image/x-tga
video/webm
~/resources # 
~/resources # php -v
PHP 8.0.7 (cli) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.7, Copyright (c) Zend Technologies
~/resources #

 

 

Edited by TheBB
  • Upvote 1
Posted (edited)

8.0.7 PHP Warning:  PHP Startup: Unable to load dynamic library 'intl.so' (tried: /opt/lib/php8/intl.so (libicuio.so.69: cannot open shared object file: No such file or directory), /opt/lib/php8/intl.so.so (/opt/lib/php8/intl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

so или so.so

Edited by Meccep45
Posted (edited)

icu_69.1-1_mipsel-3.4.ipk

icu-full-data_69.1-1_mipsel-3.4.ipk

Edited by TheBB
  • Upvote 1
Posted (edited)

91229376_Screenshot2021-07-08at04-05-35httpszav-hubddnsnet.png.dea34b4442f08c1050a2e6d7da7ee837.png

не знаю чо вы  сделали. но вы волшебник. всё заработало. потестю немного. отпишусь.

Edited by Meccep45
Posted
9 часов назад, Meccep45 сказал:

не знаю чо вы  сделали. но вы волшебник. всё заработало. потестю немного. отпишусь.

"... Я не волшебник, я только учусь..." (х/ф "Золушка", 1947 г.)

icu - нов. версия пакета (те, кто подписан на канал https://t.me/entware, уже в курсе, а не успевшим  подписаться - (инсайдерская утечка) начало очередной синхронизации ))) )

пересобрал "fileinfo" - для встроенной базы используется файл "data_file.c", который генерится из "magic.mgc" ("magic.mgc" - скомпиленый файл базы, "magic" - текстовый, а в OpenWrt, ещё и "погрызенный" (+L92)  sed`ом)

# ls -lL /opt/share/misc/
-rw-r--r--    1 root     root        725132 May 26 14:09 magic
-rw-r--r--    1 root     root       7035712 Jul  8 01:18 magic.mgc
#
# cat create_data_file.php 
#!/usr/bin/env php
/* This is a generated file, do not modify */
/* Usage: php create_data_file.php /path/to/magic.mgc > data_file.c */
...

Из пропатченного  "magic.mgc" генерится "data_file.c", размером ~ 42 MB (против ~ 40 MB в оригинале), diff (патч) из них выходит ~ 22 MB.

Нафига оно нужно? См. ниже ( такая же фиговина и для php):

/opt/bin # 
/opt/bin # file -m /opt/share/misc_orig/magic.mgc -L bash.file 
bash.file: a /opt/bin/bash script, ASCII text executable
/opt/bin # 
/opt/bin # file -m /opt/share/misc_patch/magic.mgc -L bash.file 
bash.file: Bourne-Again shell script, ASCII text executable
/opt/bin # 
/opt/bin # 
/opt/bin # file -m /opt/share/misc_orig/magic.mgc -L ldd
ldd: a /opt/bin/sh script, ASCII text executable
/opt/bin # 
/opt/bin # file -m /opt/share/misc_patch/magic.mgc -L ldd
ldd: POSIX shell script, ASCII text executable
/opt/bin # 
/opt/bin # 
/opt/bin # file -m /opt/share/misc_orig/magic.mgc -L wsrep_sst_mariabackup 
wsrep_sst_mariabackup: a /opt/bin/sh -ue script, ASCII text executable
/opt/bin # 
/opt/bin # file -m /opt/share/misc_patch/magic.mgc -L wsrep_sst_mariabackup 
wsrep_sst_mariabackup: POSIX shell script, ASCII text executable
/opt/bin # 
/opt/bin # 
/opt/bin # file -m /opt/share/misc_orig/magic.mgc -L zigbee2mqtt 
zigbee2mqtt: a /opt/bin/node script, ASCII text executable
/opt/bin # 
/opt/bin # file -m /opt/share/misc_patch/magic.mgc -L zigbee2mqtt 
zigbee2mqtt: Node.js script, ASCII text executable
/opt/bin # 
/opt/bin # 
/opt/bin # file -m /opt/share/misc_orig/magic.mgc -L file.php 
file.php: a /opt/bin/php script, ASCII text executable
/opt/bin # 
/opt/bin # file -m /opt/share/misc_patch/magic.mgc -L file.php 
file.php: PHP script, ASCII text executable
/opt/bin # 

"magic.mgc"/"magic" - значения не имеет; "/opt/share/misc_orig/magic.mgc" - оригинальный (не патченный); "/opt/share/misc_patch/magic.mgc" - патченный

  • 2 years later...
Posted

только решили в 7 версии и вот в 8 снова она.

Скрытый текст
[18-Apr-2024 05:16:22 Europe/Moscow] PHP Warning:  mime_content_type(): Failed to load magic database in /opt/share/nginx/html/test.php on line 2
[18-Apr-2024 05:16:22 Europe/Moscow] PHP Warning:  mime_content_type(): Failed identify data 0:File 543 supports only version 18 magic files. `(null)' is version 16 in /opt/share/nginx/html/test.php on line 2
[18-Apr-2024 05:16:22 Europe/Moscow] PHP Fatal error:  Uncaught ValueError: Path cannot be empty in /opt/share/nginx/html/test.php:2

 

~ # cat /opt/share/nginx/html/test.php
<?php
echo(mime_content_type('/opt/share/nginx/html/favicon/apple-touch-icon.png')); // returns image/png
?>
~ #

 

  • Thanks 1
Posted

в этот раз решилось проще. скачал  пакет file, добавил в файл www.conf  переменную env[MAGIC] = /opt/share/misc/magic и всё завелось.

Posted
8 часов назад, Meccep45 сказал:

и вот в 8 снова она.

Тут можно меня смело пинать и дать в глаз... подготовил, но пропустил-забыл. Если не критично - можно подождать до следующей синхронизации. Или?

Будет так:

 ~  # file Example1.png 
Example1.png: PNG image data, 1337 x 1067, 8-bit/color RGB, non-interlaced
 ~  # 
 ~  # php fileinfo.php; echo
image/png
 ~  # 

 

  • Upvote 1
Posted
6 часов назад, TheBB сказал:

подготовил, но пропустил-забыл

я лучше руку протяну, чтоб спасибо сказать. за отзывчивость.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...