コード例 #1
0
ファイル: index.php プロジェクト: jputz12/OneNow-Vshop
function loadDir($path)
{
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." and $file != "..") {
                //skip . and ..
                if (is_file($path . '/' . $file)) {
                    $tmpFile = trim($file);
                    $ext = pathinfo($file, PATHINFO_EXTENSION);
                    $File = pathinfo($file, PATHINFO_FILENAME);
                    $valid_exts = array('jpeg', 'JPEG', 'jpg', 'JPG', 'png', 'PNG', 'gif', 'GIF');
                    $sizes = array('f' => 45, 't' => 92, 's' => 120, 'm' => 225, 'l' => 300);
                    //required sizes in WxH ratio
                    if (in_array($ext, $valid_exts)) {
                        // if file is image then process it!
                        foreach ($sizes as $w => $h) {
                            $image = new Imagick();
                            $image->readImage($path . '/' . $tmpFile);
                            $imgWidth = $image->getImageWidth();
                            $imgHeight = $image->getImageHeight();
                            $image->resizeImage($h, $h, Imagick::FILTER_LANCZOS, 1);
                            // resize from array sizes
                            $fileName .= $File . '_' . $w . '.' . $ext;
                            //create the image filaname
                            $image->writeImage($path . '/' . $fileName);
                            $tempFileName = $path . '/' . $fileName;
                            $arrayfiles[] = $tempFileName;
                            $custWidth = $image->getImageWidth();
                            $custHeight = $image->getImageHeight();
                            echo "[ Original dimension : {$imgWidth} x {$imgHeight} ] [ Custom dimension : {$custWidth} x {$custHeight} ] Output image location: <a href='{$tempFileName}' style='text-decoration:none'> " . $tempFileName . "</a>&nbsp;&nbsp;";
                            echo "<img class='img' src='{$tempFileName}' /></br>";
                            $w = '';
                            $h = '';
                            $fileName = '';
                            $image->clear();
                            $image->destroy();
                        }
                        //end foreach sizes
                    }
                }
                if (is_dir($path . '/' . $file)) {
                    echo '</br> <div style="height:0;width:1200px;border:0;border-bottom:2px;border-style: dashed;border-color: #000000"></div><span style="font-weight:bold; font-size:14px; color:red ">Directory Name: ';
                    echo $path . "/" . $file;
                    echo '</span><div style="height:0;width:1200px;border:0;border-bottom:2px;border-style: dashed;border-color: #000000"></div></br>';
                    loadDir($path . '/' . $file);
                }
            }
        }
        // end while
    }
    // end handle
}
コード例 #2
0
ファイル: autoload.php プロジェクト: r0mdau/passwo
function autoload()
{
    loadDir(__DIR__ . '/class/');
}
コード例 #3
0
ファイル: loaddir-old.php プロジェクト: jyyy410team/hts
    		{
    			echo "修改文件失败";
    		}
    	}
    	else 
    	{
    		echo "貌似不能使用修改功能";
    	}*/
}
//字符转换
function ubb($str)
{
    $str = str_replace("<", "&lt;", $str);
    $str = str_replace(">", "&gt;", $str);
    return $str;
}
//具体操作
if (!$action) {
    loadDir("..");
} elseif ($action == "edit") {
    readFiles($urlStr);
} elseif ($action == "doedit") {
    editFiles($urlStr);
} else {
    loadDir($fileName);
}
?>
</table>
</div>
</body>
</html>
コード例 #4
0
function autoload()
{
    require_once __DIR__ . '/settings.php';
    loadDir(__DIR__ . '/core/');
}
コード例 #5
0
ファイル: FunctionsBase.php プロジェクト: neil-chen/NeilChen
/**
 * 加载某个目录下的php文件
 */
function loadDir($dir) {
	$dir = realpath ( $dir );
	$h = @opendir ( $dir );
	if (! $h) {
		return;
	}
	while ( false !== ($file = readdir ( $h )) ) {
		if (substr ( $file, 0, 1 ) == '.' || strtolower ( substr ( $file, - 3, 3 ) ) != 'php') {
			continue;
		}

		$realFile = $dir . '/' . $file;

		if (is_file ( $realFile )) {
			include_once $realFile;
		} else if (is_dir ( $realFile )) {
			loadDir ( $realFile );
		}
	}
	closedir ( $h );
}
コード例 #6
0
function loadDirOLD($dir)
{
    $dirContent = array();
    // Dir content
    $dirContent['SIZE'] = 0;
    // Initialize structure
    $dirContent['DIRS'] = array();
    $dirContent['FILES'] = array();
    if (!file_exists('wfio://' . $dir)) {
        // Check if dir exists
        return $dirContent;
    }
    $files = scandir('wfio://' . $dir);
    // Scan directory
    if (is_array($files)) {
        // Files/Directoris found
        foreach ($files as $fileName) {
            if ($fileName == '.' || $fileName == '..') {
                // Skip home and previous listings
                continue;
            }
            if (is_dir('wfio://' . $dir . '/' . $fileName)) {
                // Process directory
                $dirContent['DIRS'][$fileName] = array();
                // Init new dir structure
                $subDirContent = loadDir($dir . '/' . $fileName);
                // Load subdir data
                $dirContent['DIRS'][$fileName] = $subDirContent;
                // Store subdir data
                $dirContent['SIZE'] += $subDirContent['SIZE'];
                // Add subdir size to total size
            } else {
                $stat = stat('wfio://' . $dir . '/' . $fileName);
                // Load stat for file
                $dirContent['FILES'][$fileName] = $stat['size'];
                // Store file and it's size
                $dirContent['SIZE'] += $stat['size'];
                // Add file's size to total size
            }
        }
    }
    return $dirContent;
    // Return Dir content
}