function install(&$Page, $fields)
    {
        global $warnings;
        $database_connection_error = false;
        try {
            $db = new MySQL();
            $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
            $tables = $db->fetch(sprintf("SHOW TABLES FROM `%s` LIKE '%s'", mysql_escape_string($fields['database']['name']), mysql_escape_string($fields['database']['prefix']) . '%'));
        } catch (DatabaseException $e) {
            $database_connection_error = true;
        }
        ## Invalid path
        if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
            $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-symphony-dir');
            }
        } elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) {
            $Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'existing-htaccess');
            }
        } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
            $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-workspace');
            }
        } elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
            $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], E_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-root');
            }
        } elseif ($database_connection_error) {
            $Page->log->pushToLog("Configuration - Could not establish database connection", E_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (version_compare($db->fetchVar('version', 0, "SELECT VERSION() AS `version`;"), '4.1', '<')) {
            $version = $db->fetchVar('version', 0, "SELECT VERSION() AS `version`;");
            $Page->log->pushToLog('Configuration - MySQL Version is not correct. ' . $version . ' detected.', E_NOTICE, true);
            define("kDATABASE_VERSION_WARNING", true);
            $warnings['database-incorrect-version'] = __('Symphony requires <code>MySQL 4.1</code> or greater to work, however version <code>%s</code> was detected. This requirement must be met before installation can proceed.', array($version));
            if (!defined("ERROR")) {
                define("ERROR", 'database-incorrect-version');
            }
        } elseif (!$db->select($fields['database']['name'])) {
            $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", E_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (is_array($tables) && !empty($tables)) {
            $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", E_NOTICE, true);
            define("kDATABASE_PREFIX_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'database-table-clash');
            }
        } elseif (trim($fields['user']['username']) == '') {
            $Page->log->pushToLog("Configuration - No username entered.", E_NOTICE, true);
            define("kUSER_USERNAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-username');
            }
        } elseif (trim($fields['user']['password']) == '') {
            $Page->log->pushToLog("Configuration - No password entered.", E_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-password');
            }
        } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
            $Page->log->pushToLog("Configuration - Passwords did not match.", E_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-password-mismatch');
            }
        } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
            $Page->log->pushToLog("Configuration - Did not enter First and Last names.", E_NOTICE, true);
            define("kUSER_NAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-name');
            }
        } elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $fields['user']['email'])) {
            $Page->log->pushToLog("Configuration - Invalid email address supplied.", E_NOTICE, true);
            define("kUSER_EMAIL_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-invalid-email');
            }
        } else {
            $config = $fields;
            $kDOCROOT = rtrim($config['docroot'], '/');
            $database = array_map("trim", $fields['database']);
            if (!isset($database['host']) || $database['host'] == "") {
                $database['host'] = "localhost";
            }
            if (!isset($database['port']) || $database['port'] == "") {
                $database['port'] = "3306";
            }
            if (!isset($database['prefix']) || $database['prefix'] == "") {
                $database['prefix'] = "sym_";
            }
            $install_log = $Page->log;
            $start = time();
            $install_log->writeToLog(CRLF . '============================================', true);
            $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true);
            $install_log->writeToLog('============================================', true);
            $install_log->pushToLog("MYSQL: Establishing Connection...", E_NOTICE, true, false);
            $db = new MySQL();
            if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) {
                define('_INSTALL_ERRORS_', "There was a problem while trying to establish a connection to the MySQL server. Please check your settings.");
                $install_log->pushToLog("Failed", E_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", E_NOTICE, true, false);
            if (!$db->select($database['name'])) {
                define('_INSTALL_ERRORS_', "Could not connect to specified database. Please check your settings.");
                $install_log->pushToLog("Failed", E_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $db->setPrefix($database['prefix']);
            $conf = getDynamicConfiguration();
            if ($conf['database']['runtime_character_set_alter'] == '1') {
                $db->setCharacterEncoding($conf['database']['character_encoding']);
                $db->setCharacterSet($conf['database']['character_set']);
            }
            $install_log->pushToLog("MYSQL: Importing Table Schema...", E_NOTICE, true, false);
            $error = NULL;
            if (!fireSql($db, getTableSchema(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $author_sql = sprintf("INSERT INTO  `tbl_authors` (\n\t\t\t\t\t\t`id` , \n\t\t\t\t\t\t`username` , \n\t\t\t\t\t\t`password` , \n\t\t\t\t\t\t`first_name` , \n\t\t\t\t\t\t`last_name` , \n\t\t\t\t\t\t`email` , \n\t\t\t\t\t\t`last_seen` , \n\t\t\t\t\t\t`user_type` , \n\t\t\t\t\t\t`primary` , \n\t\t\t\t\t\t`default_section` , \n\t\t\t\t\t\t`auth_token_active`\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\tMD5('%s'),\n\t\t\t\t\t\t'%s',  \n\t\t\t\t\t\t'%s',  \n\t\t\t\t\t\t'%s', \n\t\t\t\t\t\tNULL ,  \n\t\t\t\t\t\t'developer',  \n\t\t\t\t\t\t'yes',  \n\t\t\t\t\t\t'6',  \n\t\t\t\t\t\t'no'\n\t\t\t\t\t);", $db->cleanValue($config['user']['username']), $db->cleanValue($config['user']['password']), $db->cleanValue($config['user']['firstname']), $db->cleanValue($config['user']['lastname']), $db->cleanValue($config['user']['email']));
            $install_log->pushToLog("MYSQL: Creating Default Author...", E_NOTICE, true, false);
            if (!$db->query($author_sql)) {
                $error = $db->getLastError();
                define('_INSTALL_ERRORS_', "There was an error while trying create the default author. MySQL returned: " . $error['num'] . ': ' . $error['msg']);
                $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", E_NOTICE, true, true, true);
            }
            $conf = array();
            if (@is_dir($fields['docroot'] . '/workspace')) {
                foreach (getDynamicConfiguration() as $group => $settings) {
                    if (!is_array($conf['settings'][$group])) {
                        $conf['settings'][$group] = array();
                    }
                    $conf['settings'][$group] = array_merge($conf['settings'][$group], $settings);
                }
            } else {
                $conf['settings']['admin']['max_upload_size'] = '5242880';
                $conf['settings']['symphony']['pagination_maximum_rows'] = '17';
                $conf['settings']['symphony']['allow_page_subscription'] = '1';
                $conf['settings']['symphony']['lang'] = defined('__LANG__') ? __LANG__ : 'en';
                $conf['settings']['symphony']['pages_table_nest_children'] = 'no';
                $conf['settings']['log']['archive'] = '1';
                $conf['settings']['log']['maxsize'] = '102400';
                $conf['settings']['image']['cache'] = '1';
                $conf['settings']['image']['quality'] = '90';
                $conf['settings']['database']['driver'] = 'mysql';
                $conf['settings']['database']['character_set'] = 'utf8';
                $conf['settings']['database']['character_encoding'] = 'utf8';
                $conf['settings']['database']['runtime_character_set_alter'] = '1';
                $conf['settings']['public']['display_event_xml_in_source'] = 'no';
            }
            $conf['settings']['symphony']['version'] = kVERSION;
            $conf['settings']['symphony']['cookie_prefix'] = 'sym-';
            $conf['settings']['general']['useragent'] = 'Symphony/' . kVERSION;
            $conf['settings']['general']['sitename'] = strlen(trim($config['general']['sitename'])) > 0 ? $config['general']['sitename'] : __('Website Name');
            $conf['settings']['file']['write_mode'] = $config['permission']['file'];
            $conf['settings']['directory']['write_mode'] = $config['permission']['directory'];
            $conf['settings']['database']['host'] = $database['host'];
            $conf['settings']['database']['port'] = $database['port'];
            $conf['settings']['database']['user'] = $database['username'];
            $conf['settings']['database']['password'] = $database['password'];
            $conf['settings']['database']['db'] = $database['name'];
            $conf['settings']['database']['tbl_prefix'] = $database['prefix'];
            $conf['settings']['region']['time_format'] = $config['region']['time_format'];
            $conf['settings']['region']['date_format'] = $config['region']['date_format'];
            $conf['settings']['region']['timezone'] = $config['region']['timezone'];
            ## Create Manifest directory structure
            #
            $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'manifest' directory. Check permission on the root folder.");
                $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'logs' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'cache' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", E_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not create 'tmp' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Configuration File", E_NOTICE, true, true);
            if (!writeConfig($kDOCROOT . '/manifest/', $conf, $conf['settings']['file']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not write config file. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Writing Configuration File Failed", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            $rewrite_base = trim(dirname($_SERVER['PHP_SELF']), '/');
            if (strlen($rewrite_base) > 0) {
                $rewrite_base .= '/';
            }
            $htaccess = '
### Symphony 2.0.x ###
Options +FollowSymlinks

<IfModule mod_rewrite.c>

	RewriteEngine on
	RewriteBase /' . $rewrite_base . '

	### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
	RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
	RewriteRule .* - [S=14]	

	### IMAGE RULES	
	RewriteRule ^image\\/(.+\\.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC]

	### CHECK FOR TRAILING SLASH - Will ignore files
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !/$
	RewriteCond %{REQUEST_URI} !(.*)/$
	RewriteRule ^(.*)$ $1/ [L,R=301]

	### ADMIN REWRITE
	RewriteRule ^symphony\\/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]

	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f	
	RewriteRule ^symphony(\\/(.*\\/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}	[NC,L]

	### FRONTEND REWRITE - Will ignore files and folders
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*\\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}	[L]
	
</IfModule>
######
';
            $install_log->pushToLog("CONFIGURING: Frontend", E_NOTICE, true, true);
            if (!GeneralExtended::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'])) {
                define('_INSTALL_ERRORS_', "Could not write .htaccess file. Check permission on " . $kDOCROOT);
                $install_log->pushToLog("ERROR: Writing .htaccess File Failed", E_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            if (@(!is_dir($fields['docroot'] . '/workspace'))) {
                ### Create the workspace folder structure
                #
                $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/data-sources' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/events' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/pages' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'workspace/utilities' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            } else {
                $install_log->pushToLog("MYSQL: Importing Workspace Data...", E_NOTICE, true, false);
                $error = NULL;
                if (!fireSql($db, getWorkspaceData(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                    define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}");
                    $install_log->pushToLog("Failed", E_ERROR, true, true, true);
                    installResult($Page, $install_log, $start);
                } else {
                    $install_log->pushToLog("Done", E_NOTICE, true, true, true);
                }
            }
            if (@(!is_dir($fields['docroot'] . '/extensions'))) {
                $install_log->pushToLog("WRITING: Creating 'campfire' folder (/extensions)", E_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/extensions', $conf['settings']['directory']['write_mode'])) {
                    define('_INSTALL_ERRORS_', "Could not create 'extensions' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'extensions' folder failed.", E_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", E_NOTICE, true);
            installResult($Page, $install_log, $start);
            redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/');
        }
    }
Example #2
0
    function install(&$Page, $fields)
    {
        $db = new MySQL();
        $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']);
        if ($db->isConnected()) {
            $tables = $db->fetch("SHOW TABLES FROM `" . $fields['database']['name'] . "` LIKE '" . mysql_escape_string($fields['database']['prefix']) . "%'");
        }
        ## Invalid path
        if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) {
            $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-symphony-dir');
            }
        } elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) {
            $Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'existing-htaccess');
            }
        } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) {
            $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-workspace');
            }
        } elseif (!is_writable(rtrim($fields['docroot'], '/'))) {
            $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], SYM_LOG_NOTICE, true);
            define("kENVIRONMENT_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-write-permission-root');
            }
        } elseif (!$db->isConnected()) {
            $Page->log->pushToLog("Configuration - Could not establish database connection", SYM_LOG_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (!$db->select($fields['database']['name'])) {
            $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", SYM_LOG_NOTICE, true);
            define("kDATABASE_CONNECTION_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'no-database-connection');
            }
        } elseif (is_array($tables) && !empty($tables)) {
            $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", SYM_LOG_NOTICE, true);
            define("kDATABASE_PREFIX_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'database-table-clash');
            }
        } elseif (trim($fields['user']['username']) == '') {
            $Page->log->pushToLog("Configuration - No username entered.", SYM_LOG_NOTICE, true);
            define("kUSER_USERNAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-username');
            }
        } elseif (trim($fields['user']['password']) == '') {
            $Page->log->pushToLog("Configuration - No password entered.", SYM_LOG_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-password');
            }
        } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) {
            $Page->log->pushToLog("Configuration - Passwords did not match.", SYM_LOG_NOTICE, true);
            define("kUSER_PASSWORD_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-password-mismatch');
            }
        } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') {
            $Page->log->pushToLog("Configuration - Did not enter First and Last names.", SYM_LOG_NOTICE, true);
            define("kUSER_NAME_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-no-name');
            }
        } elseif (!ereg('^[a-zA-Z0-9_\\.\\-]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.]+$', $fields['user']['email'])) {
            $Page->log->pushToLog("Configuration - Invalid email address supplied.", SYM_LOG_NOTICE, true);
            define("kUSER_EMAIL_WARNING", true);
            if (!defined("ERROR")) {
                define("ERROR", 'user-invalid-email');
            }
        } else {
            $config = $fields;
            $kDOCROOT = rtrim($config['docroot'], '/');
            $database = array_map("trim", $fields['database']);
            if (!isset($database['host']) || $database['host'] == "") {
                $database['host'] = "localhost";
            }
            if (!isset($database['port']) || $database['port'] == "") {
                $database['port'] = "3306";
            }
            if (!isset($database['prefix']) || $database['prefix'] == "") {
                $database['prefix'] = "sym_";
            }
            $install_log = $Page->log;
            $start = time();
            $install_log->writeToLog(CRLF . '============================================', true);
            $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . date("d.m.y H:i:s") . ')', true);
            $install_log->writeToLog('============================================', true);
            $db = new MySQL();
            $install_log->pushToLog("MYSQL: Establishing Connection...", SYM_LOG_NOTICE, true, false);
            $db = new MySQL();
            if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) {
                define("_INSTALL_ERRORS_", "There was a problem while trying to establish a connection to the MySQL server. Please check your settings.");
                $install_log->pushToLog("Failed", SYM_LOG_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", SYM_LOG_NOTICE, true, false);
            if (!$db->select($database['name'])) {
                define("_INSTALL_ERRORS_", "Could not connect to specified database. Please check your settings.");
                $install_log->pushToLog("Failed", SYM_LOG_NOTICE, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $db->setPrefix($database['prefix']);
            $install_log->pushToLog("MYSQL: Creating Tables...", SYM_LOG_NOTICE, true, false);
            $error = NULL;
            if (!fireSql($db, getTableSchema(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                define("_INSTALL_ERRORS_", "There was an error while trying to create tables in the database. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $author_sql = "INSERT INTO `tbl_authors` " . "(username, password, firstname, lastname, email, superuser, owner, textformat) " . "VALUES (" . "'" . $config['user']['username'] . "', " . "'" . md5($config['user']['password']) . "', " . "'" . $config['user']['firstname'] . "', " . "'" . $config['user']['lastname'] . "', " . "'" . $config['user']['email'] . "', " . "'1', '1', 'simplehtml' )";
            $error = NULL;
            $db->query($author_sql, $error);
            if (!empty($error)) {
                define("_INSTALL_ERRORS_", "There was an error while trying create the default author. MySQL returned: {$error}");
                $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true);
                installResult($Page, $install_log, $start);
            } else {
                $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
            }
            $conf = array();
            $conf['define'] = array('DOCROOT' => $kDOCROOT, 'DOMAIN' => str_replace("http://", "", _INSTALL_DOMAIN_));
            $conf['require'] = array($kDOCROOT . '/symphony/lib/boot/bundle.php');
            $conf['settings']['admin']['max_upload_size'] = '5242880';
            $conf['settings']['admin']['handle_length'] = '50';
            $conf['settings']['filemanager']['filetype_restriction'] = 'bmp, jpg, gif, png, doc, rtf, pdf, zip';
            $conf['settings']['filemanager']['enabled'] = 'yes';
            $conf['settings']['filemanager']['log_all_upload_attempts'] = 'yes';
            $conf['settings']['symphony']['build'] = kBUILD;
            $conf['settings']['symphony']['acct_server'] = kSUPPORT_SERVER;
            $conf['settings']['symphony']['update'] = '5';
            $conf['settings']['symphony']['lastupdatecheck'] = time();
            $conf['settings']['symphony']['prune_logs'] = '1';
            $conf['settings']['symphony']['allow_page_subscription'] = '1';
            $conf['settings']['symphony']['strict_section_field_validation'] = '1';
            $conf['settings']['symphony']['allow_primary_field_handles_to_change'] = '1';
            $conf['settings']['symphony']['pagination_maximum_rows'] = '17';
            $conf['settings']['symphony']['cookie_prefix'] = 'sym_';
            $conf['settings']['xsl']['exclude-parameter-declarations'] = 'off';
            if ($config['theme'] == 'yes') {
                $conf['settings']['general']['sitename'] = 'Symphony Web Publishing System';
            } else {
                $conf['settings']['general']['sitename'] = 'Website Name';
            }
            $conf['settings']['general']['useragent'] = 'Symphony/' . kBUILD;
            $conf['settings']['image']['cache'] = '1';
            $conf['settings']['image']['quality'] = '70';
            $conf['settings']['file']['extend_timeout'] = 'off';
            $conf['settings']['file']['write_mode'] = $config['permission']['file'];
            $conf['settings']['directory']['write_mode'] = $config['permission']['directory'];
            $conf['settings']['database']['driver'] = 'MySQL';
            $conf['settings']['database']['host'] = $database['host'];
            $conf['settings']['database']['port'] = $database['port'];
            $conf['settings']['database']['user'] = $database['username'];
            $conf['settings']['database']['password'] = $database['password'];
            $conf['settings']['database']['db'] = $database['name'];
            $conf['settings']['database']['tbl_prefix'] = $database['prefix'];
            $conf['settings']['database']['character_set'] = 'utf8';
            $conf['settings']['database']['character_encoding'] = 'utf8';
            $conf['settings']['database']['runtime_character_set_alter'] = '0';
            $conf['settings']['public']['status'] = 'online';
            $conf['settings']['public']['caching'] = 'on';
            $conf['settings']['public']['excerpt-length'] = '100';
            $conf['settings']['region']['time_zone'] = '10';
            $conf['settings']['region']['time_format'] = 'g:i a';
            $conf['settings']['region']['date_format'] = 'j F Y';
            $conf['settings']['region']['dst'] = 'no';
            $conf['settings']['workspace']['config_checksum'] = '';
            $conf['settings']['commenting']['allow-by-default'] = 'on';
            $conf['settings']['commenting']['email-notify'] = 'off';
            $conf['settings']['commenting']['allow-duplicates'] = 'off';
            $conf['settings']['commenting']['maximum-allowed-links'] = '3';
            $conf['settings']['commenting']['banned-words'] = '';
            $conf['settings']['commenting']['banned-words-replacement'] = '*****';
            $conf['settings']['commenting']['hide-spam-flagged'] = 'on';
            $conf['settings']['commenting']['formatting-type'] = 'simplehtml';
            $conf['settings']['commenting']['add-nofollow'] = 'off';
            $conf['settings']['commenting']['convert-urls'] = 'off';
            $conf['settings']['commenting']['check-referer'] = 'on';
            $conf['settings']['commenting']['nuke-spam'] = 'on';
            $conf['settings']['commenting']['ip-blacklist'] = '';
            ## Create Manifest directory structure
            #
            $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'manifest' directory. Check permission on the root folder.");
                $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'logs' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'cache' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not create 'tmp' directory. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
                return;
            }
            $install_log->pushToLog("WRITING: Configuration File", SYM_LOG_NOTICE, true, true);
            if (!writeConfig($kDOCROOT . "/manifest/", $conf, $conf['settings']['file']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not write config file. Check permission on /manifest.");
                $install_log->pushToLog("ERROR: Writing Configuration File Failed", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            $rewrite_base = dirname($_SERVER['PHP_SELF']);
            $rewrite_base = trim($rewrite_base, '/');
            if ($rewrite_base != "") {
                $rewrite_base .= '/';
            }
            $htaccess = '
### Symphony 1.7 - Do not edit ###

<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteBase /' . $rewrite_base . '

	### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
	RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
	RewriteRule .* - [S=14]

	### IMAGE RULES
	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/external/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6&external=true [L]
	RewriteRule ^image/external/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2&external=true [L]

	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/external/(.*)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6&external=true [L]
	RewriteRule ^image/external/(.*)\\.(jpg|gif|jpeg|png|bmp)$  /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2&external=true [L]

	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6 	[L]
	RewriteRule ^image/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2 	[L]

	RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/(.*)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6 	[L]
	RewriteRule ^image/(.*)\\.(jpg|gif|jpeg|png|bmp)$   /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2 	[L]

	### CHECK FOR TRAILING SLASH - Will ignore files
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !/' . trim($rewrite_base, '/') . '$
	RewriteCond %{REQUEST_URI} !(.*)/$
	RewriteRule ^(.*)$ /' . $rewrite_base . '$1/ [L,R=301]

	### MAIN REWRITE - This will ignore directories
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.*)\\/$ /' . $rewrite_base . 'index.php?page=$1&%{QUERY_STRING}	[L]

</IfModule>

DirectoryIndex index.php
IndexIgnore *

######
';
            $install_log->pushToLog("CONFIGURING: Frontend", SYM_LOG_NOTICE, true, true);
            if (!GeneralExtended::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'])) {
                define("_INSTALL_ERRORS_", "Could not write .htaccess file. Check permission on " . $kDOCROOT);
                $install_log->pushToLog("ERROR: Writing .htaccess File Failed", SYM_LOG_ERROR, true, true);
                installResult($Page, $install_log, $start);
            }
            if (@is_file($fields['docroot'] . '/workspace/workspace.conf')) {
                $install_log->pushToLog("CONFIGURING: Importing Workspace", SYM_LOG_NOTICE, true, false);
                if (!fireSql($db, file_get_contents($fields['docroot'] . '/workspace/workspace.conf') . getDefaultTableData(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) {
                    define("_INSTALL_ERRORS_", "There was an error while trying to import the workspace data. MySQL returned: {$error}");
                    $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true);
                    installResult($Page, $install_log, $start);
                } else {
                    $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true);
                }
            } elseif (@(!is_dir($fields['docroot'] . '/workspace'))) {
                ### Create the workspace folder structure
                #
                $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/data-sources' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/events' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'masters' folder (/workspace/masters)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/masters', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/masters' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/masters' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/pages' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'text-formatters' folder (/workspace/text-formatters)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/text-formatters', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/text-formatters' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/text-formatters' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'upload' folder (/workspace/upload)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/upload', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/upload' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/upload' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
                $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'workspace/utilities' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            if (@(!is_dir($fields['docroot'] . '/campfire'))) {
                $install_log->pushToLog("WRITING: Creating 'campfire' folder (/campfire)", SYM_LOG_NOTICE, true, true);
                if (!GeneralExtended::realiseDirectory($kDOCROOT . '/campfire', $conf['settings']['directory']['write_mode'])) {
                    define("_INSTALL_ERRORS_", "Could not create 'campfire' directory. Check permission on the root folder.");
                    $install_log->pushToLog("ERROR: Creation of 'campfire' folder failed.", SYM_LOG_ERROR, true, true);
                    installResult($Page, $install_log, $start);
                    return;
                }
            }
            $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", SYM_LOG_NOTICE, true);
            installResult($Page, $install_log, $start);
            GeneralExtended::redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/');
        }
    }
Example #3
0
$db = new MySQL();
/**
 * Include the plugin class.
 */
require_once ROOT . "includes/plugins.php";
$plugins = Plugins;
/**
 * Include and run the settings core class
 */
require_once ROOT . "includes/settings.class.php";
$settings = new settings();
/**
 *	Loop through all settings and define them.
 *	Now we can access the settings anywhere we have a init.php included.
 */
$run = $db->select("settingsitems", "*");
while ($row = $db->fetchAssoc($run)) {
    define($row['code'], $row['value']);
}
/**
 * Include and run the bans api.
 */
require_once ROOT . "includes/bans.php";
$bans = new Bans();
/**
 *	Includes the auth class.
 */
require_once ROOT . "includes/auth.php";
$auth = new auth();
/**
 * Run all plugins that have hooked in.
Example #4
0
        mysql_query($query, self::$db_link);
        return mysql_affected_rows(self::$db_link);
    }
    public function update($query)
    {
        mysql_query($query, self::$db_link);
        return mysql_affected_rows(self::$db_link);
    }
}
$query = new MySQL();
if (isset($_GET['api'])) {
    $get = $_GET;
    $data = array();
    if ($get['api'] == 'listpost') {
        extract($get);
        $data['result'] = $query->select("Select p.*,u.fullname as fullname from post p join `users` u ON p.userid = u.id limit {$offset},{$limit}");
        $data['error'] = 0;
    } elseif ($get['api'] == 'postincategory') {
        extract($get);
        $sql = "Select p.*,u.fullname as fullname from post p join `users` u ON p.userid = u.id where p.catid = {$cid} limit {$offset},{$limit}";
        $data['result'] = $query->select($sql);
        $data['error'] = 0;
    } else {
        if ($get['api'] == 'listcategory') {
            $data['result'] = $query->select("Select * from category");
            $data['error'] = 0;
        } else {
            if ($get['api'] == 'category') {
                extract($get);
                $data['result'] = $query->select("Select * from category where id = {$id}");
                $data['error'] = 0;
Example #5
0
<?php
require_once 'MySQL.php';
require_once 'Lift.php';
require_once 'config.php';

$db = new MySQL($dbuser, $dbpass, $dbbase, $dbhost);

$res = $db->select('SELECT `value` FROM `config` WHERE `key` = "floorNamingStyle"');
$floorNamingStyle = $res[0][0]; // 'World' or 'American'

$lifts = array();

$res = $db->select('SELECT `id` FROM `lifts`');
if (!empty($res))
{
	foreach ($res as $row)
	{
		$id = $row['id'];
		$lifts[$id] = new Lift($id);
	}
}

function doHeader($title = '')
{
?>
<!DOCTYPE html>
<html>
  <head>
    <title>Lift Simulator<?php if ($title != '') echo ' - ' . $title; ?></title>
    <meta charset="UTF-8" />
    <link rel="stylesheet" type="text/css" href="style.css" />