wie Button nur absenden wenn ein Feld ausgewählt ist ?

netzjunkie

Mitglied
Hallo zusammen,

ich arbeite mit einem Freund an einer Bearbeitung der Software Photokorn. Das ist eine Bild-/Shopsoftware.
Wir haben es hinbekommen das man das zu bestellende Format an Hand Klickbuttons nachbestellen kann.
Wenn man aber kein Format auswählt und den Button 'in den Warenkorb' klickt, dann wird das Bild trotzdem in den Warenkorb ohne Format übernommen.
Kann man das Ganze irgendwie absichern ?
Ich meine wenn kein Klickbutton ausgewählt ist kann man den Butto 'in den Warenkorb' zwar klicken, aber dann kommt ein Hinweisfenster mit dem Hinweis das kein Format ausgewählt wurde.

Unser bearbeitete Code, der die Bestellung per Klickbuttons ermöglicht:
HTML:
        echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
        echo "<tr>\n<td width=\"1%\" nowrap=\"nowrap\">";
       
        if (!empty($CONFIG['shop_vat']) AND $CONFIG['shop_vat']!="0") {
            $vat = round(($price * $CONFIG['shop_vat'] / 100),2);
               $vatprice = $price + $vat;
            $price2 = price_format($vatprice);
            $withvat = "$lang_inkvat"; $withvat2 = "($lang_inkvat)";
        } else {      
               $price2 = price_format($price);
            $withvat = ""; $withvat2 = "";
        }
               
        if ($CONFIG['show_shopcart'] == "0") {               
            echo "$currency ".$price2." $withvat2";           
        } elseif ($CONFIG['show_shopcart'] == "1") {
            if (!empty($pricecat) AND @mysql_num_rows($result)!="") {           
                while (list($id,$format,$multiply) = mysql_fetch_array($result)) {
                //    echo "$id";
           
                    $mulprice = $price * $multiply;
                    if ($CONFIG['shop_vat']!="" and $CONFIG['shop_vat']!="0") {
                        $vat = round(($mulprice * $CONFIG['shop_vat'] / 100),2);
                        $price2 = price_format($mulprice + $vat);           
                        $withvat = "$lang_inkvat"; $withvat2 = "($lang_inkvat)";
                    } else {      
                        $price2 = price_format($mulprice);
                        $withvat = ""; $withvat2 = "";
                    }
                    $format = str_replace("\"","&quot;",stripslashes($format));
                echo "\n<input type=\"radio\" name=\"formats\" class=\"selectpricecat\" value=\"$id\" >$format - $currency $price2\n<br>\n";
                //echo "\n<input type=\"radio\" name=\"formats\" class=\"selectpricecat\" value=\"$id\" Checked>$format - $currency $price2\n<br>\n";
                                       
                }
           
                echo "</td>";
                echo "<td width=\"1%\" nowrap=\"nowrap\">&nbsp;$withvat</td>\n";           
                echo "<td align=\"right\" ><input type=\"submit\" value=\"$lang_addtocart\" class=\"button\" />";

Viele Grüße
Thorsten
 
Danke für die Antwort
ich sehe mir das mal an

in einem anderen Quelltext habe ich so eine Abfrage gefunden und die scheitn nicht über Java-Script zu sein, oder ?

HTML:
if(!isset($_POST['radio_button_name']))
{
       echo 'fehler';
}
.

Kann man das denn auch irgendwie auf diese Weise realisieren ?


Viele Grüße
Thorsten
 
Nein das ist mit PHP.
Damit kannst du aber kein Hinweisfenster erstellen.
Mit Javascript kann das alles sehr elegant lösen.

Aber ich verstehe noch nciht genau was du meinst.
Meinst du das mind. ein Harken gesestzt sein muss oder ein so ein Radio button (Kreis mit Punkt oder halt ohne)?
 
Hallo netzjunkie,

nein, das ist nicht Javascript, sondern PHP(du erkennst das z.B. an der Variable, die mit dem $-Zeichen beginnt).

Und natürlich kann man das auf diese Weise realisieren. Du brauchst nur ein Formular, in dem sich der betreffende Radiobutton bzw. die Auswahlliste befindet. So wird das auch in aller Regel programmiert.
Du gibst in dem Formulartag dann an, welche Seite sich um die Verarbeitung der Formulardaten kümmern soll und welche Methode du zum Senden der Daten verwenden möchtest (POST oder GET) und auf der Folgeseite sprichst du dann entweder über $_GET["Formularelement"] oder über $_POST["Formularelement"] das jeweilige Element an und ziehst die Daten zur Verarbeitung raus.

Wenn es noch Fragen gibt, dann frag einfach.

//EDIT: Verdammt, ich war um ein paar Millisekunden zu spät :( ;)

Ciao:
Adam
 
Aber ich verstehe noch nciht genau was du meinst.
Meinst du das mind. ein Harken gesestzt sein muss oder ein so ein Radio button (Kreis mit Punkt oder halt ohne)?

Zur Auswahl stehen ja mehrere Formate, wovon immer nur eines per Radiobutton ausgewählt werden kann.
Wenn kein Radiobutto ausgewählt wurde wird aktuell das Bild ohne Format und Preis in den Warenkorb gelegt.
Ich möchte also irgendeine Sicherung haben, die ein anklicken des Buttons und ein Ablegen in den Warenkorb nicht zuläßt wenn kein Radiobutton ausgewählt wurde.


@Da Hacker, VanHellseh

ich würde diese Varianten ja gerne testen, aber von dieser Art der Programmierung habe ich leider kaum Ahnung.
Zumal die Codes des Photokorn-Scripts doch irgendwie 'seltsam' geschrieben sind.
Ist halt kein normales HTML, das könnte ich noch ein wenig *g*

Hier mal die komplette Datei wo auch die Buttons drin sind:
HTML:
<?php

// ------------------------------------------------------------------------- //

// 1.81 photokorn gallery

// $Id: pic.inc.php 95 2008-04-21 00:11:17Z tina $

// ------------------------------------------------------------------------- //

// Copyright (C) 2003-2008 Bernd Keil <mail@keil-software.de>

// http://www.keil-software.de

// ------------------------------------------------------------------------- //

// THIS SCRIPT IS NOT FREE! Please read the licence agreement for

// this product at http://licence.keil-software.de

// ------------------------------------------------------------------------- //

if (!defined('DIR_PATH')) {

//make sure the file cant be called directly

	exit('Invalid file request');

}



echo $tablemain;

echo $tabletop;

echo $logo;



if ($CONFIG['shop_ssl']==1) {

	$httpurl = str_replace("http","https", URL);

} else {

	$httpurl = URL;

}



// define some variables

$previous_img = $next_img = $rating = $download = $ratingvid = $downloadvid = $kwkeys = $infofields = "";

$format_rating = $extras = $extras2 = $ratinvid = $downloadvid = $size_orig = $prev = $navi_links = "";

$downloadcolumn = $printcol = $shopcol = $postcardcol = 0; $addcolumn = 2; 



getuserinfo();

$pic = intval($_GET['id']);



//get category id

$catid = mysql_fetch_row(cnt_mysql_query("SELECT catid FROM ".DB_PREFIX."pic WHERE id=$pic LIMIT 1"));

$cat = $catid[0]; $rate = "0";



if (empty($cat)) {

	echo "<span class=\"error\">$lang_error_nopicid</span>";

	errorend();

}



if (isset($_POST['rate'])){

	$rate = intval($_POST['rate']);

}



//get addinfo colums and process variables

$fieldarray = explode (",",substr($CONFIG['addnames'],1));



foreach ($fieldarray as $w) {

	if (!empty($CONFIG['addnames']) AND !empty($CONFIG['name_addinfo'.$w])) {

		$infofields .= ", addinfo$w";

	}

}



//make sure mysql sorts numbers naturally

if ($CONFIG['sortpics'] == "filesize" OR $CONFIG['sortpics'] == "views" OR $CONFIG['sortpics'] == "id" 

    OR $CONFIG['sortpics'] == "rating" OR $CONFIG['sortpics'] == "price") {

	$CONFIG['sortpics'] = $CONFIG['sortpics']."+0";

}

	

if ($CONFIG['sortpics2'] == "filesize" OR $CONFIG['sortpics2'] == "views" OR $CONFIG['sortpics2'] == "id" 

	OR $CONFIG['sortpics2'] == "rating" OR $CONFIG['sortpics2'] == "price") {

	$CONFIG['sortpics2'] = $CONFIG['sortpics2']."+0";

}



//get password

$protection = mysql_fetch_row(cnt_mysql_query("SELECT password, origfolder, sortfield, sortorder, sortfield2, sortorder2 FROM ".DB_PREFIX."cat WHERE id=$cat"));

if (isset($_SESSION['category'.$cat])=="yes" OR empty($protection[0])) {

			

	$sortpics = $CONFIG['sortpics']; $sortpics2 = $CONFIG['sortpics2'];

	$sortpicsasc = $CONFIG['sortpicsasc']; $sortpicsasc2 = $CONFIG['sortpicsasc2'];

	

	if (!empty($protection[2])) { $sortpics = $protection[2]; }

	if (!empty($protection[4])) { $sortpics2 = $protection[4]; }

	if (!empty($protection[3])) { $sortpicsasc = $protection[3]; } 

	if (!empty($protection[5])) { $sortpicsasc2 = $protection[5]; }

	

	$order = "$sortpics $sortpicsasc";

	if (!empty($CONFIG['sortpics2'])) {

		$order .= ", $sortpics2 $sortpicsasc2";

	}

	

	$query = "SELECT p.id, p.catid, p.filename, p.title, p.description, p.views, p.rating, p.numrating, p.downloads, p.filesize, (p.datetime$dotime$seconds), p.allow_rating, p.allow_postcard, p.allow_download, p.allow_shop, p.keywords, p.price, p.pricecat, v.ip, v.pic, p.upload_from{$infofields}

	FROM ".DB_PREFIX."pic as p LEFT JOIN ".DB_PREFIX."vote as v

	ON v.pic = p.id AND v.ip = '$ip' WHERE p.id=$pic";

	$result = cnt_mysql_query($query);

	$data = mysql_fetch_row($result);

	

	//assign variables title, picdesc and keywords, if not already done so in header (see pic.php)

	if ($CONFIG['show_picnameheader']=="0") { $title = stripslashes($data[3]); }

	if ($CONFIG['replace_metadesc']=="0") {	$picdesc = $data[4]; } 

	if ($CONFIG['replace_metakeys']=="0") {	$keywords = stripslashes($data[15]);}

	

	$id = $data[0];

	$cat_id = $data[1];

	$file_name = stripslashes($data[2]);

	$desc = nl2br($picdesc);

	$views = $data[5];

	$rating = $data[6];

	$numrating = $data[7];

	$down_loads = $data[8];

	$file_size = format_filesize($data[9]);

	$datetime = date("$CONFIG[date_format] $CONFIG[time_format]", $data[10]);

	$allow_rating = $data[11];

	$allow_postcard = $data[12];

	$allow_download = $data[13];

	$allow_shop = $data[14];

	$price = stripslashes($data[16]);

	$pricecat = $data[17];

	$vip = $data[18];

	$vpic = $data[19];

	$username = stripslashes($data[20]);



	if ($action=="dorate" AND $rate!="0") {



		//make sure they dont vote twice

		if ($ip=="$vip" AND $pic=="$vpic") {

			$novote = "<div class=\"error\" style=\"text-align: center;\">$lang_error_novote</div>";

			$newrating = $rating;

			$newnumrating = $numrating;

		} else {

			$newrating = $rating + $rate;

			$newnumrating = $numrating + 1;

			$time = time();

			$novote = "<div class=\"ok\" style=\"text-align: center;\">$lang_thanks_vote</div>";

			$update = "UPDATE ".DB_PREFIX."pic SET rating='$newrating', numrating='$newnumrating' WHERE id=$pic";

			$upresult = cnt_mysql_query($update);

			$insert = "INSERT into ".DB_PREFIX."vote (id, catid, ip, host, browser, pic, datetime, vote) 

			VALUES (NULL, $cat_id, '$ip', '$remotehost', '$useragent', $pic, '$time', '$rate')";

			$inresult = cnt_mysql_query($insert);

		}



	} else {

		$newrating = $rating;

		$newnumrating = $numrating;

	}



	$newviews = $views + 1;

	get_fileext($file_name);

	

	if ($isimage == "true") {

		$size_orig = @getimagesize(DIR_PATH ."/$CONFIG[gal]/$cat/$protection[1]/$file_name");

	}



	$alt = "$lang_preview"; //alt tag



	if ($isvideo == "true" or $isaudio == "true" or $isdoc == "true") {

		player ($file_name, $protection[1], $cat);

	} elseif ($isimage == "true") {

		//test if medium image exists

		if ($CONFIG['createmediumimg']==1 AND (file_exists(DIR_PATH . "/$CONFIG[gal]/$cat/med_".$nameonly.".jpg")) or (file_exists(DIR_PATH . "/$CONFIG[gal]/$cat/med_$file_name"))) {

			//show medium image

			if ($fileending==".gif" or $fileending==".jpg" or $fileending==".jpeg" or $fileeding==".jpe" or $fileending==".png") {

				$size_pic = @getimagesize(DIR_PATH . "/$CONFIG[gal]/$cat/med_".$nameonly.$fileending);

				$imgfile = "<img src=\"$CONFIG[gal]/$cat/med_".$nameonly.$fileending."\" class=\"mediumimage\" border=\"0\" $size_pic[3] alt=\"$alt\" title=\"$alt\"/>";

			} else {

				$size_pic = @getimagesize(DIR_PATH . "/$CONFIG[gal]/$cat/med_".$nameonly.".jpg");

				$imgfile = "<img src=\"$CONFIG[gal]/$cat/med_".$nameonly.".jpg\" class=\"mediumimage\" border=\"0\" $size_pic[3] alt=\"$alt\" title=\"$alt\"/>";

			}

			

		} elseif ($CONFIG['createmediumimg']==2) {

			//show original instead

			$size_pic = @getimagesize(DIR_PATH . "/$CONFIG[gal]/$cat/$protection[1]/$file_name");

			$imgfile = "<img src=\"$CONFIG[gal]/$cat/$protection[1]/$file_name\" class=\"mediumimage\" border=\"0\" $size_pic[3] alt=\"$alt\" title=\"$alt\" />";

			

		} else {

			//show error thumb

			$size_pic = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/nothumb.gif");

			$imgfile = "<img src=\"$CONFIG[imgfolder]/nothumb.gif\" border=\"0\" $size_pic[3] alt=\"$alt\" title=\"$alt\" /><br />";

			$imgfile .= "<br /><span class=\"text\">$lang_error_nomedimage</span>";

		}

	}



	//next and previous links

	if (!empty($file_name)) {

			

		$ids = array(); $ref = $prev_file = $next_file = $curr = 0;  $marker = "";

		$querypages = "SELECT id FROM ".DB_PREFIX."pic WHERE catid=$cat ORDER BY $order";

		$rows = cnt_mysql_query($querypages);



		while (list($id) = mysql_fetch_array($rows)) {

			$ref++;

			$ids[$ref] = array($id);

			$startlink = $ids[1];

			if ($ids[$ref][0]==$pic) {

				$curr = $ref;

			}

		}

			

		$prev_file = array();

		$next_file = array();

		if ($curr>1) 		{ $prev_file = $ids[$curr-1]; }

		if ($curr!=$ref)	{ $next_file = $ids[$curr+1];}



		if (@!empty($next_file[0])) {

			$next = "<a href=\"pic.php?id=$next_file[0]\" accesskey=\"n\">$lang_next</a> <b>&raquo;</b> ";

		} else {

			$next = "<a href=\"pic.php?id=$startlink[0]\" accesskey=\"s\">$lang_start</a>";

		}



		if (@$prev_file[0]!=0) {

			$prev = "<b>&laquo;</b> <a href=\"pic.php?id=$prev_file[0]\" accesskey=\"p\">$lang_previous</a>";

		} 



		if (!empty($prev) AND !empty($next)) {

			$marker = "|";

		}

	}



	//start table with image table here

	echo "\n<!-- image and rating table start //-->\n";

		

	if (!empty($file_name)) {

		//breadcrum navigation

		$crumb = breadcrumb($cat, ' <b>&raquo;</b> ');

		if (!empty($prev) AND !empty($next)) { $navilinks = "<div style=\"float: right;\">$prev $marker $next</div>\n"; }

		echo "<div class=\"breadcrumb\">$navi_links<a href=\"index.php\" accesskey=\"1\"><b>$lang_home</b></a> $crumb</div>\n";

		if ($CONFIG['show_catdesc3'] == "1" and !empty($linkdesc)) {

			echo "$linkdesc";

		}

	}

		

	echo "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"100%\" bgcolor=\"$CONFIG[tablebordercolor]\">\n";

	echo "<tr>\n<td>\n";

	echo "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">\n";



	if (!empty($cat)) { // check because of moderated images

		echo "<tr>\n";

		echo "<td bgcolor=\"$CONFIG[bgcolor2]\" class=\"text\">";

		echo "<div style=\"float: right\">".@$prev." ".@$marker." ".@$next."&nbsp;</div>\n";

		echo "&nbsp;<a href=\"index.php?action=showgal&amp;cat=$cat\" accesskey=\"b\">$lang_backtocat</a>\n";

		echo "</td>\n</tr>\n";

	}



	//show image

echo "<table border=\"0\" cellpadding=\"0\" bgcolor=\"$CONFIG[bgcolor1]\" cellspacing=\"0\" align=\"center\" width=\"100%\">\n";


	echo "<tr>\n";

	echo "<td align=\"center\" valign=\"top\" class=\"mediumcell\">$imgfile</td>\n";

echo "<td>\n";

	//get addinfo colums and process variables 

	$numfields = explode (",",substr($CONFIG['addnames'],1)); $s=21;



	foreach ($numfields as $w) {

		if ($CONFIG['addnames']!="") {

			if ($CONFIG['show_addinfo'.$w]==1 and $CONFIG['name_addinfo'.$w]!="" and $data[$s]!="") {

				echo "<tr>\n<td bgcolor=\"$CONFIG[bgcolor1]\" width=\"1%\"><b>".stripslashes($CONFIG['name_addinfo'.$w]).":&nbsp;</b></td>\n";

				echo "<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\">".stripslashes($data[$s])."</td>\n</tr>\n";

			}

			$s++;

		}

	}



	if (trim(!empty($price)) and $price!="0.00") {

		

		$currency = currency();

		if (!empty($pricecat)) { $lang_price_format = $lang_article; } else { $lang_price_format = $lang_price; }

		// echo "<tr>\n<td bgcolor=\"$CONFIG[bgcolor1]\" nowrap=\"nowrap\" width=\"1%\"><b>$lang_price_format:</b>&nbsp;</td>\n";

		echo "<td valign=\"top\" width=\"200\" bgcolor=\"$CONFIG[bgcolor1]\">";

			

		if (!empty($pricecat)) {

			$query = "SELECT id,format,multiply,sort FROM ".DB_PREFIX."pricecat 

			WHERE id IN ($pricecat) ORDER BY sort ASC";

			$result = cnt_mysql_query($query) or die("Pricecat error".mysql_error()."");

			

			if (mysql_num_rows($result)!="") {

				echo "<form method=\"post\" action=\"$httpurl/cart.php\">\n";

				echo "<input type=\"hidden\" name=\"id\" value=\"$pic\" />\n";

				echo "<input type=\"hidden\" name=\"qty\" value=\"1\" />\n";

				echo "<input type=\"hidden\" name=\"cat\" value=\"$cat\" />\n";

				echo "<input type=\"hidden\" name=\"action\" value=\"add\" />\n";

			}

		}

			
    echo "<u><b><br>Formatauswahl <br>für Ihre Bestellung:</b></u><br><br>";    //text       
        echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
        echo "<tr>\n<td width=\"1%\" nowrap=\"nowrap\">";
		

		if (!empty($CONFIG['shop_vat']) AND $CONFIG['shop_vat']!="0") {

			$vat = round(($price * $CONFIG['shop_vat'] / 100),2);

           	$vatprice = $price + $vat;

            $price2 = price_format($vatprice); 

			$withvat = "$lang_inkvat"; $withvat2 = "($lang_inkvat)";

        } else {	   

           	$price2 = price_format($price); 

			$withvat = ""; $withvat2 = "";

        }

	
// Auswahl in Radio Button geändert			

		if ($CONFIG['show_shopcart'] == "0") {				

			echo "$currency ".$price2." $withvat2";			

		} elseif ($CONFIG['show_shopcart'] == "1") {

			if (!empty($pricecat) AND @mysql_num_rows($result)!="") {			

				while (list($id,$format,$multiply) = mysql_fetch_array($result)) {
				//	echo "$id";
			
					$mulprice = $price * $multiply;

					if ($CONFIG['shop_vat']!="" and $CONFIG['shop_vat']!="0") {

						$vat = round(($mulprice * $CONFIG['shop_vat'] / 100),2);

                		$price2 = price_format($mulprice + $vat);			

						$withvat = "$lang_inkvat"; $withvat2 = "($lang_inkvat)";

            		} else {	   

                		$price2 = price_format($mulprice); 

						$withvat = ""; $withvat2 = "";

            		} 

					$format = str_replace("\"","&quot;",stripslashes($format));
				
				echo "\n<input type=\"radio\" name=\"formats\" class=\"selectpricecat\" value=\"$id\" >$format - $currency $price2\n<br>\n";
			  //echo "\n<input type=\"radio\" name=\"formats\" class=\"selectpricecat\" value=\"$id\" Checked>$format - $currency $price2\n<br>\n";
										
				}

				echo "</td>";
				echo "<tr>\n";
				echo "<td align=\"left\" ><br><br><input type=\"submit\" value=\"$lang_addtocart\" class=\"button\" /><br><br><i>Für weitere Formate sprechen Sie mich einfach an...</i>";

			} else {

				//show this if no price categories defined

				echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";

				echo "<tr>\n";

				echo "<td class=\"text\">$currency ".$price2." $withvat2</td>\n";

				echo "<td align=\"right\"><a href=\"$httpurl/cart.php?action=add&amp;id=$pic&amp;cat=$cat&amp;qty=1\">$lang_addtocart</a>&nbsp;</td>";

				echo "</tr>";

				echo "</table>";		

			}

		}

		echo "</td>\n</tr>\n</tr>\n";

		echo "</table>";

	

		if (!empty($pricecat) and @mysql_num_rows($result)!="") {

			echo "</form>\n";

		}

			echo "</td>\n</tr>\n";

		}




   
echo "</td>\n";


	echo "</tr>";



	//show rating scale if allowed

	if ($CONFIG['show_rating'] == 1) {

		if ($allow_rating == "1") {			

			echo "<tr>\n";

			echo "<td bgcolor=\"$CONFIG[bgcolor2]\">\n";

			if (isset($novote)=="") {

				echo "<form name=\"rateform\" action=\"pic.php?action=dorate&amp;id=$pic\" method=\"post\">\n";

				echo "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\">\n";

				echo "<tr>\n";

				echo "<td class=\"text\"><b>$lang_rating:&nbsp;</b></td>\n";

				echo "<td class=\"text\">$lang_rating1</td>\n";

				echo "<td>";

				for ($vi = 1; $vi <= 10; $vi++) {

					echo "<input name=\"rate\" type=\"radio\" title=\"$vi\" value=\"$vi\" onclick=\"this.form.submit()\" />";

				}

				echo "</td>\n";

				echo "<td class=\"text\">&nbsp;$lang_rating5</td>\n";

				echo "</tr>\n";

				echo "</table>\n";

				echo "</form>\n";

			} else {

				//show error message if someone tries to vote more than once

			    echo "$novote";

		    }

			echo "</td>\n</tr>\n";

		}

	}		

	echo "</table>\n";

	echo "</td>\n</tr>\n</table>\n";

	echo "<!-- image and rating table end //-->\n\n";

		

	//show file statistics ... find out how many colums will be displayed		

	if ($CONFIG['show_numdownloads']==1 AND $allow_download!=0) {

		$downloadcolumn = 1;

	}

		

	$numofcolumns = $allow_rating + $downloadcolumn + $CONFIG['show_filename'] + $CONFIG['show_numviews'] + $addcolumn;



	switch ($numofcolumns) {

	case 1:

		$columnwidth = "100%";

		break;

	case 2:

		$columnwidth = "50%";

		break;

	case 3:

		$columnwidth = "33%";

		break;

	case 4:

		$columnwidth = "25%";

		break;

	case 5:

		$columnwidth = "20%";

		break;

	case 6:

		$columnwidth = "16%";

		break;

	}

		

	echo "<!-- file info table start //-->\n";

	echo "<div class=\"cellspacing\"></div>\n";

	echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" width=\"100%\" bgcolor=\"$CONFIG[tablebordercolor]\">\n";

	echo "<tr>\n<td>\n";

	echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\">\n";

	

	if ($CONFIG['show_picinfos']!="0") {

	

		echo "<tr align=\"center\">\n";



		//#### table head ######

		echo "<td bgcolor=\"$CONFIG[bgcolor2]\" width=\"$columnwidth\"><b>$lang_date</b></td>\n";

		if ($CONFIG['show_filename'] == "1") {

			echo "<td bgcolor=\"$CONFIG[bgcolor2]\" width=\"$columnwidth\"><b>$lang_filename</b></td>\n";

		}

		echo "<td bgcolor=\"$CONFIG[bgcolor2]\" width=\"$columnwidth\"><b>$lang_filesize</b></td>\n";

		if ($CONFIG['show_rating'] == 1) {

			if ($allow_rating == "1") {

				echo "<td bgcolor=\"$CONFIG[bgcolor2]\" width=\"$columnwidth\"><b>$lang_rating</b></td>\n";

			}

		}

		if ($CONFIG['show_downloadlink'] != 3) {	

			if ($allow_download == "1" AND $CONFIG['show_numdownloads'] == "1") {

				echo "<td bgcolor=white; width=\"$columnwidth\"><b>$lang_downloads</b></td>\n";

			}

		}

		if ($CONFIG['show_numviews'] == "1") {

			echo "<td bgcolor=\"$CONFIG[bgcolor2]\" width=\"$columnwidth\"><b>$lang_views</b></td>\n";

		}

		echo "</tr>\n";

		

		// ######## second row - details ########

		echo "<tr align=\"center\">\n";

		

		//date and time

		echo "<td bgcolor=\"$CONFIG[bgcolor1]\">$datetime</td>\n";

		

		//filename

		if ($CONFIG['show_filename'] == "1") {

			echo "<td bgcolor=\"$CONFIG[bgcolor1]\">$file_name</td>\n";

		}

		

		//file size;

		$show_filesize = "<span style=\"white-space: nowrap;\">($show_filesize)</span>";

		if ($isimage=="true") { 

			$filedims = "$size_orig[0] x $size_orig[1] $show_filesize"; 

		} else {

			$filedims = "$show_filesize";

		}

		echo "<td bgcolor=\"$CONFIG[bgcolor1]\">$filedims</td>\n";

		

		// file rating	

		if ($CONFIG['show_rating'] == 1) { 	

			if ($allow_rating == "1") {

				if ($numrating != 0) {

					$currentrating = round(($newrating / $newnumrating), 2);

				} else {

					$currentrating = $newrating;

				}	

				if ($numrating > 1 or $numrating == 0) { $vote_word = "$lang_numvotes";} else {$vote_word = "$lang_numvote";}

				echo "<td bgcolor=\"$CONFIG[bgcolor1]\">$currentrating ($numrating $vote_word)</td>\n";

			} 

		}

		

		//number of downloads	

		if ($CONFIG['show_downloadlink'] != 3) { 

			if ($allow_download == "1" AND $CONFIG['show_numdownloads']=="1") {

				if ($fileending==".wmas" or $fileending==".rpas" or $fileending==".rpvs" or $fileending==".wmvs") {

					$download_val = "$lang_livestream";

				} else {

					$download_val = numbering($down_loads);

				}

				echo "<td bgcolor=\"$CONFIG[bgcolor1]\">$download_val</td>\n";

			}

		} 

		

		//number of views

		if ($CONFIG['show_numviews'] == "1") {

			echo "<td bgcolor=\"$CONFIG[bgcolor1]\">".numbering($views)."</td>\n";

		}

		echo "</tr>\n";

	}

		

	// ########### show action permissions table ############

	//find out how many colums will be displayed

	if ($CONFIG['show_downloadlink']=="0" and $allow_download=="1") { //show both

		$downloadcol = 2;

	} elseif ($CONFIG['show_downloadlink']=="1" and $allow_download=="1") { //only original

		$downloadcol = 1;

	} elseif ($CONFIG['show_downloadlink']=="2" and $allow_download=="1") { //only zip

		$downloadcol = 1;

	} elseif ($CONFIG['show_downloadlink']=="3" or $allow_download=="0") { //no download

		$downloadcol = 0;

	}

		

	if ($CONFIG['printing']=="1" AND $allow_print!="0" AND $isimage=="true") { $printcol = 1; }

	if ($CONFIG['photo_partner_id']!="" AND $CONFIG['photo_partner']!="0" AND $isimage=="true") { $shopcol = 1; }

	if ($CONFIG['show_postcardlink']=="1" and $allow_postcard!="0") { $postcardcol = 1; }

	

	$numofcolumns2 = $downloadcol + $postcardcol + $printcol + $shopcol;



	switch ($numofcolumns2) {

	case 1:

		$columnwidth2 = "100%";

		break;

	case 2:

		$columnwidth2 = "50%";

		break;

	case 3:

		$columnwidth2 = "33%";

		break;

	case 4:

		$columnwidth2 = "25%";

		break;

	case 5:

		$columnwidth2 = "20%";

		break;

	case 6:

		$columnwidth2 = "16%";

		break;

	}

	

	if ($numofcolumns2 > 0) {

	 

		echo "<tr>\n";

		echo "<td colspan=\"$numofcolumns\" bgcolor=\"$CONFIG[bgcolor1]\">\n";

		echo "\n<!-- action table start //-->\n";

		echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";

		echo "<tr align=\"center\">\n";



		//post card link

		if ($CONFIG['show_postcardlink'] == 1) {

			if ($allow_postcard == "1") {

				$size_ecard = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/postcard.gif");

				$ecard_link = "<img src=\"$CONFIG[imgfolder]/postcard.gif\" $size_ecard[3] alt=\"$lang_write\" title=\"$lang_write\" border=\"0\" class=\"actionicons\" />";

				echo "<td bgcolor=\"$CONFIG[bgcolor1]\" width=\"$columnwidth2\">$ecard_link <a href=\"postcard.php?cat=$cat&amp;pic=$pic\">$lang_write</a></td>\n";

			}

		}

	

		//download and zip link

		if ($allow_download == "1") {

			$size_down = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/download.gif");

			$download_link = "<img src=\"$CONFIG[imgfolder]/download.gif\" $size_down[3] alt=\"$lang_download_full\" title=\"$lang_download_full\" border=\"0\" class=\"actionicons\" />";

			$size_zip = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/zip_dwl.gif");

			$zip_link = "<img src=\"$CONFIG[imgfolder]/zip_dwl.gif\" $size_zip[3] alt=\"$lang_download_zip\" title=\"$lang_download_zip\" border=\"0\" class=\"actionicons\" />";

			//show both download and zip link

			if ($CONFIG['show_downloadlink'] == "0") {

				if ($fileending!=".zip") {

					echo "<td width=\"$columnwidth2\" nowrap=\"nowrap\">$zip_link <a href=\"zip.php?cat=$cat&amp;pic=$pic\">$lang_download_zip</a></td>\n";

				}

				echo "<td nowrap=\"nowrap\">$download_link <a href=\"download.php?cat=$cat&amp;pic=$pic\">$lang_download_full</a></td>\n";

			//show only normal download

			} elseif ($CONFIG['show_downloadlink'] == "1") { 

				echo "<td width=\"$columnwidth2\" nowrap=\"nowrap\">$download_link <a href=\"download.php?cat=$cat&amp;pic=$pic\">$lang_download_full</a></td>\n";   

			//show only zip download

			} elseif ($CONFIG['show_downloadlink'] == "2") { 

				echo "<td width=\"$columnwidth2\" nowrap=\"nowrap\">$zip_link <a href=\"zip.php?cat=$cat&amp;pic=$pic\">$lang_download_zip</a></td>\n";

			}

		}



		//print link if its an image

		if ($isimage=="true" and $CONFIG['printing']=="1") {

			$size_print = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/print.gif");

			$print_link = "<img src=\"$CONFIG[imgfolder]/print.gif\" $size_print[3] alt=\"$lang_print\" title=\"$lang_print\" border=\"0\" class=\"actionicons\" />";

			echo "<td width=\"$columnwidth2\">$print_link <a href=\"javascript:MM_openBrWindow('print.php?cat=$cat&amp;pic=$pic','print','width=15,height=15,scrollbars=no')\">$lang_print</a></td>\n";

		}

	

		//show partner shop cart button

		if ($isimage=="true" and $allow_shop=="1" and !empty($CONFIG['photo_partner_id'])) {			

			$originalpic = base64_encode(URL . "/$CONFIG[gal]/$cat/$protection[1]/$file_name");

			$thumbpic = base64_encode(URL . "/$CONFIG[gal]/$cat/thb_$file_name");

			if ($CONFIG['photo_partner'] == "1") {

				//fotokasten

				$countrycode = fotokasten_lang();

				$size_fk = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/cart.gif");

				$fk_link = "<img src=\"$CONFIG[imgfolder]/cart.gif\" $size_fk[3] alt=\"$lang_fk\" title=\"$lang_fk\" border=\"0\" class=\"actionicons\" />";

				echo "<td width=\"$columnwidth2\">$fk_link <a href=\"javascript:fotokasten('$CONFIG[photo_partner_id]','$originalpic','$thumbpic','$size_orig[1]','$size_orig[0]','$countrycode')\">$lang_fk</a></td>\n";

			} elseif ($CONFIG['photo_partner'] == "2") {

				//bildpartner

				$size_bp = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/cart.gif");

				$bp_link = "<img src=\"$CONFIG[imgfolder]/cart.gif\" $size_bp[3] alt=\"$lang_bp\" title=\"$lang_bp\" border=\"0\" class=\"actionicons\" />";

				echo "<td width=\"$columnwidth2\">$bp_link <a href=\"javascript:bildpartner('$CONFIG[photo_partner_id]','$originalpic','','$pic','$title')\" onmouseover=\"MM_displayStatusMsg('$lang_bp');return document.MM_returnValue\">$lang_bp</a></td>\n";

			} elseif ($CONFIG['photo_partner'] == "3") {

				//pixaco

				$size_px = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/cart.gif");

				$px_link = "<img src=\"$CONFIG[imgfolder]/cart.gif\" $size_px[3] alt=\"$lang_px\" title=\"$lang_px\" border=\"0\" class=\"actionicons\" />";

				echo "<td width=\"$columnwidth2\">$px_link <a href=\"javascript:pixacotransfer('$originalpic')\">$lang_px</a></td>\n";

			} elseif ($CONFIG['photo_partner'] == "4") {

				//pixaco by zanox

				$size_zn = @getimagesize(DIR_PATH . "/$CONFIG[imgfolder]/cart.gif");

				$zn_link = "<img src=\"$CONFIG[imgfolder]/cart.gif\" $size_bp[3] alt=\"$lang_px\" title=\"$lang_px\" border=\"0\" class=\"actionicons\" />";

				echo "<td width=\"$columnwidth2\">$zn_link <a href=\"pixacozanox('$CONFIG[photo_partner_id]','$originalpic')\">$lang_px</a></td>\n";

			}

		}

		echo "</tr>\n</table>\n"; 

		echo "</td>\n</tr>\n";

		echo "<!-- action table end //-->\n"; //end action table

	}

	

	echo "</table>\n";

	echo "</td>\n</tr>\n</table>\n";

	echo "\n<!-- file info table end //-->\n";

	

	// ############ dipslay details table ##############

	if (empty($title) AND empty($desc) AND (empty($price) OR $price=="0.00") AND empty($keywords) AND empty($CONFIG['addnames']) AND empty($username)) {

		$tableend = ""; $tableendborder = "";

	} else {

		echo "\n<!-- details table start //-->\n";

		echo "<div class=\"cellspacing\"></div>";

		echo "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"50%\" bgcolor=\"$CONFIG[tablebordercolor]\">\n";

		echo "<tr>\n<td>\n";

		echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\">\n";

		$tableend = "</table>\n";

		$tableendborder = "</td></tr></table>\n";

	}



	if (!empty($title)) {

		echo "<tr>\n<td bgcolor=\"$CONFIG[bgcolor1]\" width=\"1%\" nowrap=\"nowrap\"><b>$lang_title:&nbsp;</b></td>\n";

		echo "<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\">$title</td>\n</tr>\n";

	}



	if (!empty($desc)) {

		echo "<tr>\n<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\" nowrap=\"nowrap\" width=\"1%\"><b>$lang_desc:&nbsp;</b></td>\n";

		echo "<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\">$desc</td>\n</tr>\n";

	}



	if (!empty($keywords) AND $CONFIG['show_keywords']!=0) {

		echo "<tr>\n<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\" nowrap=\"nowrap\" width=\"1%\"><b>$lang_keywords:&nbsp;</b></td>\n";

		echo "<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\">";



		//process keywords and link them to search function

		$keywords = preg_replace("/[,]+/", ", ", $keywords);

		$kw = explode(", ",$keywords);

		for($x=0; $x<count($kw); $x++) {

			$kwlink = "<a href=\"search.php?action=search&amp;type=detail&amp;where[]=keywords&amp;keyword=".urlencode(trim($kw[$x]))."\">$kw[$x]</a>, ";

			$kwkeys .= $kwlink;

		}

		echo substr($kwkeys,0,-2);

		echo "</td>\n</tr>\n";

	}

		

	if ($username!="" and $CONFIG['show_useruploadname']==1) {

		echo "<tr>\n<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\" nowrap=\"nowrap\" width=\"1%\"><b>$lang_uploader:&nbsp;</b></td>\n";

		echo "<td valign=\"top\" bgcolor=\"$CONFIG[bgcolor1]\">$username</td>\n</tr>\n";

	}




		// update views table

		if ($action!="dorate") {

			$update = "UPDATE ".DB_PREFIX."pic SET views='$newviews' WHERE id=$pic";

			$result = cnt_mysql_query($update);

			update_stats_table($cat, 1, 0, 0, 0, "NOUPDATE", "NOUPDATE");

		}



		echo $tableend;

		echo $tableendborder;

		echo "\n<!-- details table end //-->\n";



		echo $tablebottom;

		echo $blankline;

	

		// show exif table if image has exif information

		if ($CONFIG['show_exif']==1) {

			$select_exif = "SELECT exifinfo FROM ".DB_PREFIX."exifinfo WHERE picid='$pic'";

			$result = cnt_mysql_query($select_exif);

			$data = mysql_fetch_row($result);

			$exifinfo = unserialize($data[0]);

			if (!empty($exifinfo)) {

				include_once (INCLUDE_PATH . "/libs/exif.inc.php");

			}

		}



		if (!empty($cat)) { // check because of moderated images

			// link table under image

		//	echo $tabletop;

		//	echo "<table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";

		//	echo "<tr>\n";

		//	echo "<td bgcolor=\"$CONFIG[bgcolor2]\" class=\"text\"><a href=\"index.php?action=showgal&amp;cat=$cat\">$lang_backtocat</a></td>\n";

		//	echo "<td bgcolor=\"$CONFIG[bgcolor2]\" align=\"right\" class=\"text\">".@$prev." ".@$marker." ".@$next."</td>\n";

		//	echo "</tr>\n";

		//	echo "</table>\n";

		} else {

			show_jump();

		}	

		echo $tablebottom;	

	} else {

		//no session

		header("Location: login.php?do=showpic&cat=".$cat."&pic=".$pic);

		exit();

	}



	echo $tablemain_bottom;

	echo $copyright; //removing the copyright is a violation of the licence agreement!



	// ############# Logout ###############

	if ($action == "logout") {

		session_unset();

		session_destroy();

		header("Location: index.php");

		exit();

	}

?>


Viele Grüße
Thorsten
 
Zuletzt bearbeitet:
Zurück