$file = $file->load($fileID); if ($key == hash('md5', KEY . $file->getPath())) { menubar(); $fileUpdate = new Uploadedfile(); $fileUpdate->setCampus(issetOrBlank($_POST['file-campus'])); $fileUpdate->setCategory(issetOrBlank($_POST['file-category'])); $fileUpdate->setFaculty(issetOrBlank($_POST['file-faculty'])); $fileUpdate->setExpiry(trim($_POST['file-expiry']) == "" ? "0000-00-00 00:00:00" : date('Y-m-d H:i:s', strtotime($_POST['file-expiry']))); ///0000-00-00 00:00:00 $fileUpdate->setDescription($_POST['file-description']); if (issetOrBlank($_POST['file-tags']) != $file->getTags()) { //sort the tags $tags = array_filter(array_map('trim', explode(',', issetOrBlank($_POST['file-tags'])))); asort($tags); $tags = implode(', ', $tags); $fileUpdate->setTags($tags); $query = "SELECT `option` FROM `options` WHERE `group_id` = 4 order by `sort`"; $Otags = $conn->query($query); $Otags->execute(); $Otags = $Otags->fetchAll(PDO::FETCH_COLUMN); //echo $tags; $newTags = explode(",", $fileUpdate->getTags()); $addTags = array_diff($newTags, $Otags); $pos = sizeof($Otags); foreach ($addTags as $tag) { $pos++; $newTag = $conn->prepare("INSERT INTO `fileupload`.`options` (`group_id`, `option`, `sort`) VALUES ('4', :tag, :pos)"); $newTag->bindParam(':tag', $tag); $newTag->bindParam(':pos', $pos); $newTag->execute(); }
<title>Upload File</title> </head> <body> <?php menubar(); //$file = new Uploadedfile($conn); $file->setCampus(issetOrBlank($_POST['file-campus'])); $file->setCategory(issetOrBlank($_POST['file-category'])); $file->setFaculty(issetOrBlank($_POST['file-faculty'])); $file->setExpiry(trim($_POST['file-expiry']) == "" ? "0000-00-00 00:00:00" : date('Y-m-d H:i:s', strtotime($_POST['file-expiry']))); $file->setDescription($_POST['file-description']); //sort the tags $tags = array_filter(array_map('trim', explode(',', issetOrBlank($_POST['file-tags'])))); asort($tags); $tags = implode(', ', $tags); $file->setTags($tags); //add tags to Global Tag list... //options - group_type = 4 $query = "SELECT `option` FROM `options` WHERE `group_id` = 4 order by `sort`"; $tags = $conn->query($query); $tags->execute(); $tags = $tags->fetchAll(PDO::FETCH_COLUMN); $newTags = explode(",", $file->getTags()); $addTags = array_diff($newTags, $tags); $pos = sizeof($tags); foreach ($addTags as $tag) { $pos++; $newTag = $conn->prepare("INSERT INTO `fileupload`.`options` (`group_id`, `option`, `sort`) VALUES ('4', :tag, :pos)"); $newTag->bindParam(':tag', trim($tag)); $newTag->bindParam(':pos', $pos); $newTag->execute();