generate.c 965 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. void generate_page(char password[25], int sock_in, char *query, char *ip)
  2. {
  3. char *page = get_param(query, 0);
  4. char *ppass = get_param(query, "password");
  5. if ( (ppass == 0) || (strcmp(password, ppass) != 0) )
  6. {
  7. web_send(sock_in, html_header("Enter your password"));
  8. web_send(sock_in, "<H1>NOT LOGGED IN!</H1><form action=\"/\" method=\"GET\">\n");
  9. web_send(sock_in, "Enter your password:<br>\n<input type=\"text\" name=\"password\">\n");
  10. web_send(sock_in, "<input type=\"submit\" value=\"Login\">\n");
  11. }
  12. else
  13. {
  14. //To make this simple, we will have a bunch of if statements
  15. //that then shoot out data off into functions.
  16. //The 'index'
  17. if ( strcmp(page, "/") == 0 )
  18. generate_notdone(sock_in, query, ip);
  19. //About page:
  20. if ( strcmp(page, "/about.html") == 0 )
  21. generate_about(sock_in, query, ip);
  22. //Test page:
  23. if ( strcmp(page, "/testing/") == 0 )
  24. generate_sample(sock_in, query, ip);
  25. }
  26. }