| Conditions | 13 |
| Paths | 192 |
| Total Lines | 374 |
| Code Lines | 214 |
| Lines | 15 |
| Ratio | 4.01 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 332 | //alert('Please enter a number or a blank for the "' + fieldLabel +'" field.'); |
||
| 333 | alert(message.replace("%1\$s", fieldLabel)); |
||
| 334 | formField.focus(); |
||
| 335 | result = false; |
||
| 336 | } |
||
| 337 | } |
||
| 338 | } |
||
| 339 | |||
| 340 | return result; |
||
| 341 | } |
||
| 342 | |||
| 343 | |||
| 344 | function validateURL(formField, value, secure) { |
||
| 345 | |||
| 346 | var match = /https/i.test(value); |
||
| 347 | |||
| 348 | if (value != "" && !/^http/i.test(value)) { |
||
| 349 | alert('The URL must start with http://'); |
||
| 350 | formField.focus(); |
||
| 351 | |||
| 352 | return false; |
||
| 353 | } |
||
| 354 | |||
| 355 | if (secure && value != "" && !/^https/i.test(value)) { |
||
| 356 | // alert('This should reside on a HTTPS server. Users will be warned about viewing secure and non-secure data on the same page'); |
||
| 357 | return confirm('This URL does not begin with https://\nThis image should reside on an HTTPS server.\nIf you use this URL, users will receive a warning\nabout viewing secure and non-secure data on the same page.\n\n Are you sure you want to continue?'); |
||
| 358 | } |
||
| 359 | |||
| 360 | return true; |
||
| 361 | } |
||
| 362 | |||
| 363 | |||
| 364 | function checkCancelledURL() { |
||
| 365 | if (document.tr_configs.var_pp_image_url.value == "") |
||
| 366 | alert('There is no URL for a Cancelled payment. If you do not enter\na URL for cancelled payments PayPal will also use\nthis URL for cancelled payments.'); |
||
| 367 | |||
| 368 | return true; |
||
| 369 | } |
||
| 370 | </script> |
||
| 371 | <?php |
||
| 372 | //------------------------------------------------------------------------------- |
||
| 373 | echo "<form name=\"tr_configs\" action=\"donations.php\" method=\"post\">\n" . "<input type=\"hidden\" name=\"op\" value=\"updateConfig\" />\n"; |
||
| 374 | echo "<table style=\"border-width: 1px; width: 90%; text-align: center;\"><tr>\n"; |
||
| 375 | echo "<td style=\"text-align: center; font-weight: bold;\" class=\"title\">\n"; |
||
| 376 | echo '<h3>' . _AD_DON_CONFIG_MODULE . "</h3>\n"; |
||
| 377 | echo "<table style=\"border-width: 1px; text-align: center;\">\n"; |
||
| 378 | |||
| 379 | ShowTextBox('don_button_top', "<span style=\"font-weight: bold;\">" . _AD_DON_IMG_BUTTON_TOP . '</span>', '', '70', 'onChange="return validateURL(this,this.value);"'); |
||
| 380 | ShowImgXYBox('don_top_img_width', 'don_top_img_height', "<span style=\"font-weight: bold;\">" . _AD_DON_IMAGE_SIZE . '</span>', '4', "onChange='return validInt(this,\"" . _AD_DON_IMAGE_SIZE . "\",0,\"" . _AD_DON_ALERTE_INPUT_NUMBER . "\");'"); |
||
| 381 | ShowTextBox('don_button_submit', "<span style=\"font-weight: bold;\">" . _AD_DON_IMG_BUTTON_URL . '</span>', '', '70', 'onChange="return validateURL(this,this.value);"'); |
||
| 382 | ShowImgXYBox('don_sub_img_width', 'don_sub_img_height', "<span style=\"font-weight: bold;\">" . _AD_DON_IMAGE_SIZE . '</span>', '4', "onChange='return validInt(this,\"" . _AD_DON_IMAGE_SIZE . "\",0,\"" . _AD_DON_ALERTE_INPUT_NUMBER . "\");'"); |
||
| 383 | //"onChange='return validInt(this,"._AD_DON_IMAGE_SIZE.")'" |
||
| 384 | ShowTextBox('don_name_prompt', "<span style=\"font-weight: bold;\">" . _AD_DON_USERNAME_REQUEST . '</span>', '', '70', ''); |
||
| 385 | ShowTextBox('don_name_yes', "<span style=\"font-weight: bold;\">" . _AD_DON_USERNAME_REQUEST_YES . '</span>', '', '50', ''); |
||
| 386 | ShowTextBox('don_name_no', "<span style=\"font-weight: bold;\">" . _AD_DON_USERNAME_REQUEST_NO . '</span>', '', '50', ''); |
||
| 387 | |||
| 388 | $desc = 'This is where you can appeal to your' . 'users and your community for donations.' . 'Suggestion: Explain why you need donations,' . 'what you do with the money and how you' . 'manage it. Make them comfortable that' . 'they are not throwing their money away.'; |
||
| 389 | |||
| 390 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_text'"; |
||
| 391 | $Recordset = $xoopsDB->query($sql); |
||
| 392 | $row = $xoopsDB->fetchArray($Recordset); |
||
| 393 | $donText = $row['text']; |
||
| 394 | echo "<tr>\n" . " <td title=\"{$desc}\" style=\"text-align: right; font-weight: bold;\">" . _AD_DON_INTRODUCE_TEXT . "</td>\n" . " <td title=\"{$desc}\" style=\"text-align: left;\">" . "<textarea name=\"var_don_text-rawtext-txt\" cols=\"100\" rows=\"20\">{$donText}</textarea></td>\n"; |
||
| 395 | echo "</tr>\n"; |
||
| 396 | |||
| 397 | // ShowTextBox('don_amt_checked', '<span style=\'font-weight: bold;\'>'._AD_DON_AMOUNT_DEFAULT.'</span>', '', '4', "onChange=\"return validInt(this,'"._AD_DON_AMOUNT_DEFAULT."',1,'"._AD_DON_ALERTE_INPUT_NUMBER."');\""); |
||
| 398 | |||
| 399 | echo "</table>\n"; |
||
| 400 | echo "<br />\n"; |
||
| 401 | |||
| 402 | $query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_amount' ORDER BY subtype"; |
||
| 403 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 404 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 405 | $totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
||
| 406 | $desc = htmlentities($row_Recordset1['text']); |
||
| 407 | |||
| 408 | echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
||
| 409 | echo " <tr><td style=\"text-align: center; width: 100%; font-weight: bold;\" colspan=\"8\">" . _AD_DON_SUGGESTED_AMOUNT . "<br /></td></tr>\n"; |
||
| 410 | $row1 = " <tr><td title=\"{$desc}\" style=\"text-align: center;\"></td>\n"; |
||
| 411 | $row2 = " <tr><td title=\"{$desc}\" style=\"text-align: center; font-weight: bold;\">" . _AD_DON_AMOUNT . "</td>\n"; |
||
| 412 | do { |
||
| 413 | $row1 .= " <td title=\"{$desc}\" style=\"text-align: center;\">{$row_Recordset1['subtype']}</td>\n"; |
||
| 414 | $row2 .= " <td title=\"{$desc}\" style=\"text-align: center;\"><input size=\"4\" name=\"var_don_amount-{$row_Recordset1['subtype']}\" type=\"text\" value=\"{$row_Recordset1['value']}\" onChange=\"return validInt(this,'" . _AD_DON_SUGGESTED_AMOUNT . " #{$row_Recordset1['subtype']}',1,'" . _AD_DON_ALERTE_INPUT_NUMBER . "');\" /></td>\n"; |
||
| 415 | } while (false != ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
||
| 416 | |||
| 417 | $row1 .= "</tr>\n"; |
||
| 418 | $row2 .= "</tr>\n"; |
||
| 419 | echo "{$row1} {$row2}\n"; |
||
| 420 | |||
| 421 | // display default option |
||
| 422 | $query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'don_amt_checked' LIMIT 1"; |
||
| 423 | $cfgResult = $xoopsDB->query($query_cfg); |
||
| 424 | $amt = $xoopsDB->fetchArray($cfgResult); |
||
| 425 | $amt_checked = (int)$amt['value']; |
||
| 426 | echo '<tr><td>' . _AD_DON_DEFAULT . "</td>\n"; |
||
| 427 | for ($i = 1; $i < 8; ++$i) { |
||
| 428 | $checked = ($i == $amt_checked) ? ' checked' : ''; |
||
| 429 | echo "<td><input type=\"radio\" name=\"var_don_amt_checked\"{$checked} value=\"{$i}\"></td>\n"; |
||
| 430 | } |
||
| 431 | echo "</tr>\n"; |
||
| 432 | echo "</table>\n"; |
||
| 433 | |||
| 434 | echo "</td></tr>\n"; |
||
| 435 | echo "<tr><td style=\"text-align: center; width: 100%;\"><br /><input type=\"submit\" value=\"" . _AD_DON_SUBMIT . "\" /></td></tr>"; |
||
| 436 | echo "</table><br /><br />\n"; |
||
| 437 | echo $indexAdmin->addNavigation('donations.php?op=Config'); |
||
| 438 | echo "<table style=\"border-width: 1px; width: 90%; text-align: center;\"><tr>\n"; |
||
| 439 | echo "<td class=\"title\" style=\"font-weight: bold; text-align: center;\"><h3>" . _AD_DON_CONFIG_PAYPAL_HEADER . "</h3><br />\n"; |
||
| 440 | echo "<table style=\"border-width: 1px; text-align: center;\">\n"; |
||
| 441 | |||
| 442 | $rsql = 'SELECT rank_id, rank_title FROM ' . $xoopsDB->prefix('ranks') . ''; |
||
| 443 | $rresult = $xoopsDB->query($rsql); |
||
| 444 | $r_array = array(); |
||
| 445 | while (false != ($r_row = $xoopsDB->fetchRow($rresult))) { |
||
| 446 | $r_array[] = $r_row; |
||
| 447 | } |
||
| 448 | ShowDropBox('paypal_url', '<span style=\'font-weight: bold;\'>' . _AD_DON_IPN_URL . '</span>'); |
||
| 449 | ShowTextBox('receiver_email', '<span style=\'font-weight: bold;\'>' . _AD_DON_IPN_EMAIL_RECEIVER . '</span>', '', '40', ''); |
||
| 450 | ShowTextBox('ty_url', '<span style=\'font-weight: bold;\'>' . _AD_DON_IPN_URL_SUCCESS . '</span>', '', '80', 'onChange="checkCancelledURL(); return validateURL(this,this.value);"'); |
||
| 451 | ShowTextBox('pp_cancel_url', '<span style=\'font-weight: bold;\'>' . _AD_DON_IPN_URL_CANCELED . '</span>', '', '80', 'onChange="return validateURL(this,this.value);"'); |
||
| 452 | ShowTextBox('pp_itemname', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_ITEM_NAME . '</span>', '', '20', ''); |
||
| 453 | ShowTextBox('pp_item_num', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_ITEM_NUMBER . '</span>', '', '20', ''); |
||
| 454 | ShowTextBox('pp_image_url', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_IMG . '</span>', '', '60', ''); |
||
| 455 | ShowYNBox('pp_get_addr', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_ASK_CP_ADRESS . '</span>'); |
||
| 456 | ShowDropBox('pp_curr_code', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_MONEY . '</span>'); |
||
| 457 | $gsql = 'SELECT groupid, name FROM ' . $xoopsDB->prefix('groups') . ' WHERE groupid>3'; |
||
| 458 | $gresult = $xoopsDB->query($gsql); |
||
| 459 | $g_array = array(); |
||
| 460 | while (false != ($g_row = $xoopsDB->fetchRow($gresult))) { |
||
| 461 | $g_array[] = $g_row; |
||
| 462 | } |
||
| 463 | ShowArrayDropBox('assign_group', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_GROUP . '</span>', $g_array); |
||
| 464 | $rsql = 'SELECT rank_id, rank_title FROM ' . $xoopsDB->prefix('ranks') . ''; |
||
| 465 | $rresult = $xoopsDB->query($rsql); |
||
| 466 | $r_array = array(); |
||
| 467 | while (false != ($r_row = $xoopsDB->fetchRow($rresult))) { |
||
| 468 | $r_array[] = $r_row; |
||
| 469 | } |
||
| 470 | ShowArrayDropBox('assign_rank', '<span style=\'font-weight: bold;\'>' . _AD_DON_PP_RANK . '</span>', $r_array); |
||
| 471 | ShowYNBox('don_forceadd', '<span style=\'font-weight: bold;\'>' . _AD_DON_ADD_ANYWAY . '</span>'); |
||
| 472 | |||
| 473 | echo "</table><br />\n"; |
||
| 474 | |||
| 475 | echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
||
| 476 | echo " <tr><td style=\"text-align: center; width: 100%; font-weight: bold;\" colspan=\"2\">" . _AD_DON_IPN_LOGGING . "<br /></td></tr>\n"; |
||
| 477 | echo " <tr>\n" . " <td style=\"text-align: right; font-weight: bold;\">" . _AD_DON_IPN_LOGGING_LEVEL . "</td>\n" . " <td style=\"text-align: left;\">\n" . " <select size=\"1\" name=\"var_ipn_dbg_lvl\">\n"; |
||
| 478 | echo ' <option '; |
||
| 479 | if (0 == $tr_config['ipn_dbg_lvl']) { |
||
| 480 | echo 'selected '; |
||
| 481 | } |
||
| 482 | echo "value=\"0\">" . _AD_DON_LOG_OFF . "</option>\n"; |
||
| 483 | echo ' <option '; |
||
| 484 | if ($tr_config['ipn_dbg_lvl'] == 1) { |
||
| 485 | echo 'selected '; |
||
| 486 | } |
||
| 487 | echo "value=\"1\">" . _AD_DON_LOG_ONLY_ERRORS . "</option>\n"; |
||
| 488 | echo ' <option '; |
||
| 489 | if ($tr_config['ipn_dbg_lvl'] == 2) { |
||
| 490 | echo 'selected '; |
||
| 491 | } |
||
| 492 | echo "value=\"2\">" . _AD_DON_LOG_EVERYTHING . "</option>\n"; |
||
| 493 | echo " </select>\n" . " </td>\n" . " </tr>\n"; |
||
| 494 | |||
| 495 | ShowTextBox('ipn_log_entries', '<nobr><span style=\'font-weight: bold;\'>' . _AD_DON_LOG_ENTRY . '</span></nobr>', '', '4', ''); |
||
| 496 | |||
| 497 | $desc = 'This box shows the link to the IPN recorder. |
||
| 498 | This link must be pasted EXACTLY as it is |
||
| 499 | into your PayPal IPN profile. You can click |
||
| 500 | on the "test" link to the right to verify |
||
| 501 | that the IPN recorder is functioning correctly.'; |
||
| 502 | $desc = htmlentities($desc); |
||
| 503 | echo "<tr>\n" . " <td title =\"$desc\" style=\"text-align: right; font-weight: bold;\">" . _AD_DON_IPN_LINK . "</td>\n" . " <td title =\"$desc\" style=\"text-align: center;\"> " . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/ipnppd.php \n" . " <br /><a href=\"" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/ipnppd.php?dbg=1\" target=\"_blank\"><span style=\"font-weight: bold; font-style: italic;\"><img src=\"../assets/images/admin/info.png\" style=\"height: 16px; width: 16px;\" alt=\"\"> " . _AD_DON_TEST_IPN . "</span></a>\n" . " </td>\n" . "</tr>\n"; |
||
| 504 | echo "</table><br />\n"; |
||
| 505 | echo "</td></tr>\n"; |
||
| 506 | echo "<tr><td style=\"text-align: center; width: 100%;\"><input type=\"submit\" value=\"" . _AD_DON_SUBMIT . "\" />\n"; |
||
| 507 | echo '</td></tr></table><br /><br />'; |
||
| 508 | |||
| 509 | //Goal Preferences |
||
| 510 | //=============================== |
||
| 511 | echo $indexAdmin->addNavigation('donations.php?op=Config'); |
||
| 512 | echo "<table style=\"border-width: 1px; width: 90%; text-align: center;\">\n" . " <tr>\n"; |
||
| 513 | echo " <td style=\"text-align: center; font-weight: bold;\" class=\"title\">\n" . ' <h3>' . _AD_DON_GOAL_PREFERENCES . "</h3>\n"; |
||
| 514 | echo " <table style=\"border-width: 1px; text-align: center;\">\n" . " <tr><td style=\"text-align: center;\">\n"; |
||
| 515 | echo " <table style=\"border-width: 1px; text-align: center;\">\n"; |
||
| 516 | ShowDropBox('use_goal', '<span style=\'font-weight: bold;\'>' . _AD_DON_GOAL_TYPE . '.</span>'); |
||
| 517 | echo " </table>\n"; |
||
| 518 | |||
| 519 | $query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'week_goal' AND subtype<>'Default'"; |
||
| 520 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 521 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 522 | $totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
||
| 523 | $desc = htmlentities($row_Recordset1['text']); |
||
| 524 | |||
| 525 | echo " <table style=\"border-width: 1px; width: 100px; text-align: center;\">\n" . " <tr><td style=\"text-align: center; width: 100%; font-weight: bold;\" colspan=\"5\">" . _AD_DON_GOAL_HEBDO . "<br /></td></tr>\n"; |
||
| 526 | $row1 = " <tr>\n" . " <td style=\"text-align: center; font-weight: bold;\">" . _AD_DON_WEEK . "</td>\n"; |
||
| 527 | $row2 = " <tr>\n" . " <td style=\"text-align: center; font-weight: bold;\">" . _AD_DON_GOAL . "</td>\n"; |
||
| 528 | //------------------------------------------------------------- |
||
| 529 | $shortMonth = explode('|', _AD_DON_SHORT_MONTH); |
||
| 530 | $ordinaux = explode('|', _AD_DON_NUMBER_ORDINAUX); |
||
| 531 | //------------------------------------------------------------- |
||
| 532 | $h = 0; |
||
| 533 | View Code Duplication | do { |
|
| 534 | $ord = $ordinaux[$h++]; |
||
| 535 | $row1 .= " <td title=\"{$desc}\" style=\"text-align: center;\">{$ord}</td>\n"; |
||
| 536 | $row2 .= " <td title=\"{$desc}\" style=\"text-align: center;\"><input size=\"4\" name=\"var_week_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] " . _AD_DON_GOAL_DONATION . "',1,'" . _AD_DON_ALERTE_INPUT_NUMBER . "');\" /></td>\n"; |
||
| 537 | } while (false != ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
||
| 538 | $row1 .= " </tr>\n"; |
||
| 539 | $row2 .= " </tr>\n"; |
||
| 540 | echo "{$row1} {$row2}"; |
||
| 541 | |||
| 542 | echo "</table>\n"; |
||
| 543 | |||
| 544 | $query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'month_goal' AND subtype<>'Default'"; |
||
| 545 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 546 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 547 | $totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
||
| 548 | $desc = htmlentities($row_Recordset1['text']); |
||
| 549 | |||
| 550 | $h = 0; |
||
| 551 | echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
||
| 552 | echo " <tr><td style=\"text-align: center; width: 100%; font-weight: bold;\" colspan=\"13\">" . _AD_DON_GOAL_MENSUEL . "</td></tr><br />\n"; |
||
| 553 | $row1 = " <tr>\n" . " <td style=\"text-align: center; font-weight: bold;\">" . _AD_DON_MONTH . "</td>\n"; |
||
| 554 | $row2 = " <tr>\n" . " <td style=\"text-align: center; font-weight: bold;\">" . _AD_DON_GOAL . "</td>\n"; |
||
| 555 | View Code Duplication | do { |
|
| 556 | $month = $shortMonth[$h++]; |
||
| 557 | $row1 .= " <td title=\"{$desc}\" style=\"text-align: center;\">{$month}</td>\n"; |
||
| 558 | $row2 .= " <td title=\"{$desc}\" style=\"text-align: center;\"><input size=\"4\" name=\"var_month_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] " . _AD_DON_GOAL_DONATION . "',1,'" . _AD_DON_ALERTE_INPUT_NUMBER . "');\" /></td>\n"; |
||
| 559 | } while (false != ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
||
| 560 | $row1 .= " </tr>\n"; |
||
| 561 | $row2 .= " </tr>\n"; |
||
| 562 | echo "{$row1}{$row2}"; |
||
| 563 | |||
| 564 | echo "</table>\n"; |
||
| 565 | echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
||
| 566 | ShowTextBox('swing_day', '<span style=\'font-weight: bold;\'>' . _AD_DON_SWING_DAY . '</span>', '175', '4', "onChange='return validInt(this,\"" . _AD_DON_SWING_DAY . "\",1,\"" . _AD_DON_ALERTE_INPUT_NUMBER . "\");'"); |
||
| 567 | echo "</table>\n"; |
||
| 568 | |||
| 569 | $query_Recordset1 = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = 'quarter_goal' AND subtype<>'Default'"; |
||
| 570 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 571 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 572 | $totalRows_Recordset1 = $xoopsDB->getRowsNum($Recordset1); |
||
| 573 | $desc = htmlentities($row_Recordset1['text']); |
||
| 574 | |||
| 575 | echo "<table style=\"border-width: 1px; width: 100px; text-align: center;\">\n"; |
||
| 576 | echo " <tr><td style=\"text-align: center; width: 100%; font-weight: bold;\" colspan=\"5\">" . _AD_DON_QUARTER . "<br /></td></tr>\n"; |
||
| 577 | $row1 = " <tr><td style=\"text-align: center; font-weight: bold;\">" . _AD_DON_QUARTER . "</td>\n"; |
||
| 578 | $row2 = " <tr><td style=\"text-align: center; font-weight: bold;\">" . _AD_DON_GOAL . "</td>\n"; |
||
| 579 | $h = 0; |
||
| 580 | View Code Duplication | do { |
|
| 581 | $ord = $ordinaux[$h++]; |
||
| 582 | $row1 .= " <td title='{$desc}' style='text-align: center;'>{$ord}</td>\n"; |
||
| 583 | $row2 .= " <td title='{$desc}' style='text-align: center;'><input size=\"4\" name=\"var_quarter_goal-$row_Recordset1[subtype]\" type=\"text\" value=\"$row_Recordset1[value]\" onChange=\"return validInt(this,'$row_Recordset1[subtype] " . _AD_DON_GOAL_DONATION . "',1,'" . _AD_DON_ALERTE_INPUT_NUMBER . "');\" /></td>\n"; |
||
| 584 | } while (false != ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))); |
||
| 585 | $row1 .= " </tr>\n"; |
||
| 586 | $row2 .= " </tr>\n"; |
||
| 587 | echo "{$row1} {$row2}"; |
||
| 588 | |||
| 589 | echo "</table><br />\n"; |
||
| 590 | echo "</td></tr>\n"; |
||
| 591 | echo "<tr><td style=\"text-align: center; width: 100%;\"><input type=\"submit\" value=\"" . _AD_DON_SUBMIT . "\"></td></tr>\n"; |
||
| 592 | echo "</table><br/>\n"; |
||
| 593 | echo "</td></tr></table>\n"; |
||
| 594 | echo "</form>\n"; |
||
| 595 | } |
||
| 596 | |||
| 597 | /** |
||
| 598 | * |
||
| 599 | * Update Configuration Settings in the database |
||
| 600 | */ |
||
| 601 | function updateConfig() |
||
| 602 | { |
||
| 603 | global $tr_config, $modversion, $xoopsDB; |
||
| 604 | |||
| 605 | echo '<br />' . _AD_DON_ERR_SQL_FAILURE . "<br /><br />\n"; |
||
| 606 | |||
| 607 | $error = 1; |
||
| 608 | $ilog = "<br />\n"; |
||
| 609 | |||
| 610 | foreach ($_POST as $option => $value) { |
||
| 611 | /// Look for form variables |
||
| 612 | if (preg_match('/var_/', $option)) { |
||
| 613 | $varnm = preg_replace('/var_/', '', $option); |
||
| 614 | // Check for subtype field |
||
| 615 | |||
| 616 | if (preg_match('/-(.*)/', $varnm, $subtype)) { |
||
| 617 | echo "<br />subtype = $subtype[1] <br />\n"; |
||
| 618 | $temp = $varnm; |
||
| 619 | $varnm = preg_replace('/-.*/', '', $temp); |
||
| 620 | // Is this is a text field? |
||
| 621 | if (preg_match('/([^-]*)-txt/', $subtype[1], $subtype2)) { |
||
| 622 | $textarea = addslashes($value); |
||
| 623 | echo "$varnm $subtype2[1] text=> " . nl2br(htmlspecialchars($textarea)) . "<br />\n"; |
||
| 624 | $error &= updateDb($varnm, $subtype2[1], '0', $textarea); |
||
| 625 | } else { |
||
| 626 | echo "$varnm $subtype[1] => $value<br />\n"; |
||
| 627 | $error &= updateDbShort($varnm, $subtype[1], $value); |
||
| 628 | } |
||
| 629 | } else { |
||
| 630 | echo "$varnm => $value<br />\n"; |
||
| 631 | $error &= updateDbShort($varnm, '', $value); |
||
| 632 | } |
||
| 633 | } |
||
| 634 | } |
||
| 635 | |||
| 636 | // If there were no errors |
||
| 637 | if (0 == $error) { |
||
| 638 | header('Location: donations.php?op=Config#AdminTop'); |
||
| 639 | } |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * |
||
| 644 | * Reconcile the IPN Log |
||
| 645 | */ |
||
| 646 | function reconcileIpn() |
||
| 647 | { |
||
| 648 | global $tr_config, $modversion, $xoopsDB, $currencySign; |
||
| 649 | $recdate = ''; |
||
| 650 | $query_Recordset1 = 'SELECT `date` AS recdate FROM ' . $xoopsDB->prefix('donations_financial') . " WHERE name='PayPal IPN' ORDER BY date DESC LIMIT 1"; |
||
| 651 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 652 | if ($Recordset1) { |
||
| 653 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 654 | if ($row_Recordset1) { |
||
| 655 | $recdate = "payment_date > '" . $row_Recordset1['recdate'] . "' AND"; |
||
| 656 | } |
||
| 657 | } |
||
| 658 | |||
| 659 | $query_Recordset1 = 'SELECT `payment_date` AS curdate from ' . $xoopsDB->prefix('donations_transactions') . " WHERE payment_status='Completed' AND (txn_type='send_money' OR txn_type='web_accept')" . ' ORDER BY payment_date DESC LIMIT 1'; |
||
| 660 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 661 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 662 | $curdate = $row_Recordset1['curdate']; |
||
| 663 | $query_Recordset1 = 'SELECT SUM(mc_gross - mc_fee) AS ipn_total, COUNT(*) AS numrecs' . ' FROM ' . $xoopsDB->prefix('donations_transactions') . " WHERE ({$recdate} payment_date <= '{$curdate}')" . " AND payment_status = 'Completed' AND (txn_type='send_money' OR txn_type='web_accept')"; |
||
| 664 | $Recordset1 = $xoopsDB->query($query_Recordset1); |
||
| 665 | $row_Recordset1 = $xoopsDB->fetchArray($Recordset1); |
||
| 666 | |||
| 667 | echo "<span style='text-align: center; font-weight: bold;' class='title'>" . _AD_DON_UPDATE_REGISTER_IPN . '</span><br /><br />'; |
||
| 668 | if (0 == $row_Recordset1['numrecs']) { |
||
| 669 | echo _AD_DON_NO_NEW_IPNS; |
||
| 670 | } else { |
||
| 671 | $insert_set = 'INSERT INTO `' . $xoopsDB->prefix('donations_financial') . "` (`date`,`num`,`name`,`descr`,`amount`) VALUES ('{$curdate}','','PayPal IPN','Auto-Reconcile','{$row_Recordset1['ipn_total']}')"; |
||
| 672 | |||
| 673 | if ($xoopsDB->query($insert_set)) { |
||
| 674 | echo sprintf(_AD_DON_RECORDS_INSERTED, $row_Recordset1['numrecs'], $currencySign, $row_Recordset1['ipn_total']); |
||
| 675 | } else { |
||
| 676 | echo sprintf(_AD_DON_ERR_DB_INSERTION, $row_Recordset1['numrecs']); |
||
| 677 | } |
||
| 678 | } |
||
| 679 | |||
| 680 | echo "<br /><br /><form action=\"donations.php?op=Treasury#AdminTop\" method=\"post\">"; |
||
| 681 | echo "<input type=\"hidden\" name=\"op\" value=\"Treasury\" />" . "<input type=\"submit\" value=\"" . _AD_DON_RETURN . "\" />" . '</form>'; |
||
| 682 | } |
||
| 683 | |||
| 684 | /** |
||
| 685 | * |
||
| 686 | * Display the IPN Log |
||
| 687 | * |
||
| 688 | */ |
||
| 689 | function showLog() |
||
| 690 | { |
||
| 691 | global $tr_config, $modversion, $xoopsDB, $currencySign; |
||
| 692 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 693 | $indexAdmin = new ModuleAdmin(); |
||
| 694 | echo $indexAdmin->addNavigation('donations.php?op=ShowLog'); |
||
| 695 | |||
| 696 | $query_Recordset1 = 'SELECT id, log_date, payment_date, logentry FROM ' . $xoopsDB->prefix('donations_translog') . ' ORDER BY log_date DESC'; |
||
| 697 | $transRecords = $xoopsDB->query($query_Recordset1); |
||
| 698 | $numRows = $xoopsDB->getRowsNum($transRecords); |
||
| 699 | $logForm = new XoopsThemeForm(_AD_DON_SHOW_LOG, 'logform', $_SERVER['PHP_SELF'], 'POST'); |
||
| 700 | |||
| 701 | if ($numRows) { |
||
| 702 | while (false != (list($rId, $rLdate, $rPdate, $rLentry) = $xoopsDB->fetchRow($transRecords))) { |
||
| 703 | $thisTray = 'logTray_' . $rId; |
||
| 704 | $$thisTray = new XoopsFormElementTray($rId, '<br />'); |
||
| 705 | $$thisTray->addElement(new XoopsFormLabel(_AD_DON_LOG_DATE, $rLdate)); |
||
| 706 | $$thisTray->addElement(new XoopsFormLabel(_AD_DON_PMNT_DATE, $rPdate)); |
||
| 816 |
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.