本文整理汇总了PHP中readDirectory函数的典型用法代码示例。如果您正苦于以下问题:PHP readDirectory函数的具体用法?PHP readDirectory怎么用?PHP readDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readDirectory函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readDirectory
function readDirectory($path, $d = 0)
{
global $basePath, $excludeSpecificDirectory;
$pattern = preg_quote(implode('|', $excludeSpecificDirectory), '/');
$pattern = str_replace(array('\\*', '\\|'), array('.*', '|'), $pattern);
$fullPath = $path;
if ($d == FALSE) {
$fullPath = $basePath . $path;
}
$files = array();
$list = glob($fullPath);
foreach ($list as $file) {
if ($pattern != '' && preg_match('/^' . $pattern . '$/i', $file, $match) != 0) {
continue;
}
/* Empty basepath bug fixed */
if ($d == FALSE) {
$file = substr($file, strlen($basePath));
}
if (is_file($file)) {
$files[] = $file;
} else {
if (is_dir($file) && $path != '*') {
$files = array_merge($files, readDirectory($file . '/*', 1));
}
}
}
return $files;
}
示例2: readDirectory
/**
* Recursively populated $GLOBALS['files']
*
* @param string $path The path to glob through.
*
* @return void
* @uses $GLOBALS['files']
*/
function readDirectory($path)
{
foreach (glob($path . '/*') as $file) {
if (!is_dir($file)) {
$GLOBALS['files'][] = $file;
} else {
readDirectory($file);
}
}
}
示例3: readDirectory
function readDirectory($path)
{
$handle = opendir($path);
while ($item = readdir($handle)) {
if ($item != '.' && $item != '..') {
if (is_file($path . '/' . $item)) {
echo $item . '--文件<br />';
} else {
echo $item . '--目录<br />';
readDirectory($path . '/' . $item);
}
}
}
closedir($handle);
}
示例4: readDirectory
function readDirectory($dirName)
{
$fileList = array();
$dir = opendir($dirName);
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..' && $file != 'ext') {
if (is_dir($dirName . '/' . $file)) {
$fileList = array_merge($fileList, readDirectory($dirName . '/' . $file));
} else {
if (StringTool::endsWith($file, '.js')) {
$fileList[] = $dirName . '/' . $file;
}
}
}
}
return $fileList;
}
示例5: readDirectory
<?php
$stylesheets = readDirectory("style/");
$select = "<select id='input1' name='stylesheet' onchange='form.submit();'>";
$select .= "<option value='-1'>Webbplatsens standard stylesheet</option>";
foreach ($stylesheets as $val) {
$selected = "";
if (isset($_SESSION['stylesheet']) && $_SESSION['stylesheet'] == $val) {
$selected = "selected";
}
$select .= "<option value='{$val}' {$selected}>{$val}</option>";
}
$select .= "</select>";
?>
<h1>Välj stylesheet</h1>
<p>Välj den stylesheet som du vill använda.
<form method="post" action="?p=choose-stylesheet-process">
<fieldset>
<!-- <legend>Välj Stylesheet</legend> -->
<p>
<label for="input1">Stylesheet:</label><br>
<?php
echo $select;
?>
</p>
<p>
<?php
示例6: isset
<?php
require_once "dir_func.php";
require_once "file_func.php";
$path = isset($_GET['path']) ? $_GET['path'] : "testdir";
$arr = readDirectory($path);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>dir_manager</title>
</head>
<body>
<?php
if (isset($_GET['action']) && $_GET['action'] === "show_content") {
$content = file_get_contents(urldecode($_GET['filename']));
try {
$name_enc = mb_detect_encoding($content, array("GB2312", "GBK", "UTF-8", "BIG5"), false);
if ($name_enc) {
$content = iconv($name_enc, 'UTF-8//IGNORE', $content);
}
echo $content;
} catch (Exception $e) {
echo $e->getMessage();
echo "无法打开文件";
}
}
?>
<table width="100%" border="1px" cellpadding="2" cellspacing="0" bgcolor="#ABCDEF" align="center">
<tr>
示例7: readDirectory
<?php
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
require_once '../images/filepng/tubiao.php';
//$path="../../files/files";
//原路径
$sourcepath = $_GET['path'] ? $_GET['path'] : $_POST['path'];
//要删除的目录或者文件
$folderp = $_REQUEST['folderp'];
$filep = $_REQUEST['filep'];
//新路径
$mubiaopath = $fileroot;
$mubiaopath = $_REQUEST['mubiaopath'] ? $_REQUEST['mubiaopath'] : $mubiaopath;
$info = readDirectory($mubiaopath);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>日记本_写日志</title>
<link rel="stylesheet" href="../../css/public.css" />
<link href="../css/StyleSheet_editlz.css" rel="stylesheet" type="text/css" />
<style type="text/css">
html{-webkit-box-sizing:border-box;-moz-box-sizing:border-box; box-sizing:border-box;padding:0px 0px 50px 0px; overflow:auto;}
img{border:none;}
#button{display:inline-block; *display:inline; *zoom:1; line-height:30px; padding:0 20px; background-color:#56B4DC; color:#fff; font-size:14px; border-radius:3px; cursor:pointer; font-weight:normal;}
#link1{float:left;padding-left:15px;padding-right:15px;padding-top:10px;padding-bottom:10px;}
#link{width:72px;height:72px;margin-left: auto;margin-right: auto;}
示例8: dirname
<?php
//
// Set up the path and read the directory, store all files in array $files
//
$path = dirname(__FILE__) . "/data/";
$files = readDirectory($path);
?>
<h1>Initiera och kontrollera annonsdatabasen</h1>
<?php
if (is_writable($path)) {
?>
<p class="success">Katalogen är skrivbar.</p>
<?php
} else {
?>
<p class="alert">Katalogen är ej skrivbar. Skapa katalogen och gör den skrivbar.</p>
<?php
return;
}
?>
<p>Katalogen innehåller <?php
echo sizeof($files);
?>
annonser.</p>
<ul>
<?php
示例9: readDirectory
<?php
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
$path = "file";
$path = $_REQUEST['path'] ? $_REQUEST['path'] : $path;
$act = $_REQUEST['act'];
$filename = $_REQUEST['filename'];
$dirname = $_REQUEST['dirname'];
$info = readDirectory($path);
if (!$info) {
echo "<script>alert('没有文件或目录!!!');location.href='index.php';</script>";
}
//print_r($info);
$redirect = "index.php?path={$path}";
if ($act == "创建文件") {
//创建文件
// echo $path,"--";
// echo $filename;
$mes = createFile($path . "/" . $filename);
alertMes($mes, $redirect);
} elseif ($act == "showContent") {
//查看文件内容
$content = file_get_contents($filename);
//echo "<textarea readonly='readonly' cols='100' rows='10'>{$content}</textarea>";
//高亮显示PHP代码
//高亮显示字符串中的PHP代码
if (strlen($content)) {
$newContent = highlight_string($content, true);
//高亮显示文件中的PHP代码
示例10: dynamicReplace
public function dynamicReplace($start, $end, $string)
{
//loop replace
global $settings_data;
$db = new db();
$tmdb = new tmdb();
$base = $tmdb->getConfig();
$newData = '';
$langoptions = '';
$tempoptions = '';
$qCount = 0;
$i = 0;
preg_match('/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/s', $string, $matches);
$dataArray = array();
if (strpos($start, "FILMS")) {
$allowedVideos = implode(' OR id = ', $this->allowedVideos());
if (isset($_GET['cat'])) {
$result = $db->query('videos', "SELECT * FROM info WHERE genres LIKE '%{$_GET['cat']}%' AND id = {$allowedVideos}");
} else {
if (isset($_POST['s'])) {
$result = $db->query('videos', "SELECT * FROM info WHERE title LIKE '%{$_POST['s']}%' AND id = {$allowedVideos}");
} else {
$result = $db->query('videos', "SELECT * FROM info WHERE id = {$allowedVideos} ORDER BY ROWID DESC");
}
}
if (!$result) {
echo ' DB ERROR.';
} else {
foreach ($result as $row) {
$data = str_replace('LINK_INFO', '?info&id=' . $row['id'], $matches[1]);
$data = str_replace('IMG_POSTER', $base . 'w185' . $row['poster_path'], $data);
//need to change this to optional non-tmdb data
$qCount++;
$newData .= $data;
if ($i >= $settings_data['fp_display']) {
break;
}
$i++;
}
}
}
if (strpos($start, "PAGENAV")) {
//DOESNT WORK YET!!!!!!!!!!!
$data = str_replace('PAGE_NEXT_URL', '?' . strtok($_SERVER["QUERY_STRING"], '&'), $data);
$data = str_replace('PAGE_BACK_URL', '?' . strtok($_SERVER["QUERY_STRING"], '&'), $data);
$newData .= $data;
}
if (strpos($start, "TEMPCATS")) {
$result = $db->query('videos', "SELECT genres FROM info");
$categories = array();
if ($result != false) {
foreach ($result as $row) {
$catString = explode(",", $row['genres']);
$categories = array_merge($categories, $catString);
}
}
$cats = array_unique($categories);
foreach ($cats as $cat) {
$newData .= str_replace('CAT_NAME', $cat, str_replace('CAT_LINK', '?search&cat=' . $cat, $matches[1]));
}
}
if (strpos($matches[1], 'PROFAGE_OPTIONS') !== false) {
for ($i = 1; $i <= 100; $i++) {
$ageoptions .= '<option>' . $i . '</option>';
}
$newData = str_replace('PROFAGE_OPTIONS', $ageoptions, $matches[1]);
}
if (strpos($matches[1], 'VDATA_FILE') !== false) {
foreach (readDirectory('videos') as $videos) {
//TODO: Modify for multiple directories
$newData .= str_replace('VDATA_FILE', 'videos/' . $videos, $matches[1]);
$newData = str_replace('VDATA_TITLE', $videos, $newData);
}
}
if (strpos($matches[1], 'LANGUAGE_OPTIONS') !== false || strpos($matches[1], 'TEMPLATE_OPTIONS') !== false) {
foreach (readDirectory('languages') as $lang) {
$langoptions .= '<option>' . str_replace('.php', '', $lang) . '</option>';
}
$newData = str_replace('LANGUAGE_OPTIONS', $langoptions, $matches[1]);
foreach (readDirectory('templates') as $temp) {
$tempoptions .= '<option>' . $temp . '</option>';
}
$newData = str_replace('TEMPLATE_OPTIONS', $tempoptions, $newData);
}
return preg_replace('/' . preg_quote($start) . '(.*?)' . preg_quote($end) . '/s', $newData, $string);
}
示例11: dirname
<?php
//
// Set up the path and read the directory, store all files in array $stylesheets
//
$pathToStyles = dirname(__FILE__) . "/../../style/";
$stylesheets = readDirectory($pathToStyles);
//
// Check that the stylesheet filename is valid by checking that it is in the $stylesheet array.
//
// http://php.net/manual/en/function.in-array.php
//
$filename = null;
$isWritable = null;
if (isset($_POST['stylesheet']) && in_array($_POST['stylesheet'], $stylesheets)) {
$filename = $pathToStyles . $_POST['stylesheet'];
if (is_writable($filename)) {
$isWritable = true;
} else {
$isWritable = false;
}
}
//
// Check if Save-button was pressed, save the file if true.
//
if (isset($_POST['doSave'])) {
$resFromSave = putFileContents($filename, strip_tags($_POST['styleContent']));
}
//
// Create a select/option-list based on the content of the array $stylesheets
//
示例12: getDirectory
function getDirectory($directory)
{
mountNetworkShare($directory);
return readDirectory($directory);
}
示例13: downloadFile
//Author : Wendowski, Kevin
//File Name : index.php
//Includes
include "gtfs.library.php";
//Download:
$url = "http://www2.septa.org/developer/download.php?fc=septa_gtfs.zip&download=download";
$saveDirectory = "feeds/gtfs.zip";
$result = downloadFile($url, $saveDirectory);
//Unzip:
$feedDirectory = "feeds";
$filename = $feedDirectory . "/gtfs.zip";
$filenameRail = $feedDirectory . "/gtfs/google_rail.zip";
$unzip = unzipFile($filename, $filenameRail, $feedDirectory);
//Read Files:
$directory = "feeds/google_rail";
$files = readDirectory($directory);
var_dump($files);
foreach ($files as $file) {
$location = "feeds/google_rail/" . $file;
$GTFSFilename = substr(strrchr($location, '/'), 1);
clearGTFSData($GTFSFilename);
$result = readGTFSData($location);
}
//Function:
function readDirectory($directory)
{
$files = array();
if ($handle = opendir($directory)) {
/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
$files[] = $entry;
示例14: showDirectory
function showDirectory($directory)
{
global $files, $directories, $fileInfo, $PHP_SELF;
readDirectory($directory);
showInfoDirectory($directory);
?>
<p><table cellpadding=3 cellspacing=1 width="100%" border="0" bgcolor=<?php
echo TABLE_BORDER_COLOR;
?>
>
<tr bgcolor="#000000">
<?php
if ($show_icons) {
?>
<td width="16" align="center" bgcolor=<?php
echo TABLE_BACKGROUND_COLOR;
?>
> </td>
<?php
}
?>
<td align="center"><b><small>NAME</small></b></td>
<td align="center"><b><small>SIZE</small></b></td>
<td align="center"><b><small>LAST MODIFY</small></b></td>
<td align="center"><b><small>PERMISIONS</small></b></td>
<td align="center"><b><small>ACTIONS</small></b></td>
</tr>
<?php
for ($i = 0; $i < sizeof($directories); $i++) {
$fileInfo->getInfo($directories[$i]);
showFileInfo($fileInfo);
}
for ($i = 0; $i < sizeof($files); $i++) {
$fileInfo->getInfo($files[$i]);
showFileInfo($fileInfo);
}
?>
</table>
<?php
}