-
Notifications
You must be signed in to change notification settings - Fork 0
/
addphotos.php
146 lines (130 loc) · 5.51 KB
/
addphotos.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
include("includes/db.php");
include("includes/authcheck.php");
if (isset($_SESSION['edit'])) {
$gallery = mysql_query("
SELECT gallery.*
FROM gallery
WHERE gallery.object_id = '" . $_SESSION['object_id'] . "'");
$gallery = mysql_fetch_array($gallery, MYSQL_ASSOC);
$pictures = mysql_query("
SELECT pictures.*
FROM pictures
WHERE pictures.gallery_id = '" . $gallery['id'] . "'");
while ($picture = mysql_fetch_array($pictures, MYSQL_ASSOC)) {
$images[] = $picture;
}
}
?>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/jquery.jscrollpane.css" media="all"/>
<!-- Pievienoju skriptus -->
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/plupload/plupload.full.js"></script>
<script type="text/javascript" src="js/jquery.jscrollpane.min.js"></script>
<!-- End -->
<!-- Google fonts -->
<link href='http://fonts.googleapis.com/css?family=BenchNine:400,700&subset=latin,latin-ext' rel='stylesheet'
type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Condensed&subset=latin,cyrillic-ext,cyrillic,latin-ext'
rel='stylesheet' type='text/css'>
<!-- END -->
<script type="text/javascript">
//Bilzu dzeshanas skripts
function deleteImg(object_id, gallery_id, name, element) {
name = name + '.jpg';
$.post("deleter.php", { object_id: object_id, gallery_id: gallery_id, name: name }, function (data) {
var response = JSON.parse(data);
if (response.response == true) {
if (typeof element == 'object') {
if ($(element).attr('class') == 'addedPhoto') {
$(element).remove();
} else {
$(element).parent('.addedPhoto').remove();
}
} else {
$('#' + element).remove();
}
}
});
}
//Inicializeeju plupload
$(function () {
var uploader = new plupload.Uploader({
runtimes:'gears,html5,flash,silverlight,browserplus',
browse_button:'pickfiles',
container:'uploadContainer',
max_file_size:'10mb',
url:'uploader.php',
flash_swf_url:'js/plupload/plupload.flash.swf',
silverlight_xap_url:'js/plupload/plupload.silverlight.xap',
filters:[
{title:"Image files", extensions:"jpg,gif,png"}
]
});
uploader.bind('Init', function (up, params) {
$('#filelist').html("<div>Current runtime: " + params.runtime + "</div>");
});
$('#uploadfiles').click(function (e) {
uploader.start();
e.preventDefault();
});
uploader.init();
uploader.bind('FilesAdded', function (up, files) {
$.each(files, function (i, file) {
$('#photoHolder').append(
'<div id="' + file.id + '" class="addedPhoto"><div class="progressBar"><div class="bar"></div></div></div>');
});
uploader.start();
//e.preventDefault();
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('UploadProgress', function (up, file) {
$('#' + file.id).children('.progressBar').children('.bar').css('width', file.percent + '%');
});
uploader.bind('Error', function (up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('FileUploaded', function (up, file, response) {
var obj = JSON.parse(response.response);
var name = obj.name;
$('#photoHolder').children('#' + file.id).append('<a class="removeLink" onclick="deleteImg(' + obj.object_id + ',' + obj.gallery_id + ',' + name.replace('.jpg', '') + ',' + file.id + '); return false;" href="#"><a/>');
$('#photoHolder').children('#' + file.id).append('<img src="' + obj.path + '" />');
});
});
$(document).ready(function () {
//Pievienoju jsscrollpane
$('.scroll-pane').jScrollPane({
autoReinitialise:true
});
});
</script>
<div id="uploadContainer">
<div class="fancyHead">
<h3 class="fancyHeading">
<span>Add photos</span>
</h3>
</div>
<div class="addWrapper">
<a id="pickfiles" class="addGallery" href="#">Add photos</a>
</div>
<div id="photoHolderWrap" class="scroll-pane" style="width:960px;">
<div id="photoHolder">
<?php if (isset($images)): ?>
<?php foreach ($images as $k=>$img): ?>
<div class="addedPhoto">
<a class="removeLink" onclick="deleteImg(<?php echo $_SESSION['object_id'] ?>, <?php echo $gallery['id'] ?>, '<?php echo strstr($img['name'], '.', true) ?>', this); return false;" href="#"><a/>
<img src="./uploads/objects/<?php echo $_SESSION['object_id'] ?>/<?php echo $gallery['id'] ?>/thumbnail/<?php echo $img['name'] ?>"/>
</div>
<?php endforeach ?>
<?php endif ?>
</div>
</div>
<div class="fancyFooter">
</div>
</div>