PHP安全的获取ip

    public static function getIpX(): ?string {
        [$ip] = self::getIp();
        return $ip;
    }

    public static function getIp(): array {
        $ip0 = $ip = $_SERVER['REMOTE_ADDR'] ?? null;
        if (in_array($ip, [
            '10.29.185.7', '127.0.0.1', '172.17.0.1', '172.31.242.237', # 可信IP列表
        ])) {
            $ip1 = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null;
            if ($ip1) {
                $ip0 = $ip1;
                $ip = explode(',', $ip1)[0];
            }
        }
        if (!$ip) {
            $ip = $_SERVER['REMOTE_ADDR'] ?? null;
        }
        return [$ip, $ip0];
    }

Linux swap使用率为0

Linux 中 Swap 交换分区设置教程,以及 Swap 大小与内存的关系 – 知乎

系统配置:Linux有一个swappiness参数,决定了系统使用swap的频率。默认值通常为60,值越低,越不容易使用swap。可以通过以下命令查看当前值:

cat /proc/sys/vm/swappiness

如果你希望系统更倾向于使用swap,可以将其设置为一个更高的值,例如:

sudo sysctl vm.swappiness=80
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/sunyuhua_keyboard/article/details/14248714

nginx restart failed:nginx: [alert] OPENSSL_init_ssl() failed (SSL: error:12800067:DSO support routines::could not load the shared library:filename(/snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/fips.so): /snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/fips.so: cannot open shared object file: No such file or directory error:12800067:DSO support routines::could not load the shared library error:07880025:common libcrypto routines::reason(37):name=fips error:0700006D:configuration file routines::module initialization error:module=providers, value=provider_sect retcode=-1 ) 解决办法

nginx restart failed:
nginx: [alert] OPENSSL_init_ssl() failed (SSL: error:12800067:DSO support routines::could not load the shared library:filename(/snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/fips.so): /snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/fips.so: cannot open shared object file: No such file or directory error:12800067:DSO support routines::could not load the shared library error:07880025:common libcrypto routines::reason(37):name=fips error:0700006D:configuration file routines::module initialization error:module=providers, value=provider_sect retcode=-1 )

解决办法:

nginx restart failed:
nginx: [alert] OPENSSL_init_ssl() failed (SSL: error:12800067:DSO support routines::could not load the shared library:filename(/snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/fips.so): /snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/fips.so: cannot open shared object file: No such file or directory error:12800067:DSO support routines::could not load the shared library error:07880025:common libcrypto routines::reason(37):name=fips error:0700006D:configuration file routines::module initialization error:module=providers, value=provider_sect retcode=-1      )

Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
[root@ooops ~]# find / -name fips.so
/usr/lib64/ossl-modules/fips.so
[root@ooops ~]# mount --bind /usr/lib64/ossl-modules/ /snap/certbot/4325/usr/lib/x86_64-linux-gnu/ossl-modules/

4325注意替换为你的id

HTML中的0宽度空格

HTML中的0宽度空格是一个不可见的字符,它用于在HTML中创建小的间隔或强制文本或元素在同一行内显示。

要在HTML中插入0宽度空格,你可以使用字符实体​。这是一个不断行的空格(zero-width space,ZWSP),它不会产生任何可见的间隔,但会占用空间。

PHP简易排队限流实现

$fp = fopen(sprintf("tmp/wk_exam_examination.%d.lock", $userid % 10), "w");
if (!flock($fp, LOCK_EX | LOCK_NB)) {
    ?>
  <style>
    #info {
      text-align: center;
      margin: 50px 0;
    }

    #info td {
      font-size: 36px;
      color: seagreen;
    }
  </style>
  <div id='info'></div>
  <script>
    let sec = 5000
    setTimeout(function () {
      window.location.reload()
    }, sec)
    setInterval(function () {
      sec -= 100
      if (sec >= 0) {
        let ok = sec / 1000
        document.getElementById('info').innerHTML = `<table style="margin: 0 auto;">
        <tr><td style='width: 50%; text-align: right;'>页面排队中...</td>
        <td style="width: 2em; text-align: center;">${ok}</td><td>秒后将重试!</td></tr></table>`;
      }
    }, 100)
  </script><?php
    die;
}