Пропатчил до PHP 8 скрипт поиска подозрительных файлов на хостинге ai-bolit.php
Category: PHP(Страница 1 из 3)
После перехода на PHP8 отвалился скрипт парсинга сайтов phpQuery-0.9.5.386-onefile.zip и мне пришлось пропатчить его. В результате, этот скрипт прекрасно работает на любой версии PHP8, от 8.0 и выше.
Пропатченный под PHP8 файл phpQuery-onefile.php
Скачать файл с GitGub
Скачать файл с konyakov.ru
Открыть в текстовом виде
Ошибка:
PHP Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in ...
Меняем строку:
$some_var = explode(',', $_GET['some_string']);
На:
$some_var = explode('-', $_GET['some_string'] ?? '');
Ошибка:
[TypeError]
in_array(): Argument #2 ($haystack) must be of type array, null given (0) ...
#0: in_array(string, NULL)
Меняем вхождение:
in_array("some_text", $some_var)
На:
in_array("some_text", $some_var ?? [])
Download ChaCha20 Poly1305 PHP Class
Result:
plaintext: Lorem Ipsum is simply dummy text of the printing and typesetting industry... r_key: c406e3627a624c2f7858d8729f49dfdf76e7d989 aad: 7aabe76b4ee1c27624d055baf45a8a021f6147a2 Iv: 4f5ad309b5a5eb7c4479ef58f1eb66fba686ca9d crypt: e836c0b64606d6d878b267b5daeaaff3e129352bb16c28c0a1a5d452781146c0ce1a53831bb466593dcf192bd8ee4a706c52d2bd3d978872d380c94f18e215171088336ccca3b55c23d7774b6cb11ffc1fdabeefb78045428906890a decrypt: Lorem Ipsum is simply dummy text of the printing and typesetting industry...
Code example:
<?php
include("AEAD_CHACHA20_POLY1305.php");
$x = new AEAD_CHACHA20_POLY1305;
$plaintext = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry...';
$r_key = sha1(sha1(sha1(mt_rand(0, 99999) + time())));
$aad = sha1(sha1(sha1(mt_rand(0, 99999) + time())));
$Iv = sha1(sha1(sha1(mt_rand(0, 99999) + time())));
$crypt = $x->chacha20_aead_encrypt($aad, $Key, $Iv, '07000000', $plaintext);
$decrypt = $x->chacha20_aead_decrypt($aad, $Key, $Iv, '07000000', $crypt);
$out = '<pre>';
$out .= "plaintext:\t".$plaintext."\n\n";
$out .= "r_key:\t".$r_key."\n";
$out.= "aad:\t".$aad."\n";
$out .= "Iv:\t".$Iv."\n\n";
$out .= "crypt:\t".$crypt."\n\n";
$out .= "decrypt:\t".$decrypt."\n\n";
$out .= '</pre>';
echo $out;
?>

