<commit_before><?php
	function getAverageVote($id_post){

		require('co_pdo.php');
		$reqAv = $bdd->prepare('SELECT avg(vote) FROM vote WHERE id_post = ?');
		$reqAv->execute(array($id_post));
		$resp = $reqAv->fetch();
		return round($resp['avg(vote)'],1);
		

	}

	function getNumberVote($id_post){

		require('co_pdo.php');
		$reqAv = $bdd->prepare('SELECT * FROM vote WHERE id_post = ?');
		$reqAv->execute(array($id_post));
		return $reqAv->rowCount();
		


	}

	function getPosts($mode,$pseudo=''){

		require('co_pdo.php');

		/* $mode: set the mode to display posts
		* = homeNoConnect: Display all messages (10?) range by points
		* = homeConnect: Dipslay all messages from followed users
		* = profile: Display all messages of the current user
		*
		*
		*
		*
		**/


		if($mode == 'homeNoConnect'){

			$req = $bdd->prepare('SELECT * FROM posts ORDER BY points DESC LIMIT 10');
			$req->execute();
			while($resp = $req->fetch()){?>

			<div class="block">
				<div class="block-title">
				<img class="block-img" src="img/user.png" alt="<?=$resp['author']; ?>">
			  	 <h6 class="block-name"><strong><?=$resp['author']; ?></strong></h6>
			  	<h6 class="block-points">Points : <strong> <?=$resp['points']; ?></strong></h6>
			 	 <p class="block-date">Dernière activité : <strong>Jamais</strong></p>
				</div>
				<p class="block-bio"><?=$resp['message']; ?></p>

				<?php if($resp['video'] != ''){ 

					/*Démarrage de la conversion */
					$url  = $resp['video'];
					$pattern = '/[\\?\\&]v=([^\\?\\&]+)/';
					preg_match($pattern,$url,$matches);

					if(isset($matches[1])){

						$id_vid = $matches[1];
						echo '<div class="line-separator6"></div><div class="video"><iframe class="iframe"  src="https://www.youtube.com/embed/'.$id_vid.'" frameborder="0" allowfullscreen></iframe></div>'; 

					}	
		
				/*Fin de la conversion*/

					
						
				 } ?>
				
				
				<div class="line-separator6"></div>
				<br/>
			   <div class="abouts">
			  	 	<h6 class="block-name"><strong><?=$resp['title']; ?></strong></h6>
			  	<h6 class="block-points">Vues : <strong> <?=$resp['views']; ?></strong></h6>
			 	<p class="block-date">Le <strong><?=$resp['datecreation']; ?></strong></p>
			 	 <a href="#" class="block-more">En savoir plus</a>
			   	
			   	<div class="votes">
    			<h4 class="votes-title"></h4>
    			 <div class="vote-bar">
     			<span onclick="userVote(1,<?=$resp['ID']; ?>);">&#9734;</span>
      			<span onclick="userVote(2,<?php echo $resp['ID']; ?>);">&#9734;</span>
      			 <span onclick="userVote(3,<?php echo $resp['ID']; ?>);">&#9734;</span>
     			 <span onclick="userVote(4,<?php echo $resp['ID']; ?>);">&#9734;</span>
     			<span onclick="userVote(5,<?php echo $resp['ID']; ?>); return false;">&#9734;</span>
     				</div>
     				<p>Moyenne: 
     				<?php echo getAverageVote($resp['ID']); ?>/5 pour <?php echo getNumberVote($resp['ID']); ?> votants.</p>
    		</div>
			</div>
			</div>

		
			



			<?php }

		}			

	}

?><commit_msg>ajout du lien de redirection vers le post dans la page d'accueil<commit_after><?php
	function getAverageVote($id_post){

		require('co_pdo.php');
		$reqAv = $bdd->prepare('SELECT avg(vote) FROM vote WHERE id_post = ?');
		$reqAv->execute(array($id_post));
		$resp = $reqAv->fetch();
		return round($resp['avg(vote)'],1);
		

	}

	function getNumberVote($id_post){

		require('co_pdo.php');
		$reqAv = $bdd->prepare('SELECT * FROM vote WHERE id_post = ?');
		$reqAv->execute(array($id_post));
		return $reqAv->rowCount();
		


	}

	function getPosts($mode,$pseudo=''){

		require('co_pdo.php');

		/* $mode: set the mode to display posts
		* = homeNoConnect: Display all messages (10?) range by points
		* = homeConnect: Dipslay all messages from followed users
		* = profile: Display all messages of the current user
		*
		*
		*
		*
		**/


		if($mode == 'homeNoConnect'){

			$req = $bdd->prepare('SELECT * FROM posts ORDER BY points DESC LIMIT 10');
			$req->execute();
			while($resp = $req->fetch()){?>

			<div class="block">
				<div class="block-title">
				<img class="block-img" src="img/user.png" alt="<?=$resp['author']; ?>">
			  	 <h6 class="block-name"><strong><?=$resp['author']; ?></strong></h6>
			  	<h6 class="block-points">Points : <strong> <?=$resp['points']; ?></strong></h6>
			 	 <p class="block-date">Dernière activité : <strong>Jamais</strong></p>
				</div>
				<p class="block-bio"><?=$resp['message']; ?></p>

				<?php if($resp['video'] != ''){ 

					/*Démarrage de la conversion */
					$url  = $resp['video'];
					$pattern = '/[\\?\\&]v=([^\\?\\&]+)/';
					preg_match($pattern,$url,$matches);

					if(isset($matches[1])){

						$id_vid = $matches[1];
						echo '<div class="line-separator6"></div><div class="video"><iframe class="iframe"  src="https://www.youtube.com/embed/'.$id_vid.'" frameborder="0" allowfullscreen></iframe></div>'; 

					}	
		
				/*Fin de la conversion*/

					
						
				 } ?>
				
				
				<div class="line-separator6"></div>
				<br/>
			   <div class="abouts">
			  	 	<h6 class="block-name"><strong><?=$resp['title']; ?></strong></h6>
			  	<h6 class="block-points">Vues : <strong> <?=$resp['views']; ?></strong></h6>
			 	<p class="block-date">Le <strong><?=$resp['datecreation']; ?></strong></p>
			 	 <a href="posts.php?id=<?php echo $resp['ID']; ?>" class="block-more">En savoir plus</a>
			   	
			   	<div class="votes">
    			<h4 class="votes-title"></h4>
    			 <div class="vote-bar">
     			<span onclick="userVote(1,<?=$resp['ID']; ?>);">&#9734;</span>
      			<span onclick="userVote(2,<?php echo $resp['ID']; ?>);">&#9734;</span>
      			 <span onclick="userVote(3,<?php echo $resp['ID']; ?>);">&#9734;</span>
     			 <span onclick="userVote(4,<?php echo $resp['ID']; ?>);">&#9734;</span>
     			<span onclick="userVote(5,<?php echo $resp['ID']; ?>); return false;">&#9734;</span>
     				</div>
     				<p>Moyenne: 
     				<?php echo getAverageVote($resp['ID']); ?>/5 pour <?php echo getNumberVote($resp['ID']); ?> votants.</p>
    		</div>
			</div>
			</div>

		
			



			<?php }

		}			

	}

?>
{'fraction_non_alphanumeric': 0.2420810766453307, 'fraction_numerical': 0.015099294272115543, 'mean_word_length': 3.297602256699577, 'pattern_counts': {'":': 0, '<': 162, '<?xml version=': 0, '>': 180, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '216781', 'n_tokens_mistral': 2612, 'n_tokens_neox': 2188, 'n_words': 399}