Example #1
0
function account_list()
{
    $glob = glob_files(USER_DIR);
    $result = [];
    foreach ($glob as $file) {
        $email = remove_last(basename($file), '.json');
        $result[] = account_data($email);
    }
    return $result;
}
Example #2
0
function route(&$args, $default_segments)
{
    $segments = [];
    foreach (glob_segments() as $key => $array) {
        if ($key === 'class') {
            $array = array_map(function ($path) {
                return preg_replace('/\\.php$/', '', basename($path));
            }, glob_files('controllers/*.php', $segments));
        }
        if ($key === 'method') {
            if (!class_exists('controller')) {
                require_once first_glob('core/controller.php', $segments);
            }
            if (!class_exists($segments['class'])) {
                require_once first_glob("controllers/{$segments['class']}.php", $segments);
            }
            $array = get_class_methods($segments['class']);
        }
        $segments[$key] = isset($args[0]) && !preg_match('/^_/', $args[0]) && $args[0] != $default_segments[$key] && in_array($args[0], $array) ? array_shift($args) : $default_segments[$key];
    }
    return $segments;
}
Example #3
0
/**
* List all files in a directory, recursively.
*
* @param $path
*	...
*
* @param $filetypes
*	...
*
* @return
*	...
*/
function rglob_files($path = '', $filetypes = array())
{
    // Accept file type restrictions as a single array or multiple independent values
    $arguments = func_get_args();
    array_shift($arguments);
    $filetypes = array_flatten($arguments);
    // Run glob_files for this directory and its subdirectories
    $files = glob_files($path, $filetypes);
    foreach (glob_dir($path) as $child) {
        $files = array_merge($files, rglob_files($child, $filetypes));
    }
    return $files;
}