Beispiel #1
0
<?php

/**
 *  OpenLSS - Lighter Smarter Simpler
 *
 *	This file is part of OpenLSS.
 *
 *	OpenLSS is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU Lesser General Public License as
 *	published by the Free Software Foundation, either version 3 of
 *	the License, or (at your option) any later version.
 *
 *	OpenLSS is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU Lesser General Public License for more details.
 *
 *	You should have received a copy of the 
 *	GNU Lesser General Public License along with OpenLSS.
 *	If not, see <http://www.gnu.org/licenses/>.
 */
//from openlss/core-boot
__init_load_files(ROOT_GROUP . '/url');
Beispiel #2
0
function __init_load_files($dir_path, $callback = false, $callback_params = array(), $recurse = true)
{
    $dir = false;
    $files = array();
    //try to open dir
    if (!is_dir($dir_path)) {
        return false;
    }
    $dir = opendir($dir_path);
    if (!$dir) {
        return false;
    }
    //read dir into array
    while ($dir && ($file = readdir($dir)) !== false) {
        if (substr($file, 0, 1) == '.') {
            continue;
        }
        //skip hidden files (including . and ..)
        if (!is_dir($dir_path . '/' . $file) && substr($file, -4) != '.php') {
            continue;
        }
        //only *.php
        $files[] = $file;
    }
    closedir($dir);
    //sort files if needed
    sort($files);
    //load files
    foreach ($files as $file) {
        if (is_dir($dir_path . '/' . $file)) {
            if (!$recurse) {
                continue;
            }
            //skip subdirectories
            __init_load_files($dir_path . '/' . $file, $callback, $callback_params, $recurse);
            continue;
        }
        if (defined('INIT_LOAD_DEBUG')) {
            echo 'loaded file: ' . $dir_path . '/' . $file . "\n";
        }
        if ($callback && function_exists($callback)) {
            $params = $callback_params;
            array_unshift($params, $dir_path . '/' . $file);
            call_user_func_array($callback, $params);
        } else {
            include_once $dir_path . '/' . $file;
        }
    }
    return true;
}