forked from craigk5n/webcalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicons.php
81 lines (73 loc) · 2.1 KB
/
icons.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
include_once 'includes/init.php';
$icon_path = 'icons/';
$can_edit = ( is_dir ( $icon_path ) &&
( $ENABLE_ICON_UPLOADS == 'Y' || $is_admin ) );
if ( ! $can_edit )
do_redirect ( 'category.php' );
print_header ( array ( 'js/visible.php' ), '', '', true );
$icons = [];
if ( $d = dir ( $icon_path ) ) {
while ( false !== ( $entry = $d->read() ) ) {
if ( substr ( $entry, -3, 3 ) == 'gif' ) {
$data = '';
// We''ll compare the files to eliminate duplicates.
$fd = @fopen ( $icon_path . $entry, 'rb' );
if ( $fd ) {
// We only need to compare the first 1kb.
$data .= fgets ( $fd, 1024 );
$icons[md5 ( $data )] = $entry;
}
fclose ( $fd );
}
}
$d->close();
// Remove duplicates and replace keys with 0...n.
$icons = array_unique ( $icons );
//Convert associative array into numeric array
$icons = array_values ( $icons );
$title_str = translate ( 'Click to Select' );
?>
<script>
<!-- <![CDATA[
function sendURL ( url ) {
var
thisInput = window.opener.document.catform.urlname,
thisPic = window.opener.document.images.urlpic,
thistr1 = window.opener.document.getElementById ('cat_icon'),
thistr2 = window.opener.document.getElementById ('remove_icon');
thisInput.value = url.substring (6);
thisPic.src = url;
thistr1.style.visibility =
thistr2.style.visibility = "visible";
window.close();
}
//]]> -->
</script>
<?php
echo '
<table class="aligncenter">
<tr>
<td colspan="8" class="aligncenter"><h2>'
. translate ( 'Current Icons on Server' ) . '</h2></td>
</tr>
<tr>';
for ( $i = 0, $cnt = count ( $icons ); $i < $cnt; $i++ ) {
echo '
<td><a href="#" onclick="sendURL( \'' . $icon_path . $icons[$i]
. '\' )" ><img src="' . $icon_path . $icons[$i] . '" title="'
. $title_str . '" alt="' . $title_str . '" /></a></td>'
. ( $i > 0 && $i % 8 == 0 ? '
</tr>
<tr>' : '' );
}
echo '
</tr>
<tr>
<td colspan="8" class="aligncenter">' . $title_str . '</td>
</tr>
</table>
</body>
</html>';
}
?>