Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- App::import('Utility', 'GeoRed');
- App::import('Model/Datasource', 'CakeSession');
- $session = new CakeSession();
- define('GEORED_DEBUG', !empty($_REQUEST['geored_debug']));
- if (GEORED_DEBUG) header('Content-type: text/plain; charset=utf-8');
- // Начало
- $RM = empty($_SERVER['REQUEST_METHOD']) ? 'cli' : strtolower($_SERVER['REQUEST_METHOD']);
- if (!GeoRed::isBot() && ($RM == 'get')) {
- if ($session->check('geored')) {
- $data = $session->read('geored');
- if ($data['ip'] != $_SERVER['REMOTE_ADDR']) goto geored_renew;
- GeoRed::setData($data);
- } else {
- geored_renew:
- if (!class_exists('DATABASE_CONFIG', false)) {
- require CONFIG.'database.php';
- $config = new DATABASE_CONFIG();
- }
- try {
- $session->write('geored', GeoRed::setData(GeoRed::getData(array(
- 'host' => $config->default['host'],
- 'user' => $config->default['login'],
- 'password' => $config->default['password'],
- 'name' => $config->default['database'],
- 'prefix' => $config->default['prefix']
- ))));
- } catch (Exception $e) {
- if (GEORED_DEBUG) echo $e->getMessage();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement