Category Archives: sadmin

sadmin

php8

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in file.php:206 Stack trace: #0 {main} thrown in file.php on line 206

преди
$num_results=count($r);
след
$num_results=count((array)$r);

--------------------------

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

dhc: Бъг на модула с менюто (menu fix / меню бъг)

MariaDB [d_dar6hd3]> insert into menu_bg (group_id) values ('3');
ERROR 167 (22003): Out of range value for column 'id' at row 1

MariaDB [d_dar6hd3]> describe menu_bg;
+-----------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+----------------+
| id | tinyint(3) unsigned | NO | PRI | NULL | auto_increment |
| parent_id | tinyint(3) unsigned | NO | | 0 | |
| title | varchar(255) | NO | | | |
| url | varchar(255) | NO | | | |
| class | varchar(255) | NO | | | |
| position | tinyint(3) unsigned | NO | | 0 | |
| group_id | tinyint(3) unsigned | NO | | 1 | |
| sub_exist | enum('1','0') | YES | | 0 | |
+-----------+---------------------+------+-----+---------+----------------+
8 rows in set (0,001 sec)

MariaDB [d_dar6hd3]> insert into menu_bg (group_id) values ('3');
ERROR 167 (22003): Out of range value for column 'id' at row 1

FIX

alter table menu_bg modify id SMALLINT(3) unsigned NOT NULL AUTO_INCREMENT;

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Laravel vs Core PHP vs Core PHP +Smarty

Core PHP + Smarty -- the Winner

Направихме един малък тест за бързодействие на
Laravel vs (Core PHP + Smarty) vs Core PHP

Очакван резултат, но все пак извод:
CorePHP е топ за супер натоварени сайтове където се гони абсолютен оптимум, а не просто да работи и да се купуват железа безкрай.
+ и -- на Laravel са ясни. Идеята тук е бързодействие, а със Smarty се получава и разделение на front, back.
Всеки проект и ситуация определя какво да се ползва: Laravel, друг framework, Core PHP или друго…
PS0: За тестовете бяха направени три контейнера с абсолютно еднакви параметри на дистро,пакети/apache+nginx proxy+mariadb/,страниците извършиха един и същи брой заявки към db и т.н.
Всичко се изпълни локално в конкретните контейнери/ясно е защо/
Ползван беше apache bench tool: ab -n 10000 -c 200 https://example.com

Ето ги и резултатите:

laravel_vs_core_php_vs_smarty

#Core PHP # > ab -n 10000 -c 100 https://example.com

Server Software: nginx/1.18.0
Document Length: 35030 bytes

Concurrency Level: 100
Time taken for tests: 23.690 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 354230000 bytes
HTML transferred: 350300000 bytes
Requests per second: 389.26 [#/sec] (mean)
Time per request: 256.898 [ms] (mean)
Time per request: 2.569 [ms] (mean, across all concurrent requests)
Transfer rate: 13465.55 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 5 94 43.1 85 373
Processing: 10 161 58.1 154 439
Waiting: 7 79 55.1 67 337
Total: 14 255 73.1 247 581

#######################################################################
#Core PHP + Smarty# >

Concurrency Level: 100
Time taken for tests: 2.585 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 29295000 bytes
HTML transferred: 28902000 bytes
Requests per second: 386.82 [#/sec] (mean)
Time per request: 258.516 [ms] (mean)
Time per request: 2.585 [ms] (mean, across all concurrent requests)
Transfer rate: 11066.38 [Kbytes/sec] received

#######################################################################
#Laravel

Concurrency Level: 100
Time taken for tests: 3.483 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 39052000 bytes
HTML transferred: 37818000 bytes
Requests per second: 287.10 [#/sec] (mean)
Time per request: 348.309 [ms] (mean)
Time per request: 3.483 [ms] (mean, across all concurrent requests)
Transfer rate: 10949.12 [Kbytes/sec] received

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Проблем с apache: Set the 'ServerName' directive globally to suppress this message

# apache2ctl -t
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

/etc/apache2/apache2.conf

ServerName 127.0.0.1

#/etc/init.d/apache2 restart
[ ok ] Restarting apache2 (via systemctl): apache2.service.

# apache2ctl -t
Syntax OK

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

При интервал в url-то на Apache се връща грешка 403 -- Forbidden

От версия 2.4.56 на Apache има фикс "Apache HTTP Server: HTTP request splitting with mod_rewrite and mod_proxy" (CVE-2023-25690)" където всички интервали в урл-тата ще връщат 403

За да се фиксне се доабвят флаговете BCTLS или B към текущите флагове,
т.е.

Пример:
RewriteRule ^primer$ /h_primeren_file.php [QSA,L]

Пренаписва се така:

RewriteRule ^primer$ /h_primeren_file.php [BCTL,QSA,L]

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Показване на wifi паролите на Windows 10

netsh

netsh>wlan show profile

Profiles on interface Wi-Fi:

Group policy profiles (read only)
---------------------------------

User profiles
-------------
All User Profile : wifi_network

netsh>wlan show profile "amri" key=clear

Profile amri on interface Wi-Fi:
=======================================================================

Applied: All User Profile

Profile information
-------------------
Version : 1
Type : Wireless LAN
Name : wifi_network
Control options :
Connection mode : Connect automatically
Network broadcast : Connect only if this network is broadcasting
AutoSwitch : Do not switch to other networks
MAC Randomization : Disabled

Connectivity settings
---------------------
Number of SSIDs : 1
SSID name : "wifi_network"
Network type : Infrastructure
Radio type : [ Any Radio Type ]
Vendor extension : Not present

Security settings
-----------------
Authentication : WPA2-Personal
Cipher : CCMP
Authentication : WPA2-Personal
Cipher : GCMP
Security key : Present
Key Content : super_wifi_pass

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Конвертиране от proxmox lxc към lxd

cd /tmp
pct list

vzdump 103 -compress gzip -dumpdir /tmp
echo architecture: `pct config 103 | grep arch: | awk '{print $2}' ` > metadata.yaml
echo creation_date: `date +%s` >> metadata.yaml
echo description: 'Imported from Proxmox/amri' >> metadata.yaml
tar -czvf metadata.tar.gz metadata.yaml

scp vzdump-lxc-103-2024_01_23-19_06_30.tar.gz metadata.tar.gz [email protected]:/home/amri/

lxc launch fromproxmox Test -c boot.autostart=true

lxc image import --alias=fromproxmox metadata.tar.gz vzdump-lxc-103-2024_01_23-19_06_30.tar.gz

lxc image list

Източник: https://discussion.scottibyte.com/t/replace-proxmox-lxc-containers-with-lxd-containers/247

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

APT sources.list за всяка Debian версия

debian-linux

Debian 8 (Jessie)
Оригинално хранилище:

deb http://deb.debian.org/debian/ jessie main contrib non-free
deb http://ftp.debian.org/debian/ jessie-updates main contrib
deb http://security.debian.org/ jessie/updates main contrib non-free

Архивирано хранилище:

deb http://archive.debian.org/debian/ jessie main contrib non-free
deb http://archive.debian.org/debian-security jessie/updates main contrib non-free

Debian 9 (Stretch)
Оригинално хранилище:

deb http://deb.debian.org/debian/ stretch main contrib non-free
deb http://deb.debian.org/debian/ stretch-updates main contrib non-free
deb http://security.debian.org/ stretch/updates main contrib non-free

Архивирано хранилище (анонсирано на 27.03.2023):

deb http://archive.debian.org/debian/ stretch main contrib non-free
deb http://archive.debian.org/debian/ stretch-proposed-updates main contrib non-free
deb http://archive.debian.org/debian-security stretch/updates main contrib non-free

Debian 10 (Buster)
Оригинално хранилище:

deb http://deb.debian.org/debian/ buster main non-free contrib
deb http://deb.debian.org/debian/ buster-updates main non-free contrib
deb http://security.debian.org/ buster/updates main non-free contrib

Debian 11 (Bullseye)
Оригинално хранилище:

deb http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb http://security.debian.org/debian-security bullseye-security main contrib non-free

Debian 12 (Bookworm)
Оригинално хранилище:

deb http://deb.debian.org/debian bookworm main contrib non-free-firmware non-free
deb http://deb.debian.org/debian bookworm-updates main contrib non-free-firmware non-free
deb http://security.debian.org/debian-security bookworm-security main contrib non-free-firmware non-free

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

(GNU/Linux > exiftool) Синхронизация на FileModifyDate със DateTimeOriginal от EXIF на изображенията

Изтеглих архив на всичките снимки от g drive, обаче датата която сетна на снимките е датата на генериране на архива, което е изкл. трудно за сортиране понеже са с една и съща дата.

За щастие истинската дата на създаване се пази в EXIF-а на всяко изображение. За целта ще синхронизираме FileModifyDate със DateTimeOriginal и всичко ще се нормализира ;)

exiftool "-DateTimeOriginal>FileModifyDate" -ext jpg . -L -r

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Монтиране на ssh fs на Windows :(

Идеята е на Windboze машинка да се монтира отдалечено ssh като локална папка за по- лесна работа:

1. WinFsp 2022 > https://github.com/winfsp/winfsp/releases
2. SSHFS-Win > https://github.com/winfsp/sshfs-win/releases
3. SSHFS-Win Manager > https://github.com/evsar3/sshfs-win-manager/releases

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)