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 | // XOOPS - PHP Content Management System // |
||
| 4 | // Copyright (c) 2000 XOOPS.org // |
||
| 5 | // <http://www.xoops.org/> // |
||
| 6 | // ------------------------------------------------------------------------ // |
||
| 7 | // This program is free software; you can redistribute it and/or modify // |
||
| 8 | // it under the terms of the GNU General Public License as published by // |
||
| 9 | // the Free Software Foundation; either version 2 of the License, or // |
||
| 10 | // (at your option) any later version. // |
||
| 11 | // // |
||
| 12 | // You may not change or alter any portion of this comment or credits // |
||
| 13 | // of supporting developers from this source code or any supporting // |
||
| 14 | // source code which is considered copyrighted (c) material of the // |
||
| 15 | // original comment or credit authors. // |
||
| 16 | // // |
||
| 17 | // This program is distributed in the hope that it will be useful, // |
||
| 18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
| 19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
| 20 | // GNU General Public License for more details. // |
||
| 21 | // // |
||
| 22 | // You should have received a copy of the GNU General Public License // |
||
| 23 | // along with this program; if not, write to the Free Software // |
||
| 24 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
| 25 | // ------------------------------------------------------------------------- // |
||
| 26 | // Author: Tobias Liegl (AKA CHAPI) // |
||
| 27 | // Site: http://www.chapi.de // |
||
| 28 | // Project: The XOOPS Project // |
||
| 29 | // ------------------------------------------------------------------------- // |
||
| 30 | require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/class_field.php"); |
||
| 31 | require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/config.php"); |
||
| 32 | |||
| 33 | //get module configuration |
||
| 34 | $module_handler =& xoops_gethandler('module'); |
||
| 35 | $module =& $module_handler->getByDirname("pedigree"); |
||
| 36 | $config_handler =& xoops_gethandler('config'); |
||
| 37 | $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param $columncount |
||
| 41 | * |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | function sorttable($columncount) |
||
| 45 | { |
||
| 46 | $ttemp = ""; |
||
| 47 | if ($columncount > 1) { |
||
| 48 | for ($t = 1; $t < $columncount; ++$t) { |
||
| 49 | $ttemp .= "'S',"; |
||
| 50 | } |
||
| 51 | $tsarray = "initSortTable('Result',Array(" . $ttemp . "'S'));"; |
||
| 52 | } else { |
||
| 53 | $tsarray = "initSortTable('Result',Array('S'));"; |
||
| 54 | } |
||
| 55 | |||
| 56 | return $tsarray; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param $num |
||
| 61 | * |
||
| 62 | * @return string |
||
| 63 | */ |
||
| 64 | function uploadedpict($num) |
||
| 65 | { |
||
| 66 | global $xoopsModule; |
||
| 67 | global $xoopsModule, $xoopsModuleConfig; |
||
| 68 | $max_imgsize = $xoopsModuleConfig['maxfilesize']; //1024000; |
||
| 69 | $max_imgwidth = $xoopsModuleConfig['maximgwidth']; //1500; |
||
| 70 | $max_imgheight = $xoopsModuleConfig['maximgheight']; //1000; |
||
| 71 | $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); |
||
| 72 | // $img_dir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/images" ; |
||
| 73 | $img_dir = $xoopsModuleConfig['uploaddir'] . '/images'; |
||
| 74 | include_once(XOOPS_ROOT_PATH . "/class/uploader.php"); |
||
| 75 | $field = $_POST["xoops_upload_file"][$num]; |
||
| 76 | if (!empty($field) || $field != "") { |
||
| 77 | $uploader = new XoopsMediaUploader($img_dir, $allowed_mimetypes, $max_imgsize, $max_imgwidth, $max_imgheight); |
||
| 78 | $uploader->setPrefix('img'); |
||
| 79 | if ($uploader->fetchMedia($field) && $uploader->upload()) { |
||
| 80 | $photo = $uploader->getSavedFileName(); |
||
| 81 | } else { |
||
| 82 | echo $uploader->getErrors(); |
||
| 83 | } |
||
| 84 | makethumbs($photo); |
||
| 85 | |||
| 86 | return $photo; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @param $filename |
||
| 92 | * |
||
| 93 | * @return bool |
||
| 94 | */ |
||
| 95 | function makethumbs($filename) |
||
| 96 | {/* |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
47% 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...
|
|||
| 97 | require_once('phpthumb/phpthumb.class.php'); |
||
| 98 | $thumbnail_widths = array(150, 400); |
||
| 99 | foreach ($thumbnail_widths as $thumbnail_width) { |
||
| 100 | $phpThumb = new phpThumb(); |
||
| 101 | // set data |
||
| 102 | $phpThumb->setSourceFilename('images/' . $filename); |
||
| 103 | $phpThumb->w = $thumbnail_width; |
||
| 104 | $phpThumb->config_output_format = 'jpeg'; |
||
| 105 | // generate & output thumbnail |
||
| 106 | $output_filename = 'images/thumbnails/' . basename($filename) . '_' . $thumbnail_width . '.' . $phpThumb->config_output_format; |
||
| 107 | if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! |
||
| 108 | if ($output_filename) { |
||
| 109 | if ($phpThumb->RenderToFile($output_filename)) { |
||
| 110 | // do something on success |
||
| 111 | //echo 'Successfully rendered:<br><img src="'.$output_filename.'">'; |
||
| 112 | } else { |
||
| 113 | echo 'Failed (size=' . $thumbnail_width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>'; |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } else { |
||
| 117 | echo 'Failed (size=' . $thumbnail_width . '):<pre>' . implode("\n\n", $phpThumb->debugmessages) . '</pre>'; |
||
| 118 | } |
||
| 119 | unset($phpThumb); |
||
| 120 | } |
||
| 121 | |||
| 122 | return true; |
||
| 123 | |||
| 124 | */ |
||
| 125 | |||
| 126 | // load the image |
||
| 127 | global $xoopsModule; |
||
| 128 | require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/library/Zebra_Image.php'); |
||
| 129 | $thumbnail_widths = array(150, 400); |
||
| 130 | |||
| 131 | // indicate a target image |
||
| 132 | // note that there's no extra property to set in order to specify the target |
||
| 133 | // image's type -simply by writing '.jpg' as extension will instruct the script |
||
| 134 | // to create a 'jpg' file |
||
| 135 | $config_output_format = 'jpeg'; |
||
| 136 | |||
| 137 | // create a new instance of the class |
||
| 138 | $image = new Zebra_Image(); |
||
| 139 | // indicate a source image (a GIF, PNG or JPEG file) |
||
| 140 | $image->source_path = PEDIGREE_UPLOAD_PATH . '/images/' . $filename; |
||
| 141 | |||
| 142 | foreach ($thumbnail_widths as $thumbnail_width) { |
||
| 143 | |||
| 144 | // generate & output thumbnail |
||
| 145 | $output_filename = PEDIGREE_UPLOAD_PATH . '/images/thumbnails/' . basename($filename) . '_' . $thumbnail_width . '.' . $config_output_format; |
||
| 146 | $image->target_path = $output_filename; |
||
| 147 | // since in this example we're going to have a jpeg file, let's set the output |
||
| 148 | // image's quality |
||
| 149 | $image->jpeg_quality = 100; |
||
| 150 | // some additional properties that can be set |
||
| 151 | // read about them in the documentation |
||
| 152 | $image->preserve_aspect_ratio = true; |
||
| 153 | $image->enlarge_smaller_images = true; |
||
| 154 | $image->preserve_time = true; |
||
| 155 | |||
| 156 | // resize the image to exactly 100x100 pixels by using the "crop from center" method |
||
| 157 | // (read more in the overview section or in the documentation) |
||
| 158 | // and if there is an error, check what the error is about |
||
| 159 | if (!$image->resize($thumbnail_width, 0)) { |
||
| 160 | // if there was an error, let's see what the error is about |
||
| 161 | switch ($image->error) { |
||
| 162 | |||
| 163 | case 1: |
||
| 164 | echo 'Source file could not be found!'; |
||
| 165 | break; |
||
| 166 | case 2: |
||
| 167 | echo 'Source file is not readable!'; |
||
| 168 | break; |
||
| 169 | case 3: |
||
| 170 | echo 'Could not write target file!'; |
||
| 171 | break; |
||
| 172 | case 4: |
||
| 173 | echo 'Unsupported source file format!'; |
||
| 174 | break; |
||
| 175 | case 5: |
||
| 176 | echo 'Unsupported target file format!'; |
||
| 177 | break; |
||
| 178 | case 6: |
||
| 179 | echo 'GD library version does not support target file format!'; |
||
| 180 | break; |
||
| 181 | case 7: |
||
| 182 | echo 'GD library is not installed!'; |
||
| 183 | break; |
||
| 184 | case 8: |
||
| 185 | echo '"chmod" command is disabled via configuration!'; |
||
| 186 | break; |
||
| 187 | } |
||
| 188 | |||
| 189 | // if no errors |
||
| 190 | } else { |
||
| 191 | echo 'Success!'; |
||
| 192 | } |
||
| 193 | |||
| 194 | /* |
||
|
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...
|
|||
| 195 | if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it! |
||
| 196 | if ($output_filename) { |
||
| 197 | if ($phpThumb->RenderToFile($output_filename)) { |
||
| 198 | // do something on success |
||
| 199 | //echo 'Successfully rendered:<br><img src="'.$output_filename.'">'; |
||
| 200 | } else { |
||
| 201 | echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; |
||
| 202 | } |
||
| 203 | } |
||
| 204 | } else { |
||
| 205 | echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>'; |
||
| 206 | } |
||
| 207 | */ |
||
| 208 | |||
| 209 | } |
||
| 210 | |||
| 211 | unset($image); |
||
| 212 | |||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * @param $string |
||
| 217 | * |
||
| 218 | * @return string |
||
| 219 | */ |
||
| 220 | function unhtmlentities($string) |
||
| 221 | { |
||
| 222 | $trans_tbl = get_html_translation_table(HTML_ENTITIES); |
||
| 223 | $trans_tbl = array_flip($trans_tbl); |
||
| 224 | |||
| 225 | return strtr($string, $trans_tbl); |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @param $oid |
||
| 230 | * @param $gender |
||
| 231 | * |
||
| 232 | * @return null |
||
| 233 | */ |
||
| 234 | function pups($oid, $gender) |
||
| 235 | { |
||
| 236 | global $xoopsDB, $numofcolumns, $nummatch, $pages, $columns, $dogs; |
||
| 237 | $content = ""; |
||
| 238 | if ($gender == 0) { |
||
| 239 | $sqlquery = "SELECT d.id as d_id, d.naam as d_naam, d.roft as d_roft, d.* FROM " . $xoopsDB->prefix("pedigree_tree") . " d LEFT JOIN " . $xoopsDB->prefix("pedigree_tree") |
||
| 240 | . " f ON d.father = f.id LEFT JOIN " . $xoopsDB->prefix("pedigree_tree") . " m ON d.mother = m.id where d.father=" . $oid . " order by d.naam"; |
||
| 241 | View Code Duplication | } else { |
|
| 242 | $sqlquery = "SELECT d.id as d_id, d.naam as d_naam, d.roft as d_roft, d.* FROM " . $xoopsDB->prefix("pedigree_tree") . " d LEFT JOIN " . $xoopsDB->prefix("pedigree_tree") |
||
| 243 | . " f ON d.father = f.id LEFT JOIN " . $xoopsDB->prefix("pedigree_tree") . " m ON d.mother = m.id where d.mother=" . $oid . " order by d.naam"; |
||
| 244 | } |
||
| 245 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 246 | $nummatch = $xoopsDB->getRowsNum($queryresult); |
||
| 247 | |||
| 248 | $animal = new Animal(); |
||
| 249 | //test to find out how many user fields there are... |
||
| 250 | $fields = $animal->numoffields(); |
||
| 251 | $numofcolumns = 1; |
||
| 252 | $columns[] = array('columnname' => "Name"); |
||
| 253 | View Code Duplication | for ($i = 0; $i < count($fields); ++$i) { |
|
| 254 | $userfield = new Field($fields[$i], $animal->getconfig()); |
||
| 255 | $fieldType = $userfield->getSetting("FieldType"); |
||
| 256 | $fieldobject = new $fieldType($userfield, $animal); |
||
| 257 | //create empty string |
||
| 258 | $lookupvalues = ""; |
||
| 259 | if ($userfield->active() && $userfield->inlist()) { |
||
| 260 | if ($userfield->haslookup()) { |
||
| 261 | $lookupvalues = $userfield->lookup($fields[$i]); |
||
| 262 | //debug information |
||
| 263 | //print_r($lookupvalues); |
||
| 264 | } |
||
| 265 | $columns[] = array('columnname' => $fieldobject->fieldname, 'columnnumber' => $userfield->getID(), 'lookupval' => $lookupvalues); |
||
| 266 | ++$numofcolumns; |
||
| 267 | unset($lookupvalues); |
||
| 268 | } |
||
| 269 | } |
||
| 270 | |||
| 271 | View Code Duplication | while ($rowres = $xoopsDB->fetchArray($queryresult)) { |
|
| 272 | if ($rowres['d_roft'] == "0") { |
||
| 273 | $gender = "<img src=\"assets/images/male.gif\">"; |
||
| 274 | } else { |
||
| 275 | $gender = "<img src=\"assets/images/female.gif\">"; |
||
| 276 | } |
||
| 277 | $name = stripslashes($rowres['d_naam']);; |
||
| 278 | //empty array |
||
| 279 | unset($columnvalue); |
||
| 280 | //fill array |
||
| 281 | for ($i = 1; $i < ($numofcolumns); ++$i) { |
||
| 282 | $x = $columns[$i]['columnnumber']; |
||
| 283 | if (is_array($columns[$i]['lookupval'])) { |
||
| 284 | foreach ($columns[$i]['lookupval'] as $key => $keyvalue) { |
||
| 285 | if ($keyvalue['id'] == $rowres['user' . $x]) { |
||
| 286 | $value = $keyvalue['value']; |
||
| 287 | } |
||
| 288 | } |
||
| 289 | //debug information |
||
| 290 | ///echo $columns[$i]['columnname']."is an array !"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
77% 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...
|
|||
| 291 | } //format value - cant use object because of query count |
||
| 292 | elseif (substr($rowres['user' . $x], 0, 7) == 'http://') { |
||
| 293 | $value = "<a href=\"" . $rowres['user' . $x] . "\">" . $rowres['user' . $x] . "</a>"; |
||
| 294 | } else { |
||
| 295 | $value = $rowres['user' . $x]; |
||
| 296 | } |
||
| 297 | $columnvalue[] = array('value' => $value); |
||
| 298 | } |
||
| 299 | $dogs[] = array( |
||
| 300 | 'id' => $rowres['d_id'], |
||
| 301 | 'name' => $name, |
||
| 302 | 'gender' => $gender, |
||
| 303 | 'link' => "<a href=\"dog.php?id=" . $rowres['d_id'] . "\">" . $name . "</a>", |
||
| 304 | 'colour' => "", |
||
| 305 | 'number' => "", |
||
| 306 | 'usercolumns' => $columnvalue |
||
| 307 | ); |
||
| 308 | } |
||
| 309 | |||
| 310 | return null; |
||
| 311 | } |
||
| 312 | |||
| 313 | /** |
||
| 314 | * @param $oid |
||
| 315 | * @param $pa |
||
| 316 | * @param $ma |
||
| 317 | * |
||
| 318 | * @return null |
||
| 319 | */ |
||
| 320 | function bas($oid, $pa, $ma) |
||
| 321 | { |
||
| 322 | global $xoopsDB, $numofcolumns1, $nummatch1, $pages1, $columns1, $dogs1; |
||
| 323 | if ($pa == "0" && $ma == "0") { |
||
| 324 | $sqlquery |
||
| 325 | = "SELECT * FROM " . $xoopsDB->prefix("pedigree_tree") . " where father = " . $pa . " and mother = " . $ma . " and ID != " . $oid . " and father != '0' and mother !='0' order by NAAM"; |
||
| 326 | View Code Duplication | } else { |
|
| 327 | $sqlquery = "SELECT * FROM " . $xoopsDB->prefix("pedigree_tree") . " where father = " . $pa . " and mother = " . $ma . " and ID != " . $oid . " order by NAAM"; |
||
| 328 | } |
||
| 329 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 330 | $nummatch1 = $xoopsDB->getRowsNum($queryresult); |
||
| 331 | |||
| 332 | $animal = new Animal(); |
||
| 333 | //test to find out how many user fields there are... |
||
| 334 | $fields = $animal->numoffields(); |
||
| 335 | $numofcolumns1 = 1; |
||
| 336 | $columns1[] = array('columnname' => "Name"); |
||
| 337 | View Code Duplication | for ($i = 0; $i < count($fields); ++$i) { |
|
| 338 | $userfield = new Field($fields[$i], $animal->getconfig()); |
||
| 339 | $fieldType = $userfield->getSetting("FieldType"); |
||
| 340 | $fieldobject = new $fieldType($userfield, $animal); |
||
| 341 | //create empty string |
||
| 342 | $lookupvalues = ""; |
||
| 343 | if ($userfield->active() && $userfield->inlist()) { |
||
| 344 | if ($userfield->haslookup()) { |
||
| 345 | $lookupvalues = $userfield->lookup($fields[$i]); |
||
| 346 | //debug information |
||
| 347 | //print_r($lookupvalues); |
||
| 348 | } |
||
| 349 | $columns1[] = array('columnname' => $fieldobject->fieldname, 'columnnumber' => $userfield->getID(), 'lookupval' => $lookupvalues); |
||
| 350 | ++$numofcolumns1; |
||
| 351 | unset($lookupvalues); |
||
| 352 | } |
||
| 353 | } |
||
| 354 | |||
| 355 | View Code Duplication | while ($rowres = $xoopsDB->fetchArray($queryresult)) { |
|
| 356 | if ($rowres['roft'] == "0") { |
||
| 357 | $gender = "<img src=\"assets/images/male.gif\">"; |
||
| 358 | } else { |
||
| 359 | $gender = "<img src=\"assets/images/female.gif\">"; |
||
| 360 | } |
||
| 361 | $name = stripslashes($rowres['NAAM']);; |
||
| 362 | //empty array |
||
| 363 | unset($columnvalue1); |
||
| 364 | //fill array |
||
| 365 | for ($i = 1; $i < ($numofcolumns1); ++$i) { |
||
| 366 | $x = $columns1[$i]['columnnumber']; |
||
| 367 | if (is_array($columns1[$i]['lookupval'])) { |
||
| 368 | foreach ($columns1[$i]['lookupval'] as $key => $keyvalue) { |
||
| 369 | if ($keyvalue['id'] == $rowres['user' . $x]) { |
||
| 370 | $value = $keyvalue['value']; |
||
| 371 | } |
||
| 372 | } |
||
| 373 | //debug information |
||
| 374 | ///echo $columns[$i]['columnname']."is an array !"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
77% 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...
|
|||
| 375 | } //format value - cant use object because of query count |
||
| 376 | elseif (substr($rowres['user' . $x], 0, 7) == 'http://') { |
||
| 377 | $value = "<a href=\"" . $rowres['user' . $x] . "\">" . $rowres['user' . $x] . "</a>"; |
||
| 378 | } else { |
||
| 379 | $value = $rowres['user' . $x]; |
||
| 380 | } |
||
| 381 | $columnvalue1[] = array('value' => $value); |
||
| 382 | } |
||
| 383 | $dogs1[] = array( |
||
| 384 | 'id' => $rowres['ID'], |
||
| 385 | 'name' => $name, |
||
| 386 | 'gender' => $gender, |
||
| 387 | 'link' => "<a href=\"dog.php?id=" . $rowres['ID'] . "\">" . $name . "</a>", |
||
| 388 | 'colour' => "", |
||
| 389 | 'number' => "", |
||
| 390 | 'usercolumns' => $columnvalue1 |
||
| 391 | ); |
||
| 392 | } |
||
| 393 | |||
| 394 | return null; |
||
| 395 | } |
||
| 396 | |||
| 397 | /** |
||
| 398 | * @param $oid |
||
| 399 | * @param $breeder |
||
| 400 | * |
||
| 401 | * @return string |
||
| 402 | */ |
||
| 403 | function breederof($oid, $breeder) |
||
| 404 | { |
||
| 405 | global $xoopsDB; |
||
| 406 | $content = ""; |
||
| 407 | |||
| 408 | View Code Duplication | if ($breeder == 0) { |
|
| 409 | $sqlquery = "SELECT ID, NAAM, roft from " . $xoopsDB->prefix("pedigree_tree") . " WHERE id_owner = '" . $oid . "' order by NAAM"; |
||
| 410 | } else { |
||
| 411 | $sqlquery = "SELECT ID, NAAM, roft from " . $xoopsDB->prefix("pedigree_tree") . " WHERE id_breeder = '" . $oid . "' order by NAAM"; |
||
| 412 | } |
||
| 413 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 414 | while ($rowres = $xoopsDB->fetchArray($queryresult)) { |
||
| 415 | if ($rowres['roft'] == "0") { |
||
| 416 | $gender = "<img src=\"assets/images/male.gif\">"; |
||
| 417 | } else { |
||
| 418 | $gender = "<img src=\"assets/images/female.gif\">"; |
||
| 419 | } |
||
| 420 | $link = "<a href=\"dog.php?id=" . $rowres['ID'] . "\">" . stripslashes($rowres['NAAM']) . "</a>"; |
||
| 421 | $content .= $gender . " " . $link . "<br />"; |
||
| 422 | } |
||
| 423 | |||
| 424 | return $content; |
||
| 425 | } |
||
| 426 | |||
| 427 | /** |
||
| 428 | * @param $oid |
||
| 429 | * |
||
| 430 | * @return string |
||
| 431 | */ |
||
| 432 | View Code Duplication | function getname($oid) |
|
| 433 | { |
||
| 434 | global $xoopsDB; |
||
| 435 | $sqlquery = "SELECT NAAM from " . $xoopsDB->prefix("pedigree_tree") . " WHERE ID = '" . $oid . "'"; |
||
| 436 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 437 | while ($rowres = $xoopsDB->fetchArray($queryresult)) { |
||
| 438 | $an = stripslashes($rowres['NAAM']); |
||
| 439 | } |
||
| 440 | |||
| 441 | return $an; |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * @param $PA |
||
| 446 | */ |
||
| 447 | View Code Duplication | function showparent($PA) |
|
| 448 | { |
||
| 449 | global $xoopsDB; |
||
| 450 | $sqlquery = "SELECT NAAM from " . $xoopsDB->prefix("pedigree_tree") . " where ID='" . $PA . "'"; |
||
| 451 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 452 | while ($rowres = $xoopsDB->fetchArray($queryresult)) { |
||
| 453 | $result = $rowres['NAAM']; |
||
| 454 | } |
||
| 455 | if (isset($result)) { |
||
| 456 | return $result; |
||
| 457 | } else { |
||
| 458 | return; |
||
| 459 | } |
||
| 460 | } |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @param $naam_hond |
||
| 464 | * |
||
| 465 | * @return mixed |
||
| 466 | */ |
||
| 467 | View Code Duplication | function findid($naam_hond) |
|
| 468 | { |
||
| 469 | global $xoopsDB; |
||
| 470 | $sqlquery = "SELECT ID from " . $xoopsDB->prefix("pedigree_tree") . " where NAAM= '$naam_hond'"; |
||
| 471 | $queryresult = $xoopsDB->query($sqlquery); |
||
| 472 | while ($rowres = $xoopsDB->fetchArray($queryresult)) { |
||
| 473 | $result = $rowres['ID']; |
||
| 474 | } |
||
| 475 | |||
| 476 | return $result; |
||
| 477 | } |
||
| 478 | |||
| 479 | /** |
||
| 480 | * @param $result |
||
| 481 | * @param $prefix |
||
| 482 | * @param $link |
||
| 483 | * @param $element |
||
| 484 | */ |
||
| 485 | function makelist($result, $prefix, $link, $element) |
||
| 486 | { |
||
| 487 | global $xoopsDB, $xoopsTpl; |
||
| 488 | $animal = new Animal(); |
||
| 489 | //test to find out how many user fields there are... |
||
| 490 | $fields = $animal->numoffields(); |
||
| 491 | $numofcolumns = 1; |
||
| 492 | $columns[] = array('columnname' => "Name"); |
||
| 493 | View Code Duplication | for ($i = 0; $i < count($fields); ++$i) { |
|
| 494 | $userfield = new Field($fields[$i], $animal->getconfig()); |
||
| 495 | $fieldType = $userfield->getSetting("FieldType"); |
||
| 496 | $fieldobject = new $fieldType($userfield, $animal); |
||
| 497 | if ($userfield->active() && $userfield->inlist()) { |
||
| 498 | if ($userfield->haslookup()) { |
||
| 499 | $id = $userfield->getid(); |
||
| 500 | $q = $userfield->lookup($id); |
||
| 501 | } else { |
||
| 502 | $q = ""; |
||
| 503 | } |
||
| 504 | $columns[] = array('columnname' => $fieldobject->fieldname, 'columnnumber' => $userfield->getID(), 'lookuparray' => $q); |
||
| 505 | ++$numofcolumns; |
||
| 506 | } |
||
| 507 | } |
||
| 508 | |||
| 509 | //add prelimenairy row to array if passed |
||
| 510 | if (is_array($prefix)) { |
||
| 511 | $dogs[] = $prefix; |
||
| 512 | } |
||
| 513 | |||
| 514 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 515 | //reset $gender |
||
| 516 | $gender = ""; |
||
| 517 | View Code Duplication | if (!empty($xoopsUser)) { |
|
| 518 | if ($row['user'] == $xoopsUser->getVar("uid") || $modadmin == true) { |
||
| 519 | $gender = "<a href=\"dog.php?id=" . $row['ID'] . "\"><img src=\"assets/images/edit.gif\" alt=" . _MA_PEDIGREE_BTN_EDIT . "></a><a href=\"delete.php?id=" . $row['ID'] |
||
| 520 | . "\"><img src=\"assets/images/delete.gif\" alt=" . _MA_PEDIGREE_BTN_DELE . "></a>"; |
||
| 521 | } else { |
||
| 522 | $gender = ""; |
||
| 523 | } |
||
| 524 | } |
||
| 525 | if ($row['roft'] == 0) { |
||
| 526 | $gender .= "<img src=\"assets/images/male.gif\">"; |
||
| 527 | } else { |
||
| 528 | $gender .= "<img src=\"assets/images/female.gif\">"; |
||
| 529 | } |
||
| 530 | if ($row['foto'] != '') { |
||
| 531 | $camera = " <img src=\"assets/images/camera.png\">"; |
||
| 532 | } else { |
||
| 533 | $camera = ""; |
||
| 534 | } |
||
| 535 | $name = stripslashes($row['NAAM']) . $camera; |
||
| 536 | //empty array |
||
| 537 | unset($columnvalue); |
||
| 538 | //fill array |
||
| 539 | for ($i = 1; $i < ($numofcolumns); ++$i) { |
||
| 540 | $x = $columns[$i]['columnnumber']; |
||
| 541 | $lookuparray = $columns[$i]['lookuparray']; |
||
| 542 | if (is_array($lookuparray)) { |
||
| 543 | for ($index = 0; $index < count($lookuparray); ++$index) { |
||
| 544 | if ($lookuparray[$index]['id'] == $row['user' . $x]) { |
||
| 545 | //echo "<h1>".$lookuparray[$index]['id']."</h1>"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
79% 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...
|
|||
| 546 | $value = $lookuparray[$index]['value']; |
||
| 547 | } |
||
| 548 | } |
||
| 549 | } //format value - cant use object because of query count |
||
| 550 | elseif (substr($row['user' . $x], 0, 7) == 'http://') { |
||
| 551 | $value = "<a href=\"" . $row['user' . $x] . "\">" . $row['user' . $x] . "</a>"; |
||
| 552 | } else { |
||
| 553 | $value = $row['user' . $x]; |
||
| 554 | } |
||
| 555 | $columnvalue[] = array('value' => $value); |
||
| 556 | unset($value); |
||
| 557 | } |
||
| 558 | |||
| 559 | $linkto = "<a href=\"" . $link . $row[$element] . "\">" . $name . "</a>"; |
||
| 560 | //create array |
||
| 561 | $dogs[] = array('id' => $row['ID'], 'name' => $name, 'gender' => $gender, 'link' => $linkto, 'colour' => "", 'number' => "", 'usercolumns' => $columnvalue); |
||
| 562 | } |
||
| 563 | |||
| 564 | //add data to smarty template |
||
| 565 | //assign dog |
||
| 566 | $xoopsTpl->assign("dogs", $dogs); |
||
| 567 | $xoopsTpl->assign("columns", $columns); |
||
| 568 | $xoopsTpl->assign("numofcolumns", $numofcolumns); |
||
| 569 | $xoopsTpl->assign("tsarray", sorttable($numofcolumns)); |
||
| 570 | |||
| 571 | } |
||
| 572 | |||
| 573 | /***************Blocks************** |
||
| 574 | * |
||
| 575 | * @param $cats |
||
| 576 | * |
||
| 577 | * @return string |
||
| 578 | */ |
||
| 579 | function animal_block_addCatSelect($cats) |
||
| 580 | { |
||
| 581 | if (is_array($cats)) { |
||
| 582 | $cat_sql = "(" . current($cats); |
||
| 583 | array_shift($cats); |
||
| 584 | foreach ($cats as $cat) { |
||
| 585 | $cat_sql .= "," . $cat; |
||
| 586 | } |
||
| 587 | $cat_sql .= ")"; |
||
| 588 | } |
||
| 589 | |||
| 590 | return $cat_sql; |
||
| 591 | } |
||
| 592 | |||
| 593 | /** |
||
| 594 | * @param $global |
||
| 595 | * @param $key |
||
| 596 | * @param string $default |
||
| 597 | * @param string $type |
||
| 598 | * |
||
| 599 | * @return mixed|string |
||
| 600 | */ |
||
| 601 | function animal_CleanVars(&$global, $key, $default = '', $type = 'int') |
||
| 602 | { |
||
| 603 | switch ($type) { |
||
| 604 | case 'string': |
||
| 605 | $ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; |
||
| 606 | break; |
||
| 607 | case 'int': |
||
| 608 | default: |
||
| 609 | $ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; |
||
| 610 | break; |
||
| 611 | } |
||
| 612 | if ($ret === false) { |
||
| 613 | return $default; |
||
| 614 | } |
||
| 615 | |||
| 616 | return $ret; |
||
| 617 | } |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @param $content |
||
| 621 | */ |
||
| 622 | View Code Duplication | function animal_meta_keywords($content) |
|
| 623 | { |
||
| 624 | global $xoopsTpl, $xoTheme; |
||
| 625 | $myts =& MyTextSanitizer::getInstance(); |
||
| 626 | $content = $myts->undoHtmlSpecialChars($myts->sanitizeForDisplay($content)); |
||
| 627 | if (isset($xoTheme) && is_object($xoTheme)) { |
||
| 628 | $xoTheme->addMeta('meta', 'keywords', strip_tags($content)); |
||
| 629 | } else { // Compatibility for old Xoops versions |
||
| 630 | $xoopsTpl->assign('xoops_meta_keywords', strip_tags($content)); |
||
| 631 | } |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * @param $content |
||
| 636 | */ |
||
| 637 | View Code Duplication | function animal_meta_description($content) |
|
| 638 | { |
||
| 639 | global $xoopsTpl, $xoTheme; |
||
| 640 | $myts =& MyTextSanitizer::getInstance(); |
||
| 641 | $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
||
| 642 | if (isset($xoTheme) && is_object($xoTheme)) { |
||
| 643 | $xoTheme->addMeta('meta', 'description', strip_tags($content)); |
||
| 644 | } else { // Compatibility for old Xoops versions |
||
| 645 | $xoopsTpl->assign('xoops_meta_description', strip_tags($content)); |
||
| 646 | } |
||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Verify that a mysql table exists |
||
| 651 | * |
||
| 652 | * @package News |
||
| 653 | * @author Hervé Thouzard (http://www.herve-thouzard.com) |
||
| 654 | * @copyright (c) Hervé Thouzard |
||
| 655 | */ |
||
| 656 | //function tableExists($tablename) |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
61% 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...
|
|||
| 657 | //{ |
||
| 658 | // global $xoopsDB; |
||
| 659 | // $result=$xoopsDB->queryF("SHOW TABLES LIKE '$tablename'"); |
||
| 660 | // return($xoopsDB->getRowsNum($result) > 0); |
||
| 661 | //} |
||
| 662 | |||
| 663 | /** |
||
| 664 | * Create download by letter choice bar/menu |
||
| 665 | * updated starting from this idea http://xoops.org/modules/news/article.php?storyid=6497 |
||
| 666 | * |
||
| 667 | * @return string html |
||
| 668 | * |
||
| 669 | * @access public |
||
| 670 | * @author luciorota |
||
| 671 | */ |
||
| 672 | function pedigree_lettersChoice() |
||
| 673 | { |
||
| 674 | $pedigree = PedigreePedigree::getInstance(); |
||
| 675 | |||
| 676 | $criteria = $pedigree->getHandler('download')->getActiveCriteria(); |
||
| 677 | $criteria->setGroupby('UPPER(LEFT(title,1))'); |
||
| 678 | $countsByLetters = $pedigree->getHandler('download')->getCounts($criteria); |
||
| 679 | // Fill alphabet array |
||
| 680 | $alphabet = pedigree_alphabet(); |
||
| 681 | $alphabet_array = array(); |
||
| 682 | foreach ($alphabet as $letter) { |
||
| 683 | $letter_array = array(); |
||
| 684 | if (isset($countsByLetters[$letter])) { |
||
| 685 | $letter_array['letter'] = $letter; |
||
| 686 | $letter_array['count'] = $countsByLetters[$letter]; |
||
| 687 | $letter_array['url'] = "" . XOOPS_URL . "/modules/" . $pedigree->getModule()->dirname() . "/viewcat.php?list={$letter}"; |
||
| 688 | } else { |
||
| 689 | $letter_array['letter'] = $letter; |
||
| 690 | $letter_array['count'] = 0; |
||
| 691 | $letter_array['url'] = ""; |
||
| 692 | } |
||
| 693 | $alphabet_array[$letter] = $letter_array; |
||
| 694 | unset($letter_array); |
||
| 695 | } |
||
| 696 | // Render output |
||
| 697 | View Code Duplication | if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
| 698 | include_once $GLOBALS['xoops']->path("/class/theme.php"); |
||
| 699 | $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
||
| 700 | } |
||
| 701 | require_once $GLOBALS['xoops']->path('class/template.php'); |
||
| 702 | $letterschoiceTpl = new XoopsTpl(); |
||
| 703 | $letterschoiceTpl->caching = false; // Disable cache |
||
| 704 | $letterschoiceTpl->assign('alphabet', $alphabet_array); |
||
| 705 | $html = $letterschoiceTpl->fetch("db:" . $pedigree->getModule()->dirname() . "_common_letterschoice.tpl"); |
||
| 706 | unset($letterschoiceTpl); |
||
| 707 | |||
| 708 | return $html; |
||
| 709 | } |
||
| 710 | |||
| 711 | /** |
||
| 712 | * @return bool |
||
| 713 | */ |
||
| 714 | function pedigree_userIsAdmin() |
||
| 715 | { |
||
| 716 | global $xoopsUser; |
||
| 717 | $pedigree = PedigreePedigree::getInstance(); |
||
| 718 | |||
| 719 | static $pedigree_isAdmin; |
||
| 720 | |||
| 721 | if (isset($pedigree_isAdmin)) { |
||
| 722 | return $pedigree_isAdmin; |
||
| 723 | } |
||
| 724 | |||
| 725 | if (!$xoopsUser) { |
||
| 726 | $pedigree_isAdmin = false; |
||
| 727 | } else { |
||
| 728 | $pedigree_isAdmin = $xoopsUser->isAdmin($pedigree->getModule()->getVar('mid')); |
||
| 729 | } |
||
| 730 | |||
| 731 | return $pedigree_isAdmin; |
||
| 732 | } |
||
| 733 | |||
| 734 | function pedigree_xoops_cp_header() |
||
| 735 | { |
||
| 736 | xoops_cp_header(); |
||
| 737 | } |
||
| 738 | |||
| 739 | /** |
||
| 740 | * @param bool $withLink |
||
| 741 | * |
||
| 742 | * @return string |
||
| 743 | */ |
||
| 744 | function pedigree_module_home($withLink = true) |
||
| 745 | { |
||
| 746 | $pedigree = PedigreePedigree::getInstance(); |
||
| 747 | |||
| 748 | $pedigreeModuleName = $pedigree->getModule()->getVar('name'); |
||
| 749 | if (!$withLink) { |
||
| 750 | return $pedigreeModuleName; |
||
| 751 | } else { |
||
| 752 | return '<a href="' . PEDIGREE_URL . '/">{$pedigreeModuleName}</a>'; |
||
| 753 | } |
||
| 754 | } |
||
| 755 | |||
| 756 | /** |
||
| 757 | * Detemines if a table exists in the current db |
||
| 758 | * |
||
| 759 | * @param string $table the table name (without XOOPS prefix) |
||
| 760 | * |
||
| 761 | * @return bool True if table exists, false if not |
||
| 762 | * |
||
| 763 | * @access public |
||
| 764 | * @author xhelp development team |
||
| 765 | */ |
||
| 766 | function pedigree_tableExists($table) |
||
| 767 | { |
||
| 768 | $bRetVal = false; |
||
| 769 | //Verifies that a MySQL table exists |
||
| 770 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 771 | $realName = $xoopsDB->prefix($table); |
||
| 772 | |||
| 773 | $sql = "SHOW TABLES FROM " . XOOPS_DB_NAME; |
||
| 774 | $ret = $xoopsDB->queryF($sql); |
||
| 775 | |||
| 776 | while (list($m_table) = $xoopsDB->fetchRow($ret)) { |
||
| 777 | if ($m_table == $realName) { |
||
| 778 | $bRetVal = true; |
||
| 779 | break; |
||
| 780 | } |
||
| 781 | } |
||
| 782 | $xoopsDB->freeRecordSet($ret); |
||
| 783 | |||
| 784 | return ($bRetVal); |
||
| 785 | } |
||
| 786 | |||
| 787 | /** |
||
| 788 | * Gets a value from a key in the xhelp_meta table |
||
| 789 | * |
||
| 790 | * @param string $key |
||
| 791 | * |
||
| 792 | * @return string $value |
||
| 793 | * |
||
| 794 | * @access public |
||
| 795 | * @author xhelp development team |
||
| 796 | */ |
||
| 797 | function pedigree_getMeta($key) |
||
| 798 | { |
||
| 799 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 800 | $sql = sprintf("SELECT metavalue FROM %s WHERE metakey=%s", $xoopsDB->prefix('pedigree_meta'), $xoopsDB->quoteString($key)); |
||
| 801 | $ret = $xoopsDB->query($sql); |
||
| 802 | if (!$ret) { |
||
| 803 | $value = false; |
||
| 804 | } else { |
||
| 805 | list($value) = $xoopsDB->fetchRow($ret); |
||
| 806 | |||
| 807 | } |
||
| 808 | |||
| 809 | return $value; |
||
| 810 | } |
||
| 811 | |||
| 812 | /** |
||
| 813 | * Sets a value for a key in the xhelp_meta table |
||
| 814 | * |
||
| 815 | * @param string $key |
||
| 816 | * @param string $value |
||
| 817 | * |
||
| 818 | * @return bool true if success, false if failure |
||
| 819 | * |
||
| 820 | * @access public |
||
| 821 | * @author xhelp development team |
||
| 822 | */ |
||
| 823 | function pedigree_setMeta($key, $value) |
||
| 824 | { |
||
| 825 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 826 | if ($ret = pedigree_getMeta($key)) { |
||
| 827 | $sql = sprintf( |
||
| 828 | "UPDATE %s SET metavalue = %s WHERE metakey = %s", |
||
| 829 | $xoopsDB->prefix('pedigree_meta'), |
||
| 830 | $xoopsDB->quoteString($value), |
||
| 831 | $xoopsDB->quoteString($key) |
||
| 832 | ); |
||
| 833 | } else { |
||
| 834 | $sql = sprintf( |
||
| 835 | "INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)", |
||
| 836 | $xoopsDB->prefix('pedigree_meta'), |
||
| 837 | $xoopsDB->quoteString($key), |
||
| 838 | $xoopsDB->quoteString($value) |
||
| 839 | ); |
||
| 840 | } |
||
| 841 | $ret = $xoopsDB->queryF($sql); |
||
| 842 | if (!$ret) { |
||
| 843 | return false; |
||
| 844 | } |
||
| 845 | |||
| 846 | return true; |
||
| 847 | } |
||
| 848 | |||
| 849 | /** |
||
| 850 | * @param $name |
||
| 851 | * @param $value |
||
| 852 | * @param int $time |
||
| 853 | */ |
||
| 854 | function pedigree_setCookieVar($name, $value, $time = 0) |
||
| 855 | { |
||
| 856 | if ($time == 0) { |
||
| 857 | $time = time() + 3600 * 24 * 365; |
||
| 858 | //$time = ''; |
||
|
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...
|
|||
| 859 | } |
||
| 860 | setcookie($name, $value, $time, '/'); |
||
| 861 | } |
||
| 862 | |||
| 863 | /** |
||
| 864 | * @param $name |
||
| 865 | * @param string $default |
||
| 866 | * |
||
| 867 | * @return string |
||
| 868 | */ |
||
| 869 | function pedigree_getCookieVar($name, $default = '') |
||
| 870 | { |
||
| 871 | if ((isset($_COOKIE[$name])) && ($_COOKIE[$name] > '')) { |
||
| 872 | return $_COOKIE[$name]; |
||
| 873 | } else { |
||
| 874 | return $default; |
||
| 875 | } |
||
| 876 | } |
||
| 877 | |||
| 878 | /** |
||
| 879 | * @return array |
||
| 880 | */ |
||
| 881 | function pedigree_getCurrentUrls() |
||
| 882 | { |
||
| 883 | $http = ((strpos(XOOPS_URL, "https://")) === false) ? ("http://") : ("https://"); |
||
| 884 | $phpSelf = $_SERVER['PHP_SELF']; |
||
| 885 | $httpHost = $_SERVER['HTTP_HOST']; |
||
| 886 | $queryString = $_SERVER['QUERY_STRING']; |
||
| 887 | |||
| 888 | If ($queryString != '') { |
||
| 889 | $queryString = '?' . $queryString; |
||
| 890 | } |
||
| 891 | |||
| 892 | $currentURL = $http . $httpHost . $phpSelf . $queryString; |
||
| 893 | |||
| 894 | $urls = array(); |
||
| 895 | $urls['http'] = $http; |
||
| 896 | $urls['httphost'] = $httpHost; |
||
| 897 | $urls['phpself'] = $phpSelf; |
||
| 898 | $urls['querystring'] = $queryString; |
||
| 899 | $urls['full'] = $currentURL; |
||
| 900 | |||
| 901 | return $urls; |
||
| 902 | } |
||
| 903 | |||
| 904 | function pedigree_getCurrentPage() |
||
| 905 | { |
||
| 906 | $urls = pedigree_getCurrentUrls(); |
||
| 907 | |||
| 908 | return $urls['full']; |
||
| 909 | } |
||
| 910 | |||
| 911 | /** |
||
| 912 | * @param array $errors |
||
| 913 | * |
||
| 914 | * @return string |
||
| 915 | */ |
||
| 916 | function pedigree_formatErrors($errors = array()) |
||
| 917 | { |
||
| 918 | $ret = ''; |
||
| 919 | foreach ($errors as $key => $value) { |
||
| 920 | $ret .= "<br /> - {$value}"; |
||
| 921 | } |
||
| 922 | |||
| 923 | return $ret; |
||
| 924 | } |
||
| 925 |
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.