<?php
# Copyright by: Manuel
# Support: www.ilch.de
# modified by rom
defined (
'main'
)
or
die
(
'no direct access'
);
# Benutzer ist berechtigt?
if
(
$_SESSION
[
'authright'
] <= -2 ) {
$title
=
$allgAr
[
'title'
].
' :: Bild hochladen'
;
$hmenu
=
'Bild hochladen'
;
$design
=
new
design (
$title
,
$hmenu
);
$design
->header();
if
( !
is_writable
(
'include/images/gallery'
) ) {
die
(
'<b>Fehler</b> Das Verzeichnis include/images/<u>gallery</u> hat keine Schreibrechte!! bitte nachholen!'
);
}
$show
= true;
function
create_thumb (
$imgpath
,
$thumbpath
) {
global
$allgAr
;
$neueBreite
=
$allgAr
[
'gallery_preview_width'
];
$size
=
getimagesize
(
$imgpath
);
$breite
=
$size
[0];
$hoehe
=
$size
[1];
$neueHoehe
=
intval
(
$hoehe
*
$neueBreite
/
$breite
);
if
(
$size
[2] == 2) { # JPG
$altesBild
=ImageCreateFromJPEG(
$imgpath
);
$neuesBild
=imageCreate(
$neueBreite
,
$neueHoehe
);
imageCopyResized(
$neuesBild
,
$altesBild
,0,0,0,0,
$neueBreite
,
$neueHoehe
,
$breite
,
$hoehe
);
ImageJPEG(
$neuesBild
,
$thumbpath
);
}
elseif
(
$size
[2] == 3) { # PNG
$altesBild
=ImageCreateFromPNG(
$imgpath
);
$neuesBild
=imageCreate(
$neueBreite
,
$neueHoehe
);
imageCopyResized(
$neuesBild
,
$altesBild
,0,0,0,0,
$neueBreite
,
$neueHoehe
,
$breite
,
$hoehe
);
ImagePNG(
$neuesBild
,
$thumbpath
);
}
}
switch
(
$um
) {
case
'addimg'
:
$img
=
$_FILES
[
'file'
][
'name'
];
if
(
strpos
(
$img
,
'_'
) === FALSE AND
strpos
(
$img
,
'.'
) === FALSE ) {
echo
'Konnte Bild nicht hochladen, weil der Name einen <b>.</b> (Punkt) oder einen <b>_</b> (Unterstrich) enthalten hat.<br />'
;
}
else
{
$imgpath
=
'include/images/gallery/'
.
$_POST
[
'dir'
].
'_'
.
$_FILES
[
'file'
][
'name'
];
if
(move_uploaded_file (
$_FILES
[
'file'
][
'tmp_name'
] ,
$imgpath
) ) {
$tmp
=
explode
(
'.'
,
$_FILES
[
'file'
][
'name'
]);
if
(function_exists(
'imageCopyResized'
)) {
$thumbpath
=
'include/images/gallery/'
.
$_POST
[
'dir'
].
'_'
.
$tmp
[0].
'_small.'
.
$tmp
[1];
create_thumb (
$imgpath
,
$thumbpath
);
}
if
( !
empty
(
$_POST
[
'besch'
]) ) {
$datei
=
fopen
(
'include/images/gallery/'
.
$_POST
[
'dir'
].
'_'
.
$tmp
[0].
'.txt'
,
"w"
);
fputs
(
$datei
,
$_POST
[
'besch'
]);
fclose(
$datei
);
}
}
echo
'<center><b>Bild erfolgreich hochgeladen!</center>'
;}
break
;
case
'deldir'
:
$category
=
$_GET
[
'dir'
];
$o
= opendir(
'include/images/gallery'
);
$category_length
=
strlen
(
$category
);
while
(
$f
= readdir (
$o
)) {
if
(
$f
!=
'.'
&&
$f
!=
'..'
AND
substr
(
$f
, 0,
$category_length
) ==
$category
AND
strpos
(
$f
,
'.'
) !== FALSE) {
unlink (
'include/images/gallery/'
.
$f
);
}
}
unlink (
'./include/images/gallery/'
.
$category
);
break
;
case
'adddir'
:
$dir
=
$_POST
[
'dir'
];
if
(
strpos
(
$dir
,
'_'
) === FALSE AND
strpos
(
$dir
,
'.'
) === FALSE ) {
fopen
(
'./include/images/gallery/'
.
$_POST
[
'dir'
],
'a'
);
}
else
{
echo
'Konnte Category nicht anlegen, weil der Name einen <b>.</b> (Punkt) oder einen <b>_</b> (Unterstrich) enthalten hat.<br />'
;
}
break
;
case
'chtxt'
:
$tmp
=
explode
(
'.'
,
$_GET
[
'img'
]);
$datei
=
fopen
(
'./include/images/gallery/'
.
$tmp
[0].
'.txt'
,
"w"
);
fputs
(
$datei
,
$_GET
[
'txt'
]);
fclose(
$datei
);
break
;
case
'delimg'
:
$tmp
=
explode
(
'.'
,
$_GET
[
'img'
]);
unlink(
'include/images/gallery/'
.
$_GET
[
'img'
]);
if
(
file_exists
(
'include/images/gallery/'
.
$tmp
[0].
'.txt'
) ) {
unlink(
'include/images/gallery/'
.
$tmp
[0].
'.txt'
);
}
unlink(
'include/images/gallery/'
.
$tmp
[0].
'_small.'
.
$tmp
[1]);
break
;
case
'neuthumbs'
:
$o
= opendir(
'include/images/gallery'
);
while
(
$f
= readdir (
$o
)) {
if
(
$f
!=
'.'
&&
$f
!=
'..'
AND
strpos
(
$f
,
'.'
) !== FALSE AND
strpos
(
$f
,
'_small.'
) === FALSE AND
strpos
(
$f
,
'.txt'
) === FALSE) {
$tmp
=
explode
(
'.'
,
$f
);
if
(function_exists(
'imageCopyResized'
)) {
$thumbpath
=
'include/images/gallery/'
.
$tmp
[0].
'_small.'
.
$tmp
[1];
$imgpath
=
'include/images/gallery/'
.
$f
;
if
(
$_POST
[
'overwrite'
] ==
'yes'
OR !
file_exists
(
$thumbpath
)) {
create_thumb (
$imgpath
,
$thumbpath
);
}
}
}
}
closedir
(
$o
);
break
;
}
if
(
$show
) {
$tpl
=
new
tpl (
'galleryup.htm'
);
$ordner
=
array
();
$o
= opendir(
'include/images/gallery'
);
$dirs
=
''
;
while
(
$f
= readdir (
$o
)) {
if
(
$f
!=
'.'
&&
$f
!=
'..'
AND
strpos
(
$f
,
'.'
) === FALSE) {
$dirs
.=
$tpl
->list_get(
'dirs'
,
array
(
$f
));
$ordner
[] =
$f
;
}
}
closedir
(
$o
);
$tpl
->set_out(
'dirs'
,
$dirs
,0);
foreach
(
$ordner
as
$category
) {
$tpl
->set_out(
'category'
,
$category
,1);
$o
= opendir(
'include/images/gallery'
);
$category_length
=
strlen
(
$category
);
$class
=
'Cnorm'
;
while
(
$f
= readdir (
$o
)) {
if
(
$f
!=
'.'
&&
$f
!=
'..'
AND
substr
(
$f
, 0,
$category_length
) ==
$category
AND
strpos
(
$f
,
'.'
) !== FALSE AND
strpos
(
$f
,
'_small.'
) === FALSE AND
strpos
(
$f
,
'.txt'
) === FALSE) {
$tmp
=
explode
(
'_'
,
$f
);
$class
= (
$class
==
'Cmite'
?
'Cnorm'
:
'Cmite'
);
$ar
=
array
(
'img'
=>
$tmp
[1],
'deimg'
=>
$f
,
'class'
=>
$class
);
$tpl
->set_ar_out(
$ar
,2);
}
}
closedir
(
$o
);
}
$tpl
->out(3);
}
$design
->footer();
}
else
{
die
(
'no access'
);
}
?>