Пример #1
0
 /**
  * Processing of replacing in content
  *
  * @param string	$data
  *
  * @return string
  */
 protected function process_replacing($data)
 {
     errors_off();
     foreach ($this->Search as $i => $search) {
         $data = _preg_replace($search, $this->Replace[$i], $data) ?: str_replace($search, $this->Replace[$i], $data);
     }
     errors_on();
     return $data;
 }
Пример #2
0
 /**
  * Test connection to the DB
  *
  * @param array|string $data	Array or string in JSON format of connection parameters
  *
  * @return bool
  */
 function test($data)
 {
     $Core = Core::instance();
     if (empty($data)) {
         return false;
     } elseif (is_array($data)) {
         $Config = Config::instance();
         if (isset($data[1])) {
             $db = $Config->db[$data[0]]['mirrors'][$data[1]];
         } elseif (isset($data[0])) {
             if ($data[0] == 0) {
                 $db = ['type' => $Core->db_type, 'host' => $Core->db_host, 'name' => $Core->db_name, 'user' => $Core->db_user, 'password' => $Core->db_password, 'charset' => $Core->db_charset];
             } else {
                 $db = $Config->db[$data[0]];
             }
         } else {
             return false;
         }
     } else {
         $db = _json_decode($data);
     }
     unset($data);
     if (is_array($db)) {
         errors_off();
         $engine_class = '\\cs\\DB\\' . $db['type'];
         $test = new $engine_class($db['name'], $db['user'], $db['password'], $db['host'] ?: $Core->db_host, $db['charset'] ?: $Core->db_charset);
         errors_on();
         return $test->connected();
     } else {
         return false;
     }
 }
Пример #3
0
    singleton("errors_format", "text");
    singleton("errors_logged", true);
    singleton("errors_thrown", false);
    singleton("errors_haltdb", true);
    ini_set('display_errors', 1);
}
function errors_off()
{
    singleton("errors_fatal", false);
    singleton("errors_format", "text");
    singleton("errors_logged", false);
    singleton("errors_thrown", false);
    singleton("errors_haltdb", false);
    ini_set("display_errors", 0);
}
errors_on();
// The user hasn't set their timezone, so pull up the default and suppress the warning
$timeZone = @date_default_timezone_get();
date_default_timezone_set($timeZone);
define("IMG_TICK", "<img src=\"" . $TPL["url_alloc_images"] . "tick.gif\" alt=\"Good\">");
define("IMG_CROSS", "<img src=\"" . $TPL["url_alloc_images"] . "cross.gif\" alt=\"Bad\">");
$TPL["IMG_TICK"] = IMG_TICK;
$TPL["IMG_CROSS"] = IMG_CROSS;
function show_tab_1()
{
    $tab = $_GET["tab"] or $tab = $_POST["tab"];
    return $tab == 1 || !$tab;
}
function show_tab_2()
{
    $tab = $_GET["tab"] or $tab = $_POST["tab"];
Пример #4
0
 /**
  * Decryption of data
  *
  * @param string      $data	Data to be decrypted
  * @param bool|string $key	Key, if not specified - system key will be used
  *
  * @return bool|mixed
  */
 function decrypt($data, $key = false)
 {
     if (!$this->encrypt_support) {
         return $data;
     }
     if (!is_resource($this->td)) {
         $this->td = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'cbc', '');
         $this->key = mb_substr($this->key, 0, mcrypt_enc_get_key_size($this->td));
         $this->iv = mb_substr(md5($this->iv), 0, mcrypt_enc_get_iv_size($this->td));
     }
     if ($key === false) {
         $key = $this->key;
     } else {
         $key = mb_substr(md5($this->key) . md5($key), 0, mcrypt_enc_get_key_size($this->td));
     }
     mcrypt_generic_init($this->td, $key, $this->iv);
     errors_off();
     $decrypted = @unserialize(mdecrypt_generic($this->td, $data));
     errors_on();
     mcrypt_generic_deinit($this->td);
     if (is_array($decrypted) && $decrypted['key'] == $key) {
         return $decrypted['data'];
     } else {
         return false;
     }
 }