-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.php
53 lines (50 loc) · 1.38 KB
/
move.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
use MusicProductionManager\Data\Entity\Song;
require_once "inc/app.php";
$songEnt = new Song(null, $database);
try
{
$songs = $songEnt->findAll(null, null, null);
$results = $songs->getResult();
foreach($results as $song)
{
$mp3Path = $song->getFilePath();
$midiPath = $song->getFilePathMidi();
$xmlPath = $song->getFilePathXml();
$pdfPath = $song->getFilePathPdf();
$baseDir = __DIR__ . "/files/" . $song->getSongId();
if(!file_exists($baseDir))
{
mkdir($baseDir, 0755, true);
}
if(file_exists($mp3Path))
{
$mp3Path2 = $baseDir . "/song.mp3";
copy($mp3Path, $mp3Path2);
$song->setFilePath($mp3Path2);
}
if(file_exists($midiPath))
{
$midiPath2 = $baseDir . "/song.mid";
copy($midiPath, $midiPath2);
$song->setFilePathMidi($midiPath2);
}
if(file_exists($xmlPath))
{
$xmlPath2 = $baseDir . "/song.musicxml";
copy($xmlPath, $xmlPath2);
$song->setFilePathXml($xmlPath2);
}
if(file_exists($pdfPath))
{
$pdfPath2 = $baseDir . "/scores.pdf";
copy($pdfPath, $pdfPath2);
$song->setFilePathPdf($pdfPath2);
}
$song->update();
}
}
catch(Exception $e)
{
// do nothing
}