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 | ini_set("memory_limit", "32M"); |
||
| 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 | require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/functions.php"); |
||
| 17 | |||
| 18 | $xoopsOption['template_main'] = "pedigree_coi.tpl"; |
||
| 19 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 20 | |||
| 21 | //get module configuration |
||
| 22 | $module_handler =& xoops_gethandler('module'); |
||
| 23 | $module =& $module_handler->getByDirname("pedigree"); |
||
| 24 | $config_handler =& xoops_gethandler('config'); |
||
| 25 | $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 26 | |||
| 27 | global $xoopsTpl, $xoopsDB, $moduleConfig; |
||
| 28 | |||
| 29 | //start kinship.php code -- help !! |
||
| 30 | /* ************************************************************************************* */ |
||
| 31 | /* |
||
| 32 | This program calculates the coefficient of inbreeding (IC, or COI, or F) |
||
| 33 | for the offspring of a couple of animals, given by their IDs (s=sire_ID&d=dam_ID), |
||
| 34 | or for a given animal given by its ID (a=animal_ID). |
||
| 35 | |||
| 36 | By default, all known ascendants are used. |
||
| 37 | However, maximum count of distinct ascendants is limited to $nb_maxi (default=600) |
||
| 38 | [higher values for $nb_maxi could lead to calculations ending in timeout], |
||
| 39 | or depth of tree can be limited to $nb_gen generations (default = 8). |
||
| 40 | */ |
||
| 41 | /* ************************************************************************************* */ |
||
| 42 | |||
| 43 | if (!isset ($verbose)) { |
||
| 44 | $verbose = 0; |
||
| 45 | } // don't display different steps of ICs calculation |
||
| 46 | if (!isset ($detail)) { |
||
| 47 | $detail = 1; |
||
| 48 | } // don't display detail results [faster] |
||
| 49 | if (!isset ($nb_maxi)) { |
||
| 50 | $nb_maxi = 600; |
||
| 51 | } // maximum count of distinct ascendants |
||
| 52 | if (!isset ($nb_gen)) { |
||
| 53 | $nb_gen = 8; |
||
| 54 | } // maximum count of generations of ascendants |
||
| 55 | if (!isset ($pedigree)) { |
||
| 56 | $pedigree = 0; |
||
| 57 | } // dont't display sketch pedigree [faster] |
||
| 58 | if (!isset ($max_dist)) { // maximum length of implex loops |
||
| 59 | if ($nb_gen > 9) { |
||
| 60 | $max_dist = 14; |
||
| 61 | } else { |
||
| 62 | if ($nb_gen == 9) { |
||
| 63 | $max_dist = 17; |
||
| 64 | } else { |
||
| 65 | if ($nb_gen == 8) { |
||
| 66 | $max_dist = 18; |
||
| 67 | } else { |
||
| 68 | $max_dist = 99; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | $empty = array(); // an empty array |
||
| 75 | $sql1 = "select ID, father, mother, roft from " . $xoopsDB->prefix("pedigree_tree") . " where ID "; |
||
| 76 | |||
| 77 | // input data arrays: |
||
| 78 | $IDs = $empty; |
||
| 79 | $fathers = $empty; |
||
| 80 | $mothers = $empty; |
||
| 81 | |||
| 82 | // working arrays: |
||
| 83 | $inds = $empty; |
||
| 84 | $marked = $empty; |
||
| 85 | $ICknown = $empty; |
||
| 86 | $deltaf = $empty; |
||
| 87 | $pater = $empty; |
||
| 88 | $mater = $empty; |
||
| 89 | $chrono = $empty; |
||
| 90 | |||
| 91 | // Coefficients of Inbreeding array (result): |
||
| 92 | $COIs = $empty; |
||
| 93 | |||
| 94 | /* ****************************** FUNCTIONS ********************************* */ |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return int |
||
| 98 | */ |
||
| 99 | function chrono_sort() |
||
| 100 | { |
||
| 101 | global $IDs, $inds, $fathers, $mothers, $chrono, $nl, $detail; |
||
| 102 | $impr = 0; |
||
| 103 | $modif = 1; |
||
| 104 | $nloop = 0; |
||
| 105 | $nba = count($IDs); |
||
| 106 | // print_r ($IDs) ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 107 | // echo "<b>231 : $IDs[231] $fathers[231] $mothers[231] $chrono[231] $inds[231] </b><br />\n" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 108 | foreach ($IDs as $i => $v) { |
||
| 109 | $chrono[$i] = 1; |
||
| 110 | } // initialize all chronological ranks to 1 |
||
| 111 | $chrono[0] = 0; // except animal #0 (at 0 rank). |
||
| 112 | while ($modif && $nloop < 40) { |
||
| 113 | $modif = 0; |
||
| 114 | ++$nloop; |
||
| 115 | for ($i = 1; $i < $nba; ++$i) { |
||
| 116 | $s = $fathers[$i]; |
||
| 117 | if ($s) { |
||
| 118 | $s = $inds[$s]; |
||
| 119 | } |
||
| 120 | $d = $mothers[$i]; |
||
| 121 | if ($d) { |
||
| 122 | $d = $inds[$d]; |
||
| 123 | } |
||
| 124 | if ($s && $chrono[$s] <= $chrono[$i]) { |
||
| 125 | $chrono[$s] = $chrono[$i] + 1; |
||
| 126 | $modif = 1; |
||
| 127 | } |
||
| 128 | if ($d && $chrono[$d] <= $chrono[$i]) { |
||
| 129 | $chrono[$d] = $chrono[$i] + 1; |
||
| 130 | $modif = 1; |
||
| 131 | } |
||
| 132 | } |
||
| 133 | } |
||
| 134 | if ($nloop == 40) { |
||
| 135 | die ("Endless loop detected. Stopped."); |
||
| 136 | } |
||
| 137 | array_multisort($chrono, $IDs, $fathers, $mothers); |
||
| 138 | $depth = $chrono[$nba - 1]; |
||
| 139 | //commentes out by JC |
||
| 140 | //if ($detail) echo "<br />Chronological ranking done : Pedigree stretched over <b>$depth</b> generations.<br />$nl" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% 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...
|
|||
| 141 | if ($impr) { |
||
| 142 | echo "</center><pre>$nl $nl"; |
||
| 143 | foreach ($chrono as $i => $val) { |
||
| 144 | echo "<b>$i</b> : $val $IDs[$i] $fathers[$i] $mothers[$i] $nl"; |
||
| 145 | } |
||
| 146 | echo "</pre>$nl"; |
||
| 147 | die ("</html>"); |
||
| 148 | } |
||
| 149 | $inds = array_flip($IDs); |
||
| 150 | |||
| 151 | return 0; |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @param $s |
||
| 156 | * |
||
| 157 | * @return array |
||
| 158 | */ |
||
| 159 | function fetch_record($s) |
||
| 160 | { |
||
| 161 | /** @var XoopsMySQLDatabase */ |
||
| 162 | global $xoopsDB; |
||
| 163 | $r = $xoopsDB->query($s); |
||
| 164 | $n = 0; |
||
| 165 | if ($r) { |
||
| 166 | $n = $xoopsDB->getRowsNum($r); |
||
| 167 | } |
||
| 168 | if ($n == 0) { |
||
| 169 | $record = array('0'); |
||
| 170 | } else { |
||
| 171 | $record = $xoopsDB->fetchBoth($r); |
||
| 172 | } |
||
| 173 | |||
| 174 | return $record; |
||
| 175 | } |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @param $ind |
||
| 179 | * @param $gen |
||
| 180 | * |
||
| 181 | * @return int |
||
| 182 | */ |
||
| 183 | function count_all($ind, $gen) |
||
| 184 | { |
||
| 185 | global $inds, $nb_gen, $nb_all, $fathers, $mothers; |
||
| 186 | if ($ind) { |
||
| 187 | ++$nb_all; |
||
| 188 | } |
||
| 189 | $s = $fathers[$ind]; |
||
| 190 | $d = $mothers[$ind]; |
||
| 191 | if ($s && $gen < $nb_gen) { |
||
| 192 | count_all($s, $gen + 1); |
||
| 193 | } |
||
| 194 | if ($d && $gen < $nb_gen) { |
||
| 195 | count_all($d, $gen + 1); |
||
| 196 | } |
||
| 197 | |||
| 198 | return 0; |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @param $ch |
||
| 203 | * @param $niv |
||
| 204 | * |
||
| 205 | * @return int |
||
| 206 | */ |
||
| 207 | function add_multi($ch, $niv) |
||
| 208 | { |
||
| 209 | global $implx, $couls, $nl; |
||
| 210 | reset($implx); |
||
| 211 | $first = 1; |
||
| 212 | foreach ($implx as $im => $impl) { |
||
| 213 | if ($impl[0] == $ch || $impl[1] == $ch) { |
||
| 214 | if ($niv > 1 && $first) { |
||
| 215 | echo "<br />$nl"; |
||
| 216 | } else { |
||
| 217 | echo " "; |
||
| 218 | } |
||
| 219 | $i = $im + 1; |
||
| 220 | $j = min($im, 6); |
||
| 221 | $c = $couls[$j]; |
||
| 222 | $first = 0; |
||
| 223 | echo '<font color=' . $c . ' size="+2"><b>*' . $i . '*</b></font>'; |
||
| 224 | } |
||
| 225 | } |
||
| 226 | |||
| 227 | return 0; |
||
| 228 | } |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @param $ind |
||
| 232 | * @param $gen |
||
| 233 | * @param $class |
||
| 234 | * |
||
| 235 | * @return int |
||
| 236 | */ |
||
| 237 | function output_animal($ind, $gen, $class) |
||
| 238 | { |
||
| 239 | global $depth, $IDs, $fathers, $mothers, $nl; |
||
| 240 | if ($gen > $depth) { |
||
| 241 | return 0; |
||
| 242 | } |
||
| 243 | $cell_content = "Ø"; |
||
| 244 | if ($ind || $gen == 0) { |
||
| 245 | $ID = $IDs[$ind]; |
||
| 246 | $ani = set_name($ID); |
||
| 247 | $name = $ani[1]; |
||
| 248 | $name = $ID; |
||
| 249 | $cell_content = showparent($name) . $nl; |
||
| 250 | } |
||
| 251 | $rowspan = 1 << ($depth - $gen); |
||
| 252 | echo "<td rowspan=" . $rowspan . ' align="center" class="' . $class . '">' . $cell_content . "</td>$nl"; |
||
| 253 | if ($gen < $depth) { |
||
| 254 | $sire = 0; |
||
| 255 | if ($ind || $gen == 0) { |
||
| 256 | $sire = $fathers[$ind]; |
||
| 257 | } |
||
| 258 | output_animal($sire, $gen + 1, "0"); |
||
| 259 | $dam = 0; |
||
| 260 | if ($ind || $gen == 0) { |
||
| 261 | $dam = $mothers[$ind]; |
||
| 262 | } |
||
| 263 | output_animal($dam, $gen + 1, "1"); |
||
| 264 | } else { |
||
| 265 | echo "</tr><tr>$nl"; |
||
| 266 | } |
||
| 267 | |||
| 268 | return 0; |
||
| 269 | } |
||
| 270 | |||
| 271 | /** |
||
| 272 | * @return int |
||
| 273 | */ |
||
| 274 | function SKETCH_PEDIGREE() |
||
| 275 | { |
||
| 276 | global $nl, $detail, $depth, $IDs; |
||
| 277 | // print_r ($IDs) ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 278 | echo $nl . "<br />" . $nl . '<table border="3" cellpadding="4" width="85%"" cellpadding="0" cellspacing="0">' . $nl |
||
| 279 | . '<tr><th colspan="10" align="center">SKETCH PEDIGREE OF COMMON PROGENY</th></tr>' . $nl . '<tr align="center" valign="middle"><th>Progeny</th><th>' . _("Sire / Dam") . '</th>'; |
||
| 280 | if ($depth >= 2) { |
||
| 281 | echo '<th>' . _("Grandparents") . '</th>' . $nl; |
||
| 282 | } |
||
| 283 | if ($depth >= 3) { |
||
| 284 | echo '<th>' . _("Great-Grandparents") . '</th>' . $nl; |
||
| 285 | } |
||
| 286 | if ($depth >= 4) { |
||
| 287 | echo '<th>3xGr. P.</th>' . $nl; |
||
| 288 | } |
||
| 289 | if ($depth >= 5) { |
||
| 290 | echo '<th>4xGr. P.</th>' . $nl; |
||
| 291 | } |
||
| 292 | if ($depth >= 6) { |
||
| 293 | echo '<th>5xGr. P.</th>' . $nl; |
||
| 294 | } |
||
| 295 | if ($depth >= 7) { |
||
| 296 | echo '<th>6xGr. P.</th>' . $nl; |
||
| 297 | } |
||
| 298 | echo '</tr><tr>'; |
||
| 299 | output_animal(0, 0, "0"); /* output the sketch pedigree */ |
||
| 300 | echo $nl . '</tr></table>' . $nl . "<p />" . $nl; |
||
| 301 | |||
| 302 | return 0; |
||
| 303 | } |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @return int |
||
| 307 | */ |
||
| 308 | function GENEALOGY() |
||
| 309 | { |
||
| 310 | global $IDs, $fathers, $mothers, $inds, $nb_gen, $nb_maxi, $nbani, $nl, $sql1; |
||
| 311 | global $xoopsDB; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 312 | |||
| 313 | $impr = 0; |
||
| 314 | $fathers[0] = $IDs[1]; |
||
| 315 | $mothers[0] = $IDs[2]; |
||
| 316 | $fathers[1] = 0; |
||
| 317 | $mothers[1] = 0; |
||
| 318 | $fathers[2] = 0; |
||
| 319 | $mothers[2] = 0; |
||
| 320 | $last = 2; |
||
| 321 | if ($impr) { |
||
| 322 | echo "<!-- genealogy 'de cujus' (gener. 0) : $IDs[0] = $IDs[1] x $IDs[2] -->$nl"; |
||
| 323 | } |
||
| 324 | $generation = array($IDs[1], $IDs[2]); // starting with first generation (sire and dam) |
||
| 325 | $nbtot = 0; // count of total known ascendants within $nb_gen generations |
||
| 326 | for ($nloop = 1, $tot = 2; $last <= $nb_maxi && $nloop <= $nb_gen; ++$nloop) { |
||
| 327 | $nbtot += $tot; // count of total known ascendants within $nb_gen generations |
||
| 328 | $nbani = $last; // count of distinct ascendants within $nb_gen generations |
||
| 329 | $list = join(',', array_unique($generation)); |
||
| 330 | $generation = array(); |
||
| 331 | $tot = 0; |
||
| 332 | if ($impr) { |
||
| 333 | echo " [$list]$nl"; |
||
| 334 | } |
||
| 335 | |||
| 336 | // HERE IS FETCHED EACH TRIPLET [ID, sire_ID, dam_ID] : |
||
| 337 | $r = $xoopsDB->query("$sql1 IN ($list)"); |
||
| 338 | while ($rec = $xoopsDB->fetchBoth($r)) { |
||
| 339 | $a = $rec[0] + 0; |
||
| 340 | $s = $rec[1] + 0; |
||
| 341 | $d = $rec[2] + 0; |
||
| 342 | if (!$a) { |
||
| 343 | echo "ERROR : $a = $s x $d for list = '$list'<br />\n"; |
||
| 344 | } |
||
| 345 | if ($s) { |
||
| 346 | ++$tot; |
||
| 347 | } |
||
| 348 | if ($d) { |
||
| 349 | ++$tot; |
||
| 350 | } |
||
| 351 | $j = array_keys($IDs, $a); |
||
| 352 | $j = $j[0]; |
||
| 353 | $fathers[$j] = $s; |
||
| 354 | $mothers[$j] = $d; |
||
| 355 | if ($s && !in_array($s, $IDs)) { |
||
| 356 | $i = ++$last; |
||
| 357 | $IDs[$i] = $s; |
||
| 358 | $fathers[$i] = 0; |
||
| 359 | $mothers[$i] = 0; |
||
| 360 | if ($s) { |
||
| 361 | $generation[] = $s; |
||
| 362 | } |
||
| 363 | } |
||
| 364 | if ($d && !in_array($d, $IDs)) { |
||
| 365 | $i = ++$last; |
||
| 366 | $IDs[$i] = $d; |
||
| 367 | $fathers[$i] = 0; |
||
| 368 | $mothers[$i] = 0; |
||
| 369 | if ($s) { |
||
| 370 | $generation[] = $d; |
||
| 371 | } |
||
| 372 | } |
||
| 373 | if ($impr) { |
||
| 374 | echo "<pre>genealogy ascendant (gener. $nloop) : $a = $s x $d [tot = $tot]$nl</pre>"; |
||
| 375 | } |
||
| 376 | } |
||
| 377 | if (!count($generation)) { |
||
| 378 | break; |
||
| 379 | } |
||
| 380 | } |
||
| 381 | |||
| 382 | if ($nloop <= $nb_gen) { |
||
| 383 | $nb_gen = $nloop; |
||
| 384 | } // tree cut by $nb_maxi ! |
||
| 385 | |||
| 386 | reset($IDs); |
||
| 387 | $inds = array_flip($IDs); |
||
| 388 | |||
| 389 | chrono_sort(); |
||
| 390 | |||
| 391 | return $nbtot; |
||
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @param $p |
||
| 396 | * |
||
| 397 | * @return int |
||
| 398 | */ |
||
| 399 | function dist_p($p) |
||
| 400 | { |
||
| 401 | global $IDs, $fathers, $mothers, $pater, $nb_gen, $detail, $nl; |
||
| 402 | // Anim #P is the sire |
||
| 403 | $listall = array($p); |
||
| 404 | $listnew = array($p); |
||
| 405 | $pater = array(); |
||
| 406 | $pater[$p] = 1; |
||
| 407 | for ($nloop = 2; $nloop < ($nb_gen + 1); ++$nloop) { |
||
| 408 | $liste = array(); |
||
| 409 | foreach ($listnew as $i) { |
||
| 410 | $s = $fathers[$i]; |
||
| 411 | $d = $mothers[$i]; |
||
| 412 | if ($s && !$pater[$s]) { |
||
| 413 | $pater[$s] = $nloop; |
||
| 414 | } // least distance from $s to sire's progeny |
||
| 415 | if ($d && !$pater[$d]) { |
||
| 416 | $pater[$d] = $nloop; |
||
| 417 | } // least distance from $d to sire's progeny |
||
| 418 | if ($s) { |
||
| 419 | $liste[] = $s; |
||
| 420 | } |
||
| 421 | if ($d) { |
||
| 422 | $liste[] = $d; |
||
| 423 | } |
||
| 424 | } |
||
| 425 | if (!count($liste)) { |
||
| 426 | break; |
||
| 427 | } |
||
| 428 | //commented pout by jc |
||
| 429 | //if (in_array ($IDs[2], $liste) && !$detail) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% 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...
|
|||
| 430 | //{ echo "<p>DAM is an ascendant (at $nloop generations) of SIRE. Stopped." ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% 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...
|
|||
| 431 | // die ("</body></html>$nl") ; } |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% 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...
|
|||
| 432 | $listnew = array_diff(array_unique($liste), $listall); |
||
| 433 | /* $list1 = join (' ', $listall) ; $list2 = join ('+', $listnew) ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
48% 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...
|
|||
| 434 | echo "<!-- P ($nloop) $list1/$list2 -->$nl" ; */ |
||
| 435 | $listall = array_merge($listall, $listnew); |
||
| 436 | } |
||
| 437 | // Here $pater array contains list of all distinct ascendants of #P (including P himself) |
||
| 438 | // Values of $pater are minimum distances to #P (in generations) +1 |
||
| 439 | return 0; |
||
| 440 | } |
||
| 441 | |||
| 442 | /** |
||
| 443 | * @param $m |
||
| 444 | * |
||
| 445 | * @return int |
||
| 446 | */ |
||
| 447 | function dist_m($m) |
||
| 448 | { |
||
| 449 | global $IDs, $fathers, $mothers, $mater, $nb_gen, $detail, $nl; |
||
| 450 | // Anim #M is the dam |
||
| 451 | $listall = array($m); |
||
| 452 | $listnew = array($m); |
||
| 453 | $mater = array(); |
||
| 454 | $mater[$m] = 1; |
||
| 455 | for ($nloop = 2; $nloop <= ($nb_gen + 1); ++$nloop) { |
||
| 456 | $liste = array(); |
||
| 457 | foreach ($listnew as $i) { |
||
| 458 | $s = $fathers[$i]; |
||
| 459 | $d = $mothers[$i]; |
||
| 460 | if ($s && !isset($mater[$s])) { |
||
| 461 | $mater[$s] = $nloop; |
||
| 462 | } // least distance from $s to dam's progeny |
||
| 463 | if ($d && !isset($mater[$d])) { |
||
| 464 | $mater[$d] = $nloop; |
||
| 465 | } // least distance from $d to dam's progeny |
||
| 466 | // echo "I=" . $i . " MATER(I)=" . $mater[$i] . " NLOOP=" . $nloop . "<br />$nl" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
37% 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...
|
|||
| 467 | if ($s) { |
||
| 468 | $liste[] = $s; |
||
| 469 | } |
||
| 470 | if ($d) { |
||
| 471 | $liste[] = $d; |
||
| 472 | } |
||
| 473 | } |
||
| 474 | if (!count($liste)) { |
||
| 475 | break; |
||
| 476 | } |
||
| 477 | //commented out by jc |
||
| 478 | //if (in_array ($IDs[1], $liste) && !$detail) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% 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...
|
|||
| 479 | // { echo "<p>SIRE is an ascendant (at $nloop generations) of DAM. Stopped." ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 480 | // die ("</body></html>$nl") ; } |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% 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...
|
|||
| 481 | $listnew = array_diff(array_unique($liste), $listall); |
||
| 482 | // $list1 = join (' ', $listall) ; $list2 = join ('+', $listnew) ; echo "M ($nloop) $list1/$list2 $nl" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
48% 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...
|
|||
| 483 | $listall = array_merge($listall, $listnew); |
||
| 484 | } |
||
| 485 | // Here $mater array contains list of all distinct ascendants of #M (including M herself) |
||
| 486 | // Values of $mater are minimum distances to #M (in generations) +1 |
||
| 487 | return 0; |
||
| 488 | } |
||
| 489 | |||
| 490 | /** |
||
| 491 | * @return array |
||
| 492 | */ |
||
| 493 | function calc_dist() /* Common Ascendants and their distances */ |
||
| 494 | { |
||
| 495 | global $IDs, $fathers, $mothers, $nbanims, $pater, $mater, $empty, $nb_gen, $nl; |
||
| 496 | global $dmax, $detail, $nb_gen; |
||
| 497 | $distan = array(); |
||
| 498 | // dist_m (2) ; has already been called |
||
| 499 | dist_p($fathers[0]); |
||
| 500 | $dmax = 0; |
||
| 501 | $impr = 0; |
||
| 502 | $dmx = 7; |
||
| 503 | if ($detail) { |
||
| 504 | $dmx += 2; |
||
| 505 | } |
||
| 506 | // ksort ($pater) ; print_r ($pater) ; echo "<br />$nl" ; ksort ($mater) ; print_r ($mater) ; echo "<br />$nl" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 507 | foreach ($pater as $i => $p) { |
||
| 508 | if ($p) { |
||
| 509 | $m = $mater[$i]; |
||
| 510 | if ($m) { |
||
| 511 | $di = $p + $m; |
||
| 512 | if ($impr) { |
||
| 513 | echo " $i : $p + $m = $di <br />$nl"; |
||
| 514 | } |
||
| 515 | if (!$dmax) { |
||
| 516 | $dmax = $dmx + $di - ceil($di / 2.); |
||
| 517 | } |
||
| 518 | if ($di > ($dmax + 2)) { |
||
| 519 | continue; |
||
| 520 | } |
||
| 521 | $distan[$i] = $di; |
||
| 522 | } |
||
| 523 | } |
||
| 524 | } |
||
| 525 | if (!$dmax) { |
||
| 526 | $dmax = 2 * $nb_gen - 2; |
||
| 527 | } |
||
| 528 | |||
| 529 | return $distan; |
||
| 530 | } |
||
| 531 | |||
| 532 | /** |
||
| 533 | * @param $p |
||
| 534 | * @param $m |
||
| 535 | * @param $a |
||
| 536 | * @param $ndist |
||
| 537 | * |
||
| 538 | * @return int |
||
| 539 | */ |
||
| 540 | function mater_side($p, $m, $a, $ndist) |
||
| 541 | { |
||
| 542 | global $fathers, $mothers, $marked, $COIs, $deltaf, $ICknown, $verbose, $nl, $chrono, $paternal_rank, $max_dist; |
||
| 543 | if (!$m || $ndist > $max_dist) { |
||
| 544 | return 0; |
||
| 545 | } |
||
| 546 | if ($p == $m) /* IMPLEX FOUND (node of consanguinity) { for Anim #A */ { |
||
| 547 | $already_known = isset($ICknown[$p]) ? $ICknown[$p] : 0; |
||
| 548 | |||
| 549 | if (!$already_known) { |
||
| 550 | CONSANG($p); |
||
| 551 | } // MAIN RECURSION: |
||
| 552 | $ICp = isset($COIs[$p]) ? $COIs[$p] : 0; // we need to know the IC of Parent for Wright's formula |
||
| 553 | if ($verbose && !$already_known && $ICp > 0.001 * $verbose) { |
||
| 554 | echo "IC of Animal $p is $ICp$nl"; |
||
| 555 | } |
||
| 556 | |||
| 557 | $incr = 1.0 / (1 << $ndist) * (1. + $ICp); // ******** applying WRIGHT's formula ******** |
||
| 558 | |||
| 559 | // [Note: 1 << $ndist is equal to 2 power $ndist] |
||
| 560 | $COIs[$a] = isset($COIs[$a]) ? $COIs[$a] : 0; |
||
| 561 | $COIs[$a] += $incr; // incrementing the IC of AnimC |
||
| 562 | if ($a == 0) { |
||
| 563 | $deltaf[$p] += $incr; |
||
| 564 | } |
||
| 565 | /* contribution of Anim #P to IC of Anim #0 */ |
||
| 566 | // if ($verbose && $a == 0 && $incr > 0.0001*$verbose) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
46% 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...
|
|||
| 567 | // echo "Animal $p is contributing for " . substr ($deltaf[$p], 0, 10) . " to the IC of Animal $a$nl" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
52% 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...
|
|||
| 568 | |||
| 569 | } else { |
||
| 570 | if (!$marked[$m] && $chrono[$m] < $paternal_rank) { |
||
| 571 | mater_side($p, $fathers[$m], $a, $ndist + 1); |
||
| 572 | |||
| 573 | mater_side($p, $mothers[$m], $a, $ndist + 1); |
||
| 574 | } |
||
| 575 | } |
||
| 576 | |||
| 577 | return 0; |
||
| 578 | } |
||
| 579 | |||
| 580 | /** |
||
| 581 | * @param $p |
||
| 582 | * @param $m |
||
| 583 | * @param $a |
||
| 584 | * @param $pdist |
||
| 585 | * |
||
| 586 | * @return int |
||
| 587 | */ |
||
| 588 | function pater_side($p, $m, $a, $pdist) |
||
| 589 | { |
||
| 590 | global $mater, $fathers, $mothers, $marked, $chrono, $paternal_rank; |
||
| 591 | if (!$p) { |
||
| 592 | return 0; |
||
| 593 | } |
||
| 594 | $paternal_rank = $chrono[$p]; |
||
| 595 | $marked[$p] = 1; /* cut paternal side */ |
||
| 596 | if (isset($mater[$p]) || $a) { |
||
| 597 | mater_side($p, $m, $a, $pdist); |
||
| 598 | } |
||
| 599 | pater_side($fathers[$p], $m, $a, $pdist + 1); |
||
| 600 | pater_side($mothers[$p], $m, $a, $pdist + 1); |
||
| 601 | $marked[$p] = 0; /* free paternal side */ |
||
| 602 | |||
| 603 | return 0; |
||
| 604 | } |
||
| 605 | |||
| 606 | /** |
||
| 607 | * @param $a |
||
| 608 | * |
||
| 609 | * @return int |
||
| 610 | */ |
||
| 611 | function CONSANG($a) |
||
| 612 | { |
||
| 613 | global $fathers, $mothers, $ICknown, $COIs, $nl; |
||
| 614 | if (!$a || isset($ICknown[$a])) { |
||
| 615 | return 0; |
||
| 616 | } |
||
| 617 | if ($a == -1) { |
||
| 618 | $a = 0; |
||
| 619 | } // particular case : a= -1 means Anim #0 (to bypass above test) |
||
| 620 | $IC_if_deadend = 0.0; // 0.0 means taht deadends are deemed to be total outcrosses... |
||
| 621 | // if IC was already stored in the database for Aminal #A, it should be used here instead of 0.0 |
||
| 622 | $p = $fathers[$a]; |
||
| 623 | $m = $mothers[$a]; |
||
| 624 | if (!$p || !$m) { |
||
| 625 | $COIs[$a] = $IC_if_deadend; |
||
| 626 | $ICknown[$a] = 2; |
||
| 627 | |||
| 628 | return 0; |
||
| 629 | } |
||
| 630 | |||
| 631 | if (isset($verbose)) { |
||
| 632 | echo "</center><pre>$nl"; |
||
| 633 | } |
||
| 634 | pater_side($p, $m, $a, 1); // launch tree exploration |
||
| 635 | if (isset($verbose)) { |
||
| 636 | echo "</pre><center>$nl"; |
||
| 637 | } |
||
| 638 | |||
| 639 | $ICknown[$a] = 1; |
||
| 640 | $p = $fathers[$a]; |
||
| 641 | $m = $mothers[$a]; |
||
| 642 | foreach ($fathers as $i => $pere) /* siblings share the same COI value */ { |
||
| 643 | if ($i <> $a && $pere == $p && $mothers[$i] == $m) { |
||
| 644 | $COIs[$i] = isset($COIs[$a]) ? $COIs[$a] : 0; |
||
| 645 | $ICknown[$i] = 1; |
||
| 646 | } |
||
| 647 | } |
||
| 648 | // echo "<!-- COI($a) = $COIs[$a] $IDs[$a] ($fathers[$a] x $mothers[$a])-->$nl" ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 649 | return 0; |
||
| 650 | } |
||
| 651 | |||
| 652 | /** |
||
| 653 | * @param $nb_gen |
||
| 654 | * @param $nloop |
||
| 655 | * |
||
| 656 | * @return int |
||
| 657 | */ |
||
| 658 | function boucle($nb_gen, $nloop) |
||
| 659 | { |
||
| 660 | global $fathers, $mothers, $nbanims, $listing, $nl; |
||
| 661 | $nbtot = 0; |
||
| 662 | $listing = ""; |
||
| 663 | if ($nloop < ($nb_gen + 20)) { |
||
| 664 | $nloop = $nb_gen + 20; |
||
| 665 | } |
||
| 666 | $list = array(0 => 1); /* initialize list with Anim0 (rank = 1) */ |
||
| 667 | for ($j = 1; $j < $nloop; ++$j) { |
||
| 668 | $new = 0; |
||
| 669 | foreach ($list as $i => $rank) { |
||
| 670 | if (($s = $fathers[$i])) { |
||
| 671 | if (!$list[$s]) { |
||
| 672 | $new = 1; |
||
| 673 | if ($j < $nb_gen) { |
||
| 674 | $nbtot += 1; |
||
| 675 | } |
||
| 676 | } |
||
| 677 | $list[$s] = $rank + 1; |
||
| 678 | if ($j < $nb_gen) { |
||
| 679 | $nbtot += 1; |
||
| 680 | } |
||
| 681 | if ($j > $nloop - 10) { |
||
| 682 | $listing .= "Loop $j: Animal #$s " . $IDs[$s] . $nl; |
||
| 683 | } |
||
| 684 | } |
||
| 685 | if (($d = $mothers[$i])) { |
||
| 686 | if (!$list[$d]) { |
||
| 687 | $new = 1; |
||
| 688 | if ($j < $nb_gen) { |
||
| 689 | $nbtot += 1; |
||
| 690 | } |
||
| 691 | } |
||
| 692 | $list[$d] = $rank + 1; |
||
| 693 | if ($j < $nb_gen) { |
||
| 694 | $nbtot += 1; |
||
| 695 | } |
||
| 696 | if ($j > $nloop - 10) { |
||
| 697 | $listing .= "Loop $j: Animal #$d " . $IDs[$d] . $nl; |
||
| 698 | } |
||
| 699 | } |
||
| 700 | } |
||
| 701 | if (!$new) { |
||
| 702 | break; |
||
| 703 | } |
||
| 704 | } |
||
| 705 | if ($new) { |
||
| 706 | $nbtot = 0; |
||
| 707 | } /* Endless loop detected (see listing) */ |
||
| 708 | |||
| 709 | return $nbtot; |
||
| 710 | } |
||
| 711 | |||
| 712 | /** |
||
| 713 | * @param $ID |
||
| 714 | * |
||
| 715 | * @return array |
||
| 716 | */ |
||
| 717 | function set_name($ID) |
||
| 718 | { |
||
| 719 | global $sql2, $sql2bis, $xoopsDB; |
||
| 720 | $name = ' '; |
||
| 721 | $ani = array(); |
||
| 722 | if ($ID) { |
||
| 723 | $sqlquery = "SELECT ID, NAAM, roft from " . $xoopsDB->prefix("pedigree_tree") . " where ID = '$ID'"; |
||
| 724 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 725 | $ani = $xoopsDB->fetchBoth($queryresult); |
||
| 726 | // $name = $ani[1]; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% 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...
|
|||
| 727 | if ($sql2bis) { // true for E.R.o'S. only |
||
| 728 | $name = html_accents($name); |
||
| 729 | //$affx = $ani[5] ; // affix-ID |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
55% 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...
|
|||
| 730 | if ($affx) { |
||
| 731 | $affix = fetch_record("$sql2bis '$affx'"); |
||
| 732 | $type = $affix[1]; |
||
| 733 | $affixe = html_accents($affix[0]); |
||
| 734 | if ($type[0] == 'P') { |
||
| 735 | $name = '<i>' . $affixe . "</i> " . $name; |
||
| 736 | } |
||
| 737 | if ($type[0] == 'S') { |
||
| 738 | $name = $name . " <i>" . $affixe . '</i>'; |
||
| 739 | } |
||
| 740 | } |
||
| 741 | $ani[1] = $name; |
||
| 742 | } |
||
| 743 | } |
||
| 744 | |||
| 745 | return $ani; |
||
| 746 | } |
||
| 747 | |||
| 748 | /** |
||
| 749 | * @param $ems |
||
| 750 | * |
||
| 751 | * @return string |
||
| 752 | */ |
||
| 753 | function Ems_($ems) |
||
| 754 | { |
||
| 755 | if (function_exists("Ems")) { |
||
| 756 | return Ems($ems); |
||
| 757 | } |
||
| 758 | if (!$ems) { |
||
| 759 | return " "; |
||
| 760 | } |
||
| 761 | $e = str_replace(" ", "+", $ems); |
||
| 762 | $res = '<a href="#" style="text-decoration:none;" onClick="' . "window.open('http://www.somali.asso.fr/eros/decode_ems.php?$e'," . "'', 'resizable=no,width=570,height=370')" . '"' |
||
| 763 | . "><b>$ems</b></a>"; |
||
| 764 | |||
| 765 | return $res; |
||
| 766 | } |
||
| 767 | |||
| 768 | /** |
||
| 769 | * @param $ID |
||
| 770 | * |
||
| 771 | * @return string |
||
| 772 | */ |
||
| 773 | function one_animal($ID) |
||
| 774 | { |
||
| 775 | global $xoopsDB; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 776 | global $sex, $val, $sosa, $detail, $sql3; |
||
| 777 | $sosa = 12; |
||
| 778 | $content = ''; |
||
| 779 | // echo '<div style="position:relative;float:right;width=2.0em;color=white;">' . $sosa . '</div>' ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
36% 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...
|
|||
| 780 | $animal = set_name($ID); |
||
| 781 | list ($ID, $name, $sex/*, $hd, $ems*/) = $animal; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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...
|
|||
| 782 | $sqlquery = "select SQL_CACHE count(ID) from " . $xoopsDB->prefix("pedigree_tree") . " where father = '$ID' or mother = '$ID'"; |
||
| 783 | $queryresult = $xoopsDB->($sqlquery); |
||
|
0 ignored issues
–
show
|
|||
| 784 | $nb = $xoopsDB->fetchBoth($queryresult); |
||
| 785 | $nb_children = $nb[0]; |
||
| 786 | if ($nb_children == 0) { |
||
| 787 | $nb_children = _MA_PEDIGREE_COI_NO; |
||
| 788 | } |
||
| 789 | // $dogid = $animal[0]; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% 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...
|
|||
| 790 | $content .= "<tr><td><a href=\"dog.php?id=" . $ID . "\">" . stripslashes($name) . "</a>"; |
||
| 791 | // if ($nb_enf == 0) echo ' ø' ; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 792 | if ($val) { |
||
| 793 | $content .= $val; |
||
| 794 | } |
||
| 795 | if ($sex == 1) { |
||
| 796 | $geslacht = "<img src=\"assets/images/female.gif\">"; |
||
| 797 | } |
||
| 798 | if ($sex == 0) { |
||
| 799 | $geslacht = "<img src=\"assets/images/male.gif\">"; |
||
| 800 | } |
||
| 801 | $content .= "</td><td>" . $geslacht . "</td><td>" . $nb_children . _MA_PEDIGREE_COI_OFF . '</td></tr>'; |
||
| 802 | |||
| 803 | return $content; |
||
| 804 | } |
||
| 805 | |||
| 806 | /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MAIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ |
||
| 807 | |||
| 808 | $nl = "\n"; // the newline character |
||
| 809 | |||
| 810 | //edit by jc |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
44% 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...
|
|||
| 811 | //$link = @mysql_pconnect ($host, $database, $password) |
||
| 812 | // or die ("<html><body>Connection to database failed.</body></html>") ; |
||
| 813 | $s = $_GET['s']; |
||
| 814 | $d = $_GET['d']; |
||
| 815 | $detail = $_GET['detail']; |
||
| 816 | |||
| 817 | if (isset($si)) { |
||
| 818 | $s = findid($si); |
||
| 819 | } |
||
| 820 | if (isset($da)) { |
||
| 821 | $d = findid($da); |
||
| 822 | } |
||
| 823 | //test for variables |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
46% 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...
|
|||
| 824 | //echo "si=".$si." da=".$da." s=".$s." d=".$d; |
||
| 825 | $utils = $xoopsDB->query("select user(), date_format(now(),'%d-%b-%Y')"); |
||
| 826 | list ($who, $jourj) = $xoopsDB->fetchBoth($utils); |
||
| 827 | |||
| 828 | if (isset ($IC)) { |
||
| 829 | $detail = -1; |
||
| 830 | $a = $IC; |
||
| 831 | } |
||
| 832 | |||
| 833 | if (!isset ($detail)) { |
||
| 834 | $detail = 0; |
||
| 835 | } |
||
| 836 | |||
| 837 | if (!isset($a)) { |
||
| 838 | if ($s && !isset($d)) { |
||
| 839 | $a = $s; |
||
| 840 | $s = ""; |
||
| 841 | } |
||
| 842 | if ($d && !isset($s)) { |
||
| 843 | $a = $d; |
||
| 844 | $d = ""; |
||
| 845 | } |
||
| 846 | } |
||
| 847 | |||
| 848 | if (isset($a)) { |
||
| 849 | $sqlquery = "select ID, father, mother, roft from " . $xoopsDB->prefix("pedigree_tree") . " where ID = '$a'"; |
||
| 850 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 851 | $rowhond = $xoopsDB->fetchBoth($queryresult); |
||
| 852 | $a = $rowhond['ID']; |
||
| 853 | $s = $rowhond['father']; |
||
| 854 | $d = $rowhond['mother']; |
||
| 855 | } else { |
||
| 856 | $a = 0; |
||
| 857 | } |
||
| 858 | $a += 0; |
||
| 859 | $s += 0; |
||
| 860 | $d += 0; // [IDs are numbers] |
||
| 861 | |||
| 862 | $xoopsTpl->assign("ptitle", _MA_PEDIGREE_COI_CKRI); |
||
| 863 | $xoopsTpl->assign("pcontent", strtr(_MA_PEDIGREE_COI_CKRI_CT, array('[animalType]' => $moduleConfig['animalType']))); |
||
| 864 | |||
| 865 | if (!$s && !$d) { |
||
| 866 | $error = _MA_PEDIGREE_COI_SPANF1 . $a . _MA_PEDIGREE_COI_SPANF2; |
||
| 867 | $xoopsTpl->assign("COIerror", $error); |
||
| 868 | } |
||
| 869 | |||
| 870 | $maxn_ = 1000; |
||
| 871 | $maxr_ = 9; |
||
| 872 | |||
| 873 | $maxn = $maxn_; |
||
| 874 | $maxr = $maxr_; |
||
| 875 | $cinnamon = 0; |
||
| 876 | $chocolat = 0; |
||
| 877 | $dilution = 0; |
||
| 878 | $sexlred = 0; |
||
| 879 | |||
| 880 | $nivomin = -$maxr; /* Maximal depth of recursion (-10) */ |
||
| 881 | $codec = 0; |
||
| 882 | $gens = 4; /* 4 gens. for both pedigrees of couple */ |
||
| 883 | $litter = 0; |
||
| 884 | |||
| 885 | // echo "s:".$s."<br />"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
53% 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...
|
|||
| 886 | // echo "d:".$d."<br />"; |
||
| 887 | |||
| 888 | $codec1 = $d; |
||
| 889 | $codec2 = $s; |
||
| 890 | $val = ''; |
||
| 891 | |||
| 892 | if (!$s && $d) { |
||
| 893 | $codec1 = $d; |
||
| 894 | $codec2 = 0; |
||
| 895 | } |
||
| 896 | if ($codec1 == $codec2) { |
||
| 897 | $codec2 = 0; |
||
| 898 | } |
||
| 899 | |||
| 900 | $sqlquery = "select ID, father, mother, roft from " . $xoopsDB->prefix("pedigree_tree") . " where ID = '$codec1'"; |
||
| 901 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 902 | $rowhond = $xoopsDB->fetchBoth($queryresult); |
||
| 903 | $a1 = $rowhond['ID']; |
||
| 904 | $s1 = $rowhond['father']; |
||
| 905 | $d1 = $rowhond['mother']; |
||
| 906 | $sex1 = $rowhond['roft']; |
||
| 907 | |||
| 908 | // echo "sqlquery:".$sqlquery."<br />"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% 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...
|
|||
| 909 | |||
| 910 | $sqlquery = "select ID, father, mother, roft from " . $xoopsDB->prefix("pedigree_tree") . " where ID = '$codec2'"; |
||
| 911 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 912 | $rowhond = $xoopsDB->fetchBoth($queryresult); |
||
| 913 | $a2 = $rowhond['ID']; |
||
| 914 | $s2 = $rowhond['father']; |
||
| 915 | $d2 = $rowhond['mother']; |
||
| 916 | $sex2 = $rowhond['roft']; |
||
| 917 | |||
| 918 | // echo "sqlquery:".$sqlquery."<br />"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% 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...
|
|||
| 919 | |||
| 920 | //if ($sex1 == '0' && $sex2 == '1') { $a3 = $a1 ; $a1 = $a2 ; $a2 = $a3 ; } /* permute dam and sire */ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
36% 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...
|
|||
| 921 | $codec1 = $a1; |
||
| 922 | $codec2 = $a2; |
||
| 923 | if (!(isset($s1)) || !(isset($d1)) || !(isset($s2)) || !(isset($d2))) { |
||
| 924 | $xoopsTpl->assign("COIerror", _MA_PEDIGREE_COI_SGPU); |
||
| 925 | |||
| 926 | } |
||
| 927 | |||
| 928 | $title = strtr(_MA_PEDIGREE_FLD_FATH, array('[father]' => $moduleConfig['father'])) . " (" . stripslashes(showparent($codec2)) . ")" . _MA_PEDIGREE_COI_AND . strtr( |
||
| 929 | _MA_PEDIGREE_FLD_MOTH, |
||
| 930 | array('[mother]' => $moduleConfig['mother']) |
||
| 931 | ) . " (" . stripslashes(showparent($codec1)) . ")"; |
||
| 932 | $content = stripslashes(one_animal($codec2)); |
||
| 933 | $content .= stripslashes(one_animal($codec1)); |
||
| 934 | $val = ''; |
||
| 935 | $xoopsTpl->assign("SADtitle", $title); |
||
| 936 | $xoopsTpl->assign("SADcontent", $content); |
||
| 937 | $xoopsTpl->assign( |
||
| 938 | "SADexplain", |
||
| 939 | strtr(_MA_PEDIGREE_COI_SDEX, array('[animalType]' => $moduleConfig['animalType'], '[animalTypes]' => $moduleConfig['animalTypes'], '[children]' => $moduleConfig['children'])) |
||
| 940 | ); |
||
| 941 | |||
| 942 | $de_cujus = 0; |
||
| 943 | $sire_ID = $_GET['s']; |
||
| 944 | $dam_ID = $_GET['d']; |
||
| 945 | $rec = "select ID from " . $xoopsDB->prefix("pedigree_tree") . " WHERE father = '" . $sire_ID . "' and mother = '" . $dam_ID . "' order by NAAM"; |
||
| 946 | $result = $xoopsDB->query($rec); |
||
| 947 | $content = ""; |
||
| 948 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 949 | $content .= one_animal($row['ID']); |
||
| 950 | } |
||
| 951 | |||
| 952 | $xoopsTpl->assign("COMtitle", strtr(_MA_PEDIGREE_COI_COMTIT, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother']))); |
||
| 953 | $xoopsTpl->assign("COMexplain", strtr(_MA_PEDIGREE_COI_COMEX, array('[animalType]' => $moduleConfig['animalType'], '[children]' => $moduleConfig['children']))); |
||
| 954 | $xoopsTpl->assign("COMcontent", $content); |
||
| 955 | |||
| 956 | if (!isset ($nb_gen)) { |
||
| 957 | $nb_gen = 7; |
||
| 958 | if ($detail) { |
||
| 959 | $nb_gen = 9; |
||
| 960 | } |
||
| 961 | } elseif ($nb_gen < $pedigree) { |
||
| 962 | $nb_gen = $pedigree; |
||
| 963 | } |
||
| 964 | |||
| 965 | $IDs = array($de_cujus + 0, $codec1 + 0, $codec2 + 0); /* Structuring animal IDs into memory */ |
||
| 966 | |||
| 967 | $nbanims = GENEALOGY(); // ************************************************************* // |
||
| 968 | |||
| 969 | for ($i = 0; $i <= $nbanims; ++$i) { |
||
| 970 | $empty[$i] = 0; |
||
| 971 | } |
||
| 972 | |||
| 973 | foreach ($fathers as $i => $a) { |
||
| 974 | if ($a) { |
||
| 975 | $fathers[$i] = $inds[$a]; |
||
| 976 | } |
||
| 977 | } /* Replace parents codes */ |
||
| 978 | foreach ($mothers as $i => $a) { |
||
| 979 | if ($a) { |
||
| 980 | $mothers[$i] = $inds[$a]; |
||
| 981 | } |
||
| 982 | } /* by their indices */ |
||
| 983 | |||
| 984 | dist_m($mothers[0]); // set "$mater" array (list of all maternal ascendants), for Anim #0 |
||
| 985 | |||
| 986 | /* Calculating CONSANGUINITY by dual (paternal & maternal) path method */ |
||
| 987 | $f = $empty; |
||
| 988 | $ICknown = $empty; |
||
| 989 | $deltaf = $empty; |
||
| 990 | $marked = $empty; |
||
| 991 | |||
| 992 | /****************** LAUNCHING ALL RECURSIONS ********************/ |
||
| 993 | /* */ |
||
| 994 | CONSANG(-1); /* [-1 is standing for de_cujus] |
||
| 995 | /* */ |
||
| 996 | /******************************************************************/ |
||
| 997 | |||
| 998 | $nf = ceil(100 * (isset($COIs[0]) ? $COIs[0] : 0)); |
||
| 999 | if ($nf >= 55) { |
||
| 1000 | $w = _MA_PEDIGREE_COI_HUGE; |
||
| 1001 | } else { |
||
| 1002 | if ($nf >= 35) { |
||
| 1003 | $w = _MA_PEDIGREE_COI_VHIG; |
||
| 1004 | } else { |
||
| 1005 | if ($nf >= 20) { |
||
| 1006 | $w = _MA_PEDIGREE_COI_HIGH; |
||
| 1007 | } else { |
||
| 1008 | if ($nf >= 10) { |
||
| 1009 | $w = _MA_PEDIGREE_COI_MEDI; |
||
| 1010 | } else { |
||
| 1011 | if ($nf >= 05) { |
||
| 1012 | $w = _MA_PEDIGREE_COI_LOW; |
||
| 1013 | } else { |
||
| 1014 | if ($nf >= 02) { |
||
| 1015 | $w = _MA_PEDIGREE_COI_VLOW; |
||
| 1016 | } else { |
||
| 1017 | if ($nf >= 01) { |
||
| 1018 | $w = _MA_PEDIGREE_COI_VVLO; |
||
| 1019 | } else { |
||
| 1020 | $w = _MA_PEDIGREE_COI_TLTB; |
||
| 1021 | } |
||
| 1022 | } |
||
| 1023 | } |
||
| 1024 | } |
||
| 1025 | } |
||
| 1026 | } |
||
| 1027 | } |
||
| 1028 | $w = _MA_PEDIGREE_COI_TVI . " " . $w; |
||
| 1029 | |||
| 1030 | $nb_all = 0; |
||
| 1031 | count_all(0, 0); // count all ascendants in flat tree |
||
| 1032 | |||
| 1033 | $nbmax = (2 << $nb_gen) - 2; |
||
| 1034 | $asctc = _MA_PEDIGREE_COI_ASTC . $nb_gen . _MA_PEDIGREE_COI_ASTCGEN . $nbmax . ")"; |
||
| 1035 | $ascuni = _MA_PEDIGREE_COI_ASDKA . $nb_gen . _MA_PEDIGREE_COI_ASGEN; |
||
| 1036 | $xoopsTpl->assign("ASCtitle", _MA_PEDIGREE_COI_ACTIT); |
||
| 1037 | $xoopsTpl->assign("ASCtc", $asctc); |
||
| 1038 | $xoopsTpl->assign("ASCuni", $ascuni); |
||
| 1039 | $xoopsTpl->assign("ASCall", $nb_all); |
||
| 1040 | $xoopsTpl->assign("ASCani", $nbani); |
||
| 1041 | $xoopsTpl->assign("ASCexplain", _MA_PEDIGREE_COI_ACEX); |
||
| 1042 | |||
| 1043 | $f0 = substr((isset($COIs[0]) ? $COIs[0] : 0), 0, 8); |
||
| 1044 | if (!$f0) { |
||
| 1045 | $f0 = "n.a."; |
||
| 1046 | } |
||
| 1047 | $f1 = 100 * $f0; |
||
| 1048 | |||
| 1049 | $xoopsTpl->assign("COItitle", strtr(_MA_PEDIGREE_COI_COITIT, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother']))); |
||
| 1050 | $xoopsTpl->assign("COIperc", $w); |
||
| 1051 | $xoopsTpl->assign("COIval", $f1); |
||
| 1052 | $xoopsTpl->assign( |
||
| 1053 | "COIexplain", |
||
| 1054 | strtr(_MA_PEDIGREE_COI_COIEX, array('[animalType]' => $moduleConfig['animalType'], '[animalTypes]' => $moduleConfig['animalTypes'], '[children]' => $moduleConfig['children'])) |
||
| 1055 | ); |
||
| 1056 | $xoopsTpl->assign("COIcoi", _MA_PEDIGREE_COI_COI); |
||
| 1057 | $dogid = isset($_GET['dogid']) ? $_GET['dogid'] : 0; |
||
| 1058 | $query = "UPDATE " . $xoopsDB->prefix("pedigree_tree") . " SET coi=" . $f1 . " WHERE ID = '$dogid'"; |
||
| 1059 | $xoopsDB->queryf($query); |
||
| 1060 | arsort($deltaf); |
||
| 1061 | $j = 1; |
||
| 1062 | foreach ($deltaf as $i => $v) { |
||
| 1063 | if ($j > 12) { |
||
| 1064 | break; |
||
| 1065 | } |
||
| 1066 | ++$j; |
||
| 1067 | $code = isset($IDs[$i]) ? $IDs[$i] : 0; |
||
| 1068 | $v = substr($v, 0, 7); |
||
| 1069 | $animal = set_name(isset($IDs[$i]) ? $IDs[$i] : 0); |
||
| 1070 | $name = isset($animal[1]) ? $animal[1] : ''; |
||
| 1071 | if (!$name) { |
||
| 1072 | $name = $i . ' [' . (isset($IDs[$i]) ? $IDs[$i] : '') . ']'; |
||
| 1073 | } |
||
| 1074 | if ($v > 0.0001 && $v < 1.0) { |
||
| 1075 | $dogs[] = array('id' => $code, 'name' => stripslashes($name), 'coi' => (100 * $v)); |
||
| 1076 | } |
||
| 1077 | } |
||
| 1078 | |||
| 1079 | $xoopsTpl->assign("TCAtitle", _MA_PEDIGREE_COI_TCATIT); |
||
| 1080 | $xoopsTpl->assign("TCApib", _MA_PEDIGREE_COI_TCApib); |
||
| 1081 | $xoopsTpl->assign("dogs", isset($dogs) ? $dogs : 0); |
||
| 1082 | $xoopsTpl->assign( |
||
| 1083 | "TCAexplain", |
||
| 1084 | strtr( |
||
| 1085 | _MA_PEDIGREE_COI_TCAEX, |
||
| 1086 | array( |
||
| 1087 | '[animalType]' => $moduleConfig['animalType'], |
||
| 1088 | '[animalTypes]' => $moduleConfig['animalTypes'], |
||
| 1089 | '[children]' => $moduleConfig['children'], |
||
| 1090 | '[mother]' => $moduleConfig['mother'], |
||
| 1091 | '[father]' => $moduleConfig['father'] |
||
| 1092 | ) |
||
| 1093 | ) |
||
| 1094 | ); |
||
| 1095 | |||
| 1096 | if ($detail) { |
||
| 1097 | if (!isset ($verbose)) { |
||
| 1098 | $verbose = 0; |
||
| 1099 | } |
||
| 1100 | if (count($COIs) > 1) { |
||
| 1101 | $ICs = $COIs; |
||
| 1102 | arsort($ICs); |
||
| 1103 | $j = 1; |
||
| 1104 | foreach ($ICs as $i => $ic) { |
||
| 1105 | if ($j > 12) { |
||
| 1106 | break; |
||
| 1107 | } |
||
| 1108 | ++$j; |
||
| 1109 | $ID = $IDs[$i]; |
||
| 1110 | $ani = set_name($ID); |
||
| 1111 | $name = isset($ani[1]) ? $ani[1] : ''; |
||
| 1112 | $ic = substr($ic, 0, 6); |
||
| 1113 | if ($ic > 0.125 && $i) { |
||
| 1114 | $mia[] = array('id' => $ID, 'name' => stripslashes($name), 'coi' => (100 * $ic)); |
||
| 1115 | } |
||
| 1116 | } |
||
| 1117 | } |
||
| 1118 | $xoopsTpl->assign("MIAtitle", _MA_PEDIGREE_COI_MIATIT); |
||
| 1119 | $xoopsTpl->assign("mia", isset($mia) ? $mia : 0); |
||
| 1120 | $xoopsTpl->assign("MIAexplain", strtr(_MA_PEDIGREE_COI_MIAEX, array('[animalType]' => $moduleConfig['animalType']))); |
||
| 1121 | |||
| 1122 | if (!$ICknown[1]) { |
||
| 1123 | $marked = $empty; |
||
| 1124 | CONSANG(1); |
||
| 1125 | } // Sire |
||
| 1126 | if (!$ICknown[2]) { |
||
| 1127 | $marked = $empty; |
||
| 1128 | CONSANG(2); |
||
| 1129 | } // Dam |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% 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...
|
|||
| 1130 | // $COR = 2.0 * $COIs[0] / sqrt((1. + $COIs[1]) * (1. + $COIs[2])); |
||
| 1131 | $COR = 2.0 * (isset($COIs[0]) ? $COIs[0] : 0) / sqrt((1. + (isset($COIs[1]) ? $COIs[1] : 0)) * (1. + (isset($COIs[2]) ? $COIs[2] : 0))); |
||
| 1132 | $COR = substr($COR, 0, 8); |
||
| 1133 | if (!$COR) { |
||
| 1134 | $COR = "n.a."; |
||
| 1135 | } |
||
| 1136 | $f1 = substr((isset($COIs[1]) ? $COIs[1] : 0), 0, 8); |
||
| 1137 | $f2 = substr((isset($COIs[2]) ? $COIs[2] : 0), 0, 8); |
||
| 1138 | if (!$f1) { |
||
| 1139 | $f1 = "n.a."; |
||
| 1140 | } |
||
| 1141 | if (!$f2) { |
||
| 1142 | $f2 = "n.a."; |
||
| 1143 | } |
||
| 1144 | $SSDcor = (100 * $COR); |
||
| 1145 | $SSDsire = (100 * $f2); |
||
| 1146 | $SSDdam = (100 * $f1); |
||
| 1147 | } |
||
| 1148 | |||
| 1149 | $xoopsTpl->assign("SSDtitle", strtr(_MA_PEDIGREE_COI_SSDTIT, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother']))); |
||
| 1150 | $xoopsTpl->assign("SSDcortit", _MA_PEDIGREE_COI_SSDcor); |
||
| 1151 | $xoopsTpl->assign("SSDbsd", strtr(_MA_PEDIGREE_COI_SDDbsd, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother']))); |
||
| 1152 | $xoopsTpl->assign("SSDcor", $SSDcor); |
||
| 1153 | |||
| 1154 | $xoopsTpl->assign("SSDS", _MA_PEDIGREE_COI_COI . _MA_PEDIGREE_FROM . strtr(_MA_PEDIGREE_FLD_FATH, array('[father]' => $moduleConfig['father']))); |
||
| 1155 | $xoopsTpl->assign("SSDsire", $SSDsire); |
||
| 1156 | $xoopsTpl->assign("SSDM", _MA_PEDIGREE_COI_COI . _MA_PEDIGREE_FROM . strtr(_MA_PEDIGREE_FLD_MOTH, array('[mother]' => $moduleConfig['mother']))); |
||
| 1157 | $xoopsTpl->assign("SSDdam", $SSDdam); |
||
| 1158 | |||
| 1159 | // echo "SSDsire : ".$SSDsire."<br />"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% 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...
|
|||
| 1160 | // echo "SSDdam : ".$SSDdam."<br />"; |
||
| 1161 | // print_r($COIs); |
||
| 1162 | |||
| 1163 | $xoopsTpl->assign("SSDexplain", strtr(_MA_PEDIGREE_COI_SSDEX, array('[father]' => $moduleConfig['father'], '[mother]' => $moduleConfig['mother'], '[animalType]' => $moduleConfig['animalTypes']))); |
||
| 1164 | $xoopsTpl->assign("TNXtitle", _MA_PEDIGREE_COI_TNXTIT); |
||
| 1165 | $xoopsTpl->assign("TNXcontent", _MA_PEDIGREE_COI_TNXCON); |
||
| 1166 | $xoopsTpl->assign("Name", _MA_PEDIGREE_FLD_NAME); |
||
| 1167 | $xoopsTpl->assign("Gender", _MA_PEDIGREE_FLD_GEND); |
||
| 1168 | $xoopsTpl->assign("Children", strtr(_MA_PEDIGREE_FLD_PUPS, array('[children]' => $moduleConfig['children']))); |
||
| 1169 | |||
| 1170 | //add data to smarty template |
||
| 1171 | $xoopsTpl->assign("explain", _MA_PEDIGREE_EXPLAIN); |
||
| 1172 | |||
| 1173 | //comments and footer |
||
| 1174 | include XOOPS_ROOT_PATH . "/footer.php"; |
||
| 1175 |
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.