Exemplo n.º 1
0
 /**
  * 验证用户信息并种cookie
  * @param $access_token
  */
 private function _user_login($access_token)
 {
     if (empty($access_token)) {
         $this->_apf->get_response()->redirect('/');
         exit;
     }
     $data = array("oauth_token" => $access_token, "getinfo" => true);
     $oauth = $this->_apf->get_config('oauth2');
     $curlObj = new APF_Http_Client_Curl('post');
     $curlObj->set_url($oauth['oauth_login_url']);
     $curlObj->set_attribute(CURLOPT_POST, TRUE);
     $curlObj->set_attribute(CURLOPT_POSTFIELDS, $data);
     //不需要验证CURL证书
     $curlObj->set_attribute(CURLOPT_SSL_VERIFYPEER, false);
     $curlObj->set_attribute(CURLOPT_SSL_VERIFYHOST, false);
     if ($curlObj->execute()) {
         $user_info = $curlObj->get_response_text();
         if (empty($user_info)) {
             $this->_check_error();
             exit;
         }
         $cookie_cfg = $this->_apf->get_config('cookie');
         $cookie_value = Util_AuthorCrypt::encrypt($user_info, $cookie_cfg['key']);
         $this->_apf->get_response()->set_cookie($cookie_cfg['name'], $cookie_value, time() + $cookie_cfg['expires'], $cookie_cfg['path'], $cookie_cfg['domain']);
         $this->_apf->get_response()->redirect('/');
         exit;
     } else {
         $this->_check_error();
         exit;
     }
 }
Exemplo n.º 2
0
 public function handle_request()
 {
     $params = APF::get_instance()->get_request()->get_parameters();
     $cookiename = @$params['cn'];
     $x_size = $params['x'];
     $y_size = $params['y'];
     $num_size = $params['s'];
     //添加字符数量
     $font_num = isset($params['n']) ? $params['n'] : 4;
     $x1 = $params['x1'];
     $y1 = $params['y1'];
     $x2 = $params['x2'];
     $y2 = $params['y2'];
     $seccode = $this->random($font_num, 1);
     $md5seccode = Util_AuthorCrypt::encrypt($seccode, md5($_SERVER['HTTP_USER_AGENT']));
     //		if('askquestionreg'==$cookiename){
     //			$objMem=APF_Cache_Factory::get_instance()->get_memcache();
     //			$strGUID=APF::get_instance()->get_request()->get_cookie('aQQ_ajkguid');
     //			$objMem->set('askquestionreg_'.$strGUID,$md5seccode,0,90);
     //		}
     APF::get_instance()->get_response()->set_cookie($cookiename, $md5seccode, 30 * 60);
     header("Content-type: image/png");
     $im = imagecreatetruecolor($x_size, $y_size);
     $white = imagecolorallocate($im, 255, 255, 255);
     $grey = imagecolorallocate($im, 128, 128, 128);
     $black = imagecolorallocate($im, 0, 0, 0);
     imagefilledrectangle($im, 0, 0, $x_size, $y_size, $white);
     $font = APF::get_instance()->get_config("FontsUrl");
     //var_dump($font);exit;
     imagettftext($im, $num_size, 2, $x1, $y1, $grey, $font, $seccode);
     imagettftext($im, $num_size, 2, $x2, $y2, $black, $font, $seccode);
     for ($i = 0; $i < 600; $i++) {
         $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($im, rand() % $x_size, rand() % $y_size, $randcolor);
     }
     imagepng($im);
     imagedestroy($im);
     return false;
 }
Exemplo n.º 3
0
 private function get_cookie_val($uid, $username, $iBugsecques, $cookie_time)
 {
     $browser = $_SERVER['HTTP_USER_AGENT'];
     $tmp = Util_AuthorCrypt::encrypt("{$uid}\t{$username}\t{$cookie_time}", md5($browser . $iBugsecques));
     return $tmp;
 }