This commit is contained in:
45
application/core/EA_Benchmark.php
Normal file
45
application/core/EA_Benchmark.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments benchmark.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Benchmark extends CI_Benchmark
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Cache.php
Normal file
45
application/core/EA_Cache.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments cache.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Cache extends CI_Cache
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Calendar.php
Normal file
45
application/core/EA_Calendar.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments calendar.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Calendar extends CI_Calendar
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Config.php
Normal file
45
application/core/EA_Config.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments config.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Config extends CI_Config
|
||||
{
|
||||
//
|
||||
}
|
||||
157
application/core/EA_Controller.php
Normal file
157
application/core/EA_Controller.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments controller.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*
|
||||
* @property Admins_model $admins_model
|
||||
* @property Appointments_model $appointments_model
|
||||
* @property Service_categories_model $service_categories_model
|
||||
* @property Consents_model $consents_model
|
||||
* @property Customers_model $customers_model
|
||||
* @property Providers_model $providers_model
|
||||
* @property Roles_model $roles_model
|
||||
* @property Secretaries_model $secretaries_model
|
||||
* @property Services_model $services_model
|
||||
* @property Settings_model $settings_model
|
||||
* @property Unavailabilities_model $unavailabilities_model
|
||||
* @property Users_model $users_model
|
||||
* @property Webhooks_model $webhooks_model
|
||||
* @property Blocked_periods_model $blocked_periods_model
|
||||
*
|
||||
* @property Accounts $accounts
|
||||
* @property Api $api
|
||||
* @property Availability $availability
|
||||
* @property Email_messages $email_messages
|
||||
* @property Captcha_builder $captcha_builder
|
||||
* @property Google_Sync $google_sync
|
||||
* @property Caldav_Sync $caldav_sync
|
||||
* @property Ics_file $ics_file
|
||||
* @property Instance $instance
|
||||
* @property Ldap_client $ldap_client
|
||||
* @property Notifications $notifications
|
||||
* @property Permissions $permissions
|
||||
* @property Synchronization $synchronization
|
||||
* @property Timezones $timezones
|
||||
* @property Webhooks_client $webhooks_client
|
||||
*/
|
||||
class EA_Controller extends CI_Controller
|
||||
{
|
||||
/**
|
||||
* EA_Controller constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->load->library('accounts');
|
||||
|
||||
$this->ensure_user_exists();
|
||||
|
||||
$this->configure_language();
|
||||
|
||||
$this->load_common_html_vars();
|
||||
|
||||
$this->load_common_script_vars();
|
||||
|
||||
rate_limit($this->input->ip_address());
|
||||
}
|
||||
|
||||
private function ensure_user_exists()
|
||||
{
|
||||
$user_id = session('user_id');
|
||||
|
||||
if (!$user_id || !$this->db->table_exists('users')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->accounts->does_account_exist($user_id)) {
|
||||
session_destroy();
|
||||
|
||||
abort(403, 'Forbidden');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the language.
|
||||
*/
|
||||
private function configure_language()
|
||||
{
|
||||
$session_language = session('language');
|
||||
|
||||
if ($session_language) {
|
||||
$language_codes = config('language_codes');
|
||||
|
||||
config([
|
||||
'language' => $session_language,
|
||||
'language_code' => array_search($session_language, $language_codes) ?: 'en',
|
||||
]);
|
||||
}
|
||||
|
||||
$this->lang->load('translations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load common script vars for all requests.
|
||||
*/
|
||||
private function load_common_html_vars()
|
||||
{
|
||||
html_vars([
|
||||
'base_url' => config('base_url'),
|
||||
'index_page' => config('index_page'),
|
||||
'available_languages' => config('available_languages'),
|
||||
'language' => $this->lang->language,
|
||||
'csrf_token' => $this->security->get_csrf_hash(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load common script vars for all requests.
|
||||
*/
|
||||
private function load_common_script_vars()
|
||||
{
|
||||
script_vars([
|
||||
'base_url' => config('base_url'),
|
||||
'index_page' => config('index_page'),
|
||||
'available_languages' => config('available_languages'),
|
||||
'csrf_token' => $this->security->get_csrf_hash(),
|
||||
'language' => config('language'),
|
||||
'language_code' => config('language_code'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
45
application/core/EA_DB_forge.php
Normal file
45
application/core/EA_DB_forge.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments DB forge.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_DB_forge extends CI_DB_forge
|
||||
{
|
||||
//
|
||||
}
|
||||
47
application/core/EA_DB_query_builder.php
Normal file
47
application/core/EA_DB_query_builder.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments DB query builder.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*
|
||||
* @method int insert_id()
|
||||
*/
|
||||
class EA_DB_query_builder extends CI_DB_query_builder
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_DB_utility.php
Normal file
45
application/core/EA_DB_utility.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments DB utility.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_DB_utility extends CI_DB_utility
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Email.php
Normal file
45
application/core/EA_Email.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments email.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Email extends CI_Email
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Encrypt.php
Normal file
45
application/core/EA_Encrypt.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments encrypt.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Encrypt extends CI_Encrypt
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Encryption.php
Normal file
45
application/core/EA_Encryption.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments encryption.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Encryption extends CI_Encryption
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Exceptions.php
Normal file
45
application/core/EA_Exceptions.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments exceptions.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Exceptions extends CI_Exceptions
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Hooks.php
Normal file
45
application/core/EA_Hooks.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments hooks.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Hooks extends CI_Hooks
|
||||
{
|
||||
//
|
||||
}
|
||||
83
application/core/EA_Input.php
Normal file
83
application/core/EA_Input.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments input.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*
|
||||
* @property string $raw_input_stream
|
||||
*/
|
||||
class EA_Input extends CI_Input
|
||||
{
|
||||
/**
|
||||
* Fetch an item from JSON data.
|
||||
*
|
||||
* @param string|null $index Index for item to be fetched from the JSON payload.
|
||||
* @param bool|false $xss_clean Whether to apply XSS filtering
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function json(?string $index = null, bool $xss_clean = false): mixed
|
||||
{
|
||||
/** @var EA_Controller $CI */
|
||||
$CI = &get_instance();
|
||||
|
||||
if (strpos((string) $CI->input->get_request_header('Content-Type'), 'application/json') === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$input_stream = $CI->input->raw_input_stream;
|
||||
|
||||
if (empty($input_stream)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$payload = json_decode($input_stream, true);
|
||||
|
||||
if ($xss_clean) {
|
||||
foreach ($payload as $name => $value) {
|
||||
$payload[$name] = $CI->security->xss_clean($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($index)) {
|
||||
return $payload;
|
||||
}
|
||||
|
||||
return $payload[$index] ?? null;
|
||||
}
|
||||
}
|
||||
45
application/core/EA_Lang.php
Normal file
45
application/core/EA_Lang.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments lang.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Lang extends CI_Lang
|
||||
{
|
||||
//
|
||||
}
|
||||
77
application/core/EA_Loader.php
Normal file
77
application/core/EA_Loader.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments loader.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Loader extends CI_Loader
|
||||
{
|
||||
/**
|
||||
* Override the original view loader method so that layouts are also supported.
|
||||
*
|
||||
* @param string $view View filename.
|
||||
* @param array $vars An associative array of data to be extracted for use in the view.
|
||||
* @param bool $return Whether to return the view output or leave it to the Output class.
|
||||
*
|
||||
* @return object|string
|
||||
*/
|
||||
public function view($view, $vars = [], $return = false)
|
||||
{
|
||||
$layout = config('layout');
|
||||
|
||||
$is_layout_page = empty($layout); // This is a layout page if "layout" was undefined before the page got rendered.
|
||||
|
||||
$result = $this->_ci_load([
|
||||
'_ci_view' => $view,
|
||||
'_ci_vars' => $this->_ci_prepare_view_vars($vars),
|
||||
'_ci_return' => $return,
|
||||
]);
|
||||
|
||||
$layout = config('layout');
|
||||
|
||||
if ($layout && $is_layout_page) {
|
||||
$result = $this->_ci_load([
|
||||
'_ci_view' => $layout['filename'],
|
||||
'_ci_vars' => $this->_ci_prepare_view_vars($vars),
|
||||
'_ci_return' => $return,
|
||||
]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
45
application/core/EA_Log.php
Normal file
45
application/core/EA_Log.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments log.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Log extends CI_Log
|
||||
{
|
||||
//
|
||||
}
|
||||
55
application/core/EA_Migration.php
Normal file
55
application/core/EA_Migration.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
require_once __DIR__ . '/../../system/libraries/Migration.php';
|
||||
|
||||
/**
|
||||
* Easy!Appointments migration.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Migration extends CI_Migration
|
||||
{
|
||||
/**
|
||||
* Get the current migration version.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function current_version(): int
|
||||
{
|
||||
return $this->_get_version();
|
||||
}
|
||||
}
|
||||
214
application/core/EA_Model.php
Normal file
214
application/core/EA_Model.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments model.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Model extends CI_Model
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $casts = [];
|
||||
|
||||
/**
|
||||
* EA_Model constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific field value from the database.
|
||||
*
|
||||
* @param string $field Name of the value to be returned.
|
||||
* @param int $record_id Record ID.
|
||||
*
|
||||
* @return string Returns the selected record value from the database.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @deprecated Since 1.5
|
||||
*/
|
||||
public function get_value(string $field, int $record_id): string
|
||||
{
|
||||
if (method_exists($this, 'value')) {
|
||||
return $this->value($field, $record_id);
|
||||
}
|
||||
|
||||
throw new RuntimeException('The "get_value" is not defined in model: ', __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific record from the database.
|
||||
*
|
||||
* @param int $record_id The ID of the record to be returned.
|
||||
*
|
||||
* @return array Returns an array with the record data.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @deprecated Since 1.5
|
||||
*/
|
||||
public function get_row(int $record_id): array
|
||||
{
|
||||
if (method_exists($this, 'find')) {
|
||||
return $this->find($record_id);
|
||||
}
|
||||
|
||||
throw new RuntimeException('The "get_row" is not defined in model: ', __CLASS__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all records that match the provided criteria.
|
||||
*
|
||||
* param array|string $where Where conditions
|
||||
* @param int|null $limit Record limit.
|
||||
* @param int|null $offset Record offset.
|
||||
* @param string|null $order_by Order by.
|
||||
*
|
||||
* @return array Returns an array of records.
|
||||
*/
|
||||
public function get_batch($where = null, ?int $limit = null, ?int $offset = null, ?string $order_by = null): array
|
||||
{
|
||||
return $this->get($where, $limit, $offset, $order_by);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save (insert or update) a record.
|
||||
*
|
||||
* @param array $record Associative array with the record data.
|
||||
*
|
||||
* @return int Returns the record ID.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function add(array $record): int
|
||||
{
|
||||
return $this->save($record);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easily cast fields to the correct data type.
|
||||
*
|
||||
* The integrated MySQL library will return all values as strings, something that can easily becoming problematic,
|
||||
* especially when comparing database values.
|
||||
*
|
||||
* @param array $record Record data.
|
||||
*/
|
||||
public function cast(array &$record)
|
||||
{
|
||||
foreach ($this->casts as $attribute => $cast) {
|
||||
if (!isset($record[$attribute])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ($cast) {
|
||||
case 'integer':
|
||||
$record[$attribute] = (int) $record[$attribute];
|
||||
break;
|
||||
|
||||
case 'float':
|
||||
$record[$attribute] = (float) $record[$attribute];
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
$record[$attribute] = (bool) $record[$attribute];
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
$record[$attribute] = (string) $record[$attribute];
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException('Unsupported cast type provided: ' . $cast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only keep the requested fields of the provided record.
|
||||
*
|
||||
* @param array $record Record data (single or multiple records).
|
||||
* @param array $fields Requested field names.
|
||||
*/
|
||||
public function only(array &$record, array $fields)
|
||||
{
|
||||
if (is_assoc($record)) {
|
||||
$record = array_fields($record, $fields);
|
||||
} else {
|
||||
foreach ($record as &$record_item) {
|
||||
$record_item = array_fields($record_item, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure a field exists in an array by using its value or NULL.
|
||||
*
|
||||
* @param array $record Record data (single or multiple records).
|
||||
* @param array $fields Requested field names.
|
||||
*/
|
||||
public function optional(array &$record, array $fields)
|
||||
{
|
||||
if (is_assoc($record)) {
|
||||
foreach ($fields as $field => $default) {
|
||||
$record[$field] = $record[$field] ?? null ?: $default;
|
||||
}
|
||||
} else {
|
||||
foreach ($record as &$record_item) {
|
||||
foreach ($fields as $field => $default) {
|
||||
$record_item[$field] = $record_item[$field] ?? null ?: $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DB field name based on an API field name.
|
||||
*
|
||||
* @param string $api_field API resource key.
|
||||
*
|
||||
* @return string|null Returns the column field or null if non found.
|
||||
*/
|
||||
public function db_field(string $api_field): ?string
|
||||
{
|
||||
return $this->api_resource[$api_field] ?? null;
|
||||
}
|
||||
}
|
||||
45
application/core/EA_Output.php
Normal file
45
application/core/EA_Output.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments output.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Output extends CI_Output
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Profiler.php
Normal file
45
application/core/EA_Profiler.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments profiler.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Profiler extends CI_Profiler
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Router.php
Normal file
45
application/core/EA_Router.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments router.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Router extends CI_Router
|
||||
{
|
||||
//
|
||||
}
|
||||
95
application/core/EA_Security.php
Normal file
95
application/core/EA_Security.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments security.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Security extends CI_Security
|
||||
{
|
||||
/**
|
||||
* CSRF Verify
|
||||
*
|
||||
* @return CI_Security
|
||||
*/
|
||||
public function csrf_verify()
|
||||
{
|
||||
// If it's not a POST request we will set the CSRF cookie
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST') {
|
||||
return $this->csrf_set_cookie();
|
||||
}
|
||||
|
||||
// Check if URI has been whitelisted from CSRF checks
|
||||
if ($exclude_uris = config_item('csrf_exclude_uris')) {
|
||||
$uri = load_class('URI', 'core');
|
||||
foreach ($exclude_uris as $excluded) {
|
||||
if (preg_match('#^' . $excluded . '$#i' . (UTF8_ENABLED ? 'u' : ''), $uri->uri_string())) {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check CSRF token validity, but don't error on mismatch just yet - we'll want to regenerate
|
||||
$csrf_token = $_POST[$this->_csrf_token_name] ?? ($_SERVER['HTTP_X_CSRF'] ?? null);
|
||||
|
||||
$valid =
|
||||
isset($csrf_token, $_COOKIE[$this->_csrf_cookie_name]) &&
|
||||
is_string($csrf_token) &&
|
||||
is_string($_COOKIE[$this->_csrf_cookie_name]) &&
|
||||
hash_equals($csrf_token, $_COOKIE[$this->_csrf_cookie_name]);
|
||||
|
||||
// We kill this since we're done, and we don't want to pollute the _POST array
|
||||
unset($_POST[$this->_csrf_token_name]);
|
||||
|
||||
// Regenerate on every submission?
|
||||
if (config_item('csrf_regenerate')) {
|
||||
// Nothing should last forever
|
||||
unset($_COOKIE[$this->_csrf_cookie_name]);
|
||||
$this->_csrf_hash = null;
|
||||
}
|
||||
|
||||
$this->_csrf_set_hash();
|
||||
$this->csrf_set_cookie();
|
||||
|
||||
if ($valid !== true) {
|
||||
$this->csrf_show_error();
|
||||
}
|
||||
|
||||
log_message('info', 'CSRF token verified');
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
45
application/core/EA_Session.php
Normal file
45
application/core/EA_Session.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments session.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Session extends CI_Session
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_URI.php
Normal file
45
application/core/EA_URI.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments URI.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_URI extends CI_URI
|
||||
{
|
||||
//
|
||||
}
|
||||
45
application/core/EA_Upload.php
Normal file
45
application/core/EA_Upload.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.4.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Easy!Appointments upload.
|
||||
*
|
||||
* @property EA_Benchmark $benchmark
|
||||
* @property EA_Cache $cache
|
||||
* @property EA_Calendar $calendar
|
||||
* @property EA_Config $config
|
||||
* @property EA_DB_forge $dbforge
|
||||
* @property EA_DB_query_builder $db
|
||||
* @property EA_DB_utility $dbutil
|
||||
* @property EA_Email $email
|
||||
* @property EA_Encrypt $encrypt
|
||||
* @property EA_Encryption $encryption
|
||||
* @property EA_Exceptions $exceptions
|
||||
* @property EA_Hooks $hooks
|
||||
* @property EA_Input $input
|
||||
* @property EA_Lang $lang
|
||||
* @property EA_Loader $load
|
||||
* @property EA_Log $log
|
||||
* @property EA_Migration $migration
|
||||
* @property EA_Output $output
|
||||
* @property EA_Profiler $profiler
|
||||
* @property EA_Router $router
|
||||
* @property EA_Security $security
|
||||
* @property EA_Session $session
|
||||
* @property EA_Upload $upload
|
||||
* @property EA_URI $uri
|
||||
*/
|
||||
class EA_Upload extends CI_Upload
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user