Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • f427f3551b5a07076edaa17387efa0deffc1fa9f
  • master par défaut protégée
2 résultats

image_alea.php

Blame
  • image_alea.php 2,55 Kio
    <?php
    
    require '../vendor/autoload.php';
    
    include './utils/content.php';
    include './utils/requestUtils.php';
    
    session_start();
    
    
    // postgres
    $dbName = getenv('DB_NAME');
    $dbUser = getenv('DB_USER');
    $dbPassword = getenv('DB_PASSWORD');
    $connection = new PDO("pgsql:host=postgres user=$dbUser dbname=$dbName password=$dbPassword");
    
    
    //repositories
    $userRepository = new \User\UserRepository($connection);
    $reviewRepository = new \Review\ReviewRepository($connection);
    $coupdecoeurRepository = new \CoupDeCoeur\CoupDeCoeurRepository($connection);
    
    
    
    $listeUser = $userRepository->fetchAll();
    $listeReview = $reviewRepository->fetchAll();
    $listeCDC = $coupdecoeurRepository->fetchAll();
    
    urlHasArgument();
    
    ?>
    
    
    
    <html>
    <?php
    	generateHeader('Image Alea');
    	generateUserbanner();
    ?>
    <body style="background-image:url('./ressources/background/test2.jpeg'); text-align: center">
    	<!-- génération des bonnières -->
    	<?php
    	generateNavBar('image_alea');
    	?>
    
    	<h1 class="titre" style="text-align: center"> Image Aleatoire de la bibliotheque : </h1>
    	<?php
    	$url_alea = 'https://images-api.nasa.gov/search?year_start=2007&page='.random_int(0,99);
    	$resJSON = retrieveJsonFromUrl($url_alea);
    
    	$image = $resJSON->{'collection'}->{'items'}[random_int(0, 99)];
    	// var_dump($image);
    	?>
    	<div class="view container-fluid">
    
    		<div class="hover-container" style="margin: 3px">
    			<img class="img-fluid" style="margin: 4px" src=<?php echo $image->{'links'}[0]->{'href'} ?>>
    			<div class="content">
    				<div class="text scrollbar">
    					<h4><?php echo $image->{'data'}[0]->{'title'} ?></h4>
    					<p style="font-size: 15px"><?php echo $image->{'data'}[0]->{'description'} ?></p>
    				</div>
    				<div class="actionrow" style="left: -120px;">
    					<form method="POST" action="download.php" target="_blank">
    						<input type="hidden" name="urlget" value=<?php echo $image->{'href'} ?>>
    						<input type="hidden" name="nasa_id" value=<?php echo $image->{'data'}[0]->{'nasa_id'} ?>>
    						<input type="hidden" name="title" value=<?php echo $image->{'data'}[0]->{'title'} ?>>
    						<input type="hidden" name="preview" value=<?php echo $image->{'links'}[0]->{'href'} ?>>
    						<input type="image" name="submit" alt="Submit" class="download" width="13%" src="./ressources/icons/dwnld.png" onmouseover="this.src='./ressources/icons/dwnldVert.png'" onmouseout="this.src='./ressources/icons/dwnld.png'">
    					</form>
    				</div>
    			</div>
    		</div>
    	</div>
    
    	<div class="view container-fluid">
    		<a href="image_alea.php"><button class="btn btn-primary">Nouvelle Image</button></a>
    	</div>
    
    
    	<?php generateFooter(); ?>
    </body>
    </html>