File: acid_ag_common.php

package info (click to toggle)
acidlab 0.9.6b20-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 696 kB
  • ctags: 1,462
  • sloc: php: 9,625; sql: 140
file content (75 lines) | stat: -rw-r--r-- 1,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/*  
 * Analysis Console for Incident Databases (ACID)
 *
 * Author: Roman Danyliw <rdd@cert.org>, <roman@danyliw.com>
 *
 * Copyright (C) 2000, 2001 Carnegie Mellon University
 * (see the file 'acid_main.php' for license details)
 *
 * Purpose: lookup routines for AG information 
 *
 */

function GetAGIDbyName($ag_name, $db)
{
  $ag_id = "";
  $sql = "SELECT ag_id FROM acid_ag WHERE ag_name='".$ag_name."'";

  $result = $db->acidExecute($sql, -1, -1, false);

  if ( $db->acidErrorMessage() != "" )
     ErrorMessage("The specified AG name search is invalid.  Try again!");
  else if ( $result->acidRecordCount() < 1 )
     ErrorMessage("The specified AG does not exist.");
  else
  {
        $myrow = $result->acidFetchRow();
        $ag_id = $myrow[0]; 
        $result->acidFreeRows();
  }

  return $ag_id;
}

function GetAGNamebyID($ag_id, $db)
{
  $ag_name = "";
  $sql = "SELECT ag_name FROM acid_ag WHERE ag_id='".$ag_id."'";

  $result = $db->acidExecute($sql, -1, -1, false);

  if ( $db->acidErrorMessage() != "" )
     ErrorMessage("The specified AG ID search is invalid.  Try again!");
  else if ( $result->acidRecordCount() < 1 )
     ErrorMessage("The specified AG does not exist.");
  else
  {
        $myrow = $result->acidFetchRow();
        $ag_id = $myrow[0]; 
        $result->acidFreeRows();
  }

  return $ag_name;
}

function VerifyAGID($ag_id, $db)
{
  $sql = "SELECT ag_id FROM acid_ag WHERE ag_id='".$ag_id."'";
  $result = $db->acidExecute($sql);

  if ( $db->acidErrorMessage() != "" )
  {
     ErrorMessage("Error looking up an AG ID");
     return 0;
  }
  else if ( $result->acidRecordCount() < 1 )
     return 0;
  else
  {
     $result->acidFreeRows();
     return 1;
  }
}

?>