-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversionLoader.php
More file actions
58 lines (46 loc) · 1.94 KB
/
Copy pathversionLoader.php
File metadata and controls
58 lines (46 loc) · 1.94 KB
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
54
55
56
57
58
<?php
session_start();
require('db.php');
if (isset($_SESSION['username'])){
$username = $_SESSION['username'];
$username = stripslashes($username);
$data = array();
$versionID = $_POST['versionID'];
$query = "SELECT * FROM versions WHERE versionID='$versionID'";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
$rows = mysqli_num_rows($result);
if($rows>=1){
while($row = mysqli_fetch_array($result)) {
$timestamp = strtotime($row['6']);
$date = date('d-m-Y', $timestamp);
$dataOut= '<div id="contentBox">'.
'<div id="versionButtons">'.
'<p id="timestamp">'.'updated: '.$date.'</p>'.
'<a id="newVersionButton" class="versionButton" onclick="loadVersionForm('."'". $row[0] ."',"."'".$versionID."'".')"></a>'.
'<a id="editButton" class="versionButton" onclick="editVersion('."'". $versionID ."'".')"></a>'.
'<a id="deleteButton" class="versionButton" onclick="deleteVersion('."'". $row[0] ."', '" . $versionID . "'".')"><img src="img/dump.png" alt="Delete" height="15" width="15"></a>'.
'<a id="boxclose" class="versionButton" onclick="cleanDiv('."'"."versionContainer"."'".')"></a>'.
'</div>'.
'<h1 id="versionHeading">'.$row[2].'</h1><p>'.$row[3].'</p>';
if($row[5]=="no file"){
$data['data'] = $dataOut . '</div>';
}else {
$data['data'] = $dataOut .
'<audio controls>'.
'<source src="uploaded_files/'. $row[0] ."/".$row[5].
'" type="audio/mpeg">'.
'Your browser does not support the audio element.'.
'</audio>'.'</div>';
}
//sets the last used version of a project
$query2 = "UPDATE projects SET last_version = '$versionID' WHERE projectID='$row[0]'";
mysqli_query($conn, $query2) or die(mysqli_error($conn));
}
}else{
echo "<p>No projects found</p>";
}
echo json_encode($data);
}else{
echo "<p>You are not permitted to do this</p>";
}
?>