예제 #1
0
파일: Lang.php 프로젝트: kddlb/openimporter
 /**
  * Adds a new variable to lang.
  *
  * @param string $key Name of the variable
  * @param string $value Value of the variable
  * @throws Exception
  * @return boolean|null
  */
 protected function set($key, $value)
 {
     try {
         if ($this->has($key)) {
             throw new Exception('Unable to set language string for <em>' . $key . '</em>. It was already set.');
         }
         $this->_lang[$key] = $value;
         return true;
     } catch (Exception $e) {
         // @todo this should not be a fatal error
         ImportException::exception_handler($e);
     }
 }
예제 #2
0
}
if (@ini_get('session.save_handler') == 'user') {
    @ini_set('session.save_handler', 'files');
}
@session_start();
// Add slashes, as long as they aren't already being added.
if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0) {
    $_POST = stripslashes_recursive($_POST);
}
$config = new Configurator();
$config->lang_dir = BASEDIR . '/Languages';
try {
    $lng = new Lang();
    $lng->loadLang($config->lang_dir);
} catch (Exception $e) {
    ImportException::exception_handler($e);
}
$template = new Template($lng);
global $import;
$importer = new Importer($config, $lng, $template);
$response = new HttpResponse(new ResponseHeader());
$template->setResponse($response);
$import = new ImportManager($config, $importer, $template, new Cookie(), $response);
try {
    $import->process();
} catch (Exception $e) {
    // Debug, remember to remove before PR
    echo '<br>' . $e->getMessage() . '<br>';
    echo $e->getFile() . '<br>';
    echo $e->getLine() . '<br>';
    // If an error is not catched, it means it's fatal and the script should die.
예제 #3
0
 protected function init_db()
 {
     try {
         list($db_server, $db_user, $db_passwd, $db_persist, $db_prefix, $db_name) = $this->config->destination->dbConnectionData();
         $this->db = new Database($db_server, $db_user, $db_passwd, $db_persist);
         //We want UTF8 only, let's set our mysql connetction to utf8
         $this->db->query('SET NAMES \'utf8\'');
     } catch (Exception $e) {
         ImportException::exception_handler($e, $this->template);
         die;
     }
     if (strpos($db_prefix, '.') === false) {
         // @todo ???
         if (is_numeric(substr($db_prefix, 0, 1))) {
             $this->config->to_prefix = $db_name . '.' . $db_prefix;
         } else {
             $this->config->to_prefix = '`' . $db_name . '`.' . $db_prefix;
         }
     } else {
         $this->config->to_prefix = $db_prefix;
     }
     $this->config->from_prefix = $this->config->source->getPrefix();
     if (preg_match('~^`[^`]+`.\\d~', $this->config->from_prefix) != 0) {
         $this->config->from_prefix = strtr($this->config->from_prefix, array('`' => ''));
     }
     // SQL_BIG_SELECTS: If set to 0, MySQL aborts SELECT statements that are
     // likely to take a very long time to execute (that is, statements for
     // which the optimizer estimates that the number of examined rows exceeds
     // the value of max_join_size)
     // Source:
     // https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_sql_big_selects
     $this->db->query("SET @@SQL_BIG_SELECTS = 1");
     $this->db->query("SET @@MAX_JOIN_SIZE = 18446744073709551615");
 }