This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
114 lines (104 loc) · 3.63 KB
/
search.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
<?php
session_start();
include('actions/functions.php');
if((!isset($_SESSION['is_logged'])) || ($_SESSION['is_logged']==false)) {
header('Location: index.php');
exit();
}
else {
$accountID=$_SESSION['account_accountID'];
}
$is_good=false;
if(isset($_POST['submit'])) {
if((!isset($_POST['search'])) || ($_POST['search']=="")) {
$sr_error="Fill search field";
$is_good=false;
}
else {
$search= "%".$_POST['search']."%";
$is_good=true;
}
}
require_once "connect.php";
mysqli_report(MYSQLI_REPORT_STRICT);
try {
$connect = @new mysqli($host, $user, $pass, $database);
if($connect->connect_errno!=0) {
throw new Exception(mysqli_connect_errno());
}
}
catch(Exception $e) {
echo "<i>Error:</i>";
echo "<div class='error'><b>Dev info:</b> ".$e."</div>";
}
?><!--W przyszłości dodać jeszcze do tabeli server tagi itd. i filtracje tutaj-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Discerd | Search</title>
<link rel="stylesheet" href="styles/style.css">
<link rel="stylesheet" href="styles/discerd.css">
<link rel="icon" href="imgs/icon.ico">
<script src="scripts/validation.js"></script>
</head>
<body>
<div class="banner">
<a href="discerd.php"><img src="imgs/banner.png"></a>
<ol>
<?php
echo "<li>
<form name='search' action='' method='post' onsubmit='return searches();'>
<input type='text' placeholder='Search..' onfocus='this.placeholder=``' onblur='this.placeholder=`Search..`' name='search'>
<input type='submit' value='search' name='submit'>
</form>
</li>";
?>
</ol>
</div>
<div class="servers">
<?php //list of servers
servers($accountID, $connect);
?>
</div>
<div class="friends">
<?php //list of users
friends($accountID, $connect);
?>
</div>
<div class="content" class="friendscontent">
<div class="error" id="sr_error" style="text-align: center;">
<?php
if(isset($sr_error)) {
echo $sr_error;
unset($sr_error);
}
?>
</div>
<?php
if($is_good) {
try {
if($result = $connect->query(sprintf("SELECT serverID ,server_name, server_icon FROM `server` WHERE server_name LIKE'%$search%' AND is_public=1"))) {
while($row=$result->fetch_assoc()) {
echo "<div class='friendscontent'>";
$id=$row['serverID'];
echo "<img src='usersimgs/".$row['server_icon']."' class='friendsimage'>";
echo $row['server_name']."<br><a href='invite.php?serverID=".$id."&groupID=NULL&message='><span style='text-align: right;'>Join</span></a>";
echo "</div>";
}
}
else {
throw new Exception($connect->error);
}
}
catch(Exception $e) {
echo "<i>Error:</i>";
echo "<div class='error'><b>Dev info:</b> ".$e."</div>";
$connect->close();
}
}
?>
</div>
</body>
</html>