/*

HTTP WWW AUTHENTICATION TEST CGI PROGRAM WIRITTEN IN C++

AUTHOR: Matt Coan
DATE: Tue May  8 23:15:11 EDT 2018

*/

#include "www_auth.h"

using namespace std;
using namespace cgi_tools;

int
main()
{
   if(www_auth("LOVE REALM", "mcoan", "abc123")) {
      cout << "Content-type: text/html\r\n\r\n" << flush;
      cout << "<HTML>" << endl;
      cout << "<HEAD>" << endl;
      cout << "<TITLE>" << endl;
      cout << "Athorized..." << endl;
      cout << "</TITLE>" << endl; 
      cout << "</HEAD>" << endl;
      cout << "<BODY BGCOLOR=\"WHITE\">" << endl;
      cout << "Athorized..." << endl;
      cout << "<PRE>" << endl; 
      system("env");
      cout << "</PRE>" << endl; 
      cout << "</BODY>" << endl;
      cout << "</HTML>" << endl << flush;
   }
   else {
      cout << "Content-type: text/html\r\n\r\n" << flush;
      cout << "<HTML>" << endl;
      cout << "<HEAD>" << endl;
      cout << "<TITLE>" << endl;
      cout << "Unathorized..." << endl;
      cout << "</TITLE>" << endl; 
      cout << "</HEAD>" << endl;
      cout << "<BODY BGCOLOR=\"WHITE\">" << endl;
      cout << "Unathorized..." << endl;
      cout << "<PRE>" << endl; 
      system("env");
      cout << "</PRE>" << endl;
      cout << "</BODY>" << endl;
      cout << "</HTML>" << endl << flush;
   }
   return 0;
}
