Skip to content

Instantly share code, notes, and snippets.

View Jason-cqtan's full-sized avatar
🎯
Focusing

niL Jason-cqtan

🎯
Focusing
View GitHub Profile
@Jason-cqtan
Jason-cqtan / dabblet.css
Created June 27, 2018 10:09
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
div{
padding: 6px 16px;
border: 1px solid #446d88;
background: #58a linear-gradient(#77a0bb, #58a); border-radius: 4px;
box-shadow: 0 1px 5px gray;
color: white;
text-shadow: 0 -1px 1px #335166;

Keybase proof

I hereby claim:

  • I am acheng93 on github.
  • I am 93jc (https://keybase.io/93jc) on keybase.
  • I have a public key ASDvAC2QO5kABTe4RWFde3iC95vFltaN386dBaqBUbJgeQo

To claim this, I am signing this object:

<?php
function RemoveXSS($val) {
// remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed
// this prevents some character re-spacing such as <java\0script>
// note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs
$val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val);
// straight replacements, the user should never need these since they're normal characters
// this prevents like <IMG SRC=@avascript:alert('XSS')>
$search = 'abcdefghijklmnopqrstuvwxyz';
@Jason-cqtan
Jason-cqtan / timestamp_beautiful.php
Created March 13, 2019 06:15
时间戳转换成“刚刚”,“5分钟前”,“3小时前”等
<?php
date_default_timezone_set('PRC');
/**
* [时间戳转换成“刚刚”,“5分钟前”,“3小时前”等]
* @param [string] $time [时间戳]
* @return [string]
*/
function transfer_time($time)
@Jason-cqtan
Jason-cqtan / get_remote_filesize.php
Last active March 13, 2019 06:46
获取远程图片大小
<?php
/**
* 思路:先CURL获取图片到缓冲区,然后正则获取图片的Content-Length信息
* [获取远程图片大小]
* @param [string] $uri [远程图片地址]
* @param string $user [网页授权用户名]
* @param string $pw [网页授权密码]
* @return [string]
*/
function remote_filesize($uri,$user='',$pw='')
@Jason-cqtan
Jason-cqtan / sortArrByManyField.php
Created March 13, 2019 08:49
二维数组多字段排序
<?php
$array1 = array(
0=>array('id'=>8,'name'=>'Apple','age'=> 18),
1=>array('id'=>8,'name'=>'Bed','age'=>17),
2=>array('id'=>5,'name'=>'Cos','age'=>16),
3=>array('id'=>5,'name'=>'Cos','age'=>14)
);
function sortArrByManyField(){
$args = func_get_args();
if(empty($args)){
@Jason-cqtan
Jason-cqtan / getrealip.php
Created March 13, 2019 09:13
获取客户端真实ip地址
<?php
function GetIP(){
if (getenv("HTTP_CLIENT_IP")
&& strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
$ip = getenv("HTTP_CLIENT_IP");
else if (getenv("HTTP_X_FORWARDED_FOR")
&& strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if (getenv("REMOTE_ADDR")
&& strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
@Jason-cqtan
Jason-cqtan / readLargeContent.php
Created March 14, 2019 07:00
读取大文件局部内容
<?php
//方法一、使用linux命令
file = 'access.log';
$file = escapeshellarg($file); // 对命令行参数进行安全转义
$line = `tail -n 1 $file`;
echo $line;
//方法二、使用php的fseek
//第一种:首先通过fseek找到文件的最后一位EOF,然后找最后一行的起始位置,取这一行的数据,再找次一行的起始位置,再取这一行的位置,依次类推,直到找到了$num行。
function tail($fp,$n,$base=5)
@Jason-cqtan
Jason-cqtan / makeRandStr.php
Created March 14, 2019 08:07
生成随机字符串,类似“CuOi3OQNt”
<?php
//方法一
$password_length = 8;
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
@Jason-cqtan
Jason-cqtan / verification_code.php
Created March 14, 2019 08:40
简单的验证码类
<?php
session_start();
Header("Content-type: image/gif");
class SecurityCode
{
private $codes = '';
function __construct()
{