Advertisement
Guest User

GeoRed sample

a guest
Dec 25th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1.     App::import('Utility', 'GeoRed');
  2.     App::import('Model/Datasource', 'CakeSession');
  3.     $session = new CakeSession();
  4.  
  5.     define('GEORED_DEBUG', !empty($_REQUEST['geored_debug']));
  6.     if (GEORED_DEBUG) header('Content-type: text/plain; charset=utf-8');
  7.     // Начало
  8.     $RM = empty($_SERVER['REQUEST_METHOD']) ? 'cli' : strtolower($_SERVER['REQUEST_METHOD']);
  9.     if (!GeoRed::isBot() && ($RM == 'get')) {
  10.         if ($session->check('geored')) {
  11.             $data = $session->read('geored');
  12.             if ($data['ip'] != $_SERVER['REMOTE_ADDR']) goto geored_renew;
  13.             GeoRed::setData($data);
  14.         } else {
  15.             geored_renew:
  16.             if (!class_exists('DATABASE_CONFIG', false)) {
  17.                 require CONFIG.'database.php';
  18.                 $config = new DATABASE_CONFIG();
  19.             }
  20.             try {
  21.                 $session->write('geored', GeoRed::setData(GeoRed::getData(array(
  22.                     'host'     => $config->default['host'],
  23.                     'user'     => $config->default['login'],
  24.                     'password' => $config->default['password'],
  25.                     'name'     => $config->default['database'],
  26.                     'prefix'   => $config->default['prefix']
  27.                 ))));
  28.             } catch (Exception $e) {
  29.                 if (GEORED_DEBUG) echo $e->getMessage();
  30.             }
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement