本文整理汇总了PHP中findFiles函数的典型用法代码示例。如果您正苦于以下问题:PHP findFiles函数的具体用法?PHP findFiles怎么用?PHP findFiles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findFiles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findFiles
function findFiles($dir)
{
$dir = trim($dir);
if (substr($dir, -1) != '/') {
$dir .= "/";
}
$files = array();
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file == "." || $file == "..") {
continue;
}
switch (filetype($dir . $file)) {
case "file":
if (substr($file, -4) == ".php") {
$files[] = $dir . $file;
}
break;
case "dir":
$files = array_merge($files, findFiles($dir . $file));
break;
}
}
closedir($dh);
}
}
return $files;
}
示例2: searchSourceFiles
protected function searchSourceFiles()
{
if (!$this->config['quiet']) {
printf("Pack source files in path %s\n", $this->config['srcpath']);
}
$files = array();
findFiles($this->config['srcpath'], $files);
return $files;
}
示例3: findAllFiles
function findAllFiles($paths)
{
$dirs = allDirs($paths);
$files = array();
foreach ($dirs as $dir) {
$files = array_merge($files, findFiles($dir));
}
return $files;
}
示例4: filesautocomplete
function filesautocomplete(Silex\Application $app, Request $request)
{
$term = $request->get('term');
if (empty($_GET['ext'])) {
$extensions = 'jpg,jpeg,gif,png';
} else {
$extensions = $_GET['extensions'];
}
$files = findFiles($term, $extensions);
$app['debug'] = false;
return $app->json($files);
}
示例5: findFiles
function findFiles($base, $dir, &$results = [])
{
$files = scandir($dir);
foreach ($files as $key => $value) {
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
$name = $path;
$i = strpos($name, $base);
$name = substr($name, $i, strlen($name) - $i);
$i = strrpos($name, '/');
if (is_dir($path)) {
if ($value != '.' && $value != '..') {
$newDir = str_replace('raw_stock', 'stock', $name);
if (!is_dir($newDir)) {
mkdir($newDir);
}
$results[] = ['name' => $value, 'description' => $description, 'items' => []];
findFiles($base, $path, $results[count($results) - 1]['items']);
}
} else {
if (strpos($path, '.DS_Store') === false) {
$description = substr($name, $i + 1, strlen($name) - $i - 1);
$i = strpos($description, '.');
$description = substr($description, 0, $i);
$i = strpos($description, '-');
$prefix = substr($description, 0, $i);
$hasDescription = false;
$source = '';
$sourceDomain = '';
switch ($prefix) {
case 'pexels':
$hasDescription = true;
$source = 'Free stock photos - Pexels';
$sourceDomain = 'https://www.pexels.com/';
break;
case 'stocksnap':
$hasDescription = true;
$source = 'StockSnap.io - Beautiful Free Stock Photos (CC0)';
$sourceDomain = 'https://stocksnap.io/';
break;
}
$smallFilename = str_replace(['raw_stock', $prefix . '-', '.jpg'], ['stock', '', '-small.jpg'], $name);
$mediumFilename = str_replace(['raw_stock', $prefix . '-', '.jpg'], ['stock', '', '-medium.jpg'], $name);
$largeFilename = str_replace(['raw_stock', $prefix . '-', '.jpg'], ['stock', '', '-large.jpg'], $name);
if ($hasDescription) {
$description = substr($description, $i + 1, strlen($description) - $i - 1);
$description = ucfirst(implode(' ', explode('-', $description)));
}
$results[] = ['name' => $name, 'sizes' => ['small' => ['width' => 200, 'filename' => $smallFilename], 'medium' => ['width' => 600, 'filename' => $mediumFilename], 'large' => ['filename' => $largeFilename]], 'description' => $description, 'source' => $source, 'sourceDomain' => $sourceDomain];
}
}
}
}
示例6: preFill
/**
* Add some records with dummy content..
*
* Only fill the contenttypes passed as parameters
* If the parameters is empty, only fill empty tables
*
* @see preFillSingle
* @param array $contenttypes
* @return string
*/
public function preFill($contenttypes = array())
{
$this->guzzleclient = new \Guzzle\Service\Client('http://loripsum.net/api/');
$output = "";
// get a list of images..
$this->images = findFiles('', 'jpg,jpeg,png');
$empty_only = empty($contenttypes);
foreach ($this->app['config']->get('contenttypes') as $key => $contenttype) {
$tablename = $this->getTablename($key);
if ($empty_only && $this->hasRecords($tablename)) {
$output .= __("Skipped <tt>%key%</tt> (already has records)", array('%key%' => $key)) . "<br>\n";
continue;
} elseif (!in_array($key, $contenttypes) && !$empty_only) {
$output .= __("Skipped <tt>%key%</tt> (not checked)", array('%key%' => $key)) . "<br>\n";
continue;
}
$amount = isset($contenttype['prefill']) ? $contenttype['prefill'] : 5;
for ($i = 1; $i <= $amount; $i++) {
$output .= $this->preFillSingle($key, $contenttype);
}
}
$output .= "<br>\n\n" . __('Done!');
return $output;
}
示例7: showUsage
if (count($args) == 0) {
showUsage();
}
$dir = $args[0];
# Check Protection
if (isset($options['protect']) && isset($options['unprotect'])) {
die("Cannot specify both protect and unprotect. Only 1 is allowed.\n");
}
if (isset($options['protect']) && $options['protect'] == 1) {
die("You must specify a protection option.\n");
}
# Prepare the list of allowed extensions
global $wgFileExtensions;
$extensions = isset($options['extensions']) ? explode(',', strtolower($options['extensions'])) : $wgFileExtensions;
# Search the path provided for candidates for import
$files = findFiles($dir, $extensions, isset($options['search-recursively']));
# Initialise the user for this operation
$user = isset($options['user']) ? User::newFromName($options['user']) : User::newFromName('Maintenance script');
if (!$user instanceof User) {
$user = User::newFromName('Maintenance script');
}
$wgUser = $user;
# Get block check. If a value is given, this specified how often the check is performed
if (isset($options['check-userblock'])) {
if (!$options['check-userblock']) {
$checkUserBlock = 1;
} else {
$checkUserBlock = (int) $options['check-userblock'];
}
} else {
$checkUserBlock = false;
示例8: findFiles
<?php
require 'build.php';
$extension = 'json';
$object_files = findFiles('../objects/', $extension);
$title = 'Collier MVC - Generate Objects';
$page_title = 'Generate Objects';
if ($_POST['generate'] == 1) {
$gen = generateMVC(false);
if ($gen['success']) {
$body = '
<ol class="breadcrumb">
<li><a href="../../public/index.php">Getting Started</a></li>
<li><a href="generate_mvc.php">Generate Objects</a></li>
</ol>
<div class="row pad">
<div class="col-md-8">
<p class="bg-success pad"><span class="glyphicon glyphicon-ok"></span> <b>Successfully generated MVC scripts.</b></p>
</div>
<div class="col-md-4">
<center>
<p>Ready to continue?</p>
<a class="btn btn-primary" href="../../public/instructions.php?testing=1">Next Step</a>
</center>
</div>
</div>
<div class="row">
<div class="col-md-8">
<p>Your code has been generated. You can now find your model and controllers in their dedicated folders.</p>
示例9: VARCHAR
$p = $CFG->dbprefix;
echo "Checking plugins table...<br/>\n";
$plugins = "{$p}lms_plugins";
$table_fields = $PDOX->metadata($plugins);
if ($table_fields === false) {
echo "Creating plugins table...<br/>\n";
$sql = "\ncreate table {$plugins} (\n plugin_id INTEGER NOT NULL AUTO_INCREMENT,\n plugin_path VARCHAR(255) NOT NULL,\n\n version BIGINT NOT NULL,\n\n title VARCHAR(2048) NULL,\n\n json TEXT NULL,\n created_at DATETIME NOT NULL,\n updated_at DATETIME NOT NULL,\n\n UNIQUE(plugin_path),\n PRIMARY KEY (plugin_id)\n) ENGINE = InnoDB DEFAULT CHARSET=utf8;";
$q = $PDOX->queryReturnError($sql);
if (!$q->success) {
die("Unable to create lms_plugins table: " . implode(":", $q->errorInfo));
}
echo "Created plugins table...<br/>\n";
}
echo "Checking for any needed upgrades...<br/>\n";
// Scan the tools folders
$tools = findFiles("database.php", "../");
if (count($tools) < 1) {
echo "No database.php files found...<br/>\n";
return;
}
// A simple precedence order.. Will have to improve this.
foreach ($tools as $k => $tool) {
if (strpos($tool, "core/lti/database.php") && $k != 0) {
$tmp = $tools[0];
$tools[0] = $tools[$k];
$tools[$k] = $tmp;
break;
}
}
$maxversion = 0;
$maxpath = '';
示例10: lmsDie
echo "<p>This tool must be launched by the instructor</p>";
$OUTPUT->footer();
exit;
}
// See https://canvas.instructure.com/doc/api/file.link_selection_tools.html
// Needed return values
$content_return_types = LTIX::postGet("ext_content_return_types", false);
$content_return_url = LTIX::postGet("ext_content_return_url", false);
if (strlen($content_return_url) < 1) {
lmsDie("Missing ext_content_return_url");
}
if (strpos($content_return_types, "lti_launch_url") === false) {
lmsDie("This tool requires ext_content_return_types=lti_launch_url");
}
// Scan the tools folders for registration settings
$tools = findFiles("register.php", "../");
if (count($tools) < 1) {
lmsDie("No register.php files found...<br/>\n");
}
echo "<ul>\n";
$toolcount = 0;
foreach ($tools as $tool) {
$path = str_replace("../", "", $tool);
// echo("Checking $path ...<br/>\n");
unset($REGISTER_LTI2);
require $tool;
if (isset($REGISTER_LTI2) && is_array($REGISTER_LTI2)) {
if (isset($REGISTER_LTI2['name']) && isset($REGISTER_LTI2['short_name']) && isset($REGISTER_LTI2['description'])) {
} else {
lmsDie("Missing required name, short_name, and description in " . $tool);
}
示例11: compile_java
function compile_java()
{
$projPath = $this->config['project_dir'];
$binPath = $projPath . '/bin';
if (!is_dir($binPath)) {
mkdir($binPath);
}
$classesPath = $binPath . '/classes';
if (!is_dir($classesPath)) {
mkdir($classesPath);
}
$files = array();
findFiles($projPath . '/src', $files);
findFiles($projPath . '/gen', $files);
$cmd_str = 'javac -encoding utf8 -target ' . $this->java_version . ' -source ' . $this->java_version . ' -bootclasspath ' . $this->boot_class_path . ' -d ' . $classesPath;
foreach ($files as $file) {
$cmd_str = $cmd_str . ' ' . $file;
}
$cmd_str = $cmd_str . ' -classpath ' . $this->class_path;
$retval = $this->exec_sys_cmd($cmd_str);
return $retval;
}
示例12: copyDir
private function copyDir($srcPath, $dstPath, $flagCheck)
{
$files = array();
findFiles($srcPath, $files);
foreach ($files as $src) {
$dest = str_replace($srcPath, $dstPath, $src);
$this->replaceFile($src, $dest, "create", $flagCheck);
}
}
示例13: findFiles
function findFiles($dir, array &$files)
{
$dir = rtrim($dir, "/\\") . DS;
$dh = opendir($dir);
if ($dh == false) {
return;
}
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..' || $file == ".DS_Store") {
continue;
}
$path = $dir . $file;
if (is_dir($path)) {
findFiles($path, $files);
} elseif (is_file($path)) {
$files[] = $path;
}
}
closedir($dh);
}
示例14: showUsage
if (count($args) == 0) {
showUsage();
}
$dir = $args[0];
# Check Protection
if (isset($options['protect']) && isset($options['unprotect'])) {
die("Cannot specify both protect and unprotect. Only 1 is allowed.\n");
}
if (isset($options['protect']) && $options['protect'] == 1) {
die("You must specify a protection option.\n");
}
# Prepare the list of allowed extensions
global $wgFileExtensions;
$extensions = isset($options['extensions']) ? explode(',', strtolower($options['extensions'])) : $wgFileExtensions;
# Search the path provided for candidates for import
$files = findFiles($dir, $extensions);
# Initialise the user for this operation
$user = isset($options['user']) ? User::newFromName($options['user']) : User::newFromName('Maintenance script');
if (!$user instanceof User) {
$user = User::newFromName('Maintenance script');
}
$wgUser = $user;
# Get block check. If a value is given, this specified how often the check is performed
if (isset($options['check-userblock'])) {
if (!$options['check-userblock']) {
$checkUserBlock = 1;
} else {
$checkUserBlock = (int) $options['check-userblock'];
}
} else {
$checkUserBlock = false;
示例15: translatePathToRelIMG
}
} else {
$message = "Invalid file format. Images must be in jpg, png, gif, or bmp format.";
}
}
function translatePathToRelIMG($imgpath)
{
// krumo($imgpath);
$newPath = explode("/web/", $imgpath)[1];
return $newPath;
}
// en Images.pgp
// $images=readImagesFolder();
//krumo($images);
// pintamos las imágenes disponibles
$images = findFiles($_SESSION['destacados_img_folder'], $ext = array("png", "gif", "jpg"));
//krumo($images);
$availableImgs = "";
foreach ($images as $path) {
$relPath = translatePathToRelIMG($path);
$deletepath = $_SERVER['PHP_SELF'] . "?delete=" . $path;
$availableImgs .= "<div class='popupImgs' style='width:200px;display: inline-block;margin:0 10px'>";
$availableImgs .= "<a class='destthumb' href='#imgModal' data-toggle='modal' data-relimg-url='{$relPath}' data-img-url='{$path}'><img width='200' height='auto' src='{$path}' /></a>";
$availableImgs .= "<div style='word-break:break-all;font-size:11px'>{$path}</div><a href='{$deletepath}' onclick='return confirm(\"Borrar Imagen?\")'><span class='glyphicon glyphicon-remove ' style='color:red'></span></a></div>";
}
$_SESSION['destacados_folderimages'] = $images;
?>
<!doctype html>
<html>
<head>