本文整理汇总了PHP中directoryToArray函数的典型用法代码示例。如果您正苦于以下问题:PHP directoryToArray函数的具体用法?PHP directoryToArray怎么用?PHP directoryToArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了directoryToArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: directoryToArray
/**
* Get an array that represents directory tree
*
* from http://php.net/manual/en/function.scandir.php
* @param string $directory Directory path
* @param bool $recursive Include sub directories
* @param bool $listDirs Include directories on listing
* @param bool $listFiles Include files on listing
* @param regex $exclude Exclude paths that matches this regex
*/
function directoryToArray($directory, $recursive = true, $listDirs = false, $listFiles = true, $exclude = '')
{
$arrayItems = array();
$skipByExclude = false;
$handle = opendir($directory);
if ($handle) {
while (false !== ($file = readdir($handle))) {
preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git|md))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $file, $skip);
if ($exclude) {
preg_match($exclude, $file, $skipByExclude);
}
if (!$skip && !$skipByExclude) {
if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {
if ($recursive) {
$arrayItems = array_merge($arrayItems, directoryToArray($directory . DIRECTORY_SEPARATOR . $file, $recursive, $listDirs, $listFiles, $exclude));
}
if ($listDirs) {
$file = $directory . DIRECTORY_SEPARATOR . $file;
$arrayItems[] = $file;
}
} else {
if ($listFiles) {
$file = $directory . DIRECTORY_SEPARATOR . $file;
$arrayItems[] = $file;
}
}
}
}
closedir($handle);
}
return $arrayItems;
}
示例2: tt_add_jscss
function tt_add_jscss()
{
if (!is_admin()) {
wp_deregister_script('jquery');
}
if (defined('WPCF7_VERSION')) {
wp_deregister_style('contact-form-7');
}
if (defined('QTX_VERSION')) {
wp_deregister_style('qtranslate-style');
}
if (defined('GOOGLEMAPS')) {
wp_enqueue_script('googlemaps', '//maps.googleapis.com/maps/api/js?v=3.exp&language=en&key=AIzaSyAO77hGcvxmsvOn1RSjDFQMI4YUnW89MDo', false, null, false);
}
wp_enqueue_script('jquery', get_stylesheet_directory_uri() . '/js/libs/_jquery.js', false, null, false);
if ($js_lib = directoryToArray(get_stylesheet_directory(), '/js/libs/', array('js'))) {
foreach ($js_lib as $name => $js) {
wp_enqueue_script($name, $js, array('jquery'), null, true);
}
}
wp_enqueue_script('libs', get_stylesheet_directory_uri() . '/js/lib.js', array('jquery'), null, true);
wp_enqueue_script('logic', get_stylesheet_directory_uri() . '/js/logic.js', array('libs'), null, true);
wp_enqueue_style('libs', get_stylesheet_directory_uri() . '/style/elements/libs.css');
wp_enqueue_style('scss', get_stylesheet_directory_uri() . '/style/style.css');
if (class_exists('Woocommerce')) {
wp_enqueue_style('custom-woo', get_stylesheet_directory_uri() . '/style/woo.css');
}
}
示例3: tt_add_jscss
function tt_add_jscss()
{
if (!is_admin()) {
wp_deregister_script('jquery');
}
if (defined('WPCF7_VERSION')) {
wp_deregister_style('contact-form-7');
}
if (defined('QTX_VERSION')) {
wp_deregister_style('qtranslate-style');
}
if (defined('GOOGLEMAPS')) {
wp_enqueue_script('googlemaps', '//maps.googleapis.com/maps/api/js?key=' . GOOGLEMAPS, false, null, false);
}
wp_enqueue_script('jquery', get_stylesheet_directory_uri() . '/js/libs/_jquery.js', false, null, false);
if ($js_lib = directoryToArray(get_stylesheet_directory(), '/js/libs/', array('js'))) {
foreach ($js_lib as $name => $js) {
wp_enqueue_script($name, $js, array('jquery'), null, true);
}
}
wp_enqueue_script('libs', get_stylesheet_directory_uri() . '/js/lib.js', array('jquery'), null, true);
wp_enqueue_script('init', get_stylesheet_directory_uri() . '/js/init.js', array('libs'), null, true);
if ($style_lib = directoryToArray(get_stylesheet_directory(), '/style/libs/', array('css', 'scss'))) {
foreach ($style_lib as $name => $lib) {
wp_enqueue_style($name, $lib);
}
}
wp_enqueue_style('main', get_stylesheet_directory_uri() . '/style/style.scss');
if (class_exists('Woocommerce')) {
wp_enqueue_style('custom-woo-styles', get_stylesheet_directory_uri() . '/style/woo.scss');
wp_enqueue_script('custom-woo-scripts', get_stylesheet_directory_uri() . '/js/woo.js', false, null, true);
}
wp_enqueue_style('responsive', get_stylesheet_directory_uri() . '/style/rwd.scss');
}
示例4: directoryToArray
function directoryToArray($directory, $onlyFiles = false, $originalDirectory = '', $recursive = true)
{
$originalDirectory = $originalDirectory == '' ? $directory : $originalDirectory;
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory . "/" . $file)) {
if ($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $onlyFiles, $originalDirectory, $recursive));
}
//$file = $directory . "/" . $file;
if (!$onlyFiles) {
$file = str_replace($originalDirectory, '', $directory) . "/" . $file;
$array_items[] = preg_replace("/\\/\\//si", "/", $file);
}
} else {
//$file = $directory . "/" . $file;
$file = str_replace($originalDirectory, '', $directory) . "/" . $file;
$array_items[] = preg_replace("/\\/\\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
示例5: directoryToArray
function directoryToArray($directory, $recursive, $inspector, $folder_nou)
{
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory . "/" . $file)) {
if ($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $recursive, $inspector, $folder_nou));
}
} else {
$file = $directory . "/" . $file;
$file = preg_replace("/\\/\\//si", "/", $file);
$size = filesize($file) / 1024;
$play = getAudioFilePlayTime($inspector, $file);
rename($file, $folder_nou . basename($file));
$file = str_replace("/home1/tineretp/www", "http://74.220.207.111/~tineretp/", $file);
$array_items[] = array("path" => $file, "size" => $size, "play_time" => $play);
}
}
}
closedir($handle);
}
return $array_items;
}
示例6: get_templates
function get_templates()
{
$tpldir_array = array();
$tpldir_path = SITE_ROOT . 'template';
$tpldir_array = directoryToArray($tpldir_path, false, true, false);
foreach ($tpldir_array as $key => $value) {
$tpldir_array[$key] = str_ireplace($tpldir_path, '', $value);
$tpldir_array[$key] = str_ireplace(array('\\', '/'), '', $tpldir_array[$key]);
}
return $tpldir_array;
}
示例7: directoryToArray
function directoryToArray($directory, $extension = "", $full_path = true)
{
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory . "/" . $file)) {
$array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $extension, $full_path));
} else {
if (!$extension || ereg("." . $extension, $file)) {
$array_items[] = $file;
}
}
}
}
closedir($handle);
}
return $array_items;
}
示例8: directoryToArray
function directoryToArray($directory, $recursive)
{
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'Thumbs.db' && $file != 'error_log') {
if (is_dir($directory . '/' . $file)) {
if ($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory . '/' . $file, $recursive));
}
} else {
$file = $directory . '/' . $file;
$array_items[] = preg_replace('/\\/\\//si', '/', $file);
}
}
}
closedir($handle);
}
return $array_items;
}
示例9: directoryToArray
function directoryToArray($directory, $recursive)
{
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory . "/" . $file)) {
if ($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory . "/" . $file, $recursive));
}
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\\/\\//si", "/", $file);
} else {
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\\/\\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
示例10: get_static_db_file_from_storage
function get_static_db_file_from_storage ($db_file_name) {
global $db_storage_folder;
global $read_only_folder;
global $tempfs_work_folder;
global $static_db_file_pattern;
$valid_db_file = null;
// get file list from Storage location.
$db_file_list = directoryToArray($db_storage_folder,false,false,true,$static_db_file_pattern);
// sort the list so that the newest files come first
arsort ($db_file_list);
// try to open files in starting with the newest. If a valid db file is found then it is used.
foreach ($db_file_list as $file) {
if (verify_sqlite_file($file)) // file found
{
//error_log ( "This file is good! <br />");
$valid_db_file = $file;
break;
}
// try to open file
}
// valid DB file found? Yes- nice; No - Take from Read Only storage.
if ($valid_db_file == null) $valid_db_file = $read_only_folder . $db_file_name;
error_log ("using file " . $valid_db_file);
// copy file to tempfs
if (!copy($valid_db_file, $tempfs_work_folder . $db_file_name )) {
error_log ( "failed to copy $file...\n");
}
}
示例11: checkEventFilesForKey
function checkEventFilesForKey($keyCheckString)
{
global $eventDirectory;
$keyExist = false;
$eventFiles = array();
$eventFiles = directoryToArray($eventDirectory, false);
foreach ($eventFiles as $eventFile) {
if (strpos(file_get_contents($eventFile), $keyCheckString) !== false) {
// do stuff
$keyExist = true;
break;
// return $keyExist;
}
}
return $keyExist;
}
示例12: getThumbnails
/**
* get array of thumbnails and info
* @param string $upload_path the upload sub path
* @param string $type optional thumbnail type eg thumbsm, thumbnail to filter by
* @param string $filename optional filename to filter
* @param boolean $recurse optional true: recurse into subdirectories
* @return array assoc array with thumbnail attributes
*/
function getThumbnails($upload_path = '', $type = '', $filename = '', $recurse = false)
{
$thumbs_array = array();
$files = directoryToArray(GSTHUMBNAILPATH . tsl($upload_path), $recurse);
foreach ($files as $file) {
$split = strpos(basename($file), '.');
$thumbtype = substr(basename($file), 0, $split);
$origfile = substr(basename($file), $split + 1);
if (!empty($filename) && $filename !== $origfile) {
continue;
}
if (empty($thumbtype) || !empty($type) && $type !== $thumbtype) {
continue;
}
// debugLog('thumbnail ' . $file);
$thumb = getimagesize($file);
$thumb['width'] = $thumb[0];
unset($thumb[0]);
$thumb['height'] = $thumb[1];
unset($thumb[1]);
$thumb['type'] = $thumb[2];
unset($thumb[2]);
$thumb['attrib'] = $thumb[3];
unset($thumb[3]);
$thumb['uploadpath'] = tsl(getRelPath($upload_path, GSTHUMBNAILPATH));
$thumb['primaryfile'] = GSDATAUPLOADPATH . $thumb['uploadpath'] . $origfile;
$thumb['filesize'] = filesize($file);
$thumb['primaryurl'] = getUploadURI($origfile, $thumb['uploadpath']);
$thumb['thumbfile'] = getThumbnailFile(basename($file), $upload_path, '');
$thumb['thumburl'] = getThumbnailURI(basename($file), $upload_path, '');
$thumb['thumbtype'] = $thumbtype;
$thumbs_array[$upload_path . basename($file)] = $thumb;
}
return $thumbs_array;
}
示例13: date
<?php
require 'lib/bk_zip.php';
/* include zip lib */
require 'lib/bk_db.php';
/*include export code lib*/
$name_zip_file .= date("j-n-Y");
/* get date now */
$name_zip_file .= '-user.zip';
$files_to_zip = directoryToArray('../public_html', true);
/*Export DB*/
backup_tables('db_host', 'user_db', 'user_db_pass', 'db_name');
/*Zip file*/
$result = create_zip($files_to_zip, $name_zip_file);
/*Transfer file via FTP */
$server = 'IP FTP';
$ftp_user_name = "Username FTP";
$ftp_user_pass = "Password FTP";
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) {
die('Connection attempt failed!');
}
$upload = ftp_put($connection, $name_zip_file, $name_zip_file, FTP_ASCII);
if (!$upload) {
echo 'FTP upload failed!';
}
ftp_close($connection);
/*Delete file zip and sql after backup*/
$files_db = glob("*.sql");
foreach ($files_db as $file_db) {
示例14: directoryToArray
<link rel="alternate" type="application/rss+xml" title="<?php
echo $config['team'];
?>
Releases RSS Feed" href="rss.xml" />
<link rel="shortcut icon" href="design/favicon.ico" />
<title><?php
echo $config['team'];
?>
Release Portal</title>
</head>
<body>
<div id="contentwrapper">
<div id="banner">
<?php
$bannersListe = directoryToArray('design/banners');
//Récupère la liste des bannières
$rand = mt_rand(0, count($bannersListe) - 1);
//Choisir une bannière au hasard
echo '<img src="', $bannersListe[$rand], '" alt="banniere" />';
unset($bannersListe, $rand);
?>
</div>
<div id="menu">
<ul>
<li><a href="index.php?crk=releases&spg=1">[ Latest Releases ]</a></li>
<li><a href="index.php?crk=search">[ Search Database ]</a></li>
<li><a href="index.php?crk=about">[ About <?php
echo $config['accro'];
?>
示例15: createTemplateDropdown
function createTemplateDropdown()
{
global $template;
# create themes dropdown
$theme_options = '<select name="theme-folder" id="theme-folder" >';
$templates = directoryToArray(GSTHEMESPATH, false);
$theme_dir_array = array();
foreach ($templates as $file) {
if (is_dir($file)) {
// only a theme if GSTEMPLATEFILE (template.php) exists
if (file_exists($file . '/' . GSTEMPLATEFILE)) {
$sel = "";
$theme_dir_array[] = $file;
$theme = basename($file);
if ($template == $theme) {
$sel = "selected";
}
$theme_options .= '<option ' . $sel . ' value="' . $theme . '" >' . $theme . '</option>';
}
}
}
// edit theme/root files
if (getDef('GSTHEMEEDITROOT', true)) {
$theme_options .= '<option value="." style="font-style:italic">' . i18n_r('THEME_ROOT') . '</option>';
}
$theme_options .= '</select> ';
# check to see how many themes are available
if (count($theme_dir_array) == 1) {
$theme_options = '';
}
return $theme_options;
}