分类目录归档:PHP

blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];

FORBIDDEN/12/index read-only / allow delete (api)

官方解决方法:

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

_all 可以改为自己的索引名称,也可以直接执行

curl -XPUT -H "Content-Type: application/json" http://127.0.0.1:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

原文链接:https://www.cnblogs.com/zhja/p/9717536.html

统计php-fpm内存占用总量

ps auxf|grep www_sockets | grep -v grep | awk ‘{print $6}’ | awk ‘{sum+=$1} END {print “Memory =”, sum/1024/1024, “GB”}’

根据需求定制 红色部分是你要修改的部分

php iOS内购验证库

项目地址:

https://github.com/sn01615/ios-iap-php

安装:

composer require sn01615/ios-iap-php

使用:


use sn01615\iap\ios\Verify; include "../vendor/autoload.php"; $cc = new Verify(); $receipt = ".."; // 凭据 $cc->endpoint(true);// 可选切换到沙盒环境 $vv = $cc->query($receipt); // 打印结果 var_dump($vv);

PHP7 扩展Hello world

[root@local2 ext]# ./ext_skel --extname=Hello

Creating directory Hello
Creating basic files: config.m4 config.w32 .gitignore Hello.c php_Hello.h CREDITS EXPERIMENTAL tests/001.phpt Hello.php [done].

To use your new extension, you will have to execute the following steps:

1.  $ cd ..
2.  $ vi ext/Hello/config.m4
3.  $ ./buildconf
4.  $ ./configure --[with|enable]-Hello
5.  $ make
6.  $ ./sapi/cli/php -f ext/Hello/Hello.php
7.  $ vi ext/Hello/Hello.c
8.  $ make

Repeat steps 3-6 until you are satisfied with ext/Hello/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.

[root@local2 ext]# 
# phpize 
# ./configure --enable-Hello
# make
# php -i | grep Hello
# php Hello.php 

PHP MongoDB各版本库和扩展版本对应关系

PHP DriverMongoDB 4.0MongoDB 3.6MongoDB 3.4MongoDB 3.2MongoDB 3.0MongoDB 2.6
PHPLIB 1.4 + mongodb-1.5 
PHPLIB 1.3 + mongodb-1.4 
PHPLIB 1.2 + mongodb-1.3  
PHPLIB 1.1 + mongodb-1.2  
PHPLIB 1.0 + mongodb-1.1   
mongodb-1.0    

laravel实现跨域的中间件

# 创建中间件
php artisan make:middleware EnableCrossRequestMiddleware
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class EnableCrossRequestMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param Request $request
     * @param Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $origin = $request->header('Origin');
        if ($origin) {
            $exps = [
                '/.*\.xxx\.com$/', # 匹配下自己的域名
                '/.*localhost.*/',
                '/.*127.0.0.1.*/',
                '/.*10.*/',
            ];
            foreach ($exps as $exp) {
                $matchCount = preg_match($exp, $origin, $matches);
                if ($matchCount && isset($matches[0])) {
                    if ($request->isMethod('OPTIONS')) {
                        $response = response('');
                        $response->withHeaders([
                            'Access-Control-Allow-Credentials' => 'true',
                            'Access-Control-Allow-Origin' => $origin,
                            'Access-Control-Allow-Methods' => 'GET, POST',
                            'Access-Control-Allow-Headers' => 'Content-Type, Token',
                            'Access-Control-Max-Age' => 3600 * 24,
                        ]);
                        return $response;
                    }
                    $response = $next($request);
                    $response->withHeaders([
                        'Access-Control-Allow-Credentials' => 'true',
                        'Access-Control-Allow-Origin' => $origin,
                    ]);
                    return $response;
                }
            }
        }
        return $next($request);
    }
}

另外需要关闭csrf保护否则会413