aboutsummaryrefslogtreecommitdiff
path: root/Html/licpost.php
blob: a9da4018ad196c3a4bef36fa943395a225ea2a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
require_once('includes/config.php');

$stmt = $db->prepare('SELECT licenceID, licenceTitle FROM blog_licences WHERE licenceSlug = :licenceSlug');
$stmt->bindValue(':licenceSlug', $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch();

/*
//if post does not exists redirect user.
if($row['licenceID'] == ''){
        header('Location: ./');
        exit;
}
*/
if (!isset($row['licenceID']) || empty($row['licenceID'])) {
	header('Location: ./');
        exit();
} 

elseif (!filter_var($row['licenceID'], FILTER_VALIDATE_INT)) {
	header('Location: ./');
        exit();
}

$pagetitle = 'Licence : '.html($row['licenceTitle']);

include_once('includes/header.php');

define("_BBC_PAGE_NAME", $pagetitle);
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
?>

<body>
<div id="container">

		<?php
		include_once('includes/header-logo.php');
		include_once('includes/nav.php');
		?>

    	<div id="body">
			<div id="content">

			<?php
			include_once('includes/ariane.php');
			?>

			<br />

			
			<?php
                        try {

                                $pages = new Paginator('8','p');

                                $stmt = $db->prepare('SELECT blog_posts_seo.postID FROM blog_posts_seo, blog_post_licences WHERE blog_posts_seo.postID = blog_post_licences.postID_BPL AND blog_post_licences.licenceID_BPL = :licenceID');
                                $stmt->execute(array(':licenceID' => $row['licenceID']));

				$count = $stmt->rowCount();


                                //pass number of records to
                                $pages->set_total($stmt->rowCount());

                                $stmt = $db->prepare('
                                        SELECT
                                                blog_posts_seo.postID, blog_posts_seo.postTitle, blog_posts_seo.postAuthor, blog_posts_seo.postSlug, blog_posts_seo.postDesc, blog_posts_seo.postDate
                                        FROM
                                                blog_posts_seo,
                                                blog_post_licences
                                        WHERE
                                                 blog_posts_seo.postID = blog_post_licences.postID_BPL
                                                 AND blog_post_licences.licenceID_BPL = :licenceID
                                        ORDER BY
                                                postID DESC
                                        '.$pages->get_limit());
                                $stmt->execute(array(':licenceID' => $row['licenceID']));

				echo '<h3>'.$row['licenceTitle'].'</h3>';

				if (empty($count)) {
                                        echo '<p>Aucun torrent pour cette licence.</p>';
                                }

                                while($row1 = $stmt->fetch()){

                                        echo '<fieldset>';
                                                echo '<span style="font-weight: bold; font-size: 12pt;"><a style="text-decoration: none;" href="'.html($row1['postSlug']).'">'.html($row1['postTitle']).'</a></span>';
						echo '<br /><span style="font-size: 10pt;">Posté le '.date_fr('l j F Y à H:i:s', strtotime($row1['postDate'])).' par ';		
		
                                                $stmt2 = $db->prepare('SELECT catTitle, catSlug FROM blog_cats, blog_post_cats WHERE blog_cats.catID = blog_post_cats.catID AND blog_post_cats.postID = :postID');
                                                $stmt2->execute(array(':postID' => $row1['postID']));
                                                $catRow = $stmt2->fetchAll(PDO::FETCH_ASSOC);

						echo html($row1['postAuthor']).' dans ';

                                                        $links = array();
                                                        foreach ($catRow as $cat)
                                                        {
                                                            $links[] = "<a href='c-".$cat['catSlug']."'>".$cat['catTitle']."</a>";
                                                        }
                                                        echo implode(", ", $links);

                                        echo '</span></fieldset>';

                                }

				echo '<br /><br />';
                               	echo $pages->page_links('l-'.html($_GET['id']).'&');

                        } catch(PDOException $e) {
                            echo $e->getMessage();
                        }

                        ?>
			</div>
        
		<?php include_once('sidebar.php'); ?>
        
    	<div class="clear"></div>
		</div>
</div>

<div id="footer">
	<?php include_once('includes/footer.php'); ?>
</div>

</body>
</html>