Esempio n. 1
0
         if (!is_writable('datas') || !copy($file['config_sample'], $file['config'])) {
             cot_error('install_error_config');
         }
     }
     break;
 case 2:
     // Database setup
     $db_x = cot_import('db_x', 'P', 'TXT', 0, false, true);
     try {
         $dbc_port = empty($db_port) ? '' : ';port=' . $db_port;
         $db = new CotDB('mysql:host=' . $db_host . $dbc_port . ';dbname=' . $db_name, $db_user, $db_pass);
     } catch (PDOException $e) {
         if ($e->getCode() == 1049 || mb_strpos($e->getMessage(), '[1049]') !== false) {
             // Attempt to create a new database
             try {
                 $db = new CotDB('mysql:host=' . $db_host . $dbc_port, $db_user, $db_pass);
                 $db->query("CREATE DATABASE `{$db_name}`");
                 $db->query("USE `{$db_name}`");
             } catch (PDOException $e) {
                 cot_error('install_error_sql_db', 'db_name');
             }
         } else {
             cot_error('install_error_sql', 'db_host');
         }
     }
     if (!cot_error_found() && function_exists('version_compare') && !version_compare($db->getAttribute(PDO::ATTR_SERVER_VERSION), '5.0.7', '>=')) {
         cot_error(cot_rc('install_error_sql_ver', array('ver' => $db->getAttribute(PDO::ATTR_SERVER_VERSION))));
     }
     if (!cot_error_found()) {
         $config_contents = file_get_contents($file['config']);
         cot_install_config_replace($config_contents, 'mysqlhost', $db_host);
Esempio n. 2
0
    if (empty($_SESSION['cot_inst_lang'])) {
        $lang = cot_import('lang', 'P', 'ALP');
        if (empty($lang)) {
            $lang = cot_lang_determine();
        }
    } else {
        $lang = $_SESSION['cot_inst_lang'];
    }
    require_once cot_langfile('main', 'core');
    require_once $cfg['system_dir'] . '/resources.rc.php';
} else {
    $branch = 'siena';
    $prev_branch = 'genoa';
    require_once $cfg['system_dir'] . '/database.php';
    $dbc_port = empty($cfg['mysqlport']) ? '' : ';port=' . $cfg['mysqlport'];
    $db = new CotDB('mysql:host=' . $cfg['mysqlhost'] . $dbc_port . ';dbname=' . $cfg['mysqldb'], $cfg['mysqluser'], $cfg['mysqlpassword']);
    cot::init();
    $sql_install = @$db->query("SHOW TABLES LIKE '{$db_updates}'");
    if ($sql_install->rowCount() != 1) {
        define('COT_UPGRADE', true);
        $cfg['defaulttheme'] = 'nemesis';
        $cfg['defaultscheme'] = 'default';
    }
    require_once $cfg['system_dir'] . '/common.php';
}
require_once cot_incfile('forms');
require_once cot_incfile('extensions');
require_once cot_langfile('install', 'module');
require_once cot_langfile('users', 'core');
require_once cot_langfile('admin', 'core');
require_once cot_incfile('install', 'module', 'resources');
Esempio n. 3
0
    $cache = new Cache();
    if ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($_COOKIE[$sys['site_id']]) && empty($_SESSION[$sys['site_id']]) && !defined('COT_AUTH') && !defined('COT_ADMIN') && !defined('COT_INSTALL') && !defined('COT_MESSAGE')) {
        $cache_ext = empty($_GET['e']) ? 'index' : preg_replace('#\\W#', '', $_GET['e']);
        if ($cfg['cache_' . $cache_ext]) {
            $cache->page->init($cache_ext, $cfg['defaulttheme']);
            $cache->page->read();
        }
    }
} else {
    $cache = false;
}
/* ======== Connect to the SQL DB======== */
require_once $cfg['system_dir'] . '/database.php';
try {
    $dbc_port = empty($cfg['mysqlport']) ? '' : ';port=' . $cfg['mysqlport'];
    $db = new CotDB('mysql:host=' . $cfg['mysqlhost'] . $dbc_port . ';dbname=' . $cfg['mysqldb'], $cfg['mysqluser'], $cfg['mysqlpassword']);
} catch (PDOException $e) {
    cot_diefatal('Could not connect to database !<br />
		Please check your settings in the file datas/config.php<br />
		MySQL error : ' . $e->getMessage());
}
unset($cfg['mysqlhost'], $cfg['mysqluser'], $cfg['mysqlpassword'], $dbc_port);
// Here we can init our globals facade
cot::init();
$cache && $cache->init();
/* ======== Configuration settings ======== */
if ($cache && $cot_cfg) {
    $cfg = array_merge($cot_cfg, $cfg);
} else {
    // Part 1: Load main configuration
    $sql_config = $db->query("SELECT * FROM {$db_config}");