mambax7 /
pedigree
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | // ------------------------------------------------------------------------- |
||
| 3 | |||
| 4 | require_once dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
| 5 | |||
| 6 | /* |
||
|
0 ignored issues
–
show
|
|||
| 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 | |||
| 18 | // Get all HTTP post or get parameters into global variables that are prefixed with "param_" |
||
| 19 | //import_request_variables("gp", "param_"); |
||
| 20 | extract($_GET, EXTR_PREFIX_ALL, "param"); |
||
| 21 | extract($_POST, EXTR_PREFIX_ALL, "param"); |
||
| 22 | |||
| 23 | $xoopsOption['template_main'] = "pedigree_breeder.tpl"; |
||
| 24 | |||
| 25 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 26 | // Include any common code for this module. |
||
| 27 | require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); |
||
| 28 | $xoopsTpl->assign('page_title', "Pedigree database - View owner/breeder"); |
||
| 29 | |||
| 30 | //get module configuration |
||
| 31 | $module_handler =& xoops_gethandler('module'); |
||
| 32 | $module =& $module_handler->getByDirname("pedigree"); |
||
| 33 | $config_handler =& xoops_gethandler('config'); |
||
| 34 | $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 35 | |||
| 36 | if (!isset($f)) { |
||
| 37 | $f = "lastname"; |
||
| 38 | } |
||
| 39 | //find letter on which to start else set to 'a' |
||
| 40 | if (isset($_GET['l'])) { |
||
| 41 | $l = $_GET['l']; |
||
| 42 | } else { |
||
| 43 | $l = "a"; |
||
| 44 | } |
||
| 45 | $w = $l . "%"; |
||
| 46 | if ($l == 1) { |
||
| 47 | $l = "LIKE"; |
||
| 48 | } |
||
| 49 | if (!isset($o)) { |
||
| 50 | $o = "lastname"; |
||
| 51 | } |
||
| 52 | if (!isset($d)) { |
||
| 53 | $d = "ASC"; |
||
| 54 | } |
||
| 55 | if (!isset($st)) { |
||
| 56 | $st = 0; |
||
| 57 | } |
||
| 58 | |||
| 59 | $perp = $moduleConfig['perpage']; |
||
| 60 | |||
| 61 | global $xoopsTpl; |
||
| 62 | global $xoopsDB; |
||
| 63 | global $xoopsModuleConfig; |
||
| 64 | |||
| 65 | //iscurrent user a module admin ? |
||
| 66 | $modadmin = false; |
||
| 67 | $xoopsModule =& XoopsModule::getByDirname("pedigree"); |
||
| 68 | if (!empty($xoopsUser)) { |
||
| 69 | if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
||
| 70 | $modadmin = true; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | //count total number of owners |
||
| 75 | $numowner = "SELECT count(ID) from " . $xoopsDB->prefix("pedigree_owner") . " WHERE " . $f . " LIKE '" . $w . "'"; |
||
| 76 | $numres = $xoopsDB->query($numowner); |
||
| 77 | //total number of owners the query will find |
||
| 78 | list($numresults) = $xoopsDB->fetchRow($numres); |
||
| 79 | //total number of pages |
||
| 80 | $numpages = (floor($numresults / $perp)) + 1; |
||
| 81 | if (($numpages * $perp) == ($numresults + $perp)) { |
||
| 82 | $numpages = $numpages - 1; |
||
| 83 | } |
||
| 84 | //find current page |
||
| 85 | $cpage = (floor($st / $perp)) + 1; |
||
| 86 | //create alphabet |
||
| 87 | $pages = ''; |
||
| 88 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=a\">A</a> "; |
||
| 89 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=b\">B</a> "; |
||
| 90 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=c\">C</a> "; |
||
| 91 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=d\">D</a> "; |
||
| 92 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=e\">E</a> "; |
||
| 93 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=f\">F</a> "; |
||
| 94 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=g\">G</a> "; |
||
| 95 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=h\">H</a> "; |
||
| 96 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=i\">I</a> "; |
||
| 97 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=j\">J</a> "; |
||
| 98 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=k\">K</a> "; |
||
| 99 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=l\">L</a> "; |
||
| 100 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=m\">M</a> "; |
||
| 101 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=n\">N</a> "; |
||
| 102 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=o\">O</a> "; |
||
| 103 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=p\">P</a> "; |
||
| 104 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=q\">Q</a> "; |
||
| 105 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=r\">R</a> "; |
||
| 106 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=s\">S</a> "; |
||
| 107 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=t\">T</a> "; |
||
| 108 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=u\">U</a> "; |
||
| 109 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=v\">V</a> "; |
||
| 110 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=w\">W</a> "; |
||
| 111 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=x\">X</a> "; |
||
| 112 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=y\">Y</a> "; |
||
| 113 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&st=0&l=z\">Z</a> "; |
||
| 114 | //create linebreak |
||
| 115 | $pages .= "<br />"; |
||
| 116 | //create previous button |
||
| 117 | if ($numpages > 1) { |
||
| 118 | if ($cpage > 1) { |
||
| 119 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&l=" . $l . "&st=" . ($st - $perp) . "\">" . _MA_PEDIGREE_PREVIOUS . "</a> "; |
||
| 120 | } |
||
| 121 | } |
||
| 122 | //create numbers |
||
| 123 | View Code Duplication | for ($x = 1; $x < ($numpages + 1); ++$x) { |
|
| 124 | //create line break after 20 number |
||
| 125 | if (($x % 20) == 0) { |
||
| 126 | $pages .= "<br />"; |
||
| 127 | } |
||
| 128 | if ($x != $cpage) { |
||
| 129 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&l=" . $l . "&st=" . ($perp * ($x - 1)) . "\">" . $x . "</a> "; |
||
| 130 | } else { |
||
| 131 | $pages .= $x . "  "; |
||
| 132 | } |
||
| 133 | } |
||
| 134 | //create next button |
||
| 135 | View Code Duplication | if ($numpages > 1) { |
|
| 136 | if ($cpage < ($numpages)) { |
||
| 137 | $pages .= "<a href=\"breeder.php?f=" . $f . "&o=" . $o . "&d=" . $d . "&l=" . $l . "&st=" . ($st + $perp) . "\">" . _MA_PEDIGREE_NEXT . "</a> "; |
||
| 138 | } |
||
| 139 | } |
||
| 140 | |||
| 141 | //query |
||
| 142 | $queryString |
||
| 143 | = "SELECT * from " . $xoopsDB->prefix("pedigree_owner") . " WHERE " . $f . " LIKE '" . $w . "' ORDER BY " . $o . " " . $d . " LIMIT " . $st . ", " . $perp; |
||
| 144 | $result = $xoopsDB->query($queryString); |
||
| 145 | |||
| 146 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 147 | //check for access |
||
| 148 | $access = ""; |
||
| 149 | if (!empty($xoopsUser)) { |
||
| 150 | if ($row['user'] == $xoopsUser->getVar("uid") || $modadmin == true) { |
||
| 151 | //$access = "<a href=\"dog.php?id=".$row['ID']."\"><img src=\"assets/images/edit.gif\" alt="._MA_PEDIGREE_BTN_EDIT."></a>"; |
||
| 152 | $access .= "<a href=\"deletebreeder.php?id=" . $row['ID'] . "\"><img src=\"assets/images/delete.gif\" alt=" . _MA_PEDIGREE_BTN_DELE . "></a>"; |
||
| 153 | } else { |
||
| 154 | $access = ""; |
||
| 155 | } |
||
| 156 | } |
||
| 157 | //make names |
||
| 158 | $name = $access . "<a href=\"owner.php?ownid=" . $row['ID'] . "\">" . stripslashes($row['lastname']) . ", " . stripslashes($row['firstname']) . "</a>"; |
||
| 159 | //create array for owners |
||
| 160 | $dogs[] = array( |
||
| 161 | 'id' => $row['ID'], |
||
| 162 | 'name' => $name, |
||
| 163 | 'city' => "" |
||
| 164 | ); |
||
| 165 | |||
| 166 | } |
||
| 167 | |||
| 168 | //add data to smarty template |
||
| 169 | //assign dog |
||
| 170 | if (isset($dogs)) { |
||
| 171 | $xoopsTpl->assign("dogs", $dogs); |
||
| 172 | } |
||
| 173 | //assign links |
||
| 174 | if ($d == "ASC") { |
||
| 175 | $nl = "<a href=\"breeder.php?f=" . $f . "&o=lastname&d=DESC\">" . _MA_PEDIGREE_OWN_NAME . "</a>"; |
||
| 176 | $cl = "<a href=\"breeder.php?f=" . $f . "&o=city&d=DESC\">" . _MA_PEDIGREE_OWN_CITY . "</a>"; |
||
| 177 | } else { |
||
| 178 | $nl = "<a href=\"breeder.php?f=" . $f . "&o=lastname&d=ASC\">" . _MA_PEDIGREE_OWN_NAME . "</a>"; |
||
| 179 | $cl = "<a href=\"breeder.php?f=" . $f . "&o=city&d=ASC\">" . _MA_PEDIGREE_OWN_CITY . "</a>"; |
||
| 180 | } |
||
| 181 | $xoopsTpl->assign("namelink", $nl); |
||
| 182 | $xoopsTpl->assign("colourlink", $cl); |
||
| 183 | |||
| 184 | //find last shown number |
||
| 185 | if (($st + $perp) > $numresults) { |
||
| 186 | $lastshown = $numresults; |
||
| 187 | } else { |
||
| 188 | $lastshown = $st + $perp; |
||
| 189 | } |
||
| 190 | //create string |
||
| 191 | $matches = _MA_PEDIGREE_MATCHESB; |
||
| 192 | $nummatchstr = $numresults . $matches . ($st + 1) . "-" . $lastshown . " (" . $numpages . " pages)"; |
||
| 193 | $xoopsTpl->assign("nummatch", $nummatchstr); |
||
| 194 | $xoopsTpl->assign("pages", $pages); |
||
| 195 | |||
| 196 | //comments and footer |
||
| 197 | include XOOPS_ROOT_PATH . "/footer.php"; |
||
| 198 |
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.