1 | <?php |
||
2 | /** |
||
3 | * ExtGallery User area |
||
4 | * |
||
5 | * You may not change or alter any portion of this comment or credits |
||
6 | * of supporting developers from this source code or any supporting source code |
||
7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | * |
||
12 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
13 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
14 | * @author Zoullou (http://www.zoullou.net) |
||
15 | * @package ExtGallery |
||
16 | */ |
||
17 | |||
18 | use XoopsModules\Extgallery; |
||
19 | |||
20 | include __DIR__ . '/header.php'; |
||
21 | //require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php'; |
||
0 ignored issues
–
show
|
|||
22 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
23 | |||
24 | if (\Xmf\Request::hasVar('id', 'GET')) { |
||
25 | $photoId = \Xmf\Request::getInt('id', 0, 'GET'); |
||
26 | } else$photoId = \Xmf\Request::getInt('photo_id', 0, 'POST'); |
||
27 | if (isset($_POST['step'])) { |
||
28 | $step = $_POST['step']; |
||
29 | } else { |
||
30 | $step = 'default'; |
||
31 | } |
||
32 | /** @var Extgallery\PublicPhotoHandler $photoHandler */ |
||
33 | $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
||
34 | $photo = $photoHandler->getPhoto($photoId); |
||
35 | |||
36 | $permHandler = Extgallery\PublicPermHandler::getInstance(); |
||
37 | |||
38 | if (!$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_ecard', $photo->getVar('cat_id'))) { |
||
39 | redirect_header('index.php', 3, _MD_EXTGALLERY_NOPERM); |
||
40 | } |
||
41 | /** @var xos_opal_Theme $xoTheme */ |
||
42 | switch ($step) { |
||
43 | |||
44 | case 'send': |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
45 | |||
46 | // require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/php-captcha.inc.php'; |
||
47 | |||
48 | // Enable captcha only if GD is Used |
||
49 | if ('gd' === $helper->getConfig('graphic_lib')) { |
||
50 | if (!Extgallery\PhpCaptcha::Validate($_POST['captcha'])) { |
||
51 | redirect_header('public-photo.php?photoId=' . $photoId . '#photoNav', 3, _MD_EXTGALLERY_CAPTCHA_ERROR); |
||
52 | } |
||
53 | } |
||
54 | /** @var Extgallery\PublicEcardHandler $ecardHandler */ |
||
55 | $ecardHandler = Extgallery\Helper::getInstance()->getHandler('PublicEcard'); |
||
56 | /** @var Extgallery\PublicPhotoHandler $photoHandler */ |
||
57 | $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
||
58 | |||
59 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
||
60 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
||
61 | } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { |
||
62 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
||
63 | } else { |
||
64 | $ip = $_SERVER['REMOTE_ADDR']; |
||
65 | } |
||
66 | |||
67 | $data = [ |
||
68 | 'ecard_fromname' => $_POST['ecard_fromname'], |
||
69 | 'ecard_fromemail' => $_POST['ecard_fromemail'], |
||
70 | 'ecard_toname' => $_POST['ecard_toname'], |
||
71 | 'ecard_toemail' => $_POST['ecard_toemail'], |
||
72 | 'ecard_greetings' => $_POST['ecard_greetings'], |
||
73 | 'ecard_desc' => $_POST['ecard_desc'], |
||
74 | 'ecard_ip' => $ip, |
||
75 | 'photo_id' => $photoId |
||
76 | ]; |
||
77 | |||
78 | $ecardHandler->createEcard($data); |
||
79 | $photoHandler->updateEcard($photoId); |
||
80 | |||
81 | redirect_header('public-photo.php?photoId=' . $photoId . '#photoNav', 3, _MD_EXTGALLERY_ECARD_SENT); |
||
82 | |||
83 | break; |
||
84 | |||
85 | case 'default': |
||
86 | default: |
||
0 ignored issues
–
show
The default body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a default statement must start on the line immediately following the statement. switch ($expr) {
default:
doSomething(); //right
break;
}
switch ($expr) {
default:
doSomething(); //wrong
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
87 | |||
88 | $GLOBALS['xoopsOption']['template_main'] = 'extgallery_public-sendecard.tpl'; |
||
89 | include XOOPS_ROOT_PATH . '/header.php'; |
||
90 | |||
91 | if ('' != $photo->getVar('photo_serveur')) { |
||
92 | $photoUrl = $photo->getVar('photo_serveur') . 'thumb_' . $photo->getVar('photo_name'); |
||
93 | } else { |
||
94 | $photoUrl = XOOPS_URL . '/uploads/extgallery/public-photo/thumb/thumb_' . $photo->getVar('photo_name'); |
||
95 | } |
||
96 | |||
97 | $fromName = is_a($GLOBALS['xoopsUser'], 'XoopsUser') ? $GLOBALS['xoopsUser']->getVar('uname') : ''; |
||
98 | $fromEmail = is_a($GLOBALS['xoopsUser'], 'XoopsUser') ? $GLOBALS['xoopsUser']->getVar('email') : ''; |
||
99 | |||
100 | $form = new \XoopsThemeForm(_MD_EXTGALLERY_SEND_ECARD, 'send_ecard', 'public-sendecard.php', 'post', true); |
||
101 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_FROM_NAME, 'ecard_fromname', '70', '255', $fromName), false); |
||
102 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_FROM_EMAIL, 'ecard_fromemail', '70', '255', $fromEmail), false); |
||
103 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_TO_NAME, 'ecard_toname', '70', '255', ''), false); |
||
104 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_TO_EMAIL, 'ecard_toemail', '70', '255', ''), false); |
||
105 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_GREETINGS, 'ecard_greetings', '110', '255', ''), false); |
||
106 | $form->addElement(new \XoopsFormTextArea(_MD_EXTGALLERY_DESC, 'ecard_desc', ''), false); |
||
107 | // Enable captcha only if GD is Used |
||
108 | if ('gd' === $helper->getConfig('graphic_lib')) { |
||
109 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_SECURITY, 'captcha', '10', '5', ''), false); |
||
110 | } |
||
111 | $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
112 | $form->addElement(new \XoopsFormHidden('photo_id', $photoId)); |
||
113 | $form->addElement(new \XoopsFormHidden('step', 'send')); |
||
114 | $form->assign($xoopsTpl); |
||
115 | |||
116 | $xoopsTpl->assign('photo', $photoUrl); |
||
117 | $xoopsTpl->assign('xoops_pagetitle', 'Send ' . $photo->getVar('photo_desc') . ' to eCard'); |
||
118 | $xoTheme->addMeta('meta', 'description', $photo->getVar('photo_desc')); |
||
119 | |||
120 | $rel = 'alternate'; |
||
121 | $attributes['rel'] = $rel; |
||
122 | $attributes['type'] = 'application/rss+xml'; |
||
123 | $attributes['title'] = _MD_EXTGALLERY_RSS; |
||
124 | $attributes['href'] = XOOPS_URL . '/modules/extgallery/public-rss.php'; |
||
125 | $xoTheme->addMeta('link', $rel, $attributes); |
||
126 | $xoTheme->addStylesheet('modules/extgallery/assets/css/style.css'); |
||
127 | |||
128 | $lang = [ |
||
129 | 'to' => _MD_EXTGALLERY_TO, |
||
130 | 'from' => _MD_EXTGALLERY_FROM |
||
131 | ]; |
||
132 | $xoopsTpl->assign('lang', $lang); |
||
133 | |||
134 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
135 | |||
136 | break; |
||
137 | |||
138 | } |
||
139 |
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.