<?php
require_once "/lib/pdo.php" ;
require 'Slim/Slim.php' ;
// $mapper=new DataMapper($DBH);
\Slim\Slim:: registerAutoloader ( ) ;
$app = new \Slim\Slim( ) ;
$mapper = new DataMapper( $DBH ) ;
$app -> get ( '/:id' , $file = function ( $id ) use ( $mapper ) {
return $mapper -> showFilebyID ( $id ) ;
} ) ;
$app -> run ( ) ;
if ( isset ( $_POST [ 'submit' ] ) ) {
echo "ddd" ;
}
if ( isset ( $_POST [ 'submit' ] ) ) {
$filename = $file -> showName ( ) ;
$filesize = $file -> showSize ( ) ;
header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Cache-Control: private" , false ) ; // нужен для некоторых браузеров header ( "Content-Disposition: attachment; filename=\" " . basename ( $filename ) . "\" ;" ) ; header ( "Content-Transfer-Encoding: binary" ) ; header ( "Content-Length: " . $filesize ) ; }
include "templates/file.html" ;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Profile</title>
</head>
<body>
<form method='post' action=''>
<input type='submit' value='скачать' />
</form>
</body>
</html>
PD9waHAKCglyZXF1aXJlX29uY2UgIi9saWIvcGRvLnBocCI7CgoJcmVxdWlyZSAnU2xpbS9TbGltLnBocCc7IAoKCS8vICRtYXBwZXI9bmV3IERhdGFNYXBwZXIoJERCSCk7CgoJXFNsaW1cU2xpbTo6cmVnaXN0ZXJBdXRvbG9hZGVyKCk7CgkkYXBwID0gbmV3IFxTbGltXFNsaW0oKTsgCgoKCgkkbWFwcGVyPW5ldyBEYXRhTWFwcGVyKCREQkgpOwoKCSRhcHAtPmdldCgnLzppZCcsICRmaWxlPWZ1bmN0aW9uICgkaWQpIHVzZSAoJG1hcHBlcil7IAoJCQoJCXJldHVybiAkbWFwcGVyLT5zaG93RmlsZWJ5SUQoJGlkKTsgCgl9KTsgCgkkYXBwLT5ydW4oKTsKCglpZiAoaXNzZXQoJF9QT1NUWydzdWJtaXQnXSkpCgl7CQoJCWVjaG8gImRkZCI7Cgl9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