Bonfire provides a number of resources that are loaded globally and are intended to make life a little easier for you. Most of these are loaded from the application/helpers/application_helper.php file.
$current_user
If a user is logged in, you can access the current user's detail within any of your controllers that extend Bonfire's provided controllers, like Front_Controller, Admin_Controller, etc. This is accessed by $this->current_user
.
This is an object with the user's details:
stdclass Object
{
[id] => 1
[role_id] => 1
[email] => darth@empire.com
[username] => Darth Vader
[password_hash] => ...
[reset_hash] => ...
[last_login] =>
[last_ip] =>
[created_on] =>
[deleted] => 0
[banned] => 0
[ban_message] =>
[reset_by] =>
[display_name] => Darth
[display_name_changed] =>
[timezone] => UM6
[language] =>
[active] => 1
[activate_hash] =>
[password_iterations] => 8
[force_password_reset] => 0
[role_name] => Administrator
[user_img] => (url for their avatar)
}
The exact details may change over the versions, but the entire users
table record is provided to you.
This same data is made available within all of your views as $current_user
.
<?php echo $current_user->display_name ?>
e()
A convenience function that can (and probably should) be used to replace echo()
in any places that you output text that a user might have entered. This function helps to defeat XSS attacks by running the text through htmlspecialchars()
.
<?php e($user->display_name); ?>
js_escape()
Performs some simple escaping of strings that will be inserted into javascript functions, like confirm()
or alert()
. Not suitable for use by itself within document.write. The only parameter is the string to escape.
dump()
Outputs the given variables with formatting and location. Any number of parameters can be passed to this function and they will all be printed out in a helpful manner, but script execution will continue.
gravatar_link()
Returns a URL for the user from Gravatar and provides a default image (the identicon) when the user hasn't provided one. This is intended to be used within your views for displaying the user's avatar.
<?php echo gravatar_image($current_user->email, 48, $current_user->display_name, $current_user->display_name, $class, $id); ?>
// Returns:
<img src="http://gravatar.com/avatar/XXX?s=48&r=pg&d=identicon" width="48" height="48" alt="" title="" />
The first parameter is the email address for the user. This is how they are referenced at Gravatar. The second parameter is the size of the image in pixels. The third parameter is the alt tag and the fourth parameter is the title for the tag. The fifth and sixth parameters are the class and id to be given to the img, respectively.
logit()
Logs an error to the Console in the profiler (if loaded) and to the log files.
logit('Some debugging message', 'debug');
The first parameter is the message to log. The second parameter is the log level.
If the profiler is enabled and the Console class is loaded, which it is by default in development mode, the string will show up in the Console section of the profiler.
If logging is enabled in your application/config/config.php
file, then it will also be logged to your default log file.
is_https()
This function was imported from CI v3. Returns true if a secure (HTTPS) connection is used. Otherwise, it returns false (including in the case of non-HTTP requests).
This is commonly used to ensure links generated by the site use the same protocol as is currently being used to access the site.
$httpProtocol = is_https() ? 'https://secure.' : 'http://www.';
$gravatarUrl = "{$httpProtocol}gravatar.com/";
The following functions (module_*()
) were deprecated in 0.7.1. You should use the methods in the Modules class instead.
module_folders()
Returns an array of the folders that modules are allowed to be stored in. These are set in application/config/config.php
.
DEPRECATED in version 0.7.1. Use Modules::folders() instead.
print_r( module_folders() );
Array(
application/modules,
bonfire/modules
)
module_list
Returns a list of all modules in the system. If TRUE is passed as the only parameter, any Bonfire core modules will NOT be shown, only your custom modules. If FALSE is passed, both core and custom modules will be listed.
DEPRECATED in 0.7.1. Use Modules::list_modules() instead.
print_r( module_list() );
Array
(
[0] => activities
[1] => builder
[2] => database
[3] => emailer
[5] => logs
[6] => migrations
[7] => permissions
[8] => roles
[9] => settings
[10] => sysinfo
[11] => translate
[12] => ui
[13] => update
[14] => users
)
module_controller_exists()
Looks within a module to see if a certain controller exists. The first parameter is the name of the controller, and the second parameter is the module name.
It returns either TRUE or FALSE.
DEPRECATED in 0.7.1. Use Modules::controller_exists() instead.
if (module_controller_exists('content', 'users')) { . . . }
module_file_path()
Locates a file within a module and returns the path to that file. The first parameter is the name of the module. The second parameter is the name of the folder. The last parameter is the name of the file that you're looking for (including the extension).
It returns the full server path to the file, if found.
DEPRECATED in 0.7.1. Use Modules::file_path() instead.
$path = module_file_path('users', 'assets', 'js/users.js');
module_path()
Returns the full server path to a module and, optionally, a folder within that module. The first parameter is the name of the module. The second parameter is the name of the folder.
DEPRECATED in 0.7.1. Use Modules::path() instead.
$path = module_path('users', 'assets');
module_files()
Returns an associative array of files within one or more modules.
The first parameter is the name of the module to restrict the search to. If left NULL, this will provide a list of all files within all of the modules. If a module name is specified, the search will be restricted to that module's files only.
DEPRECATED in 0.7.1. Use Modules::files() instead.
module_files('sysinfo');
// Produces:
Array
(
[sysinfo] => Array
(
[config] => Array
(
[0] => config.php
)
[controllers] => Array
(
[0] => developer.php
)
[language] => Array
(
[english] => Array
(
[0] => sysinfo_lang.php
)
[persian] => Array
(
[0] => sysinfo_lang.php
)
[portuguese_br] => Array
(
[0] => sysinfo_lang.php
)
[spanish_am] => Array
(
[0] => sysinfo_lang.php
)
)
[views] => Array
(
[developer] => Array
(
[0] => _sub_nav.php
[1] => index.php
[2] => modules.php
[3] => php_info.php
)
)
)
)
The second parameter lets you specify a folder within that module to limit the file search to. If left NULL, it will provide all of the files.
The third parameter, when set to TRUE, will exclude the core modules from the list. If FALSE, will include both the core and your custom modules.
module_config()
Returns the 'module_config' array from a module's config/config.php
file. The module_config
contains more information about a module, like the author, menu behavior, etc.
DEPRECATED in 0.7.1. Use Modules::config() instead.
49 ms | Loading Time: Base Classes |
132 ms | Controller Execution Time ( Docs / Index ) |
252 ms | Total Execution Time |
0.0004 | SELECT GET_LOCK('ilue0r6mk9rmrdm8hmklic9m67', 300) AS ci_session_lockSpeed: 0.0004 - Possible keys: - Key Used: - Type: - Rows: - Extra: No tables used |
0.0005 | SELECT `data` FROM `ap_ci3_sessions` WHERE `id` = 'ilue0r6mk9rmrdm8hmklic9m67'Speed: 0.0005 - Possible keys: - Key Used: - Type: - Rows: - Extra: Impossible WHERE noticed after reading const tables |
0.0008 | SHOW TABLES FROM `artiweb_db` |
0.0003 | SELECT * FROM `ap_settings`Speed: 0.0003 - Possible keys: - Key Used: - Type: ALL - Rows: 40 - Extra: |
0.0021 | Total Query Execution Time |
__ci_last_regenerate | 1732783992 |
requested_page | https://104854.21dyvlrb.asia/docs/developer/global_helpers |
previous_page | https://104854.21dyvlrb.asia/docs/developer/global_helpers |
No GET data exists |
No POST data exists |
docs/developer/global_helpers |
docs/index |
HTTP_ACCEPT | */* |
HTTP_USER_AGENT | Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) |
HTTP_CONNECTION | close |
SERVER_PORT | 80 |
SERVER_NAME | 104854.21dyvlrb.asia |
REMOTE_ADDR | 172.70.130.158 |
SERVER_SOFTWARE | Apache |
HTTP_ACCEPT_LANGUAGE | |
SCRIPT_NAME | /index.php |
REQUEST_METHOD | GET |
HTTP_HOST | |
REMOTE_HOST | |
CONTENT_TYPE | |
SERVER_PROTOCOL | HTTP/1.1 |
QUERY_STRING | |
HTTP_ACCEPT_ENCODING | gzip, br |
HTTP_X_FORWARDED_FOR | 3.147.27.129 |
base_url | https://104854.21dyvlrb.asia/ |
index_page | |
uri_protocol | AUTO |
url_suffix | |
language | english |
charset | UTF-8 |
enable_hooks | true |
subclass_prefix | MY_ |
composer_autoload | false |
permitted_uri_chars | a-z 0-9~%.:_- |
allow_get_array | true |
enable_query_strings | false |
controller_trigger | c |
function_trigger | m |
directory_trigger | d |
log_threshold | 0 |
log_path | /var/www/vhosts/artiplayer.com/httpdocs/application/logs/ |
log_file_extension | |
log_file_permissions | 420 |
log_date_format | Y-m-d H:i:s |
error_views_path | |
cache_path | /var/www/vhosts/artiplayer.com/httpdocs/application/cache/ |
cache_query_string | false |
encryption_key | d0680639b7b72a248f62d947aed47f62 |
sess_cookie_name | bf_session |
sess_expiration | 7200 |
sess_time_to_update | 300 |
sess_match_ip | false |
sess_expire_on_close | false |
sess_encrypt_cookie | false |
sess_use_database | false |
sess_table_name | sessions |
sess_match_useragent | true |
sess_driver | database |
sess_regenerate_destroy | false |
sess_save_path | ci3_sessions |
cookie_prefix | |
cookie_domain | |
cookie_path | / |
cookie_secure | false |
cookie_httponly | false |
standardize_newlines | false |
global_xss_filtering | false |
csrf_protection | true |
csrf_token_name | ci_csrf_token |
csrf_cookie_name | ci_csrf_token |
csrf_expire | 7200 |
csrf_regenerate | true |
csrf_exclude_uris | Array ( ) |
compress_output | false |
time_reference | utc |
rewrite_short_tags | false |
proxy_ips | |
bonfire.installed | 1 |
site.default_user_timezone | UM8 |
modules_locations | Array ( [/var/www/vhosts/artiplayer.com/httpdocs/application/modules/] => ../../application/modules/ [/var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/] => ../../bonfire/modules/ ) |
site.backup_folder | archives/ |
contexts | Array ( [0] => content [1] => reports [2] => settings [3] => developer ) |
enable_activity_logging | true |
sparks_path | ../sparks/ |
template.site_path | /var/www/vhosts/artiplayer.com/httpdocs/public/ |
template.theme_paths | Array ( [0] => themes ) |
template.default_layout | index |
template.ajax_layout | ajax |
template.use_mobile_themes | false |
template.default_theme | default/ |
template.admin_theme | admin |
template.message_template | <div class="alert alert-{type} alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button> <div>{message}</div> </div> |
template.breadcrumb_symbol | : |
template.parse_views | false |
assets.directories | Array ( [base] => assets [cache] => cache [css] => css [image] => images [js] => js [module] => module ) |
assets.js_opener | $(document).ready(function() { |
assets.js_closer | }); |
assets.css_combine | false |
assets.js_combine | false |
assets.css_minify | true |
assets.js_minify | true |
assets.encrypt_name | false |
assets.encode | false |
assets.base_folder | assets |
assets.asset_folders | Array ( [css] => css [js] => js [image] => images ) |
ui.current_shortcuts | Array ( [form_save] => Array ( [description] => Save any form in the admin area. [action] => $("input[name=save]").click();return false; ) [create_new] => Array ( [description] => Create a new record in the module. [action] => window.location.href=$("a#create_new").attr("href"); ) [select_all] => Array ( [description] => Select all records in an index page. [action] => $("table input[type=checkbox]").click();return false; ) [delete] => Array ( [description] => Delete the record(s). [action] => $("#delete-me.btn-danger").click(); ) [module_index] => Array ( [description] => Return to the index of the current module. [action] => window.location.href=$("a#list").attr("href"); ) [goto_content] => Array ( [description] => Jump to the Content context. [action] => window.location.href=$("#tb_content").attr("href") ) [goto_reports] => Array ( [description] => Jump to the Reports context. [action] => window.location.href=$("#tb_reports").attr("href") ) [goto_settings] => Array ( [description] => Jump to the Settings context. [action] => window.location.href=$("#tb_settings").attr("href") ) [goto_developer] => Array ( [description] => Jump to the Developer context. [action] => window.location.href=$("#tb_developer").attr("href") ) ) |
emailer.write_to_file | false |
migrate.auto_core | false |
migrate.auto_app | false |
commonmark.valid_drivers | Array ( [0] => Parsedown [1] => Markdown [2] => MarkdownExtra [3] => LeagueCommonMark ) |
commonmark.driver | MarkdownExtended |
docs.theme | docs |
docs.default_group | developer |
docs.show_dev_docs | true |
docs.show_app_docs | true |
docs.toc_file | _toc.ini |
docs.permitted_environments | Array ( [0] => development [1] => testing [2] => production ) |
application.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/application.php |
autoload.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/autoload.php |
config.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/config.php |
constants.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/constants.php |
database.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/database.php |
events.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/events.php |
hooks.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/hooks.php |
mimes.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/mimes.php |
profiler.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/profiler.php |
routes.php /var/www/vhosts/artiplayer.com/httpdocs/application/config/routes.php |
Base_Controller.php /var/www/vhosts/artiplayer.com/httpdocs/application/core/Base_Controller.php |
MY_Model.php /var/www/vhosts/artiplayer.com/httpdocs/application/core/MY_Model.php |
App_hooks.php /var/www/vhosts/artiplayer.com/httpdocs/application/hooks/App_hooks.php |
application_lang.php /var/www/vhosts/artiplayer.com/httpdocs/application/language/english/application_lang.php |
Profiler.php /var/www/vhosts/artiplayer.com/httpdocs/application/libraries/Profiler.php |
Base.php /var/www/vhosts/artiplayer.com/httpdocs/application/third_party/MX/Base.php |
Config.php /var/www/vhosts/artiplayer.com/httpdocs/application/third_party/MX/Config.php |
Controller.php /var/www/vhosts/artiplayer.com/httpdocs/application/third_party/MX/Controller.php |
Lang.php /var/www/vhosts/artiplayer.com/httpdocs/application/third_party/MX/Lang.php |
Loader.php /var/www/vhosts/artiplayer.com/httpdocs/application/third_party/MX/Loader.php |
Benchmark.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Benchmark.php |
CodeIgniter.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/CodeIgniter.php |
Common.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Common.php |
Config.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Config.php |
Controller.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Controller.php |
Hooks.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Hooks.php |
Input.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Input.php |
Lang.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Lang.php |
Loader.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Loader.php |
Log.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Log.php |
Model.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Model.php |
Output.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Output.php |
Router.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Router.php |
Security.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Security.php |
URI.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/URI.php |
Utf8.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/Utf8.php |
hash.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/compat/hash.php |
mbstring.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/compat/mbstring.php |
password.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/compat/password.php |
standard.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/core/compat/standard.php |
DB.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/database/DB.php |
DB_driver.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/database/DB_driver.php |
DB_query_builder.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/database/DB_query_builder.php |
DB_result.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/database/DB_result.php |
mysqli_driver.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/database/drivers/mysqli/mysqli_driver.php |
mysqli_result.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/database/drivers/mysqli/mysqli_result.php |
directory_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/helpers/directory_helper.php |
form_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/helpers/form_helper.php |
language_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/helpers/language_helper.php |
url_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/helpers/url_helper.php |
profiler_lang.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/language/english/profiler_lang.php |
Cache.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/libraries/Cache/Cache.php |
Cache_dummy.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/libraries/Cache/drivers/Cache_dummy.php |
Driver.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/libraries/Driver.php |
Session.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/libraries/Session/Session.php |
Session_driver.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/libraries/Session/Session_driver.php |
Session_database_driver.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/ci3/libraries/Session/drivers/Session_database_driver.php |
BF_Lang.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/core/BF_Lang.php |
BF_Loader.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/core/BF_Loader.php |
BF_Model.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/core/BF_Model.php |
BF_Router.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/core/BF_Router.php |
BF_Security.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/core/BF_Security.php |
BF_directory_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/helpers/BF_directory_helper.php |
BF_form_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/helpers/BF_form_helper.php |
application_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/helpers/application_helper.php |
config_file_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/helpers/config_file_helper.php |
markdown_extended_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/helpers/markdown_extended_helper.php |
markdown_helper.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/helpers/markdown_helper.php |
Assets.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/Assets.php |
CommonMark.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/CommonMark.php |
CommonMarkDriver.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/CommonMark/CommonMarkDriver.php |
CommonMark_MarkdownExtended.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/CommonMark/drivers/CommonMark_MarkdownExtended.php |
Console.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/Console.php |
Events.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/Events.php |
Modules.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/Modules.php |
Route.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/Route.php |
Template.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/libraries/Template.php |
docs.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/docs/config/docs.php |
routes.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/docs/config/routes.php |
Docs.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/docs/controllers/Docs.php |
docs_lang.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/docs/language/english/docs_lang.php |
_sidebar.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/docs/views/_sidebar.php |
index.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/docs/views/index.php |
Settings_lib.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/settings/libraries/Settings_lib.php |
Settings_model.php /var/www/vhosts/artiplayer.com/httpdocs/bonfire/modules/settings/models/Settings_model.php |
index.php index.php |
index.php themes/docs/index.php |