<?php
/**
 * Open Source - Content Managment System
 * Next Generation v2
 * @Coder:  Mutzii
 * @copyright  Copyright (c) 2012-2013 by Mutzii
 * File: auktion.api.php
 */

class auktion extends API
{
    protected $Holz;
	protected $Food;
	protected $Erz;
	protected $Stein;
	protected $Tränke;
	protected $Wolle;
	protected $Rüstung;
	protected $Waffen;


	public function Init(){
       
	      $this->setHolzblöcke();
		  $this->setFood();
		  $this->setErzblöcke();
		  $this->setSteinblöcke();
		  $this->setTränke();
		  $this->setWolle();
		  $this->setRüstung();
		  $this->setWaffen();
    
	}
   
    public function ChangePassword($password){
	
	  $password = md5($password);
	  $user     = $this->getLoginUser();
	  $SQL      =  $this->getInstance()->getSQL();
	  $update   = $SQL->updatechar("accounts","account_pass",$password,"account_user",$user);
	  $SQL->query($update);
	}
   
    public function getLoginUser()
	{
	   /* Hier wird der Name ausgegeben, von dem Spieler der gerade Eingeloggt ist. */
	   return $this->getInstance()->getLogin()->PrintUser();
	}
	
	public function equalsMoney($Name,$Money){
	     
		 /*
		     Hier wird verglichen, ob der Spieler mehr geld besitzt als 
		     in der Variable $Money drin steht.
		 */
	     if($this->getPlayerMoney($Name) >= $Money){
              return true;
         }		 
		 
	  return false;
	}
	
	public function InsertToAuktion($array)
	{
	   $SQL  =  $this->getInstance()->getSQL();
	   
	   if(is_array($array)){
	      $sqlstring = $SQL->insert("auktion",array("User","ItemID","ItemStack","ItemPrice","ItemBytes","EnchString","EnchInt","Damage"),$array);
		  $SQL->query($sqlstring);
	   }else{ die("Info: InsertToAuktion: kein Array "); }
	  
	}
	
	
	
	public function InsertToPostfach($array)
	{
	   $SQL  =  $this->getInstance()->getSQL();
	   
	   if(is_array($array)){
	      $sqlstring = $SQL->insert("postfach",array("User","ItemID","ItemStack","ItemPrice","ItemBytes","EnchString","EnchInt","Damage"),$array);
		  $SQL->query($sqlstring);
	   }else{ die("Info: InsertToPostfach: kein Array "); }
	  
	}
	
	public function InsertToLager($array)
	{
	   $SQL  =  $this->getInstance()->getSQL();
	   
	   if(is_array($array)){
	      $sqlstring = $SQL->insert("lagerhaus",array("User","ItemID","ItemStack","ItemPrice","ItemBytes","EnchString","EnchInt","Damage"),$array);
		  $SQL->query($sqlstring);
	   }else{ die("Info: InsertToLager: kein Array "); }
	  
	}
	
	
	public function RemoveAuktionsID($auktionsid)
	{
	  /* Entferne das Item vom AuktionsHaus. */
	  $SQL       =  $this->getInstance()->getSQL();
      $sqlstring =  $SQL->delete("auktion","AuktionsID",$auktionsid);
      $SQL->query($sqlstring);
	
	}
	
	public function RemoveEntry($table,$auktionsid)
	{
	  /* Entferne das Item vom AuktionsHaus. */
	  $SQL       =  $this->getInstance()->getSQL();
      $sqlstring =  $SQL->delete($table,"AuktionsID",$auktionsid);
      $SQL->query($sqlstring);
	}
	
	
	public function LagerDaten($lagerid){
	
	  $SQL       = $this->getInstance()->getSQL();
	  $sqlstring = $SQL->search("lagerhaus","AuktionsID",$lagerid);
      $result    = $SQL->query($sqlstring);
	
	  return $result;  /* Return Result */
	
	}
	
	public function PostDaten($lagerid){
	
	  $SQL       = $this->getInstance()->getSQL();
	  $sqlstring = $SQL->search("postfach","AuktionsID",$lagerid);
      $result    = $SQL->query($sqlstring);
	
	  return $result;  /* Return Result */
	
	}

	public function AuktionsDaten($auktionsid){
	
	  $SQL       = $this->getInstance()->getSQL();
	  $sqlstring = $SQL->search("auktion","AuktionsID",$auktionsid);
      $result    = $SQL->query($sqlstring);
	
	  return $result;  /* Return Result */
	}
	
	public function DatabaseArray($result)
	{
	   $daten_array = array();
	
	     while($daten = mysql_fetch_object($result)){	
		 
                                 $daten_array = $this->toArray($daten_array,$daten->User);    
								 $daten_array = $this->toArray($daten_array,$daten->ItemID);     
								 $daten_array = $this->toArray($daten_array,$daten->ItemStack);  
								 $daten_array = $this->toArray($daten_array,$daten->ItemPrice);  
								 $daten_array = $this->toArray($daten_array,$daten->ItemBytes);  
								 $daten_array = $this->toArray($daten_array,$daten->EnchString); 
								 $daten_array = $this->toArray($daten_array,$daten->EnchInt);
								 $daten_array = $this->toArray($daten_array,$daten->Damage); 							
			break;
		}
	
	   return $daten_array;
	}
	
	
	
	public function DatenbankCounter($table,$player){
	
	  $SQL       = $this->getInstance()->getSQL();
	  $sqlstring = $SQL->select($table);
      $result    = $SQL->query($sqlstring);
	  $counter   = 0;
	  
	  while($daten = mysql_fetch_object($result)){
	       if(strcmp($daten->User,$player) == 0){
		      $counter = $counter +1;
		   }
	  }
	  
      return $counter;
	}
	
	public function toArray($insert,$daten)
	{
		 array_push($insert,$daten);
		 return $insert;
	}
	
	public function ArrayToArray($insert,$array)
	{
         $insert = array_merge($insert,$array);
		 return $insert;
	}
	
	 public function BuyError()
    {
      $error = $this->getErrorList(); 
      $error->addError(1,"Auctions ID no longer exists.");
      $error->addError(2,"bought item(s) successfully");
      $error->addError(3,"You do not have enough money.");
	  
	  return $error;
    }
   
   
   public function Buy($auktionsid,$move){
        
		$Error      = "";
        $BuyMessage = $this->BuyError();
        $SQL        = $this->getInstance()->getSQL();
        $login_user = $this->getLoginUser();
        $result     = $this->AuktionsDaten($auktionsid);

            if($this->AuktionsIDSearch($auktionsid)){

                    while($daten = mysql_fetch_object($result)){
                             
							 /* Besitzt der Käufer genug Money???*/		 
							 if($this->equalsMoney($login_user,$daten->ItemPrice)){
							     
								 $daten_array = array();
								 
								 $daten_array = $this->toArray($daten_array,$login_user);        // Name
								 $daten_array = $this->toArray($daten_array,$daten->ItemID);     // ItemID
								 $daten_array = $this->toArray($daten_array,$daten->ItemStack);  // Stack
								 $daten_array = $this->toArray($daten_array,$daten->ItemPrice);  // Item Preis
								 $daten_array = $this->toArray($daten_array,$daten->ItemBytes);  // Item Bytes
								 $daten_array = $this->toArray($daten_array,$daten->EnchString); 
								 $daten_array = $this->toArray($daten_array,$daten->EnchInt);
								 $daten_array = $this->toArray($daten_array,$daten->Damage);
							    
								 /* Daten wurden ins Postfach verschoben. */
								 if($move == 1){
							        $this->InsertToPostfach($daten_array);  
								 }
								 if($move == 2){
								    $this->InsertToLager($daten_array);
								 }
								 /* Der Verkäufer bekommt sein Geld.*/
								 $this->addPlayerMoney($daten->User,$daten->ItemPrice);  
								 
								 /* Käufer wird das Geld abgezogen.*/
								 $this->subPlayerMoney($login_user,$daten->ItemPrice);
								 
								 /* Item wird vom Auktionshaus entfernt */
								 $this->RemoveAuktionsID($auktionsid);
								
                                 /* Message */
                                    $Error  = $BuyMessage->getMessage(2);								 
							 }else{ $Error  = $BuyMessage->getMessage(3);}
							 
                        break;
                    }


            }else{ $Error  = $BuyMessage->getMessage(1);}
  
       return $Error;
    }
   
   public function AuktionsIDSearch($id)
    {
        $SQL        = $this->getInstance()->getSQL();
        $sqlstring  = $SQL->select("auktion");
        $result     = $SQL->query($sqlstring);
       
        $search     = false;
        while($daten = mysql_fetch_object($result)){

             if($daten->AuktionsID == $id){
                 $search = true;
                 break;
             }
        }
       
       return $search;
    }
	
	
	public function getPlayerName($table,$id)
	{  
	    $SQL        = $this->getInstance()->getSQL();
        $sqlstring  = $SQL->select($table);
        $result     = $SQL->query($sqlstring);
		$player     = "";
		
		 while($daten = mysql_fetch_object($result)){

             if($daten->AuktionsID == $id){
                 $player = $daten->User;
                 break;
             }
         }
		 
	  return $player;
	}
	
	public function isLoginPlayer($table,$id)
	{
	    if(strcmp($this->getLoginUser(),$this->getPlayerName($table,$id)) == false){
		   return true;
		}
		
	  return false;
	}
	
	
	
	public function getPlayerMoney($Name)
    {
       $SQL        = $this->getInstance()->getSQL();
       $Money      = "";
           
       $sqlstring = $SQL->search("money","User",$Name);
       $result    = $SQL->query($sqlstring);
      
       while($daten = mysql_fetch_object($result)){
           $Money = $daten->Money;
           break;  
       }    

      return $Money;
    }
	
	
	public function addPlayerMoney($Name,$Money)
	{
	   $SQL          = $this->getInstance()->getSQL();
       $OldMoney     = $this->getPlayerMoney($Name);
       $NewMoney     = $OldMoney + $Money;
	   
       $sqlstring = $SQL->updatedouble("Money","Money",$NewMoney,"User",$Name);
       $SQL->query($sqlstring);

	}
	
	public function subPlayerMoney($Name,$Money)
	{
	   $SQL          = $this->getInstance()->getSQL();
       $OldMoney     = $this->getPlayerMoney($Name);
       $NewMoney     = $OldMoney - $Money;
	   
       $sqlstring = $SQL->updatedouble("money","Money",$NewMoney,"User",$Name);
       $SQL->query($sqlstring);

	}
		
	public function setPlayerMoney($Name,$Money)
    {
       $SQL = $this->getInstance()->getSQL();
       $sqlstring = $SQL->updatedouble("money","Money",$Money,"User",$Name);
       $SQL->query($sqlstring);
    }
	
	
	public function getSonstiges(){
	
	 $list_items = array();
	 
		$list_items = array_merge($list_items,$this->getHolzblöcke());
		$list_items = array_merge($list_items,$this->getFood());
		$list_items = array_merge($list_items,$this->getErzblöcke());
		$list_items = array_merge($list_items,$this->getSteinblöcke());
		$list_items = array_merge($list_items,$this->getWolle());
		$list_items = array_merge($list_items,$this->getTränke());
		$list_items = array_merge($list_items,$this->getWaffen());
		$list_items = array_merge($list_items,$this->getRüstung());
	
	 $sonstiges = array();
	 
	 $size = count($list_items);
	 $f    = false;
	 
	 for($x=0; $x < 3000; $x++){
	    for($y=0; $y < $size; $y++){
			if($list_items[$y] == $x){
			    $f = true;
			    break;
			}else{
                $f = false;
            }			
	   }
	   
	   if($f == false){
	        array_push($sonstiges,$x);
	   }
	  
	 }
	
	   return $sonstiges;
	}
	
	
	public function setHolzblöcke($daten = false,$array = false){
	    
		$current = array(5,17,25,47,54,58,63,64,68,84,125);
		
		if($daten != false){
		    array_push($current,$index);
		}
		if(is_array($array) && $array != false){
		    $current = $this->toArray($current,$array);
		}
		
		$this->Holz = $current;
	}
	public function getHolzblöcke(){
	   return $this->Holz;
	}
  
  
    public function setFood($daten = false, $array = false){
	 
	   $current = array(39,40,83,92,104,105,115,260,281,282,295,296,297,319,320,322,338,344,349,350,353,354,357,360,361,362,363,364,365,366);
	
	   if($daten != false){
		    array_push($current,$index);
		}
		if(is_array($array) && $array != false){
		    $current = $this->toArray($current,$array);
		}
	
	   $this->Food = $current;
	}
	
	public function getFood(){
	   return $this->Food;
	}

    public function setErzblöcke($daten = false, $array = false){
	
	   $current = array(14,15,16,21,22,41,42,56,57,73,129,133);
	    
	   if($daten != false){
		    array_push($current,$index);
		}
		if(is_array($array) && $array != false){
		    $current = $this->toArray($current,$array);
		}
	   
	   $this->Erz = $current;
	}
    
	public function getErzblöcke(){
	  return $this->Erz;
	}
	
    public function setSteinblöcke($daten = false, $array = false){
   
       $current = array(1,4,7,13,43,44,45,48,49,67,70,77,82,87,89,109);
	   
	   if($daten != false){
		    array_push($current,$index);
		}
		if(is_array($array) && $array != false){
		    $current = $this->toArray($current,$array);
		}
	   
       $this->Stein = $current;
    }
	
	public function getSteinblöcke(){
	  return $this->Stein;
	}

    public function setWolle(){
      $array = array(35);
      $this->Wolle = $array;
    }
	
	public function getWolle(){
	  return $this->Wolle;
	}
	
    public function setTränke(){
         $array = array(373,374);
         $this->Tränke = $array;
    }
	
	public function getTränke(){
	   return $this->Tränke;
	}

    public function setWaffen(){
      $_array = array();

              array_push($_array,261); // Bow
              array_push($_array,346); // Fishing Rod
    
       for($x=256; $x <= 258; $x++){
              array_push($_array,$x);
       }      
 
       for($x=267; $x <= 279; $x++){
              array_push($_array,$x);
       }

       for($x=283; $x <= 286; $x++){
              array_push($_array,$x);
       }

       for($x=290; $x <= 294; $x++){
              array_push($_array,$x);
       }

      $this->Waffen = $_array;
    }
	
	public function getWaffen(){
	   return $this->Waffen;
	}

    public function setRüstung(){
   
      $_array = array();

      for($x=298; $x <= 317; $x++){
         array_push($_array,$x);
      }

     $this->Rüstung = $_array;
    }
	
	public function getRüstung(){
	  return $this->Rüstung;
	}
	
	
	public function sortieren($array_1, $array_2){
    
	$neues_array = array();
	
	if(is_array($array_2)){
	
	  $size_1 = count($array_1);
      $size_2 = count($array_2);
    
      //$neues_array = array();
     
      for($x=0; $x < $size_1; $x++){
          for($y=0; $y < $size_2; $y++){
           
                if(strcmp($array_1[$x],$array_2[$y]) == 0){
                   array_push($neues_array,$array_1[$x]);
                }
          }
      }
	
	
	}else{
	  
	    if(strcmp($array_2,"all") == 0){
		    $neues_array = $array_1;
        }
	
	}
		
       return $neues_array;
    }

	
	public function byID($Index){
      $array = array($Index);
      return $array;
    }
   
    public function byName($Index){

          $SQL = $this->getInstance()->getSQL();
          $sqlstring = $SQL->select("itemimage");
          $result    = $SQL->query($sqlstring);

          $_array    = array();
          $_size     = strlen($Index);
          
          if($_size >= 4){
           $SubIndex =  substr ($Index,0 ,4);
          }         


          while($daten = mysql_fetch_object($result)){

                if(strcmp($Index,$daten->ItemName) == 0){
                   array_push($_array,$daten->ItemID);  
                }else{
                   
                if($_size >= 4){
                   if(strcmp($SubIndex,substr($daten->ItemName,0,4)) == 0){
                       array_push($_array,$daten->ItemID);
                   }
              
                }
          
               }

          }


       return $_array;
    }  
	
	 public function getImageItem($ItemID,$ItemByte){
      
       $SQL = $this->getInstance()->getSQL();
       $sqlstring = $SQL->select("itemimage");
       $result    = $SQL->query($sqlstring);
       
       $Message = "No Picture";
       while($daten = mysql_fetch_object($result)){

           if(strcmp($ItemID,$daten->ItemID) == 0){
              if(strcmp($ItemByte,$daten->ItemValue) == 0){

                 $Message =  $daten->ItemImage;
                 break;
              }

           }
       }
        
      return $Message;
    }

    public function getImageName($ItemID,$ItemByte){

       $SQL = $this->getInstance()->getSQL();
       $sqlstring = $SQL->select("itemimage");
       $result    = $SQL->query($sqlstring);
       
       $Message = "Nothing";

       while($daten = mysql_fetch_object($result)){
               
           if(strcmp($ItemID,$daten->ItemID) == 0){
              if(strcmp($ItemByte,$daten->ItemValue) == 0){

                 $Message =  $daten->ItemName;
                 break; 
              }

           }
       }
        
      return $Message;
    }
	
	public function getAvatarImage($player){
	  $user_avatar = '<img width="32px" src="http://minotar.net/avatar/'.$player.'/100.png"/>';
	  return  $user_avatar;
	}
	
	public function AuktionsListe($array,$table)
    {
       	 $liste  = "";
		 $SQL = $this->getInstance()->getSQL();
         $a_size = count($array);
         for($i=0; $i < $a_size; $i++) {

             $sqlstring = $SQL->search($table,"ItemID",$array[$i]);
             $result    = $SQL->query($sqlstring);
             $liste    .= $this->Liste($result,$table); 
		
        }	
      
      return $liste;
    }
	
	public function isMoveItem($table,$auktionsid,$Name){

	    $SQL = $this->getInstance()->getSQL();
	    $sqlstring = $SQL->select($table);
        $result    = $SQL->query($sqlstring);
		$return = false;
		while($daten = mysql_fetch_object($result)){
	
			if(strcmp($auktionsid,$daten->AuktionsID) == 0){
			     if(strcmp($Name,$daten->User) == 0){
                     $return = true;
				 }				 	   
			   break;
			}
		}

	    return $return;
	}
	
	public function BuildArrayFromTableviaAuktionsID($table,$auktionsid){
	
	     $SQL = $this->getInstance()->getSQL();
		 $sqlstring = $SQL->select($table);
         $result    = $SQL->query($sqlstring);
		 
		 $daten_array = array();
		 while($daten = mysql_fetch_object($result)){
		    if(strcmp($auktionsid,$daten->AuktionsID) == 0){
			
								 $daten_array = $this->toArray($daten_array,$daten->User);  
			                     $daten_array = $this->toArray($daten_array,$daten->ItemID);     // ItemID
								 $daten_array = $this->toArray($daten_array,$daten->ItemStack);  // Stack
								 $daten_array = $this->toArray($daten_array,$daten->ItemPrice);  // Item Preis
								 $daten_array = $this->toArray($daten_array,$daten->ItemBytes);  // Item Bytes
								 $daten_array = $this->toArray($daten_array,$daten->EnchString); 
								 $daten_array = $this->toArray($daten_array,$daten->EnchInt);
								 $daten_array = $this->toArray($daten_array,$daten->Damage); 
			   
			   break;
			}
		 }

	   return $daten_array;
	}
	
	
	public function moveItemIntoLager($from_table,$auktionsid,$Name){
	
	  if($this->isMoveItem($from_table,$auktionsid,$Name)){
	       $array = $this->BuildArrayFromTableviaAuktionsID($from_table,$auktionsid);
	       $this->InsertToLager($array);
		   $this->RemoveEntry($from_table,$auktionsid);
	  }
	}
	
	public function moveItemIntoPostfach($from_table,$auktionsid,$Name){
	
	  if($this->isMoveItem($from_table,$auktionsid,$Name)){
	       $array = $this->BuildArrayFromTableviaAuktionsID($from_table,$auktionsid);
	       $this->InsertToPostfach($array);
		   $this->RemoveEntry($from_table,$auktionsid);
	  }
	}
	
	
	
	public function getTableEntryByName($table,$Name){
	
	  $SQL = $this->getInstance()->getSQL();
	  $sqlstring = $SQL->select($table);
      $result    = $SQL->query($sqlstring);
	  $liste      = "";
	  while($daten = mysql_fetch_object($result)){
		  if(strcmp($daten->User,$Name) == 0){
		  
		      $imageurl = $this->getImageItem($daten->ItemID,$daten->ItemBytes);
              $ItemName = $this->getImageName($daten->ItemID,$daten->ItemBytes);
              $stockprice = $daten->ItemPrice / $daten->ItemStack;
		  
		      $ench_string = $daten->EnchString;
              $ench_int    = $daten->EnchInt;


              if(strcmp($ench_string,"0") == 0){
                 $Message = "<p>{#list_enchantments}</p>";
              }else{
     
                 $Enchantments = array();
                 $Levels       = array();
     	 
                 $Enchantments = explode(':::', $ench_string);
                 $Level      = explode(':::', $ench_int);

                 $Message = "";
           
                 $array_size = count($Enchantments);
                 $size       = $array_size -1;
       
                for($value = 0 ; $value < $array_size; $value ++)
                {

                    if($value == 0){
                      $Message .= '<p> '.$Enchantments[$value].' Lvl.:'.$Level[$value].' ';
                    }else{
                      $Message .= ''.$Enchantments[$value].' Lvl.: '.$Level[$value].' ';
                    }

						if(strcmp($value,$size) == 0){
							$Message .= '</p>';
						}
          


                }
              }               

			   
			   $liste .= '
			   
			      <div id="skal">
					   <div class="psdg-middle-left"><img src="'.$imageurl.'"></img> <br> '.$ItemName.'</div>
					   <div class="psdg-middle-center">'.$daten->ItemID.'</div>
					   <div class="psdg-middle-center">'.$daten->ItemStack.'</div>
					   <div class="psdg-middle-center">'.$daten->ItemPrice.'</div>
					   <div class="psdg-middle-center">'.$stockprice.'</div>
					   <div class="psdg-middle-center">'.$Message.'</div>
					   <div class="psdg-middle-center">'.$this->getAvatarImage($daten->User).' <br> '.$daten->User.'</div>
					   <div class="psdg-middle-center">'.$daten->AuktionsID.'</div>
			   
			   ';
		  
		 
			 if(strcmp($table,"postfach") == 0){   /* nav3 */
              $liste .='
                        
					   <div class="psdg-middle-center"><input type="checkbox" onchange="aktion();" name="nav3" value="'.$daten->AuktionsID.'"></div>
					   </div>        
               ';
			  }
			  
			  if(strcmp($table,"lagerhaus") == 0){ /* nav2 */
              $liste .='
                       
					   <div class="psdg-middle-center"><input type="checkbox" onchange="aktion();" name="nav2" value="'.$daten->AuktionsID.'"></div>
					   </div> 
					   
					                 
               ';
			  }
			  
			  if(strcmp($table,"auktion") == 0){ /* nav1*/
              $liste .='
                       
					   <div class="psdg-middle-center"><input type="checkbox" onchange="aktion();" name="nav1" value="'.$daten->AuktionsID.'"></div>
					   </div> 
					   					                 
               ';
			  }
		  
		  
		  
		  }
	  }
	
	  return $liste;
	}
	
	
	
	
	public function Liste($result,$table){
         
           $auktionsliste = "";
           while($daten = mysql_fetch_object($result)){

              $imageurl = $this->getImageItem($daten->ItemID,$daten->ItemBytes);
              $ItemName = $this->getImageName($daten->ItemID,$daten->ItemBytes);
              $stockprice = $daten->ItemPrice / $daten->ItemStack;
                
              $ench_string = $daten->EnchString;
              $ench_int    = $daten->EnchInt;


              if(strcmp($ench_string,"0") == 0){
                 $Message = "<p>{#list_enchantments}</p>";
              }else{
     
                 $Enchantments = array();
                 $Levels       = array();
     	 
                 $Enchantments = explode(':::', $ench_string);
                 $Level      = explode(':::', $ench_int);

                 $Message = "";
           
                 $array_size = count($Enchantments);
                 $size       = $array_size -1;
       
                for($value = 0 ; $value < $array_size; $value ++)
                {

                    if($value == 0){
                      $Message .= '<p> '.$Enchantments[$value].' Lvl.:'.$Level[$value].' ';
                    }else{
                      $Message .= ''.$Enchantments[$value].' Lvl.: '.$Level[$value].' ';
                    }

		    if(strcmp($value,$size) == 0){
                      $Message .= '</p>';
                    }
          


                }
              }               


              $user_avatar = '<img width="32px" src="http://minotar.net/avatar/'.$daten->User.'/100.png"/>';
     
              $auktionsliste .='
                       					   
					   <div id="skal">
					   <div class="psdg-middle-left"><img src="'.$imageurl.'"></img> <br> '.$ItemName.'</div>
					   <div class="psdg-middle-center">'.$daten->ItemID.'</div>
					   <div class="psdg-middle-center">'.$daten->ItemStack.'</div>
					   <div class="psdg-middle-center">'.$daten->ItemPrice.'</div>
					   <div class="psdg-middle-center">'.$stockprice.'</div>
					   <div class="psdg-middle-center">'.$Message.'</div>
					   <div class="psdg-middle-center">'.$user_avatar.' <br> '.$daten->User.'</div>
					   <div class="psdg-middle-center">'.$daten->AuktionsID.'</div>
					   <div class="psdg-middle-center">
					   
					     <input type="checkbox" onchange="aktion(this);" name="id" value="'.$daten->AuktionsID.'">
					   
					   </div>
					   </div> 
					                 
               ';
     
           }

        return $auktionsliste;
    }
	
		
	public function navigation($table,$navigation,$index = false,$navi = false)
	{      
	       $SQL = $this->getInstance()->getSQL();
           $liste = "";
           switch($navigation)
           {
                  case 1:
                       $sqlstring = $SQL->select($table);
           	           $result    = $SQL->query($sqlstring);
                       $liste     = $this->Liste($result,$table);                   
                  break;
                  case 2:
                       $liste  = $this->AuktionsListe($this->getSteinblöcke(),$table);
                  break;
				  case 3:
					   $liste  = $this->AuktionsListe($this->getHolzblöcke(),$table);
				  break;
				  case 4:
					   $liste  = $this->AuktionsListe($this->getErzblöcke(),$table);
				  break;
				  case 5:
                       $liste  = $this->AuktionsListe($this->getWolle(),$table);
                  break;
		          case 6:
					   $liste  = $this->AuktionsListe($this->getWaffen(),$table);
                  break;
                  case 7:
                       $liste  = $this->AuktionsListe($this->getRüstung(),$table);
                  break;
				  case 8:
					   $liste  = $this->AuktionsListe($this->getFood(),$table);
				  break;
		          case 9:
                       $liste  = $this->AuktionsListe($this->getTränke(),$table);
                  break;
				  case 10:
					   $liste  = $this->AuktionsListe($this->getSonstiges(),$table);
				  break;
                  
                  /* Suchen via ID 	or Name */
                  case 100:
                      $array = $this->byID($index);
                      $liste = $this->AuktionsListe($array,$table);
                  break;
                  case 101:
                      $array = $this->byName($index);
                      if($navi != false){
                                switch($navi){
								      
                                      case 6:
                                       $second_array = $this->getWaffen(); /* Weapons */
                                      break;
                                      case 7:
                                       $second_array = $this->getRüstung();
                                      break;	  
									  default:
									  $second_array = "all";
									  break;
                                }

                          $array = $this->sortieren($array,$second_array);
                      }
                      $liste = $this->AuktionsListe($array,$table);
                  break;
           }
		   
		   
	   return $liste;
    }
	
	
	

   
   
   
   



}



?>