1 | <?php |
||||
2 | /* |
||||
3 | * ipn_success.php |
||||
4 | * |
||||
5 | * PHP Toolkit for PayPal v0.51 |
||||
6 | * http://www.paypal.com/pdn |
||||
7 | * |
||||
8 | * Copyright (c) 2004 PayPal Inc |
||||
9 | * |
||||
10 | * Released under Common Public License 1.0 |
||||
11 | * http://opensource.org/licenses/cpl.php |
||||
12 | * |
||||
13 | */ |
||||
14 | //include file - not accessible directly |
||||
15 | |||||
16 | if (isset($paypal['business'])) { |
||||
17 | //log successful transaction to file or database |
||||
18 | $now = time(); |
||||
19 | $values = create_local_variables(); |
||||
20 | $orderid = $values['item_number']; |
||||
21 | if (checkDuplicateTrx($values['txn_id'], $values['payment_status']) === true) { |
||||
22 | $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_payments') . '_id_seq'); |
||||
23 | $sql = 'INSERT INTO ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_payments') . " |
||||
24 | (id, txn_id, txn_type, orderid, payer_business_name, address_name, address_street, address_city, address_state, address_zip, address_country, address_status, payer_email, payer_id, payer_status, mc_currency, mc_gross, mc_fee, created, payment_date, ref, payment_status) VALUES |
||||
25 | ($newid, '$values[txn_id]', '$values[txn_type]', '$orderid', '$values[payer_business_name]', '$values[address_name]', '$values[address_street]', '$values[address_city]', '$values[address_state]', '$values[address_zip]', '$values[address_country]', '$values[address_status]', '$values[payer_email]', '$values[payer_id]', '$values[payer_status]', '$values[mc_currency]', '$values[mc_gross]', '$values[mc_fee]', $now, '$values[payment_date]', '$values[custom]', '$values[payment_status]')"; |
||||
26 | $xoopsDB->queryF($sql) or $eh->show('0013'); |
||||
27 | |||||
28 | if ($newid == 0) { |
||||
29 | $paymentid = $xoopsDB->getInsertId(); |
||||
30 | } |
||||
31 | |||||
32 | $subscription = new efqSubscription(); |
||||
33 | $ordervalues = $subscription->getOrderVars($orderid); |
||||
34 | if ($ordervalues['billto'] === '') { |
||||
35 | $current_billto = $ordervalues['startdate']; |
||||
36 | } else { |
||||
37 | $current_billto = $ordervalues['billto']; |
||||
38 | } |
||||
39 | $offervalues = $subscription->getOfferVars($ordervalues['offerid']); |
||||
40 | $count = $offervalues['count']; |
||||
41 | $duration = $offervalues['duration']; |
||||
42 | $date = getdate($current_billto); |
||||
43 | |||||
44 | switch ($duration) { |
||||
45 | View Code Duplication | case '1': |
|||
0 ignored issues
–
show
|
|||||
46 | $billto = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'] + (1 * $count), $date['year']); |
||||
47 | break; |
||||
48 | View Code Duplication | case '2': |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. ![]() |
|||||
49 | $billto = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'] + (7 * $count), $date['year']); |
||||
50 | break; |
||||
51 | View Code Duplication | case '3': |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. ![]() |
|||||
52 | $billto = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'] + (1 * $count), $date['mday'], $date['year']); |
||||
53 | break; |
||||
54 | View Code Duplication | case '4': |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. ![]() |
|||||
55 | $billto = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'] + (3 * $count), $date['mday'], $date['year']); |
||||
56 | break; |
||||
57 | View Code Duplication | case '5': |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. ![]() |
|||||
58 | $billto = mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'], $date['year'] + (1 * $count)); |
||||
59 | break; |
||||
60 | default: |
||||
61 | $billto = ''; |
||||
62 | } |
||||
63 | |||||
64 | if ($ordervalues['startdate'] < time() && $ordervalues['billto'] === '') { |
||||
65 | $subscription->changeItemType($ordervalues['itemid'], $ordervalues['typeid']); |
||||
66 | $subscription->updateOrder($orderid, '1', time(), $billto); |
||||
67 | } else { |
||||
68 | $subscription->updateOrder($orderid, '1', $ordervalues['startdate'], $billto); |
||||
69 | } |
||||
70 | redirect_header('subscriptions.php?item=' . $values['custom'] . '', 5, _MD_ORDER_PROCESSED); |
||||
0 ignored issues
–
show
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
71 | exit(); |
||||
72 | } else { |
||||
73 | redirect_header('subscriptions.php?item=' . $values['custom'] . '', 10, _MD_ORDER_ALREADY_PROCESSED); |
||||
74 | exit(); |
||||
75 | } |
||||
76 | } else { |
||||
77 | die('This page is not directly accessible'); |
||||
78 | } |
||||
79 | |||||
80 | /** |
||||
81 | * @param string $txn_id |
||||
82 | * @param string $payment_status |
||||
83 | * @return bool |
||||
84 | */ |
||||
85 | function checkDuplicateTrx($txn_id = '0', $payment_status = '0') |
||||
86 | { |
||||
87 | global $xoopsDB; |
||||
88 | $block = array(); |
||||
89 | $myts = MyTextSanitizer::getInstance(); |
||||
0 ignored issues
–
show
The type
MyTextSanitizer was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
90 | $userid = 0; |
||||
91 | $sql = 'SELECT txn_id, payment_status FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_payments') . " WHERE txn_id='$txn_id' AND payment_status='$payment_status'"; |
||||
92 | $result = $xoopsDB->query($sql); |
||||
93 | $num_results = $xoopsDB->getRowsNum($result); |
||||
94 | if (!$result) { |
||||
95 | return true; |
||||
96 | } elseif ($num_results == 0) { |
||||
97 | return true; |
||||
98 | } else { |
||||
99 | return false; |
||||
100 | } |
||||
101 | } |
||||
102 |
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.