本文整理汇总了PHP中is_dir_empty函数的典型用法代码示例。如果您正苦于以下问题:PHP is_dir_empty函数的具体用法?PHP is_dir_empty怎么用?PHP is_dir_empty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_dir_empty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: iterate
function iterate($path)
{
$array_dir = @scandir($path);
@asort($array_dir);
foreach ($array_dir as $value) {
if (is_dir($value) && strcmp($value, ".") && strcmp($value, "..")) {
if (!is_dir_empty($value)) {
chdir($value);
parse();
iterate(getcwd(), $value);
chdir("..");
}
}
}
}
示例2: deleteDirectory
function deleteDirectory($path)
{
$newpath = "";
$dir = explode('/', $path);
$flag = "";
ksort($dir);
$newdir = $dir;
foreach ($dir as $d) {
$x = count($newdir);
if (is_array($newdir) and $x > 1) {
$newpath = implode('/', $newdir);
} else {
$newpath = $d;
}
if (is_dir($newpath)) {
if (is_dir_empty($newpath)) {
$y = rmdir($newpath);
if ($y) {
$flag .= "Dir Deleted : " . $newpath . "\n";
} else {
$flag .= "Failed to Deleted: " . $newpath . "\n";
}
}
}
if ($x > 1) {
$newdir = array_pop($newdir);
}
}
return $flag;
}
示例3: error_reporting
<?php
error_reporting(0);
@ini_set('cgi.fix_pathinfo', 1);
if (is_dir($_POST['directory']) && !is_dir_empty($_POST['directory'])) {
echo 1;
} else {
echo 0;
}
function is_dir_empty($dir)
{
if (!is_readable($dir)) {
return null;
}
$handle = opendir($dir);
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
return false;
}
}
return true;
}
exit;
示例4: readTxt2
function readTxt2()
{
//อ่านค่าจาก textfile เข้า db script udp
//Check if any file at the files folder
$dir = "/var/www/html/web/readfile/files";
if (is_dir_empty($dir)) {
echo "the folder is empty, Please upload text file before process";
die;
}
//end check files
if ($handle = opendir('/var/www/html/web/readfile/files')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
//test entry
//echo " $entry\n";
//die($entry);
//===read file to make sql
$tmp_file = $entry;
$i = 1;
//$text[]=$entry;
$handle1 = fopen("/var/www/html/web/readfile/files/" . $tmp_file, "rw");
if ($handle1) {
while (($line = fgets($handle1)) !== false) {
// process the line read.
preg_match('/<IP>(.*?)<\\/IP>/isu', $line, $ip);
// find ip
preg_match('/<DATE>(.*?)<\\/DATE>/isu', $line, $date);
//find time
preg_match('/<BOX>(.*?)<\\/BOX>/isu', $line, $box);
// find ip
if (preg_match("/00000000 /", $line)) {
//1
$port1 = "Off";
$port2 = "Off";
$port3 = "Off";
$port4 = "Off";
} elseif (preg_match("/00000001 /", $line)) {
//2
$port1 = "On";
$port2 = "Off";
$port3 = "Off";
$port4 = "Off";
} elseif (preg_match("/00000010 /", $line)) {
//3
$port1 = "Off";
$port2 = "On";
$port3 = "Off";
$port4 = "Off";
} elseif (preg_match("/00000011 /", $line)) {
//4
$port1 = "On";
$port2 = "On";
$port3 = "Off";
$port4 = "Off";
} elseif (preg_match("/00000100 /", $line)) {
//5
$port1 = "Off";
$port2 = "Off";
$port3 = "On";
$port3 = "On";
$port4 = "Off";
} elseif (preg_match("/00000110 /", $line)) {
//7
$port1 = "Off";
$port2 = "On";
$port3 = "On";
$port4 = "Off";
} elseif (preg_match("/00000111 /", $line)) {
//8
$port1 = "On";
$port2 = "On";
$port3 = "On";
$port4 = "Off";
} elseif (preg_match("/00001000 /", $line)) {
//9
$port1 = "Off";
$port2 = "Off";
$port3 = "Off";
$port4 = "On";
} elseif (preg_match("/00001001 /", $line)) {
//10
$port1 = "On";
$port2 = "Off";
$port3 = "Off";
$port4 = "On";
} elseif (preg_match("/00001010 /", $line)) {
//11
$port1 = "Off";
$port2 = "On";
$port3 = "Off";
$port4 = "On";
} elseif (preg_match("/00001011 /", $line)) {
//12
$port1 = "On";
$port2 = "On";
$port3 = "Off";
$port4 = "On";
} elseif (preg_match("/00001100 /", $line)) {
//13
$port1 = "Off";
//.........这里部分代码省略.........
示例5: changeprofilepic
protected function changeprofilepic()
{
global $rep, $view;
$data = array();
if (isset($_POST['changeprofilepic'])) {
$data['uploadfile'] = NULL;
if ($_FILES['picturefile']['name'] != NULL) {
$usr = $_SESSION['username'];
///check error upload
if ($_FILES['picturefile']['error'] > 0) {
if ($_FILES['picturefile']['error'] == UPLOAD_ERR_FORM_SIZE) {
$data['uploadfile'] = 'The file must not be bigger than 5mo.';
} else {
$data['uploadfile'] = 'The upload failed. Please try again, if this persists, contact the admin.';
}
//setup the error code
}
$valid_extensions = array('jpg', 'jpeg', 'gif', 'png');
$extension_upload = strtolower(substr(strrchr($_FILES['picturefile']['name'], '.'), 1));
if (!in_array($extension_upload, $valid_extensions)) {
$data['uploadfile'] = 'The extension isn\'t valid. The picture must be a jpg, jpeg, gig or png file.';
//setup the error code
}
/// end check error upload
/// check error move
$uploaddir = './images/users/' . $usr . '/';
//create the directory of theprofile pic
if (!is_dir($uploaddir)) {
mkdir($uploaddir, 0777, true);
}
//give this image a random name (for multiple images)
$temp = explode(".", $_FILES["picturefile"]["name"]);
$newfilename = round(microtime(true)) . '.' . end($temp);
$uploadfile = $uploaddir . $newfilename;
if (file_exists($uploadfile)) {
$data['uploadfile'] = 'Error during the upload. Please try again, if this persists, contact the admin.';
//setup the error code
} elseif (!move_uploaded_file($_FILES['picturefile']['tmp_name'], $uploadfile)) {
//if error moving file
if (is_dir_empty($uploaddir)) {
rmdir($uploaddir);
}
//remove the directory IF NOT EMPTY
$data['uploadfile'] = 'Error during the upload. Please try again, if this persists, contact the admin.';
//setup the error code
}
if ($data['uploadfile'] == NULL) {
if ($_SESSION['profilepic'] != 'images/users/default.jpg') {
unlink($_SESSION['profilepic']);
}
$_SESSION['profilepic'] = $uploadfile;
userModel::changepicUser($usr, $newfilename);
}
} else {
$data['uploadfile'] = 'Please select a picture!';
}
}
require_once $view['manageaccount'];
}
示例6: foreach
}
}
// Delete any checked folders
if (isset($_POST['deletefolder'])) {
foreach ($_POST['deletefolder'] as $delthis => $val) {
$safefolder = str_replace(array('../', '..\\', './', '.\\'), '', urldecode($_POST['actionfolder'][$delthis]));
if ($typenow == 'image') {
$delthisthumbdir = $_SESSION['tinybrowser']['docroot'] . $dirpath . $safefolder . '_thumbs/';
verify_dir($delthisthumbdir, $typenow);
if (is_dir($delthisthumbdir)) {
@rmdir($delthisthumbdir);
}
}
$delthisdir = $_SESSION['tinybrowser']['docroot'] . $dirpath . $safefolder;
verify_dir($delthisdir);
if (file_exists($delthisdir) && is_dir_empty($delthisdir) && is_dir($delthisdir) && @rmdir($delthisdir)) {
$deleteqty++;
} else {
$errorqty++;
}
if ($foldernow == urldecode($_POST['actionfolder'][$delthis])) {
$foldernow = '';
$passfolder = '';
}
}
}
// Rename any folders with changed name
if (isset($_POST['renamefolder'])) {
foreach ($_POST['renamefolder'] as $namethis => $newname) {
$urlparts = explode('/', rtrim(urldecode($_POST['actionfolder'][$namethis]), '/'));
$safefolder = str_replace(array('../', '..\\', './', '.\\'), '', urldecode($_POST['actionfolder'][$namethis]));
示例7: foreach
contact/inquire/<?php
echo $typeId;
?>
" class="btn btn-primary">Inquire</a></p>
</div>
</div>
<?php
}
$this->load->helper('directory');
$urls = "admin/uploads/Products/Attachments/";
foreach ($allProducts as $prod_id => $prod_name) {
?>
<?php
$catalogue = false;
if (!is_dir_empty($urls . $prod_id)) {
$catalogue = true;
$map = directory_map($urls . $prod_id);
}
?>
<div class="row">
<input class="contentSearch" type="hidden" value="<?php
echo $prod_name;
?>
" />
<div class="col-md-3" style="text-align: center">
<a href="#">
<img class="img-responsive onesidedropshadow prod_img" src="<?php
echo $base_url;
?>
admin/uploads/products/<?php
示例8: is_dir_empty
if ($action == "edit") {
echo $row_sponsors['sponsorURL'];
}
?>
" placeholder="">
<span id="helpBlock" class="help-block">Be sure to include the full website URL including the http://</span>
</div>
</div><!-- ./Form Group -->
<div class="form-group"><!-- Form Group NOT REQUIRED Select -->
<label for="contestLogo" class="col-lg-2 col-md-3 col-sm-4 col-xs-12 control-label">Logo File Name</label>
<div class="col-lg-6 col-md-6 col-sm-8 col-xs-12">
<!-- Input Here -->
<?php
$directory = USER_IMAGES;
$empty = is_dir_empty($directory);
if (!$empty) {
?>
<select class="selectpicker" name="sponsorImage" id="sponsorImage" data-live-search="true" data-size="10" data-width="auto">
<?php
echo directory_contents_dropdown($directory, $row_sponsors['sponsorImage']);
?>
</select>
<?php
} else {
echo "<p>No images exist in the user_images directory.</p>";
}
?>
<span id="helpBlock" class="help-block">If the directory is empty or a file is not on the list, use the “Upload Logo Images” button below.</span>
<a class="btn btn-sm btn-primary" href="<?php
echo $base_url;
示例9: while
</form>
</div>
<?php
}
?>
<table class="table table-striped table-advance table-hover">
<tbody>
<tr>
<th>Filename</th>
<th>Size</th>
<th>Times downloaded*</th>
<th>Action</th>
</tr>
<?php
if (is_dir_empty("s/files/")) {
?>
</table>
<center>
<h3>You don't have any shared files!</h3></center>
<?php
}
if ($handle = opendir("s/files/")) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && $entry != ".DS_Store" && $entry != ".htaccess" && $entry != ".htdocs") {
$sum += filesize("s/files/" . $entry);
$num = $num + 1;
$filesize = filesize("s/files/" . $entry);
$filesize = $filesize / 1024;
$filesize = $filesize / 1024;
$filesize = round($filesize, 3);
示例10: __dequeue_items
function __dequeue_items($name, $max = MAX_DEQUEUE_COUNT)
{
$now_writing_id = now_name();
$item_ids = array();
foreach (glob(get_queue_file($name, '*')) as $file) {
if (is_dir($file)) {
continue;
}
if (!preg_match('~/(\\d+)\\.' . ITEMS_SUFFIX . '$~', $file, $matches)) {
continue;
}
$item_id = intval($matches[1]);
if ($item_id < $now_writing_id) {
$item_ids[] = $item_id;
}
}
sort($item_ids, SORT_NUMERIC);
$output_items = array();
foreach ($item_ids as $id) {
$file_name = get_queue_file($name, $id);
$data_str = file_get_contents($file_name);
$data_arr = explode(PHP_EOL, $data_str);
while ($item_str = array_shift($data_arr)) {
if ($item_str === '') {
continue;
}
$item = json_decode($item_str, true);
if (empty($item)) {
continue;
}
$output_items[] = $item;
if (count($output_items) >= $max) {
if (!empty($data_arr)) {
$resave_str = implode(PHP_EOL, $data_arr);
file_put_contents($file_name, $resave_str);
break 2;
}
}
}
unlink($file_name);
}
$que_dir = get_queue_dir($name);
if (is_dir_empty($que_dir)) {
rmdir($que_dir);
}
return $output_items;
}
示例11: set_page_title
if (!preg_match($pattern, $url)) {
include '../templates/' . $CONF['template'] . '/header.php';
set_page_title("Teknik Git");
}
if (php_sapi_name() == 'cli-server' && file_exists(substr($_SERVER['REQUEST_URI'], 1))) {
return false;
}
if (!is_writable(__DIR__ . DIRECTORY_SEPARATOR . 'cache')) {
die(sprintf('The "%s" folder must be writable for GitList to run.', __DIR__ . DIRECTORY_SEPARATOR . 'cache'));
}
require 'vendor/autoload.php';
$config = GitList\Config::fromFile('config.ini');
$config->set('app', 'clone_url', 'git://teknik.io/');
if ($_GET['user']) {
if ($userTools->checkUsernameExists($_GET['user'])) {
if (is_dir($CONF['git_repo_path'][0] . "\\u\\" . $_GET['user']) && !is_dir_empty($CONF['git_repo_path'][0] . "\\u\\" . $_GET['user'])) {
$_SERVER['HTTP_X_ORIGINAL_URL'] = str_replace("/u/" . $_GET['user'], "", $_SERVER['HTTP_X_ORIGINAL_URL']);
$config->set('git', 'repositories', array($CONF['git_repo_path'][0] . '\\u\\' . $_GET['user']));
$config->set('git', 'hidden', array(''));
$config->set('app', 'path_prefix', '/u/' . $_GET['user']);
$config->set('app', 'clone_url', 'git://teknik.io/u/' . $_GET['user'] . '/');
$app = (require 'boot.php');
$app->run();
} else {
?>
<div class="row">
<div class="col-sm-12 text-center">
<h2>That user has no repositories</h2>
</div>
</div>
<?php
示例12: time
/**
Remove all files older than the configured expiration time (user and server)
If a file is empty after this then it is deleted
*/
function cleanUpObsolete($user)
{
// Expiration time in days
$expirationDaysServer = readConfiguration(CONFIG_FILE, CONFIG_KEY_TRACK_EXPIRATION_DAYS);
if (isNullOrEmptyString($expirationDaysServer)) {
return;
}
$expirationDaysUser = getConfiguration($user, CONFIG_KEY_TRACK_EXPIRATION_DAYS, true);
// What is the time now?
$now = time();
// Expiration time in seconds
// $a = array($expirationDaysServer, 24, 60, 60);
// $decayTimeServer = array_product($a) + $now;
$daysInSeconds = $expirationDaysServer * 24 * 60 * 60;
$decayTimeServer = $now - $daysInSeconds;
// $a = array($expirationDaysUser, 24, 60, 60);
// $decayTimeUser = array_product($a) + $now;
$daysInSeconds = $expirationDaysUser * 24 * 60 * 60;
$decayTimeUser = $now - $daysInSeconds;
// Iterate through all user directories
if ($handle = opendir(USER_DIR)) {
while (false !== ($entry = readdir($handle))) {
if ($entry == "." || $entry == "..") {
continue;
}
$userDir = USER_DIR . DIRECTORY_SEPARATOR . $entry;
if (is_dir($userDir)) {
// Is this the directory of the current user?
$decayTime = $decayTimeServer;
if ($user == $entry) {
$decayTime = $decayTimeUser;
}
if ($handleUserDirs = opendir($userDir)) {
while (false !== ($entryUserFile = readdir($handleUserDirs))) {
if ($entryUserFile == "." || $entryUserFile == "..") {
continue;
}
$userFile = $userDir . DIRECTORY_SEPARATOR . $entryUserFile;
$lastModifiedTime = filemtime($userFile);
if ($lastModifiedTime <= $decayTime) {
unlink($userFile);
}
}
}
closedir($handleUserDirs);
// Remove the user if no file is left
if (is_dir_empty($userDir)) {
rmdir($userDir);
}
}
}
closedir($handle);
}
}
示例13: cleanup_dir
/**
* Cleanup directory
*
* @param string $path
*/
function cleanup_dir($path)
{
if (file_exists($path) && is_dir($path)) {
$files = glob("{$path}/*");
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
if (is_dir_empty($path)) {
rmdir($path);
}
}
}
示例14: editpost
protected function editpost()
{
//$post
global $rep, $view;
$data = array();
if (isset($_POST['edit'])) {
//we edit
switch ($_POST['edit']) {
case 'edit':
$post_Id = isset($_POST['post_id']) ? $_POST['post_id'] : NULL;
$post_title = isset($_POST['post_title']) ? $_POST['post_title'] : NULL;
$post_content = isset($_POST['post_content']) ? $_POST['post_content'] : NULL;
$data['uploadfile'] = NULL;
//if you upload a file
if ($_FILES['imagepost']['name'] != NULL) {
///check error upload
if ($_FILES['imagepost']['error'] > 0) {
if ($_FILES['imagepost']['error'] == UPLOAD_ERR_FORM_SIZE) {
$data['uploadfile'] = 'The file must not be bigger than 5mo.';
} else {
$data['uploadfile'] = 'The upload failed. Please try again, if this persists, contact the admin.';
}
//setup the error code
}
$valid_extensions = array('jpg', 'jpeg', 'gif', 'png');
$extension_upload = strtolower(substr(strrchr($_FILES['imagepost']['name'], '.'), 1));
if (!in_array($extension_upload, $valid_extensions)) {
$data['uploadfile'] = 'The extension isn\'t valid. The picture must be a jpg, jpeg, gig or png file.';
//setup the error code
}
/// end check error upload
/// check error move
$uploaddir = './images/posts/' . $post_Id . '/';
//create the directory of theprofile pic
if (!is_dir($uploaddir)) {
mkdir($uploaddir, 0777, true);
}
//give this image a random name (for multiple images)
$temp = explode(".", $_FILES["imagepost"]["name"]);
$newfilename = round(microtime(true)) . '.' . end($temp);
$uploadfile = $uploaddir . $newfilename;
if (file_exists($uploadfile)) {
$data['uploadfile'] = 'Error during the upload. Please try again, if this persists, contact the admin.';
//setup the error code
} elseif (!move_uploaded_file($_FILES['imagepost']['tmp_name'], $uploadfile)) {
//if error moving file
if (is_dir_empty($uploaddir)) {
rmdir($uploaddir);
}
//remove the directory IF NOT EMPTY
$data['uploadfile'] = 'Error during the upload. Please try again, if this persists, contact the admin.';
//setup the error code
}
if ($data['uploadfile'] != NULL) {
$post = postModel::getPost($post_Id);
require_once $view['editpost'];
break;
} else {
imageModel::addImagePost($post_Id, $_SESSION['username'], $newfilename);
}
}
postModel::updatePost($post_Id, $post_title, $post_content);
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'editpost/' . $post_Id;
header("Location: http://{$host}{$uri}/{$extra}");
break;
case 'deletepost':
$post_Id = isset($_POST['post_id']) ? $_POST['post_id'] : NULL;
postModel::deletePost($post_Id);
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'dashboard';
header("Location: http://{$host}{$uri}/{$extra}");
break;
case 'deleteimg':
$post_Id = isset($_POST['post_id']) ? $_POST['post_id'] : NULL;
$img_id = isset($_POST['img_id']) ? $_POST['img_id'] : NULL;
imageModel::deleteImg($img_id);
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'editpost/' . $post_Id;
header("Location: http://{$host}{$uri}/{$extra}");
break;
default:
$data[0] = 'Unknow Error';
$data[1] = 'We couldnt handle that request';
$data[0] = '<a href="dashboard" >Dashboard</a>';
require_once $view['error'];
}
} else {
//otherwise we show the post
$postId = isset($_GET['arg1']) ? $_GET['arg1'] : NULL;
if ($postId == NULL) {
$data = array();
$data[0] = "We're sorry, something somewhere went wrong...";
$data[1] = "Please tell us which post you want to edit first.";
require_once $view['error'];
} elseif (postModel::getPost($postId) == NULL) {
$data = array();
//.........这里部分代码省略.........
示例15: elseif
</span>
</div>
<?php
} elseif (!in_array($language, $gb_translated_lang) && !in_array($language, $gb_lang) && $language != "") {
?>
<div class="message red" style="display: block;margin-top:30px">
<span style="padding: 4px 0;">
<strong><p style="font:12px/1.0em Arial !important;">If you would like to translate Gallery Bank in your native language, we will reward you with a free Pro Version License of Gallery Bank worth 18£.</p>
<p style="font:12px/1.0em Arial !important;">Contact Us at <a target="_blank" href="http://tech-banker.com">http://tech-banker.com</a> or email us at <a href="mailto:support@tech-banker.com">support@tech-banker.com</a></p>
</strong>
</span>
</div>
<?php
}
if (!is_dir(GALLERY_MAIN_THUMB_DIR)) {
if (!is_dir_empty(GALLERY_MAIN_THUMB_DIR)) {
?>
<div class="message red" style="display: block;margin-top:15px">
<span>
<strong>If you are getting problems with thumbnails, then you need to set 777(write) permissions to <?php
echo GALLERY_MAIN_DIR;
?>
(recursive files & directories) in order to save the images/thumbnails. </strong>
</span>
</div>
<?php
}
}
function is_dir_empty($dir)
{
if (!is_readable($dir)) {