Skip to content
Snippets Groups Projects
Commit c07fbd53 authored by Dimas's avatar Dimas
Browse files

Fix incorrect use of substr and add random id for song

parent ff964085
No related merge requests found
Pipeline #59650 failed with stages
in 0 seconds
...@@ -270,11 +270,12 @@ class LaguController ...@@ -270,11 +270,12 @@ class LaguController
$target_dir = "audio/"; $target_dir = "audio/";
$file = $formData["file_lagu"]["name"]; $file = $formData["file_lagu"]["name"];
if( substr($formData["file_lagu"]['type'], 5) !== 'audio'){ if( substr($formData["file_lagu"]['type'], 0, 5) !== "audio"){
return $res->view("Pages/AddSong", [ return $res->view("Pages/AddSong", [
"auth" => $req->auth, "auth" => $req->auth,
"added" => false, "added" => false,
"failed" => true, "failed" => true,
"tipe" => substr($formData["file_lagu"]['type'], 5)
]); ]);
} }
...@@ -296,11 +297,12 @@ class LaguController ...@@ -296,11 +297,12 @@ class LaguController
$target_dir = "image/"; $target_dir = "image/";
$file = $formData["image_file"]["name"]; $file = $formData["image_file"]["name"];
if( substr($formData["image_file"]['type'], 5) !== 'image'){ if( substr($formData["image_file"]['type'], 0, 5) !== "image"){
return $res->view("Pages/AddSong", [ return $res->view("Pages/AddSong", [
"auth" => $req->auth, "auth" => $req->auth,
"added" => false, "added" => false,
"failed" => true, "failed" => true,
"tipe" => $formData["image_file"]['type']
]); ]);
} }
...@@ -319,6 +321,7 @@ class LaguController ...@@ -319,6 +321,7 @@ class LaguController
try { try {
$transaction->insert( $transaction->insert(
[ [
"song_id" => rand(1,9223372036854775807),
"title" => $title, "title" => $title,
"release_date" => $release_date, "release_date" => $release_date,
"duration" => $duration, "duration" => $duration,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment