mirror of
https://github.com/nokonoko/Uguu.git
synced 2024-01-06 13:35:15 +00:00
commit
2002a49442
@ -247,16 +247,18 @@
|
|||||||
*
|
*
|
||||||
* @return string The file extension of the file.
|
* @return string The file extension of the file.
|
||||||
*/
|
*/
|
||||||
public function fileExtension(array $file):string
|
public function fileExtension(array $file):?string
|
||||||
{
|
{
|
||||||
|
if(str_contains($file['name'], '.')){
|
||||||
$extension = explode('.', $file['name']);
|
$extension = explode('.', $file['name']);
|
||||||
$dotCount = substr_count($file['name'], '.');
|
$dotCount = substr_count($file['name'], '.');
|
||||||
return match ($dotCount) {
|
return match ($dotCount) {
|
||||||
0 => null,
|
|
||||||
1 => end($extension),
|
1 => end($extension),
|
||||||
2 => $this->doubleDotExtension($extension),
|
2 => $this->doubleDotExtension($extension),
|
||||||
default => end($extension)
|
default => end($extension)
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
return "NOEXT";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -309,10 +311,10 @@
|
|||||||
$index = rand(0, strlen($this->Connector->CONFIG['ID_CHARSET']) - 1);
|
$index = rand(0, strlen($this->Connector->CONFIG['ID_CHARSET']) - 1);
|
||||||
$NEW_NAME .= $this->Connector->CONFIG['ID_CHARSET'][$index];
|
$NEW_NAME .= $this->Connector->CONFIG['ID_CHARSET'][$index];
|
||||||
}
|
}
|
||||||
if (!empty($extension)) {
|
if ($extension != "NOEXT") {
|
||||||
$NEW_NAME .= '.' . $extension;
|
$NEW_NAME .= '.' . $extension;
|
||||||
}
|
}
|
||||||
} while ($this->Connector->dbCheckNameExists($NEW_NAME));
|
} while ($this->Connector->dbCheckNameExists($NEW_NAME));
|
||||||
return $NEW_NAME;
|
return $NEW_NAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user