module.php
3.6 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
<?php
/**
* 万能小店
*
* @author WeEngine Team & ewei
* @url
*/
defined('IN_IA') or exit('Access Denied');
include "../addons/wn_storex/model.php";
class Wn_storexModule extends WeModule {
public $_img_url = '../addons/wn_storex/template/style/img/';
public $_css_url = '../addons/wn_storex/template/style/css/';
public $_script_url = '../addons/wn_storex/template/style/js/';
public $_hotel_level_config = array(5 => '五星级酒店', 4 => '四星级酒店', 3 => '三星级酒店', 2 => '两星级以下', 15 => '豪华酒店', 14 => '高档酒店', 13 => '舒适酒店', 12 => '经济型酒店',);
public function fieldsFormDisplay($rid = 0) {
global $_W;
if ($rid) {
$reply = pdo_fetch("SELECT * FROM " . tablename('storex_reply') . " WHERE weid=:weid and rid = :rid limit 1", array(':weid' => $_W['uniacid'], ':rid' => $rid));
$sql = 'SELECT id,title,description,thumb FROM ' . tablename('storex_hotel') . ' WHERE `weid`=:weid AND `id`=:hotelid';
$hotel = pdo_fetch($sql, array(':weid' => $_W['uniacid'], ':hotelid' => $reply['hotelid']));
}
include $this->template('form');
}
public function settingsDisplay($settings) {
global $_GPC, $_W;
if (checksubmit()) {
if (empty($_GPC['sendmail']) || empty($_GPC['senduser']) || empty($_GPC['sendpwd'])) {
message('请完整填写邮件配置信息', 'refresh', 'error');
}
if ($_GPC['host'] == 'smtp.qq.com' || $_GPC['host'] == 'smtp.gmail.com') {
$secure = 'ssl';
$port = '465';
} else {
$secure = 'tls';
$port = '25';
}
$result = $this->sendmail($_GPC['host'], $secure, $port, $_GPC['sendmail'], $_GPC['senduser'], $_GPC['sendpwd'], $_GPC['sendmail']);
$cfg = array(
'host' => $_GPC['host'],
'secure' => $secure,
'port' => $port,
'sendmail' => $_GPC['sendmail'],
'senduser' => $_GPC['senduser'],
'sendpwd' => $_GPC['sendpwd'],
'status' => $result
);
if ($result == 1) {
$this->saveSettings($cfg);
message('邮箱配置成功', 'refresh');
} else {
message('邮箱配置信息有误', 'refresh', 'error');
}
}
include $this->template('setting');
}
public function fieldsFormValidate($rid = 0) {
global $_GPC;
$hotelid = intval($_GPC['hotel']);
if ($hotelid) {
$sql = 'SELECT * FROM ' . tablename('storex_hotel') . " WHERE `id`=:hotelid";
$params = array();
$params[':hotelid'] = $hotelid;
$hotel = pdo_fetch($sql, $params);
if (!empty($hotel)) {
return '';
}
}
return '没有选择合适的酒店';
}
public function fieldsFormSubmit($rid) {
global $_GPC, $_W;
$hotelid = intval($_GPC['hotel']);
$record = array();
$record['hotelid'] = $hotelid;
$record['rid'] = $rid;
$record['weid'] = $_W['uniacid'];
$reply = pdo_fetch("SELECT * FROM " . tablename('storex_reply') . " WHERE rid = :rid limit 1", array(':rid' => $rid));
if ($reply) {
pdo_update('storex_reply', $record, array('id' => $reply['id']));
} else {
pdo_insert('storex_reply', $record);
}
}
public function ruleDeleted($rid) {
pdo_delete('storex_reply', array('rid' => $rid));
}
}