Skip to content

Instantly share code, notes, and snippets.

@blackcoat
Created August 24, 2011 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackcoat/1169037 to your computer and use it in GitHub Desktop.
Save blackcoat/1169037 to your computer and use it in GitHub Desktop.
CodeIgniter 1.7.x system detection
<?php
# This is an excerpt from a modified version of the CodeIgniter front controller, index.php
/*
|---------------------------------------------------------------
| SYSTEM FOLDER NAME
|---------------------------------------------------------------
|
| This variable must contain the name of your "system" folder.
| Include the path if the folder is not in the same directory
| as this file.
|
| NO TRAILING SLASH!
|
|
| If the $CODEIGNITER_PATH environment variable is set for this
| server, then we will use the version of CodeIgniter it references.
|
| Otherwise, we should make an educated guess about where CodeIgniter
| might be on the server. All CodeIgniter packages are named in the
| format: "CodeIgniter_<version>". Assume that such a package exists
| somewhere on the server within PHP's include_path.
|
| Because CodeIgniter 1.7's class loader attempts to use file_exists( )
| on the BASEPATH (i.e. the $system_folder with a trailing slash),
| our system folder must be an absolute path. We actually have to
| prepend the appropriate include_path folder so that the file_exists( )
| checks on the CodeIgniter library classes do not fail.
|
| It should be noted that at the time of this writing, the
| current stable version of CodeIgniter is 2.0.2.
| Stryker's servers still use an outdated version of
| CodeIgniter that we will be linking against for this app.
|
*/
$system_folder = getenv('CODEIGNITER_PATH');
if (!$system_folder) {
$ci_folder = "CodeIgniter_1.7.2/system";
foreach(explode(':', get_include_path()) as $path) {
if (file_exists($path . '/' . $ci_folder)) {
$system_folder = $path . '/' . $ci_folder;
break;
}
}
unset($ci_folder);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment