```
<?php
// 精準獲取文件的MIME類型
$mime \= array(
'ai' \=> 'application/postscript',
'eps' \=> 'application/postscript',
'exe' \=> 'application/octet-stream',
'doc' \=> 'application/vnd.ms-word',
'xls' \=> 'application/vnd.ms-excel',
'ppt' \=> 'application/vnd.ms-powerpoint',
'pps' \=> 'application/vnd.ms-powerpoint',
'pdf' \=> 'application/pdf',
'xml' \=> 'application/xml',
'odt' \=> 'application/vnd.oasis.opendocument.text',
'swf' \=> 'application/x-shockwave-flash',
// archives
'gz' \=> 'application/x-gzip',
'tgz' \=> 'application/x-gzip',
'bz' \=> 'application/x-bzip2',
'bz2' \=> 'application/x-bzip2',
'tbz' \=> 'application/x-bzip2',
'zip' \=> 'application/zip',
'rar' \=> 'application/x-rar',
'tar' \=> 'application/x-tar',
'7z' \=> 'application/x-7z-compressed',
// texts
'txt' \=> 'text/plain',
'php' \=> 'text/x-php',
'html' \=> 'text/html',
'htm' \=> 'text/html',
'js' \=> 'text/javascript',
'css' \=> 'text/css',
'rtf' \=> 'text/rtf',
'rtfd' \=> 'text/rtfd',
'py' \=> 'text/x-python',
'java' \=> 'text/x-java-source',
'rb' \=> 'text/x-ruby',
'sh' \=> 'text/x-shellscript',
'pl' \=> 'text/x-perl',
'sql' \=> 'text/x-sql',
// images
'bmp' \=> 'image/x-ms-bmp',
'jpg' \=> 'image/jpeg',
'jpeg' \=> 'image/jpeg',
'gif' \=> 'image/gif',
'png' \=> 'image/png',
'tif' \=> 'image/tiff',
'tiff' \=> 'image/tiff',
'tga' \=> 'image/x-targa',
'psd' \=> 'image/vnd.adobe.photoshop',
//audio
'mp3' \=> 'audio/mpeg',
'mid' \=> 'audio/midi',
'ogg' \=> 'audio/ogg',
'mp4a' \=> 'audio/mp4',
'wav' \=> 'audio/wav',
'wma' \=> 'audio/x-ms-wma',
// video
'avi' \=> 'video/x-msvideo',
'dv' \=> 'video/x-dv',
'mp4' \=> 'video/mp4',
'mpeg' \=> 'video/mpeg',
'mpg' \=> 'video/mpeg',
'mov' \=> 'video/quicktime',
'wm' \=> 'video/x-ms-wmv',
'flv' \=> 'video/x-flv',
'mkv' \=> 'video/x-matroska'
);
function \_getMimeDetect() {
if (class\_exists('finfo')) {
return 'finfo';
} else if (function\_exists('mime\_content\_type')) {
return 'mime\_content\_type';
} else if ( function\_exists('exec')) {
$result \= exec('file -ib '.escapeshellarg(\_\_FILE\_\_));
if ( 0 \=== strpos($result, 'text/x-php') OR 0 \=== strpos($result, 'text/x-c++')) {
return 'linux';
}
$result \= exec('file -Ib '.escapeshellarg(\_\_FILE\_\_));
if ( 0 \=== strpos($result, 'text/x-php') OR 0 \=== strpos($result, 'text/x-c++')) {
return 'bsd';
}
}
return 'internal';
}
function \_getMimeType($path) {
$fmime \= \_getMimeDetect();
switch($fmime) {
case 'finfo':
$finfo \= finfo\_open(FILEINFO\_MIME);
if ($finfo)
$type \= @finfo\_file($finfo, $path);
break;
case 'mime\_content\_type':
$type \= mime\_content\_type($path);
break;
case 'linux':
$type \= exec('file -ib '.escapeshellarg($path));
break;
case 'bsd':
$type \= exec('file -Ib '.escapeshellarg($path));
break;
default:
$pinfo \= pathinfo($path);
$ext \= isset($pinfo\['extension'\]) ? strtolower($pinfo\['extension'\]) : '';
$type \= isset($this\->mime\[$ext\]) ? $this\->mime\[$ext\] : 'unkown';
break;
}
$type \= explode(';', $type);
//需要加上這段,因為如果使用mime\_content\_type函數來獲取一個不存在的$path時會返回'application/octet-stream'
if ($fmime != 'internal' AND $type\[0\] \== 'application/octet-stream') {
$pinfo \= pathinfo($path);
$ext \= isset($pinfo\['extension'\]) ? strtolower($pinfo\['extension'\]) : '';
if (!empty($ext) AND !empty($this\->mime\[$ext\])) {
$type\[0\] \= $this\->mime\[$ext\];
}
}
return $type\[0\];
}
```
- PHP收集
- 1、精準獲取文件的MIME類型
- 2、獲取指定內容的第一張圖片做封面
- 3、生成二維碼
- 4、HTTP請求(請求微信token有用)
- 5、SQL的安裝與卸載、執行
- 6、stdclass 對象轉數組
- 7、php調用restfull API
- 8、二維數據排序
- 9、多維數組合并
- 10、API簽名與驗證
- 11、刪除一維數據指定key或者允許
- 12、字符串替換、截取
- 13、返回帶數據與狀態與狀態語的json函數封裝
- 14、EXCEL上傳下載封裝
- 15、循環刪除指定目錄下的文件與文件夾、創建指定文件夾
- 16、強制把日期或者時間戳轉星期幾
- 17、檢測字符串是否包含某字符串
- 18、獲取中文字符拼音首字母
- 19、判斷手機、郵箱格式正確否、隱藏手機號碼
- 20、TP5把圖片、視頻、文件上傳封裝
- 21、生成商品編號/貨號/訂單號/小票號
- 22、高精度數值添加
- 23、加解密字符串、可逆加解密
- 24、編輯器圖片上傳驗證
- 25、轉義單引號
- 26、字符串去重
- 27、Base64加解密
- 28、將空內容設置為特定內容
- 29、判斷訪問來源
- 30、將字符串轉換為時間戳,解決部分服務器時間不能超過2038的問題
- 31、駝峰命名轉下劃線命名
- 32、寫入日志 (使用tp自帶驅動記錄到runtime目錄中
- 33、隱藏敏感字符、隱藏部分字符
- 34、獲取全局唯一標識符、生成隨機數
- 35、過濾emoji表情
- 36、無限分類 數組轉 樹形結構
- 37、遞歸生成分類欄目結構
- 38、判斷是否是json字符串
- 39、計算時間差(優化友好時間體驗)、格式化月份
- 40、生成縮略圖
- 41、敏感詞過濾
- 42、獲取當前類方法
- 43、取文件目錄列表,該方法返回數組
- 44、防XSS注入、SQL盲注入
- JS收集
- 1、獲取圖片真實寬高
- 2、禁用F12與鼠標右鍵事件
- 3、安卓播放視頻結束出現廣告
- 4、TP手機端分頁封裝
- 5、flex布局,多行最后一行向左排列
- 6、判斷移動終端內核
- 7、判斷IE瀏覽器內核
- 8、設置主頁與加入收藏
- 9、解決H5微信轉發分享特殊符號處理
- CSS收集
- 1、移動IOS的按鈕默認樣式去除
- 2、超出行數隱藏顯示縮略號
- 3、清除浮動
- 4、背景圖透明度兼容
- HTML收集
- 1、列表視頻
- 小程序
- 1、請求封裝
- 2、插件收集
- 問題記錄集