更新三江源子平台中的curl和accountcontroller中的功能
This commit is contained in:
parent
603dfd8781
commit
2a37cec905
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
use Helpers\View;
|
||||
use Users\Member;
|
||||
use Users\Account;
|
||||
|
||||
class AccountController extends Zend_Controller_Action
|
||||
{
|
||||
function preDispatch()
|
||||
|
@ -285,7 +289,6 @@ class AccountController extends Zend_Controller_Action
|
|||
|
||||
function loginAction()
|
||||
{
|
||||
include_once("helper/view.php");
|
||||
|
||||
$success=false;
|
||||
|
||||
|
@ -319,75 +322,30 @@ class AccountController extends Zend_Controller_Action
|
|||
$this->view->href = $tohref;
|
||||
}
|
||||
|
||||
$captcha = $this->loadCaptcha();
|
||||
//登录表单提交
|
||||
|
||||
$submit = $this->_getParam("submit");
|
||||
if(!empty($submit))
|
||||
if(!$submit)
|
||||
{
|
||||
$username = trim($this->_request->getParam('username'));
|
||||
$password = trim($this->_request->getParam('password'));
|
||||
$captchaword = trim($this->_request->getParam('captcha'));
|
||||
|
||||
if(empty($username))
|
||||
{
|
||||
$this->setCaptcha($captcha);
|
||||
$this->view->error = "请输入用户名";
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($password))
|
||||
{
|
||||
$this->setCaptcha($captcha);
|
||||
$this->view->error = "请输入密码";
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($captchaword))
|
||||
{
|
||||
$this->setCaptcha($captchaword);
|
||||
$this->view->error = "请输入验证码";
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['captcha']))
|
||||
{
|
||||
$_SESSION['captcha'] = md5(time());
|
||||
}
|
||||
|
||||
if ($captchaword != $_SESSION['captcha']) {
|
||||
$this->setCaptcha($captcha);
|
||||
$this->view->error = "验证码错误";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$this->login($username,$password))
|
||||
{
|
||||
$this->setCaptcha($captcha);
|
||||
$this->view->error = "用户名或密码错误";
|
||||
$this->view->userid = $username;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!empty($tohref))
|
||||
{
|
||||
view::Post($this,"登录成功,正在跳转",$tohref);
|
||||
return true;
|
||||
}
|
||||
|
||||
if($options['module']=="default" && $options['controller'] == "account" && $options['action'] == "login")
|
||||
{
|
||||
view::Post($this,"登录成功,正在跳转",'/');
|
||||
return true;
|
||||
}else{
|
||||
view::Post($this,"登录成功,正在跳转",$_SERVER['REQUEST_URI']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$this->setCaptcha($captcha);
|
||||
return false;
|
||||
}
|
||||
|
||||
$param = array(
|
||||
'username' => '',
|
||||
'password' => ''
|
||||
);
|
||||
|
||||
$curl = new Curl();
|
||||
$curl->port = 80;
|
||||
$curl->initOptions(array('verifyssl'=>false));
|
||||
$curl->H = array(
|
||||
'X-Requested-With: XMLHttpRequest'
|
||||
);
|
||||
$data = $curl->request($main_url,$param,"POST");
|
||||
|
||||
$cache_data = json_decode($data['response'],true);
|
||||
|
||||
view::Dump($cache_data,false);
|
||||
return true;
|
||||
}
|
||||
|
||||
function loadCaptcha()
|
||||
|
|
|
@ -4,19 +4,25 @@ namespace Helpers;
|
|||
class Curl
|
||||
{
|
||||
private $options;
|
||||
public $port = 80;
|
||||
public $H;
|
||||
|
||||
public function __construct($options = array())
|
||||
{
|
||||
$this->options = array_merge(array(
|
||||
|
||||
}
|
||||
|
||||
public function initOptions($options = array())
|
||||
{
|
||||
$this->options = array_merge(array(
|
||||
'debug' => false,
|
||||
'http_port' => '80',
|
||||
'http_port' => $this->port,
|
||||
'user_agent' => 'Westdc DataService',
|
||||
'timeout' => 20,
|
||||
'curlopts' => null,
|
||||
'verifyssl' => true,
|
||||
), $options);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Send a request to the server, receive a response
|
||||
*
|
||||
|
@ -70,6 +76,11 @@ class Curl
|
|||
$headers[] = 'Content-Length: 0';
|
||||
}
|
||||
|
||||
if(!empty($this->H) && is_array($this->H) && count($this->H) > 0)
|
||||
{
|
||||
$headers = array_merge($headers,$this->H);
|
||||
}
|
||||
|
||||
$this->debug('send '.$httpMethod.' request: '.$url);
|
||||
|
||||
$curlOptions += array(
|
||||
|
@ -82,6 +93,16 @@ class Curl
|
|||
CURLOPT_SSL_VERIFYPEER => $options['verifyssl'],
|
||||
);
|
||||
|
||||
if($this->port === 443)
|
||||
{
|
||||
/*$curlOptions += array(
|
||||
CURLOPT_SSLVERSION => 3,
|
||||
CURLOPT_SSLCERT => "../application/module/Open/apache.pem",
|
||||
CURLOPT_SSLKEY => "../application/module/Open/apache.key",
|
||||
CURLOPT_CAINFO => "../application/module/Open/apache.pem"
|
||||
);*/
|
||||
}
|
||||
|
||||
if (ini_get('open_basedir') == '' && ini_get('safe_mode') != 'On') {
|
||||
$curlOptions[CURLOPT_FOLLOWLOCATION] = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue