Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
API Development Course Apr 2021
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sabarinathan k
API Development Course Apr 2021
Commits
a392c648
Commit
a392c648
authored
3 years ago
by
Sibidharan
Browse files
Options
Downloads
Patches
Plain Diff
Fixed Insecure Object Accesses
parent
1491d459
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/lib/Folder.class.php
+7
-4
7 additions, 4 deletions
api/lib/Folder.class.php
api/lib/Notes.class.php
+13
-9
13 additions, 9 deletions
api/lib/Notes.class.php
api/lib/Signup.class.php
+2
-0
2 additions, 0 deletions
api/lib/Signup.class.php
with
22 additions
and
13 deletions
api/lib/Folder.class.php
+
7
−
4
View file @
a392c648
...
...
@@ -37,15 +37,15 @@ class Folder extends Share{
}
}
public
function
createNew
(
$name
=
'
New
Folder'
){
if
(
isset
(
$_SESSION
[
'username'
])
and
strlen
(
$name
)
<
=
45
){
public
function
createNew
(
$name
=
'
Default
Folder'
){
if
(
isset
(
$_SESSION
[
'username'
])
and
strlen
(
$name
)
>
=
5
and
strlen
(
$name
)
<=
45
){
$query
=
"INSERT INTO `apis`.`folders` (`name`, `owner`) VALUES ('
$name
', '
$_SESSION[username]
');"
;
if
(
mysqli_query
(
$this
->
db
,
$query
)){
$this
->
id
=
mysqli_insert_id
(
$this
->
db
);
return
$this
->
id
;
}
}
else
{
throw
new
Exception
(
"Cannot create
not
e"
);
throw
new
Exception
(
"Cannot create
default folders
e"
);
}
}
...
...
@@ -53,8 +53,11 @@ class Folder extends Share{
if
(
$this
->
id
!=
null
){
$query
=
"SELECT * FROM folders WHERE id=
$this->id
"
;
$result
=
mysqli_query
(
$this
->
db
,
$query
);
if
(
$result
){
if
(
$result
&&
mysqli_num_rows
(
$result
)
==
1
){
$this
->
data
=
mysqli_fetch_assoc
(
$result
);
if
(
$this
->
getOwner
()
!=
$_SESSION
[
'username'
]){
throw
new
Exception
(
"Unauthorized"
);
}
$this
->
id
=
$this
->
data
[
'id'
];
}
else
{
throw
new
Exception
(
"Not found"
);
...
...
This diff is collapsed.
Click to expand it.
api/lib/Notes.class.php
+
13
−
9
View file @
a392c648
...
...
@@ -133,21 +133,25 @@ class Notes extends Share{
throw
new
Exception
(
"Note not loaded"
);
}
}
else
{
throw
new
Exception
(
"Unauthorized "
.
$this
->
getOwner
()
);
throw
new
Exception
(
"Unauthorized "
);
}
}
public
function
createNew
(
$title
,
$body
,
$folder
){
new
Folder
(
$folder
);
if
(
isset
(
$_SESSION
[
'username'
])
and
strlen
(
$title
)
<=
45
){
$query
=
"INSERT INTO `apis`.`notes` (`title`, `body`, `owner`, `folder_id`) VALUES ('
$title
', '
$body
', '
$_SESSION[username]
', '
$folder
');"
;
if
(
mysqli_query
(
$this
->
db
,
$query
)){
$this
->
id
=
mysqli_insert_id
(
$this
->
db
);
$this
->
refresh
();
return
$this
->
id
;
$f
=
new
Folder
(
$folder
);
if
(
$f
->
getOwner
()
==
$_SESSION
[
'username'
]){
if
(
isset
(
$_SESSION
[
'username'
])
and
strlen
(
$title
)
<=
45
){
$query
=
"INSERT INTO `apis`.`notes` (`title`, `body`, `owner`, `folder_id`) VALUES ('
$title
', '
$body
', '
$_SESSION[username]
', '
$folder
');"
;
if
(
mysqli_query
(
$this
->
db
,
$query
)){
$this
->
id
=
mysqli_insert_id
(
$this
->
db
);
$this
->
refresh
();
return
$this
->
id
;
}
}
else
{
throw
new
Exception
(
"Cannot create note"
);
}
}
else
{
throw
new
Exception
(
"
Cannot create note
"
);
throw
new
Exception
(
"
Unauthorized
"
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/lib/Signup.class.php
+
2
−
0
View file @
a392c648
...
...
@@ -32,6 +32,8 @@ class Signup {
$this
->
id
=
mysqli_insert_id
(
$this
->
db
);
$this
->
sendVerificationMail
();
$f
=
new
Folder
();
session_start
();
$_SESSION
[
'username'
]
=
$this
->
username
;
$f
->
createNew
(
'Default Folder'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment