Ejemplo n.º 1
0
 public function init()
 {
     if (empty($_SERVER['SERVER_NAME'])) {
         $options = getopt('c:', array('core'));
         $core = empty($options['c']) ? @$options['core'] : $options['c'];
         if (empty($core)) {
             die('no core passed');
         }
         $_SERVER['SERVER_NAME'] = $core . '.dummy.com';
         $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     }
     require_once dirname(__FILE__) . '/../config.php';
     require_once LIB_DIR . 'DB.php';
     DB\connect();
 }
Ejemplo n.º 2
0
//reset if sign out clicked on check tsv
if (!empty($_GET['l'])) {
    unset($_SESSION['check_TSV']);
}
if (!empty($_POST['s']) && !empty($_POST['p']) && !empty($_POST['u'])) {
    $errors = array();
    $u = strtolower(trim($_POST['u']));
    $p = $_POST['p'];
    if (empty($u)) {
        $errors[] = L\get('Specify_username');
    }
    if (empty($p)) {
        $errors[] = L\get('Specify_password');
    }
    if (empty($errors)) {
        DB\connect();
        $user = new User();
        $r = $user->Login($u, $p);
        if ($r['success'] == false) {
            $errors[] = L\get('Auth_fail');
        } else {
            $cfg = $user->getTSVConfig();
            if (!empty($cfg['method'])) {
                $_SESSION['check_TSV'] = time();
            } else {
                $_SESSION['user']['TSV_checked'] = true;
            }
        }
    }
    $_SESSION['message'] = array_shift($errors);
} elseif (!empty($_SESSION['check_TSV']) && !empty($_POST['c'])) {
Ejemplo n.º 3
0
require_once LIB_DIR . 'DB.php';
/* end of update include_path and include scripts */
if (!isset($cfg) || !is_array($cfg)) {
    $cfg = array();
}
//define some library paths
$cfg['HTML_PURIFIER'] = 'htmlpurifier/library/HTMLPurifier.auto.php';
$cfg['SOLR_CLIENT'] = 'Apache/Solr/Service.php';
$cfg['MINIFY_PATH'] = DOC_ROOT . 'libx/min/';
$cfg['TIKA_SERVER'] = DOC_ROOT . 'libx/tika-server.jar';
if (file_exists(DOC_ROOT . 'config.ini')) {
    //load main config so that we can connect to casebox db and read configuration for core
    $cfg = Config::loadConfigFile(DOC_ROOT . 'config.ini') + $cfg;
    if (isset($cfg['db_host']) && isset($cfg['db_user']) && isset($cfg['db_pass']) && isset($cfg['db_port'])) {
        //conect to db using global params from config.ini
        DB\connect($cfg);
    }
} else {
    //Usually this appears when installing casebox and
    //a message instead of a complex error should be enough
    echo "Config file doesnt exist\n";
    // trigger_error("WARNING: file not exists " . DOC_ROOT . 'config.ini', E_USER_WARNING);
}
//define global prefix used
define('CB\\PREFIX', (empty($cfg['prefix']) ? 'cb' : $cfg['prefix']) . '_');
define('CB\\IS_DEBUG_HOST', empty($_SERVER['SERVER_NAME']) || !empty($cfg['debug_hosts']) && Util\isInValues($_SERVER['REMOTE_ADDR'], $cfg['debug_hosts']) || Util\is_cli());
define('CB\\IS_DEVEL_SERVER', !empty($cfg['_dev_mode']) && (strpos($_SERVER['SERVER_NAME'], '.d.') !== false || !empty($cfg['_dev_hosts']) && Util\isInValues($_SERVER['REMOTE_ADDR'], $cfg['_dev_hosts'])));
//analize python option
if (empty($cfg['PYTHON'])) {
    $cfg['PYTHON'] = 'python';
}