PHP判断系统为windows还是linux

函数php_uname()返回所运行的系统信息。php_uname([string $mode]);
$mode可选参数:
'a': 返回所有信息
's': 操作系统的名称,如FreeBSD
'n': 主机的名称,如cnscn.org
'r': 版本名,如5.1.2-RELEASE
'v': 操作系统的版本号
'm': 核心类型,如i386

echo strtoupper(substr(PHP_OS,0,3))==='WIN'?'windows 服务器':'不是 widnows 服务器';
echo DIRECTORY_SEPARATOR=='\\'?'windows 服务器':'不是 widnows 服务器'; //根据分隔符判断
echo PATH_SEPARATOR==';'?'windows 服务器':'不是 widnows 服务器'; //根据PATH分割符判断

linux利用LibreOffice & unoconv 实现word转pdf

libreoffice官网:http://www.libreoffice.org/

wget下载LINUX对应32/64位rpm包
32位 http://ftp.kaist.ac.kr/tdf/libreoffice/stable/5.4.0/rpm/x86/LibreOffice_5.4.0_Linux_x86_rpm.tar.gz
64位 http://ftp.kaist.ac.kr/tdf/libreoffice/stable/5.4.0/rpm/x86_64/LibreOffice_5.4.0_Linux_x86-64_rpm.tar.gz

arm下载:https://www.oracle.com/database/technologies/instant-client/linux-arm-aarch64-downloads.html

- 阅读剩余部分 -

password_hash密码哈希与安全

支持PHP5.5+
项目中大部分加密基于MD5+SALT,事实上password_hash()已经帮我们处理好了加盐。加进去的随机子串通过加密算法自动保存着,成为哈希的一部分。password_verify()会把随机子串从中提取,所以你不必使用另一个数据库来记录这些随机子串,大大简化了计算密码哈希值和验证密码的操作。

- 阅读剩余部分 -

JavaScript手机振动API vibrate

判断浏览器对振动API的支持情况
var supportsVibrate = "vibrate" in navigator;
在window.navigator对象里就只有一个关于振动的API:vibrate。

navigator.vibrate函数可以接受一个数字参数,也可以接受一个数字数组,当使用数组参数时,奇数位的数值是震动秒数,偶数位为等待秒数。

// 振动1秒
navigator.vibrate(1000);

// 振动多次
// 参数分别是震动3秒,等待2秒,然后振动1秒
navigator.vibrate([3000, 2000, 1000]);
如果想停止震动,你只需要向navigator.vibrate方法里传入0,或一个空数组:

// 停止振动
navigator.vibrate(0);
navigator.vibrate([]);

对navigator.vibrate方法的调用并不会引起手机循环振动;当参数是一个数字时,振动之后发生一次,然后就停止下来。当参数是数组时,震动会按数组里的值震动,然后就停止振动。

持续震动

我们可以简单的使用setInterval 和 clearInterval 方法产生让手机持续震动的效果:

var vibrateInterval;

// Starts vibration at passed in level
function startVibrate(duration) {
    navigator.vibrate(duration);
}

// Stops vibration
function stopVibrate() {
    // Clear interval and stop persistent vibrating 
    if(vibrateInterval) clearInterval(vibrateInterval);
    navigator.vibrate(0);
}

// Start persistent vibration at given duration and interval
// Assumes a number value is given
function startPeristentVibrate(duration, interval) {
    vibrateInterval = setInterval(function() {
        startVibrate(duration);
    }, interval);
}

修改WampServer的默认80端口

修改httpd.conf文件中Listen 81ServerName localhost:81
重启wamp,就可以生效了。但是LocalhostphpMyAdmin依旧是默认的80端口。找到wamp安装目录下的wampmanager.tpl文件修改:

Type: item; Caption: "${w_localhost}"; Action: run; FileName: "${c_navigator}"; Parameters: "http://localhost:81/"; Glyph: 5
;WAMPPROJECTSUBMENU

Type: item; Caption: "${w_phpmyadmin}"; Action: run; FileName: "${c_navigator}"; Parameters: "http://localhost:81/phpmyadmin/"; Glyph: 5