mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-28 10:53:40 +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
165
index.php
165
index.php
|
@ -36,7 +36,7 @@
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*---------------------------------------------------------------
|
*---------------------------------------------------------------
|
||||||
* EASY!APPOINTMENTS CONFIGURATION
|
* EASY!APPOINTMENTS CONFIGURATION
|
||||||
*---------------------------------------------------------------
|
*---------------------------------------------------------------
|
||||||
|
@ -47,10 +47,15 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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
|
* COMPOSER AUTOLOAD FILE
|
||||||
*---------------------------------------------------------------
|
*---------------------------------------------------------------
|
||||||
|
@ -60,7 +65,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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
|
* 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');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*---------------------------------------------------------------
|
*---------------------------------------------------------------
|
||||||
|
@ -123,7 +133,7 @@ switch (ENVIRONMENT)
|
||||||
* This variable must contain the name of your "system" directory.
|
* This variable must contain the name of your "system" directory.
|
||||||
* Set the path if it is not in the same directory as this file.
|
* 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!
|
* NO TRAILING SLASH!
|
||||||
*/
|
*/
|
||||||
$application_folder = 'application';
|
$application_folder = 'application';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*---------------------------------------------------------------
|
*---------------------------------------------------------------
|
||||||
|
@ -155,7 +165,7 @@ switch (ENVIRONMENT)
|
||||||
*
|
*
|
||||||
* NO TRAILING SLASH!
|
* NO TRAILING SLASH!
|
||||||
*/
|
*/
|
||||||
$view_folder = '';
|
$view_folder = '';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -177,15 +187,15 @@ switch (ENVIRONMENT)
|
||||||
*
|
*
|
||||||
* Un-comment the $routing array below to use this feature
|
* Un-comment the $routing array below to use this feature
|
||||||
*/
|
*/
|
||||||
// The directory name, relative to the "controllers" directory. Leave blank
|
// The directory name, relative to the "controllers" directory. Leave blank
|
||||||
// if your controller is not in a sub-directory within the "controllers" one
|
// if your controller is not in a sub-directory within the "controllers" one
|
||||||
// $routing['directory'] = '';
|
// $routing['directory'] = '';
|
||||||
|
|
||||||
// The controller class file name. Example: mycontroller
|
// The controller class file name. Example: mycontroller
|
||||||
// $routing['controller'] = '';
|
// $routing['controller'] = '';
|
||||||
|
|
||||||
// The controller function you wish to be called.
|
// The controller function you wish to be called.
|
||||||
// $routing['function'] = '';
|
// $routing['function'] = '';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -202,8 +212,7 @@ switch (ENVIRONMENT)
|
||||||
*
|
*
|
||||||
* Un-comment the $assign_to_config array below to use this feature
|
* 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,54 +225,54 @@ switch (ENVIRONMENT)
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Set the current directory correctly for CLI requests
|
// Set the current directory correctly for CLI requests
|
||||||
if (defined('STDIN'))
|
if (defined('STDIN'))
|
||||||
{
|
{
|
||||||
chdir(dirname(__FILE__));
|
chdir(dirname(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($_temp = realpath($system_path)) !== FALSE)
|
if (($_temp = realpath($system_path)) !== FALSE)
|
||||||
{
|
{
|
||||||
$system_path = $_temp.DIRECTORY_SEPARATOR;
|
$system_path = $_temp . DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ensure there's a trailing slash
|
// Ensure there's a trailing slash
|
||||||
$system_path = strtr(
|
$system_path = strtr(
|
||||||
rtrim($system_path, '/\\'),
|
rtrim($system_path, '/\\'),
|
||||||
'/\\',
|
'/\\',
|
||||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||||
).DIRECTORY_SEPARATOR;
|
) . DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the system path correct?
|
// Is the system path correct?
|
||||||
if ( ! is_dir($system_path))
|
if ( ! is_dir($system_path))
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
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);
|
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
|
exit(3); // EXIT_CONFIG
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
* Now that we know the path, set the main path constants
|
* Now that we know the path, set the main path constants
|
||||||
* -------------------------------------------------------------------
|
* -------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
// The name of THIS file
|
// The name of THIS file
|
||||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||||
|
|
||||||
// Path to the system directory
|
// Path to the system directory
|
||||||
define('BASEPATH', $system_path);
|
define('BASEPATH', $system_path);
|
||||||
|
|
||||||
// Path to the front controller (this file) directory
|
// Path to the front controller (this file) directory
|
||||||
define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
define('FCPATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// Name of the "system" directory
|
// Name of the "system" directory
|
||||||
define('SYSDIR', basename(BASEPATH));
|
define('SYSDIR', basename(BASEPATH));
|
||||||
|
|
||||||
// The path to the "application" directory
|
// The path to the "application" directory
|
||||||
if (is_dir($application_folder))
|
if (is_dir($application_folder))
|
||||||
{
|
{
|
||||||
if (($_temp = realpath($application_folder)) !== FALSE)
|
if (($_temp = realpath($application_folder)) !== FALSE)
|
||||||
{
|
{
|
||||||
$application_folder = $_temp;
|
$application_folder = $_temp;
|
||||||
|
@ -273,34 +282,34 @@ switch (ENVIRONMENT)
|
||||||
$application_folder = strtr(
|
$application_folder = strtr(
|
||||||
rtrim($application_folder, '/\\'),
|
rtrim($application_folder, '/\\'),
|
||||||
'/\\',
|
'/\\',
|
||||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
|
elseif (is_dir(BASEPATH . $application_folder . DIRECTORY_SEPARATOR))
|
||||||
{
|
{
|
||||||
$application_folder = BASEPATH.strtr(
|
$application_folder = BASEPATH . strtr(
|
||||||
trim($application_folder, '/\\'),
|
trim($application_folder, '/\\'),
|
||||||
'/\\',
|
'/\\',
|
||||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
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;
|
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
|
exit(3); // EXIT_CONFIG
|
||||||
}
|
}
|
||||||
|
|
||||||
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
|
define('APPPATH', $application_folder . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// The path to the "views" directory
|
// The path to the "views" directory
|
||||||
if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
|
if ( ! isset($view_folder[0]) && is_dir(APPPATH . 'views' . DIRECTORY_SEPARATOR))
|
||||||
{
|
{
|
||||||
$view_folder = APPPATH.'views';
|
$view_folder = APPPATH . 'views';
|
||||||
}
|
}
|
||||||
elseif (is_dir($view_folder))
|
elseif (is_dir($view_folder))
|
||||||
{
|
{
|
||||||
if (($_temp = realpath($view_folder)) !== FALSE)
|
if (($_temp = realpath($view_folder)) !== FALSE)
|
||||||
{
|
{
|
||||||
$view_folder = $_temp;
|
$view_folder = $_temp;
|
||||||
|
@ -310,26 +319,26 @@ switch (ENVIRONMENT)
|
||||||
$view_folder = strtr(
|
$view_folder = strtr(
|
||||||
rtrim($view_folder, '/\\'),
|
rtrim($view_folder, '/\\'),
|
||||||
'/\\',
|
'/\\',
|
||||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
|
elseif (is_dir(APPPATH . $view_folder . DIRECTORY_SEPARATOR))
|
||||||
{
|
{
|
||||||
$view_folder = APPPATH.strtr(
|
$view_folder = APPPATH . strtr(
|
||||||
trim($view_folder, '/\\'),
|
trim($view_folder, '/\\'),
|
||||||
'/\\',
|
'/\\',
|
||||||
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
|
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
|
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;
|
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
|
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...
|
* And away we go...
|
||||||
*/
|
*/
|
||||||
require_once BASEPATH.'core/CodeIgniter.php';
|
require_once BASEPATH . 'core/CodeIgniter.php';
|
||||||
|
|
Loading…
Reference in a new issue