mambax7 /
pedigree
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | // ------------------------------------------------------------------------- |
||
| 3 | |||
| 4 | require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
| 5 | |||
| 6 | /* |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% 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...
|
|||
| 7 | if (file_exists(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php")) { |
||
| 8 | require_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/" . $xoopsConfig['language'] . "/main.php"; |
||
| 9 | } else { |
||
| 10 | include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/language/english/main.php"; |
||
| 11 | } |
||
| 12 | */ |
||
| 13 | |||
| 14 | xoops_loadLanguage('main', basename(dirname(__DIR__))); |
||
| 15 | |||
| 16 | // Include any common code for this module. |
||
| 17 | require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); |
||
| 18 | |||
| 19 | $xoopsOption['template_main'] = "pedigree_adddog.tpl"; |
||
| 20 | |||
| 21 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 22 | $xoopsTpl->assign('page_title', "Pedigree database - Add owner/breeder"); |
||
| 23 | |||
| 24 | //check for access |
||
| 25 | $xoopsModule =& XoopsModule::getByDirname("pedigree"); |
||
| 26 | if (empty($xoopsUser)) { |
||
| 27 | redirect_header("index.php", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); |
||
| 28 | exit(); |
||
| 29 | } |
||
| 30 | |||
| 31 | $f = isset($_GET['f']) ? $_GET['f'] : ''; |
||
| 32 | if ($f == "check") { |
||
| 33 | check(); |
||
| 34 | } |
||
| 35 | |||
| 36 | function check() |
||
| 37 | { |
||
| 38 | global $xoopsTpl, $xoopsUser, $xoopsDB, $xoopsModuleConfig; |
||
| 39 | //check for access |
||
| 40 | $xoopsModule =& XoopsModule::getByDirname("pedigree"); |
||
| 41 | if (empty($xoopsUser)) { |
||
| 42 | redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); |
||
| 43 | exit(); |
||
| 44 | } |
||
| 45 | $achternaam = $_POST['achternaam']; |
||
| 46 | $voornaam = $_POST['voornaam']; |
||
| 47 | $email = $_POST['email']; |
||
| 48 | $website = $_POST['website']; |
||
| 49 | $user = $_POST['user']; |
||
| 50 | //insert into owner |
||
| 51 | $query = "INSERT INTO " . $xoopsDB->prefix("pedigree_owner") . " VALUES ('','" . $voornaam . "','" . $achternaam . "','','','','','','" . $email . "','" . $website . "','" . $user . "')"; |
||
| 52 | $xoopsDB->query($query); |
||
| 53 | redirect_header("index.php", 1, "The data has been stored."); |
||
| 54 | } |
||
| 55 | |||
| 56 | global $xoopsTpl, $xoopsUser, $xoopsDB; |
||
| 57 | //check for access |
||
| 58 | $xoopsModule =& XoopsModule::getByDirname("pedigree"); |
||
| 59 | if (empty($xoopsUser)) { |
||
| 60 | redirect_header("javascript:history.go(-1)", 3, _NOPERM . "<br />" . _MA_PEDIGREE_REGIST); |
||
| 61 | exit(); |
||
| 62 | } |
||
| 63 | //create form |
||
| 64 | include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; |
||
| 65 | $form = new XoopsThemeForm(_MA_PEDIGREE_ADD_OWNER, 'breedername', 'add_breeder.php?f=check', 'POST'); |
||
| 66 | $form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); |
||
| 67 | $form->addElement(new XoopsFormHidden('user', $xoopsUser->getVar("uid"))); |
||
| 68 | //lastname |
||
| 69 | $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_LNAME . "</b>", 'achternaam', $size = 50, $maxsize = 255, $value = '')); |
||
| 70 | |||
| 71 | //firstname |
||
| 72 | $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_FNAME . "</b>", 'voornaam', $size = 50, $maxsize = 255, $value = '')); |
||
| 73 | |||
| 74 | |||
| 75 | $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_EMAIL . "</b>", 'email', $size = 50, $maxsize = 255, $value = '')); |
||
| 76 | |||
| 77 | //website |
||
| 78 | $form->addElement(new XoopsFormText("<b>" . _MA_PEDIGREE_FLD_OWN_WEB . "</b>", 'website', $size = 50, $maxsize = 255, $value = '')); |
||
| 79 | $form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, _MA_PEDIGREE_FLD_OWN_WEB_EX)); |
||
| 80 | |||
| 81 | //submit button |
||
| 82 | $form->addElement(new XoopsFormButton('', 'button_id', _MA_PEDIGREE_ADD_OWNER, 'submit')); |
||
| 83 | |||
| 84 | //add data (form) to smarty template |
||
| 85 | $xoopsTpl->assign("form", $form->render()); |
||
| 86 | |||
| 87 | //footer |
||
| 88 | include XOOPS_ROOT_PATH . "/footer.php"; |
||
| 89 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.