Issues (1149)

addcoupon.php (9 issues)

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
/*
22
* This file handles the addition of coupons to listings.
23
* Accessible to listing owners and administrators only.
24
*/
25
26
include __DIR__ . '/header.php';
27
$myts = MyTextSanitizer::getInstance(); // MyTextSanitizer object
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. 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...
28
require_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
29
require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php';
30
require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
31
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
32
require_once __DIR__ . '/class/class.formimage.php';
33
require_once __DIR__ . '/class/class.image.php';
34
require_once __DIR__ . '/class/class.couponhandler.php';
35
36
$eh = new ErrorHandler; //ErrorHandler object
0 ignored issues
show
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...
37
38
$moddir = $xoopsModule->getVar('dirname');
39
$mytree = new XoopsTree($xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat'), 'cid', 'pid');
0 ignored issues
show
The type XoopsTree 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...
40
41
//$moddir = $xoopsModule->getvar("dirname");
42
$couponid = isset($_GET['couponid']) ? (int)$_GET['couponid'] : 0;
43
if (isset($_POST['itemid'])) {
44
    $itemid = (int)$_POST['itemid'];
45
} elseif (isset($_GET['item'])) {
46
    $itemid = (int)$_GET['item'];
47
} else {
48
    $itemid = 0;
49
}
50
51
if (empty($xoopsUser) || !$xoopsUser->isAdmin($xoopsModule->mid()) || ($itemid == 0 && empty($_POST['delete']))) {
52
    redirect_header('index.php', 3, _NOPERM);
0 ignored issues
show
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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

52
    /** @scrutinizer ignore-call */ redirect_header('index.php', 3, _NOPERM);
Loading history...
53
    exit();
54
}
55
56
if (isset($_POST['lbr'])) {
57
    $lbr = (int)$_POST['lbr'];
58
} else {
59
    $lbr = 0;
60
}
61
if ($couponid > 0) {
62
    $coupon = new efqCouponHandler();
63
    $coupon->get($couponid);
64
    //$couponid = $coupon->couponid;
65
    $myts        = MyTextSanitizer::getInstance();
66
    $lbr         = $coupon->lbr;
67
    $description = $coupon->descr;
68
    $image       = $coupon->image;
0 ignored issues
show
The property image does not seem to exist on efqCouponHandler.
Loading history...
69
    $heading     = $coupon->heading;
70
    $publish     = $coupon->publish > 0 ? $coupon->publish : time();
71
    $expire      = $coupon->expire;
72
    $dohtml      = 1;
73
    $dobr        = $lbr;
74 View Code Duplication
    if ($expire > 0) {
75
        $setexpire = 1;
76
    } else {
77
        $setexpire = 0;
78
        $expire    = time() + 3600 * 24 * 7;
79
    }
80
} else {
81
    $itemid      = isset($_POST['itemid']) ? (int)$_POST['itemid'] : (isset($_GET['item']) ? (int)$_GET['item'] : 0);
82
    $couponid    = isset($_POST['couponid']) ? (int)$_POST['couponid'] : null;
83
    $description = isset($_POST['description']) ? $_POST['description'] : '';
84
    $publish     = isset($_POST['publish']) ? $_POST['publish'] : 0;
85
    $image       = isset($_POST['image']) ? $_POST['image'] : '';
86
    $expire      = isset($_POST['expire']) ? $_POST['expire'] : 0;
87
    $heading     = isset($_POST['heading']) ? $_POST['heading'] : '';
88 View Code Duplication
    if ($expire > 0) {
89
        $setexpire = 1;
90
    } else {
91
        $setexpire = 0;
92
        $expire    = time() + 3600 * 24 * 7;
93
    }
94
}
95
96
if (!empty($_POST['submit'])) {
97
    $coupon = new efqCouponHandler();
98
    if (isset($_POST['couponid'])) {
99
        $couponid = (int)$_POST['couponid'];
100
        $message  = _MD_COUPONEDITED;
101
    } else {
102
        $coupon->_new = true;
103
        $message      = _MD_COUPONADDED;
104
    }
105
    if (!$coupon->create()) {
106
        $coupon->message = _MD_ERR_ADDCOUPON;
0 ignored issues
show
The constant _MD_ERR_ADDCOUPON was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
107
    }
108
    redirect_header('listing.php?item=' . $itemid, 2, $coupon->message);
109
    exit();
110
} elseif (!empty($_POST['delete'])) {
111
    if (!empty($_POST['ok'])) {
112
        if (empty($_POST['couponid'])) {
113
            redirect_header('index.php', 2, _MD_ERR_COUPONIDMISSING);
114
            exit();
115
        }
116
        $coupon   = new efqCouponHandler();
117
        $couponid = (int)$_POST['couponid'];
118
        if ($coupon->delete($couponid)) {
119
            redirect_header('listing.php?item=' . $itemid, 2, _MD_COUPONDELETED);
120
            exit();
121
        }
122
    } else {
123
        include XOOPS_ROOT_PATH . '/header.php';
124
        xoops_confirm(array('delete' => 'yes', 'couponid' => $couponid, 'ok' => 1), 'addcoupon.php?item=' . $itemid . '', _MD_COUPONRUSURE);
0 ignored issues
show
The function xoops_confirm 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

124
        /** @scrutinizer ignore-call */ xoops_confirm(array('delete' => 'yes', 'couponid' => $couponid, 'ok' => 1), 'addcoupon.php?item=' . $itemid . '', _MD_COUPONRUSURE);
Loading history...
125
        require_once XOOPS_ROOT_PATH . '/footer.php';
126
        exit();
127
    }
128
}
129
include XOOPS_ROOT_PATH . '/header.php';
130
include __DIR__ . '/include/couponform.php';
131
require_once XOOPS_ROOT_PATH . '/footer.php';
132