This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 整数hash | |
function intHash($key) | |
{ | |
$md5 = substr(md5($key), 0, 8); | |
$seed = 31; | |
$hash = 0; | |
for ($i = 0;$i < 8; ++$i) { | |
$hash = $hash * $seed + ord(md5($i)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function T($time) { | |
//获取今天凌晨的时间戳 | |
$day = strtotime(date('Y-m-d',time())); | |
//获取昨天凌晨的时间戳 | |
$pday = strtotime(date('Y-m-d',strtotime('-1 day'))); | |
//获取现在的时间戳 | |
$nowtime = time(); | |
$tc = $nowtime-$time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public static function is_mobile() { | |
//正则表达式,批配不同手机浏览器UA关键词。 | |
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"; | |
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"; | |
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"; | |
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"; | |
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"; | |
$regex_match.=")/i"; | |
return isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT'])); //如果UA中存在上面的关键词则返回真。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//指定数组以$keys键值排序 | |
function array_sort($array,$keys,$type='asc'){ | |
//$array为要排序的数组,$keys为要用来排序的键名,$type默认为升序排序 | |
$keysvalue = $new_array = array(); | |
foreach ($array as $k=>$v){ | |
$keysvalue[$k] = $v[$keys]; | |
} | |
if($type == 'asc'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://h.bilibili.com/api/pushS'; | |
$data = array('act' => 'getHidInfo', 'key2' => 'value2'); | |
// use key 'http' even if you send the request to https://... | |
$options = array( | |
'http' => array( | |
'header' => "Content-type: application/x-www-form-urlencoded\r\n", | |
'method' => 'POST', | |
'content' => http_build_query($data), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysqld] | |
basedir=/usr/local/Cellar/mysql/5.6.24 | |
pid-file=/usr/local/var/mysql/flowerainsdeMacBook-Pro.local.pid | |
datadir=/usr/local/var/mysql | |
plugin-dir=/usr/local/Cellar/mysql/5.6.24/lib/plugin | |
port=3306 | |
socket= /usr/local/var/mysql/mysql.pid | |
#server_id = <ALEXMYSQL> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nowAlid, //现在类型 | |
pageSize = 50, //默认每页数量 | |
nowPage = 1, //当前页数 | |
pagiWidth = 5; //最大页数宽度 | |
function pageList(result){ | |
var pageDiv = $("#paginationDiv"); | |
var __GetPageList = function(result, pageDiv) { | |
var total_page = result.totalPage; | |
var now_page = result.page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//随机生成一个4位数的数字验证码 | |
session_start(); | |
$num=""; | |
$num=mt_rand(1000,9999); | |
//4位验证码也可以用rand(1000,9999)直接生成 | |
//将生成的验证码写入session,备验证页面使用 | |
$_SESSION["Checknum"] = $num; | |
//创建图片,定义颜色值 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (get_magic_quotes_gpc()) { | |
$_GET = array_map('stripslashes', $_GET); | |
$_POST = array_map('stripslashes', $_POST); | |
} | |
array_map('trim',explode("\n",$a)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(g) { | |
'use strict'; | |
var _console = g.console || {}; | |
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'exception', 'error', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn']; | |
var console = {version: '0.1.0'}; | |
var key; | |
for(var i = 0, len = methods.length; i < len; i++) { | |
key = methods[i]; | |
console[key] = function (key) { |
NewerOlder