Fix PHP 7 32

This commit is contained in:
2025-11-24 22:10:14 -03:00
parent 1dd676c628
commit fd7681930b
2 changed files with 28 additions and 14 deletions

View File

@@ -1,51 +1,65 @@
<?php
function bitmask()
{
$cores = intval(shell_exec("/usr/bin/grep -c ^processor /proc/cpuinfo"));
$half_cores = ceil($cores / 2);
$bitmask = 0;
for ($i = 0; $i < $half_cores; $i++) {
$bitmask |= (1 << $i);
}
return $bitmask;
}
function netinter()
{
$interface = trim(shell_exec("/usr/bin/ip route get 1 | grep -Po '(?<=dev )(\S+)'"));
return $interface;
}
function insertnet()
{
$netface = netinter();
$checknet = trim(shell_exec("/usr/bin/cat /sys/class/net/$netface/queues/rx-0/rps_cpus"));
$bit = bitmask();
if (str_contains($checknet, $bit)) {
if ($netface === '') {
echo "Não foi possível detectar interface de rede.\n";
return;
}
$path = "/sys/class/net/$netface/queues/rx-0/rps_cpus";
$checknet = trim(@shell_exec("/usr/bin/cat $path"));
$bit = bitmask();
if ((int)$checknet === (int)$bit) {
deletecone("netsta");
shell_exec("/usr/bin/echo \"0\" > /sys/class/net/$netface/queues/rx-0/rps_cpus");
shell_exec("/usr/bin/echo \"0\" > $path");
echo "Balanceamento Desativado! \n";
} else {
deletecone("netsta");
incone("netsta", "null", "null", "null", "null");
shell_exec("/usr/bin/echo \"$bit\" > /sys/class/net/$netface/queues/rx-0/rps_cpus");
shell_exec("/usr/bin/echo \"$bit\" > $path");
echo "Balanceamento ativado! \n";
}
}
function checknet()
{
$netface = netinter();
$checknet = trim(shell_exec("/usr/bin/cat /sys/class/net/$netface/queues/rx-0/rps_cpus"));
$bit = bitmask();
if (str_contains($checknet, $bit)) {
if ($netface === '') {
echo "OFF";
return;
}
$path = "/sys/class/net/$netface/queues/rx-0/rps_cpus";
$checknet = trim(@shell_exec("/usr/bin/cat $path"));
$bit = bitmask();
if ((int)$checknet === (int)$bit) {
echo "ON";
} else {
echo "OFF";
}
}
}

View File

@@ -1 +1 @@
31 Year Of the Tubular Dragon
32 Year Of the Tubular Dragon