/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/fboprime/dbconncheck.php
ViewVC logotype

Annotation of /to_be_filed/webprojs/php_libraries/php_library/fboprime/dbconncheck.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (hide annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 5 months ago) by dashley
File size: 3935 byte(s)
Initial commit.
1 dashley 35 #!/usr/bin/php -q
2     <?php
3     //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/standalone/dbconncheck.php,v 1.3 2006/04/02 00:50:34 dashley Exp $
4     //--------------------------------------------------------------------------------
5     //dbconncheck.php--Checks Database Connectivity To The FBO-Prime Database
6     //Copyright (C) 2006 David T. Ashley
7     //
8     //This program is free software; you can redistribute it and/or
9     //modify it under the terms of the GNU General Public License
10     //as published by the Free Software Foundation; either version 2
11     //of the License, or (at your option) any later version.
12     //
13     //This program is distributed in the hope that it will be useful,
14     //but WITHOUT ANY WARRANTY; without even the implied warranty of
15     //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16     //GNU General Public License for more details.
17     //
18     //You should have received a copy of the GNU General Public License
19     //along with this program; if not, write to the Free Software
20     //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21     //--------------------------------------------------------------------------------
22     //Set the include file path. This is necessary to get to the configuration
23     //information, including how to try to connect to the database.
24     set_include_path("/var/www/php_library/fboprime");
25     //
26     //Include the configuration information.
27     require_once("config.inc");
28     //
29     //--------------------------------------------------------------------------------
30     //Returns a version control string. Used for randomness.
31     //
32     function vc_info()
33     {
34     return("\$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/standalone/dbconncheck.php,v 1.3 2006/04/02 00:50:34 dashley Exp $");
35     }
36     //--------------------------------------------------------------------------------
37     //--------------------------------------------------------------------------------
38     //--------------------------------------------------------------------------------
39     //------ M A I N S C R I P T ------------------------------------------------
40     //--------------------------------------------------------------------------------
41     //--------------------------------------------------------------------------------
42     //--------------------------------------------------------------------------------
43     //
44     if ($argc == 1)
45     {
46     //The no-parameters case, as expected.
47    
48     $handle = mysql_connect(CONFIG_MYSQL_SERVER, CONFIG_MYSQL_USERNAME, CONFIG_MYSQL_PASSWORD);
49     $handle_copy = $handle;
50     if ($handle === FALSE)
51     {
52     echo "ERROR: Unable to connect and/or authenticate to MySQL database.\n";
53     exit(1);
54     }
55    
56     $result = mysql_select_db(CONFIG_MYSQL_DATABASE, $handle);
57     if ($result === FALSE)
58     {
59     echo "ERROR: Unable to select MySQL database \"" . CONFIG_MYSQL_DATABASE . "\".\n";
60     exit(1);
61     }
62    
63     $result = mysql_close($handle);
64     if ($result === FALSE)
65     {
66     echo "ERROR: Unable to close MySQL connection.\n";
67     exit(1);
68     }
69    
70     //If we've made it this far, things are OK.
71     echo "Success (";
72     echo vc_info();
73     echo ")\n";
74     echo "Server : " . CONFIG_MYSQL_SERVER . "\n";
75     echo "Username : " . CONFIG_MYSQL_USERNAME . "\n";
76     echo "Password : " . CONFIG_MYSQL_PASSWORD . "\n";
77     echo "Database : " . CONFIG_MYSQL_DATABASE . "\n";
78     echo "Handle returned : " . $handle_copy . "\n";
79    
80     exit(0);
81     }
82     else
83     {
84     echo "ERROR: This command accepts no command-line parameters.\n";
85     exit(1);
86     }
87    
88     //If we're here, success. Per the standard Unix way of thinking
89     //say nothing. Silence means OK.
90     exit(0);
91     //
92     //--------------------------------------------------------------------------------
93     //End of $RCSfile: dbconncheck.php,v $.
94     //--------------------------------------------------------------------------------
95     ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25