File: db.inc.php

package info (click to toggle)
htcheck 1%3A1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,836 kB
  • ctags: 2,885
  • sloc: cpp: 14,380; sh: 7,363; php: 3,089; ansic: 1,068; makefile: 303
file content (76 lines) | stat: -rw-r--r-- 2,010 bytes parent folder | download | duplicates (3)
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
76
<?php

//    include/db.inc.php
//    "Abstract" class for interfacing with databases
//
//    Part of the ht://Check package
//
//    Copyright (c) 1999-2004 Comune di Prato - Prato - Italy
//    Author: Gabriele Bartolini - Prato - Italy <angusgb@users.sourceforge.net>
//
//    For copyright details, see the file COPYING in your distribution
//    or the GNU General Public License version 2 or later 
//    <http://www.gnu.org/copyleft/gpl.html>
//
//    $Id: db.inc.php,v 1.4 2003/12/30 09:39:23 angusgb Exp $

if ( defined( '__DB_INC' ) ) return;
define( '__DB_INC', 1 );

class DB
{

   // Class attributes

   var $hostname; // Host to connect to
   var $username; // User name of the connection
   var $password; // Password of the user
   var $HtDBs;    // Variable containing the updated list of the htcheck databases
   var $Info;     // General info (array)

   // Get general crawling info
   function GetGeneralInfo($DBName)
   {
      // Select the Database
      if ($this->SelectDB)
         return -1;
         
      // Array of table names
      $tblnames=array("Schedule", "HtmlAttribute", "HtmlStatement",
         "Link", "Server", "Url");

      $num = count($tblnames);

      // Store all the tables record numbers               
      for ($i=0; $i < $num; $i++)
      {
         $strSQL="SELECT count(*) from " . $tblnames[$i];
         $numsched=$this->CountEntries($strSQL,$DBName);
      
         if ( $numsched <0 ) return $numsched;
         else $this->Info[$tblnames[$i]]=$numsched;
      }
      
   }
   
   function CountEntries ($strSQL, $DBName, $Select=false)
   {
      if ($Select && $this->SelectDB($DBName))  // We must select the db first of all
         return -1;  // Error
      
      // Database selected, let's query it
      if ($this->Query($DBName, $strSQL))
         return -2;
      
      // Let's fetch the row
      if ($row = $this->FetchRow())
         $total = $row[0];
      else $total = -3;
      
      return $total;
      
   }
   
}

?>