当前位置: 首页>>代码示例>>PHP>>正文


PHP ls函数代码示例

本文整理汇总了PHP中ls函数的典型用法代码示例。如果您正苦于以下问题:PHP ls函数的具体用法?PHP ls怎么用?PHP ls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ls函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ls

function ls($pattern = "*", $folder = "", $recursivly = false, $options = array('return_files', 'return_folders'))
{
    if ($folder) {
        $current_folder = realpath('.');
        if (in_array('quiet', $options)) {
            // If quiet is on, we will suppress the 'no such folder' error
            if (!file_exists($folder)) {
                return array();
            }
        }
        if (!chdir($folder)) {
            return array();
        }
    }
    $get_files = in_array('return_files', $options);
    $get_folders = in_array('return_folders', $options);
    $both = array();
    $folders = array();
    // Get the all files and folders in the given directory.
    if ($get_files) {
        $both = glob($pattern, GLOB_BRACE + GLOB_MARK);
    }
    if ($recursivly or $get_folders) {
        $folders = glob("*", GLOB_ONLYDIR + GLOB_MARK);
    }
    //If a pattern is specified, make sure even the folders match that pattern.
    $matching_folders = array();
    if ($pattern !== '*') {
        $matching_folders = glob($pattern, GLOB_ONLYDIR + GLOB_MARK);
    }
    //Get just the files by removing the folders from the list of all files.
    $all = array_values(array_diff($both, $folders));
    if ($recursivly or $get_folders) {
        foreach ($folders as $this_folder) {
            if ($get_folders) {
                //If a pattern is specified, make sure even the folders match that pattern.
                if ($pattern !== '*') {
                    if (in_array($this_folder, $matching_folders)) {
                        array_push($all, $this_folder);
                    }
                } else {
                    array_push($all, $this_folder);
                }
            }
            if ($recursivly) {
                // Continue calling this function for all the folders
                $deep_items = ls($pattern, $this_folder, $recursivly, $options);
                # :RECURSION:
                foreach ($deep_items as $item) {
                    array_push($all, $this_folder . $item);
                }
            }
        }
    }
    if ($folder) {
        chdir($current_folder);
    }
    //echo "LS_called!<br />";
    return $all;
}
开发者ID:vikkio88,项目名称:virublog,代码行数:60,代码来源:function.php

示例2: listSvgWidget

 public static function listSvgWidget()
 {
     $return = array();
     $uploaddir = dirname(__FILE__) . '/../special';
     $data['files'] = ls($uploaddir, "*", false, array('files'));
     $data['folders'] = ls($uploaddir, "*", false, array('folders'));
     for ($index = 0; $index < count($data['folders']); $index++) {
         $data['folders'][$index] = str_replace('/', '', $data['folders'][$index]);
     }
     for ($index = 0; $index < count($data['files']); $index++) {
         $filename = pathinfo($data['files'][$index]);
         for ($nbFolder = 0; $nbFolder < count($data['folders']); $nbFolder++) {
             if ($data['folders'][$nbFolder] == strtolower($filename['filename'])) {
                 $folders['name'] = $data['files'][$index];
                 $folders['folder'] = strtolower($filename['filename']) . '/';
                 $folders['files'] = ls($uploaddir . '/' . strtolower($filename['filename']), "*", false, array('files'));
                 $extension = pathinfo(strtolower($folders['files'][0]));
                 $folders['extension'] = $extension['extension'];
                 //return $folders;.replace(/<?[^>]*>/, "").replace(/<!DOCTYPE[^>]*>/, "").replace(/<!--[^>]*>/, "")
                 if (in_array($folders['extension'], array('svg'))) {
                     for ($nbFile = 0; $nbFile < count($folders['files']); $nbFile++) {
                         $filename = pathinfo($folders['files'][$nbFile]);
                         $folders['svg'][$nbFile]['name'] = $filename['filename'];
                         $folders['svg'][$nbFile]['snap'] = file_get_contents($uploaddir . '/' . $folders['folder'] . $folders['files'][$nbFile]);
                     }
                 }
                 $return[] = $folders;
             }
         }
     }
     return $return;
 }
开发者ID:tlo,项目名称:plugin-widget,代码行数:32,代码来源:widget.class.php

示例3: devicesParameters

 public static function devicesParameters($_device = '')
 {
     $path = dirname(__FILE__) . '/../config/devices';
     if (isset($_device) && $_device != '') {
         $files = ls($path, $_device . '.php', false, array('files', 'quiet'));
         if (count($files) == 1) {
             global $deviceConfiguration;
             require_once $path . '/' . $files[0];
             return $deviceConfiguration[$_device];
         }
     }
     $files = ls($path, '*.php', false, array('files', 'quiet'));
     $return = array();
     foreach ($files as $file) {
         global $deviceConfiguration;
         require_once $path . '/' . $file;
         $return = $return + $deviceConfiguration;
     }
     if (isset($_device) && $_device != '') {
         if (isset($return[$_device])) {
             return $return[$_device];
         }
         return array();
     }
     return $return;
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:26,代码来源:rfxcom.class.php

示例4: __construct

 public function __construct()
 {
     /* Init rules. */
     $rulesPath = WIKIDOT_ROOT . '/php/utils/karmarules/';
     $files = ls($rulesPath, '*.php');
     foreach ($files as $f) {
         require_once $rulesPath . '/' . $f;
         $cn = str_replace('.php', '', basename($f));
         $this->_rules[] = new $cn();
     }
 }
开发者ID:jbzdak,项目名称:wikidot,代码行数:11,代码来源:KarmaCalculator.php

示例5: compile

 private function compile(array $tokens)
 {
     $cg = (object) ['ts' => TokenStream::fromSlice($tokens), 'parsers' => []];
     traverse(rtoken('/^(T_\\w+)·(\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $token = $result->token();
         $id = $this->lookupCapture($token);
         $type = $this->lookupTokenType($token);
         $cg->parsers[] = token($type)->as($id);
     }), ($parser = chain(rtoken('/^·\\w+$/')->as('type'), token('('), optional(ls(either(future($parser)->as('parser'), chain(token(T_FUNCTION), parentheses()->as('args'), braces()->as('body'))->as('function'), string()->as('string'), rtoken('/^T_\\w+·\\w+$/')->as('token'), rtoken('/^T_\\w+$/')->as('constant'), rtoken('/^·this$/')->as('this'), label()->as('label'))->as('parser'), token(',')))->as('args'), commit(token(')')), optional(rtoken('/^·\\w+$/')->as('label'), null)))->onCommit(function (Ast $result) use($cg) {
         $cg->parsers[] = $this->compileParser($result->type, $result->args, $result->label);
     }), $this->layer('{', '}', braces(), $cg), $this->layer('[', ']', brackets(), $cg), $this->layer('(', ')', parentheses(), $cg), rtoken('/^···(\\w+)$/')->onCommit(function (Ast $result) use($cg) {
         $id = $this->lookupCapture($result->token());
         $cg->parsers[] = layer()->as($id);
     }), token(T_STRING, '·')->onCommit(function (Ast $result) use($cg) {
         $offset = \count($cg->parsers);
         if (0 !== $this->dominance || 0 === $offset) {
             $this->fail(self::E_BAD_DOMINANCE, $offset, $result->token()->line());
         }
         $this->dominance = $offset;
     }), rtoken('/·/')->onCommit(function (Ast $result) {
         $token = $result->token();
         $this->fail(self::E_BAD_CAPTURE, $token, $token->line());
     }), any()->onCommit(function (Ast $result) use($cg) {
         $cg->parsers[] = token($result->token());
     }))->parse($cg->ts);
     // check if macro dominance '·' is last token
     if ($this->dominance === \count($cg->parsers)) {
         $this->fail(self::E_BAD_DOMINANCE, $this->dominance, $cg->ts->last()->line());
     }
     $this->specificity = \count($cg->parsers);
     if ($this->specificity > 1) {
         if (0 === $this->dominance) {
             $pattern = chain(...$cg->parsers);
         } else {
             /*
               dominat macros are partially wrapped in commit()s and dominance
               is the offset used as the 'event horizon' point... once the entry
               point is matched, there is no way back and a parser error arises
             */
             $prefix = array_slice($cg->parsers, 0, $this->dominance);
             $suffix = array_slice($cg->parsers, $this->dominance);
             $pattern = chain(...array_merge($prefix, array_map(commit::class, $suffix)));
         }
     } else {
         /*
           micro optimization to save one function call for every token on the subject
           token stream whenever the macro pattern consists of a single parser
         */
         $pattern = $cg->parsers[0];
     }
     return $pattern;
 }
开发者ID:lastguest,项目名称:yay,代码行数:52,代码来源:Pattern.php

示例6: ls

function ls($basePath, $path)
{
    echo "<ul>";
    $files = scandir($basePath . $path);
    foreach ($files as $file) {
        if ($file != "." && $file != ".." && $file != ".svn") {
            echo "<li>";
            if (is_dir($basePath . $path . "/" . $file)) {
                echo $file;
                ls($basePath, $path . "/" . $file);
            } else {
                echo "<a href=\"page.php?p={$path}/{$file}\">{$file}</a>";
            }
            echo "</li>";
        }
    }
    echo "</ul>";
}
开发者ID:alakim,项目名称:aga-cms,代码行数:18,代码来源:default.php

示例7: ls

function ls($curpath)
{
    $lsoutput = "";
    $dir = dir($curpath);
    while ($file = $dir->read()) {
        if ($file != "." && $file != "..") {
            if (is_dir($curpath . $file)) {
                $lsoutput .= ls($curpath . $file . "/");
            } else {
                if (notIgnore($curpath . $file)) {
                    $lsoutput .= "      <filename>" . substr($curpath . $file, 2) . "</filename>\n";
                }
            }
        }
    }
    $dir->close();
    return $lsoutput;
}
开发者ID:KlabsTechnology,项目名称:andro,代码行数:18,代码来源:buildxml.php

示例8: listWidget

 public static function listWidget($_version)
 {
     $path = dirname(__FILE__) . '/../template/' . $_version;
     $files = ls($path, 'cmd.*', false, array('files', 'quiet'));
     $return = array();
     foreach ($files as $file) {
         $informations = explode('.', $file);
         $pathfile = $path . '/' . $file;
         $widget = new self();
         $widget->setType($informations[1]);
         $widget->setSubtype($informations[2]);
         $widget->setName($informations[3]);
         $widget->setVersion($_version);
         $widget->setContent(file_get_contents($pathfile));
         $widget->setPath($pathfile);
         $return[] = $widget;
     }
     return $return;
 }
开发者ID:Wators,项目名称:jeedom_plugins,代码行数:19,代码来源:widget.class.php

示例9: ls

 function ls($path, &$html = array())
 {
     foreach (new FilesystemIterator($path, FilesystemIterator::SKIP_DOTS) as $file) {
         if ($file->getFilename() == '.DS_Store') {
             continue;
         } elseif ($file->isDir()) {
             $html[] = "\n<li>";
             $html[] = $file->getBaseName();
             $html[] = '<ul>';
             $html[] = ls($file->getPathname());
             $html[] = '</ul>';
             $html[] = '</li>';
         } else {
             $link = ltrim(preg_replace('/^' . preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', ROOT), '/') . '/i', '', str_replace(DIRECTORY_SEPARATOR, '/', $file)), '/');
             $html[] = "\n<li>";
             $html[] = '<a href="index.php?doc=' . urlencode($link) . '">' . $file->getBaseName() . '</a>';
             $html[] = '</li>';
         }
     }
     return implode("\n", $html);
 }
开发者ID:rafr3,项目名称:docs,代码行数:21,代码来源:index.php

示例10: loadModules

function loadModules()
{
    // Code HTML d'importation
    $scripts = '';
    $styles = '';
    // Liste des modules
    ls('modules', function ($modpath, $modfile) use(&$scripts, &$styles) {
        // Fichiers de scripts/styles
        $modscripts = "{$modpath}/scripts";
        $modstyles = "{$modpath}/styles";
        // echo "$modscripts<br/>";
        // Chargement des scripts
        ls($modscripts, function ($subpath, $subfile) use(&$scripts, $modfile) {
            $scripts .= "<script src='./modules/{$modfile}/scripts/{$subfile}'></script>";
        }, 'is_file');
        // Chargement des styles
        ls($modstyles, function ($subpath, $subfile) use(&$styles, $modfile) {
            $styles .= "<link rel='stylesheet' type='text/css' href='./modules/{$modfile}/styles/{$subfile}'/>";
        }, 'is_file');
    }, 'is_dir');
    // On retourne tout
    return array('styles' => $styles . "\n", 'scripts' => $scripts . "\n");
}
开发者ID:WKnight02,项目名称:BitterFox_III,代码行数:23,代码来源:init.php

示例11: loadPlugins

/**
 * Read the plugin folder and put all the plugins found there in the dropdown menu
 */
function loadPlugins()
{
    global $config;
    $plugins = array();
    // Open plugin directory, and proceed to read its contents
    $dir = joinPath($config['site_folder'], 'plugins');
    $files = ls("*", $dir, false, array('return_folders'));
    foreach ($files as $file) {
        if ($file == 'CVS' . DIRECTORY_SEPARATOR || $file == '.' || $file == '..' || $file == 'api' . DIRECTORY_SEPARATOR || $file == '.svn' . DIRECTORY_SEPARATOR) {
            continue;
        }
        $plugins[] = substr($file, 0, -1);
        //Remove the trailing '/'
    }
    //Show the dropdown menu only if there are plugins
    if (count($plugins)) {
        print '<li class="dropdown"><a href="' . joinPath($config['site_relative_path'], 'plugins/') . '" class="plugin with-icon">Plugins</a>';
        print "\n<ul class='menu-with-icon plugins'>\n";
        foreach ($plugins as $plug) {
            print '<li><a href="' . joinPath($config['site_absolute_path'], 'plugins/', "{$plug}/") . '">' . format($plug) . '</a></li>' . "\n";
        }
        print '</ul></li>';
    }
}
开发者ID:Gninety,项目名称:Microweber,代码行数:27,代码来源:custom.php

示例12: listCachedProtocols

function listCachedProtocols($cacheDir)
{
    $protocolDirs = ls($cacheDir);
    if (count($protocolDirs) > 0) {
        foreach ($protocolDirs as $pdir) {
            $curProtocols = ls($cacheDir . "/" . $pdir);
            if (count($curProtocols) > 0) {
                foreach ($curProtocols as $pname) {
                    $protocols[$pdir][] = $pname;
                    //echo basename($pdir)."/".basename($pname)." ";
                }
            }
        }
    } else {
        $protocols = 0;
    }
    return $protocols;
}
开发者ID:racheldenison,项目名称:megavista,代码行数:18,代码来源:protocolWizard.php

示例13: foreach

                        </div>
                        <div class="well col-sm-9" id="bsPanelWidgetImages" style="min-width: 725px;">
                            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                                <div class="panel panel-default">
                                    <div class="panel-heading" role="tab" id="headingOne">
                                        <h4 class="panel-title">
                                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                                {{Bibliothèque d'images : Jeedom}}<small><em><bold> - {{Les divers icônes de Jeedom disponibles}}</bold></em></small>
                                            </a>
                                        </h4>
                                    </div>
                                    <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                                        <div class="panel-body" style="height: 250px; overflow: auto">
                                            <div class="col-sm-12" id="bsIconView">
                                                <?php 
foreach (ls('core/css/icon', '*') as $dir) {
    if (is_dir('core/css/icon/' . $dir) && file_exists('core/css/icon/' . $dir . '/style.css')) {
        $css = file_get_contents('core/css/icon/' . $dir . '/style.css');
        $research = strtolower(str_replace('/', '', $dir));
        preg_match_all("/\\." . $research . "-(.*?):/", $css, $matches, PREG_SET_ORDER);
        $height = ceil(count($matches) / 12) * 80 + 80;
        echo '<div style="height : ' . $height . 'px;"><legend>{{' . str_replace('/', '', $dir) . '}}</legend>';
        $number = 1;
        foreach ($matches as $match) {
            if (isset($match[0])) {
                if ($number == 1) {
                    echo '<div class="row">';
                }
                echo '<div class="col-sm-1 divIconSel">';
                $icon = str_replace(array(':', '.'), '', $match[0]);
                echo '<center><span class="iconSel"><i class=\'icon ' . $icon . '\'></i></span><br/><span class="iconDesc">' . $icon . '</span></center>';
开发者ID:tlo,项目名称:plugin-widget,代码行数:31,代码来源:widget.php

示例14: getCurrentSysInfoFolder

 public static function getCurrentSysInfoFolder()
 {
     $dir = dirname(__FILE__) . '/../../';
     $ls = ls($dir, 'sysinfo*');
     if (count($ls) != 1) {
         return '';
     }
     return $ls[0];
 }
开发者ID:GaelGRIFFON,项目名称:core,代码行数:9,代码来源:jeedom.class.php

示例15: _AllFiles

function _AllFiles($Dir=false)
{
	global $ExploreDir;
	
	$Dir = !$Dir ? $ExploreDir : $Dir;
	
	$FileArr = ls($Dir);
	$ret[$Dir."/"] = $FileArr["files"];
	
	foreach ($FileArr["dirs"] as $Path)
	{
		$ret = array_merge($ret,_AllFiles($Dir."/".$Path));
	}
	
	$ret = !isset($ret) ? array() : $ret ;
	return $ret;
}
开发者ID:szenekonzept,项目名称:php-FileManager,代码行数:17,代码来源:index.php


注:本文中的ls函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。