Show sourcecode

The following files exists in this folder. Click to view.

Foogler_blog/pages

PAuthor.php
PCommentProcess.php
PDeleteCommentProcess.php
PDeletePost.php
PDeletePostProcess.php
PEditPost.php
PEditPostProcess.php
PErDiagramme.php
PIndex.php
PInstall.php
PInstallProcess.php
PNewPost.php
PNewPostProcess.php
PRssFeed.php
PShowPost.php
PStatistics.php
PValidate.php
login/

PIndex.php

99 lines ASCII Windows (CRLF)
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
<?php
//--------------------
//PIndex.php
//
//Index page showing all posts
//or posts by selected category
//--------------------

//-----------------------------------
//Handles GET variables
$chosenTag = isset($_GET['tag']) ? $_GET['tag'] : '';
$chosenAuthor = isset($_GET['author']) ? $_GET['author'] : '';
$chosenDate = isset($_GET['date']) ? $_GET['date'] : '';

//-----------------------------------
//Handles DB stuff
$mysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORDDB_DATABASE); //New DB object
$tablePost   DB_PREFIX 'Post';
$tableTag   DB_PREFIX 'Tag';
$tablePostTag   DB_PREFIX 'PostTag';
$tableAuthor  DB_PREFIX 'Author';

if (
mysqli_connect_error()) {
   echo 
"Connect failed: ".mysqli_connect_error()."<br>";
   exit();
}
$mysqli->set_charset("utf8");

//Prevent SQL injections
$chosenTag   $mysqli->real_escape_string($chosenTag);
$chosenAuthor   $mysqli->real_escape_string($chosenAuthor);
$chosenDate   $mysqli->real_escape_string($chosenDate);

//-----------------------------
//SQL query

//Checks which GET variables have been set and depending adds WHERE clauses
$whereClause "";
//If a tag has been chosen
if (isset($chosenTag) && $chosenTag != '') {
  
$whereClause = <<<END
  WHERE idPost IN (
    SELECT PostTag_idPost 
    FROM 
{$tablePostTag} 
    WHERE PostTag_idTag = (
      SELECT idTag 
      FROM 
{$tableTag} 
      WHERE tagName = "
{$chosenTag}"))
END;
}
//If an author has been chosen
if (isset($chosenAuthor) && $chosenAuthor != '') {
  
$whereClause = <<<END
  WHERE Post_idAuthor = (
    SELECT idAuthor 
    FROM 
{$tableAuthor} 
    WHERE screenname = '
{$chosenAuthor}')
END;
}
//If a date has been chosen
if (isset($chosenDate) && $chosenDate != '') {
  
$whereClause = <<<END
  WHERE MONTH(postDate) = MONTH('{$chosenDate}-01')
END;
}

//Query
$query = <<<END
--
-- Selects post from DB, with where clauses depending on user choice
--
SELECT idPost FROM 
{$tablePost}
{$whereClause}
ORDER BY postDate DESC;
END;

//Performs query
$res $mysqli->query($query) or die("Could not query database" $mysqli->errno .":" $mysqli->error); 

//-----------------------------------
//Prints HTML
require_once(TP_SOURCEPATH "CHTMLPage.php");

$page = new CHTMLPage();

//For each returned post, gets formatted post HTML
$html "";
while(
$row $res->fetch_object()) {
  
$html .= $page->getFormattedPost($row->idPost);
}
$res->close();
$mysqli->close(); //Close DB connection

$page->printHTMLHeader();
$page->printPageHeader();
$page->printPageBody($html);
$page->printTagList();
$page->printRightColumn();