orderselect()   A
last analyzed

Complexity

Conditions 4
Paths 0

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 14
nc 0
nop 0
dl 0
loc 19
rs 9.2
c 0
b 0
f 0
1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      efqdirectory
16
 * @since
17
 * @author       Martijn Hertog (aka wtravel)
18
 * @author       XOOPS Development Team,
19
 */
20
21
include __DIR__ . '/header.php';
22
$myts = MyTextSanitizer::getInstance();// MyTextSanitizer object
0 ignored issues
show
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
require_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
24
require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php';
25
require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
26
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
27
require_once __DIR__ . '/class/class.subscription.php';
28
require_once __DIR__ . '/class/class.formradio.php';
29
30
$eh           = new ErrorHandler;
0 ignored issues
show
Bug introduced by
The type ErrorHandler 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
$subscription = new efqSubscription();
32
33 View Code Duplication
if (isset($_GET['op'])) {
0 ignored issues
show
Duplication introduced by
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.

Loading history...
34
    $op = $_GET['op'];
35
} elseif (isset($_POST['op'])) {
36
    $op = $_POST['op'];
37
} else {
38
    $op = '';
39
}
40
41
$moddir = $xoopsModule->getVar('dirname');
42
43 View Code Duplication
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
0 ignored issues
show
Duplication introduced by
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.

Loading history...
44
    $isadmin = true;
45
} else {
46
    $isadmin = false;
47
}
48
49
if (!empty($_GET['item'])) {
50
    $get_itemid = (int)$_GET['item'];
51
} else {
52
    $get_itemid = '0';
53
}
54
55
$owner = getUserIdFromItem($get_itemid);
0 ignored issues
show
Bug introduced by
It seems like $get_itemid can also be of type string; however, parameter $item of getUserIdFromItem() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

55
$owner = getUserIdFromItem(/** @scrutinizer ignore-type */ $get_itemid);
Loading history...
56
57
if ($xoopsUser->getVar('uid') == $owner) {
58
    $editrights = '1';
59
} else {
60
    $editrights = '0';
61
    redirect_header("listing.php?itemid=$get_itemid", 2, _MD_EDITRIGHTS);
0 ignored issues
show
Bug introduced by
The constant _MD_EDITRIGHTS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
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 ignore-call  annotation

61
    /** @scrutinizer ignore-call */ redirect_header("listing.php?itemid=$get_itemid", 2, _MD_EDITRIGHTS);
Loading history...
62
    exit();
63
}
64
65
function showsubscription()
66
{
67
    global $xoopsDB, $eh, $myts, $moddir, $get_itemid, $owner, $xoopsOption, $xoopsTpl, $subscription, $xoopsUser;
68
    //Check if item selected.
69
    if ($get_itemid == '0') {
70
        redirect_header('index.php', 2, _MD_NOVALIDITEM);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

70
        /** @scrutinizer ignore-call */ redirect_header('index.php', 2, _MD_NOVALIDITEM);
Loading history...
71
        exit();
72
    }
73
74
    //Default function (if listing type is normal) would be to view the possible subscriptions.
75
76
    //Show current subscription order for listing
77
    $defaultstartdate = time();
78
    $sql              = 'SELECT i.title, i.typeid, o.orderid, o.offerid, o.startdate, o.enddate, o.billto, o.status, o.itemid, o.autorenew, t.typename, p.ref, p.payment_status FROM '
79
                        . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_itemtypes')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $module seems to be never defined.
Loading history...
80
                        . ' t,  '
81
                        . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items')
82
                        . ' i, '
83
                        . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_orders')
84
                        . ' o LEFT JOIN '
85
                        . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_payments')
86
                        . ' p ON (o.orderid=p.orderid) WHERE o.typeid = t.typeid AND o.itemid=p.ref AND o.itemid=i.itemid AND i.itemid='
87
                        . $get_itemid
88
                        . ' ORDER BY t.typelevel ASC';
89
    $item_result      = $xoopsDB->query($sql) or $eh->show('0013');
90
    $numrows          = $xoopsDB->getRowsNum($item_result);
91
    $order_exists     = false;
92
    if ($numrows > 0) {
93
        $xoopsTpl->assign('order_table', true);
94
        while (list($title, $typeid, $orderid, $offerid, $startdate, $enddate, $billto, $orderstatus, $itemid, $autorenew, $typename, $ref, $paymentstatus) = $xoopsDB->fetchRow($item_result)) {
95
            //Assign the text of the label for subscription type.
96
            $ordername = $subscription->getOrderItemName($offerid);
97
98
            if ($paymentstatus == '') {
99
                $paymentstatus = _MD_LANG_INCOMPLETE;
100
                $terminate_on  = '1';
101
            } else {
102
                $terminate_on = null;
103
                $order_exists = true;
104
            }
105
            if ($orderstatus == '1') {
106
                $defaultstartdate = $billto;
107
            }
108
            if ($billto != '') {
109
                $billto = date('d-M-Y', $billto);
110
            }
111
            if ($enddate != '') {
112
                $enddate = date('d-M-Y', $enddate);
113
            }
114
            if ($startdate != '') {
115
                $startdate = date('d-M-Y', $startdate);
116
            }
117
            $xoopsTpl->assign('lang_subscr_offers_header', _MD_LANG_SUBSCR_ACTIVE_ORDERS_HEADER);
118
            $xoopsTpl->append('active_orders', array(
119
                'orderid'       => $orderid,
120
                'ordername'     => $ordername,
121
                'offerid'       => $offerid,
122
                'startdate'     => $startdate,
123
                'enddate'       => $enddate,
124
                'billto'        => $billto,
125
                'orderstatus'   => $orderstatus,
126
                'itemid'        => $itemid,
127
                'autorenew'     => $autorenew,
128
                'typename'      => $myts->htmlSpecialChars($typename),
129
                'ref'           => $ref,
130
                'paymentstatus' => $paymentstatus,
131
                'renewal_url'   => "subscriptions.php?op=renew&order=$orderid&item=$get_itemid",
132
                'terminate_url' => "subscriptions.php?op=terminate&order=$orderid&item=$get_itemid",
133
                'terminate_on'  => $terminate_on
134
            ));
135
            $xoopsTpl->assign('lang_current_subscr', _MD_LANG_CURRENT_SUBSCR);
136
            $xoopsTpl->assign('current_subscr', $typename);
137
            $xoopsTpl->assign('lang_terminate_order', _MD_LANG_TERMINATE_ORDER);
138
            $xoopsTpl->assign('lang_terminate_order_alt', _MD_LANG_TERMINATE_ORDER_ALT);
139
            $xoopsTpl->assign('lang_renew_subscription', _MD_LANG_RENEW_SUBSCRIPTION);
140
            $xoopsTpl->assign('lang_renew_subscription_alt', _MD_LANG_RENEW_SUBSCRIPTION_ALT);
141
            //$xoopsTpl->assign('renewal_url', "subscriptions.php?op=renew");
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
142
143
            $xoopsTpl->assign('lang_ordername', _MD_LANG_ORDERNAME);
144
            $xoopsTpl->assign('lang_startdate', _MD_LANG_STARTDATE);
145
            $xoopsTpl->assign('lang_billtodate', _MD_LANG_BILLTO);
146
            $xoopsTpl->assign('lang_enddate', _MD_LANG_ENDDATE);
147
            $xoopsTpl->assign('lang_paymentstatus', _MD_LANG_PAYMENTSTATUS);
148
            $xoopsTpl->assign('lang_actions', _MD_LANG_ACTIONS);
149
            $xoopsTpl->assign('moddir', $moddir);
150
            $listingtitle = $myts->htmlSpecialChars($title);
0 ignored issues
show
Unused Code introduced by
The assignment to $listingtitle is dead and can be removed.
Loading history...
151
        }
152
    } else {
153
        $xoopsTpl->assign('lang_no_subscr_moment', _MD_LANG_NO_SUBSCR_MOMENT);
154
    }
155
    ob_start();
156
    if ($order_exists) {
157
        $order_form_title = _MD_UPDATE_SUBSCR_FORM;
158
    } else {
159
        $order_form_title = _MD_SUBSCR_FORM;
160
    }
161
    $form            = new XoopsThemeForm($order_form_title, 'subscribeform', 'subscriptions.php?item=' . $get_itemid . '');
0 ignored issues
show
Bug introduced by
The type XoopsThemeForm 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
162
    $duration_arr    = $subscription->durationPriceArray('1');
163
    $itemtype_select = new efqFormRadio(_MD_SUBSCR_TYPE, 'typeofferid', null, '<br>');
164
    $itemtype_select->addOptionArray($duration_arr);
165
    $form->addElement($itemtype_select, true);
166
    //TO DO: Add Auto Renew functionality
167
    //$form->addElement(new XoopsFormRadioYN(_MD_AUTORENEWYN, 'autorenewal', '1'),true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
168
    $form->addElement(new XoopsFormTextDateSelect(_MD_SELECT_STARTDATE, 'startdate', 15, $defaultstartdate), true);
0 ignored issues
show
Bug introduced by
The type XoopsFormTextDateSelect 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
169
    $form->addElement(new XoopsFormButton('', 'submit', _MD_CONTINUE, 'submit'));
0 ignored issues
show
Bug introduced by
The type XoopsFormButton 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
170
    $form->addElement(new XoopsFormHidden('op', 'orderselect'));
0 ignored issues
show
Bug introduced by
The type XoopsFormHidden 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
171
    $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid')));
172
    $form->display();
173
    $orderform = ob_get_contents();
174
    ob_end_clean();
175
    $xoopsTpl->assign('orderform', $orderform);
176
}
177
178
function orderselect()
179
{
180
    //function to update subscription by creating an order or updating an order.
181
    global $xoopsDB, $eh, $myts, $moddir, $get_itemid, $owner, $xoopsOption, $xoopsTpl, $subscription, $xoopsUser;
182
    if ($get_itemid == '0') {
183
        redirect_header('index.php', 2, _MD_NOVALIDITEM);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

183
        /** @scrutinizer ignore-call */ redirect_header('index.php', 2, _MD_NOVALIDITEM);
Loading history...
184
        exit();
185
    }
186
    $orderid = $subscription->createOrder($get_itemid);
187
    if ($orderid === false) {
188
        redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_SUBSCR_TYPE_NOTSELECTED);
189
        exit();
190
    }
191
    if ($orderid != 0) {
192
        redirect_header("subscriptions.php?item=$get_itemid&op=orderpayment&orderid=$orderid", 2, _MD_SAVED);
193
        exit();
194
    } else {
195
        redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_ITEM_NOT_EXIST);
196
        exit();
197
    }
198
}
199
200
function orderpayment()
201
{
202
    global $xoopsDB, $eh, $myts, $moddir, $get_itemid, $owner, $xoopsOption, $xoopsTpl, $subscription, $xoopsUser;
203
    //Default function (if listing type is normal) would be to view the possible subscriptions.
204
205
    //Show current subscription for listing
206
    //If standard subscription: Show subcription offers plus link to upgrade
207 View Code Duplication
    if (!empty($_GET['orderid'])) {
0 ignored issues
show
Duplication introduced by
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.

Loading history...
208
        $get_orderid = (int)$_GET['orderid'];
209
    } else {
210
        redirect_header('index.php', 2, _MD_NOVALIDITEM);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

210
        /** @scrutinizer ignore-call */ redirect_header('index.php', 2, _MD_NOVALIDITEM);
Loading history...
211
        exit();
212
    }
213
    $sql          = 'SELECT o.orderid, o.uid, o.offerid, o.typeid, o.startdate, o.billto, o.status, o.itemid, o.autorenew, f.price, f.currency FROM '
214
                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_orders')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $module seems to be never defined.
Loading history...
215
                    . ' o, '
216
                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_offers')
217
                    . ' f WHERE o.offerid=f.offerid AND o.orderid='
218
                    . $get_orderid
219
                    . '';
220
    $order_result = $xoopsDB->query($sql) or $eh->show('0013');
221
    $numrows      = $xoopsDB->getRowsNum($order_result);
222
    if ($numrows > 0) {
223
        while (list($orderid, $uid, $offerid, $typeid, $startdate, $billto, $status, $itemid, $autorenew, $price, $currency) = $xoopsDB->fetchRow($order_result)) {
224
            ob_start();
225
            $itemname = $subscription->getOrderItemName($offerid);
226
            $form     = new XoopsThemeForm(_MD_ORDER_PAYMENT_FORM, 'orderpaymentform', 'process.php');
227
            $form->addElement(new XoopsFormText(_MD_PAY_FIRSTNAME, 'firstname', 50, 150, ''));
0 ignored issues
show
Bug introduced by
The type XoopsFormText 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
228
            $form->addElement(new XoopsFormText(_MD_PAY_LASTNAME, 'lastname', 50, 150, ''));
229
            $form->addElement(new XoopsFormText(_MD_PAY_ADDRESS1, 'address1', 50, 150, ''));
230
            $form->addElement(new XoopsFormText(_MD_PAY_ADDRESS2, 'address2', 50, 150, ''));
231
            $form->addElement(new XoopsFormText(_MD_PAY_CITY, 'city', 50, 150, ''));
232
            $form->addElement(new XoopsFormText(_MD_PAY_STATE, 'state', 50, 150, ''));
233
            $form->addElement(new XoopsFormText(_MD_PAY_ZIP, 'zip', 15, 50, ''));
234
            $form->addElement(new XoopsFormText(_MD_PAY_EMAIL, 'email', 30, 150, ''));
235
            $form->addElement(new XoopsFormText(_MD_PAY_PHONE1, 'phone1', 30, 150, ''));
236
            $form->addElement(new XoopsFormLabel(_MD_PAY_WITH, '<img src="images/visa_mastercard.gif">'));
0 ignored issues
show
Bug introduced by
The type XoopsFormLabel 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
237
            $form->addElement(new XoopsFormHidden('phone2', ''));
238
            $form->addElement(new XoopsFormHidden('on0', ''));
239
            $form->addElement(new XoopsFormHidden('os0', ''));
240
            $form->addElement(new XoopsFormHidden('on1', ''));
241
            $form->addElement(new XoopsFormHidden('os1', ''));
242
            $form->addElement(new XoopsFormHidden('custom', $itemid));
243
244
            $form->addElement(new XoopsFormHidden('item_name', $itemname));
245
            $form->addElement(new XoopsFormHidden('item_number', $orderid));
246
            $form->addElement(new XoopsFormHidden('amount', $price));
247
            $form->addElement(new XoopsFormHidden('quantity', 1));
248
            $form->addElement(new XoopsFormHidden('shipping_amount', '0'));
249
            $form->addElement(new XoopsFormHidden('tax', '0'));
250
251
            $form->addElement(new XoopsFormButton('', 'submit', _MD_CONTINUE, 'submit'));
252
            $form->display();
253
            $paymentform = ob_get_contents();
254
            ob_end_clean();
255
            $xoopsTpl->assign('paymentform', $paymentform);
256
        }
257
258
        $xoopsTpl->assign('lang_subscribe', _MD_LANG_SUBSCRIBE);
259
        $xoopsTpl->assign('lang_subscr_payment', _MD_LANG_SUBSCR_PAYMENT);
260
        $xoopsTpl->assign('lang_subscribe', _MD_LANG_SUBSCRIBE);
261
        $xoopsTpl->assign('moddir', $moddir);
262
    } else {
263
        //Else this item cannot be found in the database.
264
        redirect_header("listing.php?itemid=$get_itemid", 2, _MD_ITEM_NOT_EXIST);
265
        exit();
266
    }
267
}
268
269
function terminate()
270
{
271
    global $xoopsDB, $eh, $myts, $moddir, $get_itemid, $editrights;
272
    if (!empty($_GET['order'])) {
273
        $get_orderid = (int)$_GET['order'];
274
    } else {
275
        redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_NOVALIDORDER);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

275
        /** @scrutinizer ignore-call */ redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_NOVALIDORDER);
Loading history...
276
        exit();
277
    }
278
    if ($editrights == '1') {
279
        $form = new XoopsThemeForm(_MD_CONFIRM_TERMINATE_TITLE, 'terminateform', 'subscriptions.php?item=' . $get_itemid . '');
280
        $form->addElement(new XoopsFormLabel(_MD_CONFIRMATION, _MD_CONFIRM_TERMINATION_TEXT));
281
        $form->addElement(new XoopsFormButton('', 'submit', _MD_CONTINUE, 'submit'));
282
        $form->addElement(new XoopsFormHidden('op', 'terminate_confirm'));
283
        $form->addElement(new XoopsFormHidden('orderid', $get_orderid));
284
        $form->display();
285
    } else {
286
        redirect_header("subscriptions.php?itemid=$get_itemid", 2, _MD_NORIGHTS);
287
        exit();
288
    }
289
}
290
291
function terminate_confirm()
292
{
293
    global $subscription, $get_itemid;
294
    if (isset($_POST['orderid'])) {
295
        $post_orderid = (int)$_POST['orderid'];
296
        if ($subscription->delete($post_orderid)) {
297
            redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_ORDER_DELETED);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

297
            /** @scrutinizer ignore-call */ redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_ORDER_DELETED);
Loading history...
298
            exit();
299
        }
300
    } else {
301
        redirect_header("subscriptions.php?item=$get_itemid", 2, _MD_NOVALIDORDER);
302
        exit();
303
    }
304
}
305
306
function renew()
307
{
308
    global $subscription, $get_itemid, $editrights;
309 View Code Duplication
    if (!empty($_GET['order'])) {
0 ignored issues
show
Duplication introduced by
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.

Loading history...
310
        $get_orderid = (int)$_GET['order'];
311
    } else {
312
        redirect_header('index.php', 2, _MD_NOVALIDITEM);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

312
        /** @scrutinizer ignore-call */ redirect_header('index.php', 2, _MD_NOVALIDITEM);
Loading history...
313
        exit();
314
    }
315
    if ($editrights == '1') {
316
        redirect_header("subscriptions.php?item=$get_itemid&op=orderpayment&orderid=$get_orderid", 2, _MD_FORWARDED_PAYMENT_PAGE);
317
        exit();
318
    }
319
}
320
321
switch ($op) {
322
    case 'upgrade':
323
        upgrade();
0 ignored issues
show
Bug introduced by
The function upgrade 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 ignore-call  annotation

323
        /** @scrutinizer ignore-call */ upgrade();
Loading history...
324
        break;
325
    case 'orderselect':
326
        orderselect();
327
        break;
328 View Code Duplication
    case 'orderpayment':
0 ignored issues
show
Duplication introduced by
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.

Loading history...
329
        $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
330
        include XOOPS_ROOT_PATH . '/header.php';
331
        orderpayment();
332
        $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
333
        break;
334 View Code Duplication
    case 'terminate':
0 ignored issues
show
Duplication introduced by
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.

Loading history...
335
        $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
336
        include XOOPS_ROOT_PATH . '/header.php';
337
        terminate();
338
        $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
339
        break;
340
    case 'terminate_confirm':
341
        include XOOPS_ROOT_PATH . '/header.php';
342
        terminate_confirm();
343
        break;
344
    case 'renew':
345
        include XOOPS_ROOT_PATH . '/header.php';
346
        renew();
347
        break;
348 View Code Duplication
    default:
0 ignored issues
show
Duplication introduced by
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.

Loading history...
349
        $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
350
        include XOOPS_ROOT_PATH . '/header.php';
351
        showsubscription();
352
        $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
353
        break;
354
}
355
356
include XOOPS_ROOT_PATH . '/footer.php';
357