本文整理汇总了PHP中ls函数的典型用法代码示例。如果您正苦于以下问题:PHP ls函数的具体用法?PHP ls怎么用?PHP ls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ls函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: trim
$title = $header . ' - ' . $title;
} else {
// chapter NOT exist or NOT in menu >>
$error = TRUE;
}
}
// handle error >>
if ($error === TRUE) {
$header = 'Error 404: file not found';
$content = '<p>Error 404: file not found</p>';
$title = $header . ' - ' . $title;
}
// get downloadable files >>
$ls_arg = trim(get_tag($content, 'ls'));
if ($ls_arg != '') {
$ls = ls($ls_arg);
$_ = explode('<ls>' . $ls_arg . '</ls>', $content);
$content = implode($ls, $_);
}
// make style >>
$style = read_file($etc . 'master.css');
// load page design >>
include $etc . 'skin.php';
// KERNEL FUNCTIONS >>
// ----------------------------------------------------- //
// read directory handle and return array from file names >>
function read_dir($dir)
{
if (is_dir($dir)) {
if (substr($dir, -1) != '/') {
$dir = $dir . '/';
开发者ID:JerkWisdom,项目名称:zpublic,代码行数:31,代码来源:kernel.php
示例17: listPlugin
public static function listPlugin($_activateOnly = false, $_orderByCaterogy = false, $_translate = true)
{
$listPlugin = array();
if ($_activateOnly) {
$sql = "SELECT plugin\n FROM config\n WHERE `key`='active'\n AND `value`='1'";
$results = DB::Prepare($sql, array(), DB::FETCH_TYPE_ALL);
foreach ($results as $result) {
try {
$listPlugin[] = plugin::byId($result['plugin'], $_translate);
} catch (Exception $e) {
log::add('plugin', 'error', $e->getMessage(), 'pluginNotFound::' . $result['plugin']);
}
}
} else {
$rootPluginPath = dirname(__FILE__) . '/../../plugins';
foreach (ls($rootPluginPath, '*') as $dirPlugin) {
if (is_dir($rootPluginPath . '/' . $dirPlugin)) {
$pathInfoPlugin = $rootPluginPath . '/' . $dirPlugin . '/plugin_info/info.xml';
if (file_exists($pathInfoPlugin)) {
try {
$listPlugin[] = plugin::byId($pathInfoPlugin, $_translate);
} catch (Exception $e) {
log::add('plugin', 'error', $e->getMessage(), 'pluginNotFound::' . $pathInfoPlugin);
}
}
}
}
}
if ($_orderByCaterogy) {
$return = array();
if (count($listPlugin) > 0) {
foreach ($listPlugin as $plugin) {
$category = $plugin->getCategory();
if ($category == '') {
$category = __('Autre', __FILE__);
}
if (!isset($return[$category])) {
$return[$category] = array();
}
$return[$category][] = $plugin;
}
foreach ($return as &$category) {
usort($category, 'plugin::orderPlugin');
}
ksort($return);
}
return $return;
} else {
if (isset($listPlugin) && is_array($listPlugin) && count($listPlugin) > 0) {
usort($listPlugin, 'plugin::orderPlugin');
return $listPlugin;
} else {
return array();
}
}
}
开发者ID:saez0pub,项目名称:core,代码行数:56,代码来源:plugin.class.php
示例18: l
<?php
// TWEET NEST
// Load user
require "mpreheader.php";
$pageTitle = "Loading user info";
require "mheader.php";
echo l("Connecting & parsing...\n");
$path = "1/users/show.json?screen_name=" . $config['twitter_screenname'];
echo l("Connecting to: <span class=\"address\">" . ls($path) . "</span>\n");
$data = $twitterApi->query($path);
if ($data) {
$extra = array("created_at" => (string) $data->created_at, "utc_offset" => (string) $data->utc_offset, "time_zone" => (string) $data->time_zone, "lang" => (string) $data->lang, "profile_background_color" => (string) $data->profile_background_color, "profile_text_color" => (string) $data->profile_text_color, "profile_link_color" => (string) $data->profile_link_color, "profile_sidebar_fill_color" => (string) $data->profile_sidebar_fill_color, "profile_sidebar_border_color" => (string) $data->profile_sidebar_border_color, "profile_background_image_url" => (string) $data->profile_background_image_url, "profile_background_tile" => (string) $data->profile_background_tile);
echo l("Checking...\n");
$db->query("DELETE FROM `" . DTP . "tweetusers` WHERE `userid` = '0'");
// Getting rid of empty users created in error
$q = $db->query("SELECT * FROM `" . DTP . "tweetusers` WHERE `userid` = '" . $db->s($data->id) . "' LIMIT 1");
if ($db->numRows($q) <= 0) {
$iq = "INSERT INTO `" . DTP . "tweetusers` (`userid`, `screenname`, `realname`, `location`, `description`, `profileimage`, `url`, `extra`, `enabled`) VALUES ('" . $db->s($data->id) . "', '" . $db->s($data->screen_name) . "', '" . $db->s($data->name) . "', '" . $db->s($data->location) . "', '" . $db->s($data->description) . "', '" . $db->s($data->profile_image_url) . "', '" . $db->s($data->url) . "', '" . $db->s(serialize($extra)) . "', '1');";
} else {
$iq = "UPDATE `" . DTP . "tweetusers` SET `screenname` = '" . $db->s($data->screen_name) . "', `realname` = '" . $db->s($data->name) . "', `location` = '" . $db->s($data->location) . "', `description` = '" . $db->s($data->description) . "', `profileimage` = '" . $db->s($data->profile_image_url) . "', `url` = '" . $db->s($data->url) . "', `extra` = '" . $db->s(serialize($extra)) . "' WHERE `userid` = '" . $db->s($data->id) . "' LIMIT 1";
}
echo l("Updating...\n");
$q = $db->query($iq);
echo $q ? l(good("Done!")) : l(bad("DATABASE ERROR: " . $db->error()));
} else {
echo l(bad("No data! Try again later."));
}
require "mfooter.php";
开发者ID:ngpestelos,项目名称:tweetnest,代码行数:29,代码来源:loaduser.php
示例19: getAssistantFilePath
public function getAssistantFilePath()
{
$id = $this->getConfiguration('manufacturer_id') . '.' . $this->getConfiguration('product_type') . '.' . $this->getConfiguration('product_id');
$files = ls(dirname(__FILE__) . '/../config/devices', $id . '_*.php', false, array('files', 'quiet'));
foreach (ls(dirname(__FILE__) . '/../config/devices', '*', false, array('folders', 'quiet')) as $folder) {
foreach (ls(dirname(__FILE__) . '/../config/devices/' . $folder, $id . '_*.php', false, array('files', 'quiet')) as $file) {
$files[] = $folder . $file;
}
}
if (count($files) > 0) {
return $files[0];
}
return false;
}
开发者ID:stef3569,项目名称:plugin-openzwave,代码行数:14,代码来源:openzwave.class.php
示例20: define
<?php
define("BASE_DIR", dirname(dirname(__FILE__)));
require_once BASE_DIR . "/include/constants.inc";
require_once BASE_DIR . "/include/globals.inc";
require_once BASE_DIR . "/include/misc.inc";
require_once BASE_DIR . "/include/db.inc";
$dirname = str_replace("\\", "/", BASE_DIR . "/_backup");
db_set_constraints(false);
foreach (ls($dirname) as $file) {
//if ($file == 'event_guest.sql') {
// continue;
//}
try {
db_execute_file($dirname . "/" . $file);
} catch (Exception $e) {
echo '<pre>';
print_r($e);
echo '</pre>';
exit;
}
}
db_set_constraints(true);
?>
<html>
<head>
<title>Restoration done</title>
</head>
<body>
Restoration success<br/>
<a href="../index.php">Go to index</a>
开发者ID:centaurustech,项目名称:truc,代码行数:31,代码来源:restore_db.php
注:本文中的ls函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论