Browse Source

Added check for empty directory for git user sace

pull/24/head
Teknikode 5 years ago
parent
commit
6183a0040b
2 changed files with 15 additions and 1 deletions
  1. 1
    1
      git/index.php
  2. 14
    0
      includes/common.php

+ 1
- 1
git/index.php View File

@@ -37,7 +37,7 @@ if ($_GET['user'])
{
if ($userTools->checkUsernameExists($_GET['user']))
{
if (is_dir("G:\\Repositories\\u\\".$_GET['user']))
if (is_dir("G:\\Repositories\\u\\".$_GET['user']) && !is_dir_empty("G:\\Repositories\\u\\".$_GET['user']))
{
$_SERVER['HTTP_X_ORIGINAL_URL'] = str_replace("/u/".$_GET['user'], "", $_SERVER['HTTP_X_ORIGINAL_URL']);
$config->set('git', 'repositories', array('G:\\Repositories\\u\\'.$_GET['user']));

+ 14
- 0
includes/common.php View File

@@ -615,4 +615,18 @@ function compress($buffer)
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
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;
}
?>

Loading…
Cancel
Save