Changeset 572 for trunk/bin


Ignore:
Timestamp:
Feb 27, 2017 2:12:39 PM (7 years ago)
Author:
anonymous
Message:

Added option to skip using a database by testing for defined(_NODB)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/_config.inc.php

    r564 r572  
    3636}
    3737
    38 // Use codebase files releative to this file.
     38// Use codebase files relative to this file.
    3939define('CODEBASE_PATH', realpath(dirname(__FILE__) . '/../'));
    4040
     41
    4142$db_auth_file = false;
    42 $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
    43 $rii->setMaxDepth(2);
    44 foreach ($rii as $filename => $file) {
    45     if (in_array(basename($filename), ['db_auth.inc.php', 'db_auth.json'])) {
    46         $db_auth_file = $filename;
    47         break;
     43if (!defined('_NODB')) {
     44    $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
     45    $rii->setMaxDepth(2);
     46    foreach ($rii as $filename => $file) {
     47        if (in_array(basename($filename), ['db_auth.inc.php', 'db_auth.json'])) {
     48            $db_auth_file = $filename;
     49            break;
     50        }
    4851    }
    49 }
    50 if (!$db_auth_file) {
    51     die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND a db_auth file must exist within two directory levels.\n", $cli_executed));
    52 }
    53 if (fileowner($db_auth_file) != getmyuid()) {
    54     die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $cli_executed));
     52    if (!$db_auth_file) {
     53        die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND a db_auth file must exist within two directory levels.\n", $cli_executed));
     54    }
     55    if (fileowner($db_auth_file) != getmyuid()) {
     56        die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $cli_executed));
     57    }
    5558}
    5659
     
    7275    'site_email' => 'codebase@strangecode.com',
    7376    'enable_session' => false,
    74     'enable_db' => true,
     77    'enable_db' => defined('_NODB') ? false : true,
    7578    'db_create_tables' => true,
    7679    'db_auth_file' => $db_auth_file,
     
    8689));
    8790
    88 if (strtolower(getFilenameExtension($db_auth_file)) != 'json') {
    89     // DB auth file is not JSON, and will not be automatically be loaded by $app's 'db_auth_file' parser.
     91if (false !== $db_auth_file && strtolower(getFilenameExtension($db_auth_file)) != 'json') {
     92    // DB auth file is not JSON, and will not be automatically loaded by $app's 'db_auth_file' parser.
    9093    require_once $db_auth_file;
    9194}
     
    9598$app->start();
    9699
    97 // Global DB object. Automatically pre-configured by $app->start().
    98 $db =& DB::getInstance();
     100if (!defined('_NODB')) {
     101    // Global DB object. Automatically pre-configured by $app->start().
     102    $db =& DB::getInstance();
     103}
Note: See TracChangeset for help on using the changeset viewer.