source: trunk/bin/module_maker/_config.inc.php @ 523

Last change on this file since 523 was 523, checked in by anonymous, 9 years ago

First set of changes towards 2.2.0. Improved functinoality with integration in wordpress; bugs fixed.

File size: 3.2 KB
Line 
1<?php
2/**
3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
5 * Copyright 2001-2012 Strangecode, LLC
6 *
7 * This file is part of The Strangecode Codebase.
8 *
9 * The Strangecode Codebase is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * The Strangecode Codebase is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/* module_maker/_config.inc.php */
24
25// Test argument.
26if ($_SERVER['argc'] > 1 && isset($_SERVER['argv'][1]) && '' != $_SERVER['argv'][1] && is_dir($_SERVER['argv'][1])) {
27    // Determine common site directory.
28    $common_base = realpath($_SERVER['argv'][1]);
29
30    // First arg is path to current site. Realpath removes trailing /s
31    define('COMMON_BASE', $common_base);
32} else {
33    die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n");
34}
35
36// Make sure necessary files exist.
37$db_auth_file = false;
38$db_json_file = false;
39$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
40$rii->setMaxDepth(2);
41foreach ($rii as $filename => $file) {
42    if (mb_strpos($filename, 'db_auth.json') !== false) {
43        $db_json_file = $filename;
44        break;
45    }
46    if (mb_strpos($filename, 'db_auth.inc.php') !== false) {
47        $db_auth_file = $filename;
48        break;
49    }
50}
51
52if (!$db_auth_file && !$db_json_file) {
53    die("Error: First argument directory must contain the global/db_auth.inc.php file with valid MySQL credentials.\n");
54}
55
56// Set include path for all templates and libraries.
57ini_set('include_path', join(PATH_SEPARATOR, array(
58    COMMON_BASE,
59    get_include_path(),
60)));
61
62// Include core libraries.
63require_once 'codebase/lib/App.inc.php';
64require_once 'codebase/lib/Utilities.inc.php';
65require_once 'codebase/lib/Auth_SQL.inc.php';
66
67$app =& App::getInstance('module_maker');
68$app->setParam(array(
69    'site_name' => 'Module Maker',
70    'site_email' => 'codebase@strangecode.com',
71    'enable_session' => false,
72    'enable_db' => true,
73    'db_always_debug' => false,
74    'db_debug' => true,
75    'db_die_on_failure' => true,
76    'display_errors' => true,
77    'error_reporting' => E_ALL,
78    'log_screen_priority' => LOG_DEBUG,
79    'log_directory' => COMMON_BASE . '/log',
80));
81
82if ($db_json_file) {
83    $app->setParam(array(
84        'db_auth_file' => $db_json_file,
85    ));
86} else {
87    require_once $db_auth_file;
88}
89
90// Start application-based functionality: database, session, environment, ini setup, etc.
91// Most configuration parameters must be set before starting the App.
92define('_CLI', true);
93$app->start();
94
95// Global DB object. Automatically pre-configured by $app->start().
96$db =& DB::getInstance();
97
98
Note: See TracBrowser for help on using the repository browser.