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

Last change on this file since 500 was 500, checked in by anonymous, 10 years ago

Many auth and crypto changes; various other bugfixes while working on pulso.

File size: 2.9 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$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
39$rii->setMaxDepth(2);
40foreach ($rii as $filename => $file) {
41    if (mb_strpos($filename, 'db_auth.inc.php') !== false) {
42        $db_auth_file = $filename;
43        break;
44    }
45}
46
47if (!$db_auth_file) {
48    die("Error: First argument directory must contain the global/db_auth.inc.php file with valid MySQL credentials.\n");
49}
50
51// Set include path for all templates and libraries.
52ini_set('include_path', join(PATH_SEPARATOR, array(
53    COMMON_BASE,
54    get_include_path(),
55)));
56
57// Include core libraries.
58require_once 'codebase/lib/App.inc.php';
59require_once 'codebase/lib/Utilities.inc.php';
60require_once 'codebase/lib/Auth_SQL.inc.php';
61
62$app =& App::getInstance('module_maker');
63$app->setParam(array(
64    'site_name' => 'Module Maker',
65    'site_email' => 'codebase@strangecode.com',
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));
75require_once $db_auth_file;
76
77// Start application-based functionality: database, session, environment, ini setup, etc.
78// Most configuration parameters must be set before starting the App.
79$app->start();
80
81// Global DB object. Automatically pre-configured by $app->start().
82$db =& DB::getInstance();
83
84
Note: See TracBrowser for help on using the repository browser.