示例#1
0
function findfile($path, $pattern)
{
    $result = null;
    $path = rtrim(str_replace("\\", "/", $path), '/') . '/*';
    foreach (glob($path) as $fullname) {
        if (is_dir($fullname)) {
            $result = findfile($fullname, $pattern);
            if ($result) {
                break;
            }
        } else {
            if (preg_match($pattern, $fullname)) {
                $result = $fullname;
                break;
            }
        }
    }
    return $result;
}
示例#2
0
function findfile($location, $fileregex)
{
    if (!$location or !is_dir($location) or !$fileregex) {
        return false;
    }
    $matchedfiles = array();
    $all = opendir($location);
    while ($file = readdir($all)) {
        if (is_dir($location . '/' . $file) and $file != ".." and $file != ".") {
            $subdir_matches = findfile($location . '/' . $file, $fileregex);
            $matchedfiles = array_merge($matchedfiles, $subdir_matches);
            unset($file);
        } elseif (!is_dir($location . '/' . $file)) {
            if (preg_match($fileregex, $file)) {
                //array_push($matchedfiles,$location.'/'.$file);
                array_push($matchedfiles, $file);
            }
        }
    }
    closedir($all);
    unset($all);
    return $matchedfiles;
}
示例#3
0
/**
 * 根据名称在目录下查找文件
 * @param string $pattern 匹配规则
 * @param string $dir 搜索目标根目录
 * @return array
 */
function findfile($pattern, $dir = __ROOT__)
{
    $dir = trim($dir, '/\\') . DS;
    if (!is_dir($dir)) {
        return error('dir ' . $dir . ' not exists');
    }
    $pattern = '*' . trim($pattern, '*') . '*';
    $matches = glob($dir . $pattern);
    $children_dir = glob($dir . '*', GLOB_ONLYDIR);
    $matches = array_diff($matches, $children_dir);
    foreach ($children_dir as $children_dir) {
        $matches = array_merge($matches, findfile($pattern, $children_dir));
    }
    return $matches;
}
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: file_php.inc.php 79 2012-04-16 10:06:12Z wangbin $
 */
(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) && exit('Access Denied');
if (submitcheck('templatesubmit') || submitcheck('attsubmit') || submitcheck('staticsubmit') || submitcheck('othersubmit')) {
    $filelist = '';
    if ($_GET['templatesubmit']) {
        findfile('./template', array('php'));
    } elseif ($_GET['attsubmit']) {
        findfile('./data/attachment', array('php'));
    } elseif ($_GET['staticsubmit']) {
        findfile('./static', array('php'));
    } elseif ($_GET['othersubmit']) {
        findfile('./data', array('php'), array('attachment', 'template', 'threadcache', 'request', 'cache', 'log', 'plugindata'));
    }
}
showformheader("plugins&cp=file_php&pmod=safe&operation={$operation}&do={$do}&identifier={$identifier}");
showtipss($toolslang['file_phptip']);
showtableheaders($toolslang['file_php']);
showsubmit('templatesubmit', 'submit', $toolslang['template_php']);
showsubmit('attsubmit', 'submit', $toolslang['attachment_php']);
showsubmit('staticsubmit', 'submit', $toolslang['static_php']);
showsubmit('othersubmit', 'submit', $toolslang['other_php']);
showtablefooter();
if (is_array($filelist) && count($filelist) > 0) {
    showtableheader($toolslang['file_php_result']);
    showsubtitle(array('', $toolslang['file_path']));
    foreach ($filelist as $value) {
        showtablerow('', array(), array('', realpath($value)));
示例#5
0
function findfile($dir,$ext = array(),$remove = array()) {
	global $filelist;
	$fp = opendir($dir);
	while($entry = readdir($fp)) {
		
		if (in_array($entry,$remove)) {
			continue;
		}
		$fulldir = str_replace('.//','./',$dir.'/'.$entry);
		if($entry != '.' && $entry != '..' && is_dir($fulldir)) {
			findfile($fulldir,$ext,$remove);
		} elseif(in_array(get_ex($entry),$ext)) {
			$filelist[] = $fulldir;
		}
	}
}
示例#6
0
文件: menu.php 项目: stain/scrapbook
<?php

include_once "utils.php";
$url = "http://www.soiland.no/frames_with_css/";
global $SCRIPT_FILENAME;
foreach (findfile('.', '/.php$/') as $file) {
    $file = preg_replace("/.php\$/", "", $file);
    $file = preg_replace(",.*/,", "", $file);
    if ($file == "index") {
        continue;
    }
    $name = ucfirst($file);
    $name = preg_replace("/_/", " ", $name);
    if (preg_match("/{$file}/", $SCRIPT_FILENAME)) {
        echo "<a class='current' href='{$url}{$file}'>{$name}</a>\n";
    } else {
        echo "<a href='{$url}{$file}'>{$name}</a>\n";
    }
}
示例#7
0
function findFileRowsForUser($endDir, $username)
{
    // $endDir = pdf-assessment-reports | pdf-action-plans | etc
    // username = WP username, ie 'slaven'
    if ($username == '') {
        $username = '******';
    }
    // don't want to return everything if username is blank
    $basePath = '/var/www/osnap.org/public_html/';
    $webDir = 'wp-content/themes/osnap.1.0/';
    $path = $basePath . $webDir . $endDir;
    // return any file ending in pdf if user name passed is all-users
    if ($username == 'all-users') {
        $username = '';
    }
    $fileEnd = '/^' . $username . '.*\\.(pdf)$/';
    $fileList = findfile($path, $fileEnd);
    if ($endDir == 'pdf-assessment-reports') {
        $spanClass = 'delete-AR-pdf';
    } else {
        $spanClass = 'delete-AP-pdf';
    }
    foreach ($fileList as &$file) {
        echo '<tr><td>';
        echo '<a href="/' . $webDir . $endDir . '/' . $file . '">' . $file . '</a>';
        echo '<span class="' . $spanClass . ' btn" id="' . $file . '"><i class="icon-trash"></i></span>';
        echo '</td></tr>';
    }
}
示例#8
0
 function image($word)
 {
     $width =& $this->width;
     $height =& $this->height;
     // Create the Image
     $jpg = ImageCreate($width, $height);
     $bg = ImageColorAllocate($jpg, 255, 255, 255);
     $tx = ImageColorAllocate($jpg, 185, 140, 140);
     ImageFilledRectangle($jpg, 0, 0, $width, $height, $bg);
     $x = rand(0, $width);
     $y = rand(0, $height);
     $this->spiral($jpg, $x, $y, $width - 25, 190, 190);
     $x = rand(10, 30);
     $y = rand(50, $height - 20);
     //50-60
     // randomize the chars
     for ($i = 0; $i < strlen($word); $i++) {
         $angle += rand(-5, 5);
         if ($angle > 25) {
             $angle = 15;
         } elseif ($angle < -25) {
             $angle = -15;
         }
         $size = rand(14, 20);
         $y += rand(-10, 10);
         if ($y < 10) {
             $y = 11;
         } elseif ($y > $height - 10) {
             $y = $height - 11;
         }
         $x += rand($size, $size * 2);
         imagettftext($jpg, $size, $angle, $x, $y, $tx, realpath(findfile("lib/captcha/Vera.ttf")), $word[$i]);
     }
     $x = rand(0, $width + 30);
     $y = rand(0, $height + 35);
     // 115
     $this->spiral($jpg, $x, $y, 255, 190, 190);
     imageline($jpg, 0, 0, $width - 1, 0, $tx);
     imageline($jpg, 0, 0, 0, $height - 1, $tx);
     imageline($jpg, 0, $height - 1, $width - 1, $height - 1, $tx);
     imageline($jpg, $width - 1, 0, $width - 1, $height - 1, $tx);
     if (function_exists("ImageJpeg")) {
         header("Content-type: image/jpeg");
         ImageJpeg($jpg);
     } elseif (function_exists("ImagePNG")) {
         header("Content-type: image/png");
         ImagePNG($jpg);
     } elseif (function_exists("ImageGIF")) {
         header("Content-type: image/gif");
         ImageGIF($jpg);
     } else {
         trigger_error("missing GD bitmap support", E_USER_WARNING);
     }
 }