<?php $magic _a = "www.111cn.net34589"; $magic _b = "234566***+"; function Getpincookie ($pin _code) { Global $magic _a; Global $magic _b; $now = time (); $client _ip = $_server[' remote_addr ']; $pin = MD5 ($now. $client _ip. $magic _a. $pin _code. $MAIGC _b). $now; return $pin; } Function Checkpincookie ($pin _code_in, $timeout =300)//5 miniuteswww.111cn.net { global $magic _a; global $magic _b; $pin = substr ($_cookie[' pin '), 0, 32); $time = substr ($_cookie[' pin '), 32); $now = time (); if ($now-$time > $timeout) { return-100; //time_out } $pin _cod e_in = Strtolower ($pin _code_in); $client _ip = $_server[' remote_addr ']; $pin _2 = MD5 ($time. $client _ip. $magic _a. $pin _code_in); if ($pin = = = $pin _2) { return 0; } else { return-200;//Pincode is Error. } } function getpinimg () { $rnd = rand (0, 10); $rnd = 0; $path = "./www.111cn.net/". substr ("00000$rnd",-4); for ($i = 0; $i < 4; + + $i) { if (__getpinimg ($path)) { Break } } Exit } function __getpinimg ($path) { Require ("$path/pinmap.php"); $PINV = $pin [rand (0, $pin _max)]; List ($file, $pin _code) = Explode (' # ', $PINV); $filepath = "$path/$file $pin_ext"; Output pincode image. $fh = fopen ($filepath, "RB"); if (! $fh) { return false; } $data = Fread ($fh, 10240); PHP just read Max size:8k. Fclose ($FH); if (strlen ($DATA) < 200) { return false; } Set cookie; Header ("Content-type:image/jpeg"); $pin _code = strtolower ($pin _code); $pin = Getpincookie ($pin _code); Setcookie ("pin", $pin); Echo $data; return true; } |