Skip to content

Commit

Permalink
'mkdir(...)' race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Apr 15, 2019
1 parent f5b5855 commit 3c39c20
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
12 changes: 9 additions & 3 deletions admin/modify_ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ function index()
$photo_thumb_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
$photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
if (!is_dir($photo_dir)) {
mkdir($photo_dir);
if (!mkdir($photo_dir) && !is_dir($photo_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
}
}
if (!is_dir($photo_thumb_dir)) {
mkdir($photo_thumb_dir);
if (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
}
}
if (!is_dir($photo_resized_dir)) {
mkdir($photo_resized_dir);
if (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
}
}
if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
Expand Down
12 changes: 9 additions & 3 deletions admin/validate_ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,19 @@ function index()
$photo_thumb_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
$photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
if (!is_dir($photo_dir)) {
mkdir($photo_dir);
if (!mkdir($photo_dir) && !is_dir($photo_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
}
}
if (!is_dir($photo_thumb_dir)) {
mkdir($photo_thumb_dir);
if (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
}
}
if (!is_dir($photo_resized_dir)) {
mkdir($photo_resized_dir);
if (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
}
}
if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
Expand Down
12 changes: 9 additions & 3 deletions admin/view_ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ function index()
$photo_thumb_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
$photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
if (!is_dir($photo_dir)) {
mkdir($photo_dir);
if (!mkdir($photo_dir) && !is_dir($photo_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
}
}
if (!is_dir($photo_thumb_dir)) {
mkdir($photo_thumb_dir);
if (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
}
}
if (!is_dir($photo_resized_dir)) {
mkdir($photo_resized_dir);
if (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
}
}
if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
Expand Down

0 comments on commit 3c39c20

Please sign in to comment.