当前位置: 首页>>代码示例>>PHP>>正文


PHP get_files函数代码示例

本文整理汇总了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;
    }
}
开发者ID:alanhaggai,项目名称:plogger,代码行数:32,代码来源:plog-admin-functions.php

示例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;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:33,代码来源:Language.class.php

示例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>";
    }
开发者ID:lynncyr,项目名称:rrrewind,代码行数:30,代码来源:sitemap.php

示例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>';
}
开发者ID:nopuls,项目名称:dzcp,代码行数:29,代码来源:motm.php

示例5: down

 public function down()
 {
     $filenames = get_files(Config::get('log_dir'));
     foreach ($filenames as $filename) {
         unlink($filename);
     }
     rmdir(Config::get('log_dir'));
 }
开发者ID:utumdol,项目名称:codeseed,代码行数:8,代码来源:create_log_directory.class.php

示例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";
         }
     }
 }
开发者ID:dariogs,项目名称:moosh,代码行数:57,代码来源:DataStats.php

示例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));
     }
 }
开发者ID:Tapac,项目名称:hotscot,代码行数:13,代码来源:FilesystemHelperTest.php

示例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;
}
开发者ID:Coyotejld,项目名称:buildfiles,代码行数:12,代码来源:comparedirs.php

示例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();
}
开发者ID:MrWnn,项目名称:cacti,代码行数:14,代码来源:rrdcleaner.php

示例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);
 }
开发者ID:Tapac,项目名称:hotscot,代码行数:22,代码来源:css.php

示例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>';
}
开发者ID:nopuls,项目名称:dzcp,代码行数:17,代码来源:random_gallery.php

示例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();
     }
 }
开发者ID:johnulist,项目名称:PHP-Library,代码行数:55,代码来源:files.php

示例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;
     }
 }
开发者ID:lynncyr,项目名称:rrrewind,代码行数:18,代码来源:site.php

示例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();
    //}
}
开发者ID:sergelg90,项目名称:sasweb,代码行数:18,代码来源:repo-v0v1.php

示例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);
 }
开发者ID:bjornbjorn,项目名称:devkit.ee_addon,代码行数:44,代码来源:mcp.devkit.php


注:本文中的get_files函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。