/* ** Generate a test pages of HTML. ** ** To disable these tests change the WEBPAGE in the comment headers ** to WEB*PAGE and comment out the code. */ #include "config.h" #include "test.h" /* ** Generate an output page that contains information about the ** current environment. */ void test_cgi_vardump(void){ int i; extern char **environ; char zPwd[1000]; getcwd(zPwd, sizeof(zPwd)); cgi_printf("\n" "Test Page\n" "\n" "

Test Page

\n"); cgi_print_all(); cgi_printf("

Environment variables:

\n" "

\n"); for(i=0; environ[i]; i++){ cgi_printf("%h
\n",environ[i]); } cgi_printf("

\n" "

Working directory and user id

\n" "

\n" "pwd = %s
\n" "uid = %d
\n" "euid = %d
\n" "argc = %d
\n",zPwd,getpid(),geteuid(),g.argc); for(i=0; i\n",i,g.argv[i]); } cgi_printf("

\n" "\n"); } /* ** WEBPAGE: /test */ void test_page(void){ login_check_credentials(); if( !g.okSetup ){ login_needed(); return; } test_cgi_vardump(); } /* ** WEBPAGE: /formtest1 */ void form_test_1(void){ login_check_credentials(); if( !g.okSetup ){ login_needed(); return; } cgi_printf("\n" "\n" "

Parameters:

\n"); cgi_print_all(); cgi_printf("

New Form:

\n" "
\n" "X =
\n" "F1 =
\n" "Y =
\n" "F2 =
\n" "\n" "
\n"); } /* ** WEBPAGE: /test2 */ void test_page_2(void){ cgi_redirect("test"); } /* ** WEBPAGE: /endlessloop */ void endlessloop_page(void){ while(1){sleep(5);} } /* ** WEBPAGE: /setcookie */ void set_cookie_page(void){ const char *zName = PD("name","C_NAME"); const char *zVal = PD("value","C_VALUE"); login_check_credentials(); if( !g.okSetup ){ login_needed(); return; } cgi_set_cookie(zName, zVal, 0, 0); cgi_redirect(""); }