Changeset 267
- Timestamp:
- 07/21/08 01:41:26 (4 months ago)
- Files:
-
- trunk/Phergie/Bot.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Phergie/Bot.php
r229 r267 40 40 * @const string 41 41 */ 42 define('PHERGIE_BASE_DIR', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);42 define('PHERGIE_BASE_DIR', realpath('..') . DIRECTORY_SEPARATOR); 43 43 44 44 /** … … 47 47 * @const string 48 48 */ 49 define('PHERGIE_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);49 define('PHERGIE_DIR', realpath('.') . DIRECTORY_SEPARATOR); 50 50 51 51 /** … … 64 64 * Check to make sure the CLI SAPI is being used 65 65 */ 66 if (strtolower( php_sapi_name()) != 'cli') {66 if (strtolower(PHP_SAPI) != 'cli') { 67 67 trigger_error('Phergie requires the CLI SAPI in order to run', E_USER_ERROR); 68 68 } … … 72 72 * default timezone to prevent strict errors. 73 73 */ 74 $timezone = ini_get('date.timezone'); 75 if (empty($timezone)) { 76 trigger_error('The default timezone wasn\'t set, defaulting to "' . date_default_timezone_get() . '."', E_USER_NOTICE); 74 if (!ini_get('date.timezone')) { 77 75 date_default_timezone_set(date_default_timezone_get()); 78 76 } 79 unset($timezone);80 77 81 78 /** … … 93 90 echo 'No configuration file specified, defaulting to ' . PHERGIE_DEFAULT_INI . PHP_EOL; 94 91 $ini = PHERGIE_DEFAULT_INI; 95 } else if (!empty($argv[1]) && file_exists($argv[1]) && is_readable($argv[1])) {92 } else if (!empty($argv[1]) && is_file($argv[1]) && is_readable($argv[1])) { 96 93 echo 'Using specified configuration file ' . $argv[1] . PHP_EOL; 97 94 $ini = $argv[1]; … … 125 122 { 126 123 $file = $class; 127 if (str tolower(substr($file, 0, 8)) == 'phergie_') {124 if (stripos($file, 'phergie_') === 0) { 128 125 $file = substr($file, 8); 129 126 } 130 $file = str_replace('_', DIRECTORY_SEPARATOR, $file) . '.php'; 131 require_once ($file); 132 if (class_exists($class)) { 133 return; 134 } 135 trigger_error('Could not load class "' . $class . '" from file "' . $file . '"', E_USER_ERROR); 127 if (is_file($file = str_replace('_', DIRECTORY_SEPARATOR, $file) . '.php')) { 128 require $file; 129 } 136 130 } 137 131 … … 150 144 $config = parse_ini_file(PHERGIE_INI_PATH); 151 145 152 if ( count($config) == 0) {146 if (empty($config)) { 153 147 trigger_error('Configuration file inaccessible or empty: ' . $ini, E_USER_ERROR); 154 148 } … … 160 154 } 161 155 } 162 if ( count($missing) > 0) {156 if (!empty($missing)) { 163 157 trigger_error('Fatal error: Required configuration settings missing: ' . implode(', ', $missing), E_USER_ERROR); 164 158 } … … 199 193 if (!empty($config['plugins']) && 200 194 preg_match('/(all|none)(?:\s*except\s*(.+))?/ADi', $config['plugins'], $match)) { 201 $all = trim(strtolower($match[1])) != 'none';195 $all = strtolower(trim($match[1])) != 'none'; 202 196 if (!empty($match[2])) { 203 197 $include = array_map('strtolower', preg_split('/[, ]+/', trim($match[2])));