along with kidsafe. If not, see <http://www.gnu.org/licenses/>. */ /** Parameters **/ // Possible future options (not included) // filter maxlines order include 'kidsafe-config.php'; // configuration (eg. mysql login) // autoload any classes as required function __autoload($class_name) { include 'inc/' . $class_name . '.php'; } /*** Connect to database ***/ $db = new Database($dbsettings); $kdb = new KidsafeDB($db); if ($db->getStatus() != 1) { die("Unable to connect to the database"); } // used to set messages to provide to the user (eg. 'proxy not disabled for local network'); // including <br> on the end of each message will keep the messages separate for the user $user_messages = ''; /** Check for login - or redirect to login.php **/ $session = new DashboardSession(); // are we logged in already? if ($session->getUsername() == '') { //If not redirect to login page - then redirect here //header("Location: dashboardlogin.php?redirect=dashboard.php"); // can't redirect within ajax so just return message print "Not logged in"; exit(0); }
// check that settings loaded OK // If didn't load then something has gone wrong // corrupt file / write failed part way through if (!isset($dbsettings)) { $second_config_file = isset($cfgfile) ? $cfgfile : ""; displayConfigError($first_config_file, $second_config_file); exit(0); } /* Config files exist so now try creating database skeleton */ /* Setup database connection */ // Uses Database class directly (not QuizDB as is used by main code) // Use Quizdb later once we have created the database require_once $app_dir . "/includes/Database.php"; $db = new Database($dbsettings); // Connected if ($db->getStatus() == 1) { // status = 1 - means that we have connected to database and the database exists (use db) // we are not asking user to confirm that they are installing into these database // in many cases the database will need to be created outside of the install script so don't // want to impose too many "are you sure?" questions // we will still not overwrite as we check tables don't exist before creating $action_required = 'tables'; } elseif ($db->getStatus() == -2) { // We can only create db if we are on mysql (in this version) if ($dbsettings['dbtype'] == 'mysql') { // Try creating database if (!$db->createDb($dbsettings['database'])) { // unable to create database - most likely permissions - hosted accounts may need to create // the database using the hosting cpanel etc. displayDbError("Unable to create new database " . $dbsettings['database'] . " <br />\nThis is normally due to insufficient permissions. If using a hosting account on a shared server you may need to use cpanel or ask your hosting provider for how to create a database<br />\nPlease read the install documentation for more details and then create the database manually before reloading this page.\n"); exit(0);