1: 2: /* -------------------------------------------------------------
3: This file is part of FreeNATS
4:
5: FreeNATS is (C) Copyright 2008 PurplePixie Systems
6:
7: FreeNATS is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeNATS 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. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with Foobar. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freenats
21: -------------------------------------------------------------- */
22:
23: require("include.php");
24: $sn=$_SERVER['SCRIPT_NAME'];
25: $script="";
26: for ($a=strlen($sn)-1; $a>0; $a--)
27: {
28: $c=$sn[$a];
29: if ($c=="/") $a=-1;
30: else $script=$c.$script;
31: }
32: if ($script!="firstrun.php")
33: {
34: echo "Error: This script is not correctly named. In order to run it please rename "".$script."" to "firstrun.php".";
35: echo "
";
36: exit();
37: }
38: if (isset($_REQUEST['stage'])) $stage=$_REQUEST['stage'];
39: else $stage=0;
40:
41: function sqlfile($file)
42: {
43: global $BaseDir;
44: $fn=$BaseDir."sql/".$file.".sql";
45: echo "Processing ".$fn."
";
46: $fp=fopen($fn,"r");
47: if ($fp<=0)
48: {
49: echo "ERROR: Cannot Open File!
";
87:
88: echo "Testing database connectivity... ";
89: $sql=mysql_connect($fnCfg['db.server'],$fnCfg['db.username'],$fnCfg['db.password'])
90: or die("Failed to connect to database server ".$fnCfg['db.server']." with username ".$fnCfg['db.username']." Details: ".mysql_error());
91: mysql_select_db($fnCfg['db.database'])
92: or die("Connected ok but failed to select database ".$fnCfg['db.database']." Details: ".mysql_error());
93: echo "Database connection succeeded!