Beispiel #1
0
int main(int argc, char *argv[])
{
    print_html_header();
    do_cgi_data();

  return EXIT_SUCCESS;
}
Beispiel #2
0
/* entry point to generate a report writing it to the fp */
void
output_html (GLog * logger, GHolder * holder)
{
  FILE *fp = stdout;
  char now[DATE_TIME];

  generate_time ();
  strftime (now, DATE_TIME, "%Y-%m-%d %H:%M:%S", now_tm);

  print_html_header (fp, now);
  print_pure_menu (fp, now);

  print_html_summary (fp, logger);
  print_html_visitors_report (fp, holder + VISITORS);
  print_html_request_report (fp, holder + REQUESTS, logger->process);
  print_html_request_report (fp, holder + REQUESTS_STATIC, logger->process);
  print_html_request_report (fp, holder + NOT_FOUND, logger->process);
  print_html_hosts (fp, holder + HOSTS, logger->process);
  print_html_browser_os (fp, holder + OS);
  print_html_browser_os (fp, holder + BROWSERS);
  print_html_generic (fp, holder + REFERRERS, logger->process);
  print_html_generic (fp, holder + REFERRING_SITES, logger->process);
  print_html_generic (fp, holder + KEYPHRASES, logger->process);
#ifdef HAVE_LIBGEOIP
  print_html_geolocation (fp, holder + GEO_LOCATION, logger->process);
#endif
  print_html_status (fp, holder + STATUS_CODES, logger->process);

  print_html_footer (fp);
}
Beispiel #3
0
Datei: main.c Projekt: llxp/llxp
int main()
{
    //mysql_start();
    print_header();
    print_html_header(titel_);
    //var_copy=getenv("QUERY_STRING");
    parse_content(getdata_force("GET"), "=", "&", "POST");
    parse_content(getdata_force("POST"), "=", "&", "GET");
    //parse_content(getdata_force("POST"), "=", "&", "POST");
       // parse_content(getdata_force("POST"), "=", "&", 0);
//    printf("%s\n%s", getdata_force("GET"),getdata_force("POST"));
//char *post_query=(char*) malloc(100 * sizeof(char));
//char *get_query=(char*) malloc(strlen(default_string)*100* sizeof(char));
    //sprintf(post_query, "%s", getdata_force("POST"));
    //sprintf(get_query, "%s", getdata_force("GET"));
   // printf("%s", post_query);
    //strcpy(get_query, getdata_force("GET"));
    /*if(strcmp(_GET[0][0],"method")==0){
        if(strcmp(_GET[0][1], "normal")==0){
            if(strcmp(_GET[1][0],"action")==0){
                if(strcmp(_GET[1][1],"post")==0){

                    char *content_length = getenv("CONTENT_LENGTH");
                    if(content_length==NULL){

                        goto exit;
                    }
                    else{
                        size = (unsigned long) atoi(content_length);
                        if(size<=0){

                            goto exit;
                        }else{
                            content_post = (char *) malloc(size+1);
                            if(content_post==NULL){
                                free(content_post);
                                goto exit;
                            }*/
                            //scanf("%s", post_var);
                            //printf("%s", post_query);
                            //parse_content(post_query, "=", "&", "POST");
                            printf("<h1>!%s!!</h1>", _POST[0][1]);
                            //printf("Hallo!!!%s", _POST[0][1]);
                            //printf("%d", (int)strlen(*_POST[0]));
                           // for(a=0;a<(int)strlen(_POST[a]))
                            //for(b=0;b<(int)strlen(_POST[0][1]);b++){
                              //  stringReplace("+", "", _POST[0][1]);
                            //}
                            printf("\n%s=%s\n", _POST[0][0],_POST[0][1]);
                            add_tag("ul", "style={float:left;} id='left' class='left'");
                            addslash("ul");
                            //free(content_post);
                            //goto exit;

                        }
int main(void) {
  char *path = getenv("PATH_INFO");
  char *query= getenv("QUERY_STRING");
  char **patharray = NULL;
  char **queryarray = NULL;
  char *filename;
  char *category = NULL;
  int number_of_entries = 0, i = 0, sizeofpath = 0, sizeofquery = 0, feed=0;
  char *token;
  int page = 0;
  int page_entries = 0;
  struct entry **entries = read_entries(&number_of_entries);
  struct sidebar *sb = make_sidebar(entries, number_of_entries);
  struct entry **entries_to_print = entries;
  struct entry *lonely_entry = NULL;

  /* GET information from path */
  if (path) {
    token = strtok(path, "/");
    if (token) {
      do {
	patharray = realloc( patharray, sizeof(char *) * (sizeofpath + 1));
	patharray[sizeofpath] = strdup(token);
	sizeofpath++;
      } while ((token = strtok(NULL, "/")));
    }
  }

  /* GET information from query */
  if (query) {
    token = strtok(query, "=");
    if (token) {
      do {
	queryarray = realloc( queryarray, sizeof(char *) * (sizeofquery + 1));
	queryarray[sizeofquery] = strdup(token);
	sizeofquery++;
      } while ((token = strtok(NULL, "=")));

      if (sizeofquery > 1 && strcasecmp(queryarray[0], "page") == 0) {
	if (strlen(queryarray[1]) < 3 && sscanf(queryarray[1], "%d", &page) == 1) {
	  if (page > 0) {
	    page_entries = NUMBEROFENTRIESPERPAGE * page;
	  }
	}
      }
      
    }
  }

  
  /* Check if this is feed */
  if (sizeofpath > 0 && strcasecmp(patharray[sizeofpath-1], "feed") == 0) {
    feed = 1;
  }
  /* Entry, category or month*/
  if (sizeofpath > 0 && sizeofpath < 3) {
    /* Look for category */
    for (i = 0; i < sb->number_of_categories; i++) {
      if (strcasecmp(patharray[0], sb->categories[i]->name) == 0) {
	category = sb->categories[i]->name;
	entries_to_print = sb->categories[i]->ent;
	number_of_entries = sb->categories[i]->number;
	goto out;
      }
    }
    /* No category found look for months */
    for (i = 0; i < sb->number_of_months; i++) {
      if (strcasecmp(patharray[0], sb->months[i]->name) == 0) {
	entries_to_print = sb->months[i]->ent;
	number_of_entries = sb->months[i]->number;
	goto out;
      }
    }
    /* No months or categories found look one entry */
    asprintf(&filename, "%s.txt", patharray[0]);
    if ((lonely_entry = read_entry(filename))) {
      number_of_entries = 1;
      entries_to_print[0] = lonely_entry;
    }
    /* Else just show the normal index*/
  }

 out:

  /* Sort entries according to date */
  qsort(entries_to_print, 
	number_of_entries, 
	sizeof(struct entry *), 
	compare_entries);

  /* Print entries */
  if (feed) {
    print_feed_header(entries_to_print[i]);
    for (i = page_entries; i < number_of_entries && 
	   i < (NUMBEROFENTRIESPERPAGE + page_entries); i++) {
      print_feed_entry(entries_to_print[i]);    
    }
    print_feed_footer();
  }
  else {
    print_html_header(sb);
    for (i = page_entries; i < number_of_entries && 
	   i < (NUMBEROFENTRIESPERPAGE + page_entries); i++) {
      print_html_entry(entries_to_print[i]);
    }
    /* Next and previous page links. Print links only if we have more
       than one entry to print */
    if (i > (page_entries + 1) &&
	number_of_entries > (page_entries + NUMBEROFENTRIESPERPAGE)) {
      printf("<div class=\"navi\">");
      if (page > 0) {
	if (sizeofpath == 1) {
	  printf("<a href=\"%s/%s?page=%d\">%s</a> ", 
		 BASEURL, patharray[0], page - 1, L_PREVIOUSPAGE);
	}
	else {
	  printf("<a href=\"%s?page=%d\">%s</a> ", 
		 BASEURL, page - 1,  L_PREVIOUSPAGE);
	}
      }
      if (sizeofpath == 1) {
	printf("<a href=\"%s/%s?page=%d\">%s</a>", 
	       BASEURL, patharray[0], page + 1, L_NEXTPAGE);
      }
      else {
	printf("<a href=\"%s?page=%d\">%s</a>", BASEURL, page + 1, L_NEXTPAGE);
      }
      printf("</div>");
    }
    print_html_sidebar(sb);
    print_html_footer();
  }
  return 0;
}