function osc_checkLocales() { $locales = osc_listLocales(); foreach ($locales as $locale) { $data = OSCLocale::newInstance()->findByPrimaryKey($locale['code']); if (!is_array($data)) { $values = array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 's_stop_words' => $locale['stop_words'], 'b_enabled' => 0, 'b_enabled_bo' => 1); $result = OSCLocale::newInstance()->insert($values); if (!$result) { return false; } // if it's a demo, we don't import any sql if (defined('DEMO')) { return true; } // inserting e-mail translations $path = sprintf('%s%s/mail.sql', osc_translations_path(), $locale['code']); if (file_exists($path)) { $sql = file_get_contents($path); $conn = DBConnectionClass::newInstance(); $c_db = $conn->getOsclassDb(); $comm = new DBCommandClass($c_db); $result = $comm->importSQL($sql); if (!$result) { return false; } } } else { // update language version OSCLocale::newInstance()->update(array('s_version' => $locale['version']), array('pk_c_code' => $locale['code'])); } } return true; }
function allSeo_call_after_install() { if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/robots.txt")) { $rob = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/robots.txt"); } else { $rob = ''; } if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/.htaccess")) { $hta = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/.htaccess"); } else { $hta = ''; } ModelSeo::newInstance()->import('all_in_one/model/struct.sql'); osc_set_preference('allSeo_description', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_keywords', 'classified, free classified, classified web, free listings, cars for sale, sale', 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_title_first', '0', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_robots', $rob, 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_robots_enabled', '0', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_htaccess', $hta, 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_htaccess_enabled', '0', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_delimiter', '|', 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_city_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_city_order', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_region_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_region_order', '2', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_country_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_country_order', '3', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_category_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_category_order', '4', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_title_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_title_order', '5', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_body_order', '6', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_page_title', '', 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_search_city_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_city_order', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_region_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_region_order', '2', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_country_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_country_order', '3', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_category_order', '4', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_pattern_order', '6', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_title_show', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_title_order', '5', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_search_page_title', '', 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_search_improve_desc', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_other_page_title', '', 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_sitemap_freq', 'weekly', 'plugin-all_in_one', 'STRING'); osc_set_preference('allSeo_links_footer', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_sitemap_items', '1', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_sitemap_items_limit', '1000', 'plugin-all_in_one', 'INTEGER'); osc_set_preference('allSeo_allow_custom_meta', '1', 'plugin-all_in_one', 'INTEGER'); //upload email templates foreach (osc_listLocales() as $loc) { //bo_mgr_email_expired template $des_link[$loc['code']]['s_title'] = '{WEB_TITLE} - There is problem with backlink placed on your site'; $des_link[$loc['code']]['s_text'] = '<p>Dear Partner!</p> <p>Let us inform you, that we were not able to find link referring to our site: <strong>{LINK_TO}</strong> on your website <strong>{LINK_FROM}</strong>.</p> <p>Please add our link to your site or our cooperation in backlink building will be cancelled. If reason of removing link is maintenance or similar, please inform us about this.</p> <p>Regards, <br />{WEB_TITLE}</p>'; } Page::newInstance()->insert(array('s_internal_name' => 'seo_link_problem', 'b_indelible' => '1'), $des_link); }
function osc_checkLocales() { $locales = osc_listLocales(); foreach ($locales as $locale) { $data = OSCLocale::newInstance()->findByPrimaryKey($locale['code']); if (!is_array($data)) { OSCLocale::newInstance()->insert(array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 's_stop_words' => $locale['stop_words'], 'b_enabled' => 0, 'b_enabled_bo' => 1)); } } }
function osc_checkLocales() { $locales = osc_listLocales(); foreach ($locales as $locale) { $data = OSCLocale::newInstance()->findByPrimaryKey($locale['code']); if (!is_array($data)) { OSCLocale::newInstance()->insert(array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 's_stop_words' => $locale['stop_words'], 'b_enabled' => 0, 'b_enabled_bo' => 1)); // inserting e-mail translations if (defined('DEMO')) { return true; } $path = sprintf('%s%s/mail.sql', osc_translations_path(), $locale['code']); if (file_exists($path)) { $sql = file_get_contents($path); $conn = getConnection(); $conn->osc_dbImportSQL($sql); } } } }
function oc_install() { $dbhost = Params::getParam('dbhost'); $dbname = Params::getParam('dbname'); $username = Params::getParam('username'); $password = Params::getParam('password', false, false); $tableprefix = Params::getParam('tableprefix'); $createdb = false; if ($tableprefix == '') { $tableprefix = 'oc_'; } if (Params::getParam('createdb') != '') { $createdb = true; } if ($createdb) { $adminuser = Params::getParam('admin_username'); $adminpwd = Params::getParam('admin_password', false, false); $master_conn = new DBConnectionClass($dbhost, $adminuser, $adminpwd, ''); $error_num = $master_conn->getErrorConnectionLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1049: return array('error' => __('The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges')); break; case 1045: return array('error' => __('Cannot connect to the database. Check if the user has privileges.')); break; case 1044: return array('error' => __('Cannot connect to the database. Check if the username and password are correct.')); break; case 2005: return array('error' => __('Cannot resolve MySQL host. Check if the host is correct.')); break; default: return array('error' => sprintf(__('Cannot connect to the database. Error number: %s')), $error_num); break; } } $m_db = $master_conn->getOsclassDb(); $comm = new DBCommandClass($m_db); $comm->query(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname)); $error_num = $comm->getErrorLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot create the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } if (in_array($error_num, array(1006, 1044, 1045))) { return array('error' => __('Cannot create the database. Check if the admin username and password are correct.')); } return array('error' => sprintf(__('Cannot create the database. Error number: %s'), $error_num)); } unset($conn); unset($comm); unset($master_conn); } $conn = new DBConnectionClass($dbhost, $username, $password, $dbname); $error_num = $conn->getErrorConnectionLevel(); if ($error_num == 0) { $error_num = $conn->getErrorLevel(); } if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1049: return array('error' => __('The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges')); break; case 1045: return array('error' => __('Cannot connect to the database. Check if the user has privileges.')); break; case 1044: return array('error' => __('Cannot connect to the database. Check if the username and password are correct.')); break; case 2005: return array('error' => __('Cannot resolve MySQL host. Check if the host is correct.')); break; default: return array('error' => sprintf(__('Cannot connect to the database. Error number: %s'), $error_num)); break; } } if (file_exists(ABS_PATH . 'config.php')) { if (!is_writable(ABS_PATH . 'config.php')) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(__('Cannot write in config.php file. Check if the file is writable.'), __FILE__ . "::" . __LINE__); } return array('error' => __('Cannot write in config.php file. Check if the file is writable.')); } create_config_file($dbname, $username, $password, $dbhost, $tableprefix); } else { if (!file_exists(ABS_PATH . 'config-sample.php')) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(__("config-sample.php doesn't exist. Check if you have everything well decompressed."), __FILE__ . "::" . __LINE__); } return array('error' => __("config-sample.php doesn't exist. Check if you have everything well decompressed.")); } if (!is_writable(ABS_PATH)) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(__('Can\'t copy config-sample.php. Check if the root directory is writable.'), __FILE__ . "::" . __LINE__); } return array('error' => __('Can\'t copy config-sample.php. Check if the root directory is writable.')); } copy_config_file($dbname, $username, $password, $dbhost, $tableprefix); } require_once ABS_PATH . 'config.php'; $sql = file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/struct.sql'); $c_db = $conn->getOsclassDb(); $comm = new DBCommandClass($c_db); $comm->importSQL($sql); $error_num = $comm->getErrorLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot create the database structure. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1050: return array('error' => __('There are tables with the same name in the database. Change the table prefix or the database and try again.')); break; default: return array('error' => sprintf(__('Cannot create the database structure. Error number: %s'), $error_num)); break; } } require_once LIB_PATH . 'osclass/model/OSCLocale.php'; $localeManager = OSCLocale::newInstance(); $locales = osc_listLocales(); $values = array('pk_c_code' => $locales[osc_current_admin_locale()]['code'], 's_name' => $locales[osc_current_admin_locale()]['name'], 's_short_name' => $locales[osc_current_admin_locale()]['short_name'], 's_description' => $locales[osc_current_admin_locale()]['description'], 's_version' => $locales[osc_current_admin_locale()]['version'], 's_author_name' => $locales[osc_current_admin_locale()]['author_name'], 's_author_url' => $locales[osc_current_admin_locale()]['author_url'], 's_currency_format' => $locales[osc_current_admin_locale()]['currency_format'], 's_date_format' => $locales[osc_current_admin_locale()]['date_format'], 'b_enabled' => 1, 'b_enabled_bo' => 1); if (isset($locales[osc_current_admin_locale()]['stop_words'])) { $values['s_stop_words'] = $locales[osc_current_admin_locale()]['stop_words']; } $localeManager->insert($values); $required_files = array(ABS_PATH . 'oc-includes/osclass/installer/basic_data.sql', ABS_PATH . 'oc-includes/osclass/installer/pages.sql', ABS_PATH . 'oc-content/languages/' . osc_current_admin_locale() . '/mail.sql'); $sql = ''; foreach ($required_files as $file) { if (!file_exists($file)) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('The file %s doesn\'t exist'), $file), __FILE__ . "::" . __LINE__); } return array('error' => sprintf(__('The file %s doesn\'t exist'), $file)); } else { $sql .= file_get_contents($file); } } $comm->importSQL($sql); $error_num = $comm->getErrorLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot insert basic configuration. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1471: return array('error' => __('Cannot insert basic configuration. This user has no privileges to \'INSERT\' into the database.')); break; default: return array('error' => sprintf(__('Cannot insert basic configuration. Error number: '), $error_num)); break; } } osc_set_preference('language', osc_current_admin_locale()); osc_set_preference('admin_language', osc_current_admin_locale()); oc_install_example_data(); if (reportToOsclass()) { set_allow_report_osclass(true); } else { set_allow_report_osclass(false); } return false; }
function oc_install() { $dbhost = trim($_POST['dbhost']); $dbname = trim($_POST['dbname']); $username = trim($_POST['username']); $password = trim($_POST['password']); if (empty($_POST['tableprefix'])) { $tableprefix = 'oc_'; } else { $tableprefix = trim($_POST['tableprefix']); } if (isset($_POST['createdb'])) { $createdb = true; } else { $createdb = false; } if ($createdb) { $adminuser = trim($_POST['admin_username']); $adminpwd = trim($_POST['admin_password']); $master_conn = getConnection($dbhost, $adminuser, $adminpwd, 'mysql', DEBUG_LEVEL); $master_conn->osc_dbExec(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname)); $error_num = $master_conn->get_errno(); if ($error_num > 0) { if ($error_num == 1006 || $error_num == 1044 || $error_num == 1045) { return array('error' => 'Cannot create the database. Check if the admin username and password are correct.'); } return array('error' => 'Cannot create the database. Error number: ' . $error_num . '.'); } } $conn = getConnection($dbhost, $username, $password, $dbname, DEBUG_LEVEL); $error_num = $conn->get_errno(); if ($error_num > 0) { if ($error_num == 1049) { return array('error' => 'The database doesn\'t exist. You should check the "Create DB" checkbox and fill username and password with the right privileges'); } if ($error_num == 1045) { return array('error' => 'Cannot connect to the database. Check if the user has privileges.'); } if ($error_num == 1044) { return array('error' => 'Cannot connect to the database. Check if the username and password are correct.'); } return array('error' => 'Cannot connect to database. Error number: ' . $error_num . '.'); } if (file_exists(ABS_PATH . 'config.php')) { if (!is_writable(ABS_PATH . 'config.php')) { return array('error' => 'Cannot write in config.php file. Check if the file is writable.'); } create_config_file($dbname, $username, $password, $dbhost, $tableprefix); } else { if (!file_exists(ABS_PATH . 'config-sample.php')) { return array('error' => 'It doesn\'t exist config-sample.php. Check if you have everything well decompressed.'); } if (!is_writable(ABS_PATH)) { return array('error' => 'Can\'t copy config-sample.php. Check if the root directory is writable.'); } copy_config_file($dbname, $username, $password, $dbhost, $tableprefix); } require_once ABS_PATH . 'config.php'; $sql = file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/struct.sql'); $conn->osc_dbImportSQL($sql); $error_num = $conn->get_errno(); if ($error_num > 0) { if ($error_num == 1050) { return array('error' => 'There are tables with the same name in the database. Change the table prefix or the database and try again.'); } return array('error' => 'Cannot create the database structure. Error number: ' . $error_num . '.'); } require_once LIB_PATH . 'osclass/locales.php'; require_once LIB_PATH . 'osclass/model/OSCLocale.php'; $localeManager = OSCLocale::newInstance(); $locales = osc_listLocales(); foreach ($locales as $locale) { $values = array('pk_c_code' => $locale['code'], 's_name' => $locale['name'], 's_short_name' => $locale['short_name'], 's_description' => $locale['description'], 's_version' => $locale['version'], 's_author_name' => $locale['author_name'], 's_author_url' => $locale['author_url'], 's_currency_format' => $locale['currency_format'], 's_date_format' => $locale['date_format'], 'b_enabled' => $locale['code'] == 'en_US' ? 1 : 0, 'b_enabled_bo' => 1); if (isset($locale['stop_words'])) { $values['s_stop_words'] = $locale['stop_words']; } $localeManager->insert($values); } $required_files = array('basic_data.sql', 'categories.sql', 'pages.sql'); $sql = ''; foreach ($required_files as $file) { if (!file_exists(ABS_PATH . 'oc-includes/osclass/installer/' . $file)) { return array('error' => 'the file ' . $file . ' doesn\'t exist in data folder'); } else { $sql .= file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/' . $file); } } $conn->osc_dbImportSQL($sql, ''); $error_num = $conn->get_errno(); if ($error_num > 0) { if ($error_num == 1471) { return array('error' => 'Cannot insert basic configuration. This user has no privileges to \'INSERT\' into the database.'); } return array('error' => 'Cannot insert basic configuration. Error number: ' . $error_num . '.'); } return false; }
require_once LIB_PATH . 'osclass/helpers/hDefines.php'; require_once LIB_PATH . 'osclass/helpers/hErrors.php'; require_once LIB_PATH . 'osclass/helpers/hLocale.php'; require_once LIB_PATH . 'osclass/helpers/hSearch.php'; require_once LIB_PATH . 'osclass/helpers/hPlugins.php'; require_once LIB_PATH . 'osclass/helpers/hTranslations.php'; require_once LIB_PATH . 'osclass/helpers/hSanitize.php'; require_once LIB_PATH . 'osclass/default-constants.php'; require_once LIB_PATH . 'osclass/install-functions.php'; require_once LIB_PATH . 'osclass/utils.php'; require_once LIB_PATH . 'osclass/core/Translation.php'; require_once LIB_PATH . 'osclass/classes/Plugins.php'; require_once LIB_PATH . 'osclass/locales.php'; Params::init(); Session::newInstance()->session_start(); $locales = osc_listLocales(); if (Params::getParam('install_locale') != '') { Session::newInstance()->_set('userLocale', Params::getParam('install_locale')); Session::newInstance()->_set('adminLocale', Params::getParam('install_locale')); } if (Session::newInstance()->_get('adminLocale') != '' && key_exists(Session::newInstance()->_get('adminLocale'), $locales)) { $current_locale = Session::newInstance()->_get('adminLocale'); } else { if (isset($locales['en_US'])) { $current_locale = 'en_US'; } else { $current_locale = key($locales); } } Session::newInstance()->_set('userLocale', $current_locale); Session::newInstance()->_set('adminLocale', $current_locale);
function oc_install() { $dbhost = Params::getParam('dbhost'); $dbname = Params::getParam('dbname'); $username = Params::getParam('username'); $password = Params::getParam('password', false, false); $tableprefix = Params::getParam('tableprefix'); $createdb = false; require_once LIB_PATH . 'osclass/helpers/hSecurity.php'; if ($tableprefix == '') { $tableprefix = 'oc_'; } if (Params::getParam('createdb') != '') { $createdb = true; } if ($createdb) { $adminuser = Params::getParam('admin_username'); $adminpwd = Params::getParam('admin_password', false, false); $master_conn = new DBConnectionClass($dbhost, $adminuser, $adminpwd, ''); $error_num = $master_conn->getErrorConnectionLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1049: return array('error' => __("База данных не существует. Необходимо проверить возможность подключения к базе данных. Номер ошибки: \"Create DB\" флажок и заполнить имя пользователя и пароль с правом привилегий")); break; case 1045: return array('error' => __('Не удается подключиться к базе данных. Проверьтеесли у пользователя права.')); break; case 1044: return array('error' => __('Не удается подключиться к базе данных. Проверьте имя пользователя и пароль.')); break; case 2005: return array('error' => __("Не могу определить MySQL хост. Проверьте правильность хоста.")); break; default: return array('error' => sprintf(__('Не удается подключиться к базе данных. Номер ошибки: %s')), $error_num); break; } } $m_db = $master_conn->getOsclassDb(); $comm = new DBCommandClass($m_db); $comm->query(sprintf("CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI'", $dbname)); $error_num = $comm->getErrorLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__("Не удается подключиться к базе данных. Номер ошибки: %s"), $error_num), __FILE__ . "::" . __LINE__); } if (in_array($error_num, array(1006, 1044, 1045))) { return array('error' => __("Не удается подключиться к базе данных. Проверьте имя пользователя и пароль администратора.")); } return array('error' => sprintf(__("Невозможно создать базу данных. Номер ошибки: %s"), $error_num)); } unset($conn); unset($comm); unset($master_conn); } $conn = new DBConnectionClass($dbhost, $username, $password, $dbname); $error_num = $conn->getErrorConnectionLevel(); if ($error_num == 0) { $error_num = $conn->getErrorLevel(); } if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Cannot connect to the database. Error number: %s'), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1049: return array('error' => __("База данных не существует. Необходимо проверить \"Create DB\" флажок и заполнить имя пользователя и пароль с правом привилегий")); break; case 1045: return array('error' => __('Не удается подключиться к базе данных. Проверьте если у пользователя есть привилегии.')); break; case 1044: return array('error' => __('Не удается подключиться к базе данных. Проверьте имя пользователя и пароль.')); break; case 2005: return array('error' => __("Не могу определить MySQL хост.")); break; default: return array('error' => sprintf(__('Не удается подключиться к базе данных. Номер ошибки: %s'), $error_num)); break; } } if (file_exists(ABS_PATH . 'config.php')) { if (!is_writable(ABS_PATH . 'config.php')) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(__("Не удается выполнить запись в файл config.php. Проверьте доступность файла для записи."), __FILE__ . "::" . __LINE__); } return array('error' => __("Не удается выполнить запись в файл config.php. Проверьте доступность файла для записи.")); } create_config_file($dbname, $username, $password, $dbhost, $tableprefix); } else { if (!file_exists(ABS_PATH . 'config-sample.php')) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(__("config-sample.php не существует. Проверьте все ли файлы правильно распакованы."), __FILE__ . "::" . __LINE__); } return array('error' => __("config-sample.php не существует. Проверьте все ли файлы правильно распакованы.")); } if (!is_writable(ABS_PATH)) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(__('Не удается скопировать config-sample.php. Проверьте доступен ли для записи корневой каталог.'), __FILE__ . "::" . __LINE__); } return array('error' => __('Не удается скопировать config-sample.php. Проверьте доступен ли для записи корневой каталог.')); } copy_config_file($dbname, $username, $password, $dbhost, $tableprefix); } require_once ABS_PATH . 'config.php'; $sql = file_get_contents(ABS_PATH . 'oc-includes/osclass/installer/struct.sql'); $c_db = $conn->getOsclassDb(); $comm = new DBCommandClass($c_db); $comm->importSQL($sql); $error_num = $comm->getErrorLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__("Не удается создать структуру базы данных. Номер ошибки: %s"), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1050: return array('error' => __('Таблицы с таким же именем уже существуют в базе данных. Измените префикс таблиц или базу данных и повторите попытку.')); break; default: return array('error' => sprintf(__("Не удается создать структуру базы данных. Номер ошибки: %s"), $error_num)); break; } } require_once LIB_PATH . 'osclass/model/OSCLocale.php'; $localeManager = OSCLocale::newInstance(); $locales = osc_listLocales(); $values = array('pk_c_code' => $locales[osc_current_admin_locale()]['code'], 's_name' => $locales[osc_current_admin_locale()]['name'], 's_short_name' => $locales[osc_current_admin_locale()]['short_name'], 's_description' => $locales[osc_current_admin_locale()]['description'], 's_version' => $locales[osc_current_admin_locale()]['version'], 's_author_name' => $locales[osc_current_admin_locale()]['author_name'], 's_author_url' => $locales[osc_current_admin_locale()]['author_url'], 's_currency_format' => $locales[osc_current_admin_locale()]['currency_format'], 's_date_format' => $locales[osc_current_admin_locale()]['date_format'], 'b_enabled' => 1, 'b_enabled_bo' => 1); if (isset($locales[osc_current_admin_locale()]['stop_words'])) { $values['s_stop_words'] = $locales[osc_current_admin_locale()]['stop_words']; } $localeManager->insert($values); $required_files = array(ABS_PATH . 'oc-includes/osclass/installer/basic_data.sql', ABS_PATH . 'oc-includes/osclass/installer/pages.sql', ABS_PATH . 'oc-content/languages/' . osc_current_admin_locale() . '/mail.sql'); $sql = ''; foreach ($required_files as $file) { if (!file_exists($file)) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__('Файл %s не существует'), $file), __FILE__ . "::" . __LINE__); } return array('error' => sprintf(__('Файл %s не существует'), $file)); } else { $sql .= file_get_contents($file); } } $comm->importSQL($sql); $error_num = $comm->getErrorLevel(); if ($error_num > 0) { if (reportToOsclass()) { LogOsclassInstaller::instance()->error(sprintf(__("Не удается установить базовую конфигурацию. Номер ошибки: %s"), $error_num), __FILE__ . "::" . __LINE__); } switch ($error_num) { case 1471: return array('error' => __("Не удается установить базовую конфигурацию. Этот пользователь не имеет привилегий делать записи 'INSERT' в базе данных.")); break; default: return array('error' => sprintf(__("Не удается установить базовую конфигурацию. Номер ошибки: %s"), $error_num)); break; } } osc_set_preference('language', osc_current_admin_locale()); osc_set_preference('admin_language', osc_current_admin_locale()); osc_set_preference('csrf_name', 'CSRF' . mt_rand(0, mt_getrandmax())); oc_install_example_data(); if (reportToOsclass()) { set_allow_report_osclass(true); } else { set_allow_report_osclass(false); } return false; }