Example #1
0
 static function instance()
 {
     if (!isset(self::$_instance)) {
         $c = __CLASS__;
         self::$_instance = new $c();
     }
     return self::$_instance;
 }
Example #2
0
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;
}
Example #3
0
function location_by_city()
{
    $country = Params::getParam('country');
    $city = Params::getParam('city');
    if ($country == '') {
        return false;
    }
    if ($city == '') {
        return false;
    }
    $countries_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=country&term=' . urlencode(implode(',', $country)) . '&install=true&version=' . osc_version());
    $countries = json_decode($countries_json);
    $manager_country = Country::newInstance();
    if (count($countries) == 0 && reportToOsclass()) {
        LogOsclassInstaller::instance()->error('Cannot get countries - ' . implode(',', $country), __FILE__ . "::" . __LINE__);
    }
    foreach ($countries as $c) {
        $manager_country->insert(array("pk_c_code" => $c->id, "fk_c_locale_code" => $c->locale_code, "s_name" => $c->name));
    }
    $manager_city = City::newInstance();
    $manager_region = Region::newInstance();
    foreach ($countries as $c) {
        $cities_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=city&country=' . urlencode($c->name) . '&term=' . urlencode(implode(',', $city)));
        $cities = json_decode($cities_json);
        if (!isset($cities->error)) {
            foreach ($cities as $ci) {
                $regions_json = osc_file_get_contents('http://geo.osclass.org/geo.download.php?action=region&country=&id=' . $ci->region_id);
                $regions = json_decode($regions_json);
                if (count($regions) == 0 && reportToOsclass()) {
                    LogOsclassInstaller::instance()->error('Cannot get regions by - ' . $ci->region_id, __FILE__ . "::" . __LINE__);
                }
                foreach ($regions as $r) {
                    $manager_region->insert(array("pk_i_id" => $r->id, "fk_c_country_code" => $r->country_code, "s_name" => $r->name));
                }
                $manager_city->insert(array("pk_i_id" => $ci->id, "fk_i_region_id" => $ci->region_id, "s_name" => $ci->name, "fk_c_country_code" => $ci->country_code));
            }
        } else {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error('Cannot get cities by - ' . $c->name . ' - term ' . implode(',', $city), __FILE__ . "::" . __LINE__);
            }
            return '300';
        }
        unset($cities);
        unset($cities_json);
    }
    return '200';
}
Example #4
0
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);
        if ($error_num > 0) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error('Cannot connect to database. Error number: ' . $error_num, __FILE__ . "::" . __LINE__);
            }
            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.');
            }
            if ($error_num == 2005) {
                return array('error' => 'Cannot resolve MySQL host. Check if the host is correct.');
            }
            return array('error' => 'Cannot connect to database. Error number: ' . $error_num . '.');
        }
        $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 (reportToOsclass()) {
                LogOsclassInstaller::instance()->error('Cannot create the database. Error number: ' . $error_num, __FILE__ . "::" . __LINE__);
            }
            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 (reportToOsclass()) {
            LogOsclassInstaller::instance()->error('Cannot connect to database. Error number: ' . $error_num, __FILE__ . "::" . __LINE__);
        }
        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.');
        }
        if ($error_num == 2005) {
            return array('error' => 'Cannot resolve MySQL host. Check if the host is 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')) {
            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('It doesn\'t exist config-sample.php. Check if you have everything well decompressed.', __FILE__ . "::" . __LINE__);
            }
            return array('error' => 'It doesn\'t exist config-sample.php. 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');
    $conn->osc_dbImportSQL($sql);
    $error_num = $conn->get_errno();
    if ($error_num > 0) {
        if (reportToOsclass()) {
            LogOsclassInstaller::instance()->error('Cannot create the database structure. Error number: ' . $error_num, __FILE__ . "::" . __LINE__);
        }
        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)) {
            if (reportToOsclass()) {
                LogOsclassInstaller::instance()->error('the file ' . $file . ' doesn\'t exist in data folder', __FILE__ . "::" . __LINE__);
            }
            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 (reportToOsclass()) {
            LogOsclassInstaller::instance()->error('Cannot insert basic configuration. Error number: ' . $error_num, __FILE__ . "::" . __LINE__);
        }
        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 . '.');
    }
    // save in preferences allow_report_osclass
    if (reportToOsclass()) {
        set_allow_report_osclass(true);
    } else {
        set_allow_report_osclass(false);
    }
    return false;
}
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;
}