Skip to content

Commit 26df451

Browse files
authored
Add files via upload
1 parent e181512 commit 26df451

34 files changed

+3121
-0
lines changed

vAPI.postman_collection.json

+782
Large diffs are not rendered by default.

vapi.sql

+268
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 5.0.2
3+
-- https://www.phpmyadmin.net/
4+
--
5+
-- Host: 127.0.0.1
6+
-- Generation Time: Sep 06, 2020 at 05:56 PM
7+
-- Server version: 10.4.13-MariaDB
8+
-- PHP Version: 7.4.7
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
START TRANSACTION;
12+
SET time_zone = "+00:00";
13+
14+
15+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
16+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
17+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
18+
/*!40101 SET NAMES utf8mb4 */;
19+
20+
--
21+
-- Database: `vapi`
22+
--
23+
24+
-- --------------------------------------------------------
25+
26+
--
27+
-- Table structure for table `api1users`
28+
--
29+
30+
CREATE TABLE `api1users` (
31+
`id` int(10) UNSIGNED NOT NULL,
32+
`username` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
33+
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
34+
`course` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
35+
`password` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL
36+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
37+
38+
--
39+
-- Dumping data for table `api1users`
40+
--
41+
42+
INSERT INTO `api1users` (`id`, `username`, `name`, `course`, `password`) VALUES
43+
(1, 'michaels', 'Michael Scott', 'Business 101', '12345'),
44+
(2, 'meredithp', 'Meredith Palmer', 'Art of Intimidating', '12345'),
45+
(3, 'pambeese', 'Pam Beesly', 'Sketching for Dummies', '12345'),
46+
(4, 'jimhalp', 'Jim Halpert', 'Art of Pranks', '12345');
47+
48+
-- --------------------------------------------------------
49+
50+
--
51+
-- Table structure for table `api2users`
52+
--
53+
54+
CREATE TABLE `api2users` (
55+
`id` int(6) NOT NULL,
56+
`email` varchar(120) NOT NULL,
57+
`password` varchar(120) NOT NULL,
58+
`name` varchar(120) NOT NULL,
59+
`token` varchar(120) NOT NULL,
60+
`address` varchar(240) NOT NULL,
61+
`city` varchar(120) NOT NULL,
62+
`country` varchar(120) NOT NULL
63+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
64+
65+
--
66+
-- Dumping data for table `api2users`
67+
--
68+
69+
INSERT INTO `api2users` (`id`, `email`, `password`, `name`, `token`, `address`, `city`, `country`) VALUES
70+
(1, '[email protected]', 'zTyBwV/9', 'Evelyn', 'Fp0r1mty_gxK9DRZ5IUw3sX2enQ6rau68M6YGyoqR3XoBG13wtSbvmdaK5CB', '10th Downing', 'Mesport', 'USA'),
71+
(2, '[email protected]', 'kU-wDE7r', 'Tara', '1Nkoz6quzJiis1SEonJeSxwkXTzSzcULofbL9O7KPz6_sKGkUcQDzoNfI5aA', 'Wisdom Corner', 'Delhi', 'India'),
72+
(3, '[email protected]', 'kU-wDE7r', 'Joyce', 'sLqs17RjmdlWoBP2ONdAPP8WtIVNwlyz_qzLwhmJGboWD_asFICYggcE3bPi', 'San Jose', 'California', 'USA');
73+
74+
-- --------------------------------------------------------
75+
76+
--
77+
-- Table structure for table `api5users`
78+
--
79+
80+
CREATE TABLE `api5users` (
81+
`id` int(5) NOT NULL,
82+
`username` varchar(129) NOT NULL,
83+
`password` varchar(120) NOT NULL,
84+
`name` varchar(120) NOT NULL,
85+
`address` varchar(240) NOT NULL,
86+
`mobileno` varchar(10) NOT NULL
87+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
88+
89+
--
90+
-- Dumping data for table `api5users`
91+
--
92+
93+
INSERT INTO `api5users` (`id`, `username`, `password`, `name`, `address`, `mobileno`) VALUES
94+
(1, 'admin', 'admin!@#$', 'Admin User', 'ABCD XYZZ', '8080808080');
95+
96+
-- --------------------------------------------------------
97+
98+
--
99+
-- Table structure for table `api6users`
100+
--
101+
102+
CREATE TABLE `api6users` (
103+
`id` int(5) NOT NULL,
104+
`name` varchar(120) NOT NULL,
105+
`username` varchar(120) NOT NULL,
106+
`password` varchar(120) NOT NULL,
107+
`credit` varchar(8) NOT NULL
108+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
109+
110+
--
111+
-- Dumping data for table `api6users`
112+
--
113+
114+
INSERT INTO `api6users` (`id`, `name`, `username`, `password`, `credit`) VALUES
115+
(3, 'Tushar', 'roottusk', 'abcd1234', '100');
116+
117+
-- --------------------------------------------------------
118+
119+
--
120+
-- Table structure for table `api7users`
121+
--
122+
123+
CREATE TABLE `api7users` (
124+
`id` int(5) NOT NULL,
125+
`username` varchar(120) NOT NULL,
126+
`password` varchar(120) NOT NULL,
127+
`authkey` varchar(240) NOT NULL
128+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
129+
130+
--
131+
-- Dumping data for table `api7users`
132+
--
133+
134+
INSERT INTO `api7users` (`id`, `username`, `password`, `authkey`) VALUES
135+
(1, 'admin', 'Kencing@001', '8ba30b496fae88ec808d6dc74f85952d06e3739696fe689b228bc0d906d2999e');
136+
137+
-- --------------------------------------------------------
138+
139+
--
140+
-- Table structure for table `api9users`
141+
--
142+
143+
CREATE TABLE `api9users` (
144+
`id` int(5) NOT NULL,
145+
`username` varchar(120) NOT NULL,
146+
`password` varchar(120) NOT NULL,
147+
`name` varchar(120) NOT NULL
148+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
149+
150+
-- --------------------------------------------------------
151+
152+
--
153+
-- Table structure for table `comments`
154+
--
155+
156+
CREATE TABLE `comments` (
157+
`id` int(6) NOT NULL,
158+
`postid` int(5) NOT NULL,
159+
`deviceid` varchar(120) NOT NULL,
160+
`latitude` varchar(120) NOT NULL,
161+
`longitude` varchar(120) NOT NULL,
162+
`commenttext` varchar(120) NOT NULL,
163+
`username` varchar(120) NOT NULL
164+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
165+
166+
--
167+
-- Dumping data for table `comments`
168+
--
169+
170+
INSERT INTO `comments` (`id`, `postid`, `deviceid`, `latitude`, `longitude`, `commenttext`, `username`) VALUES
171+
(1, 1, 'q6ET5hl2V2fa8u4pQxRB', '45.5426274', '-122.7944111', 'THIS POST IS SH***Y', 'baduser007');
172+
173+
--
174+
-- Indexes for dumped tables
175+
--
176+
177+
--
178+
-- Indexes for table `api1users`
179+
--
180+
ALTER TABLE `api1users`
181+
ADD PRIMARY KEY (`id`),
182+
ADD UNIQUE KEY `username` (`username`);
183+
184+
--
185+
-- Indexes for table `api2users`
186+
--
187+
ALTER TABLE `api2users`
188+
ADD PRIMARY KEY (`id`),
189+
ADD UNIQUE KEY `email` (`email`);
190+
191+
--
192+
-- Indexes for table `api5users`
193+
--
194+
ALTER TABLE `api5users`
195+
ADD PRIMARY KEY (`id`),
196+
ADD UNIQUE KEY `username` (`username`);
197+
198+
--
199+
-- Indexes for table `api6users`
200+
--
201+
ALTER TABLE `api6users`
202+
ADD PRIMARY KEY (`id`),
203+
ADD UNIQUE KEY `username` (`username`);
204+
205+
--
206+
-- Indexes for table `api7users`
207+
--
208+
ALTER TABLE `api7users`
209+
ADD PRIMARY KEY (`id`),
210+
ADD UNIQUE KEY `username` (`username`);
211+
212+
--
213+
-- Indexes for table `api9users`
214+
--
215+
ALTER TABLE `api9users`
216+
ADD PRIMARY KEY (`id`);
217+
218+
--
219+
-- Indexes for table `comments`
220+
--
221+
ALTER TABLE `comments`
222+
ADD PRIMARY KEY (`id`),
223+
ADD UNIQUE KEY `deviceid` (`deviceid`);
224+
225+
--
226+
-- AUTO_INCREMENT for dumped tables
227+
--
228+
229+
--
230+
-- AUTO_INCREMENT for table `api1users`
231+
--
232+
ALTER TABLE `api1users`
233+
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
234+
235+
--
236+
-- AUTO_INCREMENT for table `api2users`
237+
--
238+
ALTER TABLE `api2users`
239+
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
240+
241+
--
242+
-- AUTO_INCREMENT for table `api5users`
243+
--
244+
ALTER TABLE `api5users`
245+
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
246+
247+
--
248+
-- AUTO_INCREMENT for table `api6users`
249+
--
250+
ALTER TABLE `api6users`
251+
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
252+
253+
--
254+
-- AUTO_INCREMENT for table `api7users`
255+
--
256+
ALTER TABLE `api7users`
257+
MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
258+
259+
--
260+
-- AUTO_INCREMENT for table `comments`
261+
--
262+
ALTER TABLE `comments`
263+
MODIFY `id` int(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
264+
COMMIT;
265+
266+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
267+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
268+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

vapi/api1/createUser.php

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
require '../db/var.php';
4+
require '../db/dbconn.php';
5+
require '../db/headerset.php';
6+
7+
8+
function validateAll()
9+
{
10+
if(isset($GLOBALS["username"]))
11+
if(isset($GLOBALS["name"]))
12+
if(isset($GLOBALS["course"]))
13+
if(isset($GLOBALS["password"]))
14+
return true;
15+
else
16+
return false;
17+
else
18+
return false;
19+
else
20+
return false;
21+
else
22+
return false;
23+
}
24+
25+
$username = $_POST["username"];
26+
$name = $_POST["name"];
27+
$course = $_POST["course"];
28+
$password = $_POST["password"];
29+
30+
if(validateAll()){
31+
32+
$username=mysqli_real_escape_string($dbconn,$username);
33+
$name=mysqli_real_escape_string($dbconn,$name);
34+
$course=mysqli_real_escape_string($dbconn,$course);
35+
$password=mysqli_real_escape_string($dbconn,$password);
36+
37+
$query="INSERT into api1users values('','$username','$name','$course','$password')";
38+
39+
if(mysqli_query($dbconn,$query)){
40+
$latest_id=mysqli_insert_id($dbconn);
41+
print json_encode(array("status"=>200,"userCreated"=>"true","userId"=>$latest_id));
42+
}
43+
else{
44+
print json_encode(array("status"=>400,"userCreated"=>"false","cause"=>"dbInsertionFailed"));
45+
}
46+
}
47+
else{
48+
print json_encode(array("status"=>400,"userCreated"=>"false","cause"=>"parameters"));
49+
}

vapi/api1/getUser.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
require '../db/var.php';
4+
require '../db/dbconn.php';
5+
require '../db/headerset.php';
6+
require '../db/CustomHeaderAuth.php';
7+
8+
$requestAuth = new CustomHeaderAuth();
9+
10+
11+
if(isset($_GET["id"]))
12+
{
13+
14+
if($requestAuth->isHeaderSet())
15+
{
16+
17+
$query="SELECT * from api1users WHERE username='".$requestAuth->getUsername()."' AND password='".$requestAuth->getPassword()."'";
18+
$result = mysqli_query($dbconn,$query);
19+
20+
if(mysqli_num_rows($result) > 0)
21+
{
22+
23+
$id=mysqli_real_escape_string($dbconn,$_GET["id"]);
24+
$result2 = mysqli_query($dbconn,"SELECT username,name,course from api1users where id=".$id);
25+
if(mysqli_num_rows($result2) > 0)
26+
{
27+
28+
29+
$row = $result2->fetch_assoc();
30+
$row["success"]="true";
31+
print json_encode($row);
32+
}
33+
else{
34+
35+
print json_encode(array("success"=>"false","cause"=>"userNotFound"));
36+
}
37+
38+
}
39+
else{
40+
41+
print json_encode(array("success"=>"false","cause"=>"usernameOrPasswordIncorrect"));
42+
}
43+
44+
45+
46+
}
47+
else{
48+
print json_encode(array("success"=>"false","cause"=>"authHeaderNotSet"));
49+
}
50+
51+
}
52+
else{
53+
print json_encode(array("success"=>"false","cause"=>"idNotSet"));
54+
}
55+
56+
57+
58+

0 commit comments

Comments
 (0)