* adjust for certify.

This commit is contained in:
wangyidong
2016-12-27 15:33:26 +08:00
parent 0ce192ff38
commit cdbf4c6dcf
7 changed files with 219 additions and 82 deletions
+2
View File
@@ -9,5 +9,7 @@ $config->url->extension = 'http://www.zentao.net/extension-browse.html';
$config->url->donation = 'http://www.zentao.net/help-donation.html';
$config->url->service = 'http://www.cnezsoft.com/article-browse-1078.html';
$config->admin->apiRoot = 'http://www.zentao.net';
if(!isset($config->safe)) $config->safe = new stdclass();
if(!isset($config->safe->weak)) $config->safe->weak = '123456,password,12345,12345678,qwerty,123456789,1234,1234567,abc123,111111,123123';
+35 -28
View File
@@ -83,7 +83,14 @@ class admin extends control
}
$alertMessage = '';
foreach($response->message as $item) $alertMessage .= is_array($item) ? join('\n', $item) . '\n' : $item . '\n';
if(is_string($response->message))
{
$alertMessage = $response->message;
}
else
{
foreach($response->message as $item) $alertMessage .= is_array($item) ? join('\n', $item) . '\n' : $item . '\n';
}
$alertMessage = str_replace(array('<strong>', '</strong>'), '', $alertMessage);
die(js::alert($alertMessage));
}
@@ -221,11 +228,20 @@ class admin extends control
$this->display();
}
/**
* Certify ztEmail.
*
* @param string $email
* @access public
* @return void
*/
public function certifyZtEmail($email = '')
{
if($_POST)
{
$this->admin->certifyByAPI('mail');
$response = $this->admin->certifyByAPI('mail');
$response = json_decode($response);
if($response->result == 'fail') die(js::alert($response->message));
die(js::locate($this->createLink('mail', 'ztCloud'), 'parent'));
}
@@ -236,11 +252,20 @@ class admin extends control
$this->display();
}
/**
* Certify ztMobile
*
* @param string $mobile
* @access public
* @return void
*/
public function certifyZtMobile($mobile = '')
{
if($_POST)
{
$this->admin->certifyByAPI('mobile');
$response = $this->admin->certifyByAPI('mobile');
$response = json_decode($response);
if($response->result == 'fail') die(js::alert($response->message));
die(js::locate($this->createLink('mail', 'ztCloud'), 'parent'));
}
@@ -251,33 +276,15 @@ class admin extends control
$this->display();
}
/**
* Ajax send code.
*
* @param int $type
* @access public
* @return void
*/
public function ajaxSendCode($type)
{
die($this->admin->sendCodeByAPI($type));
}
public function sendmail()
{
$url = 'http://api.sendcloud.net/apiv2/mail/send';
$params['apiUser'] = 'zentao_chunsheng';
$params['apiKey'] = 'I70rz0E5Org4N3jU';
$params['from'] = '876333172@qq.com';
$params['fromName'] = 'QQ';
$params['to'] = 'wyd621@163.com';
$params['subject'] = 'test';
$params['html'] = 'test';
$data = http_build_query($params);
$options['http'] = array(
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => $data
);
$context = stream_context_create($options);
$result = file_get_contents($url, FILE_TEXT, $context);
a($result);
}
}
+66 -12
View File
@@ -109,7 +109,8 @@ class adminModel extends model
*/
public function registerByAPI()
{
$apiURL = 'http://www.zentao.net/user-register.json?bind=yes&HTTP_X_REQUESTED_WITH=XMLHttpRequest';
$apiConfig = $this->getApiConfig();
$apiURL = $this->config->admin->apiRoot . "/user-apiRegister.json?HTTP_X_REQUESTED_WITH=XMLHttpRequest&{$apiConfig->sessionVar}={$apiConfig->sessionID}";
return $this->postAPI($apiURL, $_POST);
}
@@ -121,17 +122,27 @@ class adminModel extends model
*/
public function bindByAPI()
{
$apiURL = 'http://www.zentao.net/user-bindChanzhi.json?HTTP_X_REQUESTED_WITH=XMLHttpRequest';
$apiConfig = $this->getApiConfig();
$apiURL = $this->config->admin->apiRoot . "/user-bindChanzhi.json?HTTP_X_REQUESTED_WITH=XMLHttpRequest&{$apiConfig->sessionVar}={$apiConfig->sessionID}";
return $this->postAPI($apiURL, $_POST);
}
/**
* Get secret key.
*
* @access public
* @return object
*/
public function getSecretKey()
{
//$apiURL = "http://www.zentao.net/user-secretKey.json";
$apiURL = "http://www.zentao.cn/user-secretKey.json";
$apiConfig = $this->getApiConfig();
$apiURL = $this->config->admin->apiRoot . "/user-secretKey.json";
$params['u'] = $this->config->global->community;
$params['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$params[$apiConfig->sessionVar] = $apiConfig->sessionID;
$params['k'] = $this->getSignature($params);
$this->agent->cookies['lang'] = $this->cookie->lang;
$this->agent->fetch($apiURL . '?' . http_build_query($params));
$result = $this->agent->results;
@@ -139,32 +150,56 @@ class adminModel extends model
return $result;
}
/**
* Send code by API.
*
* @param string $type
* @access public
* @return string
*/
public function sendCodeByAPI($type)
{
$module = $type == 'mobile' ? 'sms' : 'mail';
//$apiURL = "http://www.zentao.net/{$module}-apiSendCode.json";
$apiURL = "http://www.zentao.cn/{$module}-apiSendCode.json";
$params['u'] = $this->config->global->community;
$apiConfig = $this->getApiConfig();
$module = $type == 'mobile' ? 'sms' : 'mail';
$apiURL = $this->config->admin->apiRoot . "/{$module}-apiSendCode.json";
$params['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$params['k'] = $this->getSignature($params);
$params[$apiConfig->sessionVar] = $apiConfig->sessionID;
if(isset($this->config->global->community) and $this->config->global->community != 'na') $this->post->set('account', $this->config->global->community);
$param = http_build_query($params);
return $this->postAPI($apiURL . '?' . $param, $_POST);
}
/**
* Certify by API.
*
* @param string $type
* @access public
* @return string
*/
public function certifyByAPI($type)
{
$module = $type == 'mobile' ? 'sms' : 'mail';
//$apiURL = "http://www.zentao.net/{$module}-apiCertify.json";
$apiURL = "http://www.zentao.cn/{$module}-apiCertify.json";
$apiConfig = $this->getApiConfig();
$module = $type == 'mobile' ? 'sms' : 'mail';
$apiURL = $this->config->admin->apiRoot . "/{$module}-apiCertify.json";
$params['u'] = $this->config->global->community;
$params['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$params[$apiConfig->sessionVar] = $apiConfig->sessionID;
$params['k'] = $this->getSignature($params);
$param = http_build_query($params);
return $this->postAPI($apiURL . '?' . $param, $_POST);
}
/**
* Get signature.
*
* @param array $params
* @access public
* @return string
*/
public function getSignature($params)
{
unset($params['u']);
@@ -172,6 +207,25 @@ class adminModel extends model
return md5(http_build_query($params) . md5($privateKey));
}
/**
* Get api config.
*
* @access public
* @return object
*/
public function getApiConfig()
{
if(!$this->session->apiConfig or time() - $this->session->apiConfig->serverTime > $this->session->apiConfig->expiredTime)
{
$config = file_get_contents($this->config->admin->apiRoot . "?mode=getconfig");
$config = json_decode($config);
if(empty($config) or empty($config->sessionID)) return null;
$this->session->set('apiConfig', $config);
}
return $this->session->apiConfig;
}
/**
* Get register information.
*
+20 -20
View File
@@ -11,27 +11,27 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<div class='panel' id='checkEmail'>
<div class='panel-heading'><strong><?php echo $lang->admin->certifyEmail;?></strong></div>
<div class='panel-body'>
<form method='post' target='hiddenwin'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->user->email;?></th>
<td><?php echo html::input('email', $email, "class='form-control'");?></td>
<td><?php echo html::a(inlink('ajaxsendcode', 'type=email'), $lang->admin->getCaptcha, '', "id='codeSender' class='btn btn-xs'");?></td>
</tr>
<tr>
<th><?php echo $lang->admin->captcha;?></th>
<td><?php echo html::input('captcha', '', "class='form-control'");?></td>
</tr>
<tr>
<th></th>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
<div class='container mw-700px' id='checkEmail'>
<div id='titlebar'>
<div class='heading'><strong><?php echo $lang->admin->certifyEmail;?></strong></div>
</div>
<form method='post' target='hiddenwin'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->user->email;?></th>
<td><?php echo html::input('email', $email, "class='form-control'");?></td>
<td><?php echo html::a(inlink('ajaxsendcode', 'type=email'), $lang->admin->getCaptcha, '', "id='codeSender' class='btn'");?></td>
</tr>
<tr>
<th><?php echo $lang->admin->captcha;?></th>
<td><?php echo html::input('captcha', '', "class='form-control'");?></td>
</tr>
<tr>
<th></th>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
</div>
<script>
$(function()
+20 -20
View File
@@ -11,27 +11,27 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<div class='panel' id='checkMobile'>
<div class='panel-heading'><strong><?php echo $lang->admin->certifyMobile;?></strong></div>
<div class='panel-body'>
<form method='post' target='hiddenwin'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->user->mobile;?></th>
<td><?php echo html::input('mobile', $mobile, "class='form-control'");?></td>
<td><?php echo html::a(inlink('ajaxsendcode', 'type=mobile'), $lang->admin->getCaptcha, '', "id='codeSender' class='btn btn-xs'");?></td>
</tr>
<tr>
<th><?php echo $lang->admin->captcha;?></th>
<td><?php echo html::input('captcha', '', "class='form-control'");?></td>
</tr>
<tr>
<th></th>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
<div class='container mw-700px' id='checkMobile'>
<div id='titlebar'>
<div class='heading'><strong><?php echo $lang->admin->certifyMobile;?></strong></div>
</div>
<form method='post' target='hiddenwin'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->user->mobile;?></th>
<td><?php echo html::input('mobile', $mobile, "class='form-control'");?></td>
<td><?php echo html::a(inlink('ajaxsendcode', 'type=mobile'), $lang->admin->getCaptcha, '', "id='codeSender' class='btn'");?></td>
</tr>
<tr>
<th><?php echo $lang->admin->captcha;?></th>
<td><?php echo html::input('captcha', '', "class='form-control'");?></td>
</tr>
<tr>
<th></th>
<td><?php echo html::submitButton();?></td>
</tr>
</table>
</form>
</div>
<script>
$(function()
+70 -2
View File
@@ -11,6 +11,9 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<style>
.input-group .input-group-btn .popover{font-size:12px;}
</style>
<div class='container mw-700px'>
<div id='titlebar'>
<div class='heading'>
@@ -44,11 +47,29 @@
</tr>
<tr>
<th><?php echo $lang->user->mobile;?></th>
<td><?php echo html::input('mobile', '', "class='form-control'");?></td>
<td>
<div class="required required-wrapper"></div>
<div class='input-group'>
<?php echo html::input('mobile', '', "class='form-control'");?>
<span class='input-group-btn'><?php echo html::a(inlink('ajaxSendCode', 'type=mobile'), $lang->admin->getCaptcha, '', "id='mobileSender' class='btn'")?></span>
<span class='input-group-addon'></span>
<span class='input-group-addon'><?php echo $lang->admin->captcha?></span>
<?php echo html::input('mobileCode', '', "class='form-control'");?>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->user->email;?></th>
<td><div class="required required-wrapper"></div><?php echo html::input('email', $register->email, "class='form-control'");?></td>
<td>
<div class="required required-wrapper"></div>
<div class='input-group'>
<?php echo html::input('email', $register->email, "class='form-control'");?>
<span class='input-group-btn'><?php echo html::a(inlink('ajaxSendCode', 'type=email'), $lang->admin->getCaptcha, '', "id='mailSender' class='btn'")?></span>
<span class='input-group-addon'></span>
<span class='input-group-addon'><?php echo $lang->admin->captcha?></span>
<?php echo html::input('emailCode', '', "class='form-control'");?>
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->user->password;?></th>
@@ -70,4 +91,51 @@
</table>
</form>
</div>
<script>
$(function()
{
$('#mobileSender').click(function()
{
var data = {mobile: $('#mobile').val()};
var url = $(this).attr('href');
$.post(url, data, function(response)
{
if(response.result == 'success')
{
$('#mobileSender').popover({trigger:'manual', content:response.message, placement:'right'}).popover('show');
$('#mobileSender').next('.popover').addClass('popover-success');
function distroy(){$('#mobileSender').popover('destroy')}
setTimeout(distroy,2000);
}
else
{
bootbox.alert(response.message);
}
}, 'json')
return false;
})
$('#mailSender').click(function()
{
var data = {email: $('#email').val()};
var url = $(this).attr('href');
$.post(url, data, function(response)
{
if(response.result == 'success')
{
$('#mailSender').popover({trigger:'manual', content:response.message, placement:'right'}).popover('show');
$('#mailSender').next('.popover').addClass('popover-success');
function distroy(){$('#mailSender').popover('destroy')}
setTimeout(distroy,2000);
}
else
{
bootbox.alert(response.message);
}
}, 'json')
return false;
})
});
</script>
<?php include '../../common/view/footer.html.php';?>
+6
View File
@@ -206,6 +206,12 @@ class mailModel extends model
$this->mta->secretKey = $this->config->mail->sendcloud->secretKey;
}
/**
* Set Ztcloud.
*
* @access public
* @return void
*/
public function setZtcloud()
{
$this->mta->account = $this->config->global->community;