Functions every page can call: main(), db(), tpl(), _class(), module(), conf(), _es(), _prepare_html() and the rest.
Most are wrapped in function_exists(), so a project can define its own version first.
yf_aliases.php 108yf_array_funcs.php 20yf_basic_auth.php 0yf_common_funcs.php 62yf_compat_funcs.php 0yf_conf.php 4yf_debug.php 0yf_is_funcs.php 24yf_placeholder_img.php 0yf_strip_tags_smart.php 0yf_aliases.php 108 functions function _301($url, $text = '')
function _301($url, $text = '')
{
return common()->redirect(['url' => $url, 'text' => $text, 'type' => '301']);
}
function _302($url, $text = '')
function _302($url, $text = '')
{
return common()->redirect(['url' => $url, 'text' => $text, 'type' => '302']);
}
function _403($text = '')
function _403($text = '')
{
return common()->error_403($text);
}
function _404($text = '')
function _404($text = '')
{
return common()->error_404($text);
}
function _add_get($add_skip = [])
function _add_get($add_skip = [])
{
return common()->add_get_vars($add_skip);
}
function _check_rights($methods)
function _check_rights($methods)
{
global $main;
return method_exists($main, '_check_rights') ? $main->_check_rights($methods) : true;
}
function _check_user_ban($info = [], $user_info = [])
function _check_user_ban($info = [], $user_info = [])
{
return common()->check_user_ban($info, $user_info);
}
function _class($class_name, $custom_path = '', $params = '', $silent = false)
function _class($class_name, $custom_path = '', $params = '', $silent = false)
{
return main()->init_class($class_name, $custom_path ?: 'classes/', $params) ?: new yf_missing_method_handler(__FUNCTION__, $silent, $class_name);
}
function _class_safe($class_name, $custom_path = '', $params = '')
function _class_safe($class_name, $custom_path = '', $params = '')
{
return main()->init_class($class_name, $custom_path ?: 'classes/', $params) ?: new yf_missing_method_handler(__FUNCTION__, $silent = true, $class_name);
}
function _cookie($key = null, $val = null)
function _debug_log($text, $log_level = false)
function _debug_log($text, $log_level = false)
{
return _class('utils')->_debug_log($text, $log_level);
}
function _e($text = '', $clear_error = true)
function _e($text = '', $clear_error = true)
{
return common()->_show_error_message($text, $clear_error);
}
function _ee($error_key = '')
function _ee($error_key = '')
{
return common()->_error_exists($error_key);
}
function _empty($in = null)
function _empty($in = null)
{
return empty($in);
}
function _env($key = null, $val = null)
function _env($key = null, $val = null)
{
return input()->env($key, $val);
}
function _es($text = '')
function _es($text = '')
{
return db()->es($text);
}
function _get($key = null, $val = null)
function _get($key = null, $val = null)
{
return input()->get($key, $val);
}
function _isset($in = null)
function _isset($in = null)
{
return isset($in);
}
function _post($key = null, $val = null)
function _post($key = null, $val = null)
{
return input()->post($key, $val);
}
function _prepare_html($text = '', $need_strip_slashes = 1, $use_smart_function = 1)
function _prepare_html($text = '', $need_strip_slashes = 1, $use_smart_function = 1)
{
return _class('utils')->_prepare_html($text, $need_strip_slashes, $use_smart_function);
}
function _re($text = '', $error_key = '')
function _re($text = '', $error_key = '')
{
return common()->_raise_error($text, $error_key);
}
function _server($key = null, $val = null)
function _server($key = null, $val = null)
{
return input()->server($key, $val);
}
function _session($key = null, $val = null)
function _session($key = null, $val = null)
{
return input()->session($key, $val);
}
function _ssh_exec($server_info = [], $cmd = '')
function _ssh_exec($server_info = [], $cmd = '')
{
return _class('ssh')->exec($server_info, $cmd);
}
function _strlen($text)
function _strlen($text)
{
return _class('utf8')->strlen($text);
}
function _strtolower($text)
function _strtolower($text)
{
return _class('utf8')->strtolower($text);
}
function _strtoupper($text)
function _strtoupper($text)
{
return _class('utf8')->strtoupper($text);
}
function _substr($text, $start, $length = null)
function _substr($text, $start, $length = null)
{
return _class('utf8')->substr($text, $start, $length);
}
function _truncate($string, $len, $wordsafe = false, $dots = false)
function _truncate($string, $len, $wordsafe = false, $dots = false)
{
return _class('utf8')->truncate_utf8($string, $len, $wordsafe, $dots);
}
function _ucfirst($text)
function _ucfirst($text)
{
return _class('utf8')->ucfirst($text);
}
function _ucwords($text)
function _ucwords($text)
{
return _class('utf8')->ucwords($text);
}
function _wordwrap($string, $length = 75, $break = '\\n', $cut = false)
function _wordwrap($string, $length = 75, $break = '\n', $cut = false)
{
return _class('utf8')->wordwrap($string, $length, $break, $cut);
}
function a()
function a()
{
return call_user_func_array([_class('html'), __FUNCTION__], func_get_args());
}
function angularjs($content, $params = [])
function angularjs($content, $params = [])
{
return _class('assets')->helper_js_library('angularjs', $content, (array) $params);
}
function asset($content, $asset_type = 'bundle', $content_type = 'auto', $params = [])
function asset($content, $asset_type = 'bundle', $content_type = 'auto', $params = [])
{
return _class('assets')->add($content, $asset_type, $content_type, $params);
}
function cache($silent = false)
function cache($silent = false)
{
return _class('cache') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function cache_del($name)
function cache_del($name)
{
return cache()->del($name);
}
function cache_files()
function cache_files()
{
static $cache;
if ( ! isset($cache)) {
$cache = clone _class('cache');
$cache->_init(['driver' => 'files']);
}
return $cache;
}
function cache_get($name, $force_ttl = 0, array $params = [])
$params array function cache_get($name, $force_ttl = 0, array $params = [])
{
return cache()->get($name, $force_ttl, $params);
}
function cache_set($name, $data, $ttl = 0)
function cache_set($name, $data, $ttl = 0)
{
return cache()->set($name, $data, $ttl);
}
function cache_tmp()
function cache_tmp()
{
static $cache;
if ( ! isset($cache)) {
$cache = clone _class('cache');
$cache->_init(['driver' => 'tmp']);
}
return $cache;
}
function coffee($content, $content_type = 'auto', $params = [])
function coffee($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add_coffee($content, $content_type, $params);
}
function common($silent = false)
function common($silent = false)
{
return _class('common') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function css($content, $content_type = 'auto', $params = [])
function css($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add($content, 'css', $content_type, $params);
}
function d()
function d()
{
global $auto_ids;
$auto_id = ($auto_prefix = 'func__' . __FUNCTION__) . @$auto_ids[$auto_prefix]++;
echo '<a class="btn btn-xs btn-default" data-toggle="collapse" data-target="#collapse_' . $auto_id . '">Trace</a><div id="collapse_' . $auto_id . '" class="collapse"><pre>' . print_r(trace(), true) . '</pre></div>';
foreach (($args = func_get_args()) as $k => $v) {
echo '<pre>' . (count((array) $args) > 1 ? '<b>args[' . (int) $k . ']</b>:' . PHP_EOL : '') . var_export($v, true) . '</pre>';
}
}
function db($tbl_name = '', $silent = false)
function db($tbl_name = '', $silent = false)
{
global $db;
if ( ! is_object($db)) {
return $tbl_name ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
return $tbl_name ? $db->_real_name($tbl_name) : $db;
}
function db_fetch($resource = null, $use_cache = true)
function db_fetch($resource = null, $use_cache = true)
{
return db()->fetch_assoc($resource, $use_cache);
}
function db_get($sql = '', $use_cache = true)
function db_get($sql = '', $use_cache = true)
{
return db()->query_fetch($sql, $use_cache);
}
function db_get_all($sql = '', $key_name = null, $use_cache = true)
function db_get_all($sql = '', $key_name = null, $use_cache = true)
{
return db()->query_fetch_all($sql, $key_name, $use_cache);
}
function db_get_one($sql = '', $use_cache = true)
function db_get_one($sql = '', $use_cache = true)
{
return db()->get_one($sql, $use_cache);
}
function db_master($tbl = '')
function db_master($tbl = '')
{
return db($tbl);
}
function &db_query($sql = '')
function &db_query($sql = '')
{
return db()->query($sql);
}
function db_slave($tbl = '')
function db_slave($tbl = '')
{
return db($tbl);
}
function ethereum($silent = false)
function ethereum($silent = false)
{
return _class('wrapper_ethereum') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function events($silent = false)
function events($silent = false)
{
return _class('core_events') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function form($replace = [], $params = [])
function form($replace = [], $params = [])
{
$form = clone _class('form2');
return $form->chained_wrapper($replace, $params);
}
function form2($replace = [], $params = [])
function form2($replace = [], $params = [])
{
$form = clone _class('form2');
return $form->chained_wrapper($replace, $params);
}
function form_item($replace = [], $params = [])
function form_item($replace = [], $params = [])
{
$form = clone _class('form2');
return $form->chained_wrapper($replace, ['no_form' => 1, 'only_content' => 1, 'no_chained_mode' => 1] + (array) $params);
}
function from()
function from()
{
return call_user_func_array([db(), __FUNCTION__], func_get_args());
}
function getmicrotime()
function getmicrotime()
{
return microtime(true);
}
function getset($key, callable $func, $ttl = 0, array $params = [])
$func callable$params array function getset($key, callable $func, $ttl = 0, array $params = [])
{
return main()->getset($key, $func, $ttl, $params);
}
function gmtime()
function gmtime()
{
return common()->gmtime();
}
function haml($content, $params = [])
function haml($content, $params = [])
{
return _class('services')->haml($content, $params);
}
function html(array $params = [])
$params array function html(array $params = [])
{
return _class('html')->chained_wrapper($params);
}
function input($silent = false)
function input($silent = false)
{
return _class('input') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function jade($content, $params = [])
function jade($content, $params = [])
{
return _class('services')->jade($content, $params);
}
function job($silent = false)
function job($silent = false)
{
return _class('wrapper_job') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function jquery($content, $params = [])
function jquery($content, $params = [])
{
return _class('assets')->jquery($content, $params);
}
function js($content, $content_type = 'auto', $params = [])
function js($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add($content, 'js', $content_type, $params);
}
function js_redirect($location, $rewrite = true, $text = '', $ttl = 0)
function js_redirect($location, $rewrite = true, $text = '', $ttl = 0)
{
return common()->redirect($location, $rewrite, 'js', $text, $ttl);
}
function l($name = '', $data = '', $lang = '')
function l($name = '', $data = '', $lang = '')
{
return common()->l($name, $data, $lang);
}
function less($content, $content_type = 'auto', $params = [])
function less($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add_less($content, $content_type, $params);
}
function load($class_name, $force_storage = '', $custom_path = '')
function load($class_name, $force_storage = '', $custom_path = '')
{
return main()->load_class_file($class_name, $custom_path, $force_storage);
}
function logger($silent = false)
function logger($silent = false)
{
return _class('logger') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function main($silent = false)
function main($silent = false)
{
global $main;
return $main ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function memcached($silent = false)
function memcached($silent = false)
{
return _class('wrapper_memcached') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function model($name, $params = [])
function model($name, $params = [])
{
return db()->model($name, $params);
}
function module($class_name, $params = '', $silent = false)
function module($class_name, $params = '', $silent = false)
{
return main()->init_class($class_name, '', $params) ?: new yf_missing_method_handler(__FUNCTION__, $silent, $class_name);
}
function module_safe($class_name, $params = '')
function module_safe($class_name, $params = '')
{
return main()->init_class($class_name, '', $params) ?: new yf_missing_method_handler(__FUNCTION__, $silent = true, $class_name);
}
function printr($var, $do_not_echo = false)
function printr($var, $do_not_echo = false)
{
return _class('utils')->printr($var, $do_not_echo);
}
function process_url($url = '', $force_rewrite = false, $for_site_id = false)
function process_url($url = '', $force_rewrite = false, $for_site_id = false)
{
return _class('rewrite')->_process_url($url, $force_rewrite, $for_site_id);
}
function pubsub($silent = false)
function pubsub($silent = false)
{
return _class('wrapper_pubsub') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function queue($silent = false)
function queue($silent = false)
{
return _class('wrapper_queue') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function rabbitmq($silent = false)
function rabbitmq($silent = false)
{
return _class('wrapper_rabbitmq') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function reactjs($content, $params = [])
function reactjs($content, $params = [])
{
return _class('assets')->helper_js_library('reactjs', $content, (array) $params);
}
function redirect($location, $rewrite = true, $text = '', $ttl = 3)
function redirect($location, $rewrite = true, $text = '', $ttl = 3)
{
return common()->redirect($location, $rewrite, 'html', $text, $ttl);
}
function redis($options = [])
function redis($options = [])
{
return $options ? _class('wrapper_redis')->factory($options) : _class('wrapper_redis');
}
function redlock($silent = false)
function redlock($silent = false)
{
return _class('wrapper_redlock') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function require_css($content, $content_type = 'auto', $params = [])
function require_css($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add($content, 'css', $content_type, $params);
}
function require_js($content, $content_type = 'auto', $params = [])
function require_js($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add($content, 'js', $content_type, $params);
}
function require_php_lib($name, $params = [])
function require_php_lib($name, $params = [])
{
return _class('services')->require_php_lib($name, $params);
}
function sass($content, $content_type = 'auto', $params = [])
function sass($content, $content_type = 'auto', $params = [])
{
return _class('assets')->add_sass($content, $content_type, $params);
}
function select()
function select()
{
return call_user_func_array([db(), __FUNCTION__], func_get_args());
}
function services($silent = false)
function services($silent = false)
{
return _class('services') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function sms_send($phone, $text, $params = [])
function sms_send($phone, $text, $params = [])
{
return _class('service_turbosms')->send($phone, $text, $params) ?: new yf_missing_method_handler(__FUNCTION__);
}
function sphinx_escape_string($string)
function sphinx_escape_string($string)
{
return _class('sphinxsearch')->escape_string($string);
}
function sphinx_query($sql, $need_meta = false)
function sphinx_query($sql, $need_meta = false)
{
return _class('sphinxsearch')->query($sql, $need_meta);
}
function t($string, $args = 0, $lang = '')
function t($string, $args = 0, $lang = '')
{
return _class('i18n')->translate_string($string, $args, $lang);
}
function table($data = [], $params = [])
function table($data = [], $params = [])
{
$table = clone _class('table2');
return $table->chained_wrapper($data, $params);
}
function table2($data = [], $params = [])
function table2($data = [], $params = [])
{
$table = clone _class('table2');
return $table->chained_wrapper($data, $params);
}
function tip($text, $extra = [])
function tip($text, $extra = [])
{
return _class('graphics')->tip($text, $extra);
}
function tpl($silent = false)
function tpl($silent = false)
{
return _class('tpl') ?: new yf_missing_method_handler(__FUNCTION__, $silent);
}
function trace($skip_before = 1, $skip_after = 1)
function trace($skip_before = 1, $skip_after = 1)
{
$e = new Exception();
return implode(PHP_EOL, array_slice(explode(PHP_EOL, $e->getTraceAsString()), $skip_before, -$skip_after));
}
function url($params = [], $host = '', $url_str = '')
function url($params = [], $host = '', $url_str = '')
{
return _class('rewrite')->_url($params, $host, $url_str);
}
function url_admin($params = [], $host = '', $url_str = '')
function url_admin($params = [], $host = '', $url_str = '')
{
return _class('rewrite')->_url_admin($params, $host, $url_str);
}
function url_user($params = [], $host = '', $url_str = '')
function url_user($params = [], $host = '', $url_str = '')
{
return _class('rewrite')->_url_user($params, $host, $url_str);
}
function user($user_id, $fields = 'full', $params = '', $return_sql = false)
function user($user_id, $fields = 'full', $params = '', $return_sql = false)
{
$_common = common();
return is_object($_common) && method_exists($_common, 'user') ? $_common->user($user_id, $fields, $params, $return_sql) : false;
}
function validate($input = '', $rules = [])
function validate($input = '', $rules = [])
{
return _class('validate')->_input_is_valid($input, $rules);
}
yf_array_funcs.php 20 functions function array_add($array, $key, $value)
Add an element to an array using "dot" notation if it doesn't exist.
$array array$key stringReturns array
function array_add($array, $key, $value)
{
if (array_get($array, $key) === null) {
array_set($array, $key, $value);
}
return $array;
}
function array_build($array, Closure $callback)
Build a new array using a callback.
$array array$callback ClosureReturns array
function array_build($array, Closure $callback)
{
$results = [];
foreach ($array as $key => $value) {
list($innerKey, $innerValue) = call_user_func($callback, $key, $value);
$results[$innerKey] = $innerValue;
}
return $results;
}
function array_divide($array)
Divide an array into two arrays. One with keys and the other with values.
$array arrayReturns array
function array_divide($array)
{
return [array_keys($array), array_values($array)];
}
function array_dot($array, $prepend = '')
Flatten a multi-dimensional associative array with dots.
$array array$prepend stringReturns array
function array_dot($array, $prepend = '')
{
$results = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$results = array_merge($results, array_dot($value, $prepend . $key . '.'));
} else {
$results[$prepend . $key] = $value;
}
}
return $results;
}
function array_except($array, $keys)
Get all of the given array except for a specified array of items.
$array array$keys arrayReturns array
function array_except($array, $keys)
{
return array_diff_key($array, array_flip((array) $keys));
}
function array_fetch($array, $key)
Fetch a flattened array of a nested array element.
$array array$key stringReturns array
function array_fetch($array, $key)
{
foreach (explode('.', $key) as $segment) {
$results = [];
foreach ($array as $value) {
$value = (array) $value;
$results[] = $value[$segment];
}
$array = array_values($results);
}
return array_values($results);
}
function array_flatten($array)
Flatten a multi-dimensional array into a single level.
$array arrayReturns array
function array_flatten($array)
{
$return = [];
array_walk_recursive($array, function ($x) use (&$return) {
$return[] = $x;
});
return $return;
}
function array_forget(&$array, $key)
Remove an array item from a given array using "dot" notation.
$array array$key string function array_forget(&$array, $key)
{
$keys = explode('.', $key);
while (count((array) $keys) > 1) {
$key = array_shift($keys);
if ( ! isset($array[$key]) || ! is_array($array[$key])) {
return;
}
$array = &$array[$key];
}
unset($array[array_shift($keys)]);
}
function array_get($array, $key, $default = null)
Get an item from an array using "dot" notation.
$array array$key string function array_get($array, $key, $default = null)
{
if ($key === null) {
return $array;
}
if (isset($array[$key])) {
return $array[$key];
}
foreach (explode('.', $key) as $segment) {
if ( ! is_array($array) || ! array_key_exists($segment, $array)) {
return value($default);
}
$array = $array[$segment];
}
return $array;
}
function array_only($array, $keys)
Get a subset of the items from the given array.
$array array$keys arrayReturns array
function array_only($array, $keys)
{
return array_intersect_key($array, array_flip((array) $keys));
}
function array_pluck($array, $value, $key = null)
Pluck an array of values from an array.
$array array$value string$key stringReturns array
function array_pluck($array, $value, $key = null)
{
$results = [];
foreach ($array as $item) {
$itemValue = is_object($item) ? $item->{$value} : $item[$value];
// If the key is "null", we will just append the value to the array and keep
// looping. Otherwise we will key the array using the value of the key we
// received from the developer. Then we'll return the final array form.
if ($key === null) {
$results[] = $itemValue;
} else {
$itemKey = is_object($item) ? $item->{$key} : $item[$key];
$results[$itemKey] = $itemValue;
}
}
return $results;
}
function array_pull(&$array, $key, $default = null)
Get a value from the array, and remove it.
$array array$key string function array_pull(&$array, $key, $default = null)
{
$value = array_get($array, $key, $default);
array_forget($array, $key);
return $value;
}
function array_set(&$array, $key, $value)
Set an array item to a given value using "dot" notation.
If no key is given to the method, the entire array will be replaced.
$array array$key stringReturns array
function array_set(&$array, $key, $value)
{
if ($key === null) {
return $array = $value;
}
$keys = explode('.', $key);
while (count((array) $keys) > 1) {
$key = array_shift($keys);
// If the key doesn't exist at this depth, we will just create an empty array
// to hold the next value, allowing us to create the arrays to hold final
// values at the correct depth. Then we'll keep digging into the array.
if ( ! isset($array[$key]) || ! is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
$array[array_shift($keys)] = $value;
return $array;
}
function array_where($array, Closure $callback)
Filter the array using the given Closure.
$array array$callback ClosureReturns array
function array_where($array, Closure $callback)
{
$filtered = [];
foreach ($array as $key => $value) {
if (call_user_func($callback, $key, $value)) {
$filtered[$key] = $value;
}
}
return $filtered;
}
function data_get($target, $key, $default = null)
Get an item from an array or object using "dot" notation.
$key string function data_get($target, $key, $default = null)
{
if (is_array($target)) {
return array_get($target, $key, $default);
} elseif (is_object($target)) {
return object_get($target, $key, $default);
}
}
function head($array)
Get the first element of an array. Useful for method chaining.
$array array function head($array)
{
return reset($array);
}
function last($array)
Get the last element from an array.
$array array function last($array)
{
return end($array);
}
function object_get($object, $key, $default = null)
Get an item from an object using "dot" notation.
$object object$key string function object_get($object, $key, $default = null)
{
if ($key === null || trim($key) == '') {
return $object;
}
foreach (explode('.', $key) as $segment) {
if ( ! is_object($object) || ! isset($object->{$segment})) {
return value($default);
}
$object = $object->{$segment};
}
return $object;
}
function value($value)
Return the default value of the given value.
function value($value)
{
return $value instanceof Closure ? $value() : $value;
}
function with($object)
Return the given object. Useful for chaining.
function with($object)
{
return $object;
}
yf_basic_auth.php 0 functions Not loaded by the framework on every request (a bootstrap script or a file loaded on demand with require_once); see its source.
yf_common_funcs.php 62 functions function _account_info($account_id)
function _account_info($account_id)
{
return _class('utils')->_account_info($account_id);
}
function _add_login_activity()
function _add_login_activity()
{
return _class('utils')->_add_login_activity();
}
function _attr_class_clean($class = '')
function _attr_class_clean($class = '')
{
if ( ! strlen($class) || strpos($class, ' ') === false) {
return $class;
}
$tmp = [];
foreach (explode(' ', trim($class)) as $v) {
$v = trim($v);
if (strlen($v)) {
$tmp[$v] = $v;
}
}
return implode(' ', $tmp);
}
function _attrs($extra, $names)
function _attrs($extra, $names)
{
$body = [];
$a = [];
foreach ((array) $names as $name) {
if (strlen($name) && isset($extra[$name])) {
$a[$name] = $extra[$name];
}
}
// Try to find and allow all data-* and ng-* attributes automatically
foreach ((array) $extra as $name => $val) {
if (strpos($name, 'data-') === 0 || strpos($name, 'ng-') === 0) {
$a[$name] = $val;
}
}
// Custom html attributes forced with sub-array "attr"
if (isset($extra['attr']) && is_array($extra['attr'])) {
foreach ($extra['attr'] as $name => $val) {
if (strlen($name)) {
$a[$name] = $val;
}
}
}
// Make sure that class attribute contains unique names and also cleanup extra spaces
if (isset($a['class']) && strpos($a['class'], ' ') !== false) {
$a['class'] = _attr_class_clean($a['class']);
}
foreach ($a as $name => $val) {
if (is_array($val)) {
$body[$name] = _htmlchars($name) . '="' . http_build_query(_htmlchars($val)) . '"';
} else {
if ( ! strlen($val)) {
continue;
}
if ($name == 'id') {
$val = fix_html_attr_id($val);
}
$body[$name] = _htmlchars($name) . '="' . _htmlchars($val) . '"';
}
}
return $body ? ' ' . implode(' ', $body) : '';
}
function _attrs_string2array($string = '', $strip_quotes = true)
function _attrs_string2array($string = '', $strip_quotes = true)
{
$output_array = [];
if ( ! is_string($string)) {
return [];
}
foreach (explode(';', str_replace(',', ';', trim($string))) as $tmp_string) {
$tmp_string = trim($tmp_string);
if ($strip_quotes) {
$tmp_string = trim(trim($tmp_string, '"\''));
}
[$try_key, $try_value] = explode('=', $tmp_string) + [1 => null];
$try_key && $try_key = trim($try_key);
$try_value && $try_value = trim($try_value);
if ($strip_quotes) {
$try_key && $try_key = trim(trim($try_key, '"\''));
$try_value && $try_value = trim(trim($try_value, '"\''));
}
if (strlen($try_key)) {
$output_array[$try_key] = (string) $try_value;
}
}
return $output_array;
}
function _avatar_exists($user_id = 0, $is_middle = 0)
function _avatar_exists($user_id = 0, $is_middle = 0)
{
return _class('utils')->_avatar_exists($user_id, $is_middle);
}
function _check_words_length($text, $length = 0, $do_encode_email = false)
function _check_words_length($text, $length = 0, $do_encode_email = false)
{
return _class('utils')->_check_words_length($text, $length, $do_encode_email);
}
function _country_name($code = '')
function _country_name($code = '')
{
return _class('utils')->_country_name($code);
}
function _cut_bb_codes($body = '')
function _cut_bb_codes($body = '')
{
return preg_replace('/\[[^\]]+\]/ims', '', $body);
}
function _day_suffix_eng($timestamp = 0)
function _day_suffix_eng($timestamp = 0)
{
return _class('utils')->_day_suffix_eng($timestamp);
}
function _display_name($user_info = [])
function _display_name($user_info = [])
{
if (is_string($user_info)) {
return $user_info;
}
return empty($user_info['display_name']) ? (empty($user_info['name']) ? $user_info['nick'] : $user_info['name']) : $user_info['display_name'];
}
function _email_link($user_id = 0, $skip_get_array = [], $do_add_get = true)
function _email_link($user_id = 0, $skip_get_array = [], $do_add_get = true)
{
return _class('utils')->_email_link($user_id, $skip_get_array, $do_add_get);
}
function _error_need_login($go_after_login = '')
function _error_need_login($go_after_login = '')
{
return _class('utils')->_error_need_login($go_after_login);
}
function _escape_tpl_braces($str = '')
function _escape_tpl_braces($str = '')
{
if (is_array($str)) {
foreach ($str as $k => $v) {
$str[$k] = _escape_tpl_braces($v);
}
return $str;
}
if ( ! is_string($str)) {
return $str;
}
return str_replace(['{', '}'], ['{', '}'], $str);
}
function _exec_in_background($cmd)
function _exec_in_background($cmd)
{
return _class('utils')->_exec_in_background($cmd);
}
function _filter_text($body, $length = 0)
function _filter_text($body, $length = 0)
{
return _check_words_length(preg_replace("/([^\s]+)\r\n/i", "\$1 \r\n", $body), $length);
}
function _floatval($val = 0)
function _floatval($val = 0)
{
return tofloat($val);
}
function _format_date($input_date = '', $type = 'short')
function _format_date($input_date = '', $type = 'short')
{
return _class('utils')->_format_date($input_date, $type);
}
function _gen_dir_path($id, $path = '', $make = false, $dir_mode = 493, $create_index_htmls = 1)
function _gen_dir_path($id, $path = '', $make = false, $dir_mode = 0755, $create_index_htmls = 1)
{
return _class('dir')->_gen_dir_path($id, $path, $make, $dir_mode, $create_index_htmls);
}
function _get_age_from_birth($birth_date = '0000-00-00')
function _get_age_from_birth($birth_date = '0000-00-00')
{
return _class('utils')->_get_age_from_birth($birth_date);
}
function _htmlchars($str = '')
function _htmlchars($str = '')
{
if (is_array($str)) {
foreach ((array) $str as $k => $v) {
$str[$k] = _htmlchars($v);
}
return $str;
}
$replace = [
'"' => '"',
"'" => ''',
'<' => '<',
'>' => '>',
];
return str_replace(array_keys($replace), array_values($replace), (string) $str);
}
function _mkdir_m($path_to_create = '', $dir_mode = 493, $create_index_htmls = 0, $start_folder = '')
function _mkdir_m($path_to_create = '', $dir_mode = 0755, $create_index_htmls = 0, $start_folder = '')
{
return file_exists($path_to_create) || _class('dir')->mkdir_m($path_to_create, $dir_mode, $create_index_htmls, $start_folder);
}
function _mklink($target, $link)
function _mklink($target, $link)
{
return _class('dir')->mklink($target, $link);
}
function _my_strip_tags($_text = '')
function _output_cache_trigger($data = [])
function _output_cache_trigger($data = [])
{
return main()->OUTPUT_CACHING ? _class('output_cache')->_exec_trigger($data) : false;
}
function _prepare_for_stpl_exec($source = '')
function _prepare_for_stpl_exec($source = '')
{
return preg_replace('/[^a-z0-9\-_\s]/ims', '', $source);
}
function _prepare_members_link($url = '')
function _prepare_members_link($url = '')
{
return _class('utils')->_prepare_members_link($url);
}
function _prepare_phone($phone = '')
function _prepare_phone($phone = '')
{
return preg_replace('/[^0-9]/ims', '', $phone);
}
function _profile_link($user_info = 0, $skip_get_array = [], $do_add_get = true)
function _profile_link($user_info = 0, $skip_get_array = [], $do_add_get = true)
{
return _class('utils')->_profile_link($user_info, $skip_get_array, $do_add_get);
}
function _range($_start = 0, $_end = 10)
function _range($_start = 0, $_end = 10)
{
$data = [];
for ($i = $_start; $i <= $_end; $i++) {
$data[$i] = $i;
}
return $data;
}
function _region_name($region_code = '', $country_code = '')
function _region_name($region_code = '', $country_code = '')
{
return _class('utils')->_region_name($region_code, $country_code);
}
function _rename($src_filename, $dest_filename)
function _rename($src_filename, $dest_filename)
{
return _class('utils')->_rename($src_filename, $dest_filename);
}
function _server_info($server_id)
function _server_info($server_id)
{
return _class('utils')->_server_info($server_id);
}
function _show_avatar($user_id = 0, $user_name = '', $as_link = 0, $is_middle = 0, $only_img_src = 0, $force_link = '')
function _show_avatar($user_id = 0, $user_name = '', $as_link = 0, $is_middle = 0, $only_img_src = 0, $force_link = '')
{
return _class('utils')->_show_avatar($user_id, $user_name, $as_link, $is_middle, $only_img_src, $force_link);
}
function _var_dump($data)
function _var_dump($data)
{
ob_start();
var_dump($data);
return ob_get_clean();
}
function _var_export($data)
function _var_export($data)
{
$str = var_export($data, 1);
$str = str_replace(' ', "\t", $str);
$str = preg_replace('~=>[\s]+array\s\(~ims', '=> [', $str);
$str = str_replace('array (', '[', $str);
$str = str_replace(')', ']', $str);
$str = preg_replace('~=>[\s]+array\(~ims', '=> [', $str);
return $str;
}
function array_to_object($d)
function array_to_object($d)
{
if (is_array($d)) {
return (object) array_map(__FUNCTION__, $d);
}
// Return object
return $d;
}
function back($where_go_back = '', $what_to_say = 'back')
function back($where_go_back = '', $what_to_say = 'back')
{
return _class('utils')->back($where_go_back, $what_to_say);
}
function base58_decode($in)
function base58_decode($in)
{
return services()->base58_decode($in);
}
function base58_encode($in)
function base58_encode($in)
{
return services()->base58_encode($in);
}
function base64_decode_safe($in)
function base64_decode_safe($in)
{
return base64_decode(strtr($in, '-_', '+/'));
}
function base64_encode_safe($in)
function base64_encode_safe($in)
{
return rtrim(strtr(base64_encode($in), '+/', '-_'), '=');
}
function cache_memcached_connect($params = [])
function cache_memcached_connect($params = [])
{
global $memcache_obj, $CONF;
if (isset($memcache_obj)) {
return $memcache_obj;
}
if ( ! $params) {
$conf_host = $CONF['MEMCACHED_HOST'];
$conf_port = $CONF['MEMCACHED_PORT'];
$params = [
'host' => $conf_host ?: '127.0.0.1',
'port' => $conf_port ?: 11211,
];
}
$memcache_obj = null;
if (class_exists('Memcached')) {
$memcache_obj = new Memcached();
$memcache_obj->addServer($params['host'], $params['port']);
}
return $memcache_obj;
}
function class_basename($class, $prefix = '', $suffix = '')
function class_basename($class, $prefix = '', $suffix = '')
{
$class = is_object($class) ? get_class($class) : $class;
$class = basename(str_replace('\\', '/', $class));
$prefixes = [
'yf' => YF_PREFIX,
'site' => 'site__',
'admin' => 'adm__',
];
if ($prefix) {
$prefixes['custom'] = $prefix;
}
foreach ($prefixes as $_prefix) {
$plen = strlen($_prefix);
if ($plen && substr($class, 0, $plen) === $_prefix) {
$class = substr($class, $plen);
}
}
$slen = strlen($suffix);
if ($slen && substr($class, -$slen) === $suffix) {
$class = substr($class, 0, -$slen);
}
return $class;
}
function error_back($where_go_back = '', $what_to_say = 'error')
function error_back($where_go_back = '', $what_to_say = 'error')
{
return _class('utils')->error_back($where_go_back, $what_to_say);
}
function fix_html_attr_id($val)
function fix_html_attr_id($val)
{
$val = trim($val);
// fix for space-like chars
$val = str_replace([' ', "\t", "\n", "\r"], '-', $val);
// fix for cyryllic symbols
if (strlen($val) && preg_match('~[а-яА-Я]+~ims', $val)) {
$val = common()->make_translit($val);
}
$val = substr(strtolower($val), 0, 128);
// fix for not allowed chars
$val = preg_replace('~[^a-z0-9\_-]+~', '', $val);
// duplicated chars
$val = trim($val, '-_');
$val = preg_replace('~([-_])+~', '\1', $val);
return $val;
}
function format_bbcode_text($body = '')
function format_bbcode_text($body = '')
{
return $body ? _class('bb_codes')->_process_text($body) : '';
}
function generate_password($Length)
function generate_password($Length)
{
return substr(base64_encode(md5(microtime(true))), 0, $Length);
}
function highlight($string, $search_words, $tag = 'span', $class = 's_word')
function highlight($string, $search_words, $tag = 'span', $class = 's_word')
{
return _class('utils')->highlight($string, $search_words, $tag, $class);
}
function js_alert($text)
function js_alert($text)
{
return _class('utils')->js_alert($text);
}
function load_db_class()
function load_db_class()
{
static $_loaded_class;
if ($_loaded_class) {
return $_loaded_class;
}
$suffix = 'db.class.php';
$patterns = [
'db' => [
APP_PATH . 'classes/' . $suffix,
APP_PATH . 'plugins/*/classes/' . $suffix,
],
'yf_db' => [
YF_PATH . 'classes/yf_' . $suffix,
YF_PATH . 'plugins/*/classes/yf_' . $suffix,
],
];
foreach ($patterns as $cls => $paths) {
foreach ($paths as $path) {
foreach (glob($path) as $file) {
require_once $file;
if (class_exists($cls)) {
$_loaded_class = $cls;
return $_loaded_class;
}
}
}
}
return false;
}
function my_explode($string = '', $divider = PHP_EOL)
function my_explode($string = '', $divider = PHP_EOL)
{
$result = explode($divider, trim($string));
foreach ((array) $result as $k => $v) {
$v = trim($v);
if ( ! strlen($v)) {
unset($result[$k]);
} else {
$result[$k] = $v;
}
}
return array_values($result);
}
function obj2arr(&$obj)
function obj2arr(&$obj)
{
$obj = (array) $obj;
foreach ($obj as &$v) {
if (is_array($v)) {
obj2arr($v);
}
}
return $obj;
}
function object_to_array($d)
function object_to_array($d)
{
if (is_object($d)) {
$d = get_object_vars($d);
}
if (is_array($d)) {
return array_map(__FUNCTION__, $d);
}
// Return array
return $d;
}
function show_text($text = '')
function show_text($text = '')
{
return _class('utils')->show_text($text);
}
function smart_htmlspecialchars($html_text = '')
function smart_htmlspecialchars($html_text = '')
{
return _class('utils')->smart_htmlspecialchars($html_text);
}
function text_filter($str)
function text_filter($str)
{
return _class('utils')->text_filter($str);
}
function todecimal($num = 0, $digits = 2)
function todecimal($num = 0, $digits = 2)
{
if (is_array($num)) {
return array_map(__FUNCTION__, $num);
}
return str_replace(',', '.', round(tofloat($num), $digits));
}
function tofloat($num = 0)
function tofloat($num = 0)
{
if (is_array($num)) {
return array_map(__FUNCTION__, $num);
}
$dotPos = strrpos($num, '.');
$commaPos = strrpos($num, ',');
$sep = (($dotPos > $commaPos) && $dotPos) ? $dotPos :
((($commaPos > $dotPos) && $commaPos) ? $commaPos : false);
if ( ! $sep) {
return (float) (preg_replace('/[^0-9\-]/', '', $num));
}
return (float) (
preg_replace('/[^0-9\-]/', '', substr($num, 0, $sep)) . '.' .
preg_replace('/[^0-9]/', '', substr($num, $sep + 1, strlen($num)))
);
}
function wildcard_compare($wild, $string)
function wildcard_compare($wild, $string)
{
if (is_array($wild)) {
$func = __FUNCTION__;
foreach ($wild as $_wild) {
if ($func($_wild, $string)) {
return true;
}
}
return false;
}
return fnmatch($wild, $string);
}
function xsb_decode($string)
function xsb_decode($string)
{
return _class('utils')->xsb_decode($string);
}
function xsb_encode($string)
function xsb_encode($string)
{
return _class('utils')->xsb_encode($string);
}
yf_compat_funcs.php 0 functions Not loaded by the framework on every request (a bootstrap script or a file loaded on demand with require_once); see its source.
yf_conf.php 4 functions function conf($name = null, $new_value = null, $_arr_name = '')
function conf($name = null, $new_value = null, $_arr_name = '')
{
$_arr_sub = null;
if ( ! $_arr_name) {
$_arr_name = 'CONF';
} else {
// Example: array('PROJECT_CONF' => 'users')
if (is_array($_arr_name)) {
$_arr_sub = current($_arr_name);
$_arr_name = key($_arr_name);
}
}
// This code needed to unify conf(), debug() and module_conf() functions
if ($_arr_sub) {
$ARR = &$GLOBALS[$_arr_name][$_arr_sub];
} else {
$ARR = &$GLOBALS[$_arr_name];
}
$value = null;
// If no first params passed - we return whole structure
if ( ! isset($name)) {
return $ARR;
}
// SET $name as array to merge as key-val
if (is_array($name)) {
$v = &$ARR;
foreach ((array) $name as $_key => $_new_val) {
if ( ! isset($_new_val)) {
continue;
}
$add_auto_index = false;
if (substr($_key, -2) == '[]') {
$_key = substr($_key, 0, -2);
$add_auto_index = true;
}
$a = false;
if (false !== strpos($_key, '::')) {
$a = explode('::', $_key);
}
if (is_array($a) && ! empty($a)) {
$_key = $a[0];
$c = count((array) $a);
$last_key = $a[$c - 1];
$base = null;
if ($c == 2) {
$base = &$v[$_key];
} elseif ($c == 3) {
$base = &$v[$_key][$a[1]];
} elseif ($c == 4) {
$base = &$v[$_key][$a[1]][$a[2]];
} elseif ($c == 5) {
$base = &$v[$_key][$a[1]][$a[2]][$a[3]];
}
if ($add_auto_index) {
$base[] = $_new_val;
} else {
$base[$last_key] = $_new_val;
}
unset($base);
} else {
if ($add_auto_index) {
$v[$_key][] = $_new_val;
} else {
$v[$_key] = $_new_val;
}
}
}
return true;
}
$add_auto_index = false;
if (substr($name, -2) == '[]') {
$name = substr($name, 0, -2);
$add_auto_index = true;
}
$a = false;
if (false !== strpos($name, '::')) {
$a = explode('::', $name);
}
if (is_array($a) && ! empty($a)) {
$name = $a[0];
$v = &$ARR[$name];
$c = count((array) $a);
$last_key = $a[$c - 1];
$base = null;
if ($c == 2) {
$base = &$v;
} elseif ($c == 3) {
$base = &$v[$a[1]];
} elseif ($c == 4) {
$base = &$v[$a[1]][$a[2]];
} elseif ($c == 5) {
$base = &$v[$a[1]][$a[2]][$a[3]];
}
if (isset($base[$last_key])) {
$value = $base[$last_key];
}
if (isset($new_value)) {
! is_array($base) && $base = [];
if ($add_auto_index) {
$base[] = $new_value;
} else {
$base[$last_key] = $new_value;
}
}
} else {
$v = &$ARR[$name];
if (isset($v)) {
$value = $v;
}
if (isset($new_value)) {
if ($add_auto_index) {
! is_array($v) && $v = [];
$v[] = $new_value;
} else {
$v = $new_value;
}
}
}
if (isset($new_value)) {
$value = $new_value;
}
return $value;
}
function conf_add($name = null, $new_value = null, $separator = ';', $arr_name = '')
Helper for concatenating string values.
function conf_add($name = null, $new_value = null, $separator = ';', $arr_name = '')
{
$actual_value = null;
if ($new_value !== null) {
$actual_value = conf($name);
}
return conf($name, ($actual_value ? $actual_value . $separator : '') . $new_value, $arr_name);
}
function debug($name = null, $new_value = null, $max_items = 500)
function debug($name = null, $new_value = null, $max_items = 500)
{
$arr_name = 'DEBUG';
if ($max_items && $new_value !== null && substr($name, -2) == '[]') {
$v = conf(substr($name, 0, -2), null, $arr_name);
if (is_array($v) && count((array) $v) >= $max_items) {
return false;
}
}
return conf($name, $new_value, $arr_name);
}
function module_conf($module = '', $name = '', $new_value = null)
function module_conf($module = '', $name = '', $new_value = null)
{
global $PROJECT_CONF;
// TODO: add/merge real value of module($module)->$property (maybe be slow due to module init);
$value = null;
if ( ! $module && ! $name) {
return $PROJECT_CONF;
}
if ($module && ! $name) {
return $PROJECT_CONF[$module];
}
return conf($name, $new_value, ['PROJECT_CONF' => $module]);
}
yf_debug.php 0 functions Not loaded by the framework on every request (a bootstrap script or a file loaded on demand with require_once); see its source.
yf_is_funcs.php 24 functions function is_403()
function is_403()
{
return main()->is_403();
}
function is_404()
function is_404()
{
return main()->is_404();
}
function is_503()
function is_503()
{
return main()->is_503();
}
function is_ajax()
function is_ajax()
{
return main()->is_ajax();
}
function is_banned()
function is_banned()
{
return main()->is_banned();
}
function is_blocks_task_403()
function is_blocks_task_403()
{
return main()->is_blocks_task_403();
}
function is_blocks_task_404()
function is_blocks_task_404()
{
return main()->is_blocks_task_404();
}
function is_cache_on()
function is_cache_on()
{
return main()->is_cache_on();
}
function is_common_page()
function is_common_page()
{
return main()->is_common_page();
}
function is_console()
function is_console()
{
return main()->is_console();
}
function is_db()
function is_db()
{
return main()->is_db();
}
function is_debug()
function is_debug()
{
return main()->is_debug();
}
function is_dev()
function is_dev()
{
return main()->is_dev();
}
function is_https()
function is_https()
{
return main()->is_https();
}
function is_logged_in()
function is_logged_in()
{
return main()->is_logged_in();
}
function is_mobile()
function is_mobile()
{
return main()->is_mobile();
}
function is_no_graphics()
function is_no_graphics()
{
return main()->no_graphics();
}
function is_output_cache_on()
function is_output_cache_on()
{
return main()->is_output_cache_on();
}
function is_post()
function is_post()
{
return main()->is_post();
}
function is_redirect()
function is_redirect()
{
return main()->is_redirect();
}
function is_site_path()
function is_site_path()
{
return main()->is_site_path();
}
function is_spider()
function is_spider()
{
return main()->is_spider();
}
function is_unit_test()
function is_unit_test()
{
return main()->is_unit_test();
}
function no_graphics($val = null)
function no_graphics($val = null)
{
return main()->no_graphics($val);
}
yf_placeholder_img.php 0 functions Not loaded by the framework on every request (a bootstrap script or a file loaded on demand with require_once); see its source.
yf_strip_tags_smart.php 0 functions Not loaded by the framework on every request (a bootstrap script or a file loaded on demand with require_once); see its source.