예제 #1
0
    }
}
if (!$bFound) {
    header_location_exit('/404.php');
}
if ($sAction && count($_POST) && $_POST['u_token_key'] != $_SESSION['rand']) {
    header_location_exit('/404.php');
}
switch ($sAction) {
    case 'add':
        $sName = substr(trim($_POST['reason_name']), 0, 64);
        $sReason = trim($_POST['reason_text']);
        $sNameError = !$sName ? 'Укажите Название причины' : '';
        $sTextError = !$sReason ? 'Укажите Текст причины' : '';
        if (!$sNameError && !$sTextError) {
            admin_log::addAdminReason($act_sel, $sName, $sReason, !empty($_POST['is_bold']) ? 't' : 'f');
            header('Location: /siteadmin/proj_reasons?act_sel=' . $act_sel);
        }
        break;
    case 'edit':
        $sCmd = __paramInit('string', null, 'cmd');
        if ($sCmd == 'go') {
            $sName = substr(trim($_POST['reason_name']), 0, 64);
            $sReason = trim($_POST['reason_text']);
            $sNameError = !$sName ? 'Укажите Название причины' : '';
            $sTextError = !$sReason ? 'Укажите Текст причины' : '';
            if ($reasonId && !$sNameError && !$sTextError) {
                admin_log::updateAdminReason($reasonId, $sName, $sReason, !empty($_POST['is_bold']) ? 't' : 'f');
                header('Location: /siteadmin/proj_reasons?act_sel=' . $act_sel);
            }
        }