~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to html/inc/ops.inc

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
// This file is part of BOINC.
3
 
// http://boinc.berkeley.edu
4
 
// Copyright (C) 2008 University of California
5
 
//
6
 
// BOINC is free software; you can redistribute it and/or modify it
7
 
// under the terms of the GNU Lesser General Public License
8
 
// as published by the Free Software Foundation,
9
 
// either version 3 of the License, or (at your option) any later version.
10
 
//
11
 
// BOINC is distributed in the hope that it will be useful,
12
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 
// See the GNU Lesser General Public License for more details.
15
 
//
16
 
// You should have received a copy of the GNU Lesser General Public License
17
 
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
 
 
19
 
// Only allow this script to run from the command line
20
 
//
21
 
function cli_only(){
22
 
    if (array_key_exists("SERVER_PORT", $_SERVER)) {
23
 
        die("<html><h1>
24
 
            This script is intended to be run from the command line,
25
 
            not from the web server!
26
 
            </h1>"
27
 
        );
28
 
    }
29
 
}
30
 
 
31
 
// initialize database connection with username & password from
32
 
// command line instead of config.xml
33
 
//
34
 
function db_init_cli() {
35
 
    $config = get_config();
36
 
    $db_name = parse_config($config, "<db_name>");
37
 
    $host = parse_config($config, "<db_host>");
38
 
    if ($host == null) {
39
 
        $host = "localhost";
40
 
    }
41
 
    $in = fopen("php://stdin","r");
42
 
    print "Database username for $db_name@$host: ";
43
 
    $user = rtrim(fgets($in, 80));
44
 
    print "Database password for $db_name@host: ";
45
 
    $pass = rtrim(fgets($in, 80));
46
 
 
47
 
    $retval = mysql_pconnect($host, $user, $pass);
48
 
    if (!$retval) {
49
 
        return 1;
50
 
    }
51
 
    if (!mysql_select_db($db_name)) {
52
 
        return 2;
53
 
    }
54
 
    return 0;
55
 
}
56
 
 
57
 
?>