***** Chem, stats package ***** is procedure stats; procedure summary; procedure showvisitors; procedure visitor_today; procedure visitors; procedure who(host varchar2,tot number); procedure announce(hostname varchar2,name varchar2); procedure special(host varchar2,tot number); procedure by_domain(domain varchar2); procedure by_date(tot number); procedure browser(tot number); owner_uid constant varchar2(10) := MAILS.owner_uid; cgi_bin1 constant varchar2(30) := MAILS.cgi_bin1; cgi_bin constant varchar2(30) := MAILS.cgi_bin; owner_name constant varchar2(20) := MAILS.owner_name; username constant varchar2(10) := owner_uid; password constant varchar2(20) := owner_uid; maxmsg constant number(8) := MAILS.maxmsg; end; ***** Chem, stats package body ***** is procedure summary is total header.id%TYPE; min_time date; now date; today number(5); begin -- wow.capture; select visitors into total from mailbox; select min(visit_time) into min_time from visitor; htp.title('Summary of Vistors Access Information'); htp.p('

Summary of Vistors Access Information

'); htp.p(''); -- wow.show_elapsed; wow.sig; end; procedure browser(tot number) is cursor cbrowser is select substr(REMOTE_USER,1,4),count(*) from visitor group by substr(REMOTE_USER,1,4) order by 2 desc, 1 asc; btype varchar2(10); browser varchar2(100); total header.id%TYPE; begin htp.htitle('Web Browser Types of the User Community'); htp.p(''); wow.sig; end; procedure showvisitors is cursor c_visitor is select visit_time,remote_host,remote_addr from visitor order by visit_time desc; n number(7) := 0; begin select visitors into n from mailbox; htp.htitle('Visitors to this archive system'); htp.p('Total: '||htf.bold(n)); htp.p('

No.........Access Time.....................Remote Host Machine............Remote Machine Address....'); htp.p(htf.line); n := n + 1; for visitor in c_visitor loop htp.p(''||to_char(n - c_visitor%ROWCOUNT)||'.....'||to_char(visitor.visit_time,'hh24:mi mm/dd/yy')||'.....'||visitor.remote_host||'.......'||visitor.remote_addr||'
'); end loop; wow.sig; end; procedure visitor_today is cursor c_visitor is select visit_time,remote_host,REMOTE_USER from visitor where visit_time >=to_date(to_char(sysdate,'ddmmyy'),'ddmmyy') order by visit_time desc; n number(7) := 0; begin select count(*) into n from visitor where visit_time >=to_date(to_char(sysdate,'ddmmyy'),'ddmmyy'); htp.htitle('Today''s Visitors to this archive system'); htp.p('Total: '||htf.bold(n)); htp.p('

No.........Access Time...............Remote Host Machine..................Web Browser....'); htp.p(htf.line); n := n + 1; for visitor in c_visitor loop htp.p(''||to_char(n - c_visitor%ROWCOUNT)||'...'|| to_char(visitor.visit_time,'hh24:mi mm/dd/yy')||'...'|| visitor.remote_host||'......'||substr(visitor.REMOTE_USER,1, instr(visitor.REMOTE_USER,' ',1,2)-1)||'
'); end loop; wow.sig; end; procedure visitors is cursor cvisitor is select remote_host,count(*) from visitor group by remote_host order by 2 desc, 1 asc; total header.id%TYPE; host visitor.remote_host%TYPE; begin select count(distinct remote_host) into total from visitor; htp.htitle('Unique visitors to this archive system'); htp.p('Total: '||htf.bold(total)); htp.p('

Remote Host Machine (Visiting Times)'); htp.p(htf.line); open cvisitor; loop fetch cvisitor into host,total; exit when cvisitor%NOTFOUND; htp.p(''||host||' ('||htf.url(cgi_bin||'stats.who?host='||host||'&tot='||total, htf.bold(total))||')
'); end loop; close cvisitor; wow.sig; end; procedure who(host varchar2,tot number) is cursor c_visitor(ahost varchar2) is select visit_time,REMOTE_USER from visitor where remote_host = ahost order by visit_time desc; n number(7) := 0; address visitor.remote_addr%TYPE; begin n := tot; htp.htitle('Visiting Information from Host ('||host||')'); select remote_addr into address from visitor where remote_host = host and rownum=1; htp.p('Total Visits: '||htf.bold(n)); htp.p('
IP Address: '||htf.bold(address)); htp.p('

No............Access Time..................Web Browser....'); htp.p(htf.line); n := n + 1; for visitor in c_visitor(host) loop htp.p(''||to_char(n - c_visitor%ROWCOUNT)||'.....'|| to_char(visitor.visit_time,'hh24:mi mm/dd/yy')||'.....'|| visitor.REMOTE_USER||'
'); end loop; wow.sig; end; procedure announce(hostname varchar2,name varchar2) is total header.id%TYPE; today number(5); netter varchar2(30); begin select visitors into total from mailbox; select count(*) into today from visitor where visit_time >=to_date(to_char(sysdate,'ddmmyy'),'ddmmyy'); if ((name='unknown') or (name IS NULL)) then netter := 'netter'; else netter := ''||name||''; end if; htp.p('Welcome, '||netter||' from '||hostname||', you are the '|| htf.url(cgi_bin||'stats.visitor_today',htf.bold(today)) ||'''th visitor today (total: '|| htf.url(cgi_bin||'stats.showvisitors',htf.bold(total))||').'); htp.p(' See all '|| htf.url(cgi_bin||'stats.summary','visitors history')||'.'); select count(*) into total from visitor where remote_host=hostname; if (total = 1) then htp.p('It is your first time visiting us, please read our '|| htf.url('/disclaim.html','Disclaimer')||'.'); else htp.p('You visited us '||htf.url(cgi_bin||'stats.who?host='||hostname|| '&tot='||total,total)||' times. '); htp.p(htf.url(cgi_bin||'stats.special?host='||hostname||'&tot='||total,'here')|| ' is a piece of special news customized for '|| htf.url(cgi_bin||'stats.who?host='||hostname|| '&tot='||total,'you')||' !'); end if; htp.p(htf.line); end; procedure special(host varchar2,tot number) is last date; domain varchar2(30); cursor c_visitor(ahost varchar2) is select visit_time from visitor where remote_host = ahost order by visit_time desc; begin MAILS.button; open c_visitor(host); fetch c_visitor into last; fetch c_visitor into last; close c_visitor; htp.p(htf.line); htp.p('

This service is currently under development. '|| 'We will soon provide you with a customized query based on'|| ' the search history of your '||htf.url (cgi_bin||'stats.who?host='||host||'&tot='||tot,'previous visits')); htp.p(' and news items incorporated into the database since your last visit ('|| to_char(new_time(last,'EST','EST'),'dd Mon yyyy hh24:mi')||' EST)' ||' up to now ('||to_char(new_time(sysdate,'EST','EST'), 'dd Mon yyyy hh24:mi')||' EST).'); htp.p('Please watch this space and visit us again.'); -- domain := lower(substr(host,instr(host,'.',-1,2))); domain := lower(substr(host,instr(host,'.',1,1)+1)); htp.p('

For the time being, '||htf.url(cgi_bin||'stats.by_domain?domain='||domain,'this query')|| ' will show you all the newsgroup mails sent by you or your colleagues (*'|| domain||') which are currently archived in the database.'); wow.sig; end; procedure by_domain(domain varchar2) is cursor csender(do varchar2) is select userid,name,email from people where lower(email) like '%'||do order by lower(email); total header.id%TYPE; s_email people.email%TYPE; s_userid people.userid%TYPE; s_name people.name%TYPE; begin MAILS.button; htp.htitle('Query By Sender'); htp.p(htf.line); open csender(domain); fetch csender into s_userid,s_name,s_email; if (csender%NOTFOUND) then htp.p('No sender with domain name ended with '||htf.bold(domain)||' found.'); close csender; wow.sig; return; end if; htp.p('

Choose one from the sender list

'); htp.formOpen(cgi_bin||'MAILS1.by_sender'); htp.p('