/
blog.php
190 lines (156 loc) · 6.33 KB
/
blog.php
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
header( 'content-type: text/html; charset=utf-8' );
session_start();
require_once 'core/SPDO.class.php';
require_once 'core/blog/classes/articles.class.php';
require_once 'core/utilitaires.class.php';
require_once 'core/Pagination.class.php';
require_once 'core/admin/admin.class.php';
setlocale(LC_TIME, "fr_FR", "fr_FR@euro", "fr", "FR", "fra_fra", "fra");
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<?php
// Get administration setting
$oAdmin = new Admin();
$aSet = $oAdmin -> getSetting();
$smtp = $aSet['smtp_sendmail'];
$port = $aSet['port_sendmail'];
$email_send = $aSet['email_sendmail'];
$oPagination = new Pagination();
$lang = $aSet['language'];
$host = $aSet['websitehost'];
ini_set('SMTP', $smtp);
ini_set('smtp_port', $port);
ini_set('sendmail_from', $email_send);
// Filtering $_GET et $_POST variables
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$cat = filter_input(INPUT_GET, 'cat', FILTER_SANITIZE_NUMBER_INT);
$new = filter_input(INPUT_GET, 'new', FILTER_SANITIZE_STRING);
$rep = filter_input(INPUT_GET, 'rep', FILTER_SANITIZE_STRING);
// $_POST variables
$nom = filter_input(INPUT_POST, 'nom', FILTER_SANITIZE_STRING);
$mail = filter_input(INPUT_POST, 'mail', FILTER_SANITIZE_URL);
$siteweb= filter_input(INPUT_POST, 'siteweb', FILTER_SANITIZE_URL);
$contenu= filter_input(INPUT_POST, 'contenu', FILTER_SANITIZE_STRING);
$oMetaArt = new Articles;
$oUtil = new Utilitaires;
// Meta-data
if (isset($id)) {
$aMetaData = $oMetaArt->ReadMetaData($_GET['id']);
$oUtil->DisplayPageMetaData($aMetaData['titre_art'], $aMetaData['resum_art'], $aMetaData['keywords_art'] );
unset($oMetaArt);
unset($oUtil);
}
// Default meta-data
elseif (!isset($_GET['id'])){
$oUtil->DisplayPageMetaData('Présentation des articles', 'Description de la page', 'php, html, css, Mysql' );
}
?>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- *** CSS *** -->
<link rel="stylesheet" href="css2/cssgeneral-s1.css">
<!-- Gestion des boutons validation formulaires -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css2/jquery.floating-social-share.min.css" />
<!-- *** JS *** -->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="addons/js/respond.js"></script>
<script src="addons/js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<!--#include virtual="includes/menu.html" -->
</div>
</div>
<?php
$oArticles = new Articles;
if (!isset($id)){
// Reading categories and combo display for selecting categories
$alistCat = $oArticles->getCategoryData();
include 'core/blog/views/form-categories.php';
}
if (isset($cat)) {
// If a category is specified then display the articles in this category
$oArticles->ReadAllArticles('util', $cat);
$aConfigValues = $oArticles->getConfigValues();
include 'core/blog/views/display_all_articles.php';
// Pagination
$nbTotArt = $aConfigValues['total_nbr_display'];
$nbrPerPage = $aConfigValues['art_page'];
$oPagination->DisplayPagination($nbTotArt, $nbrPerPage, 'blog.php', "cat=$cat");
}
elseif ((!isset($cat) OR $cat == 'Tous') AND !isset($id)) {
// If no selected category or 'All' is selected then display all articles (all categories)
$aArticles = $oArticles->ReadAllArticles('util', 0);
$aConfigValues = $oArticles->getConfigValues();
include 'core/blog/views/display_all_articles.php';
// Result Pagination
$nbTotArt = $aConfigValues['total_nbr_display'];
$nbrPerPage = $aConfigValues['art_page'];
$oPagination->DisplayPagination($nbTotArt, $nbrPerPage, 'blog.php', '');
}
// otherwise if a post is displaying
elseif (isset($id)){
// Recording a comment or response (if entry form)
$aMsg = $oAdmin->getItemTransation('BLOG', 'FRONT', $lang, 'MSG_COMMENTS_PUBLISH');
if (isset($new)){
// Registration new comment.
$oArticles->RecordNewComm($nom, $mail, $siteweb, $contenu, $id, 'new', $aMsg, $host);
}
if (isset($rep)){
// Recording a response to a comment.
$oArticles->RecordNewComm($nom, $mail, $siteweb, $contenu, $rep, 'rep', $aMsg, $host);
}
// Article display
if ( (!isset($rep)) && (!isset($new)) ){
$aArticle = $oArticles->ReadOneArticle($id);
include 'core/blog/views/display-one-article.php';
// Displaying comments
$aComm = $oArticles->ReadComments($id);
include 'core/blog/views/display-comments.php';
}
}
unset($oArticles);
?>
<!-- JavaScript
================================================== -->
<!-- jquery -->
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> -->
<!-- mediaquery -->
<script src="addons/js/css3-mediaqueries.min.js"></script>
<!-- Gestion des boutons validation formulaires -->
<script src="addons/js/jqBootstrapValidation.js"></script>
<script>
$(function() {
$("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
});
</script>
<script type="text/javascript" src="addons/js/jquery.floating-social-share.min.js"></script>
<?php if (isset($id)) { ?>
<script>
$("body").floatingSocialShare({
place: "top-left", // alternatively top-right
counter: false, // set to false for hiding the counters of buttons
buttons: ["facebook", "twitter", "google-plus", "linkedin", "envelope"], // all of the currently avalaible social buttons
title: document.title, // your title, default is current page's title
url: window.location.href, // your url, default is current page's url
text: "Partager sur ", // the title of a tags
description: $('meta[name="description"]').attr("content"), // your description, default is current page's description
popup_width: 400, // the sharer popup width, default is 400px
popup_height: 300 // the sharer popup height, default is 300px
});
</script>
<?php } ?>
</div>
</body>
</html>