Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sfcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush
sfcode
Commits
acda07e9
Commit
acda07e9
authored
Dec 07, 2020
by
Paarth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added questions backend
parent
0f54208a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
10 deletions
+80
-10
backend/database.sql
backend/database.sql
+27
-10
backend/questions/get_questions.php
backend/questions/get_questions.php
+21
-0
backend/questions/question_save.php
backend/questions/question_save.php
+31
-0
backend/register.php
backend/register.php
+1
-0
No files found.
backend/database.sql
View file @
acda07e9
-- phpMyAdmin SQL Dump
-- phpMyAdmin SQL Dump
-- version 5.0.
2
-- version 5.0.
3
-- https://www.phpmyadmin.net/
-- https://www.phpmyadmin.net/
--
--
-- Host: localhost
-- Host: localhost
-- Generation Time: Dec 07, 2020 at 0
6:55 A
M
-- Generation Time: Dec 07, 2020 at 0
1:18 P
M
-- Server version: 10.4.1
3
-MariaDB
-- Server version: 10.4.1
4
-MariaDB
-- PHP Version: 7.4.
8
-- PHP Version: 7.4.
11
SET
SQL_MODE
=
"NO_AUTO_VALUE_ON_ZERO"
;
SET
SQL_MODE
=
"NO_AUTO_VALUE_ON_ZERO"
;
START
TRANSACTION
;
START
TRANSACTION
;
...
@@ -23,6 +23,24 @@ SET time_zone = "+00:00";
...
@@ -23,6 +23,24 @@ SET time_zone = "+00:00";
-- --------------------------------------------------------
-- --------------------------------------------------------
--
-- Table structure for table `questions`
--
CREATE
TABLE
`questions`
(
`title`
varchar
(
50
)
NOT
NULL
,
`username`
varchar
(
50
)
NOT
NULL
,
`statement`
text
NOT
NULL
,
`tc1`
text
NOT
NULL
,
`out1`
text
NOT
NULL
,
`tc2`
text
NOT
NULL
,
`out2`
text
NOT
NULL
,
`stime`
datetime
NOT
NULL
,
`etime`
datetime
NOT
NULL
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
-- --------------------------------------------------------
--
--
-- Table structure for table `users`
-- Table structure for table `users`
--
--
...
@@ -41,15 +59,14 @@ CREATE TABLE `users` (
...
@@ -41,15 +59,14 @@ CREATE TABLE `users` (
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
--
--
--
Dumping data for table `users`
--
Indexes for dumped tables
--
--
INSERT
INTO
`users`
(
`id`
,
`username`
,
`name`
,
`password`
,
`email`
,
`img_url`
,
`n_attempts`
,
`correct_timeline`
,
`rating`
,
`n_files`
)
VALUES
(
26
,
'adarsh'
,
'adarsh'
,
'$2y$10$PT.s983qY0EjVx2w1JBRT.y3XO3kd4wnWIng7t4.udLeWAizHDfDi'
,
'a@g.com'
,
'https://bain.design/wp-content/uploads/2014/08/People-Avatar-Set-Rectangular-12.jpg'
,
0
,
'[]'
,
0
,
0
);
--
--
-- Indexes for
dumped tables
-- Indexes for
table `questions`
--
--
ALTER
TABLE
`questions`
ADD
PRIMARY
KEY
(
`title`
);
--
--
-- Indexes for table `users`
-- Indexes for table `users`
...
@@ -70,4 +87,4 @@ COMMIT;
...
@@ -70,4 +87,4 @@ COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */
;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */
;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */
;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */
;
\ No newline at end of file
backend/questions/get_questions.php
0 → 100644
View file @
acda07e9
<?php
include_once
(
"database.php"
);
if
(
$_SERVER
[
'REQUEST_METHOD'
])){
$sql1
=
"SELECT Now()"
;
$currtime
=
$mysqli
->
query
(
$sql1
);
$sql2
=
"SELECT * FROM questions WHERE stime <=
$currtime
and etime >=
$currtime
"
;
$data
=
[];
if
(
$result
=
mysqli
->
query
(
$sql2
)){
while
(
$row
=
mysql_fetch_assoc
(
$request
)){
array_push
(
$data
,
$row
);
}
echo
json_encode
(
$data
);
}
else
{
http_response_code
(
404
);
}
}
?>
\ No newline at end of file
backend/questions/question_save.php
0 → 100644
View file @
acda07e9
<?php
include_once
(
"database.php"
);
$postData
=
file_get_contents
(
"php://input"
);
if
(
isset
(
$postData
)
&&
!
empty
(
$postData
)){
$request
=
json_decode
(
$postData
);
$title
=
trim
(
$request
->
title
);
$username
=
trim
(
$request
->
username
);
//string
$statement
=
trim
(
$request
->
statement
);
//string
$tc1
=
trim
(
$request
->
tc1_inp
);
$out1
=
trim
(
$request
->
tc1_out
);
$tc2
=
trim
(
$request
->
tc2_inp
);
$out2
=
trim
(
$request
->
tc2_out
);
$stime
=
trim
(
$request
->
start_time
);
//string
$etime
=
trim
(
$request
->
end_time
)
$sql
=
"INSERT INTO questions(
$title
,
$username
,
$statement
,
$tc1
,
$out1
,
$tc2
,
$out2
,
$stime
,
$etime
)"
;
if
(
$result
=
$mysqli
->
query
(
$sql
)){
$msg
=
"question uploaded"
;
echo
json_encode
(
$msg
);
}
else
{
$msg
=
"title already exists"
;
echo
json_encode
(
$msg
);
}
}
?>
\ No newline at end of file
backend/register.php
View file @
acda07e9
...
@@ -29,3 +29,4 @@ if (isset($postData) && !empty($postData)) {
...
@@ -29,3 +29,4 @@ if (isset($postData) && !empty($postData)) {
echo
"mysqli_error(
$mysqli
)"
;
echo
"mysqli_error(
$mysqli
)"
;
}
}
}
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment