-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetseries.php
More file actions
117 lines (102 loc) · 2.87 KB
/
getseries.php
File metadata and controls
117 lines (102 loc) · 2.87 KB
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
<?php
//PHP SCRIPT: getimagesdb.php
//require_once 'config.php';
//$displayName = $_GET['displayName'];
//function to return the series that a user has posted to
function findSeries($displayName) {
$ctItem = 0;
$ctSeries = 0;
//get email
$toSend = "SELECT `User`.Email FROM `User`
WHERE `User`.DisplayName = :displayName;";
$connect = connect_tsbac();
$stmt = $connect->prepare($toSend, $GLOBALS['PDO_ATTRIBS']);
$stmt->execute(array(':displayName'=>$displayName));
$numrows = $stmt->rowCount();
if ($numrows > 0) {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$email = $row['Email'];
}
//get the current series (this may be multiple)
$toSend = "SELECT `Series`.`Tag` FROM `Series` WHERE `Series`.Visible = 1;";
$stmt = $connect->prepare($toSend, $GLOBALS['PDO_ATTRIBS']);
$stmt->execute();
$rows = $stmt->fetchAll();
$numrows = $stmt->rowCount();
if ($numrows > 0)
{
foreach($rows as $row)
{
$curTag = $row['Tag'];
// seperate tag into words if necessary
while (($spacePos = strpos($curTag, ' ')) > 0)
{
$restOf = substr($curTag, $spacePos+1);
$curTag = substr($curTag, 0, $spacePos-1);
$searchItem[$ctItem] = "@" . $curTag;
$curTag = $restOf;
$ctItem++;
} // no more spaces
$searchItem[$ctItem] = "@". $curTag;
$ctItem++;
$ctSeries++;
}
$fvItems = $ctItem;
}
//check for posts into the series.
$ctSeries = 0;
for ($i=0; $i<$fvItems; $i++)
{
$toSend = "SELECT ImgID FROM `Images` "
. " WHERE `Desc` LIKE :searchItem AND "
. " `Email` = :email ;";
$stmt = $connect->prepare($toSend, $GLOBALS['PDO_ATTRIBS']);
$stmt->execute(array(":searchItem"=>"%$searchItem[$i]%", ":email"=>$email));
$numrows = $stmt->rowCount();
if ($numrows > 0)
{
$foundSeries[$ctSeries]= substr($searchItem[$i],1) . "%";
$ctSeries++;
}
}
//"blindly" get the names back based on the found series
$ctSeries = 0;
$fvItem = count($foundSeries);
if ($fvItem > 0)
{
//build a search query
$toSend = "SELECT DISTINCT Name, Tag FROM Series "
." WHERE `Tag` LIKE ? ";
// append or's
for ($i=1; $i<$fvItem ; $i++)
{
$toSend .= " OR `Tag` LIKE ? ";
}
$toSend .= " ; ";
$stmt = $connect->prepare($toSend, $GLOBALS['PDO_ATTRIBS']);
$stmt->execute(array_values($foundSeries));
$rows = $stmt->fetchAll();
$numrows = $stmt->rowCount();
if ($numrows>0)
{
echo "<table class='series'> <tr><td> Series Posted To: </td> </tr> ";
foreach ($rows as $row)
{
$linkDesc = $row['Name'];
$series = $row['Tag'];
//find space in tag
if (($spacePos = strpos($series, ' ')) > 0) //if there's a space
{
//isolate series tag so we can put it in a link.
$series = substr($series, 0, $spacePos);
}
echo "<tr> <td> ";
echo "<a href='viewSeries.php?series=$series'> $linkDesc </a> ";
echo "</td> </tr> ";
}
echo "</table> " ;
}
}
return;
}
?>