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


PHP getfiles函数代码示例

本文整理汇总了PHP中getfiles函数的典型用法代码示例。如果您正苦于以下问题:PHP getfiles函数的具体用法?PHP getfiles怎么用?PHP getfiles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getfiles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: do_handle

 public function do_handle()
 {
     $allowFiles = substr(str_replace(".", "|", join("", $this->allowFiles)), 1);
     /* 获取参数 */
     $size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $this->listSize;
     $start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
     $end = $start + $size;
     /* 获取文件列表 */
     $path = $_SERVER['DOCUMENT_ROOT'] . (substr($this->path, 0, 1) == "/" ? "" : "/") . $path;
     $files = getfiles($path, $allowFiles);
     if (!count($files)) {
         return json_encode(array("state" => "no match file", "list" => array(), "start" => $start, "total" => count($files)));
     }
     /* 获取指定范围的列表 */
     $len = count($files);
     for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--) {
         $list[] = $files[$i];
     }
     //倒序
     //for ($i = $end, $list = array(); $i < $len && $i < $end; $i++){
     //    $list[] = $files[$i];
     //}
     /* 返回数据 */
     $result = json_encode(array("state" => "SUCCESS", "list" => $list, "start" => $start, "total" => count($files)));
     return $result;
 }
开发者ID:AlusaChen,项目名称:test-lar,代码行数:26,代码来源:ListImages.php

示例2: smarty_function_randphoto

function smarty_function_randphoto($_params, &$_smarty)
{
    $bgdir = $_params['pageinfo']->cssdir . '/bgs/';
    $bgfiles = getfiles($bgdir);
    $filenum = rand(0, count($bgfiles) - 1);
    return $_params['pageinfo']->cssurl . '/bgs/' . $bgfiles[$filenum];
}
开发者ID:bcipolli,项目名称:website-old-php,代码行数:7,代码来源:function.randphoto.php

示例3: sadmindeleteitem

function sadmindeleteitem($id)
{
    global $module_filepath, $Q, $DB, $module_name;
    $query = "SELECT * FROM " . $module_name . " where rid=" . $id;
    $Q->query($DB, $query);
    $count = $Q->numrows();
    $recs = "";
    for ($i = 0; $i < $count; $i++) {
        $row = $Q->getrow();
        $recs[$i] = $row[id];
    }
    for ($i = 0; $i < $count; $i++) {
        sadmindeleteitem($recs[$i]);
    }
    // ATTACHMENTS
    $ppath = $module_filepath . "/attachments/" . $id . "/";
    $mas = getfiles($ppath);
    if ($mas[0] != "") {
        for ($j = 0; $j < count($mas); $j++) {
            unlink($ppath . $mas[$j]);
        }
    }
    $query = "DELETE from " . $module_name . " WHERE id=" . $id;
    //echo $query."<br>";
    $Q->query($DB, $query);
}
开发者ID:pioytazsko,项目名称:drell,代码行数:26,代码来源:_delete.php

示例4: getfiles

/**
 * 遍历获取目录下的指定类型的文件
 * @param $path
 * @param array $files
 * @return array
 */
function getfiles($path, $allowFiles, &$files = array())
{
    global $_M;
    if (!is_dir($path)) {
        return null;
    }
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $handle = opendir($path);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $path2 = $path . $file;
            if (is_dir($path2)) {
                getfiles($path2, $allowFiles, $files);
            } else {
                if (preg_match("/\\.(" . $allowFiles . ")\$/i", $file)) {
                    $url = str_replace(PATH_WEB, $_M['url']['site'], $path2);
                    if (!strstr($url, 'thumb_dis/') && !strstr($url, 'thumb/') && !strstr($url, 'watermark/') && !strstr($url, 'upload/_thumbs/') && !strstr($url, 'upload/thumb_src/') && !strstr($url, 'upload/files/') && !strstr($url, 'upload/images/')) {
                        $files[] = array('url' => $url, 'mtime' => filemtime($path2));
                    }
                }
            }
        }
    }
    return $files;
}
开发者ID:nanfs,项目名称:lt,代码行数:33,代码来源:action_list.php

示例5: smarty_function_randphoto

function smarty_function_randphoto($_params, &$_smarty)
{
    $pageinfo = $_smarty->tpl_vars['pageinfo']->value;
    $bgdir = $pageinfo['cssdir'] . '/bgs/';
    $bgfiles = getfiles($bgdir);
    $filenum = rand(0, count($bgfiles) - 1);
    return $pageinfo['cssurl'] . '/bgs/' . $bgfiles[$filenum];
}
开发者ID:bcipolli,项目名称:website-old-php,代码行数:8,代码来源:function.randphoto.php

示例6: copyallfiles

function copyallfiles($dirfrom, $dirto)
{
    $filesfrom = getfiles($dirfrom);
    if (!$filesfrom) {
        return 0;
    }
    for ($i = 0; $i < count($filesfrom); $i++) {
        $file1 = $dirfrom . "/" . $filesfrom[$i];
        $file2 = $dirto . "/" . $filesfrom[$i];
        copy($file1, $file2);
        //	echo "$file1 $file2<br>";
    }
    echo "<p>";
}
开发者ID:pioytazsko,项目名称:drell,代码行数:14,代码来源:_copyto.php

示例7: getfiles

function getfiles($dir, &$files = array())
{
    if (!file_exists($dir) || !is_dir($dir)) {
        return;
    }
    if (substr($dir, -1) == '/') {
        $dir = substr($dir, 0, strlen($dir) - 1);
    }
    $_files = scandir($dir);
    foreach ($_files as $v) {
        if ($v != '.' && $v != '..') {
            if (is_dir($dir . '/' . $v)) {
                getfiles($dir . '/' . $v, $files);
            } else {
                $files[] = $dir . '/' . $v;
            }
        }
    }
    return $files;
}
开发者ID:vb2005xu,项目名称:automake-apk-php,代码行数:20,代码来源:markapk.php

示例8: getfiles

/**
 * 遍历获取目录下的指定类型的文件
 * @param  	 $path
 * @param  	 array $files
 * @return 	 array
 */
function getfiles($path, &$files = array())
{
    if (!is_dir($path)) {
        return null;
    }
    $handle = opendir($path);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $path2 = $path . '/' . $file;
            if (is_dir($path2)) {
                getfiles($path2, $files);
            } else {
                if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) {
                    $files[] = $path2;
                }
            }
        }
    }
    return $files;
}
开发者ID:PoppyLi,项目名称:PCMS,代码行数:26,代码来源:file_helper.php

示例9: getfiles

/**
 * 遍历获取目录下的指定类型的文件
 * @param $path
 * @param array $files
 * @return array
 */
function getfiles($path, $allowFiles, $APPCONFIG, &$files = array())
{
    if (!is_dir($path)) {
        return null;
    }
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $handle = opendir($path);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $path2 = $path . $file;
            if (is_dir($path2)) {
                getfiles($path2, $allowFiles, $APPCONFIG, $files);
            } else {
                if (preg_match("/\\.(" . $allowFiles . ")\$/i", $file)) {
                    $files[] = array('url' => $APPCONFIG['sys_images_domain'] . substr($path2, strlen($APPCONFIG['sys_upload_path'])), 'mtime' => filemtime($path2));
                }
            }
        }
    }
    return $files;
}
开发者ID:mikegit2014,项目名称:laravelback,代码行数:29,代码来源:action_list.php

示例10: getfiles

/**
 * 遍历获取目录下的指定类型的文件
 * @param $path
 * @param array $files
 * @return array
 */
function getfiles($path, $allowFiles, &$files = array())
{
    if (!is_dir($path)) {
        return null;
    }
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $handle = opendir($path);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            $path2 = $path . $file;
            if (is_dir($path2)) {
                getfiles($path2, $allowFiles, $files);
            } else {
                if (preg_match("/\\.(" . $allowFiles . ")\$/i", $file)) {
                    $files[] = array('url' => substr($path2, strlen($_SERVER['DOCUMENT_ROOT'])), 'mtime' => filemtime($path2));
                }
            }
        }
    }
    return $files;
}
开发者ID:heroshadow,项目名称:shop,代码行数:29,代码来源:action_list.php

示例11: getfiles_pictures

$pic = "images/pic.jpg";
if (file_exists("attachments/" . $_GET[id] . "/big.jpg")) {
    $pic = "attachments/" . $_GET[id] . "/big.jpg";
}
if (file_exists("attachments/" . $_GET[id] . "/1.jpg")) {
    $pic = "attachments/" . $_GET[id] . "/1.jpg";
}
$small_pics = "";
$pics = getfiles_pictures("attachments/" . $_GET[id] . "/");
for ($i = 0; $i < count($pics); $i++) {
    if (!ereg("big\\.jpg", $pics[$i]) && ereg("[0-9]+", $pics[$i]) && $pics[$i] != "1.jpg") {
        $small_pics .= "\n\t\t<tr valign='top'>\n\t\t\t<td class='vtable'><a href='/attachments/" . $_GET[id] . "/" . $pics[$i] . "' alt='" . $product[name] . "' title='" . $product[name] . "' rel='lightbox[images]'><img src='shortimage.php?path=attachments--" . $_GET[id] . "--" . $pics[$i] . "&x=41&y=41' border='0'/></a></td>\n\t\t</tr>\n\t\t";
    }
}
$instruction = "";
$files = getfiles("attachments/" . $_GET[id] . "/");
for ($i = 0; $i < count($files); $i++) {
    $ext = split("\\.", $files[$i]);
    $ext = $ext[count($ext) - 1];
    if ($ext == "pdf") {
        $instruction = "/attachments/" . $_GET[id] . "/" . $files[$i];
    }
}
?>
<td valign="top">
 	  <table id="Table2" width="100%"  border="0" cellpadding="0"  cellspacing="0"><tr height="1px" valign="top"><td  align="left" style="padding-left:20px;padding-top:10px; padding-right:25px;">
		<table id="Table" width="100%"  border="0" cellpadding="0"  cellspacing="0">
			<tr height="1px" valign="middle">
			<td style="padding-top:5px;"><p style="margin:0px;padding-top:10px;"></p><h1 class="nobottomed"><?php 
echo $product[name];
?>
开发者ID:pioytazsko,项目名称:drell,代码行数:31,代码来源:_new_center_product.php

示例12: getparams

<?php

// version 1.03, 12/03/2012;
// example usage: gallery.php?start=14&len=12
require 'common.php';
getparams();
$status = getdirs();
if ($status == 0) {
    print "directory \"{$archive_dir}\" not found<br>";
    exit;
}
getfiles();
header('content-type: text/html; charset=utf-8');
echo "<html><head><title>" . date("Y M d H:i:s", ftime($working_dir . "/" . $files[$start])) . "</title></head><body>";
navigation_top();
navigation_bottom();
// Gallery
echo "<p>";
if ($start > sizeof($files)) {
    $start = sizeof($files) - 1;
}
$last = $start + $len;
if ($last >= sizeof($files)) {
    $last = sizeof($files) - 1;
}
for ($count = $start; $count <= $last; $count++) {
    $filename = $files[$count];
    $smallname = $thumbdir . "/" . $filename;
    $smallname_abs = $root_dir . "/" . $smallname;
    if (file_exists($smallname_abs)) {
        echo "<a href='image.php?cam={$cam}&img={$filename}&dir={$dir}&i={$count}'><img src='" . $smallname . "' title='" . date("H:i:s", ftime($working_dir . "/" . $filename)) . "'></a> ";
开发者ID:jnavarroc,项目名称:mobilewebcam-serverside,代码行数:31,代码来源:gallery.php

示例13: preg_replace

    $wp = $_GET["whatpage"];
    $wp = preg_replace("/..\\//i", "", $wp);
    $myFile = ENGINE . 'news/' . $wp;
}
#$myFile=ENGINE.'newsdb.php';
$commentFile = ENGINE . 'commentsdb.php';
$newsperpage = 30;
//Список файлов в каталоге
function getfiles($inpath)
{
    if (sizeof($dir = scandir($inpath, 1)) > 1) {
        array_splice($dir, -2, 2);
    }
    return $dir;
}
$filesnews = getfiles(ENGINE . 'news/');
foreach ($filesnews as $file) {
    $file = basename($file, 'php');
    $all_files .= "|&nbsp;&nbsp;<a href=\"?whatpage={$file}\"> {$file}</a>&nbsp;&nbsp;|";
}
if (file_exists($myFile)) {
    //Запись
    if (!empty($_REQUEST['action'])) {
        $news = file($myFile);
        $countallnews = count($news);
        if ($edit > 0) {
            $new = unserialize($news[$edit - 1]);
            @($adminemail = $new['admmail']);
            @($idmess = $new['id']);
            @($time = $new['pubtime']);
            $head = filtermessage($_REQUEST['header']);
开发者ID:porese,项目名称:kandidat-cms,代码行数:31,代码来源:news.php

示例14: Array

fileIds=new Array();
<?php 
if (isset($id) && $id != "undefined") {
    $e = "";
    $filelink = "";
    $query = "select * from " . $module_name . " where lang='{$lang}' and aname='material'";
    $Q->query($DB, $query);
    $count = $Q->numrows();
    $ids[0] = $id;
    for ($i = 1; $i <= $count; $i++) {
        $row = $Q->getrow();
        $ids[$i] = $row[id];
    }
    for ($uy = 0; $uy <= $count; $uy++) {
        echo "fileIds[" . $ids[$uy] . "]=" . $uy . ";\n";
        $mas = getfiles($module_filepath . "/attachments/" . $ids[$uy] . "/");
        if ($mas[0] != "") {
            for ($i = 0; $i < count($mas); $i++) {
                $ppath[$i] = $module_filepath . "/attachments/" . $ids[$uy] . "/";
                $ppath[$i] = $ppath[$i] . $mas[$i];
            }
            //	$e[0]='<p><a class=\"filelink\"  id=\"ff0\" style=\"height:22px; margin:0px 0px 0px 0px;\" href=\"#\" onClick=\"javascript:highlight(\\\'ff0\\\');fileLink(\\\'..\\\');\" title=\"URL: #\"><img src=\"../../images/spacer.gif\" width=1 height=22 alt=\"\" border=\"0\" align=\"absmiddle\">..</a></p>';
            for ($i = 0; $i < count($mas); $i++) {
                $filesize = ceil(filesize($ppath[$i]) / 1000);
                $ext = split("\\.", mystrtohigher($mas[$i]));
                $ext = $ext[count($ext) - 1];
                $ext1 = strtolower($ext);
                $ext1 = ereg_replace("jpeg", "jpg", $ext1);
                $emp = "";
                if ($filesize > 0) {
                    if ($ext == "JPG" || $ext == "JPEG" || $ext == "GIF") {
开发者ID:pioytazsko,项目名称:drell,代码行数:31,代码来源:hyperlink.php

示例15: fopen

    $f = fopen($file, "r");
    $ln = 0;
    while (!feof($f)) {
        $line = fgets($f);
        ++$ln;
        //        echo $ln."\r\n";
        if ($line === FALSE) {
            print "FALSE\n";
        } elseif (contains($line, "scenarios (")) {
            $text = $line;
        }
    }
    fclose($f);
    return $text;
}
getfiles($dir);
//echo $body;
for ($i = 0; $i < count($result); $i++) {
    $temp = preg_replace("/.html/", "", $result[$i]);
    $temp = @split("_", $temp);
    $date[$i] = $temp[0];
    $app[$i] = $temp[1];
    $pt[$i] = $temp[2];
    $v[$i] = $temp[3];
}
for ($i = 0; $i < count($fullpath); $i++) {
    $text = Readlog($fullpath[$i]);
    $temp = @split("=", $text);
    //var_dump($temp);
    $find = "scenarios";
    $findLen = strlen($find);
开发者ID:emilymwang8,项目名称:applogplatform,代码行数:31,代码来源:report.php


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