<?php
// ======================================================================== //
//                                                                          //
//   KooBI- Webportalsystem                                                 //
//   SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS                     //
//                                                                          //
//   ====================================================================   //
//                                                                          //   
//   dream4 | webservices - Am Michelsgrund 7 - 69469 Weinheim - Germany    //    
//   tel. +49(0) 6201 - 980442 / fax. +49(0) 6201 - 64809                   //
//                                                                          //
// ======================================================================== //
if(!checkactive('products')) include(dirname(__FILE__)."/lib/notactive.php" );
$sname = simpletitle($lang['products']);
if (!permission('productdetails')) {
	$EOUT = stderror("nopermission", $lang['nopermission_t'], str_replace("__URL__", "index.php", $lang['redirect']), "index.php", 1);
	$error = 1;
	$NOOUT = 1;
}

switch($_REQUEST['action']){
	// <<-- PRODUKTDETAILS -->>
	case 'showdetails' :
	$sql = new dbc("SELECT * FROM ".PREFIX."_products WHERE id = '".escs($_REQUEST['id'])."'");
	$row = $sql->fetchrow();
	$sql2 = new dbc("UPDATE ".PREFIX."_products set hits=hits+1 WHERE id = '".escs($_REQUEST['id'])."'");
	$text = $row->descr;
	$redi_vote = explode(",", $lang['pvoting']);
	$redi_vote = $redi_vote[($row->voting)-1];
	$tmpl->assign('rvote', $redi_vote);
	
	// <<-- SEITEN -->>
	if(!isset($_REQUEST['artpage'])){ $_REQUEST['artpage']=1; };
	$seite_anzeigen = explode("[--NEU--]",$text);
	$anzahl_seiten = count($seite_anzeigen);
	$text = $seite_anzeigen[$_REQUEST['artpage']-1];
	
	// <<-- INLINESHOTS -->>
	$text = inlinescreens($row->inline_screens,$text);
	
	// <<-- NAVI -->>
	if(isset($_REQUEST['print'])) { $prinlink = "&amp;print=1"; }
	if($anzahl_seiten>1){
		$navi = artpage($anzahl_seiten, $lang['aktpos'], " <a class=\"page_navigation\" href=\"index.php?nav=1&amp;area=$area&amp;p=product&amp;action=showdetails&amp;id=".$_REQUEST['id']."$prinlink&amp;artpage={s}\">{t}</a> ");
	}
	
	$sql = new dbc("SELECT links FROM " . PREFIX . "_products WHERE id = '".escs($_REQUEST['id'])."' AND links!='NULL' limit 1");
	$numlinks = $sql->numrows();
	
	if(is_file("uploads/products/" . $row->boxshot)){ $tmpl->assign('boxshot', "uploads/products/" . $row->boxshot); }
	$tmpl->assign('linkednews', fetch_news("product", $row->id));
	$tmpl->assign('linkedarticles', fetch_linked_articles($row->id));
	
	if($row->gallery) $tmpl->assign('linkedgaleries', fetch_gallery($row->gallery));
	$tmpl->assign('mf', fetch_mfname($row->manufacturer));
	$tmpl->assign('publisher', fetch_mfname($row->publisher));
	$tmpl->assign('platform_nolinks', fetch_platform($row->platform,1));
	$tmpl->assign('platform', fetch_platform($row->platform));
	$tmpl->assign('links', fetch_links("products", $row->id));
	$tmpl->assign('genre', fetch_genre($row->genre));
	$tmpl->assign('text', $text);
	$tmpl->assign('lang', $lang);
	$tmpl->assign('row', $row);
	$tmpl->assign('area', $area);
	$tmpl->assign('navi', $navi);
	
	$tmpl->assign("content", parsetrue("container/".container("product_out"), "<a class=\"boxnavi\" href=\"index.php?p=product&amp;action=platforms&amp;area=$area\">".$lang['products'] . "</a>". $lang['f_navi_separator'] . $lang['productdetails'], $tmpl->fetch("product/detail.tpl")));
	$sname .= $lang['f_navi_separator'] . $lang['productdetails'] . $lang['f_navi_separator'] . $row->title;
	break;
	
	
	
	
	// <<-- PLATFORMÜBERSICHT -->>
	case 'platforms' :
	// <<-- DIE NEUESTEN 20 PRODUKTE -->>
	switch($_REQUEST['platform']){
		case "" : 
		case "all" : 
		$db_platform = ""; 
		$pf_once = "all";
		break;
		
		default : 
		$db_platform = " WHERE platform like '%".escs($_REQUEST['platform'])."%'"; 
		$db_pf = " AND (platform like '%".$_REQUEST['platform']."%')"; 
		$pf_once = $_REQUEST['platform'];
		break;
	} 
	$sql = new dbc("SELECT * FROM ".PREFIX."_products  WHERE area='$area' order by id desc limit 20");
	$items = array();
	while( $row=$sql->fetchrow()){
		$row->added = $row->ctime;
		$row->platform = fetch_platform($row->platform);
		$row->genre = fetch_genre($row->genre);
		array_push($items,$row);
	}
	// <<-- AUSWAHL NACH NAME -->>
	switch($_REQUEST['charakter']){
		case "1" :
		for($i=1;$i<10;$i++) { $loop .= " OR title  LIKE '".$i."%' $db_pf"; }
		$dbquery = " WHERE(title LIKE '0%' $loop)";
		$tmpl->assign('charakter', '0-9');
		break;
		
		case "" :
		$dbquery = " WHERE(title LIKE 'a%' $db_pf) ";
		$tmpl->assign('charakter', 'A');
		break;
		
		case "all" :
		$dbquery = "";
		$tmpl->assign('charakter', $lang['all']);
		break;
		
		default :
		$dbquery = " WHERE(title LIKE '".$_REQUEST['charakter']."%') $db_pf ";
		$tmpl->assign('charakter', strtoupper($_REQUEST['charakter']));
		break;
	}
	
	if($_REQUEST['search']==1){
		$dbquery = "WHERE title like '%".$_REQUEST['product_q']."%' $db_pf ";
		$tmpl->assign('product_q', stripslashes($_REQUEST['product_q']));
	}
	
	$andarea = ($dbquery) ? " AND area = '$area'" : " WHERE area = '$area'" ;
	
	$sql2 = new dbc("SELECT  boxshot,id,title,release,platform,genre FROM ".PREFIX."_products $dbquery $andarea order by title ASC");
	
	$items2 = array();
	while( $row2=$sql2->fetchrow()){
		$row2->added = $row2->ctime;
		$row2->platform2 = fetch_platform($row2->platform);
		$row2->genre = fetch_genre($row2->genre);
		array_push($items2,$row2);
	}
	
	$tmpl->assign('items2', $items2);
	$tmpl->assign('platform' ,$pf_once);
	$tmpl->assign('row2', $row2);
	$tmpl->assign('getall_platforms', getall_platforms());
	$tmpl->assign('items', $items);
	$tmpl->assign('row', $row);
	$tmpl->assign('lang', $lang);
	$tmpl->assign('area', $area);
	$tmpl->assign("content", parsetrue("container/".container("product_out"), $lang['products'], $tmpl->fetch("product/overview.tpl")));
	break;
	
}



?>