Rename the badusers date field to incidentdate to avoid reserved words in databases...
authorkkalev <kkalev>
Mon, 21 Mar 2005 17:05:17 +0000 (17:05 +0000)
committerkkalev <kkalev>
Mon, 21 Mar 2005 17:05:17 +0000 (17:05 +0000)
Peter Nixon

dialup_admin/Changelog
dialup_admin/htdocs/badusers.php3
dialup_admin/lib/add_badusers.php3
dialup_admin/sql/mysql/badusers.sql
dialup_admin/sql/oracle/badusers.sql
dialup_admin/sql/postgresql/badusers.sql

index 6a12acd..c74bbdd 100644 (file)
@@ -4,6 +4,8 @@ Ver 1.80:
   general_sessionclear_method and nasXX_sessionclear_method
 * Create a new function da_sql_limit() and use that to pass LIMIT arguments to the database layer
   since the syntax is different between db vendors
+* Rename the badusers date field to incidentdate to avoid reserved words in databases. Bug found by
+  Peter Nixon
 Ver 1.78:
 * Add a snmp_clearsession which can disconnect a user by using the Cisco AAA Session MIB
 * Add a configuration directive general_sessionclear_bin
index 97110fa..9afe582 100644 (file)
@@ -146,15 +146,16 @@ $link = @da_sql_pconnect($config);
 if ($link){
        $search = @da_sql_query($link,$config,
        "SELECT da_sql_limit($limit,0,$config) * FROM $config[sql_badusers_table]
-       WHERE username $usercheck $extra_query AND date <= '$now_str'
-       AND date >= '$prev_str' da_sql_limit($limit,1,$config) ORDER BY date $order da_sql_limit($limit,2,$config);");
+       WHERE username $usercheck $extra_query AND incidentdate <= '$now_str'
+       AND incidentdate >= '$prev_str' da_sql_limit($limit,1,$config)
+       ORDER BY incidentdate $order da_sql_limit($limit,2,$config);");
        if ($search){
                while( $row = @da_sql_fetch_array($search,$config) ){
                        $num++;
                        $id = $row[id];
                        $user = "$row[username]";
                        $User = urlencode($user);
-                       $date = "$row[date]";
+                       $date = "$row[incidentdate]";
                        $reason = "$row[reason]";
                        $admin = "$row[admin]";
                        if ($admin == $auth_user || $admin == '-')
index ed635bd..e68b17b 100644 (file)
@@ -23,7 +23,7 @@ else{
                $link = @da_sql_host_connect($server,$config);
                if ($link){
                        $r = da_sql_query($link,$config,
-                       "INSERT INTO $config[sql_badusers_table] (username,date,admin,reason)
+                       "INSERT INTO $config[sql_badusers_table] (username,incidentdate,admin,reason)
                        VALUES ('$login','$date','$admin','$msg');");
                        if (!$r)
                                echo "<b>SQL Error:" . da_sql_error($link,$config) . "</b><br>\n";
index c5011b9..c8b5032 100644 (file)
@@ -4,7 +4,7 @@
 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,
+  IncidentDate datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
   Reason varchar(200),
   Admin varchar(30) DEFAULT '-',
   PRIMARY KEY (id),
index f211968..06b0820 100644 (file)
 CREATE TABLE badusers (
        id              INT PRIMARY KEY,
        username        VARCHAR(30) DEFAULT '' NOT NULL,
-       actiondate      TIMESTAMP WITH TIME ZONE DEFAULT sysdate NOT NULL,
+       incidentdate    TIMESTAMP WITH TIME ZONE DEFAULT sysdate NOT NULL,
        reason          VARCHAR(128) DEFAULT '' NOT NULL,
        admin           VARCHAR(128) DEFAULT '-' NOT NULL
 );
 CREATE SEQUENCE badusers_seq START WITH 1 INCREMENT BY 1;
-CREATE INDEX badusers_actiondate_idx ON badusers (actiondate);
+CREATE INDEX badusers_incidentdate_idx ON badusers (incidentdate);
 CREATE INDEX badusers_username_idx ON badusers (username);
 
 /* Trigger to emulate a serial # on the primary key */
index 7312704..93e5ca0 100644 (file)
@@ -5,9 +5,9 @@ SET search_path = public, pg_catalog;
 CREATE TABLE badusers (
     id BIGSERIAL PRIMARY KEY,
     username TEXT NOT NULL,
-    date timestamp with time zone DEFAULT 'now' NOT NULL,
+    incidentdate timestamp with time zone DEFAULT 'now' NOT NULL,
     reason TEXT,
     admin TEXT DEFAULT '-'
 );
-CREATE INDEX badusers_actiondate_idx ON badusers USING btree (actiondate);
+CREATE INDEX badusers_incidentdate_idx ON badusers USING btree (incidentdate);
 CREATE INDEX badusers_username_idx ON badusers USING btree (username);