XoopsModules25x /
oledrion
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * oledrion |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Gestion des passerelles de paiement |
||
| 22 | */ |
||
| 23 | if (!defined('OLEDRION_ADMIN')) { |
||
| 24 | exit(); |
||
| 25 | } |
||
| 26 | |||
| 27 | global $baseurl; // Pour faire taire les warnings de Zend Studio |
||
| 28 | |||
| 29 | switch ($action) { |
||
| 30 | // **************************************************************************************************************** |
||
| 31 | case 'default': // Liste des passerelles de paiement installés |
||
| 32 | // **************************************************************************************************************** |
||
| 33 | xoops_cp_header(); |
||
| 34 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 35 | $adminObject->displayNavigation('index.php?op=gateways'); |
||
| 36 | |||
| 37 | global $xoopsConfig; |
||
|
0 ignored issues
–
show
|
|||
| 38 | // OledrionUtility::htitle(_AM_OLEDRION_INSTALLED_GATEWAYS, 4); |
||
|
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...
|
|||
| 39 | if (file_exists(OLEDRION_GATEWAY_LOG_PATH)) { |
||
| 40 | echo "<a href='" . $baseurl . "?op=gateways&action=seelog'>" . _AM_OLEDRION_GATEWAYS_SEELOG . '</a><br>'; |
||
| 41 | } |
||
| 42 | $currentGateway = Oledrion_gateways::getCurrentGateway(); |
||
| 43 | $class = ''; |
||
| 44 | echo "<form method='post' action='" . $baseurl . "'><input type='hidden' name='op' id='op' value='gateways'><input type='hidden' name='action' id='action' value='setDefaultGateway'>"; |
||
| 45 | echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>\n"; |
||
| 46 | echo "<tr><th align='center'>" |
||
| 47 | . _AM_OLEDRION_GATEWAYS_NAME |
||
| 48 | . "</th><th align='center'>" |
||
| 49 | . _AM_OLEDRION_GATEWAYS_VERSION |
||
| 50 | . "</th><th align='center'>" |
||
| 51 | . _AM_OLEDRION_GATEWAYS_DESCRIPTION |
||
| 52 | . "</th><th align='center'>" |
||
| 53 | . _AM_OLEDRION_GATEWAYS_AUTHOR |
||
| 54 | . "</th><th align='center'>" |
||
| 55 | . _AM_OLEDRION_GATEWAYS_DATE |
||
| 56 | . "</th><th align='center'>" |
||
| 57 | . _AM_OLEDRION_GATEWAYS_USED |
||
| 58 | . "</th></tr>\n"; |
||
| 59 | $installedGateways = Oledrion_gateways::getInstalledGatewaysList(); |
||
| 60 | $gatewaysCount = 0; |
||
| 61 | |||
| 62 | foreach ($installedGateways as $installedGateway) { |
||
| 63 | if (Oledrion_gateways::gatewayClassFileExists($installedGateway)) { // Il y a une classe donc c'est bon |
||
| 64 | if (!Oledrion_gateways::loadGatewaysLanguageDefines($installedGateway)) { // On n'a pas réussi à charger le fichier de traduction |
||
| 65 | continue; |
||
| 66 | } |
||
| 67 | Oledrion_gateways::includeGatewayClass($installedGateway); // Chargement du fichier de la classe |
||
| 68 | if (Oledrion_gateways::gatewayClassExists($installedGateway)) { |
||
| 69 | $gatewayClassName = Oledrion_gateways::gatewayClassName($installedGateway); |
||
| 70 | $temporaryGateway = new $gatewayClassName(); |
||
| 71 | if (is_object($temporaryGateway)) { |
||
| 72 | ++$gatewaysCount; |
||
| 73 | $gatewayInformation = $temporaryGateway->getGatewayInformation(); |
||
| 74 | $class = ($class === 'even') ? 'odd' : 'even'; |
||
| 75 | echo "<tr class='" . $class . "'>\n"; |
||
| 76 | echo '<td>' . $gatewayInformation['name'] . "</td>\n"; |
||
| 77 | echo "<td align='center'>" . $gatewayInformation['version'] . "</td>\n"; |
||
| 78 | echo '<td>' . $gatewayInformation['description'] . "</td>\n"; |
||
| 79 | echo '<td>' . $gatewayInformation['author']; |
||
| 80 | if (xoops_trim($gatewayInformation['credits']) != '') { |
||
| 81 | echo '<br>' . _AM_OLEDRION_GATEWAYS_CREDITS . $gatewayInformation['credits']; |
||
| 82 | } |
||
| 83 | echo "</td>\n"; |
||
| 84 | echo "<td align='center'>" . formatTimestamp(strtotime($gatewayInformation['releaseDate']), 's') . "</td>\n"; |
||
| 85 | echo "<td align='center'>"; |
||
| 86 | $checked = ''; |
||
| 87 | $isCurrentGateway = false; |
||
| 88 | if ($currentGateway == $installedGateway) { |
||
| 89 | $checked = 'checked'; |
||
| 90 | $isCurrentGateway = true; |
||
| 91 | } |
||
| 92 | echo "<input type='radio' name='gateway' id='gateway' $checked value='" . $installedGateway . "'>"; |
||
| 93 | if ($isCurrentGateway) { |
||
| 94 | echo "<br><a href='" . $baseurl . '?op=gateways&action=parameters&gateway=' . $gatewayInformation['foldername'] . "'>" . _AM_OLEDRION_GATEWAYS_PARAMETERS . '</a>'; |
||
| 95 | } |
||
| 96 | echo "</td>\n"; |
||
| 97 | echo "</tr>\n"; |
||
| 98 | } |
||
| 99 | unset($temporaryGateway); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 | if ($gatewaysCount > 0) { |
||
| 104 | $class = ($class === 'even') ? 'odd' : 'even'; |
||
| 105 | echo "<tr class='" . $class . "'>\n"; |
||
| 106 | echo "<td colspan='6' align='center'><br><input type='submit' name='btngot' id='btngo' value='" . _AM_OLEDRION_GATEWAYS_UPDATE . "'><br><br></form></td></tr>\n"; |
||
| 107 | echo "</tr>\n"; |
||
| 108 | } |
||
| 109 | echo "</table>\n"; |
||
| 110 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 111 | break; |
||
| 112 | |||
| 113 | // **************************************************************************************************************** |
||
| 114 | case 'seelog': // Voir le contenu du fichier log |
||
| 115 | // **************************************************************************************************************** |
||
| 116 | xoops_cp_header(); |
||
| 117 | global $xoopsConfig; |
||
| 118 | OledrionUtility::htitle(_AM_OLEDRION_INSTALLED_GATEWAYS, 4); |
||
| 119 | $opRedirect = '?op=gateways'; |
||
| 120 | if (!file_exists(OLEDRION_GATEWAY_LOG_PATH)) { |
||
| 121 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . $opRedirect, 4); |
||
| 122 | } |
||
| 123 | $logContent = nl2br(file_get_contents(OLEDRION_GATEWAY_LOG_PATH)); |
||
| 124 | echo '<div id="logContent" style="width: 1024px; max-width! 1024px; height: 400px; overflow: auto;">'; |
||
| 125 | echo "<pre>\n"; |
||
| 126 | echo $logContent; |
||
| 127 | echo "</pre>\n"; |
||
| 128 | echo "</div>\n"; |
||
| 129 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 130 | break; |
||
| 131 | |||
| 132 | // **************************************************************************************************************** |
||
| 133 | case 'setDefaultGateway': // Choix de la passerelle de paiement par défaut |
||
| 134 | // **************************************************************************************************************** |
||
| 135 | xoops_cp_header(); |
||
| 136 | oledrion_adminMenu(12); |
||
| 137 | $opRedirect = '?op=gateways'; |
||
| 138 | $gateway = isset($_POST['gateway']) ? strtolower($_POST['gateway']) : ''; |
||
| 139 | $gateway = Oledrion_gateways::purifyGatewayName($gateway); |
||
| 140 | if (empty($gateway)) { |
||
| 141 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl . $opRedirect, 5); |
||
| 142 | } |
||
| 143 | if (oledrion_set_module_option('used_gateway', $gateway)) { |
||
| 144 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . $opRedirect, 1); |
||
| 145 | } else { |
||
| 146 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . $opRedirect, 4); |
||
| 147 | } |
||
| 148 | break; |
||
| 149 | |||
| 150 | // **************************************************************************************************************** |
||
| 151 | case 'parameters': // Paramètres de la passerelle de paiement sélectionnée |
||
| 152 | // **************************************************************************************************************** |
||
| 153 | xoops_cp_header(); |
||
| 154 | oledrion_adminMenu(12); |
||
| 155 | OledrionUtility::htitle(_AM_OLEDRION_INSTALLED_GATEWAYS, 4); |
||
| 156 | $opRedirect = '?op=gateways'; |
||
| 157 | $gateway = isset($_GET['gateway']) ? strtolower($_GET['gateway']) : ''; |
||
| 158 | $gateway = Oledrion_gateways::purifyGatewayName($gateway); |
||
| 159 | if (empty($gateway)) { |
||
| 160 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl . $opRedirect, 5); |
||
| 161 | } |
||
| 162 | if (Oledrion_gateways::gatewayClassFileExists($gateway)) { // Il y a une classe donc c'est bon |
||
| 163 | $languageFilename = ''; |
||
| 164 | $languageFileIncluded = Oledrion_gateways::loadGatewaysLanguageDefines($gateway, $languageFilename); |
||
| 165 | if (!$languageFileIncluded) { |
||
| 166 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR2, $baseurl . $opRedirect, 4); |
||
| 167 | } |
||
| 168 | Oledrion_gateways::includeGatewayClass($gateway); |
||
| 169 | if (Oledrion_gateways::gatewayClassExists($gateway)) { |
||
| 170 | $gatewayClassName = Oledrion_gateways::gatewayClassName($gateway); |
||
| 171 | $temporaryGateway = new $gatewayClassName(); |
||
| 172 | if (!Oledrion_gateways::asGoodAncestor($temporaryGateway)) { |
||
| 173 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR4, $baseurl . $opRedirect, 4); |
||
| 174 | } |
||
| 175 | $temporaryGateway->languageFilename = $languageFilename; |
||
| 176 | $form = $temporaryGateway->getParametersForm($baseurl . $opRedirect . '&action=saveparameters'); |
||
| 177 | $form =& OledrionUtility::formMarkRequiredFields($form); |
||
| 178 | $form->display(); |
||
| 179 | } else { |
||
| 180 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR3, $baseurl . $opRedirect, 4); |
||
| 181 | } |
||
| 182 | } else { |
||
| 183 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR1, $baseurl . $opRedirect, 4); |
||
| 184 | } |
||
| 185 | break; |
||
| 186 | |||
| 187 | // **************************************************************************************************************** |
||
| 188 | case 'saveparameters': // Enregistrement des paramètres de la passerelle de paiement |
||
| 189 | // **************************************************************************************************************** |
||
| 190 | xoops_cp_header(); |
||
| 191 | oledrion_adminMenu(12); |
||
| 192 | $opRedirect = '?op=gateways'; |
||
| 193 | $gateway = isset($_POST['gateway']) ? strtolower($_POST['gateway']) : ''; |
||
| 194 | $gateway = Oledrion_gateways::purifyGatewayName($gateway); |
||
| 195 | if (empty($gateway)) { |
||
| 196 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl . $opRedirect, 5); |
||
| 197 | } |
||
| 198 | if (!Oledrion_gateways::isInstalledGatewayName($gateway)) { |
||
| 199 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR5, $baseurl . $opRedirect, 4); |
||
| 200 | } |
||
| 201 | if (Oledrion_gateways::gatewayClassFileExists($gateway)) { |
||
| 202 | if (!Oledrion_gateways::loadGatewaysLanguageDefines($gateway)) { // Le chargement des traductions a échoué |
||
| 203 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR2, $baseurl . $opRedirect, 4); |
||
| 204 | } |
||
| 205 | Oledrion_gateways::includeGatewayClass($gateway); |
||
| 206 | if (Oledrion_gateways::gatewayClassExists($gateway)) { |
||
| 207 | $gatewayClassName = Oledrion_gateways::gatewayClassName($gateway); |
||
| 208 | $temporaryGateway = new $gatewayClassName(); |
||
| 209 | if (!Oledrion_gateways::asGoodAncestor($temporaryGateway)) { |
||
| 210 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR4, $baseurl . $opRedirect, 4); |
||
| 211 | } |
||
| 212 | if ($temporaryGateway->saveParametersForm($_POST)) { |
||
| 213 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . $opRedirect, 2); |
||
| 214 | } else { |
||
| 215 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . $opRedirect, 4); |
||
| 216 | } |
||
| 217 | } else { |
||
| 218 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR3, $baseurl . $opRedirect, 4); |
||
| 219 | } |
||
| 220 | } else { |
||
| 221 | OledrionUtility::redirect(_AM_OLEDRION_GATEWAYS_ERROR1, $baseurl . $opRedirect, 4); |
||
| 222 | } |
||
| 223 | break; |
||
| 224 | } |
||
| 225 |
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state