Exemple #1
0
 /**
  * Establish a connection to the MySQL database.
  *
  * @param string server ip or name
  * @param string database user
  * @param string database password
  * @param string datatabase name
  */
 function osc_dbConnect()
 {
     $this->db = @new mysqli($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName);
     if ($this->db->connect_error) {
         if (!defined('OSC_INSTALLING')) {
             require_once LIB_PATH . 'osclass/helpers/hErrors.php';
             $title = 'Osclass » Error connecting to database';
             $message = 'Cannot connect to database. Check your configuration in <code>config.php</code> file.';
             osc_die($title, $message);
         }
         $this->debug('Error connecting to \'' . $this->dbName . '\' (' . $this->db->connect_errno . ': ' . $this->db->connect_error . ')', false);
     }
     $this->db_errno = $this->db->connect_errno;
     $this->debug('Connected to \'' . $this->dbName . '\': [DBHOST] = ' . $this->dbHost . ' | [DBUSER] = ' . $this->dbUser);
     $this->db->set_charset('utf8');
 }
Exemple #2
0
if (!defined('AUTO_UPGRADE')) {
    if (file_exists(osc_lib_path() . 'osclass/installer/struct.sql')) {
        $sql = file_get_contents(osc_lib_path() . 'osclass/installer/struct.sql');
        $conn = DBConnectionClass::newInstance();
        $c_db = $conn->getOsclassDb();
        $comm = new DBCommandClass($c_db);
        $error_queries = $comm->updateDB(str_replace('/*TABLE_PREFIX*/', DB_TABLE_PREFIX, $sql));
    }
    if (Params::getParam('skipdb') == '') {
        if (!$error_queries[0]) {
            $skip_db_link = osc_admin_base_url(true) . "?page=upgrade&action=upgrade-funcs&skipdb=true";
            $title = __('Osclass &raquo; Has some errors');
            $message = __("We've encountered some problems while updating the database structure. The following queries failed:");
            $message .= "<br/><br/>" . implode("<br>", $error_queries[2]);
            $message .= "<br/><br/>" . sprintf(__("These errors could be false-positive errors. If you're sure that is the case, you can <a href=\"%s\">continue with the upgrade</a>, or <a href=\"http://forums.osclass.org/\">ask in our forums</a>."), $skip_db_link);
            osc_die($title, $message);
        }
    }
}
$aMessages = array();
osc_set_preference('last_version_check', time());
$conn = DBConnectionClass::newInstance();
$c_db = $conn->getOsclassDb();
$comm = new DBCommandClass($c_db);
if (osc_version() < 210) {
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'save_latest_searches', '0', 'BOOLEAN')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'purge_latest_searches', '1000', 'STRING')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'selectable_parent_categories', '1', 'BOOLEAN')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'ping_search_engines', '1', 'BOOLEAN')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'numImages@items', '0', 'BOOLEAN')", DB_TABLE_PREFIX));
    $enableItemValidation = getBoolPreference('enabled_item_validation') ? 0 : -1;
Exemple #3
0
define('CONTENT_PATH', ABS_PATH . 'oc-content/');
define('TRANSLATIONS_PATH', CONTENT_PATH . 'languages/');
require_once LIB_PATH . 'osclass/db.php';
require_once LIB_PATH . 'osclass/classes/DAO.php';
require_once LIB_PATH . 'osclass/model/Preference.php';
require_once LIB_PATH . 'osclass/helpers/hPreference.php';
require_once LIB_PATH . 'osclass/helpers/hDatabaseInfo.php';
require_once LIB_PATH . 'osclass/helpers/hErrors.php';
require_once LIB_PATH . 'osclass/core/Session.php';
require_once LIB_PATH . 'osclass/helpers/hDefines.php';
require_once LIB_PATH . 'osclass/helpers/hLocale.php';
require_once LIB_PATH . 'osclass/install-functions.php';
isset($_REQUEST['step']) ? $step = (int) $_REQUEST['step'] : ($step = '1');
if (is_osclass_installed()) {
    $message = 'You appear to have already installed OSClass. To reinstall please clear your old database tables first.';
    osc_die('OSClass &raquo; Error', $message);
}
switch ($step) {
    case 1:
        $requirements = get_requirements();
        $error = check_requirements($requirements);
        break;
    case 2:
        if (isset($_REQUEST['save_stats'])) {
            setcookie('osclass_save_stats', 1);
            header('Location: ' . get_absolute_url() . 'oc-includes/osclass/install.php?step=2');
        }
        break;
    case 3:
        if (isset($_POST['dbname'])) {
            $error = oc_install();
Exemple #4
0
    if (isset($locales['en_US'])) {
        $current_locale = 'en_US';
    } else {
        $current_locale = key($locales);
    }
}
Session::newInstance()->_set('userLocale', $current_locale);
Session::newInstance()->_set('adminLocale', $current_locale);
$translation = Translation::newInstance(true);
$step = Params::getParam('step');
if (!is_numeric($step)) {
    $step = '1';
}
if (is_osclass_installed()) {
    $message = __("Похоже у вас уже установлен OSClass. Для повторной установки очистите таблицы базы данных.");
    osc_die('Ошибка &raquo; OSClass', $message);
}
switch ($step) {
    case 1:
        $requirements = get_requirements();
        $error = check_requirements($requirements);
        break;
    case 2:
        if (Params::getParam('save_stats') == '1' || isset($_COOKIE['osclass_save_stats'])) {
            setcookie('osclass_save_stats', 1, time() + 24 * 60 * 60);
        } else {
            setcookie('osclass_save_stats', 0, time() + 24 * 60 * 60);
        }
        if (Params::getParam('ping_engines') == '1' || isset($_COOKIE['osclass_ping_engines'])) {
            setcookie('osclass_ping_engines', 1, time() + 24 * 60 * 60);
        } else {
 /**
  * Connect to Osclass database
  * 
  * @access public
  * @since 2.3
  * @return boolean It returns true if the connection has been successful or false if not
  */
 function connectToOsclassDb()
 {
     $conn = $this->_connectToDb($this->dbHost, $this->dbUser, $this->dbPassword, $this->db);
     if ($conn == false) {
         $this->errorConnection();
         $this->releaseOsclassDb();
         require_once LIB_PATH . 'osclass/helpers/hErrors.php';
         $title = 'Osclass &raquo; Error';
         $message = 'Osclass database server is not available. <a href="http://forums.osclass.org/">Need more help?</a></p>';
         osc_die($title, $message);
     }
     $this->_setCharset('utf8', $this->db);
     if ($this->dbName == '') {
         return true;
     }
     $selectDb = $this->selectOsclassDb();
     if ($selectDb == false) {
         $this->errorReport();
         $this->releaseOsclassDb();
         require_once LIB_PATH . 'osclass/helpers/hErrors.php';
         $title = 'Osclass &raquo; Error';
         $message = 'Osclass database is not available. <a href="http://forums.osclass.org/">Need more help?</a></p>';
         osc_die($title, $message);
     }
     return true;
 }