Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function jensort(&$arr)
- {
- return ksort($arr, SORT_NATURAL | SORT_FLAG_CASE);
- }
- function namingway($name,$mode='prj')
- {
- $ret=$name;
- $ext='.php';
- switch ($mode) {
- case 'prj':
- $ret=substr($ret,0,-strlen($ext)).
- str_replace($ext,'',substr($ret,-strlen($ext),strlen($ext)));
- $ret='prj_'.str_replace(' ','_',$ret);
- $ret=strtolower($ret);
- break;
- case 'list':
- $ret=substr($ret,-strlen('.php'));
- $ret=substr($ret,strlen('prj_'));
- break;
- default:
- break;
- }
- return $ret;
- }
- function include_listings($path)
- {
- global $nen;
- $ret=array();
- if ($handle = opendir($nen['root'].'/'.$path.'/'));
- {
- //echo "Directory handle: $handle\n";
- //echo "Entries:\n";
- /* This is the correct way to loop over the directory. */
- while (false !== ($entry = readdir($handle)))
- if(is_file($nen['root'].'/'.$path.'/'.$entry))
- //if (($entry!=='.')&&($entry!=='..'))
- if (substr($entry,-strlen('.'.$nen['php']),strlen('.'.$nen['php']))==='.'.$nen['php'])
- {
- include_once($nen['root'].'/'.$path.'/'.$entry); //"$entry\n";
- if (function_exists(namingway($entry,'prj')))
- eval ('$ret[] = '.namingway($entry,'prj').'();');
- //echo htmlentities(var_dump($ret[$entry]));
- }
- /* This is the WRONG way to loop over the directory. */
- // while ($entry = readdir($handle)) {
- // include_once $entry; //echo "$entry\n";
- // }
- closedir($handle);
- }
- //echo htmlentities(var_dump($ret));
- jensort($ret);
- return $ret;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement