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
4696afd6
Commit
4696afd6
authored
Dec 08, 2020
by
Paarth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor
parent
bf95b9eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
29 deletions
+39
-29
backend/filedelete.php
backend/filedelete.php
+0
-1
backend/filesave.php
backend/filesave.php
+39
-28
No files found.
backend/filedelete.php
View file @
4696afd6
...
...
@@ -18,7 +18,6 @@ if (isset($postData) && !empty($postData)) {
mysqli_query
(
$mysqli
,
$sql
);
$msg
=
"file successfully deleted"
;
echo
json_encode
(
$msg
);
}
else
{
http_response_code
(
404
);
...
...
backend/filesave.php
View file @
4696afd6
...
...
@@ -11,34 +11,45 @@ if (isset($postData) && !empty($postData)) {
$lang
=
trim
(
$request
->
language
);
$path
=
'../users/'
.
$username
.
'/'
.
trim
(
$request
->
path
)
.
'/'
.
$filename
.
$lang
;
// if (file_exists($path)) {
// $msg = "file already exists";
// clearstatcache();
// echo json_encode($msg);
// }
// else {
// $sql1 = "SELECT n_files from userdata where username = $username";
// $sql2 = "UPDATE userdata SET n_files = n_files+1 WHERE username = $username ";
// $result = mysqli_query($mysqli, $sql1);
// if($result == 10){
// $msg = "maximum limit(10) reached";
// echo json_encode($msg);
// }
// else{
// if($result = mysqli_query($mysqli, $sql2)) {
$myfile
=
fopen
(
$path
,
"w"
);
fwrite
(
$myfile
,
$data
);
fclose
(
$myfile
);
$msg
=
"file successfully uploaded"
;
clearstatcache
();
echo
json_encode
(
$msg
);
// }
// else{
// http_response_code(404);
// }
// }
// }
if
(
file_exists
(
$path
))
{
$msg
=
"file already exists"
;
clearstatcache
();
echo
json_encode
(
$msg
);
}
else
{
$sql1
=
"SELECT n_files from user where username =
$username
"
;
$sql2
=
"UPDATE user SET n_files = n_files+1 WHERE username =
$username
"
;
$result
=
mysqli_query
(
$mysqli
,
$sql1
)
->
fetch_all
()[
0
];
if
(
file_exists
(
$path
)){
$myfile
=
fopen
(
$path
,
"w"
);
fwrite
(
$myfile
,
$data
);
fclose
(
$myfile
);
$msg
=
"file successfully uploaded"
;
clearstatcache
();
echo
json_encode
(
$msg
);
exit
;
}
if
(
$result
==
10
){
$msg
=
"maximum limit(10) reached"
;
echo
json_encode
(
$msg
);
}
else
{
if
(
mysqli_query
(
$mysqli
,
$sql2
)){
$myfile
=
fopen
(
$path
,
"w"
);
fwrite
(
$myfile
,
$data
);
fclose
(
$myfile
);
$msg
=
"file successfully uploaded"
;
clearstatcache
();
echo
json_encode
(
$msg
);
}
else
{
http_response_code
(
404
);
}
}
}
}
...
...
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