-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelp.php
More file actions
205 lines (180 loc) · 8.87 KB
/
help.php
File metadata and controls
205 lines (180 loc) · 8.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] != true) {
header("location: login.php");
exit;
}
$feed = false;
// Check if form is submitted and the token matches
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
// Validate token
if (!empty($_SESSION['form_token']) && $_POST['form_token'] === $_SESSION['form_token']) {
// Process form submission
$qe = $_POST['fe'];
include 'partials/_dbconnect.php';
$username = $_SESSION['username'];
$sql = "INSERT INTO `userqueries` (`username`, `question`) VALUES ('$username', '$qe')";
$result = mysqli_query($conn, $sql);
if ($result) {
$feed = true;
}
// Invalidate the token to prevent multiple submissions
unset($_SESSION['form_token']);
} else {
// Invalid or missing token, handle accordingly (optional)
// For example, you could log an error or redirect the user.
echo "Invalid form submission.";
exit;
}
}
// Generate a new form token
$_SESSION['form_token'] = bin2hex(random_bytes(32));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://getbootstrap.com/docs/5.3/assets/css/docs.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/d01fd9c369.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>CodeCraft! FAQ Page</title>
<link rel="icon" type = "image/x-icon" href="favicon-32x32.png">
<link rel="stylesheet" href="stylehelp.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#"><i class="fa-solid fa-bug"></i> CodeCraft!</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/loginsystem/welcome1.php"> <i class="fa-solid fa-house"></i> Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/loginsystem/New folder/default.php"> <i class="fa-solid fa-code"></i> Editor!</a>
</li>
</ul>
</div>
</div>
</nav>
<?php
if($feed){
echo '<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Thank You So Much! </strong>We Will Respond Soon !
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
?>
<div class="container">
<h2 class="title"><i class="fa-solid fa-circle-question"></i> Frequently Asked Questions</h2>
<div class="question" onclick="toggleAnswer('q1')">Q: Which Languages does it supports ?</div>
<div class="answer" id="q1"><i class="fa-solid fa-arrow-right"></i> Codecraft! is a editor for web developement, so it supports programming Languages such as, HTML5, CSS, and Javascript.<br>
<i class="fa-solid fa-arrow-right"></i> Although, in the upcoming versions you will definetely find more Languages support.
<div class="like-dislike">
<button class="like" onclick="likeAnswer('q1')">👍</button>
<button class="dislike" onclick="dislikeAnswer('q1')">👎</button>
</div>
</div>
<div class="question" onclick="toggleAnswer('q2')">Q: Which Mode to choose classic or default ?</div>
<div class="answer" id="q2"><i class="fa-solid fa-arrow-right"></i> It depends, the default mode has a smaller output screen, so it is better to use defaut mode
when you are using the editor for testing codes and when you are writing the smaller codes.<br>
<i class="fa-solid fa-arrow-right"></i>Whereas on the other hand the classic mode has a larger output screen, so it can be used for testing as well as for developement
purpose and for writing longer codes.
<div class="like-dislike">
<button class="like" onclick="likeAnswer('q2')">👍</button>
<button class="dislike" onclick="dislikeAnswer('q2')">👎</button>
</div>
</div>
<div class="question" onclick="toggleAnswer('q3')">Q: What if dont't log in ?</div>
<div class="answer" id="q3"><i class="fa-solid fa-arrow-right"></i> If you dont log-in, you can still use the CodeCraft! editor, but you can only use it in default mode, moreover
you won't be able to use the download option.<br>
<i class="fa-solid fa-arrow-right"></i> We, would not recommend you to use CodeCraft without log-in, we would love it if you join us and give us your valuable feedback and support us.<br>
<div class="like-dislike">
<button class="like" onclick="likeAnswer('q3')">👍</button>
<button class="dislike" onclick="dislikeAnswer('q3')">👎</button>
</div>
</div>
<div class="question" onclick="toggleAnswer('q4')">Q: Where is my code saved when i click download button ?</div>
<div class="answer" id="q4"><i class="fa-solid fa-arrow-right"></i> In case you are using the default mode, all your codes will be downloaded in text file format, and it
will reflect in your pc's downloads folder.<br>
<i class="fa-solid fa-arrow-right"></i>In case you are using the classic mode, your html code will be downloaded as .html file, your css code will be downloaded as .css file,
and your javascript code will be downloaded as .js file.<br>
<i class="fa-solid fa-arrow-right"></i> All your files will reflect in your downloads folder.
<div class="like-dislike">
<button class="like" onclick="likeAnswer('q4')">👍</button>
<button class="dislike" onclick="dislikeAnswer('q4')">👎</button>
</div>
</div>
<div class="form-container">
<h3>Any other question related to <i class="fa-solid fa-bug"></i> CodeCraft?</h3>
<form action="/loginsystem/help.php" method="post">
<!-- Hidden input field for form token -->
<input type="hidden" name="form_token" value="<?php echo $_SESSION['form_token']; ?>">
<input type="text" id="question" placeholder="Enter your question" name="fe">
<br>
<input type="submit" value="Submit" name="submit">
</form>
</div>
<br>
<h2 class="title"><i class="fa-solid fa-circle-question"></i> Admin Responses</h2>
<div class="question"><i class="fa-solid fa-arrow-right"></i>
<?php
include 'partials/_dbconnect.php';
$res;
$usname = $_SESSION['username'];
$sql = "SELECT * FROM userqueries where username = '$usname'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// Output data of each row in reverse order
while($row = $result->fetch_assoc()) {
$row["response"];
echo $row["response"];
}
} else {
$error = "We will Respond soon";
}
// Close database connection
$conn->close();
?>
</div>
</div>
<script>
function toggleAnswer(id) {
var answer = document.getElementById(id);
if (answer.style.display === "block") {
answer.style.display = "none";
} else {
answer.style.display = "block";
}
}
function likeAnswer(id) {
var likeButton = document.querySelector('#' + id + ' .like');
var dislikeButton = document.querySelector('#' + id + ' .dislike');
likeButton.classList.toggle('clicked');
dislikeButton.classList.remove('clicked');
}
function dislikeAnswer(id) {
var likeButton = document.querySelector('#' + id + ' .like');
var dislikeButton = document.querySelector('#' + id + ' .dislike');
dislikeButton.classList.toggle('clicked');
likeButton.classList.remove('clicked');
}
function submitQuestion(event) {
event.preventDefault();
var questionInput = document.getElementById('question');
var message = document.getElementById('message');
if (questionInput.value.trim() !== '') {
message.style.display = 'block';
questionInput.value = '';
}
}
</script>
</body>
</html>