分类 php 下的文章

$data = array(
  array(
    'id' => 5698,
    'first_name' => 'Bill',
    'last_name' => 'Gates',
  ),
  array(
    'id' => 4767,
    'first_name' => 'Steve',
    'last_name' => 'Aobs',
  ),
  array(
    'id' => 3809,
    'first_name' => 'Mark',
    'last_name' => 'Zuckerberg',
  )
);

//根据字段last_name对数组$data进行降序排列
$last_names = array_column($data,'last_name');
array_multisort($last_names,SORT_DESC,$data);

var_dump($data);

以本地链接线上websocket为例,如图所示
var ws = new WebSocket("ws://127.0.0.1:6543");
ws.onopen = function()
{
ws.send(JSON.stringify({'type':'bind','uid':1}))
};
步骤一:如果请求域名为http,则可以正常访问,然而当域名为https时,就会报错,如下图所示

img_a2f013e1901998dcd0bc3adc61ec82ec.png

错误信息:Mixed Content: The page at ‘https://{域名}.com/‘ was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ‘ws://{ip}:{port}/‘. This request has been blocked; this endpoint must be available over WSS.
Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS

步骤二:根据错误提示信息,需要使用wss请求var ws = new WebSocket("wss://127.0.0.1:6543");

这时重新访问,会出现如下图所示信息
错误信息:failed:Error in connection establishment: newt::ERR_SSLPROTOCOL_ERROR
注:在使用https协议时,需要指定域名,这里换成ws = new WebSocket("wss://{域名}/wss");
同时修改nginx配置文件,在conf中加入以下代码
location /wss {
proxy_pass http://172.30.9.176:6543;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

}
重启nginx服务后即可正常通讯

生成桌面快捷方式程序如下

  header("Content-type: text/html; charset=gbk");
  $title = !empty($_GET['title'])?$_GET['title']:'';//获取传值
  $url = !empty($_GET['url'])?$_GET['url']:'';//获取传值

  $title = test_input($title);
  $url = test_input($url);

  $Shortcut = "[InternetShortcut]
  URL=".$url."
  IDList=
  [{000214A0-0000-0000-C000-000000000046}]
  Prop3=19,2
  ";
  header("Content-type: application/octet-stream");
  header("Content-Disposition: attachment; filename=".$title.".url;");
  echo $Shortcut;

备注:页面编码必须为gbk或gb2312