mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-25 16:13:17 +03:00
Add validation for the existence of "config.php" and "vendor/autoload.php" in the index.php file
This commit is contained in:
parent
942cb3d46f
commit
2e81c0ea53
1 changed files with 170 additions and 161 deletions
331
index.php
331
index.php
|
@ -26,41 +26,51 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* EASY!APPOINTMENTS CONFIGURATION
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* Include Easy!Appointments configuration file so that it is available
|
||||
* globally in the application. You can access configuration information
|
||||
* through the static Config class.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* EASY!APPOINTMENTS CONFIGURATION
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* Include Easy!Appointments configuration file so that it is available
|
||||
* globally in the application. You can access configuration information
|
||||
* through the static Config class.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
if ( ! file_exists(__DIR__ . '/config.php'))
|
||||
{
|
||||
die('The root "config.php" file is missing, please copy "config-sample.php" to "config.php" and update it with your server data.');
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* COMPOSER AUTOLOAD FILE
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* Include Composer's autoload.php file so that I can use external
|
||||
* libraries directly in every section of the application.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* COMPOSER AUTOLOAD FILE
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* Include Composer's autoload.php file so that I can use external
|
||||
* libraries directly in every section of the application.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
if ( ! file_exists(__DIR__ . '/vendor/autoload.php'))
|
||||
{
|
||||
die('The "vendor/autoload.php" file is missing, please install the Composer dependencies with "composer install" before using the app.');
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
|
@ -79,7 +89,7 @@
|
|||
*
|
||||
* NOTE: If you change these, also change the error_reporting() code below
|
||||
*/
|
||||
define('ENVIRONMENT', (Config::DEBUG_MODE) ? 'development' : 'production');
|
||||
define('ENVIRONMENT', (Config::DEBUG_MODE) ? 'development' : 'production');
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
|
@ -91,28 +101,28 @@
|
|||
*/
|
||||
switch (ENVIRONMENT)
|
||||
{
|
||||
case 'development':
|
||||
error_reporting(-1);
|
||||
ini_set('display_errors', 1);
|
||||
break;
|
||||
case 'development':
|
||||
error_reporting(-1);
|
||||
ini_set('display_errors', 1);
|
||||
break;
|
||||
|
||||
case 'testing':
|
||||
case 'production':
|
||||
ini_set('display_errors', 0);
|
||||
if (version_compare(PHP_VERSION, '5.3', '>='))
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
case 'testing':
|
||||
case 'production':
|
||||
ini_set('display_errors', 0);
|
||||
if (version_compare(PHP_VERSION, '5.3', '>='))
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'The application environment is not set correctly.';
|
||||
exit(1); // EXIT_ERROR
|
||||
default:
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'The application environment is not set correctly.';
|
||||
exit(1); // EXIT_ERROR
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -123,7 +133,7 @@ switch (ENVIRONMENT)
|
|||
* This variable must contain the name of your "system" directory.
|
||||
* Set the path if it is not in the same directory as this file.
|
||||
*/
|
||||
$system_path = 'system';
|
||||
$system_path = 'system';
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
|
@ -140,7 +150,7 @@ switch (ENVIRONMENT)
|
|||
*
|
||||
* NO TRAILING SLASH!
|
||||
*/
|
||||
$application_folder = 'application';
|
||||
$application_folder = 'application';
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
|
@ -155,7 +165,7 @@ switch (ENVIRONMENT)
|
|||
*
|
||||
* NO TRAILING SLASH!
|
||||
*/
|
||||
$view_folder = '';
|
||||
$view_folder = '';
|
||||
|
||||
|
||||
/*
|
||||
|
@ -177,15 +187,15 @@ switch (ENVIRONMENT)
|
|||
*
|
||||
* Un-comment the $routing array below to use this feature
|
||||
*/
|
||||
// The directory name, relative to the "controllers" directory. Leave blank
|
||||
// if your controller is not in a sub-directory within the "controllers" one
|
||||
// $routing['directory'] = '';
|
||||
// The directory name, relative to the "controllers" directory. Leave blank
|
||||
// if your controller is not in a sub-directory within the "controllers" one
|
||||
// $routing['directory'] = '';
|
||||
|
||||
// The controller class file name. Example: mycontroller
|
||||
// $routing['controller'] = '';
|
||||
// The controller class file name. Example: mycontroller
|
||||
// $routing['controller'] = '';
|
||||
|
||||
// The controller function you wish to be called.
|
||||
// $routing['function'] = '';
|
||||
// The controller function you wish to be called.
|
||||
// $routing['function'] = '';
|
||||
|
||||
|
||||
/*
|
||||
|
@ -202,8 +212,7 @@ switch (ENVIRONMENT)
|
|||
*
|
||||
* Un-comment the $assign_to_config array below to use this feature
|
||||
*/
|
||||
// $assign_to_config['name_of_config_item'] = 'value of config item';
|
||||
|
||||
// $assign_to_config['name_of_config_item'] = 'value of config item';
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -216,120 +225,120 @@ switch (ENVIRONMENT)
|
|||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Set the current directory correctly for CLI requests
|
||||
if (defined('STDIN'))
|
||||
{
|
||||
chdir(dirname(__FILE__));
|
||||
}
|
||||
// Set the current directory correctly for CLI requests
|
||||
if (defined('STDIN'))
|
||||
{
|
||||
chdir(dirname(__FILE__));
|
||||
}
|
||||
|
||||
if (($_temp = realpath($system_path)) !== FALSE)
|
||||
{
|
||||
$system_path = $_temp.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ensure there's a trailing slash
|
||||
$system_path = strtr(
|
||||
rtrim($system_path, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
||||
).DIRECTORY_SEPARATOR;
|
||||
}
|
||||
if (($_temp = realpath($system_path)) !== FALSE)
|
||||
{
|
||||
$system_path = $_temp . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ensure there's a trailing slash
|
||||
$system_path = strtr(
|
||||
rtrim($system_path, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||
) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
// Is the system path correct?
|
||||
if ( ! is_dir($system_path))
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
// Is the system path correct?
|
||||
if ( ! is_dir($system_path))
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: ' . pathinfo(__FILE__, PATHINFO_BASENAME);
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------------
|
||||
* Now that we know the path, set the main path constants
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
// The name of THIS file
|
||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
// The name of THIS file
|
||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
|
||||
// Path to the system directory
|
||||
define('BASEPATH', $system_path);
|
||||
// Path to the system directory
|
||||
define('BASEPATH', $system_path);
|
||||
|
||||
// Path to the front controller (this file) directory
|
||||
define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
||||
// Path to the front controller (this file) directory
|
||||
define('FCPATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Name of the "system" directory
|
||||
define('SYSDIR', basename(BASEPATH));
|
||||
// Name of the "system" directory
|
||||
define('SYSDIR', basename(BASEPATH));
|
||||
|
||||
// The path to the "application" directory
|
||||
if (is_dir($application_folder))
|
||||
{
|
||||
if (($_temp = realpath($application_folder)) !== FALSE)
|
||||
{
|
||||
$application_folder = $_temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$application_folder = strtr(
|
||||
rtrim($application_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
|
||||
{
|
||||
$application_folder = BASEPATH.strtr(
|
||||
trim($application_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
// The path to the "application" directory
|
||||
if (is_dir($application_folder))
|
||||
{
|
||||
if (($_temp = realpath($application_folder)) !== FALSE)
|
||||
{
|
||||
$application_folder = $_temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$application_folder = strtr(
|
||||
rtrim($application_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif (is_dir(BASEPATH . $application_folder . DIRECTORY_SEPARATOR))
|
||||
{
|
||||
$application_folder = BASEPATH . strtr(
|
||||
trim($application_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: ' . SELF;
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
|
||||
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
|
||||
define('APPPATH', $application_folder . DIRECTORY_SEPARATOR);
|
||||
|
||||
// The path to the "views" directory
|
||||
if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
|
||||
{
|
||||
$view_folder = APPPATH.'views';
|
||||
}
|
||||
elseif (is_dir($view_folder))
|
||||
{
|
||||
if (($_temp = realpath($view_folder)) !== FALSE)
|
||||
{
|
||||
$view_folder = $_temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$view_folder = strtr(
|
||||
rtrim($view_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
|
||||
{
|
||||
$view_folder = APPPATH.strtr(
|
||||
trim($view_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
// The path to the "views" directory
|
||||
if ( ! isset($view_folder[0]) && is_dir(APPPATH . 'views' . DIRECTORY_SEPARATOR))
|
||||
{
|
||||
$view_folder = APPPATH . 'views';
|
||||
}
|
||||
elseif (is_dir($view_folder))
|
||||
{
|
||||
if (($_temp = realpath($view_folder)) !== FALSE)
|
||||
{
|
||||
$view_folder = $_temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
$view_folder = strtr(
|
||||
rtrim($view_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif (is_dir(APPPATH . $view_folder . DIRECTORY_SEPARATOR))
|
||||
{
|
||||
$view_folder = APPPATH . strtr(
|
||||
trim($view_folder, '/\\'),
|
||||
'/\\',
|
||||
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
||||
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: ' . SELF;
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
|
||||
define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
|
||||
define('VIEWPATH', $view_folder . DIRECTORY_SEPARATOR);
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
|
@ -338,4 +347,4 @@ switch (ENVIRONMENT)
|
|||
*
|
||||
* And away we go...
|
||||
*/
|
||||
require_once BASEPATH.'core/CodeIgniter.php';
|
||||
require_once BASEPATH . 'core/CodeIgniter.php';
|
||||
|
|
Loading…
Reference in a new issue