PHP、golang 如何播放mp4文件

php的处理过程

<?php
function PutMovie(file) {
    header("Content-type: video/mp4");
    header("Accept-Ranges: bytes");size = filesize(file);
    if(isset(_SERVER['HTTP_RANGE'])){
        header("HTTP/1.1 206 Partial Content");
        list(name,range) = explode("=", _SERVER['HTTP_RANGE']);
        list(begin, end) =explode("-",range);
        if(end == 0)end = size - 1;
    }
    else {begin = 0; end =size - 1;
    }
    header("Content-Length: " . (end -begin + 1));
    header("Content-Disposition: filename=".basename(file));
    header("Content-Range: bytes ".begin."-".end."/".size);
 
    fp = fopen(file, 'rb');
    fseek(fp,begin);
    while(!feof(fp)) {p = min(1024, end -begin + 1);
        begin +=p;
        echo fread(fp,p);
    }
    fclose($fp);
}
PutMovie("1.mp4");

golang的处理过程

http.ServeFile(w, r, "/webserver/1.mp4")

 

nextcloud 的 occweb 插件0.0.4版本安装报错处理方法(PHP5.6)

直接从app store安装后的occweb插件启用后直接报错500,很郁闷啊。查来查去,发现日志:

[Wed Apr 24 14:15:09.841662 2019] [:error] [pid 5756] [client 192.168.50.199:6489] PHP Parse error:  syntax error, unexpected 'list' (T_LIST), expecting identifier (T_STRING) in /unas/apps/nextcloud/web/apps/occweb/lib/Controller/OccController.php on line 88

于是乎,说明了list得重新命名。

找到apps/occweb/appinfo/routes.php

修改为

return [
    'routes' => [
     ['name' => 'occ#index', 'url' => '/', 'verb' => 'GET'],
     ['name' => 'occ#cmd', 'url' => '/cmd', 'verb' => 'POST'],
     ['name' => 'occ#list2', 'url' => '/cmd', 'verb' => 'GET'], //此处将occ#list修改为occ#list2
    ]
];

然后找到 apps/occweb/lib/Controller/OccController.php

修改其88行代码

public function list(){

public function list2(){

然后安装composer(具体安装方法此处不再浪费版面述说,百度一大堆),之后建议:

sudo mv composer.pha /usr/bin/composer 
sudo chmod +x /usr/bin/composer

然后就是make了

sudo -u www-data make

当然,此处www-data为我的php用户,是否用root请自己酌情参考,我用的php账号

最后,插件就不会报错500了。

 

sublime text3 3176激活

记录一下激活码,也方便自己以后查找
更改hosts:sudo vim /private/etc/hosts

127.0.0.1       www.sublimetext.com
127.0.0.1       license.sublimehq.com

激活码:

----- BEGIN LICENSE -----
sgbteam
Single User License
EA7E-1153259
8891CBB9 F1513E4F 1A3405C1 A865D53F
115F202E 7B91AB2D 0D2A40ED 352B269B
76E84F0B CD69BFC7 59F2DFEF E267328F
215652A3 E88F9D8F 4C38E3BA 5B2DAAE4
969624E7 DC9CD4D5 717FB40C 1B9738CF
20B3C4F1 E917B5B3 87C38D9C ACCE7DD8
5F7EF854 86B9743C FADC04AA FB0DA5C0
F913BE58 42FEA319 F954EFDD AE881E0B
------ END LICENSE ------

 

macOS 中使用 phpize 动态添加 PHP 扩展的错误解决方法

问题一:

执行 phpize 报错如下:

$ phpize 
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:

浏览全部

新浪短链接 生成 api

新浪短网址接口的稳定性和跳转速度还是很给力的,现给出其API说明。
该接口支持两种返回格式:xml和json
对应的URL请求地址为:

xml:http://api.t.sina.com.cn/short_url/shorten.xml
json:http://api.t.sina.com.cn/short_url/shorten.json

请求方式:GET
请求参数:
source:应用的appkey
url_long:需要转换的长链接

浏览全部

利用phantomjs模拟QQ自动登录

PhantomJS is a headless WebKit scriptable with a JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

开搞,代码实现如下。

var page = require('webpage').create();
var fs = require("fs");
page.settings.userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4';
page.open('http://ui.ptlogin2.qq.com/cgi-bin/login?pt_no_onekey=1&style=9&appid=1006102&s_url=http%3A%2F%2Fxiaoqu.qq.com%2Fmobile%2Fbarindex.html%3F_lv%3D29313%26_bid%3D128%26_wv%3D1027%26from%3Dshare_link%23bid%3D37469%26type%3D%26source%3Dindex%26scene%3Drecent%26from%3Ddongtai%26webview%3D1&low_login=0&hln_css=http%3A%2F%2Fpub.idqqimg.com%2Fqqun%2Fxiaoqu%2Fmobile%2Fimg%2Fnopack%2Flogin-logo.png', function(status){
    if (status == 'success') {
        page.render('index.png');
        setTimeout(function() {
            page.evaluate(function() {
                document.getElementById('u').value = 'QQ号码';
                document.getElementById('p').value = 'QQ密码';
                pt.check(false);
                //document.getElementById('go').click(); //pt.check()或.click()
            });
            setTimeout(function() {
                file = fs.open("cookie.log", 'w');
                file.write(JSON.stringify(page.cookies));
                file.close();
                phantom.exit();
            }, 2000);
        }, 1000);
    }
});

cookie会写入到当前目录下的cookie.log文件,有了cookie接下来的事情就简单多了。使用php或js将cookie种到浏览器下即可。

浏览全部