author | Dan Fuhry <dan@enanocms.org> |
Sat, 21 Aug 2010 23:35:20 -0400 | |
changeset 43 | 7df4993be0b0 |
parent 42 | 7c6e2e97aa08 |
child 44 | 17cfc3da0dcc |
permissions | -rw-r--r-- |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
1 |
<?php |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
2 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
3 |
/* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
4 |
* Snapr |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
5 |
* Version 0.1 beta 1 |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
6 |
* Copyright (C) 2007 Dan Fuhry |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
7 |
* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
10 |
* |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
13 |
*/ |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
14 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
15 |
## |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
16 |
## UPLOAD INTERFACE |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
17 |
## |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
18 |
|
40
2607b83e986d
...And a conversion to ucwords.
Dan Fuhry <dan@enanocms.org>
parents:
32
diff
changeset
|
19 |
$plugins->attachHook('session_started', 'register_special_page("GalleryUpload", "Image gallery upload");'); |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
20 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
21 |
function page_Special_GalleryUpload() |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
22 |
{ |
42
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
23 |
global $db, $session, $paths, $template, $plugins; // Common objects |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
24 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
25 |
if ( $session->user_level < USER_LEVEL_ADMIN ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
26 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
27 |
die_friendly('Access denied', '<p>You need to have administrative rights to use the gallery\'s upload features.</p>'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
28 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
29 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
30 |
$zip_support = ( class_exists('ZipArchive') || ( file_exists('/usr/bin/unzip') && is_executable('/usr/bin/unzip') ) ); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
31 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
32 |
$errors = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
33 |
$template->add_header('<link rel="stylesheet" type="text/css" href="' . scriptPath . '/plugins/gallery/dropdown.css" />'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
34 |
$template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/gallery/gallery-bits.js"></script>'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
35 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
36 |
$max_size_field = get_max_size_field(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
37 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
38 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
39 |
// EDIT IMAGES |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
40 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
41 |
if ( isset($_GET['edit_img']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
42 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
43 |
$edit_parms = $_GET['edit_img']; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
44 |
$regex = '/^((([0-9]+),)*)?([0-9]+?)$/'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
45 |
if ( !preg_match($regex, $edit_parms) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
46 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
47 |
die_friendly('Bad request', '<p>$_GET[\'edit_img\'] must be a comma-separated list of image IDs.</p>'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
48 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
49 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
50 |
// process any uploaded images |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
51 |
// FIXME is this a bad place for this? |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
52 |
$limit = isset($_GET['ajax']) ? '' : "LIMIT 5"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
53 |
$q = $db->sql_query('SELECT img_id FROM ' . table_prefix . "gallery WHERE is_folder = 0 AND processed = 0 $limit;"); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
54 |
if ( !$q ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
55 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
56 |
if ( $db->numrows() > 0 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
57 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
58 |
while ( $row = $db->fetchrow($q) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
59 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
60 |
snapr_process_image($row['img_id']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
61 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
62 |
$q = $db->sql_query('SELECT COUNT(img_id) FROM ' . table_prefix . "gallery WHERE is_folder = 0 AND processed = 0;"); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
63 |
if ( !$q ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
64 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
65 |
list($count) = $db->fetchrow_num(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
66 |
$db->free_result(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
67 |
if ( intval($count) > 0 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
68 |
redirect(makeUrlNS('Special', 'GalleryUpload', "edit_img={$_GET['edit_img']}"), "Processing images", "Processing images... $count remaining", 1); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
69 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
70 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
71 |
if ( !isset($_GET['ajax']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
72 |
$template->header(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
73 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
74 |
snapr_editform($edit_parms); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
75 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
76 |
if ( !isset($_GET['ajax']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
77 |
$template->footer(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
78 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
79 |
return; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
80 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
81 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
82 |
// REMOVE IMAGES |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
83 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
84 |
else if ( isset($_GET['rm']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
85 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
86 |
$warnings = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
87 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
88 |
if ( !preg_match('/^[0-9]+$/', $_GET['rm']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
89 |
die_friendly('Bad Request', '<p>$_GET[rm] needs to be an integer.</p>'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
90 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
91 |
$rm_id = intval($_GET['rm']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
92 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
93 |
if ( isset($_POST['confirmed']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
94 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
95 |
// The user confirmed the request. Start plowing through data to decide what to delete. |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
96 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
97 |
// Array of images and folder rows to delete |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
98 |
$del_imgs = array($rm_id); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
99 |
// Array of files to delete |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
100 |
$del_files = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
101 |
// Array of comment entries to delete |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
102 |
$del_comments = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
103 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
104 |
$all_children = gal_fetch_all_children($rm_id); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
105 |
$del_imgs = array_merge($del_imgs, $all_children); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
106 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
107 |
$imglist = 'img_id=' . implode(' OR img_id=', $del_imgs); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
108 |
$sql = "SELECT img_id, img_filename FROM ".table_prefix."gallery WHERE ( $imglist ) AND is_folder!=1;"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
109 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
110 |
if ( !$db->sql_query($sql) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
111 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
112 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
113 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
114 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
115 |
while ( $row = $db->fetchrow() ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
116 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
117 |
$files = array( |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
118 |
ENANO_ROOT . '/files/' . $row['img_filename'], |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
119 |
ENANO_ROOT . '/cache/' . $row['img_filename'] . '-thumb.jpg', |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
120 |
ENANO_ROOT . '/cache/' . $row['img_filename'] . '-preview.jpg' |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
121 |
); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
122 |
$del_files = array_merge($del_files, $files); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
123 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
124 |
$del_comments[] = intval($row['img_id']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
125 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
126 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
127 |
$commentlist = 'page_id=\'' . implode('\' OR page_id=\'', $del_imgs) . '\''; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
128 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
129 |
// Main deletion cycle |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
130 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
131 |
foreach ( $del_files as $file ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
132 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
133 |
@unlink($file) or $warnings[] = 'Could not delete file ' . $file; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
134 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
135 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
136 |
if ( !$db->sql_query('DELETE FROM '.table_prefix.'gallery WHERE ' . $imglist . ';') ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
137 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
138 |
$warnings[] = 'Main delete query failed: ' . $db->get_error(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
139 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
140 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
141 |
if ( !$db->sql_query('DELETE FROM '.table_prefix.'comments WHERE ( ' . $commentlist . ' ) AND namespace=\'Gallery\';') ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
142 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
143 |
$warnings[] = 'Comment delete query failed: ' . $db->get_error(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
144 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
145 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
146 |
if ( count($warnings) > 0 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
147 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
148 |
$template->header(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
149 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
150 |
echo '<h3>Error during deletion process</h3>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
151 |
echo '<p>The deletion process generated some warnings which are shown below.</p>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
152 |
echo '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
153 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
154 |
$template->footer(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
155 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
156 |
else |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
157 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
158 |
redirect(makeUrlNS('Special', 'Gallery'), 'Deletion successful', 'The selected item has been deleted from the gallery. You will now be transferred to the gallery index.', 2); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
159 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
160 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
161 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
162 |
else |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
163 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
164 |
// Removal form |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
165 |
$template->header(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
166 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
167 |
echo '<form action="' . makeUrlNS('Special', 'GalleryUpload', 'rm=' . $rm_id, true) . '" method="post" enctype="multipart/form-data">'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
168 |
echo $max_size_field; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
169 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
170 |
echo '<h3>Are you sure you want to delete this item?</h3>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
171 |
echo '<p>If you continue, this item will be permanently deleted from the gallery – no rollbacks.</p>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
172 |
echo '<p>If this is an image, the image files will be removed from the filesystem, and all comments associated with the image will be deleted, as well as the image\'s title, description, and location.</p>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
173 |
echo '<p>If this is a folder, all of its contents will be removed. Any images will be removed from the filesystem and all comments and metadata associated with images in this folder or any folders in it will be permanently deleted.</p>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
174 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
175 |
echo '<p><input type="submit" name="confirmed" value="Continue with delete" /></p>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
176 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
177 |
echo '</form>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
178 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
179 |
$template->footer(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
180 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
181 |
return; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
182 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
183 |
else if ( isset($_GET['ajax_proc_status']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
184 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
185 |
$q = $db->sql_query("SELECT COUNT(img_id) FROM " . table_prefix . "gallery WHERE processed = 0;"); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
186 |
if ( !$q ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
187 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
188 |
list($count) = $db->fetchrow_num(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
189 |
echo $count; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
190 |
return; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
191 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
192 |
else |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
193 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
194 |
if ( isset($_POST['do_upload']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
195 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
196 |
$files =& $_FILES['files']; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
197 |
$numfiles = count($files['name']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
198 |
$idlist = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
199 |
$destfolder = intval($_POST['targetfolder']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
200 |
if ( $destfolder < 1 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
201 |
$destfolder = NULL; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
202 |
for ( $i = 0; $i < $numfiles; $i++ ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
203 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
204 |
$ext = get_file_extension($files['name'][$i]); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
205 |
if ( snapr_extension_allowed($ext) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
206 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
207 |
// normal image |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
208 |
$result = snapr_insert_image($files['tmp_name'][$i], $destfolder); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
209 |
if ( $result !== false ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
210 |
$idlist[] = $result; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
211 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
212 |
else if ( strtolower($ext) == 'zip' ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
213 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
214 |
// zip file |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
215 |
$zipidlist = snapr_process_zip($files['tmp_name'][$i], $destfolder); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
216 |
if ( $zipidlist ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
217 |
$idlist = array_merge($idlist, $zipidlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
218 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
219 |
else |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
220 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
221 |
// FIXME handle unsupported files... maybe? |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
222 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
223 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
224 |
$idlist = implode(',', $idlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
225 |
echo '<div class="idlist">[' . $idlist . ']</div>'; |
43
7df4993be0b0
Some minimal no-javascript safety for the uploader
Dan Fuhry <dan@enanocms.org>
parents:
42
diff
changeset
|
226 |
echo 'Images uploaded successfully. Please <a href="' . makeUrlNS('Special', 'GalleryUpload', "edit_img=$idlist") . '">click here to continue</a>.'; |
42
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
227 |
//snapr_editform($idlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
228 |
return; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
229 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
230 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
231 |
// Oh yes, the image uploader! |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
232 |
$template->preload_js(array('jquery', 'jquery-ui', 'upload')); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
233 |
$template->header(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
234 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
235 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
236 |
<form action="" method="post" enctype="multipart/form-data" id="snaprupload"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
237 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
238 |
<script type="text/javascript"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
239 |
//<![CDATA[ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
240 |
addOnloadHook(function() |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
241 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
242 |
attachHook('snaprupload_ajaxupload_init', 'snapr_upload_init(ajaxupload);'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
243 |
}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
244 |
function snapr_upload_init(au) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
245 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
246 |
au.upload_start = function() |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
247 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
248 |
$(this.form).hide(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
249 |
$(this.statusbox).html('<h2 class="uploadgoing">Uploading pictures...</h2><div class="progress" style="margin: 15px 0;"></div><p class="uploadstatus"> </p>'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
250 |
$('div.progress', this.statusbox).progressbar({value: 0}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
251 |
}; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
252 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
253 |
au.status = function(state) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
254 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
255 |
if ( !state.done && !state.cancel_upload ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
256 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
257 |
var rawpct = state.bytes_processed / state.content_length; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
258 |
var pct = (Math.round((rawpct) * 1000)) / 10; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
259 |
var elapsed = state.current_time - state.start_time; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
260 |
var rawbps = state.bytes_processed / elapsed; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
261 |
var kbps = Math.round((rawbps) / 1024); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
262 |
var remain_bytes = state.content_length - state.bytes_processed; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
263 |
var remain_time = Math.round(remain_bytes / rawbps); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
264 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
265 |
$('p.uploadstatus', this.statusbox).html(pct + '% complete / ' + kbps + ' KB/s / ' + humanize_time(elapsed) + ' elapsed / ' + humanize_time(remain_time) + ' remaining'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
266 |
$('div.progress', this.statusbox).progressbar('value', pct); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
267 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
268 |
}; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
269 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
270 |
au.upload_success = function(childbody) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
271 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
272 |
$(this.statusbox).html('<div class="info-box"></div>' + childbody.innerHTML); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
273 |
var idlist = parseJSON($('div.idlist', this.statusbox).text()); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
274 |
$('div.idlist', this.statusbox).remove(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
275 |
var s = idlist.length == 1 ? '' : 's'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
276 |
$('div.info-box', this.statusbox).html(idlist.length + ' image'+s+' were uploaded successfully. Please wait while they are processed...'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
277 |
$(this.statusbox).append('<div class="progress" style="margin: 15px 0;"></div><p class="uploadstatus"> </p>'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
278 |
$('div.progress', this.statusbox).progressbar({value: 0}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
279 |
var au = this; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
280 |
ajaxGet(makeUrlNS('Special', 'GalleryUpload', 'edit_img=' + implode(',', idlist) + '&ajax=true'), function(ajax) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
281 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
282 |
if ( ajax.readyState == 4 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
283 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
284 |
window.clearTimeout(snapr_refresh_timer); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
285 |
$(au.statusbox).html(ajax.responseText); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
286 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
287 |
}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
288 |
snapr_refresh_proc(au, idlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
289 |
}; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
290 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
291 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
292 |
window.snapr_refresh_timer = false; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
293 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
294 |
function snapr_refresh_proc(au, idlist) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
295 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
296 |
void(au); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
297 |
void(idlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
298 |
ajaxGet(makeUrlNS('Special', 'GalleryUpload', 'ajax_proc_status'), function(ajax) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
299 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
300 |
if ( ajax.readyState == 4 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
301 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
302 |
var n = idlist.length - Number(ajax.responseText); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
303 |
var pct = (n / idlist.length) * 100; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
304 |
$('div.progress', au.statusbox).progressbar('value', pct); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
305 |
$('p.uploadstatus', au.statusbox).html(n + " of " + idlist.length + " images processed"); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
306 |
if ( pct < 100 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
307 |
window.snapr_refresh_timer = setTimeout(function() |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
308 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
309 |
snapr_refresh_proc(au, idlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
310 |
}, 1000); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
311 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
312 |
}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
313 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
314 |
//]]> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
315 |
</script> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
316 |
<?php ajax_upload_js('snaprupload'); ?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
317 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
318 |
<div class="tblholder"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
319 |
<table border="0" cellspacing="1" cellpadding="4"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
320 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
321 |
<th colspan="2">Upload files to the gallery</th> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
322 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
323 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
324 |
<td class="row1"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
325 |
Select files: |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
326 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
327 |
<td class="row1"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
328 |
<input type="hidden" name="do_upload" value="yes" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
329 |
<input type="file" size="50" name="files[]" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
330 |
<input type="button" class="addanother" value="+" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
331 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
332 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
333 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
334 |
<td class="row2"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
335 |
Upload into folder: |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
336 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
337 |
<td class="row2"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
338 |
<?php echo gallery_hier_formfield('targetfolder', true); ?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
339 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
340 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
341 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
342 |
<td class="row3" colspan="2" style="text-align: center; line-height: 24px;"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
343 |
<strong>Supported formats:</strong> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
344 |
<br /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
345 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
346 |
<img alt="Checkmark" src="<?php echo cdnPath; ?>/images/check.png" style="vertical-align: middle;" /> JPEG images |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
347 |
<img alt="Checkmark" src="<?php echo cdnPath; ?>/images/check.png" style="vertical-align: middle;" /> PNG images |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
348 |
<img alt="Checkmark" src="<?php echo cdnPath; ?>/images/check.png" style="vertical-align: middle;" /> GIF images |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
349 |
<?php if ( $zip_support ): ?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
350 |
<img alt="Checkmark" src="<?php echo cdnPath; ?>/images/check.png" style="vertical-align: middle;" /> Zip archives |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
351 |
<?php else: ?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
352 |
<img alt="X mark" src="<?php echo cdnPath; ?>/images/checkbad.png" style="vertical-align: middle;" /> Zip archives |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
353 |
<?php endif; ?><br /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
354 |
<small>Maximum file size: <strong><?php echo ini_get('upload_max_filesize'); ?></strong></small> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
355 |
<?php echo $max_size_field; ?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
356 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
357 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
358 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
359 |
<th colspan="2" class="subhead"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
360 |
<input type="submit" value="Upload" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
361 |
</th> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
362 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
363 |
</table> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
364 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
365 |
</form> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
366 |
<script type="text/javascript"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
367 |
// <![CDATA[ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
368 |
addOnloadHook(function() |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
369 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
370 |
$('input.addanother').click(function() |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
371 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
372 |
$(this).before('<br />'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
373 |
var inp = document.createElement('input'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
374 |
$(inp).attr('type', 'file').attr('size', '50').attr('name', 'files[]'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
375 |
this.parentNode.insertBefore(inp, this); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
376 |
$(this).before(' '); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
377 |
return false; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
378 |
}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
379 |
}); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
380 |
// ]]> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
381 |
</script> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
382 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
383 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
384 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
385 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
386 |
$template->footer(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
387 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
388 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
389 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
390 |
function snapr_editform($edit_parms) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
391 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
392 |
global $db, $session, $paths, $template, $plugins; // Common objects |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
393 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
394 |
$max_size_field = get_max_size_field(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
395 |
$errors = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
396 |
$idlist = explode(',', $edit_parms); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
397 |
$num_edit = count($idlist); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
398 |
$idlist = "SELECT img_id,img_title,img_desc,img_filename,is_folder FROM ".table_prefix."gallery WHERE img_id=" . implode(' OR img_id=', $idlist) . ';'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
399 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
400 |
if ( !$e = $db->sql_query($idlist) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
401 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
402 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
403 |
if ( isset($_POST['edit_do_save']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
404 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
405 |
@set_time_limit(0); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
406 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
407 |
$arr_img_data = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
408 |
while ( $row = $db->fetchrow($e) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
409 |
$arr_img_data[$row['img_id']] = $row; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
410 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
411 |
// Allow breaking out |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
412 |
switch(true):case true: |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
413 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
414 |
if ( !is_array($_POST['img']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
415 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
416 |
$errors[] = 'No images passed to processor.'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
417 |
break; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
418 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
419 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
420 |
// Main updater loop |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
421 |
foreach ( $_POST['img'] as $img_id => $img_data ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
422 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
423 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
424 |
if ( !preg_match('/^[0-9]+$/', $img_id) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
425 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
426 |
$errors[] = 'SQL injection attempted!'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
427 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
428 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
429 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
430 |
// Array of columns to update |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
431 |
$to_update = array(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
432 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
433 |
$key = 'reupload_' . $img_data['id']; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
434 |
if ( isset($_FILES[$key]) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
435 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
436 |
$file =& $_FILES[ $key ]; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
437 |
if ( $file['tmp_name'] != '' ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
438 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
439 |
// Reupload |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
440 |
$filename = ENANO_ROOT . '/files/' . $arr_img_data[ $img_data['id'] ]['img_filename']; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
441 |
if ( !unlink($filename) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
442 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
443 |
$errors[] = "Could not delete $filename"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
444 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
445 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
446 |
if ( !@move_uploaded_file($file['tmp_name'], $filename) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
447 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
448 |
$errors[] = "Could not move uploaded file to $filename"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
449 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
450 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
451 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
452 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
453 |
// Create scaled images |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
454 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
455 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
456 |
// Create thumbnail image |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
457 |
$thumb_filename = ENANO_ROOT . '/cache/' . $arr_img_data[ $img_data['id'] ]['img_filename'] . '-thumb.jpg'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
458 |
if ( !unlink($thumb_filename) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
459 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
460 |
$errors[] = "Could not delete $thumb_filename"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
461 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
462 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
463 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
464 |
if ( !scale_image($filename, $thumb_filename, 80, 80) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
465 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
466 |
$errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
467 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
468 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
469 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
470 |
// Create preview image |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
471 |
$preview_filename = ENANO_ROOT . '/cache/' . $arr_img_data[ $img_data['id'] ]['img_filename'] . '-preview.jpg'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
472 |
if ( !unlink($preview_filename) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
473 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
474 |
$errors[] = "Could not delete $preview_filename"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
475 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
476 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
477 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
478 |
if ( !scale_image($filename, $preview_filename, 640, 480) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
479 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
480 |
$errors[] = 'Couldn\'t scale image '.$i.': ImageMagick failed us'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
481 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
482 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
483 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
484 |
$to_update['img_time_mod'] = strval(time()); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
485 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
486 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
487 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
488 |
$vars = array( |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
489 |
'year' => date('Y'), |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
490 |
'month' => date('F'), |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
491 |
'day' => date('d'), |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
492 |
'time12' => date('g:i A'), |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
493 |
'time24' => date('G:i') |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
494 |
); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
495 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
496 |
// Image name/title |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
497 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
498 |
$title = $template->makeParserText($img_data['title']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
499 |
$title->assign_vars($vars); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
500 |
$executed = $title->run(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
501 |
if ( $executed == '_id' ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
502 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
503 |
$errors[] = 'You cannot name an image or folder "_id", this name is reserved for internal functions.'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
504 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
505 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
506 |
if ( $executed == '' ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
507 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
508 |
$errors[] = 'Please enter a name for the item with unique ID ' . $img_data['id'] . '. <pre>' . print_r($_POST,true) . '</pre>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
509 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
510 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
511 |
$to_update['img_title'] = $executed; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
512 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
513 |
// Image description |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
514 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
515 |
if ( isset($img_data['desc']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
516 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
517 |
$desc = $template->makeParserText($img_data['desc']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
518 |
$desc->assign_vars($vars); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
519 |
$executed = $desc->run(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
520 |
$executed = RenderMan::preprocess_text($executed, false, false); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
521 |
$to_update['img_desc'] = $executed; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
522 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
523 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
524 |
// Folder |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
525 |
$target_folder = false; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
526 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
527 |
if ( !empty($_POST['override_folder']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
528 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
529 |
if ( $_POST['override_folder'] == 'NULL' || preg_match('/^[0-9]+$/', $_POST['override_folder']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
530 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
531 |
$target_folder = $_POST['override_folder']; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
532 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
533 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
534 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
535 |
if ( !empty($img_data['folder']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
536 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
537 |
if ( $img_data['folder'] == 'NULL' || preg_match('/^[0-9]+$/', $img_data['folder']) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
538 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
539 |
$target_folder = $img_data['folder']; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
540 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
541 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
542 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
543 |
if ( $target_folder ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
544 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
545 |
// Make sure we're not trying to move a folder to itself or a subdirectory of itself |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
546 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
547 |
$children = gal_fetch_all_children(intval($img_data['id'])); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
548 |
if ( $img_data['id'] == $target_folder || in_array($target_folder, $children) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
549 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
550 |
$errors[] = 'You are trying to move a folder to itself, or to a subdirectory of itself, which is not allowed. If done manually (i.e. via an SQL client) this will result in infinite loops in the folder sorting code.'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
551 |
break 2; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
552 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
553 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
554 |
$to_update['folder_parent'] = $target_folder; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
555 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
556 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
557 |
if ( count($to_update) > 0 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
558 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
559 |
$up_keys = array_keys($to_update); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
560 |
$up_vals = array_values($to_update); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
561 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
562 |
$bin_cols = array('folder_parent'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
563 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
564 |
$sql = 'UPDATE ' . table_prefix.'gallery SET '; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
565 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
566 |
foreach ( $up_keys as $i => $key ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
567 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
568 |
if ( in_array($key, $bin_cols) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
569 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
570 |
$sql .= $key . '=' . $up_vals[$i] . ','; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
571 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
572 |
else |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
573 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
574 |
$sql .= $key . '=\'' . $db->escape($up_vals[$i]) . '\','; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
575 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
576 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
577 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
578 |
$sql = preg_replace('/,$/i', '', $sql) . ' WHERE img_id=' . $img_data['id'] . ';'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
579 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
580 |
if ( !$db->sql_query($sql) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
581 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
582 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
583 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
584 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
585 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
586 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
587 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
588 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
589 |
echo '<div class="info-box" style="margin-left: 0;">Your changes have been saved.</div>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
590 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
591 |
endswitch; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
592 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
593 |
// Rerun select query to make sure information in PHP memory is up-to-date |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
594 |
if ( !$e = $db->sql_query($idlist) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
595 |
$db->_die(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
596 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
597 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
598 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
599 |
if ( count($errors) > 0 ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
600 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
601 |
echo '<div class="error-box" style="margin-left: 0;"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
602 |
<b>The following errors were encountered while updating the image data:</b><br /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
603 |
<ul> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
604 |
<li>' . implode("</li>\n <li>", $errors) . '</li> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
605 |
</ul> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
606 |
</div>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
607 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
608 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
609 |
echo '<form action="' . makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $edit_parms, true) . '" method="post" enctype="multipart/form-data">'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
610 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
611 |
echo $max_size_field; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
612 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
613 |
if ( $row = $db->fetchrow($e) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
614 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
615 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
616 |
echo '<div class="tblholder"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
617 |
<table border="0" cellspacing="1" cellpadding="4">'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
618 |
echo ' <tr><th class="subhead">Information</th></tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
619 |
echo ' <tr><td class="row3"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
620 |
As with the upload form, the following variables can be used. <b>Note that when editing images, the {id} and {autotitle} variables will be ignored.</b>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
621 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
622 |
<ul> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
623 |
<li>{year}: The current year (<?php echo date('Y'); ?>)</li> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
624 |
<li>{month}: The current month (<?php echo date('F'); ?>)</li> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
625 |
<li>{day}: The day of the month (<?php echo date('d'); ?>)</li> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
626 |
<li>{time12}: 12-hour time (<?php echo date('g:i A'); ?>)</li> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
627 |
<li>{time24}: 24-hour time (<?php echo date('G:i'); ?>)</li> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
628 |
</ul> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
629 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
630 |
echo ' </td></tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
631 |
echo ' </table> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
632 |
</div>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
633 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
634 |
$i = 0; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
635 |
do |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
636 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
637 |
$thumb_url = makeUrlNS('Special', 'GalleryFetcher/thumb/' . $row['img_id'], false, true); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
638 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
639 |
# Type: folder |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
640 |
if ( $row['is_folder'] == 1 ): |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
641 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
642 |
// Image ID tracker |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
643 |
echo '<input type="hidden" name="img[' . $i . '][id]" value="' . $row['img_id'] . '" />'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
644 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
645 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
646 |
// Editor table |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
647 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
648 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
649 |
$folders = gallery_imgid_to_folder(intval($row['img_id'])); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
650 |
foreach ( $folders as $j => $xxx ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
651 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
652 |
$folder =& $folders[$j]; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
653 |
$folder = sanitize_page_id($folder); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
654 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
655 |
$folders = array_reverse($folders); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
656 |
$gal_href = implode('/', $folders) . ( count($folders) > 0 ? '/' : '' ) . sanitize_page_id($row['img_title']); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
657 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
658 |
echo '<div class="tblholder"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
659 |
<table border="0" cellspacing="1" cellpadding="4">'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
660 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
661 |
echo '<tr><th colspan="2">Folder: ' . htmlspecialchars($row['img_title']) . '</th></tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
662 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
663 |
// Primary key |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
664 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
665 |
<td class="row2">Unique ID:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
666 |
<td class="row1">' . $row['img_id'] . ' (<a href="' . makeUrlNS('Special', 'Gallery/' . $gal_href) . '">view folder contents</a>)</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
667 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
668 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
669 |
// Path info |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
670 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
671 |
<td class="row2">Parent folders:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
672 |
<td class="row1">' . /* Yeah it's dirty, but hey, it gets the job done ;-) */ ( ( $x = str_replace('&raquo;', '»', htmlspecialchars(str_replace('_', ' ', implode(' » ', $folders)))) ) ? $x : '<in root>' ) . '</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
673 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
674 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
675 |
// Image name |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
676 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
677 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
678 |
<td class="row2">Folder name:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
679 |
<td class="row1"><input type="text" style="width: 98%;" name="img[' . $i . '][title]" value="' . htmlspecialchars($row['img_title']) . '" size="43" /></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
680 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
681 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
682 |
// Mover widget |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
683 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
684 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
685 |
<td class="row2">Move to folder:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
686 |
<td class="row1"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
687 |
<div class="toggle"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
688 |
<div class="head" onclick="gal_toggle( ( IE ? this.nextSibling : this.nextSibling.nextSibling ), this.childNodes[1]);"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
689 |
<img alt=">>" src="<?php echo scriptPath; ?>/plugins/gallery/toggle-closed.png" class="toggler" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
690 |
Select folder |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
691 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
692 |
<div class="body"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
693 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
694 |
echo gallery_hier_formfield('img[' . $i . '][folder]', false); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
695 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
696 |
<br /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
697 |
<a href="#" onclick="gal_unset_radios('img[<?php echo $i; ?>][folder]'); return false;">Unselect field</a> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
698 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
699 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
700 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
701 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
702 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
703 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
704 |
// Finish table |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
705 |
echo '</table>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
706 |
echo '</div>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
707 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
708 |
# Type: image |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
709 |
else: |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
710 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
711 |
// Image ID tracker |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
712 |
echo '<input type="hidden" name="img[' . $i . '][id]" value="' . $row['img_id'] . '" />'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
713 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
714 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
715 |
// Editor table |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
716 |
// |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
717 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
718 |
echo '<div class="tblholder"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
719 |
<table border="0" cellspacing="1" cellpadding="4">'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
720 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
721 |
echo '<tr><th colspan="2">Image: ' . htmlspecialchars($row['img_title']) . '</th></tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
722 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
723 |
// Primary key |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
724 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
725 |
<td class="row2">Unique ID:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
726 |
<td class="row1">' . $row['img_id'] . ' (<a href="' . makeUrlNS('Gallery', $row['img_id']) . '">view image\'s page</a>)</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
727 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
728 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
729 |
// Thumbnail |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
730 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
731 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
732 |
<td class="row2">Thumbnail:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
733 |
<td class="row1"><img alt="Thumbnail image" src="' . $thumb_url . '" /></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
734 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
735 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
736 |
// Image name |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
737 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
738 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
739 |
<td class="row2">Image title:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
740 |
<td class="row1"><input type="text" style="width: 98%;" name="img[' . $i . '][title]" value="' . htmlspecialchars($row['img_title']) . '" size="43" /></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
741 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
742 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
743 |
// Image description |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
744 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
745 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
746 |
<td class="row2">Image description:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
747 |
<td class="row1"><textarea rows="10" cols="40" style="width: 98%;" name="img[' . $i . '][desc]">' . htmlspecialchars($row['img_desc']) . '</textarea></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
748 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
749 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
750 |
// ACL editor trigger |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
751 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
752 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
753 |
<td class="row2">Permissions:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
754 |
<td class="row1"><input type="button" onclick="ajaxOpenACLManager(\'' . $row['img_id'] . '\', \'Gallery\');" value="Edit permissions" /><br /><small>Only works in Firefox 1.5 or later, Safari 3.x or later, or Opera 9.0 or later.</small></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
755 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
756 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
757 |
// Mover widget |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
758 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
759 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
760 |
<td class="row2">Move to folder:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
761 |
<td class="row1"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
762 |
<div class="toggle"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
763 |
<div class="head" onclick="gal_toggle( ( IE ? this.nextSibling : this.nextSibling.nextSibling ), this.childNodes[1]);"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
764 |
<img alt=">>" src="<?php echo scriptPath; ?>/plugins/gallery/toggle-closed.png" class="toggler" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
765 |
Select folder |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
766 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
767 |
<div class="body"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
768 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
769 |
echo gallery_hier_formfield('img[' . $i . '][folder]', false); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
770 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
771 |
<br /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
772 |
<a href="#" onclick="gal_unset_radios('img[<?php echo $i; ?>][folder]'); return false;">Unselect field</a> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
773 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
774 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
775 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
776 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
777 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
778 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
779 |
// File replacer |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
780 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
781 |
echo '<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
782 |
<td class="row2">Upload new version:</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
783 |
<td class="row1"><input type="file" name="reupload_' . $row['img_id'] . '" size="30" style="width: 98%;" /></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
784 |
</tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
785 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
786 |
// Finish table |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
787 |
echo '</table>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
788 |
echo '</div>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
789 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
790 |
endif; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
791 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
792 |
$i++; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
793 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
794 |
while ( $row = $db->fetchrow($e) ); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
795 |
$db->free_result(); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
796 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
797 |
echo '<div class="tblholder"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
798 |
<table border="0" cellspacing="1" cellpadding="4">'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
799 |
// Mover widget |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
800 |
if ( $num_edit > 1 ): |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
801 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
802 |
<tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
803 |
<td class="row2">Move all to folder:<br /><small>Other folder fields on this page can override this for individual images.</small></td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
804 |
<td class="row1" style="width: 70%;"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
805 |
<div class="toggle"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
806 |
<div class="head" onclick="gal_toggle( ( IE ? this.nextSibling : this.nextSibling.nextSibling ), this.childNodes[1]);"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
807 |
<img alt=">>" src="<?php echo scriptPath; ?>/plugins/gallery/toggle-closed.png" class="toggler" /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
808 |
Select folder |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
809 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
810 |
<div class="body"> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
811 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
812 |
echo gallery_hier_formfield('override_folder', false); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
813 |
?> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
814 |
<br /> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
815 |
<a href="#" onclick="gal_unset_radios('override_folder'); return false;">Unselect field</a> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
816 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
817 |
</div> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
818 |
</td> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
819 |
</tr> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
820 |
<?php |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
821 |
endif; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
822 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
823 |
echo ' <tr><th class="subhead" colspan="2"><input type="submit" name="edit_do_save" value="Save changes" /></th></tr>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
824 |
echo ' </table> |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
825 |
</div>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
826 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
827 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
828 |
else |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
829 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
830 |
echo '<p>No images that matched the ID list could be found.</p>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
831 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
832 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
833 |
echo '</form>'; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
834 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
835 |
|
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
836 |
function get_max_size_field() |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
837 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
838 |
$max_size = @ini_get('upload_max_filesize'); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
839 |
$max_size_field = ''; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
840 |
if ( $max_size ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
841 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
842 |
if ( preg_match('/M$/i', $max_size) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
843 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
844 |
$max_size = intval($max_size) * 1048576; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
845 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
846 |
else if ( preg_match('/K$/i', $max_size) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
847 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
848 |
$max_size = intval($max_size) * 1024; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
849 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
850 |
else if ( preg_match('/G$/i', $max_size) ) |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
851 |
{ |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
852 |
$max_size = intval($max_size) * 1048576 * 1024; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
853 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
854 |
$max_size = intval($max_size); |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
855 |
$max_size_field = "\n" . '<input type="hidden" name="MAX_FILE_SIZE" value="' . $max_size . '" />' . "\n"; |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
856 |
} |
7c6e2e97aa08
Added AJAX file upload support.
Dan Fuhry <dan@enanocms.org>
parents:
40
diff
changeset
|
857 |
return $max_size_field; |
0
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
858 |
} |
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
859 |
|
7caf561c50ee
Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff
changeset
|
860 |
?> |