Jetzt habe ich vor, verschiedene Ordner mit Bildern zu füllen und über mehrere verschiedene Seiten zu öffnen.
Bei der ersten geht es auch, dummerweise lassen sich die anderen Ordner nicht so anwählen, wie ich mir das wünsche. Vielleicht kennt jemand diesen Fehler.
Hier der Code :
Code: Alles auswählen
$selected = "CMS_VALUE[0]";
echo "<table cellspacing=\"0\" cellpadding=\"5\" border=\"0\">
<tr valign=\"top\">
<td>Einzelbild-Seite</td>
<td>
<select name=\"CMS_VAR[0]\">";
$sql = "SELECT * FROM $cfgTab_cat_tree AS TREE, $cfgTab_cat_side AS CATSIDE, $cfgTab_cat AS CAT, $cfgTab_cat_lang AS CATLANG, $cfgTab_side_lang AS SIDELANG WHERE TREE.idcat=CATSIDE.idcat AND CATSIDE.idcat=CATLANG.idcat AND CATLANG.idlang='$lang' AND CATSIDE.idside=SIDELANG.idside AND SIDELANG.idlang='$lang' AND CAT.idcat=TREE.idcat AND CAT.idclient='$client' ORDER BY TREE.idtree";
$db->query($sql);
if ($selected != 0) {
echo "<option value=0>diese Seite</option>";
} else {
echo "<option value=0 selected>diese Seite</option>";
}
while ($db->next_record()) {
$spaces = "";
for ($i=0; $i<$db->f("level"); $i++) {
$spaces = $spaces . " ";
}
if ( $db->f("idcatside") != $selected ) {
echo "<option value=\"".$db->f("idcatside")."\">$spaces ".$db->f("name")."---".$db->f("title")."</option>";
} else {
echo "<option value=\"".$db->f("idcatside")."\" selected>$spaces ".$db->f("name")."---".$db->f("title")."</option>";
}
}
echo "</select>";
echo " </td>
</tr>
<tr>
<td>
Image-Directory:
</td>
<td>
<input size=20 type=\"text\" name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\">
</td>
</tr>
<tr>
<td>Image-Directory relativ:</td>
<td><input size=20 type=\"text\" name=\"CMS_VAR[10]\" value=\"CMS_VALUE[10]\"></td>
</tr>
<tr>
<td>
Thumbnail-Directory:
</td>
<td>
<input size=20 type=\"text\" name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\">
</td>
</tr>
<tr>
<td>Thumbnail-Directory relativ:</td>
<td><input size=20 type=\"text\" name=\"CMS_VAR[11]\" value=\"CMS_VALUE[11]\"></td>
</tr>
<tr>
<td>
Image-Dateieendung (z.B. .jpg;.gif):
</td>
<td>
<input size=20 type=\"text\" name=\"CMS_VAR[4]\" value=\"CMS_VALUE[4]\">
</td>
</tr>
<tr>
<td>
Thumbnailtabelle in Spalten x Zeilen:
</td>
<td>
<input size=3 maxlength=2 type=\"text\" name=\"CMS_VAR[5]\" value=\"CMS_VALUE[5]\">x<input size=3 maxlength=2 type=\"text\" name=\"CMS_VAR[6]\" value=\"CMS_VALUE[6]\">
</td>
</tr>
<tr>
<td>
Thumbnailgrösse in XxY:
</td>
<td>
<input size=3 maxlength=3 type=\"text\" name=\"CMS_VAR[7]\" value=\"CMS_VALUE[7]\">x<input size=3 maxlength=3 type=\"text\" name=\"CMS_VAR[8]\" value=\"CMS_VALUE[8]\">
</td>
</tr>
<tr>
<td>
Pfad zum ImageMagick (optional):
</td>
<td>
<input size=20 type=\"text\" name=\"CMS_VAR[9]\" value=\"CMS_VALUE[9]\">
</td>
</tr>
</table>";
Code: Alles auswählen
<?
$imagedir="CMS_VALUE[2]";
$imagedirrel="CMS_VALUE[10]";
$thumbnails="CMS_VALUE[3]";
$thumbnailsrel="CMS_VALUE[11]";
$imagetypes=explode(";","CMS_VALUE[4]");
$rows="CMS_VALUE[6]";
$cols="CMS_VALUE[5]";
$thb_x_size="CMS_VALUE[7]";
$thb_y_size="CMS_VALUE[8]";
$image_idcat="CMS_VALUE[0]";
$image_idside="CMS_VALUE[1]";
$im_path="CMS_VALUE[9]";
//-- config ende -------------------------------------
function is_image($filename,$typearray) {
reset($typearray);
while($val=each($typearray)) {
if (strstr($filename,$val[value])!==false) {
return true;
}
}
}
// verkleinert ein Bild auf die angegebene Breite (bei Querformat) oder Höhe (bei Hochformat)
// Seitenverhältnisse werden beibehalten
function resizeImageGD($sourceFile, $targetFile, $newwidth=50, $newheight=50){
$source = ImageCreateFromJpeg($sourceFile);
$width = ImageSx($source);
$height = ImageSy($source);
if ($width > $height){ // Querformat
$newheight = $height*($newwidth/$width);
}else{ // Hochformat
$newwidth = $width*($newheight/$height);
}
$target = ImageCreateTrueColor($newwidth,$newheight);
// ÄNDERUNG vgl. Forums-Beitrag imagecopyresized ($target, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagecopyresampled ($target, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageJPEG($target,$targetFile,100);
}
//-- functions ende ----------------------------------
if (!isset($mmstart)) {
$mmstart=0;
}
// Anzeige eines Bildes oder Übersicht?
if ($subfile!="") {
// Bild anzeigen
echo "<center><a href=\"javascript:history.back()\">zurück</a></center>";
echo "<br>";
echo "<img src=\"$subfile\">";
echo "<br>";
echo "<center><a href=\"javascript:history.back()\">zurück</a></center>";
} else {
// Gallery anzeigen
$handle=opendir($imagedir);
echo "<table>";
$n=0;
$filearray=Array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_image($file,$imagetypes)) {
$filearray[]=$file;
}
}
reset($filearray);
// skip images...
for ($n=0;$n<$mmstart;$n++)
$ffile=each($filearray);
$n=0;
while ($ffile=each($filearray)) {
$file=$ffile[value];
// generate thumbnail, if nessesairy. Now THIS is fun :)
// natuerlich nur, wenn imagemagick vorhanden ist...
if (!file_exists($thumbnails."/thb_".$file) ) {
if ($im_path!="") {
$cmd=$im_path."/convert -scale ".$thb_x_size."x".$thb_y_size." ".$imagedir."/".$file." ".$thumbnails."/thb_".$file;
exec($cmd);
// nochmal prüfen!
$thumbnail=file_exists($thumbnails."/thb_".$file);
} else{
// Bilder mit GD verkleinern
@ini_set("max_execution_time", 120);
@resizeImageGD($imagedir."/".$file, $thumbnails."/thb_".$file, $thb_x_size,$thb_y_size);
$thumbnail=file_exists($thumbnails."/thb_".$file);
}
} else
$thumbnail=true;
if ($n%$cols==0)
echo "<tr>\n";
if ($image_idcat!=0)
$url=$sess->url("front_content.php?client=$client&lang=$lang&subid=$subid&idcatside=$image_idcat&subfile=".rawurlencode($imagedir."/".$file));
else
$url=$sess->url("front_content.php?client=$client&lang=$lang&subid=$subid&idcat=$idcat&idart=$idart&idside=$idside&subfile=".rawurlencode($imagedirrel."/".$file));
echo "<td valign=\"middle\" align=\"center\" width=\"$thb_x_size\" height=\"$thb_y_size\">
<a href=\"/cms/dw.php?file=$file&imagedir=CMS_VALUE[10]\" target=\"dw\" onbeforeunload=\"MM_openBrWindow(\'/cms/dw.php?file=$file&imagedir=CMS_VALUE[10]\',\'dw\',\'menubar=yes,scrollbars=yes,resizable=yes,width=700,height=400\')\">
".($thumbnail ? "<img src=\"$thumbnailsrel/thb_$file\" border=\"0\">":"$file")."</a></td>\n";
$n++;
if ($n%$cols==0)
echo "</tr>\n";
// nur solange wie's not tut...
if ($n>=$rows*$cols)
break;
}
echo "<tr> <td colspan=\"$cols\" align=\"center\">";
if ($mmstart>0) {
$url=$sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&subid=$subid&idside=$idside&mmstart=".($mmstart-$rows*$cols));
echo "<a href=\"$url\">vorherige Bilder...</a>";
}
echo "<span style=\"font-size: 9pt;\">| zeige Bilder ".($mmstart+1)." - ".($mmstart+$n)." |</span>";
if ($n+$mmstart<count($filearray)) {
$url=$sess->url("front_content.php?client=$client&lang=$lang&idcat=$idcat&idart=$idart&subid=$subid&idside=$idside&mmstart=".($mmstart+$rows*$cols));
echo "<a href=\"$url\">weitere Bilder...</a>";
}
echo "</tr>\n";
echo "</table>";
} // Ende Gallery anzeigen
echo "</p>";
?>
Der Fehler im Log ist folgender :
Code: Alles auswählen
[08-Aug-2004 22:07:11] Invalid SQL: SELECT * FROM AS TREE, AS CATSIDE, AS CAT, AS CATLANG, AS SIDELANG WHERE TREE.idcat=CATSIDE.idcat AND CATSIDE.idcat=CATLANG.idcat AND CATLANG.idlang='6' AND CATSIDE.idside=SIDELANG.idside AND SIDELANG.idlang='6' AND CAT.idcat=TREE.idcat AND CAT.idclient='6' ORDER BY TREE.idtree<br><br>
[08-Aug-2004 22:07:11] next_record called with no query pending.
Greetz Dddanny