diff --git a/contrib/www3proxy/isqlodbc/Makefile.inc b/contrib/www3proxy/isqlodbc/Makefile.inc deleted file mode 100644 index dddfce4..0000000 --- a/contrib/www3proxy/isqlodbc/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -all: isqlodbc$(EXESUFFICS) -clean: - @$(REMOVECOMMAND) *$(OBJSUFFICS) $(COMPFILES) - -isqlodbc$(EXESUFFICS): isqlodbc$(OBJSUFFICS) - $(LN) $(LNOUT)isqlodbc$(EXESUFFICS) $(LDFLAGS) $(VERFILE) isqlodbc$(OBJSUFFICS) $(COMPATLIBS) $(LIBS) \ No newline at end of file diff --git a/contrib/www3proxy/isqlodbc/Makefile.unix b/contrib/www3proxy/isqlodbc/Makefile.unix deleted file mode 100644 index 29e6862..0000000 --- a/contrib/www3proxy/isqlodbc/Makefile.unix +++ /dev/null @@ -1,15 +0,0 @@ -CC = gcc -CFLAGS = -I /usr/local/include -DUNIX -COUT = -o -LN = gcc -LDFLAGS = -LIBS =-L /usr/local/lib -lodbc -LNOUT = -o -EXESUFFICS = -OBJSUFFICS = .o -DEFINEOPTION = -D -COMPFILES = *~ -REMOVECOMMAND = rm -f -COMPATLIBS = - -include Makefile.inc diff --git a/contrib/www3proxy/isqlodbc/Makefile.win b/contrib/www3proxy/isqlodbc/Makefile.win deleted file mode 100644 index ea7ad09..0000000 --- a/contrib/www3proxy/isqlodbc/Makefile.win +++ /dev/null @@ -1,15 +0,0 @@ -CC = gcc -CFLAGS = -DWIN32 -COUT = -o -LN = gcc -LDFLAGS = -LIBS = -lodbc32 -LNOUT = -o -EXESUFFICS = -OBJSUFFICS = .o -DEFINEOPTION = -D -COMPFILES = *~ -REMOVECOMMAND = rm -f -COMPATLIBS = - -include Makefile.inc diff --git a/contrib/www3proxy/isqlodbc/isqlodbc.c b/contrib/www3proxy/isqlodbc/isqlodbc.c deleted file mode 100644 index 7b43c48..0000000 --- a/contrib/www3proxy/isqlodbc/isqlodbc.c +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -#ifdef WIN32 -#include -#include -#endif -#ifdef UNIX -#include -#endif -#include -#include - - - -#define BUF_LENGTH 65000 - -/* environment variable */ -SQLHENV env=NULL; -SQLHDBC dbc=NULL; -SQLHSTMT stmt=NULL; -SQLHSTMT cstmt=NULL; -unsigned char *dsn; -unsigned char *user; -unsigned char *pass; - -RETCODE retcod; - -/*description a columns of result of request */ -SQLSMALLINT ColumnCount; -unsigned int ColNumber; -unsigned char ColName[SQL_MAX_COLUMN_NAME_LEN]; -unsigned int Length; -unsigned int Type; -unsigned int Size; -unsigned int Digits; -unsigned int Nullable; - - -unsigned char data_buf[BUF_LENGTH]; -unsigned long OutData; - -/* function print error message*/ -void PrintError(HENV env,HDBC dbc,HSTMT stmt,RETCODE retcod) -{ - SQLINTEGER nError; - SQLSMALLINT TextLength; - unsigned char BufErrMsg[SQL_MAX_MESSAGE_LENGTH+1]; - unsigned char SqlState[128]; - - SQLError(env,dbc,stmt,SqlState,&nError,BufErrMsg,512, &TextLength); - printf("%s\n" ,BufErrMsg); -} - -void sqlquery(SQLHDBC dbc,SQLHSTMT stmt, unsigned char *strquery) -{ - retcod=SQLAllocStmt(dbc, &stmt); - - retcod=SQLExecDirect(stmt,strquery,SQL_NTS); - if(retcod!=SQL_SUCCESS) - { PrintError(env,dbc,stmt,retcod);} - - SQLNumResultCols(stmt,&ColumnCount); - - while(SQLFetch(stmt)==SQL_SUCCESS) - { - for(ColNumber=1; ColNumber<=ColumnCount ; ColNumber++) - { - SQLGetData(stmt,ColNumber,SQL_CHAR,data_buf,BUF_LENGTH,&OutData); - printf("%s|",data_buf); - } - printf("\n",data_buf); - strcpy(data_buf,""); - } - SQLFreeStmt( stmt, SQL_DROP ); -} - -/* isqlodbc dsn[[,user][,pass]] ["SQLCMD"] */ -int main(int argc, char *argv[]) -{ - unsigned char qbuf[64000]; - unsigned char *ptr=NULL; - - /* Allocate environment and database connection handles */ - retcod=SQLAllocEnv( &env ); - if(retcod!=SQL_SUCCESS) - { - PrintError(env,dbc,stmt,retcod); - SQLFreeEnv(env); - return (-1); - } - retcod = SQLAllocConnect( env, &dbc ); - if(retcod!=SQL_SUCCESS) - { - PrintError(env,dbc,stmt,retcod); - SQLFreeConnect( dbc ); - return (-1); - } - - - if(argc > 1 ) - { - /* parsing command line and get parametrs */ - dsn = strtok(argv[1],","); - user = strtok(NULL, ","); - pass = strtok(NULL, ","); - - /* Connect from DSN */ - retcod=SQLConnect(dbc,dsn,SQL_NTS,user,SQL_NTS,pass,SQL_NTS); - - if(retcod!=SQL_SUCCESS) - { PrintError(env,dbc,stmt,retcod); } - else - { - if (argc > 2) - { - /*sql cmd from command line*/ - sqlquery(dbc,stmt,argv[2]); - } - else - { - /*sql cmd from stdin */ - if( isatty(0) ){ printf(".tables - list table\n.q - exit\nsql>"); } - while(fgets(qbuf,63000,stdin) != NULL ) - { - ptr=strrchr(qbuf,';'); - if (ptr!=NULL) - { - sqlquery(dbc,stmt,qbuf); - } - else - { - /*cmd exit*/ - if (strstr(qbuf,".q")){ break; }; - - /*cmd table list*/ - if (strstr(qbuf,".tables")) - { - retcod=SQLAllocStmt(dbc, &stmt); - if(retcod!=SQL_SUCCESS){ PrintError(env,dbc,stmt,retcod); } - else - { - retcod=SQLTables(stmt,NULL,0,NULL,0,NULL,0,NULL,0); - if(retcod !=SQL_SUCCESS) { PrintError(env,dbc,stmt,retcod);} - while(SQLFetch(stmt)==SQL_SUCCESS) - { - SQLGetData(stmt,3,SQL_CHAR,data_buf,BUF_LENGTH,&OutData); - printf("%s|",data_buf); - - /*list columns */ - retcod=SQLAllocStmt(dbc, &cstmt); - retcod=SQLColumns(cstmt,NULL,0,NULL,0,data_buf,strlen(data_buf),NULL,0); - - if(retcod !=SQL_SUCCESS) { PrintError(env,dbc,stmt,retcod);} - else - { - printf("create table %s (",data_buf); - while(SQLFetch(cstmt)==SQL_SUCCESS) - { - SQLGetData(cstmt,4,SQL_CHAR,data_buf,BUF_LENGTH,&OutData); - printf("%s ",data_buf); - SQLGetData(cstmt,6,SQL_CHAR,data_buf,BUF_LENGTH,&OutData); - printf("%s, ",data_buf); - } - printf(");\n"); - SQLFreeStmt( cstmt, SQL_DROP ); - }/*end list columns*/ - - }/*end while SQLFetch */ - SQLFreeStmt( stmt, SQL_DROP ); - } - - }/*end if (strstr(qbuf,".tables")) */ - - - } /*end else cmd*/ - if( isatty(0) ){ printf("sql>"); } - } /*end while*/ - } - } - SQLDisconnect(dbc); - } /* if (argc > 2) */ - else - { - printf("isqlodbc dsn[[,user][,pass]] [\"SQLCMD\"]\n"); - } - - SQLFreeConnect( dbc ); - SQLFreeEnv( env ); - return 0; -} diff --git a/contrib/www3proxy/log.sql b/contrib/www3proxy/log.sql deleted file mode 100644 index 747b5d1..0000000 --- a/contrib/www3proxy/log.sql +++ /dev/null @@ -1,22 +0,0 @@ - -create table log (ldate date,ltime time,username char (30),userip char (16),bytein integer (10),byteout integer (10),service char (8), host char(255), hostport integer (10), url char (255) ); - -create index idate on log (ldate); -create index iusername on log (username); -create index iuserip on log (userip); -create index ihost on log (host); - -create table services (port integer(10),service char(100),description char (100)); - -INSERT INTO services values (80,'PROXY', 'Access to Web Server'); -INSERT INTO services values (21,'PROXY', 'Access to Ftp Server via HTTP proxy'); -INSERT INTO services values (5190,'PROXY', 'Access to ICQ via HTTP proxy'); -INSERT INTO services values (0, 'POP3P', 'Received Mail via POP3'); -INSERT INTO services values (0,'FTPPR', 'Access to Ftp server via FTP proxy'); -INSERT INTO services values (0,'SOCKS4', 'Access to external server via Socks v4'); -INSERT INTO services values (0,'SOCKS5', 'Access to external server via Socks v5'); -INSERT INTO services values (0,'TCPPM', 'Access to external server via TCP mapping'); -INSERT INTO services values (0,'UDPPM', 'Access to external server via UDP mapping'); -INSERT INTO services values (0, 0, NULL, 'Unknown'); - - diff --git a/contrib/www3proxy/readme.ru b/contrib/www3proxy/readme.ru deleted file mode 100644 index 70013c5..0000000 --- a/contrib/www3proxy/readme.ru +++ /dev/null @@ -1,63 +0,0 @@ ------------------------------- KOI8-R ------------------------------------ - Этот архив содержит набор CGI cкриптов и программ для получения -статистики работы пользователей прокси сервера "3proxy", посредством анализа -лога расположенного в ODBC источнике(базе), через Web интерфейс. - -stat.awk - основной CGI скрипт (Для его испольнения под Win9X/2000 необходима - программа awk.exe ,в linux/freebsd она как правило входит в сиситему - по умолчанию). -isqlodbc - программа для выполнения SQL запросов к базам ODBC - (вызывается из stat.awk). компилируется gcc и работает как в - win9X/2000 так и в linux/freebsd. (Так же может - использоваться независимо от stat.awk как отдельная - программа..) -log.sql - SQL скрипт создания базы для лога сервера. -awk.exe - awk интерпретатор под Win9X/2000. - - Настройка скриптов статистики . - -Для работы вам потребуется: -1) любой http сервер подерживающий CGI -2) odbc менеджер (под win32 ) или iodbc менеджер (под unix) - любая база данных например : sqlite, mysql, postgress или любые другие - имеющие ODBC драйвера.(Как настраивать iODBC под linux/freebsd смотрите в - файле iodbc.txt в каталоге /doc/ru архива 3proxy.) - - Шаг настройки N1: -Создаем базу данных и DSN для хранения лога. ( в нашем случае DSN будет -называться "sqlite".) далее выполняя скрипт log.sql создаем необходимые -таблицы и индексы: - -isqlodbc sqlite < log.sql - - Шаг настройки N2: -Устанавливаем DSN и формат таблицы с логом в файле 3proxy.cfg следующего вида: ------------ -# create table log ( -# ldate date, -# ltime time, -# username char (30), -# userip char (16), -# bytein integer (10), -# byteout integer (10), -# service char (8), -# host char(255), -# hostport integer (10), -# url char (255) -# ); - -log &sqlite -logformat "Linsert into log values ('%Y-%m-%d','%H:%M:%S','%U','%C','%I','%O','%N','%n','%r','%T');" ------------ - - Шаг настройки N3: -Копируем файлы isqlodbc и stat.awk в каталог с CGI скриптами http сервера -и меняем в stat.awk путь вызова и DSN на свои значения , например: -isql="./isqlodbc.exe sqlite " - - Шаг настройки N4: -Пробуем вызвать скрипт из web браузера , например - -http://localhost/cgi/stat.awk? - ------------------------------- KOI8-R ------------------------------------ \ No newline at end of file diff --git a/contrib/www3proxy/stat.awk b/contrib/www3proxy/stat.awk deleted file mode 100644 index b3d3eb2..0000000 --- a/contrib/www3proxy/stat.awk +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/awk -f -BEGIN { - scriptname = ENVIRON["SCRIPT_NAME"] - #for win32 - isql=".\\isqlodbc.exe sqlite " - - #for unix - #isql="./isqlodbc sqlite " - - - print "Content-Type: text/html; charset=koi8-r \n\n" - print "\n\n"; - - # query parse - query_str = ENVIRON["QUERY_STRING"] - n = split(query_str, querys, "&") - for (i=1; i<=n; i++) - { - split(querys[i], data, "=") - qr[data[1]] = data[2] - } - - printf "
" - printf "datefrom: " - printf "dateto:
" - printf " LOGIN user
" - printf " IP user
" - printf "" - printf "" - printf "
" - - - #printf "query_str=%s\n
",query_str - #print qr["rep"] - - if(qr["rep"]=="user") - { - cmd = isql " \"select " qr["userid"] ",sum(bytein),sum(byteout),sum(bytein+byteout) from log \ - where ldate > '" qr["datefrom"] "' AND ldate < '" qr["dateto"] \ - "' group by " qr["userid"] " order by sum(bytein+byteout) desc;\"" - printf " " - while( (cmd|getline result)>0) - { - split(result, rt, "|") - printf "", - scriptname,qr["datefrom"],qr["dateto"],qr["userid"],rt[1],rt[1],rt[2],rt[3],rt[4] - totalbytein=totalbytein+rt[2]; - totalbyteout=totalbyteout+rt[3]; - totalbytesum=totalbytesum+rt[4]; - } - printf " \ -
user bytein byteout bytesum
%s <\/a>%d%d%d

Total users

%d

%d

%d
",totalbytein,totalbyteout, totalbytesum - close(cmd) - } - - - if(qr["rep"]=="host") - { - cmd = isql "\"select sum(bytein+byteout), sum(bytein), sum(byteout),host from log \ - where ldate > '" qr["datefrom"] "' AND ldate < '"qr["dateto"] \ - "' AND " qr["userid"] " = '" qr["selectid"] \ - "' group by host order by sum(bytein+byteout) desc;\"" - - printf "
Detail statistic for user: %s
",qr["selectid"] - printf " " - while( (cmd|getline result)>0) - { - split(result, rt, "|") - printf "",rt[1],rt[2],rt[3],rt[4] - totalbytein=totalbytein+rt[1]; - totalbyteout=totalbyteout+rt[2]; - totalbytesum=totalbytesum+rt[3]; - - } - printf " \ -
sum byte bytein byteouthost
%d%d%d%s

%d

%d

%d

Total host
",totalbytein,totalbyteout, totalbytesum - printf " " - close(cmd) - - } - - printf " "; -} # end BEGIN - - -# decode urlencoded string -function decode(text, hex, i, hextab, decoded, len, c, c1, c2, code) { - - split("0 1 2 3 4 5 6 7 8 9 a b c d e f", hex, " ") - for (i=0; i<16; i++) hextab[hex[i+1]] = i - - # urldecode function from Heiner Steven - # http://www.shelldorado.com/scripts/cmds/urldecode - - # decode %xx to ASCII char - decoded = "" - i = 1 - len = length(text) - - while ( i <= len ) { - c = substr (text, i, 1) - if ( c == "%" ) - { - if ( i+2 <= len ) - { - c1 = tolower(substr(text, i+1, 1)) - c2 = tolower(substr(text, i+2, 1)) - if ( hextab [c1] != "" || hextab [c2] != "" ) { - if ( (c1 >= 2 && (c1 != 7 && c2 != "F")) || (c1 == 0 && c2 ~ "[9acd]") ) - { - code = 0 + hextab [c1] * 16 + hextab [c2] + 0 - c = sprintf ("%c", code) - } - else { c = " " } - i = i + 2 - } - } - } else if ( c == "+" ) { # special handling: "+" means " " - c = " " - } - decoded = decoded c - ++i - } - # change linebreaks to \n - gsub(/\r\n/, "\n", decoded) - # remove last linebreak - sub(/[\n\r]*$/,"",decoded) - return decoded -} diff --git a/contrib/www3proxy/stat.pl b/contrib/www3proxy/stat.pl deleted file mode 100644 index 87c6b7c..0000000 --- a/contrib/www3proxy/stat.pl +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/perl -eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - # this emulates #! processing on NIH machines. - # (remove #! line above if indigestible) - -eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; - # process any FOO=bar switches - -$[ = 1; # set array base to 1 -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator - -$scriptname = $ENVIRON{'SCRIPT_NAME'}; -#for win32 -$isql = ".\\isqlodbc.exe sqlite "; - -#for unix -#isql="./isqlodbc sqlite " - -print "Content-Type: text/html; charset=koi8-r \n\n"; -print "\n\n"; - -# query parse -$query_str = $ENVIRON{'QUERY_STRING'}; -$n = (@querys = split(/&/, $query_str, 9999)); -for ($i = 1; $i <= $n; $i++) { - @data = split(/=/, $querys[$i], 9999); - $qr{$data[1]} = $data[2]; -} - -printf "
"; -printf "datefrom: "; -printf "dateto:
"; -printf - - " LOGIN user
"; -printf - - " IP user
"; -printf ""; -printf ""; -printf '
'; - -#printf "query_str=%s\n
",query_str -#print qr["rep"] - -if ($qr{'rep'} eq 'user') { - $cmd = $isql . " \"select " . $qr{'userid'} . - - ",sum(bytein),sum(byteout),sum(bytein+byteout) from log where ldate > '" - - . $qr{'datefrom'} . "' AND ldate < '" . $qr{'dateto'} . "' group by " . - - $qr{'userid'} . " order by sum(bytein+byteout) desc;\""; - printf - - ' '; - while ((($result = &Getline3($cmd, '|'),$getline_ok)) > 0) { - @rt = split(/\|/, $result, 9999); - printf - - "", - - - $scriptname, $qr{'datefrom'}, $qr{'dateto'}, $qr{'userid'}, $rt[1], - - $rt[1], $rt[2], $rt[3], $rt[4]; - $totalbytein = $totalbytein + $rt[2]; - $totalbyteout = $totalbyteout + $rt[3]; - $totalbytesum = $totalbytesum + $rt[4]; - } - printf - - '
user bytein byteout bytesum
%s <\\/a>%d%d%d

Total users

%d

%d

%d
', - - $totalbytein, $totalbyteout, $totalbytesum; - delete $opened{$cmd} && close($cmd); -} - -if ($qr{'rep'} eq 'host') { - $cmd = $isql . - - "\"select sum(bytein+byteout), sum(bytein), sum(byteout),host from log where ldate > '" - - . $qr{'datefrom'} . "' AND ldate < '" . $qr{'dateto'} . "' AND " . - - $qr{'userid'} . " = '" . $qr{'selectid'} . - - "' group by host order by sum(bytein+byteout) desc;\""; - - printf '
Detail statistic for user: %s
', - - $qr{'selectid'}; - printf - - ' '; - while ((($result = &Getline3($cmd, '|'),$getline_ok)) > 0) { - @rt = split(/\|/, $result, 9999); - printf '', - - $rt[1], $rt[2], $rt[3], $rt[4]; - $totalbytein = $totalbytein + $rt[1]; - $totalbyteout = $totalbyteout + $rt[2]; - $totalbytesum = $totalbytesum + $rt[3]; - } - printf - - '
sum byte bytein byteouthost
%d%d%d%s

%d

%d

%d

Total host
', - - $totalbytein, $totalbyteout, $totalbytesum; - printf ' '; - delete $opened{$cmd} && close($cmd); -} - -printf ' '; - -# end BEGIN - -# decode urlencoded string - -sub decode { - local($text, *Hex, $i, *hextab, $decoded, $len, $c, $c1, $c2, $code) = @_; - @Hex = split(' ', '0 1 2 3 4 5 6 7 8 9 a b c d e f', 9999); - for ($i = 0; $i < 16; $i++) { - $hextab{$Hex[$i + 1]} = $i; - - # urldecode function from Heiner Steven - # http://www.shelldorado.com/scripts/cmds/urldecode - - # decode %xx to ASCII char - ; - } - $decoded = ''; - $i = 1; - $len = length($text); - - while ($i <= $len) { #??? - $c = substr($text, $i, 1); - if ($c eq '%') { - if ($i + 2 <= $len) { - $c1 = &tolower(substr($text, $i + 1, 1)); - $c2 = &tolower(substr($text, $i + 2, 1)); - if ($hextab{$c1} ne '' || $hextab{$c2} ne '') { - if (($c1 >= 2 && ($c1 != 7 && $c2 ne 'F')) || - - ($c1 == 0 && $c2 =~ '[9acd]')) { - $code = 0 + $hextab{$c1} * 16 + $hextab{$c2} + 0; - $c = sprintf('%c', $code); - } - else { - $c = ' '; - } - $i = $i + 2; - } - } - } - elsif ($c eq '+') { - # special handling: "+" means " " - $c = ' '; - } - $decoded = $decoded . $c; - ++$i; - } - # change linebreaks to \n - $decoded =~ s/\r\n/\n/g; - # remove last linebreak - $decoded =~ s/[\n\r]*$//; - $decoded; -} - -sub Getline3 { - &Pick('',@_); - local($_); - if ($getline_ok = (($_ = <$fh>) ne '')) { - ; - } - $_; -} - -sub Pick { - local($mode,$name,$pipe) = @_; - $fh = $name; - open($name,$mode.$name.$pipe) unless $opened{$name}++; -}