| 1 | <?php
|
|---|
| 2 | /* --------------------------------------------------------------
|
|---|
| 3 | $Id: auto_include.inc.php 7992 2015-03-24 15:46:34Z h-h-h $
|
|---|
| 4 |
|
|---|
| 5 | modified eCommerce Shopsoftware
|
|---|
| 6 | http://www.modified-shop.org
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 2009 - 2014 [www.modified-shop.org]
|
|---|
| 9 | --------------------------------------------------------------
|
|---|
| 10 | Released under the GNU General Public License
|
|---|
| 11 | --------------------------------------------------------------*/
|
|---|
| 12 |
|
|---|
| 13 | function auto_include($dir, $ext = 'php', $expr = '*', $scansubdir = true)
|
|---|
| 14 | {
|
|---|
| 15 | if((substr($dir, strlen($dir)-1 )=="/") || (substr($dir, strlen($dir)-1 )=="\\")){
|
|---|
| 16 | $dir=substr($dir, 0,strlen($dir)-1);
|
|---|
| 17 | }
|
|---|
| 18 | $files=array();
|
|---|
| 19 | if($scansubdir == true){
|
|---|
| 20 | $priority = glob("{$dir}/*", GLOB_ONLYDIR);
|
|---|
| 21 | if(is_array($priority) && count($priority)>0){
|
|---|
| 22 | sort($priority);
|
|---|
| 23 | foreach($priority as $prioritydir){
|
|---|
| 24 | echo '<br />';
|
|---|
| 25 | foreach(glob("{$prioritydir}/$expr.".$ext) as $subdirfile){
|
|---|
| 26 | $files[] = $subdirfile;
|
|---|
| 27 | }
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | foreach(glob("{$dir}/$expr.".$ext) as $file){
|
|---|
| 33 | $files[] = $file;
|
|---|
| 34 | }
|
|---|
| 35 | $files = ((is_array($files)) ? $files : array());
|
|---|
| 36 | if (function_exists('debugMessage')) {
|
|---|
| 37 | debugMessage('auto_include',$files);
|
|---|
| 38 | }
|
|---|
| 39 | return $files;
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | /*
|
|---|
| 43 | $priority = glob("{$dir}", GLOB_ONLYDIR);
|
|---|
| 44 | if(is_array($priority) && count($priority)>0){
|
|---|
| 45 | sort($priority);
|
|---|
| 46 | foreach($priority as $prioritydir){
|
|---|
| 47 | $files[] = glob("{$prioritydir}/$expr.".$ext);
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 | $files[] = glob("{$dir}/$expr.".$ext);
|
|---|
| 51 | $files = ((is_array($files)) ? $files : array());
|
|---|
| 52 | if (function_exists('debugMessage')) {
|
|---|
| 53 | debugMessage('auto_include',$files);
|
|---|
| 54 | }
|
|---|
| 55 | return $files;
|
|---|
| 56 | */
|
|---|
| 57 |
|
|---|
| 58 | }
|
|---|