1<?php 2/******************************************************************************* 3** Basic Analysis and Security Engine (BASE) 4** Copyright (C) 2004 BASE Project Team 5** Copyright (C) 2000 Carnegie Mellon University 6** 7** (see the file 'base_main.php' for license details) 8** 9** Project Lead: Kevin Johnson <kjohnson@secureideas.net> 10** Sean Muller <samwise_diver@users.sourceforge.net> 11** Built upon work by Roman Danyliw <rdd@cert.org>, <roman@danyliw.com> 12** 13** Purpose: Database abstraction layer 14******************************************************************************** 15** Authors: 16******************************************************************************** 17** Kevin Johnson <kjohnson@secureideas.net 18** 19******************************************************************************** 20*/ 21/** The below check is to make sure that the conf file has been loaded before this one.... 22 ** This should prevent someone from accessing the page directly. -- Kevin 23 **/ 24defined( '_BASE_INC' ) or die( 'Accessing this file directly is not allowed.' ); 25 26class baseCon { 27 28 var $DB; 29 var $DB_type; 30 var $DB_name; 31 var $DB_host; 32 var $DB_port; 33 var $DB_username; 34 var $lastSQL; 35 var $version; 36 var $sql_trace; 37 38 function baseCon($type) 39 { 40 $this->DB_type = $type; 41 } 42 43 function baseDBConnect($method, $database, $host, $port, $username, $password, $force = 0) 44 { 45 GLOBAL $archive_dbname, $archive_host, $archive_port, $archive_user, $archive_password, $debug_mode; 46 47 // Check archive cookie to see if they want to be using the archive tables 48 // and check - do we force to use specified database even if archive cookie is set 49 if ( (@$_COOKIE['archive'] == 1) && ($force != 1) ) 50 { 51 // Connect to the archive tables 52 if ($debug_mode > 0) 53 { 54 print "<BR><BR>\n" . __FILE__ . ":" . __LINE__ . ": DEBUG: Connecting to archive db.<BR><BR>\n\n"; 55 } 56 57 if ( $method == DB_CONNECT ) 58 $this->baseConnect($archive_dbname, $archive_host, $archive_port, $archive_user, $archive_password); 59 else 60 $this->basePConnect($archive_dbname, $archive_host, $archive_port, $archive_user, $archive_password); 61 62 } else { 63 // Connect to the main alert tables 64 if ($debug_mode > 0) 65 { 66 print "<BR><BR>\n" . __FILE__ . ":" . __LINE__ . ": DEBUG: Connecting to alert db.<BR><BR>\n\n"; 67 } 68 69 if ( $method == DB_CONNECT ) 70 $this->baseConnect($database, $host, $port, $username, $password); 71 else 72 $this->basePConnect($database, $host, $port, $username, $password); 73 } 74 } 75 76 function baseConnect($database, $host, $port, $username, $password) 77 { 78 GLOBAL $sql_trace_mode, $sql_trace_file; 79 80 $this->DB = NewADOConnection(); 81 $this->DB_name = $database; 82 $this->DB_host = $host; 83 $this->DB_port = $port; 84 $this->DB_username = $username; 85 86 if ( $sql_trace_mode > 0 ) 87 { 88 $this->sql_trace = fopen($sql_trace_file,"a"); 89 if ( !$this->sql_trace ) 90 { 91 ErrorMessage(_ERRSQLTRACE." '".$sql_trace_file."'"); 92 die(); 93 } 94 } 95 96 $db = $this->DB->Connect( ( ( $port == "") ? $host : ($host.":".$port) ), 97 $username, $password, $database); 98 99 if ( !$db ) 100 { 101 $tmp_host = ( $port == "") ? $host : ($host.":".$port); 102 echo '<P><B>'._ERRSQLCONNECT.' </B>'. 103 $database.'@'. $tmp_host ._ERRSQLCONNECTINFO; 104 105 echo $this->baseErrorMessage(); 106 die(); 107 } 108 109 /* Set the database schema version number */ 110 $sql = "SELECT vseq FROM schema"; 111 if ($this->DB_type == "mysql") $sql = "SELECT vseq FROM `schema`"; 112 if ($this->DB_type == "mssql") $sql = "SELECT vseq FROM [schema]"; 113 114 $result = $this->DB->Execute($sql); 115 if ( $this->baseErrorMessage() != "" ) 116 $this->version = 0; 117 else 118 { 119 $myrow = $result->fields; 120 $this->version = $myrow[0]; 121 $result->Close(); 122 } 123 124 if ( $sql_trace_mode > 0 ) 125 { 126 fwrite($this->sql_trace, 127 "\n--------------------------------------------------------------------------------\n"); 128 fwrite($this->sql_trace, "Connect [".$this->DB_type."] ".$database."@".$host.":".$port." as ".$username."\n"); 129 fwrite($this->sql_trace, "[".date ("M d Y H:i:s", time())."] ".$_SERVER["SCRIPT_NAME"]." - db version ".$this->version); 130 fwrite($this->sql_trace, 131 "\n--------------------------------------------------------------------------------\n\n"); 132 fflush($this->sql_trace); 133 } 134 135 return $db; 136 } 137 138 function basePConnect($database, $host, $port, $username, $password) 139 { 140 GLOBAL $sql_trace_mode, $sql_trace_file; 141 142 $this->DB = NewADOConnection(); 143 $this->DB_name = $database; 144 $this->DB_host = $host; 145 $this->DB_port = $port; 146 $this->DB_username = $username; 147 148 if ( $sql_trace_mode > 0 ) 149 { 150 $this->sql_trace = fopen($sql_trace_file,"a"); 151 if ( !$this->sql_trace ) 152 { 153 ErrorMessage(_ERRSQLTRACE." '".$sql_trace_file."'"); 154 die(); 155 } 156 } 157 158 $db = $this->DB->PConnect( ( ( $port == "") ? $host : ($host.":".$port) ), 159 $username, $password, $database); 160 161 if ( !$db ) 162 { 163 $tmp_host = ( $port == "") ? $host : ($host.":".$port); 164 echo '<P><B>'._ERRSQLPCONNECT.' </B>'. 165 $database.'@'. $tmp_host ._ERRSQLCONNECTINFO; 166 167 echo $this->baseErrorMessage(); 168 die(); 169 } 170 171 /* Set the database schema version number */ 172 $sql = "SELECT vseq FROM schema"; 173 if ($this->DB_type == "mssql") $sql = "SELECT vseq FROM [schema]"; 174 if ($this->DB_type == "mysql") $sql = "SELECT vseq FROM `schema`"; 175 176 $result = $this->DB->Execute($sql); 177 if ( $this->baseErrorMessage() != "" ) 178 $this->version = 0; 179 else 180 { 181 $myrow = $result->fields; 182 $this->version = $myrow[0]; 183 $result->Close(); 184 } 185 186 if ( $sql_trace_mode > 0 ) 187 { 188 fwrite($this->sql_trace, 189 "\n--------------------------------------------------------------------------------\n"); 190 fwrite($this->sql_trace, "PConnect [".$this->DB_type."] ".$database."@".$host.":".$port." as ".$username."\n"); 191 fwrite($this->sql_trace, "[".date ("M d Y H:i:s", time())."] ".$_SERVER["SCRIPT_NAME"]." - db version ".$this->version); 192 fwrite($this->sql_trace, 193 "\n--------------------------------------------------------------------------------\n\n"); 194 fflush($this->sql_trace); 195 } 196 197 return $db; 198 } 199 200 function baseClose() 201 { 202 $this->DB->Close(); 203 } 204 205 function baseExecute($sql, $start_row=0, $num_rows=-1, $die_on_error=true ) 206 { 207 GLOBAL $debug_mode, $sql_trace_mode; 208 209 /* ** Begin DB specific SQL fix-up ** */ 210 if ($this->DB_type == "mssql") 211 { 212 $sql = preg_replace("/''/i", "NULL", $sql); 213 } 214 215 if ($this->DB_type == "oci8") 216 { 217 if (!strpos($sql, 'TRIGGER')) 218 { 219 if (substr($sql, strlen($sql)-1, strlen($sql))==';') 220 { 221 $sql=substr($sql, 0, strlen($sql)-1); 222 } 223 } 224 } 225 226 $this->lastSQL = $sql; 227 $limit_str = ""; 228 229 /* Check whether need to add a LIMIT / TOP / ROWNUM clause */ 230 if ( $num_rows == -1 ) 231 $rs = new baseRS($this->DB->Execute($sql), $this->DB_type); 232 else 233 { 234 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || 235 ($this->DB_type == "maxsql") ) 236 { 237 $rs = new baseRS($this->DB->Execute($sql." LIMIT ".$start_row.", ".$num_rows), 238 $this->DB_type); 239 $limit_str = " LIMIT ".$start_row.", ".$num_rows; 240 } 241 else if ( $this->DB_type == "oci8" ) { 242 $rs = new baseRS($this->DB->Execute($sql), 243 $this->DB_type); 244 $limit_str = " LIMIT ".$start_row.", ".$num_rows; 245 } 246 else if ( $this->DB_type == "postgres" ) 247 { 248 $rs = new baseRS($this->DB->Execute($sql." LIMIT ".$num_rows." OFFSET ".$start_row), 249 $this->DB_type); 250 $limit_str = " LIMIT ".$num_rows." OFFSET ".$start_row; 251 } 252 253 /* Databases which do not support LIMIT (e.g. MS SQL) natively must emulated it */ 254 else 255 { 256 $rs = new baseRS($this->DB->Execute($sql), $this->DB_type); 257 $i = 0; 258 while ( ($i < $start_row) && $rs) 259 { 260 if ( !$rs->row->EOF ) 261 $rs->row->MoveNext(); 262 $i++; 263 } 264 } 265 } 266 267 if ( $sql_trace_mode > 0 ) 268 { 269 fputs($this->sql_trace, $sql."\n"); 270 fflush($this->sql_trace); 271 } 272 273 if ( (!$rs || $this->baseErrorMessage() != "") && $die_on_error ) 274 { 275 echo '</TABLE></TABLE></TABLE> 276 <FONT COLOR="#FF0000"><B>'._ERRSQLDB.'</B>'.($this->baseErrorMessage()).'</FONT>'. 277 '<P><PRE>'.( $debug_mode > 0 ? ($this->lastSQL).$limit_str : "" ).'</PRE><P>'; 278 die(); 279 } 280 else 281 { 282 return $rs; 283 } 284 } 285 286 function baseErrorMessage() 287 { 288 GLOBAL $debug_mode; 289 290 if ( $this->DB->ErrorMsg() && 291 ($this->DB_type != 'mssql' || (!strstr($this->DB->ErrorMsg(), 'Changed database context to') && 292 !strstr($this->DB->ErrorMsg(), 'Changed language setting to')))) 293 return '</TABLE></TABLE></TABLE>'. 294 '<FONT COLOR="#FF0000"><B>'._ERRSQLDB.'</B>'.($this->DB->ErrorMsg()).'</FONT>'. 295 '<P><CODE>'.( $debug_mode > 0 ? $this->lastSQL : "" ).'</CODE><P>'; 296 } 297 298 function baseTableExists($table) 299 { 300 if ($this->DB_type == "oci8") $table=strtoupper($table); 301 302 if ( in_array($table, $this->DB->MetaTables()) ) 303 return 1; 304 else 305 return 0; 306 } 307 308 function baseIndexExists($table, $index_name) 309 { 310 if ( in_array($index_name, $this->DB->MetaIndexes($table)) ) 311 return 1; 312 else 313 return 0; 314 } 315 316 function baseInsertID() 317 { 318 /* Getting the insert ID fails on certain databases (e.g. postgres), but we may use it on the once it works 319 * on. This function returns -1 if the dbtype is postgres, then we can run a kludge query to get the insert 320 * ID. That query may vary depending upon which table you are looking at and what variables you have set at 321 * the current point, so it can't be here and needs to be in the actual script after calling this function 322 * -- srh (02/01/2001) 323 */ 324 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || 325 ($this->DB_type == "maxsql") || ($this->DB_type == "mssql")) 326 return $this->DB->Insert_ID(); 327 else if ($this->DB_type == "postgres" ||($this->DB_type == "oci8")) 328 return -1; 329 } 330 331 function baseTimestampFmt($timestamp) 332 { 333 // Not used anywhere????? -- Kevin 334 return $this->DB->DBTimeStamp($timestamp); 335 } 336 337 function baseSQL_YEAR($func_param, $op, $timestamp) 338 { 339 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || 340 ($this->DB_type == "maxsql") || ($this->DB_type == "mssql") ) 341 return " YEAR($func_param) $op $timestamp "; 342 else if( $this->DB_type == "oci8" ) 343 return " to_number( to_char( $func_param, 'RRRR' ) ) $op $timestamp "; 344 else if ( $this->DB_type == "postgres" ) 345 return " DATE_PART('year', $func_param) $op $timestamp "; 346 } 347 348 function baseSQL_MONTH($func_param, $op, $timestamp) 349 { 350 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || 351 ($this->DB_type == "maxsql") || ($this->DB_type == "mssql") ) 352 return " MONTH($func_param) $op $timestamp "; 353 else if( $this->DB_type == "oci8" ) 354 return " to_number( to_char( $func_param, 'MM' ) ) $op $timestamp "; 355 else if ( $this->DB_type == "postgres" ) 356 return " DATE_PART('month', $func_param) $op $timestamp "; 357 } 358 359 function baseSQL_DAY($func_param, $op, $timestamp) 360 { 361 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") ) 362 return " DAYOFMONTH($func_param) $op $timestamp "; 363 else if($this->DB_type == "oci8") 364 return " to_number( to_char( $func_param, 'DD' ) ) $op $timestamp "; 365 else if ( $this->DB_type == "postgres" ) 366 return " DATE_PART('day', $func_param) $op $timestamp "; 367 else if ( $this->DB_type == "mssql" ) 368 return " DAY($func_param) $op $timestamp "; 369 } 370 371 function baseSQL_HOUR($func_param, $op, $timestamp) 372 { 373 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") ) 374 return " HOUR($func_param) $op $timestamp "; 375 else if($this->DB_type == "oci8") 376 return " to_number( to_char( $func_param, 'HH' ) ) $op $timestamp "; 377 else if ( $this->DB_type == "postgres" ) 378 return " DATE_PART('hour', $func_param) $op $timestamp "; 379 else if ( $this->DB_type == "mssql" ) 380 return " DATEPART(hh, $func_param) $op $timestamp "; 381 } 382 383 function baseSQL_MINUTE($func_param, $op, $timestamp) 384 { 385 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") ) 386 return " MINUTE($func_param) $op $timestamp "; 387 else if($this->DB_type == "oci8") 388 return " to_number( to_char( $func_param, 'MI' ) ) $op $timestamp "; 389 else if ( $this->DB_type == "postgres" ) 390 return " DATE_PART('minute', $func_param) $op $timestamp "; 391 else if ( $this->DB_type == "mssql" ) 392 return " DATEPART(mi, $func_param) $op $timestamp "; 393 } 394 395 function baseSQL_SECOND($func_param, $op, $timestamp) 396 { 397 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") ) 398 return " SECOND($func_param) $op $timestamp "; 399 else if($this->DB_type == "oci8") 400 return " to_number( to_char( $func_param, 'SS' ) ) $op $timestamp "; 401 else if ( $this->DB_type == "postgres" ) 402 return " DATE_PART('second', $func_param) $op $timestamp "; 403 else if ( $this->DB_type == "mssql" ) 404 return " DATEPART(ss, $func_param) $op $timestamp "; 405 } 406 407 function baseSQL_UNIXTIME($func_param, $op, $timestamp) 408 { 409 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") ) 410 { 411 return " UNIX_TIMESTAMP($func_param) $op $timestamp "; 412 } 413 else if($this->DB_type == "oci8") 414 return " to_number( $func_param ) $op $timestamp "; 415 else if ( $this->DB_type == "postgres" ) 416 { 417 if ( ($op == "") && ($timestamp == "") ) 418 /* Catches the case where I want to get the UNIXTIME of a constant 419 * i.e. DATE_PART('epoch', timestamp) > = DATE_PART('epoch', timestamp '20010124') 420 * (This one /\ ) 421 */ 422 return " DATE_PART('epoch', $func_param::timestamp) "; 423 else 424 return " DATE_PART('epoch', $func_param::timestamp) $op $timestamp "; 425 } 426 else if ($this->DB_type == "mssql") 427 { 428 return " DATEDIFF(ss, '1970-1-1 00:00:00', $func_param) $op $timestamp "; 429 } 430 431 } 432 433 function baseSQL_TIMESEC($func_param, $op, $timestamp) 434 { 435 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") ) 436 return " TIME_TO_SEC($func_param) $op $timestamp "; 437 else if($this->DB_type == "oci8") 438 return " to_number( $func_param ) $op $timestamp "; 439 else if ( $this->DB_type == "postgres" ) 440 { 441 442 if ( ($op == "") && ($timestamp == "") ) 443 return " DATE_PART('second', DATE_PART('day', '$func_param') "; 444 else 445 return " DATE_PART('second', DATE_PART('day', $func_param) ) $op $timestamp "; 446 } 447 else if ( $this->DB_type == "mssql" ) 448 { 449 if ( ($op == "") && ($timestamp == "") ) 450 return " DATEPART(ss, DATEPART(dd, $func_parm) "; 451 else 452 return " DATEPART(ss, DATE_PART(dd, $func_param) ) $op $timestamp "; 453 454 } 455 456 } 457 458 function baseGetDBversion() 459 { 460 return $this->version; 461 } 462 463 function getSafeSQLString($str) 464 { 465 $t = str_replace("\\", "\\\\", $str); 466 if ($this->DB_type != "mssql" && $this->DB_type != "oci8" ) 467 $t = str_replace("'", "\'", $t); 468 else 469 $t = str_replace("'", "''", $t); 470 $t = str_replace("\"", "\\\\\"", $t); 471 472 return $t; 473 } 474 475} 476 477class baseRS { 478 479 var $row; 480 var $DB_type; 481 482 function baseRS($id, $type) 483 { 484 $this->row = $id; 485 $this->DB_type = $type; 486 } 487 488 function baseFetchRow() 489 { 490 GLOBAL $debug_mode; 491 492 493 /* Workaround for the problem, that the database may contain NULL 494 * whereas "NOT NULL" has been defined, when it was created */ 495 if (!is_object($this->row)) 496 { 497 if ($debug_mode > 1) 498 { 499 echo "<BR><BR>" . __FILE__ . ':' . __LINE__ . ": ERROR: \$this->row is not an object (1)<BR><PRE>"; 500 debug_print_backtrace(); 501 echo "<BR><BR>"; 502 echo "var_dump(\$this):<BR>"; 503 var_dump($this); 504 echo "<BR><BR>"; 505 echo "var_dump(\$this->row):<BR>"; 506 var_dump($this->row); 507 echo "</PRE><BR><BR>"; 508 } 509 510 return ""; 511 } 512 if ( !$this->row->EOF ) 513 { 514 $temp = $this->row->fields; 515 $this->row->MoveNext(); 516 return $temp; 517 } 518 else 519 return ""; 520 } 521 522 function baseColCount() 523 { 524 // Not called anywhere???? -- Kevin 525 return $this->row->FieldCount(); 526 } 527 528 function baseRecordCount() 529 { 530 GLOBAL $debug_mode; 531 532 if (!is_object($this->row)) 533 { 534 if ($debug_mode > 1) 535 { 536 echo '<BR><BR>'; 537 echo __FILE__ . ':' . __LINE__ . ': ERROR: $this->row is not an object (2).'; 538 echo '<BR><PRE>'; 539 debug_print_backtrace(); 540 echo '<BR><BR>var_dump($this):<BR>'; 541 var_dump($this); 542 echo '<BR><BR>var_dump($this->row):<BR>'; 543 var_dump($this->row); 544 echo '</PRE><BR><BR>'; 545 } 546 547 return 0; 548 } 549 550 // Is This if statement necessary? -- Kevin 551 /* MS SQL Server 7, MySQL, Sybase, and Postgres natively support this function */ 552 if ( ($this->DB_type == "mysql") || ($this->DB_type == "mysqlt") || ($this->DB_type == "maxsql") || 553 ($this->DB_type == "mssql") || ($this->DB_type == "sybase") || ($this->DB_type == "postgres") || ($this->DB_type == "oci8")) 554 return $this->row->RecordCount(); 555 556 /* Otherwise we need to emulate this functionality */ 557 else 558 { 559 $i = 0; 560 while ( !$this->row->EOF ) 561 { 562 ++$i; 563 $this->row->MoveNext(); 564 } 565 566 return $i; 567 } 568 } 569 570 function baseFreeRows() 571 { 572 GLOBAL $debug_mode; 573 574 /* Workaround for the problem, that the database may contain NULL, 575 * although "NOT NULL" had been defined when it had been created. 576 * In such a case there's nothing to free(). So we can ignore this 577 * row and don't have anything to do. */ 578 if (!is_object($this->row)) 579 { 580 if ($debug_mode > 1) 581 { 582 echo '<BR><BR>'; 583 echo __FILE__ . ':' . __LINE__ . ': ERROR: $this->row is not an object (3).'; 584 echo '<BR><PRE>'; 585 debug_print_backtrace(); 586 echo '<BR><BR>var_dump($this):<BR>'; 587 var_dump($this); 588 echo '<BR><BR>var_dump($this->row):<BR>'; 589 var_dump($this->row); 590 echo '</PRE><BR><BR>'; 591 } 592 } 593 else 594 { 595 $this->row->Close(); 596 } 597 } 598} 599 600function VerifyDBAbstractionLib($path) 601{ 602 GLOBAL $debug_mode; 603 604 if ( $debug_mode > 0 ) 605 echo(_DBALCHECK." '$path'<BR>"); 606 607 if( !ini_get('safe_mode') ){ 608 if ( is_readable($path) ) // is_file 609 return true; 610 else 611 { 612 echo _ERRSQLDBALLOAD1.'"'.$path. 613 '"'._ERRSQLDBALLOAD2; 614 615 die(); 616 } 617 } 618} 619 620function NewBASEDBConnection($path, $type) 621{ 622 GLOBAL $debug_mode; 623 if ( !( 624 ($type == "mysql") || 625 ($type == "mysqlt") || 626 ($type == "maxsql") || 627 ($type == "postgres") || 628 ($type == "mssql") || 629 ($type == "oci8") 630 ) 631 ) 632 { 633 echo "<B>"._ERRSQLDBTYPE."</B>". 634 "<P>:"._ERRSQLDBTYPEINFO1."<CODE>'$type'</CODE>. "._ERRSQLDBTYPEINFO2; 635 die(); 636 } 637 638 /* Export ADODB_DIR for use by ADODB */ 639 /** Sometimes it may already be defined. So check to see if it is first -- Tim Rupp**/ 640 if (!defined('ADODB_DIR')) { 641 define('ADODB_DIR', $path); 642 } 643 $GLOBALS['ADODB_DIR'] = $path; 644 645 $last_char = substr($path, strlen($path)-1, 1); 646 647 if ( $debug_mode > 1 ) 648 echo "Original path = '".$path."'<BR>"; 649 650 if ( $last_char == "\\" || $last_char == "/" ) 651 { 652 if ( $debug_mode > 1 ) echo "Attempting to load: '".$path."adodb.inc.php'<BR>"; 653 654 VerifyDBAbstractionLib($path."adodb.inc.php"); 655 include($path."adodb.inc.php"); 656 } 657 else if ( strstr($path,"/") || $path == "" ) 658 { 659 if ( $debug_mode > 1 ) echo "Attempting to load: '".$path."/adodb.inc.php'<BR>"; 660 661 VerifyDBAbstractionLib($path."/adodb.inc.php"); 662 include($path."/adodb.inc.php"); 663 } 664 else if ( strstr($path,"\\") ) 665 { 666 if ( $debug_mode > 1 ) echo "Attempting to load: '".$path."\\adodb.inc.php'<BR>"; 667 668 VerifyDBAbstractionLib($path."\\adodb.inc.php"); 669 include($path."\\adodb.inc.php"); 670 } 671 672 ADOLoadCode($type); 673 674 return new baseCon($type); 675} 676 677function MssqlKludgeValue($text) 678{ 679 $mssql_kludge = ""; 680 for ($i = 0 ; $i < strlen($text) ; $i++) 681 { 682 $mssql_kludge = $mssql_kludge."[". 683 substr($text,$i, 1)."]"; 684 } 685 return $mssql_kludge; 686} 687 688function RepairDBTables($db) 689{ 690 /* This function was completely commented in original.... 691 I will be searching to see where it was called from if at all */ 692} 693 694function ClearDataTables($db) 695{ 696 $db->baseExecute("DELETE FROM acid_event"); 697 $db->baseExecute("DELETE FROM data"); 698 $db->baseExecute("DELETE FROM event"); 699 $db->baseExecute("DELETE FROM icmphdr"); 700 $db->baseExecute("DELETE FROM iphdr"); 701 $db->baseExecute("DELETE FROM reference"); 702 $db->baseExecute("DELETE FROM sensor"); 703 $db->baseExecute("DELETE FROM sig_class"); 704 $db->baseExecute("DELETE FROM sig_reference"); 705 $db->baseExecute("DELETE FROM signature"); 706 $db->baseExecute("DELETE FROM tcphdr"); 707 $db->baseExecute("DELETE FROM udphdr"); 708} 709// vim:tabstop=2:shiftwidth=2:expandtab 710?> 711