These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /************************************************************************/ |
||
3 | /* Donations - Paypal financial management module for Xoops 2 */ |
||
4 | /* Copyright (c) 2016 XOOPS Project */ |
||
5 | /* http://dev.xoops.org/modules/xfmod/project/?group_id=1060 */ |
||
6 | /* |
||
7 | /************************************************************************/ |
||
8 | /* */ |
||
9 | /* Based on NukeTreasury for PHP-Nuke - by Dave Lawrence AKA Thrash */ |
||
10 | /* NukeTreasury - Financial management for PHP-Nuke */ |
||
11 | /* Copyright (c) 2004 by Dave Lawrence AKA Thrash */ |
||
12 | /* [email protected] */ |
||
13 | /* [email protected] */ |
||
14 | /* */ |
||
15 | /************************************************************************/ |
||
16 | /* */ |
||
17 | /* This program is free software; you can redistribute it and/or modify */ |
||
18 | /* it under the terms of the GNU General Public License as published by */ |
||
19 | /* the Free Software Foundation; either version 2 of the License. */ |
||
20 | /* */ |
||
21 | /* This program is distributed in the hope that it will be useful, but */ |
||
22 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ |
||
23 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ |
||
24 | /* General Public License for more details. */ |
||
25 | /* */ |
||
26 | /* You should have received a copy of the GNU General Public License */ |
||
27 | /* along with this program; if not, write to the Free Software */ |
||
28 | /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ |
||
29 | /* USA */ |
||
30 | /************************************************************************/ |
||
31 | |||
32 | include __DIR__ . '/header.php'; |
||
33 | include_once dirname(__DIR__) . '/include/functions.php'; |
||
34 | $xoopsOption['template_main'] = 'donations_main.tpl'; |
||
35 | include XOOPS_ROOT_PATH . '/header.php'; |
||
36 | |||
37 | $tr_config = configInfo(); //load the module configuration settings |
||
38 | $paypal_url = explode('|', $tr_config['paypal_url']); |
||
39 | $paypal_url = $paypal_url[0]; |
||
40 | |||
41 | //determine the currency |
||
42 | $PP_CURR_CODE = explode('|', $tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR] |
||
43 | $PP_CURR_CODE = $PP_CURR_CODE[0]; |
||
44 | $currencySign = defineCurrency($PP_CURR_CODE); |
||
45 | |||
46 | $swingd = $tr_config['swing_day']; |
||
47 | $PP_RECEIVER_EMAIL = $tr_config['receiver_email']; |
||
48 | $PP_ITEMNAME = $tr_config['pp_itemname']; |
||
49 | $PP_TY_URL = $tr_config['ty_url']; |
||
50 | $PP_CANCEL_URL = $tr_config['pp_cancel_url']; |
||
51 | |||
52 | // Fill out some more template tags |
||
53 | $DON_BUTTON_SUBMIT = $tr_config['don_button_submit']; |
||
54 | |||
55 | $PP_NO_SHIP = $tr_config['pp_get_addr'] ? '0' : '1'; |
||
56 | $PP_IMAGE_URL = $tr_config['pp_image_url']; |
||
57 | |||
58 | $DON_SUB_IMG_DIMS = ''; |
||
59 | if (is_numeric($tr_config['don_sub_img_width'])) { |
||
60 | $DON_SUB_IMG_DIMS .= 'width=' . $tr_config['don_sub_img_width'] . ' '; |
||
61 | } |
||
62 | if (is_numeric($tr_config['don_sub_img_height'])) { |
||
63 | $DON_SUB_IMG_DIMS .= 'height=' . $tr_config['don_sub_img_height'] . ' '; |
||
64 | } |
||
65 | |||
66 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_text'"; |
||
67 | $Recordset = $xoopsDB->query($sql); |
||
68 | $row = $xoopsDB->fetchArray($Recordset); |
||
69 | $DON_TEXT = $row['text']; |
||
70 | |||
71 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name='don_amount' ORDER BY subtype"; |
||
72 | $Recordset1 = $xoopsDB->query($sql); |
||
73 | |||
74 | $DONATION_AMOUNTS = ''; |
||
75 | View Code Duplication | while (false != ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))) { |
|
0 ignored issues
–
show
|
|||
76 | if (is_numeric($row_Recordset1['value']) && $row_Recordset1['value'] > 0) { |
||
77 | if ($row_Recordset1['subtype'] == $tr_config['don_amt_checked']) { |
||
78 | $checked = ' selected'; |
||
79 | $xoopsTpl->assign('BASEDONATION', $row_Recordset1['value']); |
||
80 | } else { |
||
81 | $checked = ''; |
||
82 | } |
||
83 | $DONATION_AMOUNTS .= '<option value="' . $row_Recordset1['value'] . '" ' . $checked . ' > ' . $currencySign . $row_Recordset1['value'] . '</option>' . "\n"; |
||
84 | } |
||
85 | } |
||
86 | $DONATION_AMOUNTS .= '<option value="0"> ' . _MD_DON_OTHER . ' </option>'; |
||
87 | |||
88 | $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||
89 | |||
90 | // Ok, output the page |
||
91 | |||
92 | $xoopsTpl->assign('CUSTOM', $uid); |
||
93 | $xoopsTpl->assign('DON_TITLE', _MD_DON_TITLE); |
||
94 | $xoopsTpl->assign('PP_RECEIVER_EMAIL', $PP_RECEIVER_EMAIL); |
||
95 | $xoopsTpl->assign('PP_ITEMNAME', $PP_ITEMNAME); |
||
96 | $xoopsTpl->assign('DONATION_AMOUNTS', $DONATION_AMOUNTS); |
||
97 | $xoopsTpl->assign('DON_TEXT', $DON_TEXT); |
||
98 | $xoopsTpl->assign('DON_NAME_YES', $tr_config['don_name_yes']); |
||
99 | $xoopsTpl->assign('DON_NAME_NO', $tr_config['don_name_no']); |
||
100 | $xoopsTpl->assign('PP_NO_SHIP', $PP_NO_SHIP); |
||
101 | $xoopsTpl->assign('PP_CURR_CODE', $PP_CURR_CODE); |
||
102 | $xoopsTpl->assign('PP_CANCEL_URL', $PP_CANCEL_URL); |
||
103 | $xoopsTpl->assign('PP_TY_URL', $PP_TY_URL); |
||
104 | $xoopsTpl->assign('PP_IMAGE_URL', $PP_IMAGE_URL); |
||
105 | $xoopsTpl->assign('DON_SUB_IMG_DIMS', $DON_SUB_IMG_DIMS); |
||
106 | $xoopsTpl->assign('DON_BUTTON_SUBMIT', $DON_BUTTON_SUBMIT); |
||
107 | $xoopsTpl->assign('MAKEADON', _MD_DON_MAKEADON); |
||
108 | $xoopsTpl->assign('SELECTAMT', _MD_DON_SELECTAMT); |
||
109 | $xoopsTpl->assign('SHOWNAME', $tr_config['don_name_prompt']); |
||
110 | $xoopsTpl->assign('DONTHISMONTH', _MD_DON_DONTHISMONTH); |
||
111 | $xoopsTpl->assign('DON_NAME', _MD_DON_NAME); |
||
112 | $xoopsTpl->assign('DON_DIR', $xoopsModule->getVar('dirname')); |
||
113 | $xoopsTpl->assign('SUBMIT_BUTTON', _MD_DON_SUBMIT_BUTTON); |
||
114 | $xoopsTpl->assign('PAYPAL_URL', $paypal_url); |
||
115 | |||
116 | include __DIR__ . '/footer.php'; |
||
117 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.