case 1: # форма для добавления / изменения BeginHtml($Title4, $Title3 . $Delimeter . $Title4, "http://" . $DOC_DOMAIN . "/settings/redirect/"); $perm->ExitIfNotAccess(NC_PERM_REDIRECT, 0, 0, 0, 0); if ($RedirectID) { $UI_CONFIG = new ui_config_tool(REDIRECT_TAB_LIST, REDIRECT_TAB_EDIT, 'i_settings_big.gif', 'redirect.edit(' . $RedirectID . ')'); } else { $UI_CONFIG = new ui_config_tool(REDIRECT_TAB_LIST, REDIRECT_TAB_ADD, 'i_settings_big.gif', 'redirect.add'); } RedirectForm($RedirectID); break; case 2: # собственно добавление / изменение BeginHtml($Title2, $Title2, "http://" . $DOC_DOMAIN . "/settings/redirect/"); $perm->ExitIfNotAccess(NC_PERM_REDIRECT, 0, 0, 0, 1); RedirectCompleted(); RedirectList(); break; case 3: # удаление BeginHtml($Title2, $Title2, "http://" . $DOC_DOMAIN . "/settings/redirect/"); $perm->ExitIfNotAccess(NC_PERM_REDIRECT, 0, 0, 0, 1); while (list($key, $val) = each($_POST)) { if (strcmp(substr($key, 0, 6), "Delete") == 0) { DeleteRedirect($val); } } RedirectList(); break; } EndHtml();
/** * Функция отображает список переадрасаций * * @return 0 */ function RedirectList() { global $nc_core, $db, $UI_CONFIG, $ADMIN_TEMPLATE; $db->last_error = ''; $Result = $db->get_results("SELECT `Redirect_ID`,`OldURL`,`NewURL`, `Header` FROM `Redirect` ORDER BY `Redirect_ID`", ARRAY_N); // на случай, если поля не существует if (strstr($db->last_error, 'Header')) { $db->query("ALTER TABLE `Redirect` ADD `Header` INT(3) NULL DEFAULT '301';"); return RedirectList(); } if ($countClassif = $db->num_rows) { ?> <form method=post action=redirect.php> <table class='nc-table nc--striped' width='100%'> <tr> <th >ID</th> <th width=35%><?php echo TOOLS_REDIRECT_OLDURL; ?> </th> <th width=35%><?php echo TOOLS_REDIRECT_NEWURL; ?> </th> <th class='nc-text-center'><?php echo TOOLS_REDIRECT_HEADER; ?> </th> <th class='nc-text-center'><?php echo TOOLS_REDIRECT_SETTINGS; ?> </th> <th class='nc-text-center'><div class='icons icon_delete' title='<?php echo CONTROL_CONTENT_CATALOUGE_FUNCS_SHOWCATALOGUELIST_DELETE; ?> '></div></th> </tr> <?php foreach ($Result as $Array) { print "<tr>"; print "<td >" . $Array[0] . "</td>\n"; print "<td>" . $Array[1] . "</a></td>"; print "<td>" . $Array[2] . "</td>"; print "<td class='nc-text-center'>" . ($Array[3] ? $Array[3] : 301) . "</td>"; print "<td class='nc-text-center'><a href=redirect.php?phase=1&RedirectID=" . $Array[0] . "><div class='icons icon_settings' title='" . TOOLS_REDIRECT_CHANGEINFO . "'></div></a></td>"; print "<td class='nc-text-center'>" . nc_admin_checkbox_simple("Delete" . $Array[0], $Array[0]) . "</td>"; print "</tr>"; } print "</table><br>"; } else { nc_print_status(TOOLS_REDIRECT_NONE, 'info'); } if ($countClassif) { $UI_CONFIG->actionButtons[] = array("id" => "submit", "caption" => NETCAT_ADMIN_DELETE_SELECTED, "action" => "mainView.submitIframeForm()", "align" => "right", "red_border" => true); print "<input type=hidden name=phase value=3>"; print "<input type='submit' class='hidden'>"; print $nc_core->token->get_input(); print "</form>"; } $UI_CONFIG->actionButtons[] = array("id" => "add", "caption" => TOOLS_REDIRECT_ADD, "location" => "redirect.add", "align" => "left"); return 0; }