-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
124 lines (118 loc) · 3.44 KB
/
home.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
<?php
session_start();
?><!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<link rel="stylesheet" type="text/css" href="sketchy.css">
<title>Sketchy | Home</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>Sketchy</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>
<h2>Your Sketches</h2>
<h3><a href="upload.php" id="addsketch">(Add a Sketch)</a></h3>
</section>
</div>
</div>
<?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");
}
$query1 =
"SELECT sketchid, title, date, description, path FROM sketch
WHERE sketcherid={$_SESSION['sketcherid']} 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>";
echo "<div class='svg_overlay'>";
echo "<div onclick='alert(this.innerHTML)'>";
$svg_path = ($row['path']);
echo file_get_contents($svg_path);
echo "</div>";//ends svg onclick alert
echo "</div>";//end svg_overlay
echo "<div class='description'>{$row['description']}<br>";
echo "<span class='date'>added on {$row['date']}</span></div>";
$query2 =
"SELECT tags.tagid, tag FROM tags, describes, sketch
WHERE sketch.sketchid=describes.sketchid
AND describes.tagid=tags.tagid
AND sketch.sketchid={$row['sketchid']}";
$result2 = mysqli_query($DBConnect, $query2);
echo "<div class='tag'>";
while ($row = mysqli_fetch_assoc($result2))
{
echo "|<a href='tag.php?tagid={$row['tagid']}&tag={$row['tag']}'> {$row['tag']} </a>";
}
echo "|</div>";
echo "<a class='deconstruct' href='home.php?svg=$svg_path#decon'>deconstruct</a>";
echo "</div>";//end column center
echo "</div>";//div class item
}
echo "</div>";//end container
if(isset($_GET['svg']))
{
echo "<div id='decon'>";
$svg = $_GET['svg'];
include("parseSVG.php");
parseSVG($svg);
echo "</div>"; //end shapes class and parseSVG function
}
mysqli_close($DBConnect);
}//ends successful DBConnect else statement
}
?>
</div><!--end page-wrap-->
</body>
</html>