Ejemplo n.º 1
0
 /**
  * Given the hash of a some data, check to see whether it exists in
  * `tbl_cache`. If no cached object is found, this function will return
  * false, otherwise the cached object will be returned as an array.
  *
  * @param string $hash
  *  The hash of the Cached object, as defined by the user
  * @param string $namespace
  *  The namespace allows a group of data to be retrieved at once
  * @return array|boolean
  *  An associative array of the cached object including the creation time,
  *  expiry time, the hash and the data. If the object is not found, false will
  *  be returned.
  */
 public function read($hash, $namespace = null)
 {
     $data = false;
     // Check namespace first
     if (!is_null($namespace)) {
         $data = $this->Database->fetch("\n                SELECT SQL_NO_CACHE *\n                FROM `tbl_cache`\n                WHERE `namespace` = '{$namepspace}'\n                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)\n            ");
     }
     // Then check hash
     if (!is_null($hash)) {
         $data = $this->Database->fetchRow(0, "\n                SELECT SQL_NO_CACHE *\n                FROM `tbl_cache`\n                WHERE `hash` = '{$hash}'\n                AND (`expiry` IS NULL OR UNIX_TIMESTAMP() <= `expiry`)\n                LIMIT 1\n            ");
     }
     // If the data exists, see if it's still valid
     if ($data) {
         if (!($data['data'] = Cacheable::decompressData($data['data']))) {
             $this->delete($hash, $namespace);
             return false;
         }
         return $data;
     }
     $this->delete(null, $namespace);
     return false;
 }
Ejemplo n.º 2
0
    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/');
        }
    }
Ejemplo n.º 3
0
 function refresh_cus_credit()
 {
     $mysql = new MySQL();
     $sql_cusnum = 'SELECT COUNT(*) FROM customer_info;';
     $result = $mysql->query($sql_cusnum);
     $row = $mysql->fetch($result);
     $cus_num = $row[0];
     for ($num = 1; $num <= $cus_num; $num++) {
         $sql_cuscredit = "select sum(order_price) from orders as o Join customer_info as c ON o.customer_id=c.customer_id where c.cus_number='{$num}';";
         $result_cuscredit = $mysql->query($sql_cuscredit);
         $row_cuscredit = $mysql->fetch($result_cuscredit);
         $sql_refcredit = "UPDATE customer_info SET credit = '{$row_cuscredit['0']}' where cus_number='{$num}';";
         $mysql->query($sql_refcredit);
     }
 }
Ejemplo n.º 4
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/');
        }
    }
Ejemplo n.º 5
0
        <link type="text/css" rel="stylesheet" href="css/kube.css"/>
    </head>
    <body><br/>
        <row centered>
        <column cols="6">
        <?php 
require_once "database.php";
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
session_start();
$mysql = new MySQL();
$sql_foodinfo = "select s.food_id,s.cata_name as food_name,s.price,p.cata_name from food_catalogue as s join food_catalogue as p where p.food_id = s.catalog_id and  s.food_id != s.catalog_id;";
$result = $mysql->query($sql_foodinfo);
$food_cata_info = array();
echo "<form action ='submit.php' method = 'post'>";
echo "<table class ='table-bordered'>";
while ($row = $mysql->fetch($result)) {
    $food_cata_info['name'][$row['food_id']] = $row['food_name'];
    $food_cata_info['price'][$row['food_id']] = $row['price'];
    $food_cata_info['cata'][$row['food_id']] = $row['cata_name'];
}
$datetime = date('m-d-y h:i:s', time());
echo "<th colspan='4'><span style='font-size: 26px;'>New Order</span> {$datetime}</th>";
echo "<tr class='bold'><td>Food Type</td><td>Food Name</td><td>Price</td><td>Quantity</td></tr>";
$totalid = $mysql->fetch($mysql->query('select count(*) from food_catalogue;'))[0];
$create_res = array();
$totalp = 0;
$itemcount = 0;
for ($f_id = 11; $f_id < $totalid; $f_id++) {
    $f_quantity = $_POST[$f_id];
    if (!empty($_POST[$f_id])) {
        echo "<tr><td>" . $food_cata_info['cata'][$f_id] . "</td>";
Ejemplo n.º 6
0
Archivo: e.php Proyecto: serghei/wmvc
 static function text($text)
 {
     $content = "";
     $related = 0;
     $rel_tooltips = "";
     $lines = explode("\n", $text);
     $list = false;
     foreach ($lines as $line) {
         $line = trim($line);
         $first_char = substr($line, 0, 1);
         if (!$list and "=" == $first_char) {
             $content .= "<ul>";
         } else {
             if ($list and "=" != $first_char) {
                 $content .= "</ul>";
             }
         }
         $list = $first_char === "=";
         if ($list) {
             $text = "<li>" . htmlspecialchars(trim(substr($line, 1, 999))) . "</li>";
         } else {
             $text = "<p>" . htmlspecialchars($line) . "</p>";
         }
         $text = str_replace("[**", "<span class=\"info\">", $text);
         $text = str_replace("**]", "</span>", $text);
         $text = str_replace("{{", "<em>", $text);
         $text = str_replace("}}", "</em>", $text);
         $text = str_replace("[[", "<strong>", $text);
         $text = str_replace("]]", "</strong>", $text);
         // process related
         if ('%' == $first_char) {
             list($head, $id_prods) = explode('|', trim(substr($line, 1, 999)));
             MySQL::query("SELECT id, cat, link, brand, title, brief, price FROM products WHERE shown=1 AND id IN ({$id_prods}) ORDER BY FIELD (id, {$id_prods})");
             if (0 == MySQL::rows()) {
                 continue;
             }
             $related++;
             $i = 0;
             $prods = array();
             while ($row = MySQL::fetch()) {
                 list($id, $cat, $link, $brand, $title, $brief, $price) = $row;
                 $prods[$i++] = array($id, $cat, $link, $brand, $title, $brief, $price);
             }
             if ($_SERVER["REMOTE_ADDR"] == "109.99.148.134xx") {
                 $text = '<div class="row"><div class="col-md-12">';
                 $text .= '<div class="carousel slide">';
                 $text .= '<div class="carousel-inner">';
                 $text .= 'test';
                 $text .= '</div></div></div></div>';
             }
             $text = "<strong>{$head}</strong><ul id=\"related{$related}\" class=\"related-skin\">";
             foreach ($prods as $prod) {
                 list($id, $cat, $link, $brand, $title, $brief, $price) = $prod;
                 $text .= "<li id='rel_{$id}'>" . show_small_image($link, "");
                 $text .= "<input type='hidden' value='/{$cat}/" . urlencode($link) . "'>";
                 $text .= "<div class='title'>{$title}</div>";
                 $text .= "<div class='brand'>{$brand}</div>";
                 $text .= "<div class='price'><strong>" . ($price + 0) . "</strong> LEI</div>";
                 $text .= "</li>";
                 $rel_tooltips .= "\t\$('#rel_{$id}').poshytip({ content: '" . str_replace("'", "\\'", $brief) . "', className: 'tip-darkgray', showTimeout: 100 });\n";
             }
             $text .= "</ul>";
         }
         // process links
         $offset = 0;
         while (true) {
             $beg = strpos($text, "&lt;&lt;", $offset);
             if (false === $beg) {
                 break;
             }
             $end = strpos($text, "&gt;&gt;", $beg);
             if (false === $end) {
                 $end = strlen($text);
             }
             $text1 = substr($text, 0, $beg);
             $text2 = substr($text, $beg + 8, $end - $beg - 8);
             $text3 = substr($text, $end + 8);
             list($link, $text) = explode("|", $text2);
             if (!$text) {
                 $text = $uri;
             }
             $text2 = "<a href='{$link}'>{$text}</a>";
             $text = $text1 . $text2 . $text3;
             $offset = $end;
         }
         $content .= $text;
     }
     if ($line) {
         $content .= "</ul>";
     }
     if ($related) {
         $content .= "\n" . '<script type="text/javascript">' . "\n";
         $content .= '$(document).ready(function() {' . "\n";
         for ($i = 1; $i <= $related; $i++) {
             $content .= "\t" . '$("#related' . $i . '").jcarousel();' . "\n";
         }
         $content .= $rel_tooltips;
         $content .= "});\n</script>\n";
     }
     return $content;
 }