From: kkalev Date: Tue, 15 Jan 2002 14:45:21 +0000 (+0000) Subject: Add the dialup_admin web interface. Hope everything works fine X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=cb9137cf600b7f57bd9028b185c5a3fd0e765316;p=freeradius-dialup-admin.git Add the dialup_admin web interface. Hope everything works fine --- cb9137cf600b7f57bd9028b185c5a3fd0e765316 diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..1b087e4 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,14 @@ +Kostas Kalevras: kkalev@noc.ntua.gr +Main developper + +Vasilis Pappas: vpappas@noc.ntua.gr +parts of user_edit and user_admin + +Thanasis Duitsis: aduitsis@noc.ntua.gr +Part of accounting report generator + +Panagiotis Christias: christia@noc.ntua.gr +HTML pages layout designer + +Dragan Milivojevic: galileo@MICROSKY.NET +A number of bug reports and a lot of crash testing diff --git a/Changelog b/Changelog new file mode 100644 index 0000000..11de3f0 --- /dev/null +++ b/Changelog @@ -0,0 +1,130 @@ +Ver 1.28: +* Make user_delete.php3 print something when a user is deleted +* Cache nas hostname lookups in user_accounting +Ver 1.27: +* Allow for variable expansion in the configuration file. Something like: + general_base_dir: /usr/local/dialup_admin + general_default_file: %{general_base_dir}/conf/default.vals +* Small changes in the README file +* A few corrections in the sql drivers +* Enlarged the textboxes in the user_edit page +* Created a folder help +* Added a help page for: + o Login-Time + o Simultaneous-Use + o Dialup-Access + o Framed-Compression + o Port-Limit + o Lock Message + o Framed-IP-Address +Ver 1.26: +* A few bugfixes for the general sql code (typo mistakes mostly) +Ver 1.25: +* Deleted a mysql_close from lib/mysql/create_user since we now have persistent sql connections +* Removed the select_db() from accounting.php3 since it is not needed +* A lot of html changes in accounting.php3 +* Changed the sql code to be modular. Now under lib we don't have a mysql directory but a sql directory + with a directory drivers which contains the database specific functions. As a result all calls to mysql* + functions where changed to call da_sql* functions. Right now mysql should work and postgresql *may* work + It is not tested though. Hopefully things will come back to being stable in a few days. +* Added sql_port and sql_type configuration file directives +Ver 1.20: +* Fixed a bug in lib/ldap/change_attrs. When we modify an attribute do an ldap_mod_del($mod) and then a + ldap_mod_add($add_r) +* In accounting.php3 show the attribute description instead of the attribute name. +Ver 1.19: +* In lib/ldap/check_password.php3 don't do a user search but use the already available user DN +* Remove the language support from the get_user_info() functions. They are only used in the user_finger page +* In user_state show weekly usage for the week starting from sunday 00:00, not for the last 7 days +* Show upload/download when connected or for the last time the user connected +* Fixed a few minor problems with the help and about pages +Ver 1.18: +* Fixed a small problem with total upload,download numbers in user_admin +* Fixed a major problem in the accounting report generator when adding an attribute check. Now it + should be all OK. +* Fixed a small bug in lib/mysql/functions.php3. Bug found be galileo@microsky.net +Ver 1.17: +* Fixed a few more problems in the mysql code +* Updated README +* the help page now prints the README file. It also has a common layout with the other pages +* Changed the about page to have a common look with the other pages. +Ver 1.16: +* Fixed a few typing mistakes in mysql.attrmap +* If the corresponding attribute name (in ldap or mysql) is 'none' then do not + edit/add it. Based on a bug report by galileo@microsky.net +* Fixed a few errors in lib/attrshow.php3 +Ver 1.15: +* Added user test page. It will use radclient to send a radius access-request + to the radius server and check the response. This page is also used to check + that the radius server is working fine. Added user_test.php3 and a few config + file parameters. +* Support for multi valued attributes. +* Changed cleartext encryption name from none to clear +* Renamed the general_sql_row_limit configuration directive to sql_row_limit +Ver 1.12: +* Added an FAQ +* Small changes in html code +* Small changes in the README file +* Fixed a small problem in delete_user from ldap +* Removed the Base64 encode since it was causing problems +Ver 1.11: +* Changed all ldap_bind() to use the ldap bind DN and password. Should have been + the default behaviour +* Do a Base64 encode in ldap/change_password.php3 before sending the password to + the ldap server +* Added support for module messages in log_badlogins and user_accounting +* Updated documentation +Ver 1.10: +* Added support for users in mysql database. All bugs are welcome. To activate + just use mysql as library_type +* Added support for salt in crypt.php3 +* Added userinfo table to keep information for users (Name,Phone etc). Added two + corresponding values in admin.conf +* Added mysql.attrmap for mysql support +* Added TODO +* Added persistent connections for mysql (mysql_pconnect()) +Ver 1.00: +* Added password change facility in user_edit. Support for multiple + password encryption methods +* Added user deletion page user_delete.php3 with corresponding ldap lib code +* Moved the second user_info.php3 include in user_edit to the correct location. Also + used isset instead of == '' +* Moved the action toolbar (show,edit,accounting...) into a separate html file +* Added the nas model in user_finger.php3 +Ver 0.99.8: +* Added the caller id in the finger facility +* Changed the start date in the badusers file to 0000 +* Added the out of quota message in user_admin +* fixed a few problems with the html code in user_admin.php3 +* calculate account status in user_admin for the last week only +* Change font color to red if used time > corresponding limit (weekly or daily) +* Added the user_stats.php3. It can be used by outside pages to get a quick + overview of the status of the user. It will return the following fields + separated by new lines: + account_status(active or inactive),lock message,weekly limit,daily limit, + weekly used,weekly connections,daily used,daily connections +* fixed a bug in the subscription analysis in user_admin.php3 +* calculate weekly used from sunday 00:00:00 when the counters reset +* added clean_radacct which will clean radacct entries which have been open + for more than a day. It will not do any harm even if it is incorrect since + when rlm_sql runs if the update operation fails then it will fall back to + insert (see sql.conf) +* added log_badlogins. It will continuously read the radius.log file and log + to the radacct table all login incorrect and multiple logins with a + corresponding acctterminatecause. user_accounting.php3 is already prepared + for this (it will show those entries in red) +* fix a small bug with null values in change_vals.php3 of the ldap lib +Ver 0.99: +* Added the badusers table +* Added the default and regular profile from ldap for user_edit +* Added the snmpfinger in the finger facility so that it will not + relly on the sql database. +* Added the new user facility +* Added support for the Lock Message facility +* Various bug fixes and enhancements + +Ver 0.31: +* Added the @ sign in the {mysql,ldap}_{open,close} functions so that + they don't show error messages +* Changed double quotes with single quotes where applicable for performance + reasons diff --git a/FAQ b/FAQ new file mode 100644 index 0000000..842c71a --- /dev/null +++ b/FAQ @@ -0,0 +1,28 @@ +> I was wondering if there is any more documentation about howto setup this +> software other than what comes in the README? + +No, there isn't. It's easier for me to write code than to document it :-) +Anyway, I always try to make better documentation. +There's also this FAQ :-) + +> +> What tables do I need to create in the MySQL database? + +It depends. +If you are using ldap for user authentication/information then you only need +to create the freeradius sql tables (in order to create the radacct table, +the other tables will just sit around doing nothing) which can be created from a +sql script in the freeradius distribution. If you are runing mysql it is in +src/modules/rlm_sql/drivers/rlm_sql_mysql/db_mysql.sql + +If you are using mysql for user authentication/information then you will again +need to create the freeradius sql tables and if you want you could also create +the userinfo table to store user information (name,telephone etc) + +You could also create the badusers table if you want the functionality it provides. + +sql scripts to create the badusers and userinfo tables can be found in the +directory sql (of dialup_admin distribution). + +-- +kkalev diff --git a/README b/README new file mode 100644 index 0000000..5f104c4 --- /dev/null +++ b/README @@ -0,0 +1,85 @@ +dialup_admin is a web based administration interface for the freeradius radius server. +It is modular and right now it assumes that user information is stored in an ldap server +or an sql database and accounting in an sql server. + +There are also a few more things included: + +* sql/badusers.sql: It will create a table named badusers which can be used to hold the + history for badusers (date,action) +* sql/userinfo.sql: It will create a table named userinfo which contains personal information + for users stored in the sql database. This can be used if a sql database is used to store user profiles + (not ldap). +* bin/log_badlogins: It will constantly check the radiusd.log file and add all login-incorrect, + invalid-user, outside of allowed login time and multiple-login cases to the radacct table with + acctstarttime=acctstoptime, acctsessiontime=0 and acctterminatecause containing the reason. + If the failing module sent back a module message then it will also appear in the terminate cause. +* bin/clean_radacct: It will delete all entries in the radacct table with a starttime > 1 day and + stoptime = 0. It will not do an harm even if it deletes valid entries since radiusd will fall + back to insert if update fails. + +The structure of the tree is: + +conf:: Contains various configuration files. +conf::admin.conf=> + The main configuration file. The directives used should be easily + understood +conf::config.php3=> + Just a helper php4 for reading the admin.conf file. Just make sure that it + opens the correct admin.conf file +conf::default.vals=> + Contains the default values for check and reply items. If you also use the users + file except for the ldap/sql databases fill in the default values you have inserted + for the users.Else comment them out. +conf::sql.attrs=> + Contains inmformation about the sql attributes. This is used by the accounting + report generator (accounting.php3). +conf::user_edit.attrs=> + Contains the attributes that user_edit.php3 will show. Just uncomment those + which you want to be displayed. +conf::extra.ldap-attrmap=> + Contains a few items not included in ldap.attrmap which are used only by dialup_admin + Things like User-Password and Dialup-Lock-Msg. Use none for attributes that are not known + by the radius or ldap server. +conf::sql.attrmap=> + Contains the Attribute map for the sql database. Use none for attributes that are not known by + the radius server. +conf::auth.request=> + Contains value pairs sent in the test packets which are sent from the test user/server pages. + +htdocs:: Contains the basic php files +htdocs::index.html=> + The main index file. Just contains the frames tags +htdocs::content.html=> + Change this file to include the greeting of your choise +htdocs::buttons.html=> + The buttons html page +htdocs::style.css=> + CSS style file. Change it to match your preferences +htdocs:: user_state.php3 => + It can be used by outside pages to get a quick + overview of the status of a user. It will return the following fields + separated by new lines: + account_status(active or inactive),lock message,weekly limit,daily limit, + weekly used,weekly connections,daily used,daily connections + +html:: Contains the html code for a few pages +html::user_admin.html.php3 => + html code for the user_admin page +html::stats.html.php3 => + html code for the stats page +html::user_toolbar.html.php3 => + the user toolbar (show,edit,accounting...) which appears in almost all pages + +lib:: Contains the library items +lib::ldap=> + The ldap files +lib::lang=> + Allow for multiple languages to be supported +lib::crypt=> + Allow for multiple encryption schemes (for user passwords) +lib::sql=> + Contains the sql library files. There is also a directory drivers + which contains functions for various sql databases (mysql and + postgresql for the time being). + +The rest: The rest are the php4 files. Normally, you should not need to change anything in them. diff --git a/TODO b/TODO new file mode 100644 index 0000000..90e6b00 --- /dev/null +++ b/TODO @@ -0,0 +1,12 @@ +* Minimize database (ldap,mysql) connections. +* Clean up html code to make it smaller +* More messages +* Skins +* Other languages in html +* Multilanguage support for ldap attributes +* Add language attributes in user_new.php3 +* Finger facility. Should find a way to make it work with all nases. That will + mean that it should be made modular and fall back to simple queries to the + sql db if it cannot get user info from the nas server +* Check out dbx library. It seems very promising for database independent code. + We 'll see where it goes. diff --git a/bin/clean_radacct b/bin/clean_radacct new file mode 100755 index 0000000..e3652f1 --- /dev/null +++ b/bin/clean_radacct @@ -0,0 +1,26 @@ +#!/usr/bin/perl +use DBI; +use POSIX; + +$conf=shift||'/usr/local/dialup_admin/conf/admin.conf'; + +open CONF, "<$conf" + or die "Could not open configuration file\n"; +while(){ + chomp; + ($key,$val)=(split /:\s*/,$_); + $sql_server = $val if ($key eq 'sql_server'); + $sql_username = $val if ($key eq 'sql_username'); + $sql_password = $val if ($key eq 'sql_password'); + $sql_database = $val if ($key eq 'sql_database'); + $sql_accounting_table = $val if ($key eq 'sql_accounting_table'); +} +close CONF; + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; +$date = POSIX::strftime("%Y-%m-%d %T",$sec,$min,$hour,($mday - 1),$mon,$year,$wday,$yday,$isdst); +print "$date\n"; + +$dbh = DBI->connect("DBI:mysql:$sql_database:$sql_server","$sql_username","$sql_password"); +$dbh->do("DELETE FROM $sql_accounting_table WHERE AcctStopTime = '0' AND AcctStartTime < '$date';"); +$dbh->disconnect(); diff --git a/bin/log_badlogins b/bin/log_badlogins new file mode 100755 index 0000000..ed6808e --- /dev/null +++ b/bin/log_badlogins @@ -0,0 +1,87 @@ +#!/usr/bin/perl +use DBI; + +use Date::Manip qw(ParseDate UnixDate); +$|=1; + +$file=shift||'none'; +$conf=shift||'/usr/local/dialup_admin/conf/admin.conf'; + +open CONF, "<$conf" + or die "Could not open configuration file\n"; +while(){ + chomp; + ($key,$val)=(split /:\s*/,$_); + $sql_server = $val if ($key eq 'sql_server'); + $sql_username = $val if ($key eq 'sql_username'); + $sql_password = $val if ($key eq 'sql_password'); + $sql_database = $val if ($key eq 'sql_database'); + $sql_accounting_table = $val if ($key eq 'sql_accounting_table'); +} +close CONF; + +$dbh = DBI->connect("DBI:mysql:$sql_database:$sql_server","$sql_username","$sql_password") + or die "Could not connect to SQL database: $DBI::errtstr\n"; +open LOG, "<$file" + or die "Could not open file $file\n"; +seek LOG, 0, 2; +for(;;){ + while(){ + $do=0; + chomp; + if ($_ ne ''){ + $user = $nas = $port = $caller = '-'; + if (/Login incorrect/){ + if (/Login incorrect \((.+?)\):/){ + $cause = 'Login-Incorrect ($1)'; + }else{ + $cause='Login-Incorrect'; + } + $do=1; + } + elsif (/Invalid user/){ + if (/Invalid user \((.+?)\):/){ + $cause = 'Invalid-User ($1)'; + }else{ + $cause='Invalid-User'; + } + $do=1; + } + elsif (/Multiple logins/){ + $cause='Multiple-Logins'; + $do=1; + } + elsif (/(Outside allowed timespan \(.+?\)):/){ + $cause = '$1'; + $do=1; + } + if ($do){ + $date = (split / : /,$_)[0]; + $date2 = ParseDate($date); + if ($date2){ + ($year,$mon,$mday,$hour,$min,$sec)=UnixDate($date2,'%Y','%m','%d','%H','%M','%S'); + } + $time = "$year-$mon-$mday $hour:$min:$sec"; + if (/\[(\w+?)\]\s+\(from (.+?)\)/){ + $user = $1; + ($nas,$port,$caller) = (split /\s+/,$2)[1,3,5]; + } + $caller='' if (!defined($caller)); + $user =~s/[^\w]//g; + $nas =~s/[^\w]//g; + if ($nas !~ /\.noc\.ntua\.gr$/){ + $nas .= '.noc.ntua.gr'; + } + $port =~s/[^\d]//g; + $caller =~s/[^\d]//g; + $addr = gethostbyname $nas; + ($a,$b,$c,$d)=unpack('C4',$addr); + $addr = "$a.$b.$c.$d"; +$dbh->do("INSERT INTO $sql_accounting_table (UserName,NASIPAddress,NASPortId,AcctStartTime,AcctStopTime,AcctSessionTime,AcctInputOctets,AcctOutputOctets,CallingStationId,AcctTerminateCause) VALUES ('$user','$addr','$port','$time','$time','0','0','0','$caller','$cause');"); + } + } + } + sleep 2; + seek LOG,0,1; +} +$dbh->disconnect(); diff --git a/bin/showmodem b/bin/showmodem new file mode 100755 index 0000000..e7a4f8f --- /dev/null +++ b/bin/showmodem @@ -0,0 +1,89 @@ +#!/usr/bin/perl + +$snmpget="/usr/local/bin/snmpget"; +$snmpwalk="/usr/local/bin/snmpwalk"; +$nas=shift; +$user=shift; +$com=shift || "public"; +$type=shift|| "xml"; + +@ModulationScheme = ( + "error", + "unknown", + "bell103a", + "bell212a", + "v21", + "v22", + "v22bis", + "v32", + "v32bis", + "vfc", + "v34", + "v17", + "v29", + "v33", + "k56flex", + "v23", + "v32terbo", + "v34plus", + "v90", + "v27ter", +); + +@Protocol = ( + "error", + "normal", + "direct", + "reliableMNP", + "reliableLAPM", + "syncMode", + "asyncMode", + "ara10", + "ara20", + "unknown", +); + +$modem=`$snmpwalk $nas $com enterprises.9.2.9.2.1.18 | grep $user`; +if($modem=~/enterprises\.9\.2\.9\.2\.1\.18\.(\d+) =/){ + $modem=$1; + $slot=(1+int($modem/120)); + $port=$modem%120-1; + $modem="$slot.$port"; + + + $duration=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.9.$modem` or die "No MIB\n"; + $duration=~/\) (.*)\./; + $duration=$1; + + $modulation=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.12.$modem` or die "No MIB\n"; + $modulation=~/ \= (\d+)/; + $modulation=$ModulationScheme[$1]; + + $protocol=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.13.$modem` or die "No MIB\n"; + $protocol=~/ \= (\d+)/; + $protocol=$Protocol[$1]; + + $txrate=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.14.$modem` or die "No MIB\n"; + $txrate=~/Gauge32\: (\d+)/; + $txrate=$1; + + $rxrate=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.15.$modem` or die "No MIB\n"; + $rxrate=~/Gauge32\: (\d+)/; + $rxrate=$1; + + $rxsignal=`$snmpget $nas $com enterprises.9.9.47.1.3.1.1.17.$modem` or die "No MIB\n"; + $rxsignal=~/ \= (.*)\n/; + $rxsignal=$1; + + if($type eq "xml"){ + print"$modulation$protocol$txrate$rxrate$rxsignal\n"; + + }else{ + print "Duration>\t$duration\n"; + print "Modulation>\t$modulation\n"; + print "Protocol>\t$protocol\n"; + print "TxRate>\t\t$txrate\n"; + print "RxRate>\t\t$rxrate\n"; + print "RxSignal>\t$rxsignal dbm\n"; + } +} diff --git a/bin/snmpfinger b/bin/snmpfinger new file mode 100755 index 0000000..b9dda8b --- /dev/null +++ b/bin/snmpfinger @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +$SNMPWALK="/usr/bin/snmpwalk"; + +$walk =`$SNMPWALK $ARGV[0] public .iso.org.dod.internet.private.enterprises.9.2.9.2.1.18`; +$walk.=`$SNMPWALK $ARGV[0] public .iso.org.dod.internet.private.enterprises.9.9.27.1.1.3.1.7`; + +while($walk=~/\"(\w+?)\"/g){ + $user=lc($1); + if($out) { + $out=$out.",'$user'"; + }else{ + $out="'$user'"; + } +} +print "$out\n"; diff --git a/conf/admin.conf b/conf/admin.conf new file mode 100644 index 0000000..a20566c --- /dev/null +++ b/conf/admin.conf @@ -0,0 +1,99 @@ +# +# it can be el (greek) or default +# +general_prefered_lang: el +general_prefered_lang_name: Greek +# +general_base_dir: /usr/local/dialup_admin +general_radiusd_base_dir: /usr/local/radiusd +general_domain: company.com +# +general_ldap_attrmap: %{general_radiusd_base_dir}/etc/raddb/ldap.attrmap +general_sql_attrmap: %{general_base_dir}/conf/sql.attrmap +general_extra_ldap_attrmap: %{general_base_dir}/conf/extra.ldap-attrmap +# +# it can be either ldap or sql +# +general_lib_type: ldap +general_user_edit_attrs_file: %{general_base_dir}/conf/user_edit.attrs +general_sql_attrs_file: %{general_base_dir}/conf/sql.attrs +general_default_file: %{general_base_dir}/conf/default.vals +general_snmpfinger_bin: %{general_base_dir}/bin/snmpfinger +general_radclient_bin: %{general_radiusd_base_dir}/bin/radclient +# +# this information is used from the server check page +# +general_test_account_login: test +general_test_account_password: testpass +# +# These are used as default values for the user test page +# +general_radius_server: localhost +general_radius_server_port: 1812 +# +# sorry, single valued for now. Should become something like +# password[server-name]: xxxxx +# +general_radius_server_secret: XXXXXX +general_auth_request_file: %{general_base_dir}/conf/auth.request +# +# can be one of crypt,md5,clear +# +general_encryption_method: crypt + +nas1_name: nas1.%{general_domain} +nas1_model: Cisco 2511 access server +nas1_ip: 147.122.122.121 +nas1_port_num: 16 +nas1_community: public +nas2_name: nas2.%{general_domain} +nas2_model: Cisco 2511 access server +nas2_ip: 147.122.122.123 +nas2_port_num: 16 +nas2_community: public +nas3_name: nas3.%{general_domain} +nas3_model: Cisco 5300 access server +nas3_ip: 147.122.122.124 +nas3_port_num: 210 +nas3_community: public + +ldap_server: ldap.%{general_domain} +ldap_base: dc=company,dc=com +ldap_binddn: cn=Directory Manager +ldap_bindpw: XXXXXXX +ldap_default_new_entry_suffix: ou=dialup,ou=guests,%{ldap_base} +ldap_default_dn: uid=default-dialup,%{ldap_base} +ldap_regular_profile_attr: dialupregularprofile + +# +# can be one of mysql,pg where: +# mysq: MySQL database (port 3306) +# pg: PostgreSQL database (port 5432) +# +sql_type: mysql +sql_server: localhost +sql_port: 3306 +sql_username: dialup_admin +sql_password: XXXXXX +sql_database: radius +sql_accounting_table: radacct +sql_badusers_table: badusers +sql_check_table: radcheck +sql_reply_table: radreply +sql_user_info_table: userinfo +# +# true or false +# +sql_use_user_info_table: true +sql_password_attribute: Crypt-Password +sql_date_format: Y-m-d +sql_full_date_format: Y-m-d H:i:s +# +# Used in the accounting report generator so that we +# don't return too many results +# +sql_row_limit: 40 + +counter_default_daily: 14400 +counter_default_weekly: 72000 +counter_default_monthly: none diff --git a/conf/auth.request b/conf/auth.request new file mode 100644 index 0000000..a90c5d7 --- /dev/null +++ b/conf/auth.request @@ -0,0 +1 @@ +Service-Type = Framed-User diff --git a/conf/config.php3 b/conf/config.php3 new file mode 100644 index 0000000..565eb28 --- /dev/null +++ b/conf/config.php3 @@ -0,0 +1,14 @@ + diff --git a/conf/default.vals b/conf/default.vals new file mode 100644 index 0000000..021e41d --- /dev/null +++ b/conf/default.vals @@ -0,0 +1,16 @@ +# +# Uncomment these lines if you add default values in the users file +# +#Simultaneous-Use: 1 +#Framed-IP-Address: 255.255.255.254 +#Framed-IP-Netmask: 255.255.255.255 +#Framed-MTU: 1500 +#Framed-Protocol: PPP +#Framed-Compression: Van-Jacobson-TCP-IP +#Session-Timeout: 14400 +#Idle-Timeout: 600 +#Port-Limit: 1 +#Max-Weekly-Session: 72000 +#Max-Daily-Session: 14400 +#Login-Time: +#Auth-Type: LDAP diff --git a/conf/extra.ldap-attrmap b/conf/extra.ldap-attrmap new file mode 100644 index 0000000..9edec2a --- /dev/null +++ b/conf/extra.ldap-attrmap @@ -0,0 +1,3 @@ +checkItem Dialup-Lock-Msg radiuslockmsg +checkItem User-Password userpassword +replyItem Reply-Item radiusReplyItem diff --git a/conf/sql.attrmap b/conf/sql.attrmap new file mode 100644 index 0000000..138bc20 --- /dev/null +++ b/conf/sql.attrmap @@ -0,0 +1,39 @@ +checkItem Auth-Type Auth-Type +checkItem Simultaneous-Use Simultaneous-Use +checkItem Called-Station-Id Called-Station-Id +checkItem Calling-Station-Id Calling-Station-Id +checkItem Dialup-Access none +checkItem Max-Daily-Session none +checkItem Max-Weekly-Session none +checkItem Login-Time Login-Time + +replyItem Service-Type Service-Type +replyItem Framed-Protocol Framed-Protocol +replyItem Framed-IP-Address Framed-IP-Address +replyItem Framed-IP-Netmask Framed-IP-Netmask +replyItem Framed-Route Framed-Route +replyItem Framed-Routing Framed-Routing +replyItem Filter-Id Filter-Id +replyItem Framed-MTU Framed-MTU +replyItem Framed-Compression Framed-Compression +replyItem Login-IP-Host Login-IP-Host +replyItem Login-Service Login-Service +replyItem Login-TCP-Port Login-TCP-Port +replyItem Callback-Number Callback-Number +replyItem Callback-Id Callback-Id +replyItem Framed-IPX-Network Framed-IPX-Network +replyItem Class Class +replyItem Session-Timeout Session-Timeout +replyItem Idle-Timeout Idle-Timeout +replyItem Termination-Action Termination-Action +replyItem Login-LAT-Service Login-LAT-Service +replyItem Login-LAT-Node Login-LAT-Node +replyItem Login-LAT-Group Login-LAT-Group +replyItem Framed-AppleTalk-Link Framed-AppleTalk-Link +replyItem Framed-AppleTalk-Network Framed-AppleTalk-Network +replyItem Framed-AppleTalk-Zone Framed-AppleTalk-Zone +replyItem Port-Limit Port-Limit +replyItem Login-LAT-Port Login-LAT-Port +replyitem Reply-Message Reply-Message +replyItem Dialup-Lock-Msg Reply-Message +replyItem User-Password Password diff --git a/conf/sql.attrs b/conf/sql.attrs new file mode 100644 index 0000000..797baf2 --- /dev/null +++ b/conf/sql.attrs @@ -0,0 +1,27 @@ +# +# Mysql attributes Description Show Use function +# +RadAcctId Accounting Id no +AcctSessionId Session Id no +AcctUniqueId Unique Id no +UserName User Name yes +Realm Realm no +NASIPAddress NAS IP Address yes +NASPortId NAS Port yes +NASPortType NAS Port Type no +AcctStartTime Login Time yes +AcctStopTime Logout Time yes +AcctSessionTime Session Time yes time2str +AcctAuthentic AcctAuthentic no +ConnectInfo_start Start Connect Info no +ConnectInfo_stop Stop Connect Info no +AcctInputOctets Upload yes bytes2str +AcctOutputOctets Download yes bytes2str +CalledStationId CalledStationId no +CallingStationId Caller Id no +AcctTerminateCause Terminate Cause no +ServiceType Service Type no +FramedProtocol Protocol no +FramedIPAddress Client IP Address yes +AcctStartDelay Accounting Start Delay no time2str +AcctStopDelay Accounting Stop Delay no time2str diff --git a/conf/user_edit.attrs b/conf/user_edit.attrs new file mode 100644 index 0000000..f83d651 --- /dev/null +++ b/conf/user_edit.attrs @@ -0,0 +1,33 @@ +#Auth-Type Auth Type +#Simultaneous-Use Simultaneous Use +Framed-Protocol Protocol +Framed-IP-Address IP Address +Framed-IP-Netmask IP Netmask +#Framed-Route Route +#Framed-Routing +#Filter-Id +Framed-MTU MTU +Framed-Compression Compression Used +#Login-IP-Host +#Login-Service +#Login-TCP-Port +#Callback-Number +#Callback-Id +#Framed-IPX-Network +#Class +Session-Timeout Session Timeout +Idle-Timeout Idle Timeout +#Termination-Action +#Login-LAT-Service +#Login-LAT-Node +#Login-LAT-Group +#Framed-AppleTalk-Link +#Framed-AppleTalk-Network +#Framed-AppleTalk-Zone +Port-Limit Port Limit +#Login-LAT-Port +#Dialup-Access Dialup Access (use FALSE to lock) +Dialup-Lock-Msg Lock Message +#Max-Daily-Session Daily Limit (secs) +#Max-Weekly-Session Weekly Limit (secs) +#Login-Time User Login Period (UUCP Format) diff --git a/htdocs/about.html b/htdocs/about.html new file mode 100644 index 0000000..8e4201e --- /dev/null +++ b/htdocs/about.html @@ -0,0 +1,52 @@ + + +About page + + + +
+ + + + +
+
+
+ + + + + +
+ + +
dialup_admin About Page 
+
+ + +
+
+
+
+A web based administration interface for the freeradius radius server
+written in PHP4
+

+Copyright (C) 2001,2002 Kostas Kalevras +


+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version
+2 of the License, or (at your option) any later version.
+
+
+Authors:
Kostas Kalevras (kkalev at noc.ntua.gr)
+Basilis Pappas (vpappas at noc.ntua.gr)
+Panagiotis Christias (christia at noc.ntua.gr)
+Thanasis Duitsis (aduitsis at noc.ntua.gr)
+
+
+
+
+ + diff --git a/htdocs/accounting.php3 b/htdocs/accounting.php3 new file mode 100644 index 0000000..db8873a --- /dev/null +++ b/htdocs/accounting.php3 @@ -0,0 +1,268 @@ + + +Accounting Report Generator + + + +
+Could not include SQL library functions. Aborting + + +EOM; + exit(); +} + +$operators=array( '<', '>', '=', '>=', '<=' ); + +$link = @da_sql_pconnect ($config) or die('cannot connect to sql databse'); +$fields = @da_sql_list_fields($config[sql_accounting_table],$link,$config); +$no_fields = @da_sql_num_fields($fields,$config); + +for($i=0;$i<$no_fields;$i++){ + $key = @da_sql_field_name($fields,$i,$config); + $val = $sql_attrs[$key][desc]; + $show = $sql_attrs[$key][show]; + $selected[$key] = ($show == 'yes') ? 'selected' : ''; + $items[$key] = "$val"; +} +asort($items); + +class Qi { + var $name; + var $item; + var $_item; + var $operator; + var $type; + var $typestr; + var $value; + function Qi($name,$item,$operator) { + $this->name=$name; + $this->item=$item; + $this->operator=$operator; + } + + function show() { global $operators; + global $items; + $nam = $this->item; + echo << + $items[$nam] + + + + + +EOM; + } + + function get($designator) { global ${"item_of_$designator"}; + global ${"value_of_$designator"}; + global ${"operator_of_$designator"}; + if(${"item_of_$designator"}){ + $this->value= ${"value_of_$designator"}; + $this->operator=${"operator_of_$designator"}; + $this->item=${"item_of_$designator"}; + } + } + function query(){ + global $operators; + global $items; + return $items[$this->item]." $this->operator '$this->value'"; + } +} + +?> + + + +Accounting Report Generator + + + + + + + + + + +
+Show the following attributes:
+ +EOM; + +foreach($items as $key => $val) + if ($val == 'UserName') + echo <<$val +EOM; + else + echo <<$val +EOM; + +echo << +
+
+ + + + +EOM; + +$number=1; +$offset=0; +while (${"item_of_w$number"}) { + if(${"delete_w$number"}==1) {$offset=1;$number++;} + else { + $designator=$number-$offset; + ${"w$designator"} = new Qi("w$designator","",""); + ${"w$designator"}->get("w$number"); + ${"w$designator"}->show(); + $number++; + } + } +if($add==1) { + ${"w$number"} = new Qi("w$number","$item_name","$operators[0]"); + ${"w$number"}->show(); + } +echo << + + + + +
+Selection criteria: +
+
+ +
+
+ + + +EOM; + +} + +if ($queryflag == 1){ +$i = 1; +while (${"item_of_w$i"}){ + $where .= ($i == 1) ? ' WHERE ' . ${"item_of_w$i"} . ${"operator_of_w$i"} . "'" . ${"value_of_w$i"} . "'" : + ' AND ' . ${"item_of_w$i"} . ${"operator_of_w$i"} . "'" . ${"value_of_w$i"} . "'" ; + $i++; +} + +$order = ($order_by != '') ? "$order_by" : 'UserName'; + +foreach ($show_attrs as $val) + $query_view .= $val . ','; +$query_view = ereg_replace(',$','',$query_view); +$query="SELECT $query_view FROM $config[sql_accounting_table] $where ORDER BY $order LIMIT $config[sql_row_limit]"; + +echo << + + + + +
+ + + + + +
+ + +
+ Accounting Report Generator  +
+
+ + +
+

+ + + +EOM; +foreach($show_attrs as $val){ + $desc = $sql_attrs[$val][desc]; + echo "\n"; +} +echo "\n"; + + $search = @da_sql_query($link,$config,"$query"); + if ($search){ + while( $row = @da_sql_fetch_array($search,$config) ){ + $num++; + echo "\n"; + foreach($show_attrs as $val){ + $info = $row[$val]; + if ($info == '') + $info = '-'; + $info = $sql_attrs[$val][func]($info); + if ($val == 'UserName') + $info = "$info"; + echo <<$info +EOM; + } + echo "\n"; + } + } +echo << + +
$desc
+

+ + +EOM; +} +?> diff --git a/htdocs/badusers.php3 b/htdocs/badusers.php3 new file mode 100644 index 0000000..b1060d2 --- /dev/null +++ b/htdocs/badusers.php3 @@ -0,0 +1,150 @@ + +Unauthorized Service Usage History for $login + + + +
+Could not include SQL library functions. Aborting + + +EOM; + exit(); +} + +$now = time(); +$now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400); +$prev_str = ($prev_str != '') ? "$prev_str" : "0000-00-00 00:00:00"; +$num = 0; +$pagesize = ($pagesize) ? $pagesize : 10; +$limit = ($pagesize == 'all') ? '' : "LIMIT $pagesize"; +$selected[$pagesize] = 'selected'; +$login = ($login != '') ? $login : 'anyone'; +$usercheck = ($login == 'anyone') ? "LIKE '%'" : "= '$login'"; + +echo << +Unauthorized Service Usage History for $login + + + +
+ + + + +
+EOM; + +if ($login != 'anyone'){ + echo << +EOM; + +include("../html/user_toolbar.html.php3"); + +print << +EOM; +} + +echo <<
+ + + + + +
+ + +
+ Unauthorized Service Usage History for $login  +
+
+ + +
+$prev_str up to $now_str +EOM; +?> + +

+ + + + + += '$prev_str' ORDER BY Date ASC $limit;"); + if ($search){ + while( $row = @da_sql_fetch_array($search,$config) ){ + $num++; + $user = "$row[UserName]"; + $date = "$row[Date]"; + $reason = "$row[Reason]"; + if ($reason == '') + $reason = '-'; + echo << + + + + + +EOM; + } + } +} +echo << + +
#userdatereason
$num$user$date$reason
+
+
+
+ + + + + + + + + + +EOM; +?> + + +
+ + the from date matches any login after the 00:00 that day, + and the to date any login before the 23:59 that day. + the default values shown are the current week. +
userfrom dateto datepagesize
+ +
+

+ + diff --git a/htdocs/buttons.html b/htdocs/buttons.html new file mode 100644 index 0000000..a6555f5 --- /dev/null +++ b/htdocs/buttons.html @@ -0,0 +1,73 @@ + + + + + + +
+ + + + +
+ +
+ + +
+Main Menu +
+
+ + + +
+ + + + + + + + + + + + + +
+
+
+
+ diff --git a/htdocs/content.html b/htdocs/content.html new file mode 100644 index 0000000..d8fa823 --- /dev/null +++ b/htdocs/content.html @@ -0,0 +1,9 @@ + + +
+

+A web based administration interface for the freeradius radius server +

+
+ + diff --git a/htdocs/help/dialup_access_help.html b/htdocs/help/dialup_access_help.html new file mode 100644 index 0000000..164b542 --- /dev/null +++ b/htdocs/help/dialup_access_help.html @@ -0,0 +1,36 @@ + + +Dialup Access Help Page + + + +
+ + + + + +
+ + +
Dialup Access Help Page 
+
+ + + + +
+
+
+
+  If the Dialup-Access attribute is specified, the ldap module
+  checks for its existance in user object. If it exists and is
+  set to FALSE, user is denied remote access. Otherwise, the user
+  is allowed remote access.
+
+
+Close Window +
+
+ + diff --git a/htdocs/help/framed_compression_help.html b/htdocs/help/framed_compression_help.html new file mode 100644 index 0000000..07dc7c3 --- /dev/null +++ b/htdocs/help/framed_compression_help.html @@ -0,0 +1,38 @@ + + +Framed Compression Help Page + + + +
+ + + + + +
+ + +
Framed Compression Help Page 
+
+ + + + +
+
+
+
+  Framed-Compression indicates a compression protocol to be used for the link.
+  Possible values are:
+
+ None
+ Van-Jacobson-TCP-IP
+ IPX-Header-Compression
+ Stac-LZS
+
+Close Window +
+
+ + diff --git a/htdocs/help/framed_ip_address_help.html b/htdocs/help/framed_ip_address_help.html new file mode 100644 index 0000000..6002cf4 --- /dev/null +++ b/htdocs/help/framed_ip_address_help.html @@ -0,0 +1,40 @@ + + +Framed-IP-Address Help Page + + + +
+ + + + + +
+ + +
Framed-IP-Address Help Page 
+
+ + + + +
+
+
+
+  Framed-IP-Address can be used to specify the IP address that
+  a dialup user will use. There are two special values:
+
+255.255.255.255: Assign the user requested IP
+255.255.255.254: Assign an IP from the NAS IP pool
+
+  All other values will be assigned as they are to the user dialup
+  interface
+
+
+Close Window +
+
+ + diff --git a/htdocs/help/help.php3 b/htdocs/help/help.php3 new file mode 100644 index 0000000..54cca94 --- /dev/null +++ b/htdocs/help/help.php3 @@ -0,0 +1,44 @@ + + +Help page + + + +
+ + + + +
+ +
+ +
+ + + + + +
+ + +
dialup_admin help page 
+
+ + +
+
+
+
+For now we just include the README file
+ + + +
+
+
+
+ + diff --git a/htdocs/help/lock_message_help.html b/htdocs/help/lock_message_help.html new file mode 100644 index 0000000..21a163b --- /dev/null +++ b/htdocs/help/lock_message_help.html @@ -0,0 +1,36 @@ + + +Lock Message Help Page + + + +
+ + + + + +
+ + +
Lock Message Help Page 
+
+ + + + +
+
+
+
+  The Lock Message will be included as a Reply-Item in all radius server responses for
+  the user. It will also appear in the Usefull User Description in the user admin page.
+  It is intended to be used as a hint to the user and to the administrator for the reason
+  of the user lock out.
+
+
+Close Window +
+
+ + diff --git a/htdocs/help/login_time_help.html b/htdocs/help/login_time_help.html new file mode 100644 index 0000000..42ed56f --- /dev/null +++ b/htdocs/help/login_time_help.html @@ -0,0 +1,49 @@ + + +Login-Time Help Page + + + +
+ + + + + +
+ + +
Login-Time Help Page 
+
+ + + + +
+
+
+
+  Login-Time defines the time span a user may login to the system. The
+  format of a so-called time string is like the format used by UUCP.
+  A time string may be a list of simple time strings separated by "|" or ",".
+
+  Each simple time string must begin with a day definition. That can be just
+  one day, multiple days, or a range of days separated by a hyphen. A
+  day is Mo, Tu, We, Th, Fr, Sa or Su, or Wk for Mo-Fr. "Any" or "Al"
+  means all days.
+
+  After that a range of hours follows in hhmm-hhmm format.
+
+  For example, "Wk2305-0855,Sa,Su2305-1655".
+
+  Radiusd calculates the number of seconds left in the time span, and
+  sets the Session-Timeout to that number of seconds. So if someones
+  Login-Time is "Al0800-1800" and he logs in at 17:30, Session-Timeout
+  is set to 1800 seconds so that he is kicked off at 18:00.
+
+
+Close Window +
+
+ + diff --git a/htdocs/help/port_limit_help.html b/htdocs/help/port_limit_help.html new file mode 100644 index 0000000..6ae3281 --- /dev/null +++ b/htdocs/help/port_limit_help.html @@ -0,0 +1,35 @@ + + +Port Limit Help Page + + + +
+ + + + + +
+ + +
Port Limit Help Page 
+
+ + + + +
+
+
+
+  Port-Limit is intended for use in conjuction with Multilink PPP or similar uses.
+  It defines the maximum number of channels the user is allowed to open during
+  a multilink dialup session.
+
+
+Close Window +
+
+ + diff --git a/htdocs/help/simultaneous_use_help.html b/htdocs/help/simultaneous_use_help.html new file mode 100644 index 0000000..6ce5f71 --- /dev/null +++ b/htdocs/help/simultaneous_use_help.html @@ -0,0 +1,35 @@ + + +Simultaneous Use Help Page + + + +
+ + + + + +
+ + +
Simultaneous Use Help Page 
+
+ + + + +
+
+
+
+  This attribute defines the maximum number of concurrent logins
+  for a user. It is independent from the number of ports the user
+  is allowed to open in a multilink session.
+
+
+Close Window +
+
+ + diff --git a/htdocs/images/bg.gif b/htdocs/images/bg.gif new file mode 100644 index 0000000..3a45d0f Binary files /dev/null and b/htdocs/images/bg.gif differ diff --git a/htdocs/images/black.gif b/htdocs/images/black.gif new file mode 100644 index 0000000..639e5f2 Binary files /dev/null and b/htdocs/images/black.gif differ diff --git a/htdocs/images/greenlines1.gif b/htdocs/images/greenlines1.gif new file mode 100644 index 0000000..2b5fc8e Binary files /dev/null and b/htdocs/images/greenlines1.gif differ diff --git a/htdocs/images/logo2.gif b/htdocs/images/logo2.gif new file mode 100644 index 0000000..c47ce14 Binary files /dev/null and b/htdocs/images/logo2.gif differ diff --git a/htdocs/images/pixel.gif b/htdocs/images/pixel.gif new file mode 100644 index 0000000..1118d01 Binary files /dev/null and b/htdocs/images/pixel.gif differ diff --git a/htdocs/images/title2.gif b/htdocs/images/title2.gif new file mode 100644 index 0000000..3e0d954 Binary files /dev/null and b/htdocs/images/title2.gif differ diff --git a/htdocs/index.html b/htdocs/index.html new file mode 100644 index 0000000..e08c94e --- /dev/null +++ b/htdocs/index.html @@ -0,0 +1,17 @@ + + + +dialup administration + + + + + + + <body bgcolor=yellow> + <p><font color="darkblue"><h1>this page can only be seen by a frames capable browser. sorry...</h1></font> + </p></body> + + diff --git a/htdocs/password.php3 b/htdocs/password.php3 new file mode 100644 index 0000000..04cac5b --- /dev/null +++ b/htdocs/password.php3 @@ -0,0 +1,22 @@ +
+> + +
+ + + + +
+ + +
+ Check Password  +
+
+ +
+ + +
Password
+
+
diff --git a/htdocs/stats.php3 b/htdocs/stats.php3 new file mode 100644 index 0000000..4130a34 --- /dev/null +++ b/htdocs/stats.php3 @@ -0,0 +1,158 @@ + + +account analysis + + + +
+ +Could not include SQL library functions. Aborting + + +EOM; + exit(); +} + + +$date = strftime('%A, %e %B %Y, %T %Z'); +$now = time(); +if ($before == '') + $before = date($config[sql_date_format], $now + 86400); +$after = ($after != '') ? "$after" : date($config[sql_date_format], $now - 604800 ); + +$after_time = date2time($after); +$before_time = date2time($before); +$days[0] = $after; +$counter = $after_time + 86400; +$i = 1; +while($counter < $before_time){ + $days[$i++] = date($config[sql_date_format],$counter); + $counter += 86400; +} +$days[$i] = $before; +$num_days = $i; + +$column1 = ($column1 != '') ? "$column1" : 'sessions'; +$column2 = ($column2 != '') ? "$column2" : 'usage'; +$column3 = ($column3 != '') ? "$column3" : 'download'; +$column[1] = "$column1"; +$column[2] = "$column2"; +$column[3] = "$column3"; +$selected1["$column1"] = 'selected'; +$selected2["$column2"] = 'selected'; +$selected3["$column3"] = 'selected'; + +$message['sessions'] = 'sessions'; +$message['usage'] = 'total usage time'; +$message['upload'] = 'uploads'; +$message['download'] = 'downloads'; +$sql_val['usage'] = 'AcctSessionTime'; +$sql_val['upload'] = 'AcctInputOctets'; +$sql_val['download'] = 'AcctOutputOctets'; +$fun['sessions'] = nothing; +$fun['usage'] = time2strclock; +$fun['upload'] = bytes2str; +$fun['download'] = bytes2str; +$sql_val['user'] = ($login == '') ? "WHERE UserName LIKE '%'" : "WHERE UserName = '$login'"; +for ($j = 1; $j <= 3; $j++){ + $tmp = "{$sql_val[$column[$j]]}"; + $res[$j] = ($tmp == "") ? 'COUNT(RadAcctId)' : "sum($tmp)"; +} +$i = 1; +$servers[all] = 'all'; +while(1){ + $nas = 'nas' . $i; + $ip = $nas . '_ip'; + $name = $nas . '_name'; + if ($config[$ip] == '') + break; + $name = $config[$name]; + $servers[$name] = $config[$ip]; + $i++; +} +if ($server != 'all') + $s = "AND NASIPAddress = '$server'"; + +$link = @da_sql_pconnect($config); +if ($link){ + for ($i = $num_days;$i > -1; $i--){ + $day = "$days[$i]"; + $search = @da_sql_query($link,$config, + "SELECT $res[1],$res[2],$res[3] FROM $config[sql_accounting_table] + $sql_val[user] AND AcctStopTime LIKE '$day%' $s;"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $data[$day][1] = $row["$res[1]"]; + $data[sum][1] += $row["$res[1]"]; + $num[1] = ($data[$day][1]) ? $num[1] + 1 : $num[1]; + $data[$day][2] = $row["$res[2]"]; + $data[sum][2] += $row["$res[2]"]; + $num[2] = ($data[$day][2]) ? $num[2] + 1 : $num[2]; + $data[$day][3] = $row["$res[3]"]; + $data[sum][3] += $row["$res[3]"]; + $num[3] = ($data[$day][3]) ? $num[3] + 1 : $num[3]; + } + } +} + +$num[1] = ($num[1]) ? $num[1] : 1; +$num[2] = ($num[2]) ? $num[2] : 1; +$num[3] = ($num[3]) ? $num[3] : 1; + +$data['avg'][1] = ceil($data['sum'][1] / $num[1]); +$data['avg'][2] = ceil($data['sum'][2] / $num[2]); +$data['avg'][3] = ceil($data['sum'][3] / $num[3]); + +$data['avg'][1] = $fun[$column[1]]($data['avg'][1]); +$data['avg'][2] = $fun[$column[2]]($data['avg'][2]); +$data['avg'][3] = $fun[$column[3]]($data['avg'][3]); + +$data['sum'][1] = $fun[$column[1]]($data['sum'][1]); +$data['sum'][2] = $fun[$column[2]]($data['sum'][2]); +$data['sum'][3] = $fun[$column[3]]($data['sum'][3]); + +for ($i = 0; $i <= $num_days; $i++){ + $day = "$days[$i]"; + $max[1] = ($max[1] > $data[$day][1] ) ? $max[1] : $data[$day][1]; + $max[2] = ($max[2] > $data[$day][2] ) ? $max[2] : $data[$day][2]; + $max[3] = ($max[3] > $data[$day][3] ) ? $max[3] : $data[$day][3]; + +} +for ($i = 0; $i <= $num_days; $i++){ + $day = "$days[$i]"; + for ($j = 1; $j <= 3; $j++){ + $tmp = $data[$day][$j]; + if (!$max[$j]) + $p = $w = $c = 0; + else{ + $p = floor(100 * ($tmp / $max[$j])); + $w = floor(70 * ($tmp / $max[$j])); + $c = hexdec('f0e9e2') - (258 * $p); + $c = dechex($c); + } + if (!$w) + $w++; + $perc[$day][$j] = $p . "%"; + $width[$day][$j] = $w; + $color[$day][$j] = $c; + } + + $data[$day][1] = $fun[$column[1]]($data[$day][1]); + $data[$day][2] = $fun[$column[2]]($data[$day][2]); + $data[$day][3] = $fun[$column[3]]($data[$day][3]); +} + +$data[max][1] = $fun[$column[1]]($max[1]); +$data[max][2] = $fun[$column[2]]($max[2]); +$data[max][3] = $fun[$column[3]]($max[3]); + +require('../html/stats.html.php3'); +?> diff --git a/htdocs/style.css b/htdocs/style.css new file mode 100644 index 0000000..09c0faf --- /dev/null +++ b/htdocs/style.css @@ -0,0 +1,32 @@ +td {font-family:verdana,sans-serif;text-decoration:none;font-size:11px} +th {font-family:verdana,sans-serif;text-decoration:none;font-size:11px} +A {FONT-FAMILY: verdana,sans-serif; FONT-SIZE: 11px; TEXT-DECORATION: none} +H1 {FONT-FAMILY: lucida,sans-serif; FONT-SIZE: 24px; TEXT-DECORATION: none} +INPUT{ + BACKGROUND-COLOR: #FFFFFF; + BORDER-BOTTOM: #3333CC 1px solid; + BORDER-LEFT: #3333CC 1px solid; + BORDER-RIGHT: #3333CC 1px solid; + BORDER-TOP: #3333CC 1px solid; + COLOR: #000000; + FONT-FAMILY: Verdana +} +INPUT.button{ + BACKGROUND-COLOR: #999999; + BORDER-BOTTOM: #3333CC 1px solid; + BORDER-LEFT: #3333CC 1px solid; + BORDER-RIGHT: #3333CC 1px solid; + BORDER-TOP: #3333CC 1px solid; + COLOR: #000000; + FONT-FAMILY: Verdana +} +body +{ + scrollbar-track-color:#b0bd90; + scrollbar-arrow-color:#000000; + scrollbar-face-color:#d0ddb0; + scrollbar-shadow-color:#909d70; + scrollbar-highlight-color:#fffff0; + scrollbar-3dlight-color:#000000; + scrollbar-darkshadow-color:#000000; +} diff --git a/htdocs/user_accounting.php3 b/htdocs/user_accounting.php3 new file mode 100644 index 0000000..e6048f3 --- /dev/null +++ b/htdocs/user_accounting.php3 @@ -0,0 +1,185 @@ + +subscription analysis for $login ($cn) + + + +
+Could not include SQL library functions. Aborting + + +EOM; + exit(); +} + +$now = time(); +$now_str = ($now_str != '') ? "$now_str" : date($config[sql_date_format],$now + 86400); +$prev_str = ($prev_str != '') ? "$prev_str" : date($config[sql_date_format], $now - 604800 ); +$num = 0; +$pagesize = ($pagesize) ? $pagesize : 10; +$limit = ($pagesize == 'all') ? '' : "LIMIT $pagesize"; +$selected[$pagesize] = 'selected'; + +echo << +subscription analysis for $login ($cn) + + + +
+ + + + +
+ +EOM; + +include("../html/user_toolbar.html.php3"); + +print << +
+
+ + + + +
+ + +
+ Subscription Analysis for $login  +
+
+ + +
+$prev_str up to $now_str +EOM; +?> + +

+ + + + + + += '$prev_str' ORDER BY AcctStartTime ASC $limit;"); + if ($search){ + while( $row = @da_sql_fetch_array($search,$config) ){ + $tr_color='white'; + $num++; + $acct_type = "$row[FramedProtocol]/$row[NASPortType]"; + $acct_logedin = $row[AcctStartTime]; + $acct_sessiontime = $row[AcctSessionTime]; + $acct_sessiontime_sum += $acct_sessiontime; + $acct_sessiontime = time2str($acct_sessiontime); + $acct_ip = $row[FramedIPAddress]; + if ($acct_ip == '') + $acct_ip = '-'; + $acct_upload = $row[AcctInputOctets]; + $acct_upload_sum += $acct_upload; + $acct_upload = bytes2str($acct_upload); + $acct_download = $row[AcctOutputOctets]; + $acct_download_sum += $acct_download; + $acct_download = bytes2str($acct_download); + $acct_server = $da_name_cache[$row[NASIPAddress]]; + if (!isset($acct_server)){ + $acct_server = gethostbyaddr($row[NASIPAddress]); + $da_name_cache[$row[NASIPAddress]] = $acct_server; + } + $acct_server = "$acct_server:$row[NASPortId]"; + $acct_terminate_cause = "$row[AcctTerminateCause]"; + if ($acct_terminate_cause == '') + $acct_terminate_cause = '-'; + if (ereg('Login-Incorrect',$acct_terminate_cause) || + ereg('Multiple-Logins', $acct_terminate_cause) || ereg('Invalid-User',$acct_terminate_cause)) + $tr_color='#ffe8e0'; + $acct_callerid = "$row[CallingStationId]"; + if ($acct_callerid == '') + $acct_callerid = '-'; + echo << + + + + + + + + + + + +EOM; + } + $acct_sessiontime_sum = time2str($acct_sessiontime_sum); + $acct_upload_sum = bytes2str($acct_upload_sum); + $acct_download_sum = bytes2str($acct_download_sum); + } +} +echo << + + + + + + + + + +
#typelogged insession timeip addressuploaddownloadserverterminate causecallerid
$num$acct_type$acct_logedin$acct_sessiontime$acct_ip$acct_upload$acct_download$acct_server$acct_terminate_cause$acct_callerid
Page Total$acct_sessiontime_sum $acct_upload_sum$acct_download_sum   
+

+
+
+ + + + + + + + + + + +EOM; +?> + + +
+ + the from date matches any login after the 00:00 that day, + and the to date any login before the 23:59 that day. + the default values shown are the current week. +
userfrom dateto datepagesize
+ +
+
+ + diff --git a/htdocs/user_admin.php3 b/htdocs/user_admin.php3 new file mode 100644 index 0000000..e84b641 --- /dev/null +++ b/htdocs/user_admin.php3 @@ -0,0 +1,225 @@ + + +user information page + + + +
+
+User Name   + +  does not exist
+ + + +EOM; + exit(); + } +} + +if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php3")) + include_once("../lib/sql/drivers/$config[sql_type]/functions.php3"); +else{ + echo <<user information page + + + +
+Could not include SQL library functions. Aborting + + +EOM; + exit(); +} + +$weekly_limit = ($item_vals['Max-Weekly-Session'][0] != '') ? $item_vals['Max-Weekly-Session'][0] : $default_vals['Max-Weekly-Session']; +$weekly_limit = ($weekly_limit) ? $weekly_limit : $config[counter_default_weekly]; +$daily_limit = ($item_vals['Max-Daily-Session'][0] != '') ? $item_vals['Max-Daily-Session'][0] : $default_vals['Max-Daily-Session']; +$daily_limit = ($daily_limit) ? $daily_limit : $config[counter_default_daily]; +$session_limit = ($item_vals['Session-Timeout'][0] != '') ? $item_vals['Session-Timeout'][0] : $default_vals['Session-Timeout']; +$session_limit = ($session_limit) ? $session_limit : 'none'; + +$now = time(); +$week = $now - 604800; +$now_str = date("$config[sql_date_format]",$now + 86400); +$week_str = date("$config[sql_date_format]",$week); +$day = date('w'); +$week_start = date($config[sql_date_format],$now - ($day)*86400); +$today = $day; +$now_tmp = $now; +for ($i = $day; $i >-1; $i--){ + $days[$i] = date($config[sql_date_format],$now_tmp); + $now_tmp -= 86400; +} +$day++; +//$now -= ($day * 86400); +$now -= 604800; +$now += 86400; +for ($i = $day; $i <= 6; $i++){ + $days[$i] = date($config[sql_date_format],$now); +// $now -= 86400; + $now += 86400; +} + +$daily_used = $weekly_used = $monthly_used = $lastlog_session_time = '-'; +$extra_msg = ''; +$used = array('-','-','-','-','-','-','-'); + +$link = @da_sql_pconnect($config); +if ($link){ + $search = @da_sql_query($link,$config, + "SELECT sum(AcctSessionTime),sum(AcctInputOctets),sum(AcctOutputOctets), + avg(AcctSessionTime),avg(AcctInputOctets),avg(AcctOutputOctets),COUNT(*) FROM + $config[sql_accounting_table] WHERE UserName = '$login' + AND AcctStopTime >= '$week_str' AND AcctStopTime <= '$now_str';"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $tot_time = time2str($row['sum(AcctSessionTime)']); + $tot_input = bytes2str($row['sum(AcctInputOctets)']); + $tot_output = bytes2str($row['sum(AcctOutputOctets)']); + $avg_time = time2str($row['avg(AcctSessionTime)']); + $avg_input = bytes2str($row['avg(AcctInputOctets)']); + $avg_output = bytes2str($row['avg(AcctOutputOctets)']); + $tot_conns = $row['COUNT(*)']; + } + for($i = 0; $i <=6; $i++){ + if ($days[$i] == '') + continue; + $search = @da_sql_query($link,$config, + "SELECT sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE + UserName = '$login' AND AcctStopTime LIKE '$days[$i]%';"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $used[$i] = $row['sum(AcctSessionTime)']; + if ($used[$i] > $daily_limit) + $used[$i] = "" . time2str($used[$i]) . ""; + else + $used[$i] = time2str($used[$i]); + if ($today == $i){ + $daily_used = $row['sum(AcctSessionTime)']; + $remaining = $daily_limit - $daily_used; + if ($remaining <=0) + $remaining = 0; + $log_color = ($remaining) ? 'green' : 'red'; + if (!$remaining) + $extra_msg = '(Out of daily quota)'; + $daily_used = time2str($daily_used); + if (!$remaining) + $daily_used = "$daily_used"; + } + } + } + $search = @da_sql_query($link,$config, + "SELECT sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE + UserName = '$login' AND AcctStopTime >= '$week_start' AND + AcctStopTime <= '$now_str';"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $weekly_used = $row['sum(AcctSessionTime)']; + $tmp = $weekly_limit - $weekly_used; + if ($tmp <=0){ + $tmp = 0; + $extra_msg .= '(Out of weekly quota)'; + } + if ($remaining > $tmp) + $remaining = $tmp; + $log_color = ($remaining) ? 'green' : 'red'; + $weekly_used = time2str($weekly_used); + if (!$tmp) + $weekly_used = "$weekly_used"; + } + $search = @da_sql_query($link,$config, + "SELECT * FROM $config[sql_accounting_table] + WHERE UserName = '$login' AND AcctStopTime = '0' + ORDER BY AcctStartTime DESC LIMIT 1;"); + if ($search){ + if (@da_sql_num_rows($search,$config)){ + $logged_now = 1; + $row = @da_sql_fetch_array($search,$config); + $lastlog_time = $row['AcctStartTime']; + $lastlog_server_ip = $row['NASIPAddress']; + $lastlog_server_port = $row['NASPortId']; + $lastlog_session_time = date2timediv($lastlog_time); + $remaining = $daily_limit - $lastlog_session_time; + if ($remaining < 0) + $remaining = 0; + $log_color = ($remaining) ? 'green' : 'red'; + $lastlog_session_time_jvs = 1000 * $lastlog_session_time; + $lastlog_session_time = time2strclock($lastlog_session_time); + $lastlog_client_ip = $row['FramedIPAddress']; + $lastlog_server_name = gethostbyaddr($lastlog_server_ip); + $lastlog_client_name = gethostbyaddr($lastlog_client_ip); + $lastlog_input = $row['AcctInputOctets']; + if ($lastlog_input) + $lastlog_input = bytes2str($lastlog_input); + else + $lastlog_input = 'not available'; + $lastlog_output = $row['AcctOutputOctets']; + if ($lastlog_output) + $lastlog_input = bytes2str($lastlog_output); + else + $lastlog_output = 'not available'; + } + } + if (! $logged_now){ + $search = @da_sql_query($link,$config, + "SELECT * FROM $config[sql_accounting_table] + WHERE UserName = '$login' AND AcctSessionTime != '0' + ORDER BY AcctStopTime DESC LIMIT 1;"); + if ($search){ + if (@da_sql_num_rows($search,$config)){ + $row = @da_sql_fetch_array($search,$config); + $lastlog_time = $row['AcctStartTime']; + $lastlog_server_ip = $row['NASIPAddress']; + $lastlog_server_port = $row['NASPortId']; + $lastlog_session_time = time2str($row['AcctSessionTime']); + $lastlog_client_ip = $row['FramedIPAddress']; + $lastlog_server_name = gethostbyaddr($lastlog_server_ip); + $lastlog_client_name = gethostbyaddr($lastlog_client_ip); + $lastlog_input = $row['AcctInputOctets']; + $lastlog_input = bytes2str($lastlog_input); + $lastlog_output = $row['AcctOutputOctets']; + $lastlog_output = bytes2str($lastlog_output); + } + else + $not_known = 1; + } + } +} + +$monthly_limit = time2str($monthly_limit); +$weekly_limit = time2str($weekly_limit); +$daily_limit = time2str($daily_limit); +$session_limit = time2str($session_limit); +$remaining = time2str($remaining); + +if ($item_vals['Dialup-Access'][0] == 'FALSE') + $msg =<< The user account is locked +EON; +else + $msg =<< $remaining $extra_msg +EON; +$lock_msg = $item_vals['Dialup-Lock-Msg'][0]; +if ($lock_msg != '') + $descr =<<$lock_msg +EON; +else + $descr = '-'; + +require('../html/user_admin.html.php3'); diff --git a/htdocs/user_delete.php3 b/htdocs/user_delete.php3 new file mode 100644 index 0000000..b41bf27 --- /dev/null +++ b/htdocs/user_delete.php3 @@ -0,0 +1,76 @@ + + +delete user $login ($cn) + + + +
+ + + + +
+ + +EOM; + +include("../html/user_toolbar.html.php3"); + +print << + +
+
+ + + + +
+ + +
+ User $login Deletion  +
+
+ + +
+EOM; + +if ($delete_user == 1){ + if (is_file("../lib/$config[general_lib_type]/delete_user.php3")) + include("../lib/$config[general_lib_type]/delete_user.php3"); + echo <<
+
+ + +EOM; + exit(); +} +?> + + > + + + + + +
+Are you sure you want to delete user ? +
+
+ + +
+
+ + diff --git a/htdocs/user_edit.php3 b/htdocs/user_edit.php3 new file mode 100644 index 0000000..c53d79f --- /dev/null +++ b/htdocs/user_edit.php3 @@ -0,0 +1,134 @@ + + +subscription configuration for $login ($cn) + + + +
+ + + + +
+ + +EOM; + +include("../html/user_toolbar.html.php3"); + +print << + +
+
+ + + + +
+ + +
+ User Preferences for $login ($cn)  +
+
+ + +
+EOM; + +if ($change == 1){ + if (is_file("../lib/$config[general_lib_type]/change_attrs.php3")) + include("../lib/$config[general_lib_type]/change_attrs.php3"); + if ($passwd != '' && is_file("../lib/$config[general_lib_type]/change_passwd.php3")) + include("../lib/$config[general_lib_type]/change_passwd.php3"); + if (is_file("../lib/$config[general_lib_type]/user_info.php3")) + include("../lib/$config[general_lib_type]/user_info.php3"); +} +else if ($badusers == 1){ + if (is_file("../lib/add_badusers.php3")) + include("../lib/add_badusers.php3"); +} + +?> +
+ > + + + + + + + + + $desc){ + $name = $attrmap["$key"]; + if ($name == 'none') + continue; + unset($vals); + if (count($item_vals["$key"])){ + for($i=0;$i<$item_vals["$key"][count];$i++) + $vals[] = $item_vals["$key"][$i]; + } + else + $vals[] = $default_vals["$key"]; + if ($add && $name == $add_attr) + array_push($vals, $default_vals["$key"]); + + $i = 0; + foreach($vals as $val){ + $name1 = $name . $i; + $i++; + print << + + + +EOM; + } + } +?> + + + + +
+User Password (changes only) + + +
+$desc + + +
+Add Attribute + + +
+
+ +

+ +
+
+
+ + diff --git a/htdocs/user_finger.php3 b/htdocs/user_finger.php3 new file mode 100644 index 0000000..a66c222 --- /dev/null +++ b/htdocs/user_finger.php3 @@ -0,0 +1,152 @@ + + + +User Finger Facility + + + + + +
+Could not include SQL library functions. Aborting + + +EOM; + exit(); +} + +$date = strftime('%A, %e %B %Y, %T %Z'); + +$link = @da_sql_pconnect($config); +$link2 = connect2db($config); +if ($link){ + $h = 21; + while(1){ + $i++; + $num = 0; + $nas = 'nas' . $i; + $name = $nas . '_name'; + $model = $nas . '_model'; + $community = $nas . '_community'; + $ip = $nas . '_ip'; + $portnum = $nas . '_port_num'; + + if ($config[$name] == ''){ + $i--; + break; + } + $name_data = $config[$ip]; + $community_data = $config[$community]; + $server_name[$i] = $config[$name]; + $server_model[$i] = $config[$model]; + $users=exec("$config[general_snmpfinger_bin] $name_data $community_data"); + if (strlen($users)) + $extra = "AND UserName IN ($users)"; + else + $extra = ""; + $search = @da_sql_query($link,$config, + "SELECT DISTINCT UserName,AcctStartTime,FramedIPAddress,CallingStationId + FROM $config[sql_accounting_table] WHERE + AcctStopTime = '0' AND NASIPAddress = '$name_data' $extra + GROUP BY UserName ORDER BY AcctStartTime;"); + if ($search){ + while($row = @da_sql_fetch_array($search,$config)){ + $num++; + $h += 21; + $user = $row['UserName']; + $finger_info[$i][$num]['ip'] = $row['FramedIPAddress']; + if ($finger_info[$i][$num]['ip'] == '') + $finger_info[$i][$num]['ip'] = '-'; + $session_time = $row['AcctStartTime']; + $session_time = date2timediv($session_time); + $finger_info[$i][$num]['session_time'] = time2strclock($session_time); + $finger_info[$i][$num]['user'] = $user; + $finger_info[$i][$num]['callerid'] = $row['CallingStationId']; + if ($finger_info[$i][$num]['callerid'] == '') + $finger_info[$i][$num]['callerid'] = '-'; + if ($user_info["$user"] == ''){ + $user_info["$user"] = get_user_info($link2,$user,$config); + if ($user_info["$user"] == '' || $user_info["$user"] == ' ') + $user_info["$user"] = 'Unknown User'; + } + } + $height[$i] = $h; + } + $server_loggedin[$i] = $num; + $server_rem[$i] = ($config[$portnum]) ? ($config[$portnum] - $num) : 'unknown'; + } +} +?> + + +
+ + + + +
+
+ + + + + +
+ + +
+ Online Users  +
+
+ + +
+$date +EOM; + for($j = 1; $j <= $i; $j++){ + echo << + + + +
$server_name[$j]
$server_model[$j]
$server_loggedin[$j] users connected$server_rem[$j] free lines
+
+ + + + +EOM; + for( $k = 1; $k <= $server_loggedin[$j]; $k++){ + $user = $finger_info[$j][$k][user]; + $time = $finger_info[$j][$k][session_time]; + $ip = $finger_info[$j][$k][ip]; + $cid = $finger_info[$j][$k][callerid]; + $inf = $user_info[$user]; + echo << + + +EOM; + } + + echo << + +EOM; +} +?> + +
#userip addresscaller idnameduration
$k$user$ip$cid$inf$time
+
+

+ diff --git a/htdocs/user_new.php3 b/htdocs/user_new.php3 new file mode 100644 index 0000000..0837a68 --- /dev/null +++ b/htdocs/user_new.php3 @@ -0,0 +1,145 @@ + + + + +New user creation page + + + +

+ + + + +
+ +
+ + + + + +
+ + +
+ User Preferences for new user  +
+
+ + +
+ +The username $login already exists in the user database +EOM; + } + else{ + if (is_file("../lib/$config[general_lib_type]/create_user.php3")) + include("../lib/$config[general_lib_type]/create_user.php3"); + } +} +?> +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +EOM; + foreach($show_attrs as $key => $desc){ + $name = $attrmap["$key"]; + if ($name == 'none') + continue; + $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"]; + print << + + + +EOM; + } +?> +
+ Username + + +
+ Password + + +
+ Name (First Name Surname) + + +
+ Mail + + +
+ Departement + + +
+ Home Phone + + +
+ Work Phone + + +
+ Mobile Phone + + +
+$desc + + +
+
+ +

+ +
+
+
+ + diff --git a/htdocs/user_state.php3 b/htdocs/user_state.php3 new file mode 100644 index 0000000..e9a31d9 --- /dev/null +++ b/htdocs/user_state.php3 @@ -0,0 +1,55 @@ + 'TRUE','Dialup-Lock-Msg' => '-', + 'Max-Weekly-Session' => 0,'Max-Daily-Session' => 0); +foreach($vars as $key => $val){ + $val = ($item_vals["$key"][0] != "") ? $item_vals["$key"][0] : $default_vals["$key"]; + $vars["$key"]=$val; +} +$vars['Dialup-Access'] = ($vars['Dialup-Access'] == 'FALSE') ? 'inactive' : 'active'; +$vars['Max-Daily-Session'] = time2strclock($vars['Max-Daily-Session']); +$vars['Max-Weekly-Session'] = time2strclock($vars['Max-Weekly-Session']); + +$now = time(); +$week = $now - date('w') * 86400; +$now_str = date("$config[sql_date_format]",$now + 86400); +$week_str = date("$config[sql_date_format]",$week); +$today = date("$config[sql_date_format]",$now); + +$link = @da_sql_pconnect($config); +if ($link){ + $search = @da_sql_query($link,$config, + "SELECT COUNT(*), sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE + UserName = '$login' AND AcctStopTime >= '$week_str' AND + AcctStopTime <= '$now_str';"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $weekly_used = time2strclock($row['sum(AcctSessionTime)']); + $weekly_conns = $row['COUNT(*)']; + } + $search = @da_sql_query($link,$config, + "SELECT COUNT(*),sum(AcctSessionTime) FROM $config[sql_accounting_table] WHERE + UserName = '$login' AND AcctStopTime LIKE '$today%';"); + if ($search){ + $row = @da_sql_fetch_array($search,$config); + $daily_used = time2strclock($row['sum(AcctSessionTime)']); + $daily_conns = $row['COUNT(*)']; + } +} + + +foreach($vars as $val){ + echo "$val\n"; +} +echo "$weekly_used\n$weekly_conns\n$daily_used\n$daily_conns"; +?> diff --git a/htdocs/user_test.php3 b/htdocs/user_test.php3 new file mode 100644 index 0000000..e28bb68 --- /dev/null +++ b/htdocs/user_test.php3 @@ -0,0 +1,184 @@ + + +test user $login ($cn) + + + +
+ + + + +
+ + +EOM; + +if (!$test_login) + include("../html/user_toolbar.html.php3"); + +print << + +
+
+ + + + +
+ + +
+EOM; + +if ($test_login){ + print <<Radius Server Test Page  +EOM; +}else{ + print <<User $login Test Page  +EOM; +} +?> +
+
+ + +
+ +' . $tmp_file; + $fp = popen("$comm","w"); + if ($fp){ + foreach ($req as $val){ + fwrite($fp,$val); + } + if ($test_login){ + $test=1; + fwrite($fp, "User-Name = \"$config[general_test_account_login]\"\n"); + fwrite($fp, "Password = \"$config[general_test_account_password]\"\n"); + pclose($fp); + } + else{ + fwrite($fp, "User-Name = \"$login\"\n"); + if ($auth_proto == 'pap') + fwrite($fp, "Password = \"$passwd\"\n"); + else if ($auth_proto == 'chap') + fwrite($fp, "CHAP-Password = \"$passwd\"\n"); + pclose($fp); + } + $reply = file($tmp_file); + unlink($tmp_file); + if (ereg('code 2', $reply[0])) + $msg = "Authentication was successful"; + else if (ereg('code 3',$reply[0])) + $msg = "Authentication failed"; + else if (ereg('no response from server', $reply[0])) + $msg = "No response from server"; + else if (ereg('Connection refused',$reply[0])) + $msg = "Connection was refused"; + if ($test_login) + $msg .= " (test user $login)
\n"; + else + $msg .= "

\n"; + array_shift($reply); + if (count($reply)){ + $msg .= "
Server response:
\n"; + foreach ($reply as $val){ + $msg .= "$val
\n"; + } + } + if ($test_login){ + print << +
+
+ + +EOM; + exit(); + } + + } +} +?> +
+ > + + + + + + + + + + + + + + + + + + + +
+User Password + + +
+Radius Server + + +
+Radius Server Port + + +
+Authentication Protocol + + +
+
+ +
+ +$msg +EOM; +} +?> +
+
+ + diff --git a/html/stats.html.php3 b/html/stats.html.php3 new file mode 100644 index 0000000..ce1809e --- /dev/null +++ b/html/stats.html.php3 @@ -0,0 +1,270 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
from dateto dateuseron server 
+

+ + + + + +
+ + +   + statistics period:
+$after up to $before +EOM; +?> +
+

access statistics

+ + + + +
+
+ statistics for +all users +EOM; +else + echo <<$login +EOM; +?> +
+
+ + + + +

+
+
+ + + + + + + +
+
+ + + + +
+ + + + +
+
+
+
+ + + + + +
+ + +
+ Daily Analysis  +
+
+ + +
+

+ + + +$message[$column1] + + +EOM; +?> + + + + + + + + + + + + + +EOM; +} +?> +
date$message[$column2]$message[$column3]
$day{$data[$day][1]}{$perc[$day][1]} + + + + +
the $message[$column1] for $day is {$data[$day][1]}
+
{$data[$day][2]}{$perc[$day][2]} + + + + +
the $message[$column3] for $day is {$data[$day][2]}
+
{$data[$day][3]}{$perc[$day][3]} + + + + +
the $message[$column3] for $day is {$data[$day][3]}
+
+

+
+
+

+ + + + + +
+ + +
+ Daily Summary  +
+
+ +
+

+ + + +$message[$column1] + + +EOM; +?> + + + + + + + + + + + + + + + + + + + +EOM; +?> +
 $message[$column2]$message[$column3]
maximum{$data[max][1]}{$data[max][2]}{$data[max][3]}
average{$data[avg][1]}{$data[avg][2]}{$data[avg][3]}
sum{$data[sum][1]}{$data[sum][2]}{$data[sum][3]}
+

+
+ + +

+
+ + diff --git a/html/user_admin.html.php3 b/html/user_admin.html.php3 new file mode 100644 index 0000000..066ea22 --- /dev/null +++ b/html/user_admin.html.php3 @@ -0,0 +1,413 @@ +user information for $cn + + + +EOM; +if ($logged_now) + print << + + +EOM; + +print << + + + + +
+ +EOM; + +include("../html/user_toolbar.html.php3"); + +print << +
+
+ + +
+ + + +
+ + +
+ Connection Status for $login ($cn)  +
+
+ +
+ + +EOM; +if ($logged_now){ + print << + + + + + + + + +EOM; +}else if ($not_known) print << +EOM; +else print << + + + + + + + +EOM; + +print << + +
+ User is online since + + $lastlog_time +
+ Connection Duration + + +
+ User IP Address + + $lastlog_client_name ($lastlog_client_ip) +
+ NAS Server + + $lastlog_server_name ($lastlog_server_ip) +
+ NAS Port + + $lastlog_server_port +
+ Upload + + $lastlog_input +
+ Download + + $lastlog_output +
+ This user has never connected + - +
+ User is not online now
+
- +
+ Last Connection Time + + $lastlog_time +
+ IP Address + + $lastlog_client_name ($lastlog_client_ip) +
+ Online Time + + $lastlog_session_time +
+ NAS Server + + $lastlog_server_name ($lastlog_server_ip) +
+ NAS Port + + $lastlog_server_port +
+ Upload + + $lastlog_input +
+ Download + + $lastlog_output +
+ Allowed Session + + $msg +
+ Usefull User Description + + $descr +
+
+
+ +EOM; + +if (is_file("../lib/$config[general_lib_type]/password_check.php3")) + include("../lib/$config[general_lib_type]/password_check.php3"); + +echo << + + + + +
+ + +
+ Account Status For The Last 7 Days  +
+
+ +
+ + + + + + + + +
Connections + $tot_conns
Online time + $tot_time
Upload + $tot_input
Download + $tot_output
Average Time + $avg_time
Average Upload + $avg_input
Average Download + $avg_output
+
+
+
+ + + + +
+ + +
+ Subscription Analysis  +
+
+ +
+ + + + +
-monthlyweeklydailyper session
limit$monthly_limit$weekly_limit$daily_limit$session_limit
used$monthly_used$weekly_used$daily_used$lastlog_session_time
+ + + + + + + + + +
daydaily limitused
sunday$daily_limit$used[0]
monday$daily_limit$used[1]
tuesday$daily_limit$used[2]
wednesday$daily_limit$used[3]
thursday$daily_limit$used[4]
friday$daily_limit$used[5]
saturday$daily_limit$used[6]
+
+
+EOM; + +if ($user_info) print << + + + + + +
+ Personal Information +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ name + + $cn +
+ name ($config[general_prefered_lang_name]) + + $cn_lang +
+ departement + + $ou +
+ departement ($config[general_prefered_lang_name]) + + $ou_lang +
+ title + + $title +
+ title ($config[general_prefered_lang_name]) + + $title_lang +
+ address + + $homeaddress +
+ address ($config[general_prefered_lang_name]) + + $homeaddress_lang +
+ phone + + $telephonenumber +
+ home phone + + $homephone +
+ mobile + + $mobile +
+ fax + + $fax +
+ home page + + $url +
+ e-mail + + $mail +
+ e-mail alias + + $mailalt +
+
+ + +EOM; +?> + + + + + startcounter(); + +EOM; +?> + + + diff --git a/html/user_toolbar.html.php3 b/html/user_toolbar.html.php3 new file mode 100644 index 0000000..456a638 --- /dev/null +++ b/html/user_toolbar.html.php3 @@ -0,0 +1,18 @@ + + +SHOW + +EDIT + +ACCOUNTING + +BADUSERS + +DELETE + +TEST + +EOM; +?> diff --git a/lib/acctshow.php3 b/lib/acctshow.php3 new file mode 100644 index 0000000..3ba0d66 --- /dev/null +++ b/lib/acctshow.php3 @@ -0,0 +1,13 @@ + diff --git a/lib/add_badusers.php3 b/lib/add_badusers.php3 new file mode 100644 index 0000000..7ed0574 --- /dev/null +++ b/lib/add_badusers.php3 @@ -0,0 +1,25 @@ +Could not include SQL library
\n"; + exit(); +} + +$date=date($config[sql_full_date_format]); +$msg = $$attrmap['Dialup-Lock-Msg']; +if ($msg == '') + echo "Lock Message should not be empty
\n"; +else{ + $link = @da_sql_pconnect($config); + if ($link){ + $r = da_sql_query($link,$config, + "INSERT INTO $config[sql_badusers_table] (UserName,Date,Reason) + VALUES ('$login','$date','$msg');"); + if (!$r) + echo "SQL Error:" . da_sql_error($link) . "
\n"; + } + else + echo "SQL Error: Could not connect to sql server(" . da_sql_error($link) . ")
\n"; +} +?> diff --git a/lib/attrshow.php3 b/lib/attrshow.php3 new file mode 100644 index 0000000..8c26f14 --- /dev/null +++ b/lib/attrshow.php3 @@ -0,0 +1,11 @@ + diff --git a/lib/crypt/clear.php3 b/lib/crypt/clear.php3 new file mode 100644 index 0000000..a4771d1 --- /dev/null +++ b/lib/crypt/clear.php3 @@ -0,0 +1,6 @@ + diff --git a/lib/crypt/crypt.php3 b/lib/crypt/crypt.php3 new file mode 100644 index 0000000..037c418 --- /dev/null +++ b/lib/crypt/crypt.php3 @@ -0,0 +1,12 @@ + diff --git a/lib/crypt/md5.php3 b/lib/crypt/md5.php3 new file mode 100644 index 0000000..7d0c2cc --- /dev/null +++ b/lib/crypt/md5.php3 @@ -0,0 +1,6 @@ + diff --git a/lib/defaults.php3 b/lib/defaults.php3 new file mode 100644 index 0000000..1bdce8f --- /dev/null +++ b/lib/defaults.php3 @@ -0,0 +1,11 @@ + 524288) + $str = sprintf("%5.2f MBs", $bytes/1048576); + else + $str = sprintf("%5.2f KBs", $bytes/1024); + + return $str; +} + +function nothing($ret) +{ + return $ret; +} +?> diff --git a/lib/lang/default/utf8.php3 b/lib/lang/default/utf8.php3 new file mode 100644 index 0000000..aea4837 --- /dev/null +++ b/lib/lang/default/utf8.php3 @@ -0,0 +1,11 @@ + diff --git a/lib/lang/el/utf8.php3 b/lib/lang/el/utf8.php3 new file mode 100644 index 0000000..8048ea7 --- /dev/null +++ b/lib/lang/el/utf8.php3 @@ -0,0 +1,49 @@ +"~@", ""=>"~A", "‚"=>"~B", "ƒ"=>"~C", "„"=>"~D", "…"=>"~E", + "†"=>"~F", "‡"=>"~G", "ˆ"=>"~H", "‰"=>"~I", "Š"=>"~J", "‹"=>"~K", + "Œ"=>"~L", ""=>"~M", "Ž"=>"~N", ""=>"~O", ""=>"~P", "‘"=>"~Q", + "’"=>"~R", "“"=>"~S", "”"=>"~T", "•"=>"~U", "–"=>"~V", "—"=>"~W", + "ž"=>"~^", "Ÿ"=>"~_", " "=>"| ", "ʽ"=>"¡", "ʼ"=>"¢", "£"=>"£", + "�"=>"¤", "�"=>"¥", "¦"=>"¦", "§"=>"§", "¨"=>"¨", "©"=>"©", + "�"=>"ª", "«"=>"«", "¬"=>"¬", "­"=>"­", "�"=>"®", "―"=>"¯", + "°"=>"°", "±"=>"±", "²"=>"²", "³"=>"³", "΄"=>"´", "΅"=>"µ", + "Ά"=>"¶", "·"=>"·", "Έ"=>"¸", "Ή"=>"¹", "Ί"=>"º", "»"=>"»", + "Ό"=>"¼", "½"=>"½", "Ύ"=>"¾", "Ώ"=>"¿", "ΐ"=>"À", "Α"=>"Á", + "Β"=>"Â", "Γ"=>"Ã", "Δ"=>"Ä", "Ε"=>"Å", "Ζ"=>"Æ", "Η"=>"Ç", + "Θ"=>"È", "Ι"=>"É", "Κ"=>"Ê", "Λ"=>"Ë", "Μ"=>"Ì", "Ν"=>"Í", + "Ξ"=>"Î", "Ο"=>"Ï", "Π"=>"Ð", "Ρ"=>"Ñ", "�"=>"Ò", "Σ"=>"Ó", + "Τ"=>"Ô", "Î¥"=>"Õ", "Φ"=>"Ö", "Χ"=>"×", "Ψ"=>"Ø", "Ω"=>"Ù", + "Ϊ"=>"Ú", "Ϋ"=>"Û", "ά"=>"Ü", "έ"=>"Ý", "ή"=>"Þ", "ί"=>"ß", + "ΰ"=>"à", "α"=>"á", "β"=>"â", "γ"=>"ã", "δ"=>"ä", "ε"=>"å", + "ζ"=>"æ", "η"=>"ç", "θ"=>"è", "ι"=>"é", "κ"=>"ê", "λ"=>"ë", + "μ"=>"ì", "ν"=>"í", "ξ"=>"î", "ο"=>"ï", "π"=>"ð", "ρ"=>"ñ", + "ς"=>"ò", "σ"=>"ó", "τ"=>"ô", "υ"=>"õ", "φ"=>"ö", "χ"=>"÷", + "ψ"=>"ø", "ω"=>"ù", "ϊ"=>"ú", "ϋ"=>"û", "ό"=>"ü", "ύ"=>"ý", + "ώ"=>"þ", "˜"=>"~X", "™"=>"~Y", "š"=>"~Z", "›"=>"~[", ""=>"~]" + ); + + return $k; +} + +function decode_string($line,$k) +{ + $line = ereg_replace("&","&&",$line); + $line = ereg_replace("([,+0-9./() -])", "%\\1", $line); + $mline = chunk_split($line, 2, " "); + $chars = explode(" ", $mline); + foreach ($chars as $c){ + $val = $k["$c"]; + $c = ($val != "") ? "$val" : "$c"; + $new_line .= $c; + } + $new_line = ereg_replace("%%", " ", $new_line); + $new_line = ereg_replace("%([,+0-9./() -])", "\\1", $new_line); + $new_line = ereg_replace("%", " ",$new_line); + $new_line = ereg_replace("&&","&",$new_line); + + return $new_line; +} +?> diff --git a/lib/ldap/attrmap.php3 b/lib/ldap/attrmap.php3 new file mode 100644 index 0000000..f7a3199 --- /dev/null +++ b/lib/ldap/attrmap.php3 @@ -0,0 +1,21 @@ + diff --git a/lib/ldap/change_attrs.php3 b/lib/ldap/change_attrs.php3 new file mode 100644 index 0000000..7a0ea52 --- /dev/null +++ b/lib/ldap/change_attrs.php3 @@ -0,0 +1,67 @@ + $attr){ + if ($attrmap["$key"] == 'none') + continue; + $i = $j = 0; + $name = $attrmap["$key"] . $i; + + while (isset($$name)){ + $val = $$name; + $i++; + $name = $attrmap["$key"] . $i; +// +// if value is the same as the default and the corresponding attribute in ldap does not exist or +// the value is the same as that in ldap then continue +// + if ( ($val == $default_vals["$key"] && !isset($item_vals["$key"][$j])) || + $val == $item_vals["$key"][$j]) + continue; +// +// if value is null and ldap attribute does not exist then continue +// + if ($val == '' && !isset($item_vals["$key"][$j])) + continue; +// +// if values is the same as the default or if the value is null and the ldap attribute exists +// then delete them +// + if (($val == $default_vals["$key"] || $val == '') && + isset($item_vals["$key"][$j])) + $del[$attrmap["$key"]] = $item_vals["$key"][$j]; +// +// else modify the ldap attribute +// + else{ + if (isset($item_vals["$key"][$j])){ + $mod[$attrmap["$key"]] = $item_vals["$key"][$j]; + $add_r[$attrmap["$key"]] = $val; + } + else{ + $add_r[$attrmap["$key"]] = $val; + } + } + $j++; + } + } + if (isset($mod)){ + @ldap_mod_del($ds,$dn,$mod); + } + if (isset($add_r)){ + @ldap_mod_add($ds,$dn,$add_r); + } + if (isset($del)){ + @ldap_mod_del($ds,$dn,$del); + } + } + if (@ldap_error($ds) == 'Success') + echo "The changes were successfully commited to the directory
\n"; + else + echo "LDAP ERROR: " . ldap_error($ds) . "
\n"; + @ldap_close($ds); + } +?> diff --git a/lib/ldap/change_passwd.php3 b/lib/ldap/change_passwd.php3 new file mode 100644 index 0000000..b032cdd --- /dev/null +++ b/lib/ldap/change_passwd.php3 @@ -0,0 +1,20 @@ +LDAP ERROR: " . ldap_error($ds) . "
\n"; + } + else + echo "Could not open encryption library file.
\n"; + } + @ldap_close($ds); + } +?> diff --git a/lib/ldap/create_user.php3 b/lib/ldap/create_user.php3 new file mode 100644 index 0000000..d18f117 --- /dev/null +++ b/lib/ldap/create_user.php3 @@ -0,0 +1,58 @@ +Could not open encryption library file.Password will be clear text.
\n"; + $new_user_entry[$attrmap['User-Password']]="{clear}" . $passwd; + } + + print_r($new_user_entry); + + @ldap_add($ds,$dn,$new_user_entry); + + foreach($show_attrs as $key => $attr){ + if ($attrmap["$key"] == 'none') + continue; +// +// if value is the same as the default and the corresponding attribute in ldap does not exist or +// the value is the same as that in ldap then continue +// + if ( $$attrmap["$key"] == $default_vals["$key"]) + continue; + if ( $$attrmap["$key"] == '') + continue; + $mod[$attrmap["$key"]] = $$attrmap["$key"]; + + @ldap_mod_add($ds,$dn,$mod); + } + } + if (@ldap_error($ds) == 'Success') + echo "User was added in user database
\n"; + else + echo "LDAP ERROR: " . ldap_error($ds) . "
\n"; + @ldap_close($ds); + } +?> diff --git a/lib/ldap/defaults.php3 b/lib/ldap/defaults.php3 new file mode 100644 index 0000000..c5fb4a5 --- /dev/null +++ b/lib/ldap/defaults.php3 @@ -0,0 +1,41 @@ + $val){ + if ($info[0]["$val"][0] != '') + $default_vals["$key"] = $info[0]["$val"][0]; + } + } + } + if ($regular_profile_attr != ''){ + $get_attrs = array("$regular_profile_attr"); + $sr=@ldap_search($ds,"$config[ldap_base]","uid=" . $login,$get_attrs); + if ($info = @ldap_get_entries($ds,$sr)){ + $dn2 = $info[0][$regular_profile_attr][0]; + if ($dn2 != ''){ + $sr2=@ldap_search($ds,"$dn2",'objectclass=*'); + if ($info2 = @ldap_get_entries($ds,$sr2)){ + $dn3 = $info2[0]['dn']; + if ($dn3 != ''){ + foreach($attrmap as $key => $val){ + if ($info2[0]["$val"][0] != '') + $default_vals["$key"] = $info2[0]["$val"][0]; + } + } + } + } + } + } + @ldap_close($ds); + } +} + +?> diff --git a/lib/ldap/delete_user.php3 b/lib/ldap/delete_user.php3 new file mode 100644 index 0000000..1d8aab2 --- /dev/null +++ b/lib/ldap/delete_user.php3 @@ -0,0 +1,14 @@ +User Deleted successfully
\n"; + else + echo "LDAP ERROR: " . ldap_error($ds) . "
\n"; + @ldap_close($ds); + } +} +?> diff --git a/lib/ldap/functions.php3 b/lib/ldap/functions.php3 new file mode 100644 index 0000000..72805d8 --- /dev/null +++ b/lib/ldap/functions.php3 @@ -0,0 +1,27 @@ + diff --git a/lib/ldap/password_check.php3 b/lib/ldap/password_check.php3 new file mode 100644 index 0000000..41dcb9d --- /dev/null +++ b/lib/ldap/password_check.php3 @@ -0,0 +1,23 @@ +YES It is that'; + else + $msg = 'NO It is wrong'; + } + else + $msg = 'User DN is not available. Check your configuration'; + @ldap_close($ds); + } + else + $msg = 'Could not connect to LDAP server'; + echo "$msg\n"; +} +?> + diff --git a/lib/ldap/personattrs.php3 b/lib/ldap/personattrs.php3 new file mode 100644 index 0000000..9807d0d --- /dev/null +++ b/lib/ldap/personattrs.php3 @@ -0,0 +1,11 @@ + diff --git a/lib/ldap/user_info.php3 b/lib/ldap/user_info.php3 new file mode 100644 index 0000000..73242fd --- /dev/null +++ b/lib/ldap/user_info.php3 @@ -0,0 +1,48 @@ + $val){ + $item_vals["$key"] = $info[0]["$val"]; + } + } + @ldap_close($ds); +} +?> diff --git a/lib/sql/attrmap.php3 b/lib/sql/attrmap.php3 new file mode 100644 index 0000000..9524f7d --- /dev/null +++ b/lib/sql/attrmap.php3 @@ -0,0 +1,11 @@ +Could not include SQL library
\n"; + exit(); +} +$link = @da_sql_pconnect($config); +if ($link){ + foreach($show_attrs as $key => $desc){ + if ($attrmap["$key"] == 'none') + continue; + $i = $j = 0; + $name = $attrmap["$key"] . $i; + + while(isset($$name)){ + $val=$$name; + $i++; + $name = $attrmap["$key"] . $i; + + $sql_attr=$attrmap["$key"]; + if ($attr_type["$key"] == 'checkItem') + $table = $config[sql_check_table]; + else if ($attr_type["$key"] == 'replyItem') + $table = $config[sql_reply_table]; + // if value is the same as that in the sql database do nothing + if ($val == $item_vals["$key"][$j]) + continue; + // if value is null and corresponding value exists then delete + else if (($val == $default_vals["$key"] || $val == '') && isset($item_vals["$key"][$j])){ + $res = @da_sql_query($link,$config, + "DELETE FROM $table WHERE UserName = '$login' AND Attribute = '$sql_attr';"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Delete failed for attribute $key
\n"; + } + // if value is null then don't add it + else if ($val == '') + continue; + // if value differs from the sql value then update + else{ + if (isset($item_vals["$key"][$j])) + $res = @da_sql_query($link,$config, + "UPDATE $table SET Value = '$val' WHERE UserName = '$login' AND + Attribute = '$sql_attr';"); + else + $res = @da_sql_query($link,$config, + "INSERT INTO $table (UserName,Attribute,Value) + VALUES ('$login','$sql_attr','$val');"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Change failed for attribute $key
\n"; + } + $j++; + } + } +} +else + echo "Could not connect to database
\n"; diff --git a/lib/sql/change_passwd.php3 b/lib/sql/change_passwd.php3 new file mode 100644 index 0000000..77c5f9e --- /dev/null +++ b/lib/sql/change_passwd.php3 @@ -0,0 +1,41 @@ +Could not include SQL library
\n"; + exit(); +} +$link = @da_sql_pconnect($config); +if ($link){ + if (is_file("../lib/crypt/$config[general_encryption_method].php3")){ + include("../lib/crypt/$config[general_encryption_method].php3"); + $passwd = da_encrypt($passwd); + $res = @da_sql_query($link,$config, + "SELECT Value FROM $config[sql_check_table] WHERE UserName = '$login' + AND Attribute = '$config[sql_password_attribute]';"); + if ($res){ + $row = @da_sql_fetch_array($res,$config); + if ($row){ + $res = @da_sql_query($link,$config, + "UPDATE $config[sql_check_table] SET Value = '$passwd' WHERE + Attribute = '$config[sql_password_attribute]' AND UserName = '$login';"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Error while changing password
\n"; + } + else{ + $res = @da_sql_query($link,$config, + "INSERT INTO $config[sql_check_table] (Attribute,Value,UserName) + VALUES ('$config[sql_password_attribute]','$passwd','$login');"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Error while changing password
\n"; + } + } + else + echo "Error while executing query
\n"; + } + else + echo "Could not open encryption library file
\n"; +} +else + echo "Could not connect to database
\n"; +?> diff --git a/lib/sql/create_user.php3 b/lib/sql/create_user.php3 new file mode 100644 index 0000000..5c580ac --- /dev/null +++ b/lib/sql/create_user.php3 @@ -0,0 +1,63 @@ +Could not include SQL library
\n"; + exit(); +} +$da_abort=0; +$link = @da_sql_pconnect($config); +if ($link){ + if (is_file("../lib/crypt/$config[general_encryption_method].php3")){ + include("../lib/crypt/$config[general_encryption_method].php3"); + $passwd = da_encrypt($passwd); + $res = @da_sql_query($link,$config, + "INSERT INTO $config[sql_check_table] (Attribute,Value,UserName) + VALUES ('$config[sql_password_attribute]','$passwd','$login');"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)){ + echo "Unable to add user $login. SQL error
\n"; + $da_abort=1; + } + if ($config[sql_use_user_info_table] == 'true' && !$da_abort){ + $res = @da_sql_query($link,$config, + "SELECT UserName FROM $config[sql_user_info_table] WHERE + UserName = '$login';"); + if ($res){ + if (!@da_sql_num_rows($res,$config)){ + $res = @da_sql_query($link,$config, + "INSERT INTO $config[sql_user_info_table] + (UserName,Name,Mail,Department,HomePhone,WorkPhone,Mobile) VALUES + ('$login','$cn','$mail','$ou','$telephonenumber','$homephone','$mobile');"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Could not add user information in user info table
\n"; + } + else + echo "User already exists in user info table.
\n"; + } + } + if (!$da_abort){ + foreach($show_attrs as $key => $attr){ + if ($attrmap["$key"] == 'none') + continue; + if ($attr_type[$key] == 'checkItem') + $table = "$config[sql_check_table]"; + else if ($attr_type[$key] == 'replyItem') + $table = "$config[sql_reply_table]"; + $val = $$attrmap["$key"]; + if ($val == '' || $val == $default_vals["$key"]) + continue; + $res = @da_sql_query($link,$config, + "INSERT INTO $table (Attribute,Value,UserName) + VALUES ('$attrmap[$key]','$val','$login');"); + if (!$res || !@da_sql_affected_rows($link,$res,$config)) + echo "Query failed for attribute $key
\n"; + } + } + echo "User created successfully
\n"; + } + else + echo "Could not open encryption library file
\n"; +} +else + echo "Could not connect to database
\n"; +?> diff --git a/lib/sql/delete_user.php3 b/lib/sql/delete_user.php3 new file mode 100644 index 0000000..dee7a02 --- /dev/null +++ b/lib/sql/delete_user.php3 @@ -0,0 +1,33 @@ +Could not include SQL library
\n"; + exit(); +} +$link = @da_sql_pconnect($config); +if ($link){ + $res = @da_sql_query($link,$config, + "DELETE FROM $config[sql_reply_table] WHERE UserName = '$login';"); + if ($res){ + $res = @da_sql_query($link,$config, + "DELETE FROM $config[sql_check_table] WHERE UserName = '$login';"); + if ($res){ + if ($config[sql_use_user_info_table] == 'true'){ + $res = @da_sql_query($config[sql_database], + "DELETE FROM $config[sql_user_info_table] WHERE UserName = '$login';"); + if ($res) + echo "User $login deleted successfully
\n"; + else + echo "Error deleting user $login from user info table
\n"; + } + } + else + echo "Error deleting user $login from check table
\n"; + } + else + echo "Error deleting user $login from reply table
\n"; +} +else + echo "Could not connect to database
\n"; +?> diff --git a/lib/sql/drivers/mysql/functions.php3 b/lib/sql/drivers/mysql/functions.php3 new file mode 100644 index 0000000..b0ff08f --- /dev/null +++ b/lib/sql/drivers/mysql/functions.php3 @@ -0,0 +1,58 @@ + diff --git a/lib/sql/drivers/pg/functions.php3 b/lib/sql/drivers/pg/functions.php3 new file mode 100644 index 0000000..ba88622 --- /dev/null +++ b/lib/sql/drivers/pg/functions.php3 @@ -0,0 +1,87 @@ + '0' and + attrelid = (select oid from pg_class where relname='$table');"); + if ($res){ + $row = @pg_fetch_row($res,0); + if ($row){ + if (!$row[0]) + return NULL; + $fields[num] = $row[0]; + } + } + $res = @pg_exec($link, + "select attname from pg_attribute where attnum > '0' and + attrelid = (select oid from pg_class where relname='$table');"); + if ($res) + $fields[res]=$res; + else + return NULL; + + return $fields; +} + +function da_sql_num_fields($fields,$config) +{ + if ($fields) + return $fields[num]; +} + +function da_sql_field_name($fields,$num,$config) +{ + if ($fields){ + $row = @pg_fetch_row($fields[res],$num); + if ($row) + return $row[0]; + } +} + +function da_sql_error($link,$config) +{ + return pg_errormessage($link); +} +?> diff --git a/lib/sql/functions.php3 b/lib/sql/functions.php3 new file mode 100644 index 0000000..11f8cec --- /dev/null +++ b/lib/sql/functions.php3 @@ -0,0 +1,33 @@ +Could not include SQL library
\n"; + exit(); +} + +function connect2db($config) +{ + $link=@da_sql_pconnect($config); + + return $link; +} + +function get_user_info($link,$user,$config) +{ + if ($link && $config[sql_use_user_info_table] == 'true'){ + $res=@da_sql_query($link,$config, + "SELECT Name FROM $config[sql_user_info_table] WHERE UserName = '$user';"); + if ($res){ + $row = @da_sql_fetch_array($res,$config); + if ($row) + return $row[Name]; + } + } +} + +function closedb($link,$config) +{ + return 1; +} +?> diff --git a/lib/sql/password_check.php3 b/lib/sql/password_check.php3 new file mode 100644 index 0000000..f584fff --- /dev/null +++ b/lib/sql/password_check.php3 @@ -0,0 +1,35 @@ +Could not include SQL library
\n"; + exit(); +} + +if ($action == 'checkpass'){ + $link = @da_sql_pconnect($config); + if ($link){ + $res = @da_sql_query($link,$config, + "SELECT Value FROM $config[sql_check_table] WHERE UserName = '$login' + AND Attribute = '$config[sql_password_attribute]';"); + if ($res){ + $row = @da_sql_fetch_array($res,$config); + if (is_file("../lib/crypt/$config[general_encryption_method].php3")){ + include("../lib/crypt/$config[general_encryption_method].php3"); + $enc_passwd = $row[Value]; + $salt=substr($enc_passwd,0,2); + $passwd = da_encrypt($passwd,$salt); + if ($passwd == $enc_passwd) + $msg = 'YES It is that'; + else + $msg = 'NO It is wrong'; + } + else + echo "Could not open encryption library file
\n"; + } + } + echo "$msg\n"; +} +?> + diff --git a/lib/sql/user_info.php3 b/lib/sql/user_info.php3 new file mode 100644 index 0000000..215f46c --- /dev/null +++ b/lib/sql/user_info.php3 @@ -0,0 +1,62 @@ +Could not include SQL library
\n"; + exit(); +} +$user_exists = 'no'; +$link = @da_sql_pconnect($config); +if ($link){ + $res = @da_sql_query($link,$config, + "SELECT Attribute,Value FROM $config[sql_check_table] WHERE UserName = '$login';"); + if ($res){ + if (@da_sql_num_rows($res,$config)) + $user_exists = 'yes'; + while(($row = @da_sql_fetch_array($res,$config))){ + $attr = $row[Attribute]; + $val = $row[Value]; + $tmp["$attr"][]="$val"; + $tmp["$attr"][count]++; + } + $res = @da_sql_query($link,$config, + "SELECT Attribute,Value FROM $config[sql_reply_table] WHERE UserName = '$login';"); + if ($res){ + while(($row = @da_sql_fetch_array($res,$config))){ + $attr = $row[Attribute]; + $val = $row[Value]; + $tmp["$attr"][] = "$val"; + $tmp["$attr"][count]++; + } + if ($config[sql_use_user_info_table] == 'true'){ + $res = @da_sql_query($link,$config, + "SELECT * FROM $config[sql_user_info_table] WHERE UserName = '$login';"); + if ($res){ + if (($row = @da_sql_fetch_array($res,$config))){ + $cn = ($row[Name]) ? $row[Name] : '-'; + $telephonenumber = ($row[WorkPhone]) ? $row[WorkPhone] : '-'; + $homephone = ($row[HomePhone]) ? $row[HomePhone] : '-'; + $ou = ($row[Depatment]) ? $row[Department] : '-'; + $mail = ($row[Mail]) ? $row[Mail] : '-'; + $mobile = ($row[Mobile]) ? $row[Mobile] : '-'; + } + } + } + } + else + echo "Database query failed partially
\n"; + foreach($attrmap as $key => $val){ + if (isset($tmp[$val])){ + $item_vals["$key"] = $tmp[$val]; + $item_vals["$key"][count] = $tmp[$val][count]; + } + } + + } + else + echo "Database query failed
\n"; +} +else + echo "Could not connect to database
\n"; +?> diff --git a/sql/badusers.sql b/sql/badusers.sql new file mode 100644 index 0000000..09aa8c0 --- /dev/null +++ b/sql/badusers.sql @@ -0,0 +1,10 @@ +# +# Table structure for table 'badusers' +# +CREATE TABLE badusers ( + id int(10) DEFAULT '0' NOT NULL auto_increment, + UserName varchar(30), + Date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, + Reason varchar(200), + PRIMARY KEY (id) +); diff --git a/sql/userinfo.sql b/sql/userinfo.sql new file mode 100644 index 0000000..243a4f5 --- /dev/null +++ b/sql/userinfo.sql @@ -0,0 +1,14 @@ +# +# Table structure for table 'userinfo' +# +CREATE TABLE userinfo ( + id int(10) DEFAULT '0' NOT NULL auto_increment, + UserName varchar(30), + Name varchar(200), + Mail varchar(200), + Department varchar(200), + WorkPhone varchar(200), + HomePhone varchar(200), + Mobile varchar(200), + PRIMARY KEY (id) +);