install.php
7.16 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* DZAPP Haodai Install Process
*
* @copyright (c) 2013 DZAPP. (http://www.dzapp.cn)
* @author BranchZero <branchzero@gmail.com>
* @LastModTime 2013/11/22 15:44
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) exit('Access Denied!');
$request_url = str_replace('&step='.$_GET['step'],'',$_SERVER['QUERY_STRING']);
$form_url = str_replace('action=','',$request_url);
showsubmenusteps($installlang['title'], array(
array($installlang['choose'], $_GET['step']==''),
array($installlang['reg'], $_GET['step']=='install'),
array($installlang['succeed'], $_GET['step']=='ok')
));
switch($_GET['step']){
default:
C::t('common_plugin')->update($_GET['pluginid'], array('available' => '1'));
updatecache(array('plugin', 'setting', 'styles'));
if(stripos($_G['siteurl'], "http://localhost") !== FALSE || stripos($_G['siteurl'], "http://127.0.0.1") !== FALSE) cpmsg($installlang['local_ban'], '', 'error');
cpmsg($installlang['ifreg'], "{$request_url}&step=install&modetype=1", 'form', array(), '', TRUE, $_G['siteurl']."admin.php?{$request_url}&step=install&modetype=2");
case 'install':
if(extension_loaded('curl')){
if($_GET['modetype'] == '1'){
if(!submitcheck('submit')){
showtips($installlang['hd_tip1']);
showformheader("{$form_url}&step=install&modetype=1");
showtableheader($installlang['reg_header']);
showsetting($installlang['email'], 'email', $_G['setting']['adminemail'], 'text', '', '', $installlang['must_fill'].$installlang['email_summary']);
showsetting($installlang['password'], 'passwd', '', 'password', '', '', $installlang['must_fill'].$installlang['password_summary']);
showsetting($installlang['repassword'], 'repasswd', '', 'password', '', '', $installlang['must_fill']);
showsetting($installlang['nickname'], 'nickname', '', 'text', '', '', $installlang['must_fill']);
showsetting($installlang['contact_name'], 'realname', '', 'text', '', '', $installlang['must_fill'].$installlang['contact_name_summary']);
showsetting($installlang['contact_tel'], 'tel', '', 'text', '', '', $installlang['must_fill'].$installlang['contact_tel_summary']);
showsetting('QQ', 'qq', '', 'text', '', '', $installlang['must_fill'].$installlang['qq_summary']);
showsubmit('submit', 'submit');
showtablefooter();
showformfooter();
}else{
if(!$_GET['email'] || !$_GET['passwd'] || !$_GET['repasswd'] || !$_GET['nickname'] || !$_GET['realname'] || !$_GET['tel'] || !$_GET['qq']) cpmsg($installlang['not_fill'], '', 'error');
if($_GET['passwd'] !== $_GET['repasswd']) cpmsg($installlang['psw_not_match'], '', 'error');
define('HD_API_HOST', 'http://api.haodai.com/');
include_once DISCUZ_ROOT.'./source/plugin/dzapp_haodai/haodai.api.class.php';
$client = new HaoDaiClient('1000002', 'sLXuof1JgsqxssYSkJVXqci4MNHftaxB');
$client->set_debug(0);
$config = array();
$data = array(
'email' => diconv($_GET['email'], CHARSET, 'UTF-8'),
'tel' => $_GET['tel'],
'nickname' => diconv($_GET['nickname'], CHARSET, 'UTF-8'),
'passwd' => diconv($_GET['passwd'], CHARSET, 'UTF-8'),
'realname' => diconv($_GET['realname'], CHARSET, 'UTF-8'),
'qq' => $_GET['qq'],
'domain' => $_G['siteurl'],
'sitename' => diconv($_G['setting']['sitename'], CHARSET, 'UTF-8')
);
$result = $client->register_union_account($data);
if($result['rs_code'] != '1000'){
cpmsg($installlang['errmsg']."<br>".diconv($result['rs_msg'], 'UTF-8', CHARSET), '', 'error');
}
$config['HD_REF'] = $result['hd_ref'];
define('HD_REF', $config['HD_REF']);
$client = new HaoDaiClient('1000002', 'sLXuof1JgsqxssYSkJVXqci4MNHftaxB');
$client->set_debug(0);
$data = array(
'app_name' => diconv($_G['setting']['sitename'].' '.dgmdate($_G['timestamp'], 'Y-m-d-H:i'), CHARSET, 'UTF-8'),
'site_url' => $_G['siteurl'],
'desc' => diconv($_G['setting']['sitename'].$installlang['hd_desc'], CHARSET, 'UTF-8'),
'callback_url' => $_G['siteurl'].'plugin.php?id=dzapp_haodai:callback',
);
$result = $client->haodai_app_register($data);
if($result['rs_code'] != '1000'){
cpmsg($installlang['errmsg']."<br>".diconv($result['rs_msg'], 'UTF-8', CHARSET), '', 'error');
}else{
$config['HD_AKEY'] = $result['hd_akey'];
$config['HD_SKEY'] = $result['hd_skey'];
$config['HD_CALLBACK_URL'] = $result['hd_callback_url'];
$config['HD_API_HOST'] = 'http://api.haodai.com/';
$config = daddslashes($config);
$configfile = "<?php \r\n";
foreach($config as $key => $value){
$configfile .= "define('$key', '$value');\r\n";
}
$configfile .= "?>";
$file = DISCUZ_ROOT."./data/dzapp_haodai_config.php";
$fp = fopen($file, 'w');
fwrite($fp, $configfile);
fclose($fp);
cpmsg($installlang['install_succeed'], "{$request_url}&step=ok", 'loading', '');
}
}
}elseif($_GET['modetype'] == '2'){
if(!submitcheck('submit')){
showtips($installlang['hd_tip2']);
showformheader("{$form_url}&step=install&modetype=2");
showtableheader($installlang['reg_header2']);
showsetting($installlang['ref'], 'ref', '', 'text', '', '', $installlang['must_fill'].$installlang['ref_summary']);
showsubmit('submit', 'submit');
showtablefooter();
showformfooter();
}else{
if(!$_GET['ref']) cpmsg($installlang['not_fill'], '', 'error');
define('HD_API_HOST', 'http://api.haodai.com/');
define('HD_REF', $_GET['ref']);
include_once DISCUZ_ROOT.'./source/plugin/dzapp_haodai/haodai.api.class.php';
$client = new HaoDaiClient('1000002', 'sLXuof1JgsqxssYSkJVXqci4MNHftaxB');
$client->set_debug(0);
$config = array();
$config['HD_REF'] = $_GET['ref'];
$data = array(
'app_name' => diconv($_G['setting']['sitename'].' '.dgmdate($_G['timestamp'], 'Y-m-d-H:i'), CHARSET, 'UTF-8'),
'site_url' => $_G['siteurl'],
'desc' => diconv($_G['setting']['sitename'].$installlang['hd_desc'], CHARSET, 'UTF-8'),
'callback_url' => $_G['siteurl'].'plugin.php?id=dzapp_haodai:callback',
);
$result = $client->haodai_app_register($data);
if($result['rs_code'] != '1000'){
cpmsg($installlang['errmsg']."<br>".diconv($result['rs_msg'], 'UTF-8', CHARSET), '', 'error');
}else{
$config['HD_AKEY'] = $result['hd_akey'];
$config['HD_SKEY'] = $result['hd_skey'];
$config['HD_CALLBACK_URL'] = $result['hd_callback_url'];
$config['HD_API_HOST'] = 'http://api.haodai.com/';
$config['HD_CITY'] = '';
$config = daddslashes($config);
$configfile = "<?php \r\n";
foreach($config as $key => $value){
$configfile .= "define('$key', '$value');\r\n";
}
$configfile .= "?>";
$file = DISCUZ_ROOT."./data/dzapp_haodai_config.php";
$fp = fopen($file, 'w');
fwrite($fp, $configfile);
fclose($fp);
cpmsg($installlang['install_succeed'], "{$request_url}&step=ok", 'loading', '');
}
}
}
}else{
cpmsg($installlang['curl_unsupported'], '', 'error');
}
break;
case 'ok':
$finish = TRUE;
break;
}
?>