2019年7月

function ipCode() {
    $ip_long = array(
        array('607649792', '608174079'), // 36.56.0.0-36.63.255.255
        array('1038614528', '1039007743'), // 61.232.0.0-61.237.255.255
        array('1783627776', '1784676351'), // 106.80.0.0-106.95.255.255
        array('2035023872', '2035154943'), // 121.76.0.0-121.77.255.255
        array('2078801920', '2079064063'), // 123.232.0.0-123.235.255.255
        array('-1950089216', '-1948778497'), // 139.196.0.0-139.215.255.255
        array('-1425539072', '-1425014785'), // 171.8.0.0-171.15.255.255
        array('-1236271104', '-1235419137'), // 182.80.0.0-182.92.255.255
        array('-770113536', '-768606209'), // 210.25.0.0-210.47.255.255
        array('-569376768', '-564133889'), // 222.16.0.0-222.95.255.255
    );
 
    $rand_key = mt_rand(0, 9);
 
    return $ip = long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
}

分享网址:
http://www.dooccn.com/php7/#id/b68e0f6af9ba47807a24478ffdaf2684

<?php
function randNumberArray($min, $max, $count){
    $res = [];
    foreach (range(1, $count) as $n) {
        $res[] = mt_rand($min, $max);
    }
    sort($res, SORT_NUMERIC);
    return $res;
}

/**
 * 合并秒和毫钞,并按从小到大排序
 */
function mergeTimeMillisecond($times, $milliseconds){
    sort($times, SORT_NUMERIC);
    $times = array_map(function ($v,$idx) use ($milliseconds) {
        return $v * 1000 + ($milliseconds[$idx]??0);
    }, $times, array_keys($times));
    sort($times, SORT_NUMERIC);
    $times = array_map(function ($v) {
        $_f = explode('.', strval($v / 1000));
        return [
            $_f[0],
            $_f[1]??0
        ];
    }, $times, array_keys($times));
    return $times;
}

function randMillisecond($count, $total, $extent=0.3){
    $res = [];
    $svg = $total / $count;
    for($i=1;$i<$count;$i++){
        $_rand = mt_rand(max(0, $svg-($svg*$extent)), min(999, $svg+($svg*$extent)));
        $res[] = $_rand;
    }
    $end = $total - array_sum($res);
    if ($end < 0) {
        $end = abs($end);
        foreach ($res as &$v) {
            if ($v > $end) {
                $v -=$end;
                continue;
            }
        }
        unset($v);
        $end = 0;
    }
    $res[] = $end;
    shuffle($res);
    return $res;
}

$count = 10;
$total = intval(999 * $count * .5);
$res = randMillisecond($count, $total);
$times =  randNumberArray(time() - 10, time(), 10);
$times = mergeTimeMillisecond($times, $res);
var_dump($count, $total, $res, array_sum($res), $times);

查看命令文档:

man ls

按大小排序:

ll -Sh

按时间排序:

ll -t

默认是按降序,如要按升序可+上管道:| tac

可能的情况:
1、服务器磁盘满了,查看磁盘
https://blog.csdn.net/dujianxiong/article/details/84288658

df -h

2、nginx的fastcgi_temp目录没有读写权限,查看nginx的error日志,会发现:

2010/03/13 02:52:19 [crit] 3396#0: *10 open() 
"/usr/local/nginx/fastcgi_temp/2/00/0000000002" failed (13: Permission denied)

处理方法,给目录增加权限或者修改所有者为nginx worker的运行用户

chown www:www /usr/local/nginx/fastcgi_temp -R

分析 fastcgi_temp 错误以及 Nginx 的 Buffer 机制: https://blog.csdn.net/crx05/article/details/70210323