Beispiel #1
0
 function bootPackage($package)
 {
     $booters = rglob('*.php', 0, base_path('vendor/' . $package . '/src/boot'));
     foreach ($booters as $booter) {
         include_once $booter;
     }
 }
Beispiel #2
0
/**
 *
 *
 * Recursive glob()
 *
 * @access public
 * @package Utils
 * @category Files
 *
 * @uses is_array()
 * @param int|string $pattern
 * the pattern passed to glob()
 * @param int $flags
 * the flags passed to glob()
 * @param string $path
 * the path to scan
 * @return mixed
 * an array of files in the given path matching the pattern.
 */
function rglob($pattern = '*', $flags = 0, $path = '')
{
    if (!$path && ($dir = dirname($pattern)) != '.') {
        if ($dir == '\\' || $dir == '/') {
            $dir = '';
        }
        return rglob(basename($pattern), $flags, $dir . DS);
    }
    $path = normalize_path($path, 1);
    $paths = glob($path . '*', GLOB_ONLYDIR | GLOB_NOSORT);
    $files = glob($path . $pattern, $flags);
    if (is_array($paths)) {
        foreach ($paths as $p) {
            $temp = rglob($pattern, false, $p . DS);
            if (is_array($temp) and is_array($files) and !empty($files)) {
                $files = array_merge($files, $temp);
            } else {
                if (is_array($temp) and !empty($temp)) {
                    $files = $temp;
                }
            }
        }
    }
    return $files;
}
Beispiel #3
0
function rglob($pattern, $files = 1, $dirs = 0, $flags = 0)
{
    $dirname = dirname($pattern);
    $basename = basename($pattern);
    $glob = glob($pattern, $flags);
    $files = array();
    $dirlist = array();
    foreach ($glob as $path) {
        if (is_file($path) && !$files) {
            continue;
        }
        if (is_dir($path)) {
            $dirlist[] = $path;
            if (!$dirs) {
                continue;
            }
        }
        $files[] = $path;
    }
    foreach (glob("{$dirname}/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        $dirfiles = rglob($dir . '/' . $basename, $files, $dirs, $flags);
        $files = array_merge($files, $dirfiles);
    }
    return $files;
}
Beispiel #4
0
 static function larakitRegisterMenuSubpages($package, $alias)
 {
     //автоматическая регистрация дочерних страниц Subpages
     $dir = base_path('vendor/' . $package . '/src/config/larakit/subpages/');
     $dir = HelperFile::normalizeFilePath($dir);
     if (file_exists($dir)) {
         $dirs = rglob('*.php', 0, $dir);
         foreach ($dirs as $d) {
             $d = str_replace($dir, '', $d);
             $d = str_replace('.php', '', $d);
             $d = trim($d, '/');
             $menus_subpages = (array) \Config::get($alias . '::larakit/subpages/' . $d);
             if (count($menus_subpages)) {
                 foreach ($menus_subpages as $page => $items) {
                     $manager = \Larakit\Widget\WidgetSubpages::factory($page);
                     foreach ($items as $as => $props) {
                         $style = Arr::get($props, 'style', 'bg-aqua');
                         $is_curtain = Arr::get($props, 'is_curtain', false);
                         $manager->add($as, $style, $is_curtain);
                     }
                 }
             }
         }
     }
 }
Beispiel #5
0
function rglob($pattern, $flags = 0)
{
    $files = preg_grep('/vendor/', glob($pattern, $flags), PREG_GREP_INVERT);
    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        $files = array_merge($files, rglob($dir . '/' . basename($pattern), $flags));
    }
    return $files;
}
Beispiel #6
0
function rglob($pattern, $flags = 0)
{
    $files = glob($pattern, $flags);
    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        $files = array_merge($files, rglob($dir . '/' . basename($pattern), $flags));
    }
    return $files;
}
Beispiel #7
0
/**
 * 递归返回指定目录,指定样式文件
 * 
 * @param string $pattern 文件模板
 * @param int $flags 修改标志
 * @param string $path 路径
 * @return array 文件名路径数组
 */
function rglob($pattern = '*', $flags = 0, $path = '')
{
    $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
    $files = glob($path . $pattern, $flags);
    foreach ($paths as $path) {
        $files = array_merge($files, rglob($pattern, $flags, $path));
    }
    return $files;
}
Beispiel #8
0
 function rglob($pattern, $flags = 0, $path = '') {
     if (!$path && ($dir = dirname($pattern)) != '.') {
         if ($dir == '\\' || $dir == '/') $dir = '';
         return rglob(basename($pattern), $flags, $dir . '/');
     }
     $paths = glob($path . '*', GLOB_ONLYDIR | GLOB_NOSORT);
     $files = glob($path . $pattern, $flags);
     foreach ($paths as $p) $files = array_merge($files, rglob($pattern, $flags, $p . '/'));
     return $files;
 }
Beispiel #9
0
 static function init_package($package, $dir = 'init')
 {
     $path = dirname(dirname(dirname(__DIR__))) . '/' . $package . '/src/' . $dir;
     if (file_exists($path)) {
         $inits = rglob('*.php', 0, $path);
         foreach ($inits as $init) {
             include_once $init;
         }
     }
 }
Beispiel #10
0
 public function test()
 {
     $ret = rglob(ROOT_PATH . '/*.php');
     assert(1 < count($ret));
     assertEquals('autoload.php', basename($ret[0]));
     $ret = rglob(ROOT_PATH . '/*.php', 0, RGLOB_UP);
     assert(1 < count($ret));
     assertNotEquals('autoload.php', basename($ret[0]));
     assertEquals('autoload.php', basename($ret[count($ret) - 1]));
 }
Beispiel #11
0
function rglob($dir, $pattern = '*', $flags = 0)
{
    $paths = glob($dir . DIRECTORY_SEPARATOR . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
    $files = glob($dir . DIRECTORY_SEPARATOR . $pattern, $flags);
    foreach ($paths as $path) {
        if ($path != '.' && $path != '..') {
            $files = array_merge($files, rglob($path, $pattern, $flags));
        }
    }
    return $files;
}
Beispiel #12
0
function rglob($pattern, $flags = 0)
{
    // Funcion para hacer un glob() recursivo. Tomado de:
    // http://stackoverflow.com/a/17161106
    $files = glob($pattern, $flags);
    //foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
    foreach (glob(dirname($pattern) . '/*') as $dir) {
        $files = array_merge($files, rglob($dir . '/' . basename($pattern), $flags));
    }
    return $files;
}
Beispiel #13
0
 function AllTests()
 {
     $this->TestSuite('Tutti i tests');
     // Considera solamente queste cartelle quando si cerca per i files di test
     $paths = array("core", "restful");
     foreach ($paths as $path) {
         foreach (rglob(ROOT_PATH . "{$path}/*/*Test.php") as $filename) {
             $this->addFile($filename);
         }
     }
 }
Beispiel #14
0
function rglob($pattern, $flags = 0)
{
    $files = glob($pattern, $flags);
    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        // avoid auto-removing the database
        if (strpos($dir, "malicious_code") === false) {
            $files = array_merge($files, rglob($dir . '/' . basename($pattern), $flags));
        }
    }
    return $files;
}
Beispiel #15
0
 function rglob($pattern = '*', $flags = 0, $path = false)
 {
     if (!$path) {
         $path = dirname($pattern) . DIRECTORY_SEPARATOR;
     }
     $pattern = basename($pattern);
     $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
     $files = glob($path . $pattern, $flags);
     foreach ($paths as $path) {
         $files = array_merge($files, rglob($pattern, $flags, $path));
     }
     return $files;
 }
Beispiel #16
0
 function rglob($pattern = '*', $flags = 0, $path = false)
 {
     if (!$path) {
         $path = dirname($pattern) . DIRECTORY_SEPARATOR;
     }
     $pattern = basename($pattern);
     $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
     $files = glob($path . $pattern, $flags);
     foreach ($paths as $path) {
         $files = array_merge($files, rglob($pattern, $flags, $path));
     }
     $files = array_map(['Larakit\\Helper\\HelperFile', 'normalizeFilePath'], $files);
     return $files;
 }
/**
 * Searches include_path for a matching source file, and calls require_once()
 * NOTE: Source file must be defined in a file with a name matching $className
 */
function loadClass($className)
{
    $include_path = get_include_path();
    $paths = explode(PATH_SEPARATOR, $include_path);
    $pattern = $className . ".*";
    foreach ($paths as $path) {
        $path .= "/";
        $files = rglob($pattern, 0, $path);
        if (count($files) == 1) {
            // trim path (for inclusion relative to include_path)
            $file = $files[0];
            $file = substr($file, strlen($path));
            require_once $file;
        }
    }
}
Beispiel #18
0
function rglob($pattern, $flags = 0, $path = '')
{
    if (empty($path) && ($dir = dirname($pattern)) != '.') {
        if ($dir == '\\' || $dir == '/') {
            $dir = '';
        }
        return rglob(basename($pattern), $flags, $dir . '/');
    }
    $paths = glob($path . '*', GLOB_ONLYDIR | GLOB_NOSORT);
    $files = glob($path . $pattern, $flags);
    if (is_array($paths) && is_array($files)) {
        foreach ($paths as $p) {
            $files = array_merge($files, rglob($pattern, $flags, $p . '/'));
        }
    }
    return $files;
}
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     foreach (Boot::$configs as $path_config => $is_deploy) {
         $path_config = str_replace('\\', '/', $path_config);
         $files = rglob('*.php', 0, $path_config);
         foreach ($files as $path) {
             $path = str_replace('\\', '/', $path);
             //                dump($path);
             $file = str_replace([$path_config], [''], $path);
             $key = str_replace(['.php', '/'], ['', '.'], $file);
             $config = app('config')->get($key, []);
             //                dd($path, require $path);
             //                dump(require $path, $config, array_merge(require $path, $config));
             app('config')->set($key, array_merge(require $path, $config));
             if ($is_deploy) {
                 $this->publishes([$path => config_path($file)], 'config');
             }
         }
     }
 }
Beispiel #20
0
 public function create_full()
 {
     if (!defined('INI_SYSTEM_CHECK_DISABLED')) {
         define('INI_SYSTEM_CHECK_DISABLED', ini_get('disable_functions'));
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'ini_set')) {
         ini_set('memory_limit', '512M');
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
         set_time_limit(600);
     }
     $backup_actions = array();
     $backup_actions[] = 'make_db_backup';
     $userfiles_folder = userfiles_path();
     $media_folder = media_base_path();
     $all_images = $this->app->media_manager->get_all('limit=10000');
     if (!empty($all_images)) {
         foreach ($all_images as $image) {
             if (isset($image['filename']) and $image['filename'] != false) {
                 $fn = url2dir($image['filename']);
                 if (is_file($fn)) {
                     $backup_actions[] = $fn;
                 }
             }
         }
     }
     $host = parse_url(site_url());
     $host_dir = false;
     if (isset($host['host'])) {
         $host_dir = $host['host'];
         $host_dir = str_ireplace('www.', '', $host_dir);
         $host_dir = str_ireplace('.', '-', $host_dir);
     }
     $userfiles_folder_uploaded = $media_folder . DS . $host_dir . DS . 'uploaded' . DS;
     $userfiles_folder_uploaded = $media_folder . DS . $host_dir . DS;
     $userfiles_folder_uploaded = \normalize_path($userfiles_folder_uploaded);
     $folders = \rglob($userfiles_folder_uploaded . '*', GLOB_NOSORT);
     if (!is_array($folders)) {
         $folders = array();
     }
     $cust_css_dir = $userfiles_folder . 'css' . DS;
     if (is_dir($cust_css_dir)) {
         $more_folders = \rglob($cust_css_dir . '*', GLOB_NOSORT);
         if (!empty($more_folders)) {
             $folders = array_merge($folders, $more_folders);
         }
     }
     if (!empty($folders)) {
         $text_files = array();
         foreach ($folders as $fold) {
             if (!stristr($fold, 'backup')) {
                 if (stristr($fold, '.php') or stristr($fold, '.js') or stristr($fold, '.css')) {
                     $text_files[] = $fold;
                 } else {
                     $backup_actions[] = $fold;
                 }
             }
         }
         if (!empty($text_files)) {
             $backup_actions = array_merge($text_files, $backup_actions);
         }
     }
     $cache_id = 'backup_queue';
     $cache_id_loc = 'backup_progress';
     $cache_state_id = 'backup_zip_state';
     $this->app->cache_manager->save($backup_actions, $cache_id, 'backup');
     $this->app->cache_manager->save(false, $cache_id_loc, 'backup');
     $this->app->cache_manager->save(false, $cache_state_id, 'backup');
     if (!defined('MW_NO_SESSION')) {
         define('MW_NO_SESSION', 1);
     }
     return;
 }
file_put_contents('distribution/navigate.sql', $sql);
/*	5/ Pack folders and files in "package.zip"
		include: (root)
				 cache (ignore the contents)
				 cfg (without the valid globals.php),
				 css
				 docs
				 img
				 js
				 lib
				 plugins (at least "votes plugin" and "webuser_account_lite")
				 private [deprecated] (ocean files [161..172])
				 web
*/
$zipfile = new zipfile();
$navigate_files = rglob("*", GLOB_MARK, NAVIGATE_PATH . '/');
$total = count($navigate_files);
$index = 0;
foreach ($navigate_files as $file) {
    //$index++;
    //echo 'Adding '.$index.'/'.$total.' ('.round(($index/$total*100),2).'%)<br />';
    //flush();
    if (!file_exists($file)) {
        continue;
    }
    $file = substr($file, strlen(NAVIGATE_PATH . '/'));
    // file must be excluded from package?
    if ($file == 'cfg/globals.php') {
        continue;
    }
    if (substr($file, 0, strlen('setup/')) == 'setup/') {
Beispiel #22
0
/**
 * Recursive glob file pattern search utility function
 * @see https://secure.php.net/manual/de/function.glob.php
 * @return array Matched files and directories
 */
function rglob($glob, $flags = 0)
{
    $glob = preg_replace('/[\\\\\\/]/', DS, $glob);
    $result = glob($glob, $flags);
    foreach ($result as $item) {
        if (is_dir($item)) {
            $subresult = rglob($item . DS . '*', $flags);
            $result = array_merge($result, $subresult);
        }
    }
    return $result;
}
Beispiel #23
0
<?php

include dirname(__FILE__) . '/inc/common.php';
$phpSelf = $_SERVER['PHP_SELF'];
$baseUrl = substr($phpSelf, 0, strrpos($phpSelf, '/'));
$baseUrl = substr($baseUrl, 0, strrpos($baseUrl, '/'));
$host = HOST_URL . $baseUrl;
$filePaths = rglob('*.wiki', BASE_PATH);
echo '<?xml version="1.0" encoding="UTF-8"?>', "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1" xmlns:video="http://www.sitemaps.org/schemas/sitemap-video/1.1">';
foreach ($filePaths as $filePath) {
    echo '<url>';
    echo '<loc>', $host, getFileUrl($filePath), '</loc>';
    echo '</url>';
}
echo '</urlset>';
Beispiel #24
0
 public function get_modules_from_current_site_template()
 {
     if (!defined('ACTIVE_TEMPLATE_DIR')) {
         $this->app->content_manager->define_constants();
     }
     $dir_name = ACTIVE_TEMPLATE_DIR . 'modules' . DS;
     if (is_dir($dir_name)) {
         $configs = array();
         $glob_patern = '*config.php';
         $dir = rglob($glob_patern, 0, $dir_name);
         $replace_root = normalize_path($dir_name);
         $def_icon = modules_path() . 'default.png';
         if (!empty($dir)) {
             foreach ($dir as $module) {
                 $module_dir = dirname($module);
                 $module_dir = normalize_path($module_dir);
                 $config = array();
                 include $module;
                 $module_name = str_replace($replace_root, '', $module_dir);
                 $module_name = rtrim($module_name, '\\');
                 $module_name = rtrim($module_name, '/');
                 $config['module'] = $module_name;
                 $config['module'] = rtrim($config['module'], '\\');
                 $config['module'] = rtrim($config['module'], '/');
                 $try_icon = $module_dir . $module_name . '.png';
                 if (is_file($try_icon)) {
                     $config['icon'] = $this->app->url_manager->link_to_file($try_icon);
                 } else {
                     $config['icon'] = $this->app->url_manager->link_to_file($def_icon);
                 }
                 $configs[] = $config;
             }
         }
         return $configs;
     }
 }
Beispiel #25
0
function clearCache($folder = '', $olderThan = 0)
{
    global $settings;
    if ($settings['apc_enabled']) {
        apc_delete($folder);
        return;
    }
    $timeNow = time();
    if (empty($folder)) {
        $files = rglob('*.php', null, IN_PATH . 'cache');
    } else {
        $files = rglob('*.php', null, IN_PATH . 'cache/' . $folder);
    }
    foreach ($files as $file) {
        if ($olderThan == 0) {
            unlink($file);
        } else {
            if ($timeNow - filemtime($file) > $olderThan) {
                unlink($file);
            }
        }
    }
}
Beispiel #26
0
// }}}
// 数据
$diff = array_diff($old_acls, $new_acls);
//var_export($diff);
// 日志
$log = 'log/search_old_acls.log';
// 查找路径
$paths = array('/home/libo/git/src/web/tpl/admin/tpl1' => '*.html', '/home/libo/git/src/web/tpl/admin/tpl1/js' => '*.js', '/home/libo/src/web/php' => '*.php', '/home/libo/src/lib/' => '*.php', '/home/libo/git/src/shell/utils' => '*');
//$paths = array('/home/libo/test' => '*.txt');
// }}}
if (is_file($log)) {
    unlink($log);
}
$fp = fopen($log, 'a+');
foreach ($paths as $path => $file_pattern) {
    $files = rglob($file_pattern, 0, $path);
    foreach ($files as $file) {
        if (false !== strpos($file, 'lang_zh.js')) {
            continue;
        }
        $file_content = file_get_contents($file);
        $key = array();
        foreach ($diff as $acl_id) {
            if (false !== strpos($file_content, $acl_id)) {
                $key[] = $acl_id;
            }
        }
        $count = count($key);
        if (0 !== $count) {
            fwrite($fp, "Search file: <{$file}>\n");
            fwrite($fp, "    Count: " . $count . " \n");
Beispiel #27
0
 public static function moved_file($tmpdir, $newdir, $pack)
 {
     //return rename( $tmpdir, $newdir );
     $list = rglob($tmpdir . '*', GLOB_BRACE);
     //var_dump( $list );
     //exit;
     //批量迁移文件
     foreach ($list as $file) {
         $newd = str_replace($tmpdir, $newdir, $file);
         //var_dump( $file );
         //var_dump( $newd );
         //echo '<hr />';
         if (file_exists($file) && is_writable($file) == FALSE) {
             //记录在案
             self::$lastfile = str_replace($tmpdir, '', $file);
             return -10007;
         }
         ////////////////////////////
         if (file_exists($newd) && is_writable($newd) == FALSE) {
             //记录在案
             self::$lastfile = str_replace($newdir, '', $newd);
             return -10007;
         }
         ////////////////////////////
         //创建文件夹
         if (is_dir($file)) {
             create_dir($newd, TRUE, 0777);
         } else {
             //删除旧文件(winodws 环境需要)
             if (file_exists($newd)) {
                 unlink($newd);
             }
             //生成新文件
             $test = @rename($file, $newd);
             //记录在案
             self::$lastfile = str_replace($tmpdir, '', $file);
         }
         ////////////////////////////
         //移动文件出错
         if ($test === FALSE) {
             return -10005;
         }
     }
     //删除临时目录
     delete_dir($tmpdir);
     //删除文件包
     unlink(self::get_pack_file($pack));
     return count($list);
 }
Beispiel #28
0
 public function run()
 {
     if (($file = $this->config->file) !== 'stdout') {
         display("Anonymizing file {$file}\n");
         if (!file_exists($file)) {
             die('Can\'t anonymize ' . $file . ' as it doesn\'t exist' . "\n");
         }
         if (!$this->checkCompilation($file)) {
             die('Can\'t anonymize ' . $file . ' as it doesn\'t compile with PHP ' . PHP_VERSION . "\n");
         }
         $this->processFile($file);
     } else {
         $dir = $this->config->dirname;
         if (!empty($dir)) {
             if (substr($dir, -1) === '/') {
                 $dir = substr($dir, 0, -1);
             }
             if (!file_exists($dir)) {
                 die('Can\'t anonymize ' . $dir . ' as it doesn\'t exist' . "\n");
             }
             display("Anonymizing directory {$dir}\n");
             $files = rglob($dir);
             $total = 0;
             if (file_exists($dir . '.anon')) {
                 rmdirRecursive($dir . '.anon');
             }
             mkdir($dir . '.anon', 0755);
             foreach ($files as $file) {
                 if ($this->checkCompilation($file)) {
                     ++$this->strings;
                     $total += (int) $this->processFile($file, $dir . '.anon/' . $this->strings . '.php');
                 }
             }
             display("Anonymized {$total} files\n");
         } elseif (($project = $this->config->project) !== 'default') {
             display("Anonymizing project {$project}\n");
             $dir = $this->config->projects_root . '/projects/' . $project . '/' . $project;
             if (!file_exists($this->config->projects_root . '/projects/' . $project)) {
                 die('Can\'t anonymize project ' . $project . ' as it doesn\'t exist' . "\n");
             }
             if (!file_exists($this->config->projects_root . '/projects/' . $project . '/code')) {
                 die('Can\'t anonymize project ' . $project . ' as it doesn\'t have code' . "\n");
             }
             $files = $this->datastore->getCol('files', 'file');
             $path = $this->config->projects_root . '/projects/' . $this->config->project . '/code';
             $total = 0;
             if (file_exists($dir . '.anon')) {
                 rmdirRecursive($dir . '.anon');
             }
             mkdir($dir . '.anon', 0755);
             foreach ($files as $file) {
                 if ($this->checkCompilation($path . $file)) {
                     ++$this->strings;
                     $total += (int) $this->processFile($path . $file, $dir . '.anon/' . $this->strings . '.php');
                 }
             }
             display("Anonymized {$total} files\n");
         } else {
             die("Usage : php exakat anonymize -file <filename>\n                                 -d <dirname>\n                                 -p <project>\n");
         }
     }
     display('Processing file ' . $file . ' into ' . $file . ".anon\n");
 }
Beispiel #29
0
 /**
  * \Files\Api::get
  *
  *  Get an array that represents directory and files
  *
  * @package        modules
  * @subpackage    files
  * @subpackage    files\api
  * @category    files module api
  * @version 1.0
  * @since 0.320
  * @return mixed Array with files
  *
  * @param array $params = array()     the params
  * @param string $params['directory']       The directory
  * @param string $params['keyword']       If set it will seach the dir and subdirs
  */
 static function get($params)
 {
     if (is_admin() == false) {
         mw_error("Must be admin");
     }
     $params = parse_params($params);
     if (!isset($params['directory'])) {
         mw_error("You must define directory");
     } else {
         $directory = $params['directory'];
     }
     $from_search = 0;
     $arrayItems = array();
     if (isset($params['search']) and strval($params['search']) != '') {
         $from_search = 1;
         $arrayItems_search = rglob($pattern = DS . '*' . $params['search'] . '*', $flags = 0, $directory);
     } else {
         //$paths = glob($directory . DS . '*', GLOB_ONLYDIR | GLOB_NOSORT);
         //$files = glob($directory . DS . '*', 0);
         //$arrayItems_search = array_merge($paths, $files);
         if (!is_dir($directory . DS)) {
             return false;
         }
         $arrayItems_search = array();
         $myDirectory = opendir($directory . DS);
         // get each entry
         while ($entryName = readdir($myDirectory)) {
             if ($entryName != '..' and $entryName != '.') {
                 $arrayItems_search[] = $entryName;
             }
         }
         // close directory
         closedir($myDirectory);
     }
     if (!empty($arrayItems_search)) {
         if (isset($params['sort_by']) and strval($params['sort_by']) != '') {
             if (isset($params['sort_order']) and strval($params['sort_order']) != '') {
                 $ord = SORT_DESC;
                 if (strtolower($params['sort_order']) == 'asc') {
                     $ord = SORT_ASC;
                 }
                 array_multisort(array_map($params['sort_by'], $arrayItems_search), SORT_NUMERIC, $ord, $arrayItems_search);
                 //	d($arrayItems_search);
             }
         }
         //usort($myarray, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
         $arrayItems_f = array();
         $arrayItems_d = array();
         foreach ($arrayItems_search as $file) {
             if ($from_search == 0) {
                 $file = $directory . DS . $file;
             }
             if (is_file($file)) {
                 $df = normalize_path($file, false);
                 if (!in_array($df, $arrayItems_f)) {
                     $arrayItems_f[] = $df;
                 }
             } else {
                 $df = normalize_path($file, 1);
                 if (!in_array($df, $arrayItems_d)) {
                     $arrayItems_d[] = $df;
                 }
             }
         }
         $arrayItems['files'] = $arrayItems_f;
         $arrayItems['dirs'] = $arrayItems_d;
     }
     return $arrayItems;
 }
/*
This will parse the playlist files and produce a user-friendly list of what
each playlist does. It will pull data from the cvarlists to get friendly names
and information about the variables.
*/
$title = "Insurgency Playlist Parser";
$tableclasses = "table table-striped table-bordered table-condensed table-responsive";
require_once "include/header.php";
$dirs = glob("data/playlists/*");
foreach ($dirs as $dir) {
    $versions[] = basename($dir);
}
asort($versions);
$newest_version = $version = end($versions);
if ($_REQUEST['version']) {
    if (in_array($_REQUEST['version'], $versions)) {
        $version = $_REQUEST['version'];
    }
}
$version_compare = $version;
if ($_REQUEST['version_compare']) {
    if (in_array($_REQUEST['version_compare'], $versions)) {
        $version_compare = $_REQUEST['version_compare'];
    }
}
$data = array();
$files = rglob("data/playlists/{$version}/*.playlist");
foreach ($files as $file) {
    $data = array_merge_recursive($data, parseKeyValues(file_get_contents($file)));
}
var_dump($data);