INT32 hourly_page_hits(struct mapping *urls, struct mapping *pages, struct mapping *hits, struct multiset *pagexts, INT32 code) { INT32 i, e, len; struct svalue *sind; struct svalue *sval; struct pike_string *decoded; unsigned char *decode_buf; unsigned char *qmark; unsigned INT32 numpages = 0; struct keypair *k; decode_buf = malloc(MAX_LINE_LEN+1); MY_MAPPING_LOOP(urls, e, k) { sind = &k->ind; sval = &k->val; qmark = (unsigned char *)STRCHR(sind->u.string->str, '?'); if(qmark) { MEMCPY(decode_buf, sind->u.string->str, len = MIN(MAX_LINE_LEN, ((INT32)qmark - (INT32)sind->u.string->str - 1))); } else { MEMCPY(decode_buf, sind->u.string->str, len = MIN(MAX_LINE_LEN, sind->u.string->len)); } decoded = http_decode_string(decode_buf, len); if(ispage(decoded, pagexts)) { numpages += sval->u.integer; /* printf("\tPAGE: %5d\t%s\n", sval->u.integer, decoded->str);*/ mapaddstrnum(pages, decoded, sval); } else { /* printf("\tHIT: %5d\t%s\n", sval->u.integer, decoded->str);*/ mapaddstrnum(hits, decoded, sval); } free_string(decoded); }
int put_inode( char *str, /* ident str */ int type, /* obj type */ u_long count, /* hit count */ u_long file, /* File flag */ double xfer, /* xfer size */ u_long *ctr, /* counter */ u_long visit, /* visits */ u_long tstamp,/* timestamp */ INODEPTR *htab) /* hashtable */ { INODEPTR cptr,nptr; if ((str[0]=='-') || (str[0]==0)) return 0; /* skip if no username */ /* check if hashed */ if ( (cptr = htab[hash(str)]) == NULL) { /* not hashed */ if ( (nptr=new_inode(str)) != NULL) { nptr->flag = type; nptr->count = count; nptr->files = file; nptr->xfer = xfer; nptr->next = NULL; htab[hash(str)] = nptr; if (type!=OBJ_GRP) (*ctr)++; if (visit) { nptr->visit=(visit-1); nptr->tstamp=tstamp; return 0; } else { if (ispage(log_rec.url)) nptr->tstamp=tstamp; } } } else { /* hashed */ while (cptr != NULL) { if (strcmp(cptr->string,str)==0) { if ((type==cptr->flag)||((type!=OBJ_GRP)&&(cptr->flag!=OBJ_GRP))) { /* found... bump counter */ cptr->count+=count; cptr->files+=file; cptr->xfer +=xfer; if (ispage(log_rec.url)) { if ((tstamp-cptr->tstamp)>=visit_timeout) cptr->visit++; cptr->tstamp=tstamp; } return 0; } } cptr = cptr->next; } /* not found... */ if ( (nptr = new_inode(str)) != NULL) { nptr->flag = type; nptr->count = count; nptr->files = file; nptr->xfer = xfer; nptr->next = htab[hash(str)]; htab[hash(str)]=nptr; if (type!=OBJ_GRP) (*ctr)++; if (visit) { nptr->visit = (visit-1); nptr->tstamp= tstamp; return 0; } else { if (ispage(log_rec.url)) nptr->tstamp= tstamp; } } } if (nptr!=NULL) { /* set object type */ if (type==OBJ_GRP) nptr->flag=OBJ_GRP; /* is it a grouping? */ else { /* check if it's a hidden object */ if (isinlist(hidden_users,nptr->string)!=NULL) nptr->flag=OBJ_HIDE; } } return nptr==NULL; }
int put_hnode( char *str, /* Hostname */ int type, /* obj type */ u_long count, /* hit count */ u_long file, /* File flag */ double xfer, /* xfer size */ u_long *ctr, /* counter */ u_long visit, /* visits */ u_long tstamp,/* timestamp */ char *lasturl, /* lasturl */ HNODEPTR *htab) /* ptr>next */ { HNODEPTR cptr,nptr; /* check if hashed */ if ( (cptr = htab[hash(str)]) == NULL) { /* not hashed */ if ( (nptr=new_hnode(str)) != NULL) { nptr->flag = type; nptr->count = count; nptr->files = file; nptr->xfer = xfer; nptr->next = NULL; htab[hash(str)] = nptr; if (type!=OBJ_GRP) (*ctr)++; if (visit) { nptr->visit=(visit-1); nptr->lasturl=find_url(lasturl); nptr->tstamp=tstamp; return 0; } else { if (ispage(log_rec.url)) { if (htab==sm_htab) update_entry(log_rec.url); nptr->lasturl=find_url(log_rec.url); nptr->tstamp=tstamp; nptr->visit=1; } } } } else { /* hashed */ while (cptr != NULL) { if (strcmp(cptr->string,str)==0) { if ((type==cptr->flag)||((type!=OBJ_GRP)&&(cptr->flag!=OBJ_GRP))) { /* found... bump counter */ cptr->count+=count; cptr->files+=file; cptr->xfer +=xfer; if (ispage(log_rec.url)) { if ((tstamp-cptr->tstamp)>=visit_timeout) { cptr->visit++; if (htab==sm_htab) { update_exit(cptr->lasturl); update_entry(log_rec.url); } } cptr->lasturl=find_url(log_rec.url); cptr->tstamp=tstamp; } return 0; } } cptr = cptr->next; } /* not found... */ if ( (nptr = new_hnode(str)) != NULL) { nptr->flag = type; nptr->count = count; nptr->files = file; nptr->xfer = xfer; nptr->next = htab[hash(str)]; htab[hash(str)]=nptr; if (type!=OBJ_GRP) (*ctr)++; if (visit) { nptr->visit = (visit-1); nptr->lasturl=find_url(lasturl); nptr->tstamp= tstamp; return 0; } else { if (ispage(log_rec.url)) { if (htab==sm_htab) update_entry(log_rec.url); nptr->lasturl=find_url(log_rec.url); nptr->tstamp= tstamp; nptr->visit=1; } } } } if (nptr!=NULL) { /* set object type */ if (type==OBJ_GRP) nptr->flag=OBJ_GRP; /* is it a grouping? */ else { /* check if it's a hidden object */ if ((hide_sites)||(isinlist(hidden_sites,nptr->string)!=NULL)) nptr->flag=OBJ_HIDE; } } return nptr==NULL; }