Changed upload error order
This commit is contained in:
parent
dc4af58d31
commit
5f3a913629
1 changed files with 31 additions and 31 deletions
|
@ -298,37 +298,6 @@ class PostController
|
|||
|
||||
if (!empty($_FILES['file']['name']))
|
||||
{
|
||||
/* safety */
|
||||
$suppliedSafety = intval(InputHelper::get('safety'));
|
||||
if (!in_array($suppliedSafety, PostSafety::getAll()))
|
||||
throw new SimpleException('Invalid safety type "' . $suppliedSafety . '"');
|
||||
|
||||
|
||||
/* tags */
|
||||
$suppliedTags = InputHelper::get('tags');
|
||||
$suppliedTags = preg_split('/[,;\s+]/', $suppliedTags);
|
||||
$suppliedTags = array_filter($suppliedTags);
|
||||
$suppliedTags = array_unique($suppliedTags);
|
||||
foreach ($suppliedTags as $tag)
|
||||
if (!preg_match('/^[a-zA-Z0-9_-]+$/i', $tag))
|
||||
throw new SimpleException('Invalid tag "' . $tag . '"');
|
||||
if (empty($suppliedTags))
|
||||
throw new SimpleException('No tags set');
|
||||
|
||||
$dbTags = [];
|
||||
foreach ($suppliedTags as $tag)
|
||||
{
|
||||
$dbTag = R::findOne('tag', 'name = ?', [$tag]);
|
||||
if (!$dbTag)
|
||||
{
|
||||
$dbTag = R::dispense('tag');
|
||||
$dbTag->name = $tag;
|
||||
R::store($dbTag);
|
||||
}
|
||||
$dbTags []= $dbTag;
|
||||
}
|
||||
|
||||
|
||||
/* file contents */
|
||||
$suppliedFile = $_FILES['file'];
|
||||
self::handleUploadErrors($suppliedFile);
|
||||
|
@ -367,6 +336,37 @@ class PostController
|
|||
while (file_exists($path));
|
||||
|
||||
|
||||
/* safety */
|
||||
$suppliedSafety = intval(InputHelper::get('safety'));
|
||||
if (!in_array($suppliedSafety, PostSafety::getAll()))
|
||||
throw new SimpleException('Invalid safety type "' . $suppliedSafety . '"');
|
||||
|
||||
|
||||
/* tags */
|
||||
$suppliedTags = InputHelper::get('tags');
|
||||
$suppliedTags = preg_split('/[,;\s+]/', $suppliedTags);
|
||||
$suppliedTags = array_filter($suppliedTags);
|
||||
$suppliedTags = array_unique($suppliedTags);
|
||||
foreach ($suppliedTags as $tag)
|
||||
if (!preg_match('/^[a-zA-Z0-9_-]+$/i', $tag))
|
||||
throw new SimpleException('Invalid tag "' . $tag . '"');
|
||||
if (empty($suppliedTags))
|
||||
throw new SimpleException('No tags set');
|
||||
|
||||
$dbTags = [];
|
||||
foreach ($suppliedTags as $tag)
|
||||
{
|
||||
$dbTag = R::findOne('tag', 'name = ?', [$tag]);
|
||||
if (!$dbTag)
|
||||
{
|
||||
$dbTag = R::dispense('tag');
|
||||
$dbTag->name = $tag;
|
||||
R::store($dbTag);
|
||||
}
|
||||
$dbTags []= $dbTag;
|
||||
}
|
||||
|
||||
|
||||
/* db storage */
|
||||
$dbPost = R::dispense('post');
|
||||
$dbPost->type = $postType;
|
||||
|
|
Loading…
Reference in a new issue