Index: openacs-4/packages/tracker/sql/oracle/tracker-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/oracle/tracker-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/oracle/tracker-create.sql 16 May 2007 09:20:27 -0000 1.1 @@ -0,0 +1,20 @@ +-- +-- Copyright (C) 2004, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author Felix Hernandez del Olmo (felixh@dia.uned.es) +-- +-- @date 05/04/2004 +-- + +@ tracker-tracker-create.sql +@ tracker-package-create.sql + + Index: openacs-4/packages/tracker/sql/oracle/tracker-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/oracle/tracker-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/oracle/tracker-drop.sql 16 May 2007 09:20:27 -0000 1.1 @@ -0,0 +1,24 @@ +-- +-- Copyright (C) 2007, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author David Arroyo Menéndez (darroyo@innova.uned.es) +-- @author Mario Aguado Castro (maguado@innova.uned.es) +-- +-- @date 10/04/2007 +-- + +drop package tracker; + +drop table tracker_parameters; +drop table tracker_visits; +drop sequence sec_visits; +drop table tracker_sessions; + Index: openacs-4/packages/tracker/sql/oracle/tracker-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/oracle/tracker-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/oracle/tracker-package-create.sql 16 May 2007 09:20:27 -0000 1.1 @@ -0,0 +1,81 @@ +-- +-- Copyright (C) 2007, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author David Arroyo Menéndez (darroyo@innova.uned.es) +-- +-- @date 27/03/2007 +-- + +create or replace package tracker +as + + procedure new ( + p_session_id in tracker_sessions.session_id%TYPE, + p_user_id in tracker_sessions.user_id%TYPE, + p_ip in tracker_sessions.ip%TYPE default null, + p_ip_reverse in tracker_sessions.ip_reverse%TYPE default null, + p_user_agent in tracker_sessions.user_agent%TYPE default null + ); + + function visit ( + p_user_id in tracker_visits.user_id%TYPE, + p_url in tracker_visits.url%TYPE default null, + p_page_type in tracker_visits.page_type%TYPE default null, + p_request in tracker_visits.request%TYPE default null, + p_session_id in tracker_visits.session_id%TYPE, + p_object_id in tracker_visits.object_id%TYPE + ) return tracker_visits.visit_id%TYPE; + +end tracker; +/ +show errors + + + +create or replace package body tracker +as + + procedure new ( + p_session_id in tracker_sessions.session_id%TYPE, + p_user_id in tracker_sessions.user_id%TYPE, + p_ip in tracker_sessions.ip%TYPE default null, + p_ip_reverse in tracker_sessions.ip_reverse%TYPE default null, + p_user_agent in tracker_sessions.user_agent%TYPE default null + ) + is + v_session_temp tracker_sessions.session_id%TYPE; + begin + select count(session_id) into v_session_temp from tracker_sessions where session_id=p_session_id and user_id=p_user_id; + if v_session_temp = 0 then + insert into tracker_sessions values(p_session_id,p_user_id,p_ip,p_ip_reverse,p_user_agent); + end if; + end new; + + function visit ( + p_user_id in tracker_visits.user_id%TYPE, + p_url in tracker_visits.url%TYPE default null, + p_page_type in tracker_visits.page_type%TYPE default null, + p_request in tracker_visits.request%TYPE default null, + p_session_id in tracker_visits.session_id%TYPE, + p_object_id in tracker_visits.object_id%TYPE + ) return tracker_visits.visit_id%TYPE + is + v_visit_id tracker_visits.visit_id%TYPE; + begin + select sec_visits.nextval into v_visit_id from dual; + insert into tracker_visits values (v_visit_id,sysdate,p_url,p_page_type,p_request,p_session_id,p_user_id,p_object_id); + return v_visit_id; + end visit; + +end tracker; +/ +show errors + Index: openacs-4/packages/tracker/sql/oracle/tracker-tracker-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/oracle/tracker-tracker-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/oracle/tracker-tracker-create.sql 16 May 2007 09:20:27 -0000 1.1 @@ -0,0 +1,52 @@ +-- +-- Copyright (C) 2007, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author David Arroyo Menéndez (darroyo@innova.uned.es) +-- +-- @date 28/03/2007 +-- + +create table tracker_sessions ( + session_id integer, + user_id integer constraint tracker_user_id_fk references users(user_id) + on delete cascade, + ip varchar2(255), + ip_reverse varchar2(255), + user_agent varchar2(255), + constraint tracker_session_pk primary key (session_id,user_id) +); + +create table tracker_visits ( + visit_id integer constraint tracker_visits_pk primary key, + visit_date date, + url varchar2(255), + page_type char(1) default('d') check(page_type in ('d','s')), + request integer, + session_id integer, + user_id integer constraint tracker_v_user_id_fk references users(user_id) on delete cascade, + object_id integer constraint tracker_v_object_id_fk references acs_objects(object_id) on delete cascade +); + +create index tracker_visits_url_idx on tracker_visits (url); +create index tracker_visits_date_idx on tracker_visits (visit_date); + +create sequence sec_visits start with 1; + +create table tracker_parameters ( + visit_id integer references tracker_visits(visit_id) on delete cascade, + name varchar2(255), + value CLOB, + constraint tracker_parameter_pk primary key (visit_id, name) +); + + + + Index: openacs-4/packages/tracker/sql/postgresql/tracker-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/postgresql/tracker-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/postgresql/tracker-create.sql 16 May 2007 09:22:06 -0000 1.1 @@ -0,0 +1,80 @@ +-- +-- Copyright (C) 2004, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author Felix Hernandez del Olmo (felixh@dia.uned.es) +-- +-- @date 05/04/2004 +-- + +create table tracker_sessions ( + session_id integer, + user_id integer references users(user_id) on delete cascade, + ip varchar, + ip_reverse varchar, + user_agent varchar, + primary key (session_id,user_id) +); + +create or replace function tracker_session__new (integer,integer,varchar,varchar,varchar) +returns integer as ' +declare + p_session_id alias for $1; + p_user_id alias for $2; + p_ip alias for $3; + p_ip_reverse alias for $4; + p_user_agent alias for $5; + v_session_temp integer; +begin + select session_id into v_session_temp from tracker_sessions where session_id=p_session_id and user_id=p_user_id; + if v_session_temp is null then + insert into tracker_sessions values(p_session_id,p_user_id,p_ip,p_ip_reverse,p_user_agent); + end if; + return 0; +end;' language 'plpgsql'; + +create table tracker_visits ( + visit_id integer primary key, --integer references acs_objects(object_id) primary key, + visit_date timestamp, + url varchar, + page_type char(1) default('d') check(page_type in ('d','s')), + request integer, + session_id integer, --references tracker_sessions(session_id) on delete cascade, + user_id integer references users(user_id) on delete cascade, + object_id integer references acs_objects(object_id) on delete cascade +); + +create index tracker_visits_url_index on tracker_visits (url); +create index tracker_visits_date_index on tracker_visits (visit_date); + +create sequence sec_visits; + +create table tracker_parameters ( + visit_id integer primary key references tracker_visits(visit_id) on delete cascade, + name varchar, + value varchar +); + +create or replace function tracker_visit__new(integer,varchar,char,integer,integer,integer,integer) +returns integer as ' +declare + user_id alias for $1; + url alias for $2; + page_type alias for $3; + request alias for $4; + session_id alias for $5; + object_id alias for $6; + visit_id integer; +begin + visit_id := nextval(''sec_visits''); + insert into tracker_visits values (visit_id,now(),url,page_type,request,session_id,user_id,object_id); + return visit_id; +end;' language 'plpgsql'; + Index: openacs-4/packages/tracker/sql/postgresql/tracker-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/postgresql/tracker-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/postgresql/tracker-drop.sql 16 May 2007 09:22:06 -0000 1.1 @@ -0,0 +1,23 @@ +-- +-- Copyright (C) 2004, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author Felix Hernandez (felixh@dia.uned.es) +-- +-- @date 05/04/2004 +-- + + +drop table tracker_sessions cascade; +drop function tracker_session__new(integer,integer,varchar,varchar,varchar); +drop table tracker_parameters; +drop table tracker_visits; +drop sequence sec_visits; +drop function tracker_visit__new(integer,varchar,char,integer,integer,integer); Index: openacs-4/packages/tracker/sql/postgresql/tracker-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/postgresql/tracker-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/postgresql/tracker-package-create.sql 16 May 2007 09:22:06 -0000 1.1 @@ -0,0 +1,51 @@ +-- +-- Copyright (C) 2004, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author Felix Hernandez del Olmo (felixh@dia.uned.es) +-- +-- @date 05/04/2004 +-- + + +create or replace function tracker_session__new (integer,integer,varchar,varchar,varchar) +returns integer as ' +declare + p_session_id alias for $1; + p_user_id alias for $2; + p_ip alias for $3; + p_ip_reverse alias for $4; + p_user_agent alias for $5; + v_session_temp integer; +begin + select session_id into v_session_temp from tracker_sessions where session_id=p_session_id and user_id=p_user_id; + if v_session_temp is null then + insert into tracker_sessions values(p_session_id,p_user_id,p_ip,p_ip_reverse,p_user_agent); + end if; + return 0; +end;' language 'plpgsql'; + + +create or replace function tracker_visit__new(integer,varchar,char,integer,integer,integer,integer) +returns integer as ' +declare + user_id alias for $1; + url alias for $2; + page_type alias for $3; + request alias for $4; + session_id alias for $5; + object_id alias for $6; + visit_id integer; +begin + visit_id := nextval(''sec_visits''); + insert into tracker_visits values (visit_id,now(),url,page_type,request,session_id,user_id,object_id); + return visit_id; +end;' language 'plpgsql'; + Index: openacs-4/packages/tracker/sql/postgresql/tracker-tracker-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/sql/postgresql/tracker-tracker-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/sql/postgresql/tracker-tracker-create.sql 16 May 2007 09:22:06 -0000 1.1 @@ -0,0 +1,49 @@ +-- +-- Copyright (C) 2004, +-- +-- This file is part of "tracker" package. +-- +-- "tracker" is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +-- details. +-- +-- +-- @author Felix Hernandez del Olmo (felixh@dia.uned.es) +-- +-- @date 05/04/2004 +-- + +create table tracker_sessions ( + session_id integer, + user_id integer references users(user_id) on delete cascade, + ip varchar, + ip_reverse varchar, + user_agent varchar, + primary key (session_id,user_id) +); + + +create table tracker_visits ( + visit_id integer primary key, --integer references acs_objects(object_id) primary key, + visit_date timestamp, + url varchar, + page_type char(1) default('d') check(page_type in ('d','s')), + request integer, + session_id integer, --references tracker_sessions(session_id) on delete cascade, + user_id integer references users(user_id) on delete cascade, + object_id integer references acs_objects(object_id) on delete cascade +); + +create index tracker_visits_url_index on tracker_visits (url); +create index tracker_visits_date_index on tracker_visits (visit_date); + +create sequence sec_visits; + +create table tracker_parameters ( + visit_id integer references tracker_visits(visit_id) on delete cascade, + name varchar, + value varchar, + primary key (visit_id, name) +); + Index: openacs-4/packages/tracker/tcl/tracker-main-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/tcl/tracker-main-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/tcl/tracker-main-procs-oracle.xql 16 May 2007 09:25:37 -0000 1.1 @@ -0,0 +1,28 @@ + + + + oracle8.1.6 + + + + begin + :1 := tracker.visit(:user_id,:url,:page_type,:request,:session_id,:package_id); + end; + + + + + + begin + tracker.new(:session_id,:user_id,:peeraddr,:host,:user_agent); + end; + + + + + + insert into tracker_parameters values(:visit_id,:v,:var) + + + + \ No newline at end of file Index: openacs-4/packages/tracker/tcl/tracker-main-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/tcl/tracker-main-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/tcl/tracker-main-procs-postgresql.xql 16 May 2007 09:25:37 -0000 1.1 @@ -0,0 +1,24 @@ + + + + postgresql7.1 + + + + select tracker_visit__new(:user_id,:url,:page_type,65,:session_id,:package_id); + + + + + + select tracker_session__new(:session_id,:user_id,:peeraddr,:host,:user_agent); + + + + + + insert into tracker_parameters values(:visit_id,:v,:var) + + + + Index: openacs-4/packages/tracker/tcl/tracker-main-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/tcl/tracker-main-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/tcl/tracker-main-procs.tcl 16 May 2007 09:25:37 -0000 1.1 @@ -0,0 +1,80 @@ +ad_library { + Traker libraries + + @author Felix Hernandez del Olmo + @date 04/04/2004 +} + + +ad_proc -public tr_another_visit { page_type parameters } { + Procedure which handles calls to \"ad_page_contract\" from tcl's. + It takes a list of \{variable value\} list which correspond with tcls' parameters. + Here page_type is set to \"dynamic\" + + It takes control of static pages also. Then page_type is set to \"static\" +} { + + set session_id [ad_conn session_id] + set user_id [ad_conn user_id] + set url [ad_conn url] + set page_type [string range $page_type 0 0] + set request [ad_conn request] + set package_id [ad_conn object_id] + if { [db_0or1row q "select 1 from tracker_sessions where session_id= :session_id and user_id= :user_id"] } { + #Next + set request [ad_conn request] + set visit_id [db_exec_plsql insert_visit {}] + } else { + #Create new session + set peeraddr [ad_conn peeraddr] + with_catch error { + set host [ns_hostbyaddr $peeraddr] + } { + set host "no accesible" + } + db_transaction { + set user_agent [ns_set get [ad_conn header] User-Agent] + db_exec_plsql insert_session {} + set visit_id [db_exec_plsql insert_visit {}] + } + } + + #Si la pagina es dinamica genera las filas de parametros + if {$page_type == "d"} { + foreach v $parameters { + upvar 2 $v value + if [info exists value] { + if [array exists value] { + set vars [array names value] + foreach v1 $vars { + set var [array get value $v1] + if {$var != ""} { + set v "$v:$v1" + db_dml insert_parameters {} + } + } + } else { + if {$value != ""} { + set var $value + db_dml insert_parameters {} + } + } + } + } + } + +} + +# static HTML filters +ad_proc -private tr_trace_static_page { conn why } { + Procedure that handles calls from html filters. +} { + tr_another_visit static {} + return filter_ok +} + +if {[info exist tr_only_once] == 0} { + ad_register_filter trace * *.html tr_trace_static_page + ad_register_filter trace * *.htm tr_trace_static_page + set tr_only_once 1 +} Index: openacs-4/packages/tracker/tcl/tracker-main-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/tcl/tracker-main-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/tcl/tracker-main-procs.xql 16 May 2007 09:25:37 -0000 1.1 @@ -0,0 +1,11 @@ + + + + + + insert into tracker_parameters values(:visit_id,:v,:var); + commit; + + + + \ No newline at end of file Index: openacs-4/packages/tracker/www/index-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/www/index-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/www/index-oracle.xql 16 May 2007 09:27:29 -0000 1.1 @@ -0,0 +1,14 @@ + + + + oracle8.1.6 + + + + select distinct person_id as user_id, first_names, last_name + from persons, tracker_visits + where person_id=user_id and rownum<=10 + + + + Index: openacs-4/packages/tracker/www/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/www/index-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/www/index-postgresql.xql 16 May 2007 09:27:29 -0000 1.1 @@ -0,0 +1,13 @@ + + + + postgresql7.1 + + + + select distinct person_id as user_id, first_names, last_name + from persons inner join tracker_visits on(person_id=user_id) limit 10 + + + + Index: openacs-4/packages/tracker/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/www/index.adp 16 May 2007 09:27:29 -0000 1.1 @@ -0,0 +1,11 @@ + + + +
+ + Index: openacs-4/packages/tracker/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/tracker/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/tracker/www/index.tcl 16 May 2007 09:27:29 -0000 1.1 @@ -0,0 +1,13 @@ +ad_page_contract { + Page for viewing tracker working + + @author Felix Hernandez (felixh@dia.uned.es) +} { } + + +template::query select_users users multirow {} + + + + +