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 is_utf8($str) { | |
$temp_str = @iconv('utf-8', 'utf-8', $str); | |
if ($str === $temp_str) { | |
return 'utf8'; | |
} else { | |
return 'gbk'; | |
} |
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 | |
$auto = 1; | |
checkdir('D:\path\path'); | |
function checkdir($basedir) { | |
if ($dh = opendir($basedir)) { | |
while (($file = readdir($dh)) !== false) { | |
if($file{0} == '.') { | |
continue; | |
} |
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 authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { | |
$ckey_length = 4; | |
$key = md5($key); | |
$keya = md5(substr($key, 0, 16)); | |
$keyb = md5(substr($key, 16, 16)); | |
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; |
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 | |
/* | |
* Return path folders and files | |
* @param string $path Input path | |
* @param showFolder $path is show folder | |
* @param pattern $path glob function's pattern | |
* @return array | |
*/ | |
function fileTree($path, $showFolder = false, $pattern = '*'){ |
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 | |
/* | |
* Curl 多线程类 | |
* 使用方法: | |
* ======================== | |
$urls = array("http://baidu.com", "http://dzone.com", "http://google.com"); | |
$mp = new MultiHttpRequest($urls); | |
$mp->start(); | |
* ======================== | |
* 当然,如果你喜欢,还可以对此类进行扩展, |
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
/* | |
| @param char|int $start_date 一个有效的日期格式,例如:20091016,2009-10-16 | |
| @param char|int $end_date 同上 | |
| @return 给定日期之间的周末天数 | |
*/ | |
function get_weekend_days($start_date,$end_date){ | |
if (strtotime($start_date) > strtotime($end_date)) list($start_date, $end_date) = array($end_date, $start_date); | |
$start_reduce = $end_add = 0; |
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
/** | |
* 获取该条记录的自增ID | |
* 将自增转换为62进制,并拼接网址 如:http://qetee.com/w7e | |
* 用户访问到 http://qetee.com/w7e 时,提取短网址后缀 w7e | |
* 将短网址后缀转换为10进制,得到自增ID号 如:123456 | |
* 使用查询该记录,进行业务逻辑处理(比如跳转) | |
*/ | |
/** | |
* 十进制数转换成62进制 |
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 | |
header('Content-Type: text/plain;charset=utf-8'); | |
$data = 'phpbest'; | |
$key = 'oScGU3fj8m/tDCyvsbEhwI91M1FcwvQqWuFpPoDHlFk='; //echo base64_encode(openssl_random_pseudo_bytes(32)); | |
$iv = 'w2wJCnctEG09danPPI7SxQ=='; //echo base64_encode(openssl_random_pseudo_bytes(16)); | |
echo '内容: '.$data."\n"; | |
$encrypted = openssl_encrypt($data, 'aes-256-cbc', base64_decode($key), OPENSSL_RAW_DATA, base64_decode($iv)); | |
echo '加密: '.base64_encode($encrypted)."\n"; |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"net/http" | |
"os" | |
"os/exec" | |
"path/filepath" | |
) |
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 isDecimal(strValue ) { | |
var objRegExp= /^\d+\.\d+$/; | |
return objRegExp.test(strValue); | |
} | |
/*校验是否中文名称组成 */ | |
function ischina(str) { | |
var reg=/^[\u4E00-\u9FA5]{2,4}$/; /*定义验证表达式*/ | |
return reg.test(str); /*进行验证*/ |
OlderNewer