예제 #1
0
 $fileAlias = issetOrBlank($_POST['file-alias']);
 if (!startsWith($fileAlias, "/")) {
     $fileAlias = "/" . $fileAlias;
 }
 //	echo "Alias: ".$file->getAliasID();
 //	echo "Alias Text: ".$fileAlias;
 //check if alias is new or changed.
 $aliasFind = "SELECT `id` FROM `alias` WHERE `alias` = :ALIASTEXT";
 $aliasFind = $conn->prepare($aliasFind);
 $aliasFind->bindParam(':ALIASTEXT', $fileAlias);
 $aliasFind->execute();
 $aliasFind = $aliasFind->fetchAll(PDO::FETCH_ASSOC);
 //echo "Alias ID: ".$aliasFind[0]['id'];
 if ($aliasFind[0]['id'] == $file->getAliasID()) {
     //echo "No Alias Update";
     $fileUpdate->setAliasID($file->getAliasID());
 } else {
     //need to update the alias...
     //echo 'Alias ID: '.$file->getAliasID().' needs to point to: '.$fileAlias;
     if ($fileAlias == "/") {
         //remove the alias
         echo "Delete alias" . $file->getAliasID();
         $fileUpdate->setAliasID(0);
         $aliasUpdate = "DELETE FROM `alias` where `id` = :ALIASID";
         $aliasUpdate = $conn->prepare($aliasUpdate);
         $aliasUpdate->bindParam(':ALIASID', $file->getAliasID());
         if ($aliasUpdate->execute()) {
             echo "Alias deleted Successfully.";
         }
     } else {
         //new or Update
예제 #2
0
 $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();
 }
 $file->setType(issetOrBlank($_POST['file-type']));
 $file->setUploadDate(date('Y-m-d H:i:s'));
 $file->setActive(1);
 $file->setAliasID(0);
 //echo UPLOADS_DIR;
 $DATEPATH = date('Y') . DIRECTORY_SEPARATOR . date('m') . DIRECTORY_SEPARATOR;
 $uploadTo = $DATEPATH . $file->getCampus() . DIRECTORY_SEPARATOR . $file->getFaculty() . DIRECTORY_SEPARATOR . $file->getCategory() . DIRECTORY_SEPARATOR;
 $uploadTo = issetOrBlank($uploadTo);
 //$uploadTo = "";
 //echo $uploadTo;
 //Ensure that the directory path exists
 //echo UPLOADS_DIR;
 //exit;
 mkpath(UPLOADS_DIR . $uploadTo);
 //echo UPLOADS_DIR.$uploadTo;
 $uploaded = 0;
 if (!file_exists(UPLOADS_DIR . $uploadTo)) {
     //could not create directory
     echo '<h1 class="error">Could not create directory for upload</h1>';