Bilder angepasst im Upload-Verzeichnis

Gesperrt
HardCastle
Beiträge: 22
Registriert: Mi 12. Mär 2003, 12:06
Kontaktdaten:

Bilder angepasst im Upload-Verzeichnis

Beitrag von HardCastle »

Wer sich schon immer mal geärgert hat, dass im Bilder-Upload Verzeichnis die Bilder vollkommen verzerrt dargestellt werden, bekommt nachfolgend eine angepasste Datei:

fnc_upl.inc.php

Damit werden die Bilder im Original angezeigt und falls sie größer als die Tabellenspalte werden, werden sie proportional verkleinert. Als kleinen Zusatz gibt es die Größenangabe des Originals.

Folgenden Code per Copy&Paste in eine neue Datei (Editor) einfügen. Unter "fnc_upl.inc.php" abspeichern und in das Verzeichnis ".../contenido/inc/" kopieren. Originaldatei vorher sichern.

Code: Alles auswählen

<?php
/******************************************************************************
Description : Defines the 'upl' related functions
Copyright   : four for business AG, 2002
Author      : Olaf Niemann
Urls        : www.contenido.de
Create date : 2002-03-02

Functions
uplListDirectory($path)
uplDeleteFile($file)
********************************************************************************/
function uplListDirectory($path) {
	global $db;
	global $sess;
	global $client;
	global $lang;
	global $cfgPathImg;
	global $cfgTab_upl;
	global $cfgClient;
	global $formaction;
	global $tmp_d;
	global $tmp_f;
	global $upltype;
	global $cellpadding;
	global $cellspacing;
	global $border;
	global $lngUpl;

	//**************List of files in upload directory taken from db
	echo "<TABLE cellpadding=$cellpadding cellspacing=$cellspacing border=$border>";
	echo "<TR><TD class=head colspan=3 width=600 nowrap>Inhalt des Verzeichnisses \"$path\":</TD></TR>";
	echo "<TR><TD class=head>Vorschau/Größe/Beschreibung</TD><TD class=head>Dateiname</TD><TD class=head>&nbsp;</TD></TR>";

	$sql = "SELECT * FROM $cfgTab_upl WHERE idclient='$client' AND dirname='$upltype' AND filetype='".$cfgClient[$client]["filetype"]["$upltype"]."' ORDER BY filename";
	$db->query($sql);
	$i = 0;
	while ($db->next_record())
	{
        $i++;

        if ($action=30 && $db->f("filename") == $tmp_f) {
			echo "<TR><TD class=content width=250><a name=clickedhere>";

            if($db->f('filetype') == 'img'){


$imgwidthfix = "470";						// Breite des verkleinerten Bildes
$img = $cfgClient[$client]["htmlpath"]["$upltype"].$db->f("filename");
$imgsize   = GetImageSize ("$img");				//  Ermittelt die Ausmaße einer Image-Datei
$imgwidth  = $imgsize[0];					// Img Breite
$imgheight = $imgsize[1];					// Img Hoehe
if ($imgwidth > $imgwidthfix)
{
   $zoomfaktor = $imgwidthfix/$imgwidth;			// Zommfaktor ermitteln
   $imgheight  = $imgheight*$zoomfaktor;			// Hoehe des verkleinerten Bildes
   $imgheight  = floor ($imgheight);				// ganze positive Zahl
   $imgwidth   = $imgwidthfix;
}
$imglink = "<IMG SRC='$img' width='$imgwidth' height='$imgheight'>";


			    echo $imglink."<br>(".$imgsize[0]."x".$imgsize[1].") ".$db->f("description");
            }
            else{
			     echo $db->f("description");
			}

            echo "</TD><TD class=content>".$db->f("filename")."&nbsp;<A HREF=\"".$sess->url("main.php?action=31&tmp_d=$tmp_d&tmp_f=$tmp_f&idupl=".$db->f("idupl")."&upltype=$upltype")."\"><img src=\"".$cfgPathImg."but_confirm.gif\" border=0></A><a href=\"javascript:history.back()\"><img src=\"".$cfgPathImg."but_cancel_delete.gif\" border=0></a></TD>";
        }
        else {
            echo "<TR><TD class=content width=470>";

            if($db->f('filetype') == 'img'){

$imgwidthfix = "470";						// Breite des verkleinerten Bildes
$img = $cfgClient[$client]["htmlpath"]["$upltype"].$db->f("filename");
$imgsize   = GetImageSize ("$img");					//  Ermittelt die Ausmaße einer Image-Datei
$imgwidth  = $imgsize[0];						// Img Breite
$imgheight = $imgsize[1];

if ($imgwidth > $imgwidthfix)
{
   $zoomfaktor = $imgwidthfix/$imgwidth;				// Zommfaktor ermitteln
   $imgheight  = $imgheight*$zoomfaktor;				// Hoehe des verkleinerten Bildes
   $imgheight  = floor ($imgheight);					// ganze positive Zahl
   $imgwidth   = $imgwidthfix;
}
$imglink = "<IMG SRC='$img' width='$imgwidth' height='$imgheight' border=0>";


			    echo $imglink."<br>(".$imgsize[0]."x".$imgsize[1].") ".$db->f("description");
            }
            else{
			     echo $db->f("description");
			}

            echo"</TD><TD class=content>".$db->f("filename")."</TD>";
        }


        echo "<form name=\"uploadform$i\" action=\"$formaction#clickedhere\" method=post enctype=\"multipart/form-data\">";
        $sess->hidden_session();

        //$tmp_area = "upl";
		//echo "  <INPUT type=hidden name=area VALUE='$tmp_area'>";

		echo "<INPUT type=hidden name=action VALUE=\"30\">";
        echo "<input type=hidden name=tmp_d value=\"$path\">";
        echo "<input type=hidden name=tmp_f value=\"".$db->f("filename")."\">";
        echo "<INPUT type=hidden name=upltype VALUE=\"$upltype\">";
        echo "<INPUT type=hidden name=idupl VALUE=\"".$db->f("idupl")."\">";
        echo "<TD class=content><a href=\"#\" class=action onclick=\"uploadform$i.submit()\">".$lngUpl["delete"]."</a>";

        //echo "<TD class=content><INPUT type=image src=\"".$cfgPathImg."but_ok.gif\" border=0>";

        echo "</TD></form>";
		echo "</TR>";

        if ($i == 0){
                echo "<TR><TD class=content colspan=3>".$lngUpl["dirisempty"]."</TR>";
        }

    }
        echo "</TABLE>";

}

function uplDeleteFile($file) {
	global $db;
	global $cfgTab_upl;
	global $idupl;
	global $cfgTab_side_lang;

	$sql = "SELECT * FROM $cfgTab_side_lang WHERE idside='0' and idlang='0'";
	$db->query($sql);
	$i = 0;
	if ($db->next_record()) {
		while ( list($key, $value) = each($db->Record) ) {
			if (is_string($key)) {
				if (ereg("img", $key) && !ereg("^imgdescr", $key) ) {
					$i++;
				}
			}
		}
	} else {
		die("there should be an default entry with idside=0 AND idlang=0 in con_side_lang table");
	}

	$empty = 1;
	for ($j=1; $j<$i+1; $j++) {
		$sql = "SELECT * FROM $cfgTab_side_lang WHERE img".$j."='$idupl'";
		$db->query($sql);
		if ($db->next_record()) {
			$empty = 0;
		}
	}

	if ($empty == 0) {
		return "0701";		// file is still in use, you cannot delete it
	} else {
        	unlink("$file");

        	$sql = "DELETE FROM $cfgTab_upl WHERE idupl='$idupl'";
        	$db->query($sql);
        }
}
?>
Gruß HardCastle
Gesperrt