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 | |
/************************************************* | |
* | |
* Snoopy - the PHP net client | |
* Author: Monte Ohrt <monte@ohrt.com> | |
* Copyright (c): 1999-2014, all rights reserved | |
* Version: 2.0.0 | |
* This library is free software; you can redistribute it and/or | |
* modify it under the terms of the GNU Lesser General Public |
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
#!/bin/bash | |
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin | |
export PATH | |
clear; | |
echo '================================================================'; | |
echo ' [LNMP/Nginx] Amysql Host - AMH 4.2 '; | |
echo ' http://Amysql.com'; | |
echo '================================================================'; |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 | |
/** | |
* author : forecho <caizhenghai@gmail.com> | |
* createTime : 2015/6/10 10:27 | |
* description: | |
*/ | |
class Security | |
{ | |
/** |
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 | |
$files = glob('200_*.jpg'); | |
array_walk($files, function ($file) { | |
unlink($file); | |
}); |
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 | |
/** | |
* author : forecho <caizhenghai@gmail.com> | |
* createTime : 2015/7/9 16:32 | |
* description: | |
*/ | |
if (!isset($_GET['auth']) || $_GET['auth'] != "forecho") { | |
die(); | |
} |
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 | |
class UploadController extends ActiveController | |
{ | |
public $documentPath = 'documents/'; | |
public function verbs() | |
{ | |
$verbs = parent::verbs(); | |
$verbs[ "upload" ] = ['POST' ]; |
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 int $rows 数据池 | |
* @return mixed | |
*/ | |
protected function random($rows = 100) | |
{ | |
$count = User::find()->select(['itemid'])->where([])->count(); | |
$random = mt_rand($rows, $count - $rows); | |
$model = User::find()->where(['>=', 'id', $random])->joinWith(['type'])->limit($rows)->all(); |
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 | |
$array=array(1,2,3,4,5); | |
echo $array[count($array)-1];//计算数组长度,然后获取数组最后一个元素,如果数组中最后一个元素含有非数字键名,结果可能跟预期不符合 | |
//适用于键名为数字的数组 | |
echo '<br>'; | |
echo end($array);//将数组的内部指针指向最后一个单元,适用于所有数组 | |
echo '<br>'; | |
rsort($array);//对数组逆向排序,如果数组中含有字母或汉字,结果可能不符合预期,最适用于数字数组 | |
echo $array[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
<?php | |
function httpClient($url, $data = FALSE, $header = FALSE, $timeout = 30) | |
{ | |
if (!strstr($url, 'http://') && !strstr($url, 'https://')) { | |
$url = 'http://' . $url; | |
} | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $url); |
OlderNewer