$rightPdoManager = new RightPdoManager(); //Chemin des fichiers de test $path = 'D:\\Cours SUPINFO\\M1\\Projet Fin d\'annee\\Nestbox\\Fichiers de test/'; /** * /Nestbox/ * IMG/ * Croquis Nesbtox.jpg * code/ * js/ * front/ * js.txt * css/ * test.txt * * suivi de projet.gdoc * liens upload.gdoc * Explorateur de fichier.gdoc * /Nestbox - test/ * carte.gif */ //contient 12 éléments $insert = array(array('_id' => new MongoId('5392061f09413a1021000041'), 'state' => 1, 'name' => 'Nestbox', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/'), array('state' => 1, 'name' => 'Nestbox - test', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000074'), 'serverPath' => '/'), array('state' => 1, 'name' => 'IMG', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/'), array('state' => 1, 'name' => 'Croquis Nestbox', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb502180800006f'), 'serverPath' => '/Nestbox/IMG/', 'size' => fileSize64($path . 'Nestbox/IMG/Croquis Nestbox.jpg'), 'hash' => sha1_file($path . 'Nestbox/IMG/Croquis Nestbox.jpg'), 'downloadLink' => ''), array('state' => 1, 'name' => 'code', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/'), array('state' => 1, 'name' => 'js', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/'), array('state' => 1, 'name' => 'front', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/js/'), array('state' => 1, 'name' => 'js', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('539b0c4eedb502ac0d000044'), 'serverPath' => '/Nestbox/code/js/front/', 'size' => fileSize64($path . 'Nestbox/code/js/front/js.txt'), 'hash' => sha1_file($path . 'Nestbox/code/js/front/js.txt'), 'downloadLink' => ''), array('state' => 1, 'name' => 'css', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/'), array('state' => 1, 'name' => 'test', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('539b0c4eedb502ac0d000044'), 'serverPath' => '/Nestbox/code/css/', 'size' => fileSize64($path . 'Nestbox/code/css/test.txt'), 'hash' => sha1_file($path . 'Nestbox/code/css/test.txt'), 'downloadLink' => ''), array('state' => 1, 'name' => 'suivi de projet', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000058'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/suivi de projet.doc'), 'hash' => sha1_file($path . 'Nestbox/suivi de projet.doc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'liens upload', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000058'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/liens upload.doc'), 'hash' => sha1_file($path . 'Nestbox/liens upload.doc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'Explorateur de fichier', 'idOwner' => new MongoId('536749adedb5025416000029'), 'idRefElement' => new MongoId('53639f93edb5021808000058'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/Explorateur de fichier.doc'), 'hash' => sha1_file($path . 'Nestbox/Explorateur de fichier.doc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'carte', 'idOwner' => new MongoId('5397628aedb502300d000050'), 'idRefElement' => new MongoId('53639f93edb502180800006b'), 'serverPath' => '/', 'size' => fileSize64($path . 'carte.gif'), 'hash' => sha1_file($path . 'carte.gif'), 'downloadLink' => ''), array('idOwner' => new MongoId("5397628aedb502300d000050"), 'idRefElement' => new MongoId("53639f93edb5021808000074"), 'name' => 'First Share', 'serverPath' => '/', 'state' => new MongoInt32(1))); foreach ($insert as $element) { $elementPdoManager->create($element); } $insertRight = array(array('idElement' => new MongoId("53977311edb502b40c000050"), 'idRefRight' => new MongoId("53639f93edb5021808000047"), 'idUser' => new MongoId("536749adedb5025416000029"), 'state' => new MongoInt32(1)), array('idElement' => new MongoId("539761f1edb502300d00004f"), 'idRefRight' => new MongoId("53639f93edb5021808000047"), 'idUser' => new MongoId("536749adedb5025416000029"), 'state' => new MongoInt32(1))); foreach ($insertRight as $right) { $rightPdoManager->create($right); } echo 'Insertion OK'; exit;
if (isset($_POST['downloadAnonymousElem']) && isset($_POST['idElement'])) { userDownload($_POST['owner'], $_POST['idElement']); } // soumission du formulaire d'upload basique if (isset($_POST['uploadBasicElem']) && isset($_FILES['fileExplorer'])) { $path = 'C:/wamp/www/Nestbox/' . $userId . '/Tmp-' . $userId . ''; $folder = $path . '/'; $file = $_FILES['fileExplorer']['name']; move_uploaded_file($_FILES['fileExplorer']['tmp_name'], $folder . $file); $returnMoveFS = moveFSElement($userId, '/Tmp-' . $userId . '/', $_FILES['fileExplorer']['name'], $_POST['destination'], $_FILES['fileExplorer']['name']); if ($returnMoveFS == TRUE) { $newPath = $projectRoot . '/' . $userId . $_POST['destination']; $elementManager = new ElementPdoManager(); $refElementManager = new RefElementPdoManager(); $hash = sha1_file($newPath . $_FILES['fileExplorer']['name']); $size = fileSize64($newPath . $_FILES['fileExplorer']['name']); $pathInfo = pathinfo($newPath . $_FILES['fileExplorer']['name']); $refElement = $refElementManager->findOne(array('extension' => '.' . $pathInfo['extension'])); if (is_array($refElement) && array_key_exists('error', $refElement)) { echo "Extension not found"; } else { $idRefElement = $refElement->getId(); $criteria = array('downloadLink' => '', 'idOwner' => $userId, 'idRefElement' => $idRefElement, 'name' => $pathInfo['filename'], 'state' => 1, 'hash' => $hash, 'serverPath' => $_POST['destination'], 'size' => $size); $createElement = $elementManager->create($criteria); updateFolderStatus($_POST['destination'], $userId); header('Location : ' . $_SERVER['PHP_SELF'] . ''); } } else { echo "Error during upload."; } }
* Time: 23:53 */ /** @var string $projectRoot chemin du projet dans le système de fichier */ $projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Nestbox'; require_once $projectRoot . '/required.php'; $elementPdoManager = new ElementPdoManager(); //Chemin des fichiers de test $path = 'D:/supinfo courses/Projets/M1/Drive/NestBox/Fichiers de test/'; /** * /Nestbox/ * IMG/ * Croquis Nesbtox.jpg * code/ * js/ * front/ * js.txt * css/ * test.txt * * suivi de projet.gdoc * liens upload.gdoc * Explorateur de fichier.gdoc * /Nestbox - test/ */ //contient 12 éléments $insert = array(array('_id' => new MongoId('5392061f09413a1021000041'), 'state' => 1, 'name' => 'Nestbox', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/'), array('state' => 1, 'name' => 'Nestbox - test', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000074'), 'serverPath' => '/'), array('state' => 1, 'name' => 'IMG', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/'), array('state' => 1, 'name' => 'Croquis Nestbox', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb502180800006f'), 'serverPath' => '/Nestbox/IMG/', 'size' => fileSize64($path . 'Nestbox/IMG/Croquis Nestbox.jpg'), 'hash' => sha1_file($path . 'Nestbox/IMG/Croquis Nestbox.jpg'), 'downloadLink' => ''), array('state' => 1, 'name' => 'code', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/'), array('state' => 1, 'name' => 'js', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/'), array('state' => 1, 'name' => 'front', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/js/'), array('state' => 1, 'name' => 'test', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000076'), 'serverPath' => '/Nestbox/code/js/front/', 'size' => fileSize64($path . 'Nestbox/code/js/front/js.txt'), 'hash' => sha1_file($path . 'Nestbox/code/js/front/js.txt'), 'downloadLink' => ''), array('state' => 1, 'name' => 'css', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000075'), 'serverPath' => '/Nestbox/code/'), array('state' => 1, 'name' => 'test', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000076'), 'serverPath' => '/Nestbox/code/css/', 'size' => fileSize64($path . 'Nestbox/code/css/test.txt'), 'hash' => sha1_file($path . 'Nestbox/code/css/test.txt'), 'downloadLink' => ''), array('state' => 1, 'name' => 'suivi de projet', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000076'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/suivi de projet.gdoc'), 'hash' => sha1_file($path . 'Nestbox/suivi de projet.gdoc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'liens upload', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000076'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/liens upload.gdoc'), 'hash' => sha1_file($path . 'Nestbox/liens upload.gdoc'), 'downloadLink' => ''), array('state' => 1, 'name' => 'Explorateur de fichier', 'idOwner' => new MongoId('5350ece509413aec15000033'), 'idRefElement' => new MongoId('53639f93edb5021808000076'), 'serverPath' => '/Nestbox/', 'size' => fileSize64($path . 'Nestbox/Explorateur de fichier.gdoc'), 'hash' => sha1_file($path . 'Nestbox/Explorateur de fichier.gdoc'), 'downloadLink' => '')); foreach ($insert as $element) { $elementPdoManager->create($element); } echo 'Insertion OK'; exit;
/** * Created by PhpStorm. * User: Harry * Date: 12/06/14 * Time: 19:42 */ $path = 'C:/wamp/www/Nestbox/' . $userId . '/Tmp-' . $userId . ''; /* Si l'utilisateur décide d'uploader un element */ if (isset($_POST['destination']) && isset($_SESSION['file'])) { $returnMoveFS = moveFSElement($userId, '/Tmp-' . $userId . '/', $_SESSION['file']['name'], $_POST['destination'], $_SESSION['file']['name']); if ($returnMoveFS == TRUE) { $newPath = $projectRoot . '/' . $userId . $_POST['destination']; $elementManager = new ElementPdoManager(); $refElementManager = new RefElementPdoManager(); $hash = sha1_file($newPath . $_SESSION['file']['name']); $size = fileSize64($newPath . $_SESSION['file']['name']); $pathInfo = pathinfo($newPath . $_SESSION['file']['name']); $refElement = $refElementManager->findOne(array('extension' => '.' . $pathInfo['extension'])); if (is_array($refElement) && array_key_exists('error', $refElement)) { echo "Extension not found"; } else { $idRefElement = $refElement->getId(); $criteria = array('downloadLink' => '', 'idOwner' => $userId, 'idRefElement' => $idRefElement, 'name' => $pathInfo['filename'], 'state' => 1, 'hash' => $hash, 'serverPath' => $_POST['destination'], 'size' => $size); $createElement = $elementManager->create($criteria); updateFolderStatus($_POST['destination'], $userId); echo "Your element has been successfully uploaded."; } unset($_SESSION['file']); } else { echo "Error during upload."; }