コード例 #1
0
ファイル: functions.php プロジェクト: JJaicmkmy/Chevereto
/**
 * check_files_folders
 * This checks for filer or folders existence
 * If the folder doesn't exists the script will attempt to create it.
 */
function check_files_folders($elements, $type)
{
    global $install_errors;
    $type = strtolower($type);
    foreach ($elements as $element) {
        if ($type == 'directory') {
            @mkdir($element);
        }
        if (preg_match('/.+\\.min\\.(js|css)$/i', $element)) {
            if (conditional_config('minify') && !file_exists($element)) {
                require_once __CHV_PATH_CLASSES__ . 'class.minify.php';
                $minify = new Minify();
                try {
                    $minify->addSource(preg_replace('/(.+)\\.min(\\.(js|css))$/i', '$1$2', $element));
                    $minify->exec();
                } catch (MinifyException $e) {
                    if (conditional_config('error_reporting')) {
                        debug($e->getMessage());
                    }
                }
            }
        }
        if (!file_exists($element)) {
            $install_errors[] = '<code>' . absolute_to_relative($element) . '</code>';
        }
    }
    if (count($install_errors) == 0) {
        return true;
    }
}