-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.php
executable file
·65 lines (53 loc) · 1.68 KB
/
account.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
class Account extends DNS_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('daccount');
}
public function index()
{
$this->load_view('account_list', array('list' => $this->account_list), 'account');
}
/**
* 添加DNSPOD账户
* @return type
*/
public function add()
{
$login_email = $this->input->post('username');
$login_password = $this->input->post('password');
$api_param = array(
'login_email' => $login_email,
'login_password' => $login_password
);
$this->load->library('dnsapi', $api_param);
$this->load->helper('ajax');
//调用API获取用户信息,以确定用户是否合法
try{
$api_data = $this->dnsapi->get('User.Detail');
$info = $api_data['info'];
// print_r($info);
}
catch (Exception $e) {
return ajax_error($e->getMessage());
}
$data = array(
'uid' => $this->user->id,
'dnspod_username' => $login_email,
'dnspod_password' => $login_password,
'nickname' => $info['user']['nick']
);
if ($this->daccount->add($data)) {
ajax_success();
} else {
ajax_error($this->daccount->get_error());
}
}
public function set_account($account_id = 0)
{
$this->session->set_userdata('account_id', (int)$account_id);
$this->output->set_header('Location:/domain');
}
}