コード例 #1
0
ファイル: Abstract.php プロジェクト: hongbo819/LJL
 /**
  * 父类的Validate
  */
 public function baseValidate(LJL_Request $input, LJL_Response $output)
 {
     //获取静态文件路径
     $output->_SFP = LJL_Config::get(APP_NAME . "_App", 'staticPath');
     //不是爬虫
     if (!LJL_Http::isRobot()) {
         //防止恶意刷新
         if ($input->cookie('whatareyou')) {
             echo 'what are you 弄啥嘞! ……robot-like';
             die;
         }
         if ($input->cookie('emithsulf') || setcookie('emithsulf', API_Item_Security_Algos::fastEncode(array('value' => 1)), SYSTEM_TIME + 3, '/')) {
             if (API_Item_Security_Algos::fastDecode(array('value' => $input->cookie('emithsulf'))) > 10) {
                 setcookie('whatareyou', 'ekil-tobor', SYSTEM_TIME + 120, '/');
             }
             $nowNum = API_Item_Security_Algos::fastDecode(array('value' => $input->cookie('emithsulf'))) + 1;
             setcookie('emithsulf', API_Item_Security_Algos::fastEncode(array('value' => $nowNum)), SYSTEM_TIME + 3, '/');
         }
     }
     //登录验证
     // 	    if($input->cookie('blog_ckid') && $input->cookie('blog_username')) {
     // 	        if(false === Blog_Plugin_Common::loginAuth($input->cookie('blog_ckid'), $input->cookie('blog_username'))) {
     // 	            echo '非法。。。登录。。。';die();
     // 	        }
     // 	    }
     return true;
 }
コード例 #2
0
ファイル: Captcha.php プロジェクト: hongbo819/APILJL
 /**
  * 显示验证码
  */
 public static function showImage($paramArr)
 {
     $options = array('token' => 0, 'numCnt' => 4, 'width' => 100, 'height' => 40, 'type' => 1, 'plex' => 5);
     if (is_array($paramArr)) {
         $options = array_merge($options, $paramArr);
     }
     extract($options);
     if (!$token && LJL_Api::$_globalVars['_COOKIE'] && isset(LJL_Api::$_globalVars['_COOKIE']["ip_ck"])) {
         $token = LJL_Api::$_globalVars['_COOKIE']["ip_ck"];
     }
     if (!$token) {
         #不返回了,直接生成 ip_ck cookie 值
         $token = API_Item_Base_Page::createIpCk(array('setCookie' => 1));
         //            return false;
     }
     #获得唯一的用户码
     $uniqCode = API_Item_Security_Algos::getUniqueCode();
     $text = self::getAuthCode($uniqCode, $numCnt);
     #将数据数据到Redis
     $redis = API_Redis::getLink(self::$server);
     #获得redis对象
     $key = self::$keyPre . $token;
     $redis->setex($key, 3600, $text);
     //最长1小时的缓存周期
     #输出图片
     $param = array('token' => $token, 'width' => $width, 'height' => $height, 'numCnt' => $numCnt, 'text' => $text);
     switch ($type) {
         case 2:
             self::getCodeColorImage($param);
             #黑白
             break;
         case 3:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/GifCode.php";
             getGifCode($param);
             break;
         case 4:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/GgCode.php";
             getAuthImage($param);
             break;
         case 5:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/code_math.php";
             $param['redis'] = $redis;
             $param['key'] = $key;
             getMathCode($param);
             break;
         case 6:
             require_once LJL_API_ROOT . "/Item/Security/Captchas/CaptchaBuilderInterface.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/PhraseBuilderInterface.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/CaptchaBuilder.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/PhraseBuilder.php";
             require_once LJL_API_ROOT . "/Item/Security/Captchas/captchaBuilderFunc.php";
             $param['plex'] = $plex;
             getCaptchaBuilder($param);
             break;
         case 1:
         default:
             self::getCodeSimpleImage($param);
             #彩色
             break;
     }
     exit;
 }