ok danke leute ich will ja nicht zuviel ))) aber jetzt hab ich den übeltäter, ich/wir benutzen eine aus dem weg kostenlos bei php-welt zur verfügung gestellte bild-archiv-datenbank…dort kann man für jedes foto auch kommentare ablassen…scheinbar ist das ding nicht ganz sauber programmiert, denn jedesmal wenn ein bild aufgerufen wird, wird eine while-query-abfrage generiert um global zu prüfen ob kommentare überhaupt vorhanden sind, das muss man umprogrammieren, aber das skript sprengt meine fähigkeiten bei weiten, es hat mich schon 2 tage anpassungsarbeit gekostet und ich hab auch ne menge gelernt, aber vielleicht könnte mir doch ein freak mal helfen::: wo liegt der unsaubere code?
/* Copyright © 2000 Christophe Thibault */
include „config.inc.php“;
include („userin.php3“);
if($thumb_generator==„convert“) {
@exec(„which convert“, $my_convert_path);
if($my_convert_path=="") die(„install convert (see manual) or use ‚GD‘ or ‚manual‘ as thumb generator“);
}
function set_cookie_val($val)
{
global $cookiesite;
setcookie(„LoginValue“,$val,time()+(3600*24*365*3),"/");
}
function get_comment($nom)
{
global $sDB,$nConnection,$sTable;
$cmd=„select * from $sTable where name=’“.addslashes($nom)."’";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return $row[„descr“];
}
function get_level_db($nom)
{
global $sDB,$nConnection,$sTable;
$cmd=„select * from $sTable where name=’“.addslashes($nom)."’";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return (int)$row[„seclevel“];
}
function get_level($pic) {
if(!strstr($pic,"/")) return (int)get_level_db($pic);
$l=get_level_db($pic);
if($l!=0) return (int)$l;
$l2=get_level_db($pic."/");
if($l2!=0) return (int)$l2;
return (int)(get_level(substr($pic,0,strrpos($pic,"/"))));
}
function reformat($s)
{
if($s) $s=StripSlashes($s);
if(!strstr($s,"…")) { } else $s=""; // ANTI HACK
return($s);
}
// image convertion functions
function wait_convert_proc()
{
global $sem,$use_sem;
register_shutdown_function(„end_convert_proc“);
if($use_sem) {
$sem=sem_get(31337);
sem_acquire($sem);
}
}
function end_convert_proc()
{
global $sem,$use_sem;
if($use_sem) {
sem_release($sem);
}
register_shutdown_function("");
}
function convert_image($sourcepic,$destpic,$res,$quality)
{
global $my_convert_path,$thumb_generator;
wait_convert_proc();
if($thumb_generator==„convert“) {
@exec($my_convert_path[0]." -geometry „.$res.“ -quality „.$quality.“ „“.$sourcepic."" „“.$destpic.""");
} else if($thumb_generator==„gd“) {
if(eregi(".(jpg|jpeg)$",$sourcepic))
$im=imagecreatefromjpeg($sourcepic);
else if (eregi(".png$",$fn))
$im=imagecreatefrompng($createfn);
if ($im != „“) {
$dims=explode(„x“,$res);
$newh=$dims[1];
$neww=$newh/imagesy($im) * imagesx($im);
if ($neww > imagesx($im)) {
$neww=imagesx($im);
$newh=imagesy($im);
}
if ($neww > $dims[0])
{
$neww=$dims[0];
$newh=$neww/imagesx($im) * imagesy($im);
}
$im2=ImageCreate($neww,$newh);
ImageCopyResized($im2,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
if (eregi(".(jpg|jpeg)$",$sourcepic)) imagejpeg($im2,$destpic,$quality);
else if (eregi(".png$",$fn)) imagepng($im2,$destpic);
ImageDestroy($im);
ImageDestroy($im2);
}
}
end_convert_proc();
}
// comments functions
function get_nb_comments($id)
{
global $sDB,$nConnection,$sTableComments;
$cmd=„select * from „.$sTableComments.“ where pic_name=’“.addslashes($id)."’";
$res=mysql_db_query($sDB,$cmd,$nConnection);
return mysql_num_rows($res);
}
function display_comments($id)
{
global $sDB,$nConnection,$sTableComments,$admin;
global $txt_comments,$txt_add_comment,$txt_comment_from,$txt_comment_on;
?>
if(get_nb_comments($id)>0) { ?>
echo $txt_comments ?>
} ?>
[if (document.layers) document.writeln(’<FONT FACE=„Arial,Verdana,helvetica,sans-serif“ SIZE=„1“ Color="#FF9900">’)« Seite zurück if (document.layers) document.writeln(’</FONT>’)](javascript:history.back())
[if (document.layers) document.writeln(’<FONT FACE=„Arial,Verdana,helvetica,sans-serif“ SIZE=„1“ Color="#FF9900">’)Foto verschickenif (document.layers) document.writeln(’</FONT>’)](javascript:zeigsmir(‚content/fotoversand.php?&route=…/‘,240,330,1,0,0,0,0,0))if (document.layers) document.writeln(’<FONT FACE=„Arial,Verdana,helvetica,sans-serif“ SIZE=„1“ Color="#FF9900">’) | if (document.layers) document.writeln(’</FONT>’)if (document.layers) document.writeln(’<FONT FACE="A…
// variablendefinition fuer netscape 4.x stylez
$style1 = „“;
$style1end = „“;
$styleVorZ = „“;
$cmd=„select * from „.$sTableComments.“ where pic_name=’“.addslashes($id)."’";
$res=mysql_db_query($sDB,$cmd,$nConnection);
while($row=mysql_fetch_array($res))
{
echo „“.$txt_comment_from."".$row[„user“]."".$txt_comment_on.$row[„datetime“];
if($admin)
{
echo " | Delete";
}
echo "
„;
echo „“;
echo nl2br(htmlentities($row[„comment“])).“
";
echo "
";
}
}
// logout ?
if($logout) {
set_cookie_val("");
header("Location: ".$SCRIPT_NAME);
exit;
}
// logging in ?
unset($user_row);
if($startlogin) {
$cmd=„select * from „.$sTableUsers.“ where login=’$user’ and pass=’$pass’“;
$res = mysql_db_query($sDB,$cmd,$nConnection);
if(!$res || mysql_num_rows($res)==0 ) $error_login=1;
else {
$logged=1;
$user_row=mysql_fetch_array($res);
set_cookie_val($user_row[„cookieval“]);
}
} else if($LoginValue) { // login cookie present ?
$cmd=„select * from „.$sTableUsers.“ where cookieval=’$LoginValue’“;
$res = mysql_db_query($sDB,$cmd,$nConnection);
if($res && mysql_num_rows($res)>0 ) {
$logged=1;
$user_row=mysql_fetch_array($res);
}
}
$admin=($user_row[„seclevel“]==999);
// pic comment update ?
if($updpic&&$admin) {
$cmd=„replace into $sTable values(’$display’,’$dsc’,’$lev’)“;
mysql_db_query($sDB,$cmd,$nConnection);
}
// dir level update ?
if($dirlevel&&$admin) {
$cmd=„replace into $sTable values(’$dir’,’’,’$dirlevel’)“;
mysql_db_query($sDB,$cmd,$nConnection);
}
if($dir) $dir=reformat($dir);
if($display) $display=reformat($display);
if($displaypic) $displaypic=reformat($displaypic);
if($preview) $preview=reformat($preview);
if($display) $dir=dirname($display);
if(substr($root_dir,-1)!=’/’) $root_dir.=’/’;
if($dir && substr($dir,-1)!=’/’) $dir.=’/’;
// dir creation ?
if($dircreate&&$admin) {
mkdir($root_dir.$dir.$createdirname,0755);
}
// file uploaded ?
if($admin&&$picupload&&$picuploadname!=„none“) {
Exec(„cp -f „$picuploadname“ „“.$root_dir.$dir.$picuploadname_name.“"");
Exec(„chmod 755 „“.$root_dir.$dir.$picuploadname_name.“"");
}
// adding comment ?
if($addingcomment && (trim($comment) || trim($user))) {
$picname=reformat($picname);
$cmd=„insert into „.$sTableComments.“ values(0,’“.addslashes($picname)."’,’$comment’,’".date(„Y-m-d H:i:s“)."’,’$user’,’$REMOTE_ADDR’)";
mysql_db_query($sDB,$cmd,$nConnection);
?> window.opener.location=„pictures.php?display=<? echo rawurlencode($picname) ?>“;window.close();
exit;
}
// deleting comment ?
if($delcom&&$admin) {
$cmd=„delete from „.$sTableComments.“ where id=$delcom“;
mysql_db_query($sDB,$cmd,$nConnection);
}
// picture displaying ?
if($displaypic && get_level($displaypic)=$lr_limit && !$non_lr) {
// switch to lr_mode
$lrdir=$root_dir.dirname($displaypic)."/.thumbs";
$lrfile=$lrdir."/lr_".basename($displaypic);
if(!file_exists($lrfile)) {
if(!is_dir($lrdir)) mkdir($lrdir,0755);
convert_image($root_dir.$displaypic,$lrfile,$lr_res,$lr_quality);
}
readfile($lrfile);
} else readfile($root_dir.$displaypic);
exit;
}
if($preview) {
header(„Content-type: image/jpeg“);
$prdir=$root_dir.dirname($preview)."/.thumbs";
$prfile=$prdir."/thumb_".basename($preview);
if(!file_exists($prfile)) {
if(!is_dir($prdir)) mkdir($prdir,0755);
convert_image($root_dir.$preview,$prfile,$thumb_res,$thumb_quality);
}
readfile($prfile);
exit;
}
// random image?
if($random) {
$level=0;
if($logged) $level=(int)$user_row[„seclevel“];
$ok=0;
srand ((double) microtime() * 1000000);
exec(‚find ‚.$root_dir.‘ -type f -and -name *.jpg -or -name *.gif -or -name *.jpeg -or -name *.png | grep -v „.thumbs/“‘,$find_ar);
$l=sizeof($find_ar);
for($try=0;!$ok && $try
";
$gen_lr=0; $gen_th=0;
exec(‚find ‚.$root_dir.‘ -type f -and -name *.jpg -or -name *.gif -or -name *.jpeg -or -name *.png | grep -v „.thumbs/“‘,$find_ar);
for($i=0;$find_ar[$i];$i++) {
$pic=substr($find_ar[$i],strlen($root_dir));
$lrdir=$root_dir.dirname($pic)."/.thumbs";
if(!is_dir($lrdir)) mkdir($lrdir,0755);
// low res check
if(filesize($root_dir.$pic)>=$lr_limit) {
$lrfile=$lrdir."/lr_".basename($pic);
if(!file_exists($lrfile)) {
echo "Generating low res picture for $pic
";
flush();
convert_image($root_dir.$pic,$lrfile,$lr_res,$lr_quality);
$gen_lr++;
}
}
// thumbnail check
$prfile=$lrdir."/thumb_".basename($pic);
if(!file_exists($prfile)) {
echo "Generating thumbnail picture for $pic
";
flush();
convert_image($root_dir.$pic,$prfile,$thumb_res,$thumb_quality);
$gen_th++;
}
}
echo "
";
echo "Generated $gen_lr low res pictures and $gen_th thumbnails.
";
echo "Your library has „.sizeof($find_ar).“ pictures.
";
exit;
}
?>
include „headerp.inc.php“ ?>
// Login form
if($login) {
?>
echo $txt_login_form_login ?>
echo $txt_login_form_pass ?>
include „footerp.inc.php“;
exit;
} else if($create&&$admin) { // Create dir form
echo "Current directory : „.$dir.“
";
?>
Directory to create:
include „footerp.inc.php“;
exit;
} else if($upload&&$admin) { // Create dir form
echo "Current directory : „.$dir.“
";
?>
File to upload:
include „footerp.inc.php“;
exit;
} else if($addcomment) { // (little „add comment“ popup window)
$id=reformat($id);
?>
echo $txt_comment_form_name ?> >
echo $txt_comment_form_comment ?>
include „footerp.inc.php“;
exit;
} else if($lastcomments) { // display last added comments
echo "
Die letzten 100 Kommentare:
";
echo "
";
$cmd=„select * from „.$sTableComments.“ order by datetime desc“;
$res=mysql_db_query($sDB,$cmd,$nConnection);
$i=0;
echo "
„;
while($row=mysql_fetch_array($res) and $i(int)$user_row[„seclevel“]) continue;
echo „“;
echo $row[„datetime“].“ by „.$row[„user“].“ : „;
$comment=get_comment($row[„pic_name“]);
if($comment==“") $comment=$row[„pic_name“];
echo „".$comment."“;
echo "
";
$i++;
}
echo "
";
echo "« Zurück zur Übersicht
";
echo "
";
include „footerp.inc.php“;
exit;
}
?>
if(get_level($dir)>(int)$user_row[„seclevel“]) exit; // antihack
// scan dir
$nb_dirs=0; $nb_files=0;
$dirs[0]=""; $files[0]="";
$dh=dir($root_dir.$dir);
//$dh=dir($root_dir.$dir);
while ($file=$dh->read()) {
if(substr($file,0,1)==".") continue;
// if(substr($file,-3)=="_lr") continue;
// if(substr($file,-6)=="_thumb") continue;
if(substr($file,-8)=="_comment") continue;
if(is_dir($root_dir.$dir.$file)) {
// directory
if(get_level($dir.$file."/")close();
sort($dirs);
if (is_file($root_dir.$dir."/.desc"))
rsort($files);
else
sort($files);
?>
// display current dir
if(!$dir) echo "Home | Event-Übersicht
„.$txt_root_dir.“";
else echo „Home | Event-Übersicht | „.$txt_root_dir.“/“;
$alldirs=explode("/",$dir);
$alldirtmp="";
for($i=0;$alldirs[$i];$i++) {
$alldirtmp.=$alldirs[$i]."/";
if($alldirs[$i+1] || $display) echo „"; echo $alldirs[$i]; if($alldirs[$i+1] || $displa…/“;
}
echo "
";
?>
if(!$logged) { ?>
echo $txt_login ?>
} else {
echo $user_row[„login“]." - ";
if($admin) {
echo "create dir - upload - ";
echo "gen all pics - ";
} ?>
logout
} ?>
if($txt_random_pic) { ?>
// display dirs
for($i=0;$i".$dirs[$i]."
\n";
}
?>
if($admin&&$dir&&!$display) {
echo "Directory security level: ";
echo „“;
echo " ";
}
?>
// display .welcome message if it exists
echo "Liste der letzten 100 Kommentare hier »
";
?>
if(!$display) { ?>
// display the directory content
function echo_pic($i)
{
global $dir,$files,$sDB,$nConnection;
//src=„pictures.php?preview=“.rawurlencode($dir.$files[$i])."" border=0>";
echo „“;
$comment=get_comment($dir.$files[$i]);
if($comment=="") $comment=$files[$i];
echo „".nl2br(htmlentities($comment))."“;
if(($nbc=get_nb_comments($dir.$files[$i]))>0)
{
echo "
Kommentare: „.$nbc.“";
}
echo „“;
}
if(!$startpic) $startpic=0;
echo „“;
for($i=$startpic;$i";
echo_pic($i);
echo „“;
}
echo „“;
$startpic2=$i;
for(;$i";
echo_pic($i);
echo „“;
}
echo „“;
echo „“;
if($startpic!=0) {
$a=$startpic-($nb_pic_max*2);
if($a".$txt_previous_page." ";
}
if($i!=$nb_files) {
echo „".$txt_next_page."“;
}
echo „“;
echo „“;
?>
} else {
// display the picture
for($i=0;$i";
$style1end = „“;
$styleVorZ = „“;
}
echo " „.$style1.„picture-id: „;
$comment=get_comment($display);
if($comment!=“") echo nl2br(htmlentities($comment)); else echo basename($display);
echo „“.$style1end." „;
if($i!=0) echo „".$styleVorZ."".$txt_previous_image."".$style1end." „;
echo " „.$style1.“(“.($i+1).“/“.$nb_files.“)“.$style1end." „;
if(filesize($root_dir.$display)>=$lr_limit && !$non_lr) echo " „.$txt_hires_image.““;
if(filesize($root_dir.$display)>=$lr_limit && $non_lr) echo " ".$txt_lores_image."1";
if($files[$i+1]) echo "".$styleVorZ."".$txt_next_image."".$style1end."
";
echo " ";
if($admin) { ?>
Description:
echo get_comment($display) ?>
Security level:
}
// display comment message if it exists
if(is_file($root_dir.$display."_comment")) {
echo „“;
system(„cat „“.$root_dir.$display.“_comment"");
echo „“;
}
if(get_level($display)
} ?>
display_comments($display);
} ?>
include „footerp.inc.php“ ?>
danke
meth
habt was gut )