ALT Linux Bugzilla
– Attachment 2267 Details for
Bug 13426
netams admintool work with mysql only
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
Патч для работы admintool с другими sql db
netams-admin-3.4.0rc2-pg.patch (text/plain), 13.55 KB, created by
Alexey V. Novikov
on 2007-11-14 15:48:44 MSK
(
hide
)
Description:
Патч для работы admintool с другими sql db
Filename:
MIME Type:
Creator:
Alexey V. Novikov
Created:
2007-11-14 15:48:44 MSK
Size:
13.55 KB
patch
obsolete
>diff -uNr netams-3.4.0rc2.orig/cgi-bin/activate.cgi netams-3.4.0rc2/cgi-bin/activate.cgi >--- netams-3.4.0rc2.orig/cgi-bin/activate.cgi 2006-01-13 02:13:23 +0300 >+++ netams-3.4.0rc2/cgi-bin/activate.cgi 2007-11-13 11:32:06 +0300 >@@ -24,7 +24,7 @@ > ($tem1,$tem2)=split /XXXXXXXXX/, $tem; > > if ($cgi->param('action') eq 'do') { >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { $p1.="<b>Unable to connect to SQL database!</b><hr>"; } > > netams_login($sc_host, $sc_port, $sc_user, $sc_passwd); >@@ -99,7 +99,7 @@ > if (defined $log_to_events) { > if ($log_to_events eq "yes") { > use DBI; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { return; } > else { > $dbh->do("INSERT INTO events VALUES (unix_timestamp(),'CGI', ".hex($oid).",0,".hex($oid).",\"$ip\t$action\")"); >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/access.cgi netams-3.4.0rc2/cgi-bin/admin/access.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/access.cgi 2004-07-02 16:09:01 +0400 >+++ netams-3.4.0rc2/cgi-bin/admin/access.cgi 2007-11-13 11:39:52 +0300 >@@ -13,11 +13,11 @@ > > $toppane = "<b>Access Users and Right Management</b>"; > >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { > $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; } > else { >- $p1.="<b>Connected to database $mysql_dbname</b><hr>"; >+ $p1.="<b>Connected to database $sql_dbname</b><hr>"; > } > > if($action eq "delete") { >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/cardtool.cgi netams-3.4.0rc2/cgi-bin/admin/cardtool.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/cardtool.cgi 2007-02-18 15:39:21 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/cardtool.cgi 2007-11-13 11:33:37 +0300 >@@ -26,7 +26,7 @@ > NoAccess(); > } > >-$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { $p1.="<b>Unable to connect to SQL database!</b><hr>"; } > > >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/config.cgi netams-3.4.0rc2/cgi-bin/admin/config.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/config.cgi 2005-11-22 22:35:50 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/config.cgi 2007-11-14 15:12:49 +0300 >@@ -7,7 +7,12 @@ > $sc_host="localhost"; $sc_port=20001; $sc_user="admin"; $sc_passwd="aaa"; > > #login to database >-$mysql_host="localhost"; $mysql_login="root"; $mysql_password=""; $mysql_dbname="netams"; >+# sql_type may be "mysql" and "Pg" >+$sql_type="mysql"; >+$sql_host="localhost"; >+$sql_login="root"; >+$sql_password=""; >+$sql_dbname="netams"; > > #enable or disable billing > $have_billing="yes"; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/graph.cgi netams-3.4.0rc2/cgi-bin/admin/graph.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/graph.cgi 2006-10-12 14:24:15 +0400 >+++ netams-3.4.0rc2/cgi-bin/admin/graph.cgi 2007-11-13 11:34:13 +0300 >@@ -496,7 +496,7 @@ > if ($have_access ne "yes") {return 9;} > $what = shift; > $user = $ENV{REMOTE_USER}; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > $sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'"); > $sth->execute(); > @rights=split //,$sth->fetchrow_array; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/monitor.cgi netams-3.4.0rc2/cgi-bin/admin/monitor.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/monitor.cgi 2006-12-20 08:55:58 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/monitor.cgi 2007-11-13 11:35:03 +0300 >@@ -329,7 +329,7 @@ > $where.=$where1; > $debug.=$where1; > } >- $db = DBI->connect("DBI:mysql:database=".$mysql_dbname.";host=".$mysql_host, $mysql_login, $mysql_password); >+ $db = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if($db eq "") { die "Error database connecting."; } > if ($action eq "Refresh" or $action eq "Refresh_db") { > $v_parse_proto=0 if $v_parse_proto eq ""; >@@ -1253,7 +1253,7 @@ > } > $what = shift; > $user = $ENV{REMOTE_USER}; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > $sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'"); > $sth->execute(); > @rights=split //,$sth->fetchrow_array; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/netams.cgi netams-3.4.0rc2/cgi-bin/admin/netams.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/netams.cgi 2007-05-13 17:30:50 +0400 >+++ netams-3.4.0rc2/cgi-bin/admin/netams.cgi 2007-11-14 10:54:25 +0300 >@@ -91,7 +91,7 @@ > if (defined $log_to_events) { > if ($log_to_events eq "yes") { > use DBI; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { return; } > else { > $dbh->do("INSERT INTO events VALUES (unix_timestamp(),'CGI', ".hex($oid).",0,".hex($oid).",\"$ip\t$action\")"); >@@ -122,7 +122,7 @@ > use DBI; > $what = shift; > $user = $ENV{REMOTE_USER}; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > $sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'"); > $sth->execute(); > @rights=split //,$sth->fetchrow_array; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/radius.cgi netams-3.4.0rc2/cgi-bin/admin/radius.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/radius.cgi 2004-05-26 17:19:33 +0400 >+++ netams-3.4.0rc2/cgi-bin/admin/radius.cgi 2007-11-13 11:42:36 +0300 >@@ -17,11 +17,11 @@ > > $toppane="<b>Radius Management</b>"; > >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { > $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; } > else { >- $p1.="<b>Connected to database $mysql_dbname</b><hr>"; >+ $p1.="<b>Connected to database $sql_dbname</b><hr>"; > } > > $p1="<a href=$url>Users</a> <a href=$url?action=grouplist>Groups</a><hr>"; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/rrdgraph.cgi netams-3.4.0rc2/cgi-bin/admin/rrdgraph.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/rrdgraph.cgi 2005-11-22 22:35:50 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/rrdgraph.cgi 2007-11-13 11:38:07 +0300 >@@ -70,8 +70,7 @@ > > print STDERR "Last update: ".RRDs::last($rrd_filename)."\n"; > >- DBI->install_driver("mysql"); >- $dbh = DBI->connect("DBI:mysql:netams","root", "", { RaiseError=>0,AutoCommit=>1 }); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host",$sql_login, $sql_password, { RaiseError=>0,AutoCommit=>1 }); > if (not defined $dbh) { showError("database connect"); } > > $dbs = $dbh->prepare("SELECT hex(policy_oid),t_from,bytes_in,bytes_out from summary WHERE prefix='H' AND unit_oid=0x0".$oid." AND t_from >=".$time_1." AND t_from <=".$time_2." ORDER BY t_from,policy_oid"); >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/statistic.cgi netams-3.4.0rc2/cgi-bin/admin/statistic.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/statistic.cgi 2006-12-17 20:59:25 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/statistic.cgi 2007-11-13 11:38:30 +0300 >@@ -608,7 +608,7 @@ > if ($have_access ne "yes") {return 9;} > $what = shift; > $user = $ENV{REMOTE_USER}; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > $sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'"); > $sth->execute(); > @rights=split //,$sth->fetchrow_array; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/unit.cgi netams-3.4.0rc2/cgi-bin/admin/unit.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/unit.cgi 2006-03-16 19:04:39 +0300 >+++ netams-3.4.0rc2/cgi-bin/admin/unit.cgi 2007-11-14 14:16:21 +0300 >@@ -28,7 +28,7 @@ > > if($have_radius eq "yes") { > use DBI; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; } > else { > $dbh->do("DELETE FROM $radcheck WHERE id = ".hex($oid).""); >@@ -191,7 +176,7 @@ > $ip=$ip{$oid}; > } > use DBI; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; } > else { > $dbh->do("REPLACE $radcheck VALUES (".hex($oid).",'$name','Password','==','$password')"); >diff -uNr netams-3.4.0rc2.orig/cgi-bin/admin/view.cgi netams-3.4.0rc2/cgi-bin/admin/view.cgi >--- netams-3.4.0rc2.orig/cgi-bin/admin/view.cgi 2004-05-06 15:09:45 +0400 >+++ netams-3.4.0rc2/cgi-bin/admin/view.cgi 2007-11-13 11:42:42 +0300 >@@ -9,11 +9,11 @@ > $url="view.cgi"; > > $toppane="<b>View Log</b>"; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { > $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; } > else { >- $p1.="<b>Connected to database $mysql_dbname</b><hr>"; >+ $p1.="<b>Connected to database $sql_dbname</b><hr>"; > } > > if(($aid=$cgi->param("aid")) ne "") { >diff -uNr netams-3.4.0rc2.orig/cgi-bin/config.cgi netams-3.4.0rc2/cgi-bin/config.cgi >--- netams-3.4.0rc2.orig/cgi-bin/config.cgi 2005-04-06 20:21:49 +0400 >+++ netams-3.4.0rc2/cgi-bin/config.cgi 2007-11-14 15:12:34 +0300 >@@ -7,7 +7,12 @@ > $sc_host="localhost"; $sc_port=20001; $sc_user="admin"; $sc_passwd="aaa"; > > #login to database >-$mysql_host="localhost"; $mysql_login="root"; $mysql_password=""; $mysql_dbname="netams"; >+# sql_type may be "mysql" and "Pg" >+$sql_type="mysql" >+$sql_host="localhost"; >+$sql_login="root"; >+$sql_password=""; >+$sql_dbname="netams"; > > #log events > $log_to_events="yes"; >diff -uNr netams-3.4.0rc2.orig/cgi-bin/statistic.pl netams-3.4.0rc2/cgi-bin/statistic.pl >--- netams-3.4.0rc2.orig/cgi-bin/statistic.pl 2006-12-17 20:59:26 +0300 >+++ netams-3.4.0rc2/cgi-bin/statistic.pl 2007-11-13 11:32:28 +0300 >@@ -649,7 +649,7 @@ > ################################################ > sub bdconnect { > use DBI; >- my $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ my $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { die "<A>Error database connecting. </a>"; } > return $dbh; > } >diff -uNr netams-3.4.0rc2.orig/cgi-bin/usertool.cgi netams-3.4.0rc2/cgi-bin/usertool.cgi >--- netams-3.4.0rc2.orig/cgi-bin/usertool.cgi 2005-11-25 23:37:08 +0300 >+++ netams-3.4.0rc2/cgi-bin/usertool.cgi 2007-11-13 11:39:45 +0300 >@@ -69,7 +69,7 @@ > if($k[$i] eq $unit) { > use DBI; > >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; } > $dbh->do("REPLACE $radcheck VALUES (".hex($oid).",'$name','Password','==','$password')"); > $p4.="<b><i>Applying:</i></b> Syncing to Radius server<br>"; >@@ -121,11 +121,11 @@ > } elsif ($cgi->param("action") eq "view") { > use DBI; > >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password); >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password); > if ($dbh eq "") { > $p4.="<b>Unable to connect to SQL radius database!</b><hr>"; } > else { >- $p4.="<b>Connected to database $mysql_dbname</b><hr>"; >+ $p4.="<b>Connected to database $sql_dbname</b><hr>"; > } > > $sth = $dbh->prepare("SELECT * FROM events WHERE account_oid='".hex($oid)."' ORDER BY time DESC"); >@@ -235,7 +235,7 @@ > if (defined $log_to_events) { > if ($log_to_events eq "yes") { > use DBI; >- $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password >+ $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password > ); > if ($dbh eq "") { return; } > else {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 13426
: 2267