Subversion Repositories Applications.papyrus

Rev

Rev 1087 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
 
3
////////////////////////////////////////////////////////////////////////////////
4
//                                                                            //
5
//   Copyright (C) 2006  Phorum Development Team                              //
6
//   http://www.phorum.org                                                    //
7
//                                                                            //
8
//   This program is free software. You can redistribute it and/or modify     //
9
//   it under the terms of either the current Phorum License (viewable at     //
10
//   phorum.org) or the Phorum License that was distributed with this file    //
11
//                                                                            //
12
//   This program is distributed in the hope that it will be useful,          //
13
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
14
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
15
//                                                                            //
16
//   You should have received a copy of the Phorum License                    //
17
//   along with this program.                                                 //
18
////////////////////////////////////////////////////////////////////////////////
19
 
20
    // Check the database connection and setup. We may want to have finer
21
    // granulated checks here to give users with problem real good
22
    // information about what should be fixed, but for that the
23
    // database layer must be extended. For now it's just a simple
24
    // connect check that will mostly just sit there and be pretty ;-)
25
    //
26
    // Extra checks to think about:
27
    // - test if all needed permissions are set;
28
    // - catch the error from the database on connection failure and
29
    //   try to give the user specific data for fixing the problem.
30
 
31
    $phorum_check = "Database connection";
32
 
33
    function phorum_check_database() {
34
        $PHORUM = $GLOBALS["PHORUM"];
35
 
36
        // Check if we have a database configuration available.
37
        if (! isset($PHORUM["DBCONFIG"])) return array(
38
            PHORUM_SANITY_CRIT,
39
            "No database configuration was found in your environment.",
40
            "You probably have not copied include/db/config.php.sample
41
             to include/db/config.php. Read Phorum's install.txt for
42
             installation instructions."
43
        );
44
 
45
        // Check if a connection can be made.
46
        $connected = @phorum_db_check_connection();
47
        if (! $connected) return array(
48
            PHORUM_SANITY_CRIT,
49
            "Connecting to the database failed.",
50
            "Check your database settings in the file include/db/conf.php"
51
        );
52
 
53
        // Do a database layer specific check, if available.
54
        if (function_exists("phorum_db_sanitychecks")) {
55
            $res = phorum_db_sanitychecks();
56
            if ($res[0] != PHORUM_SANITY_OK) return $res;
57
        }
58
 
59
        // All checks are OK.
60
        return array(PHORUM_SANITY_OK, NULL);
61
    }
62
?>