$sql = sed_sql_query("DELETE FROM {$db_pages} WHERE page_id='{$id}'");
            $sql = sed_sql_query("DELETE FROM {$db_ratings} WHERE rating_code='{$id2}'");
            $sql = sed_sql_query("DELETE FROM {$db_rated} WHERE rated_code='{$id2}'");
            $sql = sed_sql_query("DELETE FROM {$db_com} WHERE com_code='{$id2}'");
            sed_log("Deleted page #" . $id, 'adm');
        } else {
            $rpagedate = $rpagedatenow ? $sys['now_offset'] : sed_mktime($rhour, $rminute, 0, $rmonth, $rday, $ryear) - $usr['timezone'] * 3600;
            $rpagebegin = sed_mktime($rhour_beg, $rminute_beg, 0, $rmonth_beg, $rday_beg, $ryear_beg) - $usr['timezone'] * 3600;
            $rpageexpire = sed_mktime($rhour_exp, $rminute_exp, 0, $rmonth_exp, $rday_exp, $ryear_exp) - $usr['timezone'] * 3600;
            $rpageexpire = $rpageexpire <= $rpagebegin ? $rpagebegin + 31536000 : $rpageexpire;
            $rpagetype = $usr['maingrp'] != 5 && $rpagetype == 2 ? 0 : $rpagetype;
            if (!empty($rpagealias)) {
                $sql = sed_sql_query("SELECT page_id FROM {$db_pages} WHERE page_alias='" . sed_sql_prep($rpagealias) . "' AND page_id!='" . $id . "'");
                $rpagealias = sed_sql_numrows($sql) > 0 ? "alias" . rand(1000, 9999) : $rpagealias;
            }
            $sql = sed_sql_query("UPDATE {$db_pages} SET\n\t\t\t\tpage_cat = '" . sed_sql_prep($rpagecat) . "',\n\t\t\t\tpage_type = '" . sed_sql_prep($rpagetype) . "',\n\t\t\t\tpage_key = '" . sed_sql_prep($rpagekey) . "',\n\t\t\t\tpage_extra1 = '" . sed_sql_prep($rpageextra1) . "',\n\t\t\t\tpage_extra2 = '" . sed_sql_prep($rpageextra2) . "',\n\t\t\t\tpage_extra3 = '" . sed_sql_prep($rpageextra3) . "',\n\t\t\t\tpage_extra4 = '" . sed_sql_prep($rpageextra4) . "',\n\t\t\t\tpage_extra5 = '" . sed_sql_prep($rpageextra5) . "',\n\t\t\t\tpage_title = '" . sed_sql_prep($rpagetitle) . "',\n\t\t\t\tpage_desc = '" . sed_sql_prep($rpagedesc) . "',\n\t\t\t\tpage_text='" . sed_sql_prep($rpagetext) . "',\n\t\t\t\tpage_author = '" . sed_sql_prep($rpageauthor) . "',\n\t\t\t\tpage_ownerid = '{$rpageownerid}',\n\t\t\t\tpage_date = '{$rpagedate}',\n\t\t\t\tpage_begin = '{$rpagebegin}',\n\t\t\t\tpage_expire = '{$rpageexpire}',\n\t\t\t\tpage_file = '" . sed_sql_prep($rpagefile) . "',\n\t\t\t\tpage_url = '" . sed_sql_prep($rpageurl) . "',\n\t\t\t\tpage_size = '" . sed_sql_prep($rpagesize) . "',\n\t\t\t\tpage_count = '{$rpagecount}',\n\t\t\t\tpage_filecount = '{$rpagefilecount}',\n\t\t\t\tpage_alias = '" . sed_sql_prep($rpagealias) . "'\n\t\t\t\tWHERE page_id='{$id}'");
            sed_log("Edited page #" . $id, 'adm');
        }
        if ($r == 'adm') {
            header("Location: admin.php?m=page&s=queue");
            exit;
        } else {
            header("Location: list.php?c={$rpagecat}");
            exit;
        }
    }
}
if ($a == 'unvalidate') {
    sed_check_xg();
    $sql = sed_sql_query("SELECT page_ownerid, page_cat FROM {$db_pages} WHERE page_id='{$id}' LIMIT 1");
    if ($row = sed_sql_fetcharray($sql)) {
    if ($ruser == "") {
        $error_string .= $L['plu_noname'] . "<br>";
    }
    if ($remail != "") {
        $error_string .= strlen($remail) < 4 || !eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]{2,})+\$", $remail) ? $L['plu_emailnotvalid'] . "<br />" : "";
    }
    if ($rwebsite != "") {
        $error_string .= !eregi("[[:alpha:]]+://", $rwebsite) ? $L['plu_websitenotvalid'] . "<br />" : "";
    }
    $error_string .= strlen($rtext) < $cfg['plugin']['guestbook']['minchars'] ? $L['plu_entrytooshort'] . "<br>" : "";
    $error_string .= strlen($rtext) > $cfg['plugin']['guestbook']['maxchars'] ? $L['plu_entrytoolong'] . "<br>" : "";
    if ($error_string == "") {
        $ruser = sed_sql_prep($ruser);
        $rtext = sed_sql_prep($rtext);
        $rdate = $sys['now_offset'];
        $rwebsite = $rwebsite != "http://" ? sed_sql_prep($rwebsite) : '';
        $sql = sed_sql_query("UPDATE {$db_guestbook} SET gb_author='{$ruser}', gb_text='{$rtext}', gb_email='{$remail}', gb_website='{$rwebsite}' WHERE gb_id='{$id}' ");
        header("Location: plug.php?e=guestbook");
        exit;
    }
}
if (isset($error_string)) {
    $t->assign("GUESTBOOK_ERROR_BODY", $error_string);
    $t->parse("MAIN.GUESTBOOK_ERROR");
}
if ($a == "sign" or $a == "send") {
    $bbcodes = $cfg['plugin']['guestbook']['bbcodes'] == 'Yes' ? sed_build_bbcodes("guestbookentry", "rtext", $L['BBcodes']) : '';
    $smilies = $cfg['plugin']['guestbook']['smilies'] == 'Yes' ? sed_build_smilies("guestbookentry", "rtext", $L['Smilies']) : '';
    $name = $usr['id'] == 0 ? "<input type=\"text\" name=\"ruser\" value=\"" . $ruser . "\">" : "<input type=\"text\" name=\"ruser\" value=\"" . $usr['name'] . "\" readonly>";
    $email = "<input type=\"text\" name=\"remail\" value=\"" . $remail . "\">";
    $website = $rwebsite == "" ? "<input type=\"text\" name=\"rwebsite\" value=\"http://\">" : "<input type=\"text\" name=\"rwebsite\" value=\"" . $rwebsite . "\">";
Type=Plugin
Author=riptide
Description=Delete users which stayed off your website too long automaticaly
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=userwatchdog
Part=users.auth.check.done
File=userwatchdog.auth
Hooks=users.auth.check.done
Tags=
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]

==================== */
if (!defined('SED_CODE')) {
    die("Wrong URL.");
}
if ($cfg['plugin']['userwatchdog']['uwd_enableplugin'] == 'yes') {
    $uwd_reprieveslot = $cfg['plugin']['userwatchdog']['uwd_reprieveslot'];
    if ($rusername != '') {
        //check if it is a user with a reprieve and if yes, clear the reprieve date
        $uwd_sql = sed_sql_query("UPDATE {$db_users} SET " . $uwd_reprieveslot . "='' WHERE " . $uwd_reprieveslot . ">'0' AND user_name='" . sed_sql_prep($rusername) . "' LIMIT 1");
        $uwd_backagain = sed_sql_affectedrows($uwd_sql);
        if ($uwd_backagain > 0) {
            sed_log("User watchdog plugin welcomes back: " . sed_sql_prep($rusername) . "", 'adm');
        }
        unset($uwd_backagain);
    }
}
     $sql_expirepages = sed_sql_query("SELECT page_id, page_cat FROM {$db_pages} WHERE page_expire<" . (int) $sys['now_offset'] . " && page_state!='4'");
 }
 while ($expirepages_result = sed_sql_fetchassoc($sql_expiredpages)) {
     $pageid = (int) $expirepages_result['page_id'];
     switch ($pageexpireaction) {
         case 'delete':
             if ($cfg['trash_page']) {
                 $newtempexpiredate = $sys['now_offset'] + 31556926 * 7;
                 $expirepages_result['page_expire'] = (int) $newtempexpiredate;
                 $expirepages_result['page_state'] = 1;
                 $expirepages_result['page_comcount'] = 0;
                 sed_trash_put('page', $expirepages_result['page_title'], $expirepages_result['page_id'], $expirepages_result);
             }
             $sql_pagestatus = sed_sql_query("DELETE FROM {$db_pages} WHERE page_id='" . (int) $expirepages_result['page_id'] . "'");
             sed_log("Deleted page #" . (int) $expirepages_result['page_id'], 'adm');
             sed_sql_query("UPDATE {$db_structure} SET structure_pagecount=structure_pagecount-1 WHERE structure_code='" . sed_sql_prep($expirepages_result['page_cat']) . "'");
             if ($cfg['plugin']['hidefuturepages']['deletepagerelated'] == 'Yes') {
                 $pagecode = "p" . $pageid;
                 sed_sql_query("DELETE FROM {$db_ratings} WHERE rating_code='{$pagecode}'");
                 sed_sql_query("DELETE FROM {$db_rated} WHERE rated_code='{$pagecode}'");
                 sed_sql_query("DELETE FROM {$db_com} WHERE com_code='{$pagecode}'");
             }
             break;
         case 'hide':
             $sql_pagestatus = sed_sql_query("UPDATE {$db_pages} SET page_state='4' WHERE page_id='{$pageid}'");
             break;
     }
     if ($sql_pagestatus) {
         $expirepages_count++;
     }
 }
function hfp_tool_action_set_to_display($id)
{
    global $db_pages, $cfg, $sys, $usr, $db_structure;
    sed_check_xg();
    $id = (int) $id;
    $state = sed_import('state', 'G', 'INT', 1);
    if ($id > 0) {
        $sql = sed_sql_query("SELECT page_cat FROM {$db_pages} WHERE page_id='" . $id . "'");
        if ($result = sed_sql_fetchassoc($sql)) {
            $pageexpire = hfp_tool_get_yearstillexpire();
            sed_sql_query("UPDATE {$db_pages} SET page_begin='" . (int) $sys['now_offset'] . "', page_expire='" . $pageexpire . "', page_state='0' WHERE page_id='{$id}'");
            sed_sql_query("UPDATE {$db_structure} SET structure_pagecount=structure_pagecount+1 WHERE structure_code='" . sed_sql_prep($result['page_cat']) . "'");
        }
    }
    sed_redirect(sed_url('admin', 'm=tools&p=hidefuturepages&state=' . $state, NULL, TRUE));
}