#include #include #include #include "global.h" #include "custom.h" #include "manhat-lib/shared_util.h" #include "manhat-lib/shared_cookie.h" #include "manhat-lib/shared_login.h" #include "manhat-lib/shared_super_util.h" #include "manhat-lib/shared_cs_util.h" static void read_parameters (char *key, int *first) { char temp[12]; cs_get_required_parameter ("id", key, MAX_KEY); cs_get_optional_parameter("first",temp,11); *first = atoi(temp); } int main() { char key[MAX_KEY + 1]; SESSION user; int cookies_work; int first; char cookie_key[MAX_KEY +1]; cs_cgi_init(); read_parameters (key, &first); cookies_work = parse_cookie(cookie_key); if(!cookies_work) /* shared_cookie.c - if cookies don't work */ { if(SUPER_REQUIRE_COOKIES) /* custom.h - cookies don't work -stop!*/ cs_critical_error(ERR_COOKIES_MUST_BE_ENABLED, ""); else /* allow user to continue, even though he's disabled cookies on his browser */ printf("Location:%s?id=%s&first=%d\n\n", "super_admin_page", key, first); } else /* if cookies are enabled and they work */ { validate_super_key(key, &user); create_super_key(user.username, key); set_cookie(key, SBIN_ALIAS, ALIAS); /* shared_cookie.c */ printf("", "super_admin_page", USE_COOKIE, first); } /* cookies are enabled */ return 0; cs_cgi_destroy(); }