Exemplo n.º 1
0
     $perm->ExitIfNotAccess(NC_PERM_REDIRECT, 0, 0, 0, 0);
     if ($nc_core->NC_REDIRECT_DISABLED) {
         nc_print_status(TOOLS_REDIRECT_DISABLED, 'info');
     }
     RedirectList();
     break;
 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);
Exemplo n.º 2
0
function RedirectCompleted()
{
    global $db;
    $OldURL = $db->escape($_POST['OldURL']);
    $NewURL = $db->escape($_POST['NewURL']);
    $HeaderCode = intval($_POST['HeaderCode']);
    $RedirectID = intval($_POST['RedirectID']);
    if ($HeaderCode != 301 && $HeaderCode != 302) {
        $HeaderCode = 301;
    }
    if (!$OldURL || !$NewURL) {
        print TOOLS_REDIRECT_CANTBEEMPTY . "<br />";
        RedirectForm($RedirectID);
        $Result = 0;
    } elseif (!$RedirectID) {
        $Result = $db->query("INSERT INTO  `Redirect` (`OldURL`,`NewURL`, `Header`) VALUES ('" . $OldURL . "','" . $NewURL . "', '" . $HeaderCode . "')");
    } else {
        $Result = $db->query("UPDATE `Redirect` SET `OldURL`='" . $OldURL . "', `NewURL`='" . $NewURL . "', `Header` = '" . $HeaderCode . "' WHERE `Redirect_ID`='" . $RedirectID . "'");
    }
    return $Result;
}