View | Details | Raw Unified | Return to bug 13426
Collapse All | Expand All

(-)netams-3.4.0rc2.orig/cgi-bin/activate.cgi (-2 / +2 lines)
Lines 24-30 Link Here
24
($tem1,$tem2)=split /XXXXXXXXX/, $tem;
24
($tem1,$tem2)=split /XXXXXXXXX/, $tem;
25
25
26
if ($cgi->param('action') eq 'do') {
26
if ($cgi->param('action') eq 'do') {
27
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
27
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
28
	if ($dbh eq "") { $p1.="<b>Unable to connect to SQL database!</b><hr>"; }
28
	if ($dbh eq "") { $p1.="<b>Unable to connect to SQL database!</b><hr>"; }
29
29
30
	netams_login($sc_host, $sc_port, $sc_user, $sc_passwd);
30
	netams_login($sc_host, $sc_port, $sc_user, $sc_passwd);
Lines 99-105 Link Here
99
	if (defined $log_to_events) {
99
	if (defined $log_to_events) {
100
		if ($log_to_events eq "yes") {
100
		if ($log_to_events eq "yes") {
101
			use DBI;
101
			use DBI;
102
			$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
102
			$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
103
			if ($dbh eq "") { return; }
103
			if ($dbh eq "") { return; }
104
			else { 
104
			else { 
105
				$dbh->do("INSERT INTO events VALUES (unix_timestamp(),'CGI', ".hex($oid).",0,".hex($oid).",\"$ip\t$action\")"); 
105
				$dbh->do("INSERT INTO events VALUES (unix_timestamp(),'CGI', ".hex($oid).",0,".hex($oid).",\"$ip\t$action\")"); 
(-)netams-3.4.0rc2.orig/cgi-bin/admin/access.cgi (-2 / +2 lines)
Lines 13-23 Link Here
13
13
14
	$toppane = "<b>Access Users and Right Management</b>";
14
	$toppane = "<b>Access Users and Right Management</b>";
15
15
16
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
16
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
17
        if ($dbh eq "") {
17
        if ($dbh eq "") {
18
                $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
18
                $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
19
        else {
19
        else {
20
                $p1.="<b>Connected to database $mysql_dbname</b><hr>";
20
                $p1.="<b>Connected to database $sql_dbname</b><hr>";
21
        }
21
        }
22
22
23
if($action eq "delete") {
23
if($action eq "delete") {
(-)netams-3.4.0rc2.orig/cgi-bin/admin/cardtool.cgi (-1 / +1 lines)
Lines 26-32 Link Here
26
        NoAccess();
26
        NoAccess();
27
}
27
}
28
28
29
$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
29
$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
30
if ($dbh eq "") { $p1.="<b>Unable to connect to SQL database!</b><hr>"; }
30
if ($dbh eq "") { $p1.="<b>Unable to connect to SQL database!</b><hr>"; }
31
31
32
32
(-)netams-3.4.0rc2.orig/cgi-bin/admin/config.cgi (-1 / +6 lines)
Lines 7-13 Link Here
7
$sc_host="localhost"; $sc_port=20001; $sc_user="admin"; $sc_passwd="aaa";
7
$sc_host="localhost"; $sc_port=20001; $sc_user="admin"; $sc_passwd="aaa";
8
8
9
#login to database
9
#login to database
10
$mysql_host="localhost"; $mysql_login="root"; $mysql_password=""; $mysql_dbname="netams";
10
# sql_type may be "mysql" and "Pg"
11
$sql_type="mysql";
12
$sql_host="localhost";
13
$sql_login="root";
14
$sql_password="";
15
$sql_dbname="netams";
11
16
12
#enable or disable billing
17
#enable or disable billing
13
$have_billing="yes";
18
$have_billing="yes";
(-)netams-3.4.0rc2.orig/cgi-bin/admin/graph.cgi (-1 / +1 lines)
Lines 496-502 Link Here
496
	if ($have_access ne "yes") {return 9;}
496
	if ($have_access ne "yes") {return 9;}
497
	$what = shift;
497
	$what = shift;
498
	$user = $ENV{REMOTE_USER};
498
	$user = $ENV{REMOTE_USER};
499
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
499
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
500
	$sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
500
	$sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
501
        $sth->execute();
501
        $sth->execute();
502
        @rights=split //,$sth->fetchrow_array;
502
        @rights=split //,$sth->fetchrow_array;
(-)netams-3.4.0rc2.orig/cgi-bin/admin/monitor.cgi (-2 / +2 lines)
Lines 329-335 Link Here
329
	$where.=$where1;
329
	$where.=$where1;
330
	$debug.=$where1;
330
	$debug.=$where1;
331
    }
331
    }
332
    $db = DBI->connect("DBI:mysql:database=".$mysql_dbname.";host=".$mysql_host, $mysql_login, $mysql_password);
332
    $db = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
333
    if($db eq "") { die "Error database connecting."; }
333
    if($db eq "") { die "Error database connecting."; }
334
    if ($action eq "Refresh" or $action eq "Refresh_db") {
334
    if ($action eq "Refresh" or $action eq "Refresh_db") {
335
	$v_parse_proto=0 if $v_parse_proto eq "";
335
	$v_parse_proto=0 if $v_parse_proto eq "";
Lines 1253-1259 Link Here
1253
	}
1253
	}
1254
	$what = shift;
1254
	$what = shift;
1255
	$user = $ENV{REMOTE_USER};
1255
	$user = $ENV{REMOTE_USER};
1256
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
1256
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
1257
	$sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
1257
	$sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
1258
        $sth->execute();
1258
        $sth->execute();
1259
        @rights=split //,$sth->fetchrow_array;
1259
        @rights=split //,$sth->fetchrow_array;
(-)netams-3.4.0rc2.orig/cgi-bin/admin/netams.cgi (-2 / +2 lines)
Lines 91-97 Link Here
91
	if (defined $log_to_events) {
91
	if (defined $log_to_events) {
92
		if ($log_to_events eq "yes") {
92
		if ($log_to_events eq "yes") {
93
			use DBI;
93
			use DBI;
94
			$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
94
			$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
95
			if ($dbh eq "") { return; }
95
			if ($dbh eq "") { return; }
96
			else {
96
			else {
97
				$dbh->do("INSERT INTO events VALUES (unix_timestamp(),'CGI', ".hex($oid).",0,".hex($oid).",\"$ip\t$action\")");
97
				$dbh->do("INSERT INTO events VALUES (unix_timestamp(),'CGI', ".hex($oid).",0,".hex($oid).",\"$ip\t$action\")");
Lines 122-128 Link Here
122
	use DBI;
122
	use DBI;
123
	$what = shift;
123
	$what = shift;
124
	$user = $ENV{REMOTE_USER};
124
	$user = $ENV{REMOTE_USER};
125
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
125
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
126
	$sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
126
	$sth = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
127
        $sth->execute();
127
        $sth->execute();
128
        @rights=split //,$sth->fetchrow_array;
128
        @rights=split //,$sth->fetchrow_array;
(-)netams-3.4.0rc2.orig/cgi-bin/admin/radius.cgi (-2 / +2 lines)
Lines 17-27 Link Here
17
	
17
	
18
	$toppane="<b>Radius Management</b>";
18
	$toppane="<b>Radius Management</b>";
19
19
20
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
20
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
21
	if ($dbh eq "") {
21
	if ($dbh eq "") {
22
		$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
22
		$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
23
	else {
23
	else {
24
		$p1.="<b>Connected to database $mysql_dbname</b><hr>";
24
		$p1.="<b>Connected to database $sql_dbname</b><hr>";
25
	}
25
	}
26
	
26
	
27
	$p1="<a href=$url>Users</a>&nbsp;<a href=$url?action=grouplist>Groups</a><hr>";
27
	$p1="<a href=$url>Users</a>&nbsp;<a href=$url?action=grouplist>Groups</a><hr>";
(-)netams-3.4.0rc2.orig/cgi-bin/admin/rrdgraph.cgi (-2 / +1 lines)
Lines 70-77 Link Here
70
70
71
print STDERR "Last update: ".RRDs::last($rrd_filename)."\n";
71
print STDERR "Last update: ".RRDs::last($rrd_filename)."\n";
72
72
73
	DBI->install_driver("mysql");
73
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host",$sql_login, $sql_password, { RaiseError=>0,AutoCommit=>1 });
74
	$dbh = DBI->connect("DBI:mysql:netams","root", "", { RaiseError=>0,AutoCommit=>1 });
75
	if (not defined $dbh) { showError("database connect"); }
74
	if (not defined $dbh) { showError("database connect"); }
76
	
75
	
77
	$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"); 
76
	$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"); 
(-)netams-3.4.0rc2.orig/cgi-bin/admin/statistic.cgi (-1 / +1 lines)
Lines 608-614 Link Here
608
	if ($have_access ne "yes") {return 9;}
608
	if ($have_access ne "yes") {return 9;}
609
	$what = shift;
609
	$what = shift;
610
	$user = $ENV{REMOTE_USER};
610
	$user = $ENV{REMOTE_USER};
611
	$dbh  = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
611
	$dbh  = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
612
	$sth  = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
612
	$sth  = $dbh->prepare("SELECT rights FROM $accessdb WHERE login='$user'");
613
			$sth->execute();
613
			$sth->execute();
614
		@rights=split //,$sth->fetchrow_array;
614
		@rights=split //,$sth->fetchrow_array;
(-)netams-3.4.0rc2.orig/cgi-bin/admin/unit.cgi (-2 / +2 lines)
Lines 28-34 Link Here
28
		
28
		
29
			if($have_radius eq "yes") {
29
			if($have_radius eq "yes") {
30
				use DBI;
30
				use DBI;
31
                                $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
31
                                $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
32
                                if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
32
                                if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
33
                                else {
33
                                else {
34
                                        $dbh->do("DELETE FROM $radcheck WHERE id = ".hex($oid)."");
34
                                        $dbh->do("DELETE FROM $radcheck WHERE id = ".hex($oid)."");
Lines 191-197 Link Here
191
                			$ip=$ip{$oid};
176
                			$ip=$ip{$oid};
192
				}
177
				}
193
				use DBI;
178
				use DBI;
194
				$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
179
				$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
195
				if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
180
				if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
196
				else {
181
				else {
197
					$dbh->do("REPLACE $radcheck VALUES (".hex($oid).",'$name','Password','==','$password')");
182
					$dbh->do("REPLACE $radcheck VALUES (".hex($oid).",'$name','Password','==','$password')");
(-)netams-3.4.0rc2.orig/cgi-bin/admin/view.cgi (-2 / +2 lines)
Lines 9-19 Link Here
9
$url="view.cgi";
9
$url="view.cgi";
10
10
11
	$toppane="<b>View Log</b>";
11
	$toppane="<b>View Log</b>";
12
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
12
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
13
        if ($dbh eq "") {
13
        if ($dbh eq "") {
14
                $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
14
                $p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
15
        else {
15
        else {
16
                $p1.="<b>Connected to database $mysql_dbname</b><hr>";
16
                $p1.="<b>Connected to database $sql_dbname</b><hr>";
17
        }
17
        }
18
	
18
	
19
	if(($aid=$cgi->param("aid")) ne "") {
19
	if(($aid=$cgi->param("aid")) ne "") {
(-)netams-3.4.0rc2.orig/cgi-bin/config.cgi (-1 / +6 lines)
Lines 7-13 Link Here
7
$sc_host="localhost"; $sc_port=20001; $sc_user="admin"; $sc_passwd="aaa";
7
$sc_host="localhost"; $sc_port=20001; $sc_user="admin"; $sc_passwd="aaa";
8
8
9
#login to database
9
#login to database
10
$mysql_host="localhost"; $mysql_login="root"; $mysql_password=""; $mysql_dbname="netams";
10
# sql_type may be "mysql" and "Pg"
11
$sql_type="mysql"
12
$sql_host="localhost";
13
$sql_login="root";
14
$sql_password="";
15
$sql_dbname="netams";
11
16
12
#log events
17
#log events
13
$log_to_events="yes";
18
$log_to_events="yes";
(-)netams-3.4.0rc2.orig/cgi-bin/statistic.pl (-1 / +1 lines)
Lines 649-655 Link Here
649
################################################
649
################################################
650
sub bdconnect {
650
sub bdconnect {
651
	use DBI;
651
	use DBI;
652
	my  $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
652
	my  $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
653
	if ($dbh eq "") { die "<A>Error database connecting. </a>"; }
653
	if ($dbh eq "") { die "<A>Error database connecting. </a>"; }
654
	return $dbh;
654
	return $dbh;
655
}
655
}
(-)netams-3.4.0rc2.orig/cgi-bin/usertool.cgi (-4 / +4 lines)
Lines 69-75 Link Here
69
				if($k[$i] eq $unit) {
69
				if($k[$i] eq $unit) {
70
					use DBI;
70
					use DBI;
71
					
71
					
72
					$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
72
					$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
73
					if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
73
					if ($dbh eq "") {$p1.="<b>Unable to connect to SQL radius database!</b><hr>"; }
74
					$dbh->do("REPLACE $radcheck VALUES (".hex($oid).",'$name','Password','==','$password')");
74
					$dbh->do("REPLACE $radcheck VALUES (".hex($oid).",'$name','Password','==','$password')");
75
					$p4.="<b><i>Applying:</i></b> Syncing to Radius server<br>";
75
					$p4.="<b><i>Applying:</i></b> Syncing to Radius server<br>";
Lines 121-131 Link Here
121
} elsif ($cgi->param("action") eq "view") {
121
} elsif ($cgi->param("action") eq "view") {
122
	use DBI;
122
	use DBI;
123
	
123
	
124
	$dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password);
124
	$dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password);
125
        if ($dbh eq "") {
125
        if ($dbh eq "") {
126
                $p4.="<b>Unable to connect to SQL radius database!</b><hr>"; }
126
                $p4.="<b>Unable to connect to SQL radius database!</b><hr>"; }
127
        else {
127
        else {
128
                $p4.="<b>Connected to database $mysql_dbname</b><hr>";
128
                $p4.="<b>Connected to database $sql_dbname</b><hr>";
129
        }
129
        }
130
130
131
	$sth = $dbh->prepare("SELECT * FROM events WHERE account_oid='".hex($oid)."' ORDER BY time DESC");
131
	$sth = $dbh->prepare("SELECT * FROM events WHERE account_oid='".hex($oid)."' ORDER BY time DESC");
Lines 235-241 Link Here
235
        if (defined $log_to_events) {
235
        if (defined $log_to_events) {
236
                if ($log_to_events eq "yes") {
236
                if ($log_to_events eq "yes") {
237
                        use DBI;
237
                        use DBI;
238
                        $dbh = DBI->connect("DBI:mysql:database=$mysql_dbname;host=$mysql_host", $mysql_login, $mysql_password
238
                        $dbh = DBI->connect("DBI:$sql_type:database=$sql_dbname;host=$sql_host", $sql_login, $sql_password
239
);
239
);
240
                        if ($dbh eq "") { return; }
240
                        if ($dbh eq "") { return; }
241
                        else {
241
                        else {

Return to bug 13426