[1] | 1 | <?php |
---|
[362] | 2 | /** |
---|
| 3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[396] | 5 | * Copyright 2001-2012 Strangecode, LLC |
---|
[457] | 6 | * |
---|
[362] | 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. |
---|
[457] | 13 | * |
---|
[362] | 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. |
---|
[457] | 18 | * |
---|
[362] | 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 | */ |
---|
[1] | 22 | |
---|
[362] | 23 | /* module_maker/_config.inc.php */ |
---|
| 24 | |
---|
[19] | 25 | // Test argument. |
---|
[151] | 26 | if ($_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]); |
---|
[457] | 29 | |
---|
[1] | 30 | // First arg is path to current site. Realpath removes trailing /s |
---|
| 31 | define('COMMON_BASE', $common_base); |
---|
| 32 | } else { |
---|
[19] | 33 | die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n"); |
---|
[1] | 34 | } |
---|
| 35 | |
---|
[19] | 36 | // Make sure necessary files exist. |
---|
[500] | 37 | $db_auth_file = false; |
---|
| 38 | $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE)); |
---|
| 39 | $rii->setMaxDepth(2); |
---|
| 40 | foreach ($rii as $filename => $file) { |
---|
| 41 | if (mb_strpos($filename, 'db_auth.inc.php') !== false) { |
---|
| 42 | $db_auth_file = $filename; |
---|
| 43 | break; |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | if (!$db_auth_file) { |
---|
[19] | 48 | die("Error: First argument directory must contain the global/db_auth.inc.php file with valid MySQL credentials.\n"); |
---|
| 49 | } |
---|
| 50 | |
---|
[432] | 51 | // Set include path for all templates and libraries. |
---|
| 52 | ini_set('include_path', join(PATH_SEPARATOR, array( |
---|
| 53 | COMMON_BASE, |
---|
| 54 | get_include_path(), |
---|
| 55 | ))); |
---|
[1] | 56 | |
---|
| 57 | // Include core libraries. |
---|
| 58 | require_once 'codebase/lib/App.inc.php'; |
---|
| 59 | require_once 'codebase/lib/Utilities.inc.php'; |
---|
| 60 | require_once 'codebase/lib/Auth_SQL.inc.php'; |
---|
| 61 | |
---|
| 62 | $app =& App::getInstance('module_maker'); |
---|
| 63 | $app->setParam(array( |
---|
| 64 | 'site_name' => 'Module Maker', |
---|
[10] | 65 | 'site_email' => 'codebase@strangecode.com', |
---|
[1] | 66 | 'enable_session' => false, |
---|
| 67 | 'enable_db' => true, |
---|
| 68 | 'db_always_debug' => false, |
---|
| 69 | 'db_debug' => true, |
---|
| 70 | 'db_die_on_failure' => true, |
---|
| 71 | 'display_errors' => true, |
---|
| 72 | 'error_reporting' => E_ALL, |
---|
| 73 | 'log_screen_priority' => LOG_DEBUG, |
---|
| 74 | )); |
---|
[500] | 75 | require_once $db_auth_file; |
---|
[1] | 76 | |
---|
[136] | 77 | // Start application-based functionality: database, session, environment, ini setup, etc. |
---|
| 78 | // Most configuration parameters must be set before starting the App. |
---|
[1] | 79 | $app->start(); |
---|
| 80 | |
---|
[334] | 81 | // Global DB object. Automatically pre-configured by $app->start(). |
---|
[136] | 82 | $db =& DB::getInstance(); |
---|
| 83 | |
---|
| 84 | |
---|