<commit_before>#include "stdsneezy.h"
#include "database.h"
#include "shop.h"

#include <iostream>
#include <vector>
#include <string>

#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"

using namespace cgicc;


int main(int argc, char **argv){
  Cgicc cgi;
  TDatabase db("sneezyprod");
  sstring buf;

  form_iterator name = cgi.getElement("name");
  form_iterator pw = cgi.getElement("pw");
  form_iterator shop_nr = cgi.getElement("shop_nr");

  if(name == cgi.getElements().end() ||
     pw == cgi.getElements().end()){
    cout << HTTPHTMLHeader() << endl;
    cout << html() << head(title("shop logs")) << endl;
    cout << body() << endl;

    cout << "<form method=post action=\"/shoplog.cgi\">" << endl;
    cout << "Name: <input type=text name=name>" << endl;
    cout << "Password: <input type=password name=pw><br>" << endl;
    cout << "<input type=submit>" << endl;
    cout << body() << html();
  } else if(shop_nr == cgi.getElements().end()){
    cout << HTTPHTMLHeader() << endl;
    cout << html() << head(title("shop logs")) << endl;
    cout << body() << endl;

    cout << "<form method=post action=\"/shoplog.cgi\">" << endl;
    cout << "Select a shop: <select name=shop_nr>" << endl;

    db.query("select soa.shop_nr from shopownedaccess soa, shopowned so where lower(name) = lower('%s') and soa.shop_nr=so.shop_nr and so.password='%s'", (**name).c_str(), (**pw).c_str());
    while(db.fetchRow()){
      cout << "<option value=" << db.getColumn("shop_nr");
      cout << "> " << db.getColumn("shop_nr") << endl;
    }
    cout << "</select>";
    cout << "<input type=hidden name=name value=" << **name << ">";
    cout << "<input type=hidden name=pw value=" << **pw << ">";
    cout << "<input type=submit>" << endl;
    cout << body() << html();
  } else {
    db.query("select shop_nr, name, action, item, talens, shoptalens, shopvalue, logtime, itemcount from shoplog where shop_nr=%i order by logtime", convertTo<int>(**shop_nr));
    cout << "Content-type: text/plain\n\n";
    
    while(db.fetchRow()){
      for(int i=0;i<7;++i){
	cout << db.getColumn(i) << ",";
      }
      cout << db.getColumn(8) << endl;
    }
  }
  
}<commit_msg>fixed a bug with missing output column added column headers stripped color codes<commit_after>#include "stdsneezy.h"
#include "database.h"
#include "shop.h"

#include <iostream>
#include <vector>
#include <string>

#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"

using namespace cgicc;


int main(int argc, char **argv){
  Cgicc cgi;
  TDatabase db("sneezyprod");
  sstring buf;

  form_iterator name = cgi.getElement("name");
  form_iterator pw = cgi.getElement("pw");
  form_iterator shop_nr = cgi.getElement("shop_nr");

  if(name == cgi.getElements().end() ||
     pw == cgi.getElements().end()){
    cout << HTTPHTMLHeader() << endl;
    cout << html() << head(title("shop logs")) << endl;
    cout << body() << endl;

    cout << "<form method=post action=\"/shoplog.cgi\">" << endl;
    cout << "Name: <input type=text name=name>" << endl;
    cout << "Password: <input type=password name=pw><br>" << endl;
    cout << "<input type=submit>" << endl;
    cout << body() << html();
  } else if(shop_nr == cgi.getElements().end()){
    cout << HTTPHTMLHeader() << endl;
    cout << html() << head(title("shop logs")) << endl;
    cout << body() << endl;

    cout << "<form method=post action=\"/shoplog.cgi\">" << endl;
    cout << "Select a shop: <select name=shop_nr>" << endl;

    db.query("select soa.shop_nr from shopownedaccess soa, shopowned so where lower(name) = lower('%s') and soa.shop_nr=so.shop_nr and so.password='%s'", (**name).c_str(), (**pw).c_str());
    while(db.fetchRow()){
      cout << "<option value=" << db.getColumn("shop_nr");
      cout << "> " << db.getColumn("shop_nr") << endl;
    }
    cout << "</select>";
    cout << "<input type=hidden name=name value=" << **name << ">";
    cout << "<input type=hidden name=pw value=" << **pw << ">";
    cout << "<input type=submit>" << endl;
    cout << body() << html();
  } else {
    db.query("select shop_nr, name, action, item, talens, shoptalens, shopvalue, logtime, itemcount from shoplog where shop_nr=%i order by logtime", convertTo<int>(**shop_nr));
    cout << "Content-type: text/plain\n\n";
    cout << "shop_nr, name, action, item, talens, shoptalens, shopvalue, logtime, itemcount\n";

    while(db.fetchRow()){
      for(int i=0;i<8;++i){
	cout << stripColorCodes(db.getColumn(i)) << ", ";
      }
      cout << stripColorCodes(db.getColumn(8)) << endl;
    }
  }
  
}
{'fraction_non_alphanumeric': 0.2061498484192291, 'fraction_numerical': 0.00129926375054136, 'mean_word_length': 3.79149377593361, 'pattern_counts': {'":': 0, '<': 235, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4696358', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1601, 'n_words': 384}