This file contains hidden or 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 autoload($className) | |
| { | |
| $className = ltrim($className, '\\'); | |
| $fileName = ''; | |
| $namespace = ''; | |
| if ($lastNsPos = strrpos($className, '\\')) { | |
| $namespace = substr($className, 0, $lastNsPos); | |
| $className = substr($className, $lastNsPos + 1); |
This file contains hidden or 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 PassHash { | |
| // blowfish | |
| private static $algo = '$2a'; | |
| // cost parameter | |
| private static $cost = '$10'; | |
| // mainly for internal use | |
| public static function unique_salt() { |
This file contains hidden or 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 Demo | |
| { | |
| /** | |
| * @var string | |
| */ | |
| public static $ACCESS_KEY = 'KUN6xYZlOAtid2MjHm90-6VFY2M7HC90ijDH4uOR'; | |
| /** | |
| * @var string |
This file contains hidden or 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 | |
| $perror = function($msg){ | |
| $errorCode = socket_last_error(); | |
| $errorMsg = socket_strerror($errorCode); | |
| exit("$msg: [$errorCode] $errorMsg\r\n"); | |
| }; | |
| if(!$socket = socket_create(AF_INET, SOCK_STREAM, 0)){ | |
| $perror('could not create scoket'); |
This file contains hidden or 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 | |
| $data = array('name' => 'zhangsan'); | |
| $post_data = http_build_query($data); | |
| $http = "POST /site/test HTTP/1.1\r\n"; | |
| $http .= "Host: example.com\r\n"; | |
| $http .= "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n"; | |
| $http .= "Content-Type: application/x-www-form-urlencoded\r\n"; | |
| $http .= "Content-length: " . strlen($post_data) . "\r\n"; | |
| $http .= "Connection: close\r\n\r\n"; |
This file contains hidden or 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 | |
| $options = array( | |
| 'http' => array( | |
| 'method' => "POST", | |
| 'header' => | |
| "Accept-language: en\r\n" . | |
| "Content-type: application/x-www-form-urlencoded\r\n", | |
| 'content' => http_build_query(array('name' => 'zhangsan')) | |
| )); |
This file contains hidden or 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 getImg($url) | |
| { | |
| $data = parse_url($url); | |
| $referer = $data['scheme'] . '://' . $data['host']; | |
| $options = array( | |
| 'http' => array( | |
| 'method' => 'GET', | |
| 'header' => "Referer:{$referer}\r\nCache-Control: max-age=3600\r\n", | |
| 'timeout'=> 1, | |
| ) |
This file contains hidden or 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 | |
| /** | |
| * Aspect | |
| * @source http://www.jaceju.net/blog/archives/327/ | |
| * | |
| */ | |
| class Aspect | |
| { | |
| /** | |
| * Name of target class |
This file contains hidden or 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 | |
| do{ | |
| $retry = false; | |
| $try_num = 1; | |
| try{ | |
| $db->exec('UPDATE table num = num + 1 where id = 1;'); | |
| } catch (Exception $e) { | |
| if($e->getMessage() == 'error message' && $try_num < 10) { |
This file contains hidden or 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 | |
| set_time_limit(0); | |
| //省份id | |
| $id = isset($_GET['id']) ? intval($_GET['id']) : 33; | |
| //市 | |
| $url = "http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2013/{$id}.html"; | |
| $province = pathinfo($url, PATHINFO_FILENAME); |
OlderNewer