Exemple #1
0
 public function Suicide()
 {
     if ($this->IsSnapshot) {
         $tmp = Api::GetCollection(Api::COLLECTIONPATH . $this->GetID());
         $this->list = $tmp->GetList();
         $this->IsSnapshot = false;
     }
     foreach ($this->list as $item) {
         if ($item instanceof Artifact) {
             $this->list[$item->GetID()]->Suicide();
             unset($this->list[$item->GetID()]);
         } elseif ($item instanceof Collection) {
             $item->Suicide();
         }
     }
     unlink(Api::COLLECTIONPATH . $this->GetID());
 }
Exemple #2
0
    <br>
    <form action="" method="GET">
        <input name="' . $ID . '">
        <button>Find</button>
    </form>
';
if (isset($_GET[$ID])) {
    $collection = Api::GetCollection($_GET[$ID]);
    if (isset($_GET['delete']) && isset($_GET["type"])) {
        if ($_GET["type"] == "artifact") {
            $artifact = $collection->GetArtifact($_GET['delete']);
            if ($artifact != NULL) {
                $collection->DeleteArtifact($artifact->GetID());
            }
        } elseif ($_GET["type"] == "collection") {
            $ctd = Api::GetCollection($_GET['delete']);
            if ($ctd != NULL) {
                $collection->DeleteCollection($ctd->GetID());
                header("Location: ?id=" . $collection->GetID());
                die;
            }
        }
    }
    echo "\n    <i>{$collection->GetID()}</i>\n    <h2>{$collection->GetName()}</h2>\n    <ul>\n    ";
    foreach ($collection->GetList() as $item) {
        echo '<li>';
        if ($item instanceof Artifact) {
            $path = Api::APIPATH . Api::ARTIFACTPATH . $item->GetID();
            echo "<a href='{$path}' download='{$item->GetFilename()}'><b>{$item->GetFilename()}</b></a> <i>({$item->GetID()})</i>";
            echo " <a href='share.php?id={$item->GetID()}&fcid={$collection->GetID()}'>Share</a>";
            echo " <a href='update.php?cid={$collection->GetID()}&id={$item->GetID()}'>Update</a>";
Exemple #3
0
<?php

error_reporting(E_ALL);
require_once "init.php";
$itemID = null;
$collectionID = null;
$extension = null;
if (isset($_GET["id"]) && isset($_GET["cid"])) {
    $itemID = $_GET["id"];
    $collectionID = $_GET["cid"];
    $originalCollection = Api::GetCollection($collectionID);
    if ($originalCollection != NULL) {
        $item = $originalCollection->GetArtifact($itemID);
        if ($item != null) {
            $extension = $item->GetExtension();
            if (isset($_FILES["file"])) {
                $item->Update($_FILES["file"]);
            }
        }
    }
}
echo '
     <br>
     <form enctype="multipart/form-data" action="?cid=' . $collectionID . '&id=' . $itemID . '" method="POST">
        Artifact <b>' . $itemID . '</b> from collection <b><a href="find.php?id=' . $collectionID . '">' . $collectionID . '</a></b>
        <br>
        <br>
        <input type="file" name="file" accept=".' . $extension . '">
        <button>Update</button>
    </form>
';
Exemple #4
0
<?php

error_reporting(E_ALL);
require_once "init.php";
$NAME = "name";
$PID = "pid";
$parentElement = "";
if (isset($_GET[$PID])) {
    $parentElement = "Adding to collection: <a href='find.php?id={$_GET[$PID]}'><b>{$_GET[$PID]}</b></a><input type=hidden name='{$PID}' value='{$_GET[$PID]}'>";
}
if (isset($_GET[$NAME])) {
    $collection = new Collection($_GET[$NAME]);
    if (isset($_GET[$PID])) {
        $parent = Api::GetCollection($_GET[$PID]);
        if ($parent != null) {
            $parent->AddCollection($collection);
        }
    }
    header("Location: find.php?id=" . $collection->GetID());
}
$body = '
    <br>
    <form action="" method="GET">
        Collection name: <input name="' . $NAME . '">
        <br>
        ' . $parentElement . '
        <br>
        <button>Create and open</button>
    </form>
';
echo $body;
Exemple #5
0
<?php

error_reporting(E_ALL);
require_once "init.php";
$itemID = null;
$collectionID = null;
if (isset($_GET["id"]) && isset($_GET["fcid"])) {
    $itemID = $_GET["id"];
    $collectionID = $_GET["fcid"];
    if (isset($_GET["cid"])) {
        $originalCollection = Api::GetCollection($collectionID);
        $targetCollection = Api::GetCollection($_GET["cid"]);
        if ($originalCollection != NULL && $targetCollection != NULL) {
            $item = $originalCollection->GetArtifact($itemID);
            $targetCollection->AddArtifact($item);
        }
    }
}
echo '
     <br>
     <form action="?" method="GET">
        <input type=hidden value="' . $collectionID . '" name="fcid">
        <input type=hidden value="' . $itemID . '" name="id">
        Artifact <b>' . $itemID . '</b> from collection <b><a href="find.php?id=' . $collectionID . '">' . $collectionID . '</a></b>
        <br>
        Collection ID <br>
        <input name="cid">
        <button>Share</button>
    </form>
';
Template::Render();
Exemple #6
0
error_reporting(E_ALL);
require_once "init.php";
$FILE = "file";
$CID = "CollectionID";
$preCollectionID = null;
if (isset($_GET[$CID])) {
    $preCollectionID = $_GET[$CID];
}
$body = '
    <br>
   <form enctype="multipart/form-data" action="?CollectionID=' . $preCollectionID . '" method="POST">
        Upload artifact to collection <b><a href="find.php?id=' . $preCollectionID . '">' . $preCollectionID . '</a></b>
        <br>
        <input type="file" name="' . $FILE . '">
        <br>
        <button>Upload</button>
    </form>
';
if (isset($_FILES[$FILE]) && isset($_GET[$CID])) {
    $collectionID = $_GET[$CID];
    $collection = Api::GetCollection($collectionID);
    if ($collection != null) {
        $collection->AddArtifact(new Artifact($_FILES[$FILE]));
        echo "Upload successfull!";
    } else {
        echo "Collection does not exist";
    }
}
echo $body;
Template::Render();