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; }
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; }
function findAllFiles($paths) { $dirs = allDirs($paths); $files = array(); foreach ($dirs as $dir) { $files = array_merge($files, findFiles($dir)); } return $files; }
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); }
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]; } } } }
/** * 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; }
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;
<?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>
$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 = '';
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); }
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; }
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); } }
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); }
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;
} } 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>
<p>This request is missing custom parameters to configure which tool you would like to select to run on this system. You Learning Management system can set these custom parameters as key/value pairs. </p> </div> <p> While each tool hosted in this system may have its own custom parameters here are some of the parameters that you might need to use. <ul> <li> <b>assn=mod/pythonauto/auto.php</b> - the <b>assn</b> parameter selects which tool to run in the system.</li> <li> <b>exercise=3.3</b> - For the pythonauto tool, use this custom parameter to select the exercise.</li> <li> <b>done=_close</b> - Some tools have a "Done" button. If this is a URL when the user presses "Done" within the tool they will be sent to the URL. If this is "_close" the window will be closed - this makes the most sense if the original launch was a popup window. If this parameter is omitted, no "Done" button will be shown - this is useful if the tool is launched in an iframe.</li> </ul> <p> <?php $tools = findFiles(); if (count($tools) > 1) { echo "<p>Tools in this system:</p><ul>\n"; foreach ($tools as $tool) { echo "<li>" . htmlent_utf8($tool) . "</li>\n"; } echo "</ul>\n"; } $OUTPUT->footer();
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); } else { $dir = @$_SESSION['display.dir']; $dircount = @$_SESSION['display.dircount']; $previous = @$_SESSION['display.previous']; if (strlen($dir) <= 0 || file_exists($dir)) { $dir = newDir($settings['photo.dirs']); $dircount = 0; } $files = findFiles($dir); if ($dircount > $settings['photo.max_from_dir'] || $dircount >= count($files)) { $tries = 0; do { $dir = newDir($settings['photo.dirs']); $dircount = 0; $files = findFiles($dir); } while ((count($files) <= 0 || $previousDir == $dir) && $tries++ < 100); } do { $file = $files[rand(0, count($files) - 1)]; } while ($file == $previous && count($files) > 1); $dircount++; $_SESSION['display.dir'] = $dir; $_SESSION['display.dircount'] = $dircount; $_SESSION['display.previous'] = $file; } $width = $_REQUEST['width']; $height = $_REQUEST['height']; // Info string $info = ''; if ($settings['photo.show_filename']) {
public function preFill() { $this->guzzleclient = new Guzzle\Service\Client('http://loripsum.net/api/'); $output = ""; // get a list of images.. $this->images = findFiles('', 'jpg,jpeg,png'); foreach ($this->config['contenttypes'] as $key => $contenttype) { $amount = isset($contenttype['prefill']) ? $contenttype['prefill'] : 5; for ($i = 1; $i <= $amount; $i++) { $output .= $this->preFillSingle($key, $contenttype); } } $output .= "\n\nDone!"; return $output; }
<?php use App\Metacom\Metacom; //Autoload classes. require __DIR__ . '/../vendor/autoload.php'; if (isset($argv[1])) { switch ($argv[1]) { case "-extract": findFiles(); break; case "-compare": compare(); break; case "-update": compare(true); break; case "-generate": generate(); break; default: break; } } else { echo "Welcome to Metacom: The PHP comment framework! \n"; } function findFiles() { $path = realpath(getcwd()); $it = new RecursiveDirectoryIterator($path); $display = array('php', 'html'); $metacom = new Metacom();
// // // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## // // Do not add trailing slash '/' $directory = "."; // This key must match the key spesified in your flash recorder ez publish object. // If they don't match no files will be returned. // IMPORTANT: Change the key (here and in your flash recorder object) from the // default key if you do not want people to be able to retreive the file list. $key = "ThisIsTheDefaultKeyChangeMe"; $limit = 10; if (isset($_GET["key"]) === false || $_GET['key'] != $key) { return; } $files = findFiles($directory); // Output the list one file pr line $counter = 0; foreach ($files as $file) { if ($counter < $limit) { echo $file . "\n"; } else { break; } $counter++; } // Find all files in $directory with $fileExtension as their extension. // This function will not look for files recursively. // Returns an array of filenames sorted by mtime (modified), newest first. function findFiles($directory, $fileExtension = '.flv') {
/** * Build image DB * * @param bool $purge * @param bool $tidy * @param string $dir * @return bool */ public function buildDatabase($purge = false, $tidy = false, $dir = '') { $dir = !empty($dir) ? $dir : $this->_manage_root . '/' . $this->_sub_dir; findFiles($file_array, $dir); if (($existing = $GLOBALS['db']->select('CubeCart_filemanager', array('filename', 'filepath'), false, array('filename' => 'ASC'))) !== false) { foreach ($existing as $file) { $exists[] = $file['filepath'] . $file['filename']; } } if ($file_array) { foreach ($file_array as $key => $file) { if (!is_dir($file)) { // Skip existing entries, and sources/thumbs if (isset($exists) && in_array(str_replace(array($this->_manage_root . '/', 'source/'), '', $file), $exists)) { continue; } $newfilename = $this->makeFilename($file); $oldfilename = basename($file); if ($newfilename !== $oldfilename) { // rename file so we match up $new_path = str_replace($oldfilename, $newfilename, $file); if (!rename($file, $new_path)) { trigger_error("Failed to rename file from '{$oldfilename}' to '{$newfilename}'.", E_USER_WARNING); } else { $file = $new_path; } } $filepath_record = $this->formatPath(str_replace($this->_manage_root, '', dirname($file))); $filepath_record = empty($filepath_record) ? 'NULL' : $filepath_record; $filepath_record = str_replace(chr(92), "/", $filepath_record); $record = array('type' => (int) $this->_mode, 'filepath' => $filepath_record, 'filename' => $newfilename, 'filesize' => filesize($file), 'mimetype' => $this->getMimeType($file), 'md5hash' => md5_file($file)); // Hash comparison check $checkhash = $GLOBALS['db']->select('CubeCart_filemanager', array('file_id'), array('type' => $this->_mode, 'md5hash' => $record['md5hash'], 'filepath' => $record['filepath']), false, 1); if (!$checkhash) { $GLOBALS['db']->insert('CubeCart_filemanager', $record); $updated = true; } else { if ($tidy) { unlink($file); } } } } } // Remove orphaned records if (($existing = $GLOBALS['db']->select('CubeCart_filemanager', false, array('type' => $this->_mode))) !== false) { foreach ($existing as $file) { if ($file['file_id'] > 0 && !file_exists($this->_manage_root . '/' . $file['filepath'] . $file['filename'])) { $GLOBALS['db']->delete('CubeCart_filemanager', array('file_id' => (int) $file['file_id'])); $updated = true; } } } if (isset($updated) && $updated === true) { return true; } }
function compile_java() { if (!is_dir('bin')) { mkdir('bin'); } if (!is_dir('bin/classes')) { mkdir('bin/classes'); } $files = array(); findFiles('src', $files); findFiles('gen', $files); $cmd_str = 'javac -encoding utf8 -target ' . $this->java_version . ' -bootclasspath ' . $this->boot_class_path . ' -d bin/classes'; 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; }
/* * This file is part of the Behat * * (c) Konstantin Kudryashov <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ $filename = 'mink_extension.phar'; if (file_exists($filename)) { unlink($filename); } $phar = new \Phar($filename, 0, 'extension.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); foreach (findFiles('src') as $path) { $phar->addFromString($path, file_get_contents(__DIR__ . '/' . $path)); } $phar->addFromString('init.php', file_get_contents(__DIR__ . '/init.php')); $phar->setStub(<<<STUB <?php /* * This file is part of the Behat * * (c) Konstantin Kudryashov <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */
function get($name = '') { $data = array(); $files = findFiles($name . '.php'); foreach ($files as $view) { $section = $this->getSection($view); $data[$section] = View::do_fetch($view, $this->vars); } return $data; }
* @package MediaWiki * @subpackage Maintenance * @author Rob Church <*****@*****.**> */ require_once 'commandLine.inc'; require_once 'importImages.inc.php'; echo "Import Images\n\n"; # Need a directory and at least one extension if (count($args) > 1) { $dir = array_shift($args); # Check the allowed extensions while ($ext = array_shift($args)) { $exts[] = ltrim($ext, '.'); } # Search the directory given and pull out suitable candidates $files = findFiles($dir, $exts); # Set up a fake user for this operation $wgUser = User::newFromName('Image import script'); $wgUser->setLoaded(true); # Batch "upload" operation foreach ($files as $file) { $base = basename($file); # Validate a title $title = Title::makeTitleSafe(NS_IMAGE, $base); if (is_object($title)) { # Check existence $image = new Image($title); if (!$image->exists()) { global $wgUploadDirectory; # copy() doesn't create paths so if the hash path doesn't exist, we # have to create it
/** * Find files * * @param array $list * @param string $path * @param bool $recursive */ function findFiles(&$list, $path = false, $recursive = true) { $path .= substr($path, -1) == '/' ? '' : '/'; if (file_exists($path)) { $files = glob($path . '*', GLOB_MARK); foreach ($files as $file) { if (is_dir($file) && $recursive) { if (preg_match('#(source|thumbs)[\\\\/]$#', $file)) { continue; } findFiles($list, $file, $recursive); } else { $list[] = $file; } } } }
} $fullPath = "{$prefix}/{$file}"; if (is_dir($fullPath)) { $answer += findfiles($fullPath, $fullPath); } else { $answer[] = $fullPath; } } return $answer; } $baseUrl = "http://" . $_SERVER["HTTP_HOST"]; $latest = findFiles("./latest", "latest"); $numLatest = count($latest); $inTests = findFiles("./tests", "tests"); $numInTests = count($inTests); $releases = findFiles("./releases", "releases"); $numReleases = count($releases); ?> <html> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <title>Umple Releases</title> </head> <body> <div class="container"> <div class="row"> <div class="col-md-6"> <h2>Latest Build (<?php
} } 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['cruzrojatv_img_folder'], $ext = array("png", "gif", "jpg")); //krumo($images); $availableImgs = ""; foreach ($images as $path) { $relPath = translatePathToRelIMG($path); $availableImgs .= "<div style='width:164px;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='auto' height='auto' src='{$path}' /></a>"; $availableImgs .= "<div style='word-break:break-all;font-size:11px'>{$path}</div></div>"; } $_SESSION['cruztv_folderimages'] = $images; ?> <!doctype html> <html> <head> <meta charset="utf-8">