-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag.php
144 lines (132 loc) · 4.48 KB
/
tag.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
<?php
session_start();
$tag = ucwords($_GET['tag']);
?><!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<link rel="stylesheet" type="text/css" href="sketchy.css">
<title>Sketchy | <?=$tag;?></title>
<script src="js/masonry.pkgd.min.js"></script>
</head>
<body>
<div id="page-wrap">
<div class="row1">
<header>
<div class="col-1">
<div id="headleft">
<h1><a id="head" href='home.php'>Sketchy</a></h1>
<form method='get' action='search.php'>
<input type=search name=s placeholder="search sketches">
<input type='submit' value='search' name='submit'>
</form>
See All Sketches → <a href='sketches.php'>Ⓢ</a>
</div>
<span id="sub">SVG for You and Me</span>
</div>
</header>
</div>
<div class="row2">
<nav>
<div class="col-1-3">
<a href='#'>about</a>
</div>
<div class="col-1-3">
<a href='#'>resources</a>
</div>
<div class="col-1-3">
<a href='#'>terms and conditions</a>
</div>
</nav>
</div>
<div class="row3">
<div class="col-1">
<section>
<?php
if(!isset($_SESSION['sketcherid']))
{
die("<h3>Sorry, but you are not logged in. Try <a href='index.php'>logging
in</a> again.</h3>");
}
else
{
include("inc_sketchy_connect.php");
if ($DBConnect === FALSE)
{
die("<p>Connection error: " . mysqli_error() . "</p>\n");
}
else
{
if ($DBSelect === FALSE)
{
die("<p>Could not select the \"$DBName\" " . "database: " .
mysqli_error($DBConnect) . "</p>\n");
}
$tagid = $_GET['tagid'];
echo "<h2>$tag Sketches</h2>";
echo "</section>";
echo "</div>";
echo "</div>";
$query1 =
"SELECT sketch.sketchid, title, date, description, path FROM tags, describes, sketch
WHERE sketch.sketchid=describes.sketchid
AND describes.tagid=tags.tagid AND tags.tagid=$tagid
ORDER BY sketchid DESC";
$result1 = mysqli_query($DBConnect, $query1);
echo "<div id='container' class='js-masonry''data-masonry-options='{'itemSelector':'.item'}'>";
while ($row = mysqli_fetch_assoc($result1))
{
echo "<div class='item'>";
echo "<div class='center'>";
echo "<div class='title'>{$row['title']}</div><br>";
echo "<div class='svg_overlay'>";
echo "<div onclick='alert(this.innerHTML)'>";
$svg_path = ($row['path']);
echo file_get_contents($row['path']);
echo "</div>";//ends svg onclick alert
echo "</div>";//end svg_overlay
echo "<div class='description'>{$row['description']}<br>";
$date = "{$row['date']}";
$query2=
"SELECT sketcher.sketcherid, username FROM sketcher, sketch
WHERE sketcher.sketcherid=sketch.sketcherid
AND sketchid={$row['sketchid']}";
$result2 = mysqli_query($DBConnect, $query2);
$query3 =
"SELECT tags.tagid, tag FROM tags, describes, sketch
WHERE sketch.sketchid=describes.sketchid
AND describes.tagid=tags.tagid
AND sketch.sketchid={$row['sketchid']}";
$result3 = mysqli_query($DBConnect, $query3);
while ($row = mysqli_fetch_assoc($result2))
{
echo "<span class='date'>added by <a href='sketcher.php?sketcherid={$row['sketcherid']}&sketcher={$row['username']}'>{$row['username']}</a> on $date</span></div>";
}
echo "<div class='tag'>";
while ($row = mysqli_fetch_assoc($result3))
{
echo "|<a href='tag.php?tagid={$row['tagid']}&tag={$row['tag']}'> {$row['tag']} </a>";
}
echo "|</div>";//ends tag dig
echo "<a class='deconstruct' href='tag.php?tagid=$tagid&tag=$tag&svg=$svg_path#decon'>deconstruct</a>";
echo "</div>";
echo "</div>";//div class item
}
echo "</div>";//end container
if(isset($_GET['svg']))
{
echo "<span id='decon'>";
$svg = $_GET['svg'];
include("parseSVG.php");
parseSVG($svg);
echo "</span>"; //end shapes class and parseSVG function
}
mysqli_close($DBConnect);
}//ends successful DBConnect else statement
} //ends php code on submission button
?>
</div><!--end col-1-->
</div><!--end row3-->
</div><!--end page-wrap-->
</body>
</html>