XoopsModules25x /
suico
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||||||
| 2 | |||||||
| 3 | namespace XoopsModules\Suico\Form; |
||||||
| 4 | |||||||
| 5 | use XoopsFormButton; |
||||||
| 6 | use XoopsFormHidden; |
||||||
| 7 | use XoopsFormLabel; |
||||||
| 8 | use XoopsModules\Suico\{ |
||||||
| 9 | Helper, |
||||||
| 10 | Profile |
||||||
| 11 | }; |
||||||
| 12 | use XoopsThemeForm; |
||||||
| 13 | |||||||
| 14 | /** @var Helper $helper */ |
||||||
| 15 | |||||||
| 16 | /** |
||||||
| 17 | * Get {@link XoopsThemeForm} for registering new users |
||||||
| 18 | * |
||||||
| 19 | * @param Profile $profile |
||||||
| 20 | * @param XoopsUser $user {@link XoopsUser} to register |
||||||
| 21 | * @param int $step Which step we are at |
||||||
| 22 | * |
||||||
| 23 | * @return object |
||||||
| 24 | * @internal param \profileRegstep $next_step |
||||||
| 25 | */ |
||||||
| 26 | class RegisterForm extends XoopsThemeForm |
||||||
| 27 | { |
||||||
| 28 | /** |
||||||
| 29 | * RegisterForm constructor. |
||||||
| 30 | * @param \XoopsUser $user |
||||||
| 31 | * @param Profile $profile |
||||||
| 32 | * @param int|null $step |
||||||
| 33 | * @throws \Exception |
||||||
| 34 | */ |
||||||
| 35 | public function __construct(\XoopsUser $user, $profile, $step = null) |
||||||
| 36 | { |
||||||
| 37 | global $opkey; // should be set in register.php |
||||||
| 38 | if (empty($opkey)) { |
||||||
| 39 | $opkey = 'profile_opname'; |
||||||
| 40 | } |
||||||
| 41 | $next_opname = 'op' . \random_int(10000, 99999); |
||||||
| 42 | $_SESSION[$opkey] = $next_opname; |
||||||
| 43 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||||||
| 44 | if (empty($GLOBALS['xoopsConfigUser'])) { |
||||||
| 45 | /** @var \XoopsConfigHandler $configHandler */ |
||||||
| 46 | $configHandler = \xoops_getHandler('config'); |
||||||
| 47 | $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(\XOOPS_CONF_USER); |
||||||
| 48 | } |
||||||
| 49 | $action = $_SERVER['REQUEST_URI']; |
||||||
| 50 | $step_no = $step['step_no']; |
||||||
| 51 | $use_token = $step['step_no'] > 0; // ? true : false; |
||||||
| 52 | parent::__construct($step['step_name'], 'regform', $action, 'post', $use_token); |
||||||
| 53 | if ($step['step_desc']) { |
||||||
| 54 | $this->addElement(new XoopsFormLabel('', $step['step_desc'])); |
||||||
| 55 | } |
||||||
| 56 | if (1 == $step_no) { |
||||||
| 57 | //$uname_size = $GLOBALS['xoopsConfigUser']['maxuname'] < 35 ? $GLOBALS['xoopsConfigUser']['maxuname'] : 35; |
||||||
| 58 | $elements[0][] = [ |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||||||
| 59 | 'element' => new \XoopsFormText(\_MD_SUICO_NICKNAME, 'uname', 35, $GLOBALS['xoopsConfigUser']['maxuname'], $user->getVar('uname', 'e')), |
||||||
|
0 ignored issues
–
show
It seems like
$user->getVar('uname', 'e') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, 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
Loading history...
|
|||||||
| 60 | 'required' => true, |
||||||
| 61 | ]; |
||||||
| 62 | $weights[0][] = 0; |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 63 | $elements[0][] = ['element' => new \XoopsFormText(\_MD_SUICO_EMAILADDRESS, 'email', 35, 255, $user->getVar('email', 'e')), 'required' => true]; |
||||||
| 64 | $weights[0][] = 0; |
||||||
| 65 | $elements[0][] = ['element' => new \XoopsFormPassword(\_MD_SUICO_PASSWORD, 'pass', 35, 32, ''), 'required' => true]; |
||||||
| 66 | $weights[0][] = 0; |
||||||
| 67 | $elements[0][] = ['element' => new \XoopsFormPassword(\_US_VERIFYPASS, 'vpass', 35, 32, ''), 'required' => true]; |
||||||
| 68 | $weights[0][] = 0; |
||||||
| 69 | } |
||||||
| 70 | // Dynamic fields |
||||||
| 71 | $profileHandler = Helper::getInstance()->getHandler('Profile'); |
||||||
| 72 | $fields = $profileHandler->loadFields(); |
||||||
| 73 | $_SESSION['profile_required'] = []; |
||||||
| 74 | foreach (\array_keys($fields) as $i) { |
||||||
| 75 | if ($fields[$i]->getVar('step_id') == $step['step_id']) { |
||||||
| 76 | $fieldinfo['element'] = $fields[$i]->getEditElement($user, $profile); |
||||||
| 77 | //assign and check (=) |
||||||
| 78 | if ($fieldinfo['required'] = $fields[$i]->getVar('field_required')) { |
||||||
| 79 | $_SESSION['profile_required'][$fields[$i]->getVar('field_name')] = $fields[$i]->getVar('field_title'); |
||||||
| 80 | } |
||||||
| 81 | $key = $fields[$i]->getVar('cat_id'); |
||||||
| 82 | $elements[$key][] = $fieldinfo; |
||||||
| 83 | $weights[$key][] = $fields[$i]->getVar('field_weight'); |
||||||
| 84 | } |
||||||
| 85 | } |
||||||
| 86 | \ksort($elements); |
||||||
| 87 | // Get categories |
||||||
| 88 | $categoryHandler = \XoopsModules\Suico\Helper::getInstance()->getHandler('Category'); |
||||||
| 89 | $categories = $categoryHandler->getObjects(null, true, false); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 90 | foreach (\array_keys($elements) as $k) { |
||||||
| 91 | \array_multisort($weights[$k], \SORT_ASC, \array_keys($elements[$k]), \SORT_ASC, $elements[$k]); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
SORT_ASC cannot be passed to array_multisort() as the parameter $rest expects a reference.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
array_keys($elements[$k]) cannot be passed to array_multisort() as the parameter $rest expects a reference.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 92 | //$title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _MD_SUICO_DEFAULT; |
||||||
| 93 | //$desc = isset($categories[$k]) ? $categories[$k]['cat_description'] : ""; |
||||||
| 94 | //$this->insertBreak("<p>{$title}</p>{$desc}"); |
||||||
| 95 | //$this->addElement(new XoopsFormLabel("<h2>".$title."</h2>", $desc), false); |
||||||
| 96 | foreach (\array_keys($elements[$k]) as $i) { |
||||||
| 97 | $this->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']); |
||||||
| 98 | } |
||||||
| 99 | } |
||||||
| 100 | //end of Dynamic User fields |
||||||
| 101 | if (1 == $step_no && 0 != $GLOBALS['xoopsConfigUser']['reg_dispdsclmr'] && '' != $GLOBALS['xoopsConfigUser']['reg_disclaimer']) { |
||||||
| 102 | $disc_tray = new \XoopsFormElementTray(\_US_DISCLAIMER, '<br>'); |
||||||
| 103 | $disc_text = new \XoopsFormLabel('', '<div class="pad5">' . $GLOBALS['myts']->displayTarea($GLOBALS['xoopsConfigUser']['reg_disclaimer'], 1) . '</div>'); |
||||||
| 104 | $disc_tray->addElement($disc_text); |
||||||
| 105 | $agree_chk = new \XoopsFormCheckBox('', 'agree_disc'); |
||||||
| 106 | $agree_chk->addOption(1, \_US_IAGREE); |
||||||
| 107 | $disc_tray->addElement($agree_chk); |
||||||
| 108 | $this->addElement($disc_tray); |
||||||
| 109 | } |
||||||
| 110 | global $xoopsModuleConfig; |
||||||
| 111 | $useCaptchaAfterStep2 = $xoopsModuleConfig['profileCaptchaAfterStep1'] + 1; |
||||||
| 112 | if ($step_no <= $useCaptchaAfterStep2) { |
||||||
| 113 | $this->addElement(new \XoopsFormCaptcha(), true); |
||||||
| 114 | } |
||||||
| 115 | $this->addElement(new XoopsFormHidden($next_opname, 'register')); |
||||||
| 116 | $this->addElement(new XoopsFormHidden('uid', $user->getVar('uid'))); |
||||||
|
0 ignored issues
–
show
It seems like
$user->getVar('uid') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, 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
Loading history...
|
|||||||
| 117 | $this->addElement(new XoopsFormHidden('step', $step_no)); |
||||||
| 118 | $this->addElement(new XoopsFormButton('', 'submitButton', \_SUBMIT, 'submit')); |
||||||
| 119 | } |
||||||
| 120 | } |
||||||
| 121 |