2
// This file is part of BOINC.
3
// http://boinc.berkeley.edu
4
// Copyright (C) 2008 University of California
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.
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.
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/>.
19
// Only allow this script to run from the command line
22
if (array_key_exists("SERVER_PORT", $_SERVER)) {
24
This script is intended to be run from the command line,
25
not from the web server!
31
// initialize database connection with username & password from
32
// command line instead of config.xml
34
function db_init_cli() {
35
$config = get_config();
36
$db_name = parse_config($config, "<db_name>");
37
$host = parse_config($config, "<db_host>");
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));
47
$retval = mysql_pconnect($host, $user, $pass);
51
if (!mysql_select_db($db_name)) {