dzapp_haodai.inc.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <?php
  2. /**
  3. * DZAPP Haodai Main View
  4. *
  5. * @copyright (c) 2013 DZAPP. (http://www.dzapp.cn)
  6. * @author BranchZero <branchzero@gmail.com>
  7. */
  8. !defined('IN_DISCUZ') && exit('Access Denied');
  9. include_once DISCUZ_ROOT.'./data/dzapp_haodai_config.php';
  10. include_once DISCUZ_ROOT.'./source/plugin/dzapp_haodai/haodai.api.class.php';
  11. include_once DISCUZ_ROOT.'./source/plugin/dzapp_haodai/dzapp_haodai.func.php';
  12. @include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_setting.php';
  13. @include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_city.php';
  14. require_once libfile('function/cache');
  15. $var = $_G['cache']['plugin']['dzapp_haodai'];
  16. $dzapp_haodai_seo = dunserialize($_G['setting']['dzapp_haodai_seo']);
  17. $current_host = parse_url($_G['siteurl'], PHP_URL_HOST);
  18. $action = $_GET['action'];
  19. if(!isset($hd_token)){
  20. if($_G['adminid'] == 1){
  21. $oauth = new HaoDaiOAuth(HD_AKEY, HD_SKEY);
  22. $auth_url = $oauth->getAuthorizeURL(HD_CALLBACK_URL);
  23. header('Location:'.$auth_url);
  24. }else{
  25. showmessage('dzapp_haodai:callback_error_user');
  26. }
  27. }else{
  28. if(isset($hd_token['expires']) && TIMESTAMP > $hd_token['expires'] - 3600){
  29. $client = new HaoDaiClient(HD_AKEY, HD_SKEY);
  30. $client->set_debug(0);
  31. $result = $client->haodai_check_AccessToken();
  32. if($result['rs_code'] != '1000'){
  33. if($result['rs_code'] == '2100'){
  34. $hd_token = $client->oauth->getAccessToken('token', $hd_token);
  35. writetocache('dzapp_haodai_setting', getcachevars(array('hd_token' => $hd_token)));
  36. }else{
  37. showmessage('dzapp_haodai:callback_error_user');
  38. }
  39. }
  40. }elseif(isset($hd_token['expires']) && TIMESTAMP < $hd_token['expires'] - 3600){
  41. }else{
  42. showmessage('dzapp_haodai:callback_error_user');
  43. }
  44. }
  45. if($_G['cookie']['HD_CITY'] && $zones[$_G['cookie']['HD_CITY']]){
  46. $city = $_G['cookie']['HD_CITY'];
  47. }else{
  48. require_once libfile('function/misc');
  49. $location = convertip($_G['clientip']);
  50. $charset = strtoupper(CHARSET);
  51. foreach($zones as $key => $value){
  52. if($charset == 'UTF-8'){
  53. $value = substr($value, 0, strlen($value) - 3);
  54. }elseif($charset == 'GBK'){
  55. $value = substr($value, 0, strlen($value) - 2);
  56. }elseif($charset == 'BIG5'){
  57. $city = '';
  58. break;
  59. }
  60. if(stripos($location,$value) !== FALSE){
  61. $city = $key;
  62. break;
  63. }
  64. }
  65. if($city){
  66. dsetcookie('HD_CITY', $city);
  67. }else{
  68. $city = defined('HD_CITY') && (HD_CITY !== '') ? HD_CITY : showmessage('dzapp_haodai:pleasechoosecity', 'admin.php?action=plugins&operation=config&identifier=dzapp_haodai&pmod=admincp_city');
  69. dsetcookie('HD_CITY', HD_CITY);
  70. }
  71. }
  72. $client = new HaoDaiClient(HD_AKEY, HD_SKEY, $hd_token['access_token']);
  73. $client->set_debug(0);
  74. if(defined('IN_MOBILE')){
  75. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_filter_mobile.php'){
  76. $filter_raw = $filterm = $filtermn = array();
  77. $rawtypes = array('gouche', 'goufang', 'qiye', 'xiaofei');
  78. foreach($rawtypes as $value){
  79. $filter_raw[$value] = get_xindai_filter($value);
  80. foreach($filter_raw[$value]['filter'] as $value1){
  81. foreach($value1['options'] as $value2){
  82. $filterm[$value][$value1['key']][$value2['val']] = array('name' => $value2['name'], 'val' => $value2['val']);
  83. }
  84. $filtermn[$value][$value1['key']] = $value1['name'];
  85. }
  86. }
  87. unset($filter_raw);
  88. writetocache('dzapp_haodai_filter_mobile', getcachevars(array('filterm' => $filterm, 'filtermn' => $filtermn)));
  89. }
  90. }
  91. if($action == ''){
  92. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_xindai_ad_'.$city.'.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_xindai_ad_'.$city.'.php') > $var['refreshtime']){
  93. $xindai_ad = get_xindai_ad();
  94. $xindai_ad_type = array();
  95. $xindai_ad_detail = array();
  96. foreach($xindai_ad['items'] as $key => $value){
  97. $xindai_ad_type[] = $value['type_name'];
  98. foreach($value['list'] as $value2){
  99. $value2['apply'] = cutstr(strip_tags($value2['apply']), 90);
  100. $xindai_ad_detail[$key][] = $value2;
  101. }
  102. }
  103. writetocache('dzapp_haodai_xindai_ad_'.$city, getcachevars(array('xindai_ad_type' => $xindai_ad_type,'xindai_ad_detail' => $xindai_ad_detail)));
  104. }
  105. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkgl_'.$city.'.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkgl_'.$city.'.php') > $var['refreshtime']){
  106. $dkgl_article = get_article_dkgl_list();
  107. writetocache('dzapp_haodai_dkgl_'.$city, getcachevars(array('dkgl_article' => $dkgl_article)));
  108. }
  109. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkzx_'.$city.'.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkzx_'.$city.'.php') > $var['refreshtime']){
  110. $dkzx_article = get_article_dkzx_list();
  111. writetocache('dzapp_haodai_dkzx_'.$city, getcachevars(array('dkzx_article' => $dkzx_article)));
  112. }
  113. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_cjwt_'.$city.'.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_cjwt_'.$city.'.php') > $var['refreshtime']){
  114. $cjwt_article = get_article_cjwt_list();
  115. writetocache('dzapp_haodai_cjwt_'.$city, getcachevars(array('cjwt_article' => $cjwt_article)));
  116. }
  117. $seodata = array('bbname' => $_G['setting']['bbname']);
  118. list($navtitle, $metadescription, $metakeywords) = get_seosetting('', $seodata, $dzapp_haodai_seo['main']);
  119. include template('dzapp_haodai:main_'.$var['mode']);
  120. }elseif($action == 'search'){
  121. $_GET['xd_type'] = $_GET['xd_type'] ? $_GET['xd_type'] : 'xiaofei';
  122. if(!in_array($_GET['xd_type'],array('xiaofei','goufang','qiye','gouche'))) showmessage('dzapp_haodai:xd_type_fail');
  123. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_filter_'.$_GET['xd_type'].'.php'){
  124. $filter = get_xindai_filter();
  125. writetocache('dzapp_haodai_filter_'.$_GET['xd_type'], getcachevars(array('filter' => $filter)));
  126. }
  127. $money = $_GET['money'] ? intval($_GET['money']) : 10;
  128. $month = $_GET['month'] ? intval($_GET['month']) : 12;
  129. $param = is_array($_GET['param']) ? $_GET['param'] : array();
  130. $data = array();
  131. $page = max(1, intval($_GET['page']));
  132. unset($_GET['page']);
  133. if($_GET['remove']){
  134. unset($_GET[$_GET['remove']]);
  135. unset($_GET['remove']);
  136. }
  137. if($_GET['allremove']){
  138. $data = array();
  139. $newget = array('id'=>$_GET['id'], 'action'=>$_GET['action'], 'xd_type'=>$_GET['xd_type'], 'money'=>$_GET['money'], 'month'=>$_GET['month']);
  140. $_GET = $newget;
  141. }
  142. $chosen = array();
  143. foreach($filter['filter'] as $key => $value){
  144. $value['get'] = $_GET;
  145. if($value['get'][$value['key']]){
  146. $chosen[] = array('name'=>$value['name'], 'key'=>$value['key']);
  147. $data[$value['key']] = $value['get'][$value['key']];
  148. unset($value['get'][$value['key']]);
  149. }
  150. $filter['filter'][$key]['link'] = 'plugin.php?'.url_implode($value['get']);
  151. }
  152. if($_GET['grade']) $data['grade'] = $_GET['grade'];
  153. if($_GET['total_interest']) $data['total_interest'] = $_GET['total_interest'];
  154. if($_GET['month_repay']) $data['month_repay'] = $_GET['month_repay'];
  155. $result = get_xindai_list($money, $month, $data, $page);
  156. $num = $result['count'];
  157. $items = array();
  158. foreach($result['items'] as $value){
  159. $value['year_rate'] = round($value['year_rate'], 2);
  160. $value['more'] = count(explode(',',$value['profession'])) > 3 ? 1 : 0;
  161. $value['professions'] = reset(array_chunk(explode(',',$value['profession']),3));
  162. $items[] = $value;
  163. }
  164. $theurl = 'plugin.php?'.url_implode($_GET);
  165. $sort_get = $_GET;
  166. unset($sort_get['grade']);
  167. unset($sort_get['total_interest']);
  168. unset($sort_get['month_repay']);
  169. $theurl_without_sort = 'plugin.php?'.url_implode($sort_get);
  170. $start_limit = ($page - 1) * 10;
  171. $multipage = multi($num, 10, $page, $theurl);
  172. $maxpage = ceil($num / 10);
  173. $seodata = array('bbname' => $_G['setting']['bbname'], 'xd_type' => lang('plugin/dzapp_haodai','xd_type_'.$_GET['xd_type']));
  174. list($navtitle, $metadescription, $metakeywords) = get_seosetting('', $seodata, $dzapp_haodai_seo['search']);
  175. include template('dzapp_haodai:search');
  176. }elseif($action == 'news'){
  177. if(!$_GET['aid']) showmessage('dzapp_haodai:param_wrong');
  178. $id = intval($_GET['aid']);
  179. $result = get_article_detail($id);
  180. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkzx_'.$city.'.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkzx_'.$city.'.php') > $var['refreshtime']){
  181. $dkzx_article = get_article_dkzx_list();
  182. writetocache('dzapp_haodai_dkzx_'.$city, getcachevars(array('dkzx_article' => $dkzx_article)));
  183. }
  184. $seodata = array('bbname' => $_G['setting']['bbname'], 'news_title' => $result['title']);
  185. list($navtitle, $metadescription, $metakeywords) = get_seosetting('', $seodata, $dzapp_haodai_seo['news']);
  186. include template('dzapp_haodai:news');
  187. }elseif($action == 'view'){
  188. $_GET['xd_type'] = $_GET['xd_type'] ? $_GET['xd_type'] : 'xiaofei';
  189. if(!in_array($_GET['xd_type'],array('xiaofei','goufang','qiye','gouche'))) showmessage('dzapp_haodai:xd_type_fail');
  190. if(!$_GET['xd_id']) showmessage('dzapp_haodai:param_wrong');
  191. $xd_id = intval($_GET['xd_id']);
  192. $money = $_GET['money'] ? intval($_GET['money']) : 1;
  193. $month = $_GET['month'] ? intval($_GET['month']) : 12;
  194. $get_related = get_xindai_recommend($money, $month);
  195. $get_related = $get_related['items'];
  196. $xd = get_xindai_detail($xd_id, $money, $month);
  197. $xd['limit_min'] = round($xd['limit_min']);
  198. $xd['limit_max'] = round($xd['limit_max']);
  199. $xd['apply'] = htmlspecialchars_decode($xd['apply']);
  200. $xd['stuff'] = htmlspecialchars_decode($xd['stuff']);
  201. $xd['content'] = htmlspecialchars_decode($xd['content']);
  202. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_hot_recommend.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_hot_recommend.php') > $var['refreshtime']){
  203. $hot_recommend = get_hot_recommend();
  204. writetocache('dzapp_haodai_hot_recommend', getcachevars(array('hot_recommend' => $hot_recommend)));
  205. }
  206. $seodata = array('bbname' => $_G['setting']['bbname'], 'xd_type' => lang('plugin/dzapp_haodai','xd_type_'.$_GET['xd_type']), 'bank_name' => $xd['bank_name'], 'xd_name' => $xd['name']);
  207. list($navtitle, $metadescription, $metakeywords) = get_seosetting('', $seodata, $dzapp_haodai_seo['view']);
  208. include template('dzapp_haodai:view');
  209. }elseif($action == 'apply'){
  210. $_GET['xd_type'] = $_GET['xd_type'] ? $_GET['xd_type'] : 'xiaofei';
  211. if(!in_array($_GET['xd_type'],array('xiaofei','goufang','qiye','gouche'))) showmessage('dzapp_haodai:xd_type_fail');
  212. if(!$_GET['xd_id']) showmessage('dzapp_haodai:param_wrong');
  213. $xd_id = intval($_GET['xd_id']);
  214. $money = $_GET['money'] ? intval($_GET['money']) : 1;
  215. $month = $_GET['month'] ? intval($_GET['month']) : 12;
  216. $xd = get_xindai_detail($xd_id, $money, $month);
  217. if(!submitcheck('applysubmit')) {
  218. $seodata = array('bbname' => $_G['setting']['bbname']);
  219. list($navtitle, $metadescription, $metakeywords) = get_seosetting('', $seodata, $dzapp_haodai_seo['apply']);
  220. include template('dzapp_haodai:apply');
  221. }else{
  222. if($_GET['xd_type'] == 'xiaofei'){
  223. if(!$_GET['company_type'] || !$_GET['year_born'] || !$_GET['salary_type'] || !$_GET['salary'] || !$_GET['has_creditcard'] || !$_GET['has_debt'] || !$_GET['has_succ_apply'] || !$_GET['has_debt_loan'] || !$_GET['nickname'] || !$_GET['mobile']) showmessage('dzapp_haodai:apply_incomplete');
  224. if($_GET['has_creditcard'] == lang('plugin/dzapp_haodai','have') && (!$_GET['creditcard_num'] || !$_GET['creditcard_money'])) showmessage('dzapp_haodai:apply_incomplete');
  225. if($_GET['has_debt'] == lang('plugin/dzapp_haodai','have') && !$_GET['debt_money']) showmessage('dzapp_haodai:apply_incomplete');
  226. if($_GET['has_debt_loan'] == lang('plugin/dzapp_haodai','have') && !$_GET['debt_loan_money']) showmessage('dzapp_haodai:apply_incomplete');
  227. $remark = lang('plugin/dzapp_haodai','remark_company_type').$_GET['company_type'].lang('plugin/dzapp_haodai','remark_birth').$_GET['year_born'].lang('plugin/dzapp_haodai','remark_salary_type').$_GET['salary_type'].lang('plugin/dzapp_haodai','remark_month_income').$_GET['salary'].lang('plugin/dzapp_haodai','remark_worktime').$_GET['job_year'].lang('plugin/dzapp_haodai','remark_year').$_GET['job_month'].lang('plugin/dzapp_haodai','remark_month').($_GET['has_creditcard'] == lang('plugin/dzapp_haodai','have') ? lang('plugin/dzapp_haodai','remark_has_card').$_GET['creditcard_num'].lang('plugin/dzapp_haodai','remark_card_num').$_GET['creditcard_money'].lang('plugin/dzapp_haodai','remark_yuan') : lang('plugin/dzapp_haodai','remark_has_card_no')).($_GET['has_debt'] == lang('plugin/dzapp_haodai','have') ? lang('plugin/dzapp_haodai','remark_has_debt').$_GET['debt_money'].lang('plugin/dzapp_haodai','remark_yuan') : lang('plugin/dzapp_haodai','remark_has_debt_no')).lang('plugin/dzapp_haodai','remark_succeed_applied').$_GET['has_succ_apply'].($_GET['has_debt_loan'] == lang('plugin/dzapp_haodai','have') ? lang('plugin/dzapp_haodai','remark_has_debt_num').$_GET['debt_loan_money'].lang('plugin/dzapp_haodai','remark_yuan') : lang('plugin/dzapp_haodai','remark_has_debt_num_no'));
  228. }elseif($_GET['xd_type'] == 'goufang'){
  229. if(!$_GET['house_type'] || !$_GET['monthly'] || !$_GET['hukou'] || !$_GET['has_secondhandhouse'] || !$_GET['nickname'] || !$_GET['mobile']) showmessage('dzapp_haodai:apply_incomplete');
  230. $remark = lang('plugin/dzapp_haodai','remark_house_type').$_GET['house_type'].lang('plugin/dzapp_haodai','remark_month_income').$_GET['monthly'].lang('plugin/dzapp_haodai','remark_second_hand').$_GET['has_secondhandhouse'].lang('plugin/dzapp_haodai','remark_live_in').$_GET['hukou'];
  231. }elseif($_GET['xd_type'] == 'gouche'){
  232. if(!$_GET['has_house'] || !$_GET['car_step'] || !$_GET['monthly'] || !$_GET['nickname'] || !$_GET['mobile']) showmessage('dzapp_haodai:apply_incomplete');
  233. $remark = lang('plugin/dzapp_haodai','remark_has_house').$_GET['has_house'].lang('plugin/dzapp_haodai','remark_car_no').$_GET['car_step'].lang('plugin/dzapp_haodai','remark_card_bank_num').$_GET['monthly'];
  234. }elseif($_GET['xd_type'] == 'qiye'){
  235. if(!$_GET['company_type'] || !$_GET['monthly'] || !$_GET['has_house'] || !$_GET['business_time'] || !$_GET['nickname'] || !$_GET['mobile']) showmessage('dzapp_haodai:apply_incomplete');
  236. $remark = lang('plugin/dzapp_haodai','remark_company_type').$_GET['company_type'].lang('plugin/dzapp_haodai','remark_card_bank_num').$_GET['monthly'].lang('plugin/dzapp_haodai','remark_qiye_has_house').$_GET['has_house'].lang('plugin/dzapp_haodai','bt').$_GET['business_time'];
  237. }
  238. $remark = diconv($remark, CHARSET, 'UTF-8');
  239. $_GET['nickname'] = diconv($_GET['nickname'], CHARSET, 'UTF-8');
  240. if($_GET['details']){
  241. if(strlen($_GET['details']) > 280) showmessage('dzapp_haodai:apply_reach_limit');
  242. $_GET['details'] = diconv($_GET['details'], CHARSET, 'UTF-8');
  243. }
  244. $data = array();
  245. if($_GET['email']) $data['email'] = $_GET['email'];
  246. if($_GET['details']) $data['details'] = $_GET['details'];
  247. $data['xd_id'] = $xd_id;
  248. $data['xd_type'] = $_GET['xd_type'];
  249. $data['bank_id'] = $xd['bank_id'];
  250. $data['month'] = $month;
  251. $data['remark'] = $remark;
  252. $result = arrayCoding($client->send_xindai_apply($city, $_GET['nickname'], $money, $_GET['mobile'], $data), 'UTF-8', CHARSET);
  253. if($result['rs_code'] != '1000') showmessage(lang('plugin/dzapp_haodai','apply_fail').$result['rs_msg']);
  254. if($result['id'] && $_GET['details']){
  255. $result2 = arrayCoding($client->send_xindai_apply_details($result['id'], $_GET['details'], $_GET['xd_type']), 'UTF-8', CHARSET);
  256. if($result2['rs_code'] != '1000') showmessage(lang('plugin/dzapp_haodai','apply_fail').$result2['rs_msg']);
  257. }
  258. showmessage('dzapp_haodai:apply_succeed','plugin.php?id=dzapp_haodai');
  259. }
  260. }elseif($action == 'list'){
  261. $page = max(1, intval($_GET['page']));
  262. if($_GET['type'] == 'dkgl'){
  263. $result = get_article_dkgl_list($page);
  264. $maxpage = ceil($result['count'] / 10);
  265. }elseif($_GET['type'] == 'dkzx'){
  266. $result = get_article_dkzx_list($page);
  267. $maxpage = ceil($result['count'] / 10);
  268. }elseif($_GET['type'] == 'cjwt'){
  269. $result = get_article_cjwt_list($page);
  270. $maxpage = ceil($result['count'] / 10);
  271. }else{
  272. showmessage('dzapp_haodai:param_wrong');
  273. }
  274. if(defined('IN_MOBILE')){
  275. $pageinfo = '<div class="Pbottom"><div class="Pbottom_nei auto w85 no">';
  276. if($page != 1){
  277. $pageinfo .= '<a href="'.rewrite_list($_GET['type'], $page - 1).'" class="NextPage fl"><span class="BackPage_box Page_box auto"><span class="BackPage_box_icon Page_box_icon iconbox touming"></span><span class="Page_box_word fr">'.lang('plugin/dzapp_haodai','page_2').'</span><div class="clear"></div></span></a>';
  278. }else{
  279. $pageinfo .= '<span class="no fl"><span class="BackPage_box Page_box auto"><span class="BackPage_box_icon Page_box_icon iconbox touming"></span><span class="Page_box_word fr">'.lang('plugin/dzapp_haodai','page_2').'</span><div class="clear"></div></span></span>';
  280. }
  281. if($page < 3){
  282. $startpage = 1;
  283. }elseif($maxpage - $page < 2){
  284. $startpage = $maxpage - 4;
  285. }else{
  286. $startpage = $page - 2;
  287. }
  288. $pageinfo .= '<span class="page_number fl"><select class="number_con" name="jumpMenu" id="jumpMenu" onchange="location.href=this.value;">';
  289. for($i=$startpage;$i <= $startpage + 4; $i++){
  290. $pageinfo .= '<option'.(($i == $page) ? ' selected' : '').' value="'.rewrite_list($_GET['type'], $i).'">'.$i.'</option>';
  291. }
  292. $pageinfo .= '</select></span>';
  293. if($page != $maxpage){
  294. $pageinfo .= '<a href="'.rewrite_list($_GET['type'], $page + 1).'" class="NextPage fl"><span class="NextPage_box Page_box auto"><span class="Page_box_word fl">'.lang('plugin/dzapp_haodai','page_3').'</span><span class="NextPage_box_icon Page_box_icon iconbox"></span><div class="clear"></div></span></a>';
  295. }else{
  296. $pageinfo .= '<span class="no fl"><span class="NextPage_box Page_box auto"><span class="Page_box_word fl">'.lang('plugin/dzapp_haodai','page_3').'</span><span class="NextPage_box_icon Page_box_icon iconbox"></span><div class="clear"></div></span></span>';
  297. }
  298. $pageinfo .= '<div class="clear"></div></div></div>';
  299. }else{
  300. if($page != 1){
  301. $pageinfo = '<a href="'.rewrite_list($_GET['type'], 1).'" class="nextpage">'.lang('plugin/dzapp_haodai','page_1').'</a><a href="'.rewrite_list($_GET['type'], $page - 1).'" class="nextpage">'.lang('plugin/dzapp_haodai','page_2').'</a>';
  302. }else{
  303. $pageinfo = '';
  304. }
  305. if($page < 3){
  306. $startpage = 1;
  307. }elseif($maxpage - $page < 2){
  308. $startpage = $maxpage - 4;
  309. }else{
  310. $startpage = $page - 2;
  311. }
  312. for($i=$startpage;$i <= $startpage + 4; $i++){
  313. if($i == $page){
  314. $pageinfo .= '<span class="pageon">'.$page.'</span>';
  315. }else{
  316. $pageinfo .= '<a href="'.rewrite_list($_GET['type'], $i).'" class="pageoff">'.$i.'</a>';
  317. }
  318. }
  319. if($page != $maxpage){
  320. $pageinfo .= '<a href="'.rewrite_list($_GET['type'], $page + 1).'" class="nextpage">'.lang('plugin/dzapp_haodai','page_3').'</a><a href="'.rewrite_list($_GET['type'], $maxpage).'" class="nextpage">'.lang('plugin/dzapp_haodai','page_4').'</a>';
  321. }
  322. }
  323. if(empty($result['items'])) showmessage('dzapp_haodai:param_wrong');
  324. $articles = $result['items'];
  325. include template('dzapp_haodai:list');
  326. }elseif($action == 'calc'){
  327. $type = $_GET['type'];
  328. if(!in_array($type, array('chedai', 'debj', 'debx', 'esjys', 'fd', 'gjj', 'secondhand', 'zhdk'))) showmessage('dzapp_haodai:param_wrong');
  329. if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkgl_'.$city.'.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_dkgl_'.$city.'.php') > $var['refreshtime']){
  330. $dkgl_article = get_article_dkgl_list();
  331. writetocache('dzapp_haodai_dkgl_'.$city, getcachevars(array('dkgl_article' => $dkgl_article)));
  332. }
  333. $seodata = array('bbname' => $_G['setting']['bbname'], 'calc_type' => lang('plugin/dzapp_haodai','calc_'.$type));
  334. list($navtitle, $metadescription, $metakeywords) = get_seosetting('', $seodata, $dzapp_haodai_seo['calc']);
  335. if(defined('IN_MOBILE') && $type == 'fd'){
  336. $script_more = '
  337. var $btnss = $(\'.btn-b\');
  338. var $tables = $btnss.siblings(\'.int_table\');
  339. $btnss.click(
  340. function() {
  341. if ($tables.hasClass(\'hide-table\')) {
  342. $tables.removeClass(\'hide-table\');
  343. $(this).html(\''.lang('plugin/dzapp_haodai','hide-table').'\');
  344. } else
  345. {
  346. $tables.addClass(\'hide-table\');
  347. $(this).html(\''.lang('plugin/dzapp_haodai','check-more').'\');
  348. }
  349. });';
  350. }
  351. include template('dzapp_haodai:calc_'.$type);
  352. }elseif($action == 'fastloan'){
  353. if(submitcheck('applysubmit')){
  354. if(!$_GET['mobile'] || !$_GET['nickname'] || !$_GET['money']) showmessage('dzapp_haodai:apply_incomplete');
  355. $_GET['nickname'] = diconv($_GET['nickname'], CHARSET, 'UTF-8');
  356. $_GET['money'] = intval($_GET['money']);
  357. if(!is_numeric($_GET['mobile'])) showmessage('dzapp_haodai:mobile_be_int');
  358. $result = arrayCoding($client->send_xindai_apply($city, $_GET['nickname'], $_GET['money'], $_GET['mobile']), 'UTF-8', CHARSET);
  359. if($result['rs_code'] != '1000') showmessage(lang('plugin/dzapp_haodai','apply_fail').$result['rs_msg']);
  360. showmessage('dzapp_haodai:apply_succeed','plugin.php?id=dzapp_haodai');
  361. }else{
  362. $navtitle = lang('plugin/dzapp_haodai','fastloan');
  363. include template('dzapp_haodai:fastloan');
  364. }
  365. }
  366. ?>