Beispiel #1
0
 function __construct($server, $user, $pass, $db, $install = false)
 {
     $server = trim($server);
     $user = trim($user);
     $pass = trim($pass);
     $db = trim($db);
     if ($install) {
         if (strlen($server) && $server !== 'localhost' && $server !== '127.0.0.1') {
             if (!dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) {
                 notice(sprintf(t('Cannot locate DNS info for database server \'%s\''), $server));
                 $this->connected = false;
                 $this->db = null;
                 return;
             }
         }
     }
     if (class_exists('mysqli')) {
         $this->db = @new mysqli($server, $user, $pass, $db);
         if (!mysqli_connect_errno()) {
             $this->connected = true;
         }
     } else {
         $this->mysqli = false;
         $this->db = mysql_connect($server, $user, $pass);
         if ($this->db && mysql_select_db($db, $this->db)) {
             $this->connected = true;
         }
     }
     if (!$this->connected) {
         $this->db = null;
         if (!$install) {
             system_unavailable();
         }
     }
 }
Beispiel #2
0
 function __construct($server, $user, $pass, $db, $install = false)
 {
     $this->db = @new mysqli($server, $user, $pass, $db);
     if (mysqli_connect_errno() && !install) {
         system_unavailable();
     }
 }
Beispiel #3
0
 * Load the configuration file which contains our DB credentials.
 * Ignore errors. If the file doesn't exist or is empty, we are running in
 * installation mode.
 */
$a->install = file_exists('.htconfig.php') && filesize('.htconfig.php') ? false : true;
@(include '.htconfig.php');
$a->timezone = x($default_timezone) ? $default_timezone : 'UTC';
date_default_timezone_set($a->timezone);
/*
 * Try to open the database;
 */
require_once 'include/dba/dba_driver.php';
if (!$a->install) {
    $db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, $a->install);
    if (!$db->connected) {
        system_unavailable();
    }
    unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
    /**
     * Load configs from db. Overwrite configs from .htconfig.php
     */
    load_config('config');
    load_config('system');
    load_config('feature');
    require_once 'include/session.php';
    load_hooks();
    call_hooks('init_1');
    $a->language = get_best_language();
    load_translation_table($a->language);
    // Force the cookie to be secure (https only) if this site is SSL enabled. Must be done before session_start().
    if (intval($a->config['system']['ssl_cookie_protection'])) {
Beispiel #4
0
function sys_boot()
{
    // our central App object
    App::init();
    /*
     * Load the configuration file which contains our DB credentials.
     * Ignore errors. If the file doesn't exist or is empty, we are running in
     * installation mode.
     */
    // miniApp is a conversion object from old style .htconfig.php files
    $a = new miniApp();
    App::$install = file_exists('.htconfig.php') && filesize('.htconfig.php') ? false : true;
    @(include '.htconfig.php');
    if (!defined('UNO')) {
        define('UNO', 0);
    }
    if (array_key_exists('default_timezone', get_defined_vars())) {
        App::$config['system']['timezone'] = $default_timezone;
    }
    $a->convert();
    App::$timezone = App::$config['system']['timezone'] ? App::$config['system']['timezone'] : 'UTC';
    date_default_timezone_set(App::$timezone);
    /*
     * Try to open the database;
     */
    require_once 'include/dba/dba_driver.php';
    if (!App::$install) {
        DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
        if (!DBA::$dba->connected) {
            system_unavailable();
        }
        unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
        /**
         * Load configs from db. Overwrite configs from .htconfig.php
         */
        load_config('config');
        load_config('system');
        load_config('feature');
        App::$session = new Zotlabs\Web\Session();
        App::$session->init();
        load_hooks();
        call_hooks('init_1');
    }
}