/
bear
/
opencorpora
Обзор
Документация
Войти
/
bear
/
opencorpora
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lib/header_ajax.php
29 строк
981 B
Dmitry Granovsky
use json config in php code (issue #760)
27 июн 2020, 12:00
27 июн 2020, 12:00
7cd4dbe
Код
Авторство
О чём код?
<?php if (!headers_sent()) { session_start(); header('Content-type: application/json'); } $config = json_decode(file_get_contents(__DIR__ . '/../config.json'), true); require_once(__DIR__.'/../vendor/autoload.php'); // Smarty, something else which was installed via Composer require_once('common.php'); require_once('constants.php'); require_once('timer.php'); $transaction_counter = 0; $nested_transaction_counter = 0; $current_revset_id = 0; $pdo_db = new PDO(sprintf('mysql:host=%s;dbname=%s;charset=utf8', $config['mysql']['host'], $config['mysql']['dbname']), $config['mysql']['user'], $config['mysql']['passwd']); $pdo_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $pdo_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $pdo_db->query("SET NAMES utf8"); $pdo_db->query("SET session sql_mode = ''"); mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); $result = array('error' => 0); // this will end up being json-encoded and returned ?>