本文整理汇总了PHP中get_files函数的典型用法代码示例。如果您正苦于以下问题:PHP get_files函数的具体用法?PHP get_files怎么用?PHP get_files使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_files函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_files
function get_files($directory)
{
// Try to open the directory
if ($dir = opendir($directory)) {
// Create an array for all files found
$tmp = array();
// Add the files
while ($file = readdir($dir)) {
// Make sure the file exists
if ($file != "." && $file != ".." && $file[0] != '.') {
// If it's a directiry, list all files within it
if (is_dir($directory . "/" . $file)) {
$tmp2 = get_files($directory . "/" . $file);
if (is_array($tmp2)) {
$tmp = array_merge($tmp, $tmp2);
}
} else {
if (is_readable($directory . "/" . $file)) {
$filename = basename(stripslashes($file));
$pi = pathinfo($file);
if (is_allowed_extension($pi["extension"])) {
array_push($tmp, $directory . "/" . $file);
}
}
}
}
}
// Finish off the function
closedir($dir);
return $tmp;
}
}
示例2: getTranslationFiles
/**
* Return array of translation files
*
* @param void
* @return array
*/
function getTranslationFiles()
{
if ($this->translation_files === false) {
$this->translation_files = array();
$localization_path = $this->getLocalizationPath();
$localization_path_len = strlen($localization_path);
$files = get_files($localization_path, 'php');
if (is_foreachable($files)) {
foreach ($files as $path) {
$file = substr($path, $localization_path_len + 1);
if (!str_starts_with($file, 'module.')) {
continue;
}
// if
$this->translation_files[] = substr($file, 7, strlen($file) - 11);
}
// foreach
}
// if
if (count($this->translation_files) < 1) {
$this->translation_files = null;
}
// if
}
// if
return $this->translation_files;
}
示例3: index
function index()
{
$domains = get_domains();
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc><?php
echo site_url();
?>
</loc><priority>1</priority></url><?php
//foreach domain
foreach ($domains as $domain) {
//if not a separator
if ($domain['type'] != 'separator') {
//get files
$files = get_files($domain['webname']);
foreach ($files as $file) {
//get rid off extension
$file = str_replace("." . $domain['type'], "", $file);
//extract segments
$date = extract_feed_date($file, $domain['webname']);
//make url
$url = site_url($domain['webname'] . '/' . $date['y'] . '/' . $date['m'] . '/' . $date['d']);
//display URL tag
echo '<url><loc>' . $url . '</loc></url>';
}
}
}
echo "</urlset>";
}
示例4: motm
function motm()
{
global $db, $allowHover;
$userpics = get_files(basePath . '/inc/images/uploads/userpics/');
$qry = db("SELECT * FROM " . $db['users'] . " WHERE level >= 2");
while ($rs = _fetch($qry)) {
foreach ($userpics as $userpic) {
$tmpId = intval($userpic);
if ($tmpId == $rs['id']) {
$temparr[] = $rs['id'];
$a++;
break;
}
}
}
$arrayID = rand(0, count($temparr) - 1);
$uid = $temparr[$arrayID];
$get = _fetch(db("SELECT * FROM " . $db['users'] . " WHERE id = '" . $uid . "'"));
if (!empty($get) && !empty($temparr)) {
$status = $get['status'] == 1 || $get['level'] == 1 ? _aktiv : _inaktiv;
if ($allowHover == 1) {
$info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . rawautor($get['id']) . '</td></tr><tr><td width=80px><b>' . _posi . ':</b></td><td>' . getrank($get['id']) . '</td></tr><tr><td><b>' . _status . ':</b></td><td>' . $status . '</td></tr><tr><td><b>' . _age . ':</b></td><td>' . getAge($get['bday']) . '</td></tr><tr><td colspan=2 align=center>' . jsconvert(userpic($get['id'])) . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
}
$member = show("menu/motm", array("uid" => $get['id'], "upic" => userpic($get['id'], 130, 161), "info" => $info));
} else {
$member = '';
}
return empty($member) ? '' : '<table class="navContent" cellspacing="0">' . $member . '</table>';
}
示例5: down
public function down()
{
$filenames = get_files(Config::get('log_dir'));
foreach ($filenames as $filename) {
unlink($filename);
}
rmdir(Config::get('log_dir'));
}
示例6: execute
public function execute()
{
global $CFG, $DB;
$options = $this->expandedOptions;
$dataroot = run_external_command("du -s {$CFG->dataroot}", "Couldn't find dataroot directory");
$pattern = '/\\d*/';
preg_match($pattern, $dataroot[0], $matches);
$filedir = run_external_command("du -s {$CFG->dataroot}/filedir", "Couldn't find filedir directory");
preg_match($pattern, $filedir[0], $dir_matches);
$sql_query = "SELECT SUM(filesize) AS total FROM {files}";
$all_files = $DB->get_record_sql($sql_query);
$sql_query = "SELECT DISTINCT contenthash, SUM(filesize) AS total FROM {files}";
if (is_a($DB, 'pgsql_native_moodle_database')) {
$sql_query .= " GROUP BY contenthash";
$distinct_contenthash = $DB->get_records_sql($sql_query);
$total = 0;
foreach ($distinct_contenthash as $k => $v) {
$total += $v->total;
}
$distinctfilestotal = $total;
} else {
$distinct_contenthash = $DB->get_record_sql($sql_query);
$distinctfilestotal = $distinct_contenthash->total;
}
$filesbycourse = array();
if ($courses = get_all_courses()) {
foreach ($courses as $course) {
$subcontexts = get_sub_context_ids($course->ctxpath);
$filesbycourse[$course->id] = array('unique' => 0, 'all' => 0);
foreach ($subcontexts as $subcontext) {
if ($files = get_files($subcontext->id)) {
foreach ($files as $file) {
$filesbycourse[$course->id]['unique'] += file_is_unique($file->contenthash, $subcontext->id) ? $file->filesize : 0;
$filesbycourse[$course->id]['all'] += $file->filesize;
}
}
}
}
}
$sortarray = higher_size($filesbycourse);
$backups = backup_size();
$data = array('dataroot' => $matches[0], 'filedir' => $dir_matches[0], 'files total' => $all_files->total, 'distinct files total' => $distinctfilestotal);
foreach ($sortarray as $courseid => $values) {
$data["Course {$courseid} files total"] = strval($values['all']);
$data["Course {$courseid} files unique"] = strval($values['unique']);
}
foreach ($backups as $key => $values) {
$data["Backup {$values->username}"] = strval($values->backupsize);
}
if ($options['json']) {
echo json_encode($data);
} else {
foreach ($data as $k => $v) {
echo "{$k}: " . display_size($v) . "\n";
}
}
}
示例7: testScandir
/**
* test getting a list of all of a certain file from a directory
*/
public function testScandir()
{
$files = get_files(SITE_ROOT . 'htdoc/css/', 'css', true);
// assert we have files back
$this->assertArrayCountGreaterThanOrEqual($files, 1);
// assert each file is a file and exists
foreach ($files as $file) {
$this->assertTrue(is_file($file));
}
}
示例8: find_removed_files
function find_removed_files($newPath, $oldPath)
{
$ret = array();
$newFiles = get_files($newPath);
$oldFiles = get_files($oldPath);
foreach ($oldFiles as $of) {
if (!in_array($of, $newFiles)) {
$ret[] = $of;
}
}
return $ret;
}
示例9: rrdclean_fill_table
function rrdclean_fill_table()
{
global $config, $rra_path;
/* suppress warnings */
error_reporting(0);
/* install the rrdclean error handler */
set_error_handler('rrdclean_error_handler');
/* delete old file names table */
rrdclean_truncate_tables();
get_files();
clearstatcache();
/* restore original error handler */
restore_error_handler();
}
示例10: generate
/**
* used in dev and to generate the final css, this scans a directory and created one css file
*
* @return void
* @author Craig Ulliott
*/
public function generate()
{
$files = get_files(SITE_ROOT . 'htdoc/css/', 'css');
// we arrange our files alphabetically to determine the order css is generated
sort($files);
// we bring all the css in and parse it as php, so output buffering is the best means to capture the output
ob_start();
foreach ($files as $css_file) {
// get and parse stylesheet
include $css_file;
}
$css = ob_get_contents();
//clean up
ob_end_clean();
v('content/text/css', $css);
}
示例11: random_gallery
function random_gallery()
{
global $db;
$imgArr = array();
$files = get_files('../gallery/images/');
$get = _fetch(db("SELECT * FROM " . $db['gallery'] . " ORDER BY RAND()"));
foreach ($files as $file) {
if (intval($file) == $get['id']) {
array_push($imgArr, $file);
}
}
shuffle($imgArr);
if (!empty($imgArr[0])) {
$gallery = show("menu/random_gallery", array("image" => $imgArr[0], "id" => $get['id'], "kat" => re($get['kat'])));
}
return empty($gallery) ? '' : '<table class="navContent" cellspacing="0">' . $gallery . '</table>';
}
示例12: getFiles
/**
* Retrieve all files in a specified directory
* @param <string> $folder Directory path to search for files
* @param <boolean> $includeSubs (optional) TRUE if sub directories should be included
* @return <array> List of files retrieved
* @category Files
* <code>
* $result = Files::getFiles('C:/xampp/', TRUE);
* </code>
*/
function getFiles($folder, $includeSubs = FALSE)
{
try {
// Remove any trailing slash
if (substr($folder, -1) == '/') {
$folder = substr($folder, 0, -1);
}
// Make sure a valid folder was passed
if (!file_exists($folder) || !is_dir($folder) || !is_readable($folder)) {
return FALSE;
exit;
}
// Grab a file handle
$allFiles = FALSE;
if ($handle = opendir($folder)) {
$allFiles = array();
// Start looping through a folder contents
while ($file = @readdir($handle)) {
// Set the full path
$path = $folder . '/' . $file;
// Filter out this and parent folder
if ($file != '.' && $file != '..') {
// Test for a file or a folder
if (is_file($path)) {
$allFiles[] = $path;
} elseif (is_dir($path) && $includeSubs) {
// Get the subfolder files
$subfolderFiles = get_files($path, TRUE);
// Anything returned
if ($subfolderFiles) {
$allFiles = array_merge($allFiles, $subfolderFiles);
}
}
}
}
// Cleanup
closedir($handle);
}
// Return the file array
@sort($allFiles);
return $allFiles;
} catch (Exception $err) {
return $err->getMessage();
}
}
示例13: _get_previous_feed
function _get_previous_feed($domains, $webname, $date)
{
//get files of this site
$files = get_files($webname);
$result = false;
if ($files) {
$count = count($files) - 1;
//count -1 because last file because it doesnt has a previous file
//files loop
for ($i = 0; $i < $count; $i++) {
if ($files[$i] == $webname . $date['y'] . $date['m'] . $date['d'] . "." . $domains[$webname]['type']) {
$result = $files[$i + 1];
//get the previous
}
}
return $result;
}
}
示例14: repo_update
function repo_update()
{
if (!is_dir('pool')) {
mkdir('pool', 0777);
}
$files = get_files('pool_old');
$i = 0;
foreach ($files as $file) {
copy_to_pool($file);
apk_icon($file);
$i++;
}
echo "{$i}: Aplicaiones Agregadas\n";
//update_from_pool();
//if (!isset($params['dir']) && $params['update']) {
// update_from_pool();
//}
}
示例15: sync_globals
function sync_globals()
{
$this->EE->load->helper('devkit_helper');
$vars = array();
$vars['performed'] = array();
if ($this->EE->config->item('save_tmpl_files') == 'y') {
$tmpl_basepath = $this->EE->config->slash_item('tmpl_file_basepath') . $this->EE->config->slash_item('site_short_name');
if ($tmpl_basepath != $this->EE->config->slash_item('site_short_name') && file_exists($tmpl_basepath)) {
$global_variables = get_files($tmpl_basepath . 'global_variables/');
$snippets = get_files($tmpl_basepath . 'snippets/');
foreach ($global_variables as $global_variable_filename) {
$this->EE->db->where('variable_name', $global_variable_filename);
$this->EE->db->from('global_variables');
$global_variable_data = file_get_contents($tmpl_basepath . 'global_variables/' . $global_variable_filename);
if ($this->EE->db->count_all_results() == 0) {
$this->EE->db->insert('global_variables', array('variable_name' => $global_variable_filename, 'variable_data' => $global_variable_data));
$vars['performed'][] = 'Inserted <strong>global_variable</strong> <em>' . $global_variable_filename . "</em>";
} else {
$this->EE->db->where('variable_name', $global_variable_filename);
$this->EE->db->update('global_variables', array('variable_data' => $global_variable_data));
$vars['performed'][] = 'Updated <strong>global_variable</strong> <em>' . $global_variable_filename . "</em>";
}
}
foreach ($snippets as $snippet_filename) {
$this->EE->db->like('snippet_name', $snippet_filename);
$this->EE->db->from('snippets');
$snippet_data = file_get_contents($tmpl_basepath . 'snippets/' . $snippet_filename);
if ($this->EE->db->count_all_results() == 0) {
$this->EE->db->insert('snippets', array('snippet_name' => $snippet_filename, 'snippet_contents' => $snippet_data));
$vars['performed'][] = 'Inserted <strong>snippet</strong> <em>' . $snippet_filename . "</em>";
} else {
$this->EE->db->where('snippet_name', $snippet_filename);
$this->EE->db->update('snippets', array('snippet_contents' => $snippet_data));
$vars['performed'][] = 'Updated <strong>snippet</strong> <em>' . $snippet_filename . "</em>";
}
}
} else {
show_error('Template basepath not defined - or not found (' . $tmpl_basepath . ')');
}
} else {
show_error('Save templates as files must be set to Yes in Global Template Preferences');
}
return $this->content_wrapper('sync', 'dev_sync_globals', $vars);
}