Пример #1
0
    $folder = new Folder();
    $doc_list = $doc->getAll($userid);
}
$folder_list = $folder->ListUserFolder($userid);
if (isset($_REQUEST['dossier'])) {
    $dossier = $_REQUEST['dossier'];
    $folder->new_folder($dossier, $userid);
    $session->refresh();
}
if (isset($_REQUEST['upload']) && $_FILES['userfile']['size'] > 0) {
    if (isset($_REQUEST['folder_id']) && isset($_FILES['userfile']['name']) && isset($_FILES['userfile']['tmp_name']) && isset($_FILES['userfile']['type'])) {
        $db = Database::getInstance();
        $folder_id = $_REQUEST['folder_id'];
        $fileName = $_FILES['userfile']['name'];
        $tmpName = $_FILES['userfile']['tmp_name'];
        $fileSize = $_FILES['userfile']['size'];
        $fileType = $_FILES['userfile']['type'];
        $fp = fopen($tmpName, 'r');
        $content = fread($fp, filesize($tmpName));
        $content = addslashes($content);
        fclose($fp);
        if (!get_magic_quotes_gpc()) {
            $fileName = addslashes($fileName);
        }
        $doc->upload($fileName, $fileSize, $fileType, $content, $folder_id);
        $iddoc = $db->lastInsertId();
        $doc->new_doc_owner($iddoc, $userid);
        header('Location: ' . $_SERVER['HTTP_REFERER']);
    }
}
echo $twig->render("my_folder.html.twig", array("user" => array("folder" => $folder_list, "doc" => $doc_list), "folder_cur" => $folder_cur));