<?php ini_set( "expose_php", "off") ?>
<?php $menu_group = "annoncer"; ?>
<?php include("mysqli_read.inc.php"); ?>
<?php session_start(); ?>
<?php
        $sql = "SELECT *  FROM ((((article LEFT JOIN category ON article.category_id=id_category) LEFT JOIN type ON type_id = id_type) LEFT JOIN stand ON stand_id = id_stand) LEFT JOIN users ON user_id = uid) LEFT JOIN zipcodes ON zip = id_zip WHERE aid = '".$mysql_read->real_escape_string($_GET['article'])."'";
        $res = $mysql_read->query($sql);
        $row4 = $res->fetch_assoc();

        if ($row4['article_type'] == 's')
                $type = "Salgsannonce";
        else
                $type = "Købsannonce";

        if ($row4['variant'] == "")
                $variant = "Ikke angivet";
        else
                $variant = $row4['variant'];

        if ($row4['year_c'] == 0)
                $year = "Ikke angivet";
        else
                $year = $row4['year_c'];

        if ($row4['type_id'] == null)
                $ctype = "Ikke angivet";
        else if ($row4['type_id'] == 0)
                $ctype = "Anden";
        else
                $ctype = $row4['type'];

        if ($row4['price'] == 0)
                $price = "Ikke angivet";
        else
                $price = $row4['price']." kr.";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="da">
<head>
<link href='/style.css' rel='stylesheet' type='text/css'/>
<?php include("meta.inc"); ?>
<meta name="description" content="<?php echo $row4['articletext']; ?>"/>
<meta property="og:description" content="<?php echo $row4['articletext']; ?>" />
<meta property="og:title" content=<?php echo $row4['headline']; ?>" />
<meta property="og:image" content="https://veteranstumper.dk/pictures/<?php echo $row4['aid']; ?>a.jpg" />
<meta property="og:image:secure_url" content="https://veteranstumper.dk/pictures/<?php echo $row4['aid']; ?>a.jpg" />
<meta name="twitter:card" content="<?php echo $row4['articletext']; ?>" />
<meta name="twitter:description" content="<?php echo $row4['articletext']; ?>" />
<meta name="twitter:title" content="<?php echo $row4['headline']; ?>" />
<meta name="twitter:image" content="https://veteranstumper.dk/pictures/<?php echo $row4['aid']; ?>a.jpg" />
<title><?php echo $row4['headline']; ?></title>
<script type="text/javascript" src="/js/main.js"></script>
</head>
<body>
<?php include("top.inc.php"); ?>
<h1>annonce</h1>

<div id="maincontent-container">
<h2>generel information	</h2>

<?php if ($row4['deleted'] != 'n') { ?>
<div class="headcontainer">
 <div class="deletedmessage">***VÆR OPMÆRKSOM***<br/>Denne annonce er SLETTET og er ikke længere aktiv.<br/>Men fortvivl ikke, vi mange andre annoncer. <br/>Du kan blot klikke <a class="deletedmessagelink" href="/annoncer/alle/p0.html">her</a> for at se de seneste annoncer.</div>
</div>
<?php } ?>
 
 <div class="headcontainer">
  <div class="articlehead">overskrift:</div>
  <div class="nofloat2"><?php echo $row4['headline']; ?></div>
 </div>

  <div class="headcontainer">&nbsp;</div>

  <div class="headcontainer">
  <div class="articlehead">annonce type:</div>
  <div class="nofloat"><?php echo $type ?></div>
  </div>

  <div class="headcontainer">
  <div class="articlehead">kategori:</div>
  <div class="nofloat"><?php echo $row4['category']; ?></div>
  </div>
  
  <?php if ($row4['cat_type'] == 'r')
  	echo "<h2>til model</h2>";
  else
  	echo "<h2>model</h2>"; ?>
  
  <div class="headcontainer">
  <div class="articlehead">mærke:</div>
  <div class="nofloat"><?php echo $ctype ?></div>
  </div>
  
  <div class="headcontainer">
  <div class="articlehead">variant:</div>
  <div class="nofloat"><?php echo $variant ?></div>
  </div>
  
  <div class="headcontainer">
  <div class="articlehead">årstal:</div>
  <div class="nofloat"><?php echo $year ?></div>
  </div>
  
  <h2>annonce tekst</h2>
  <p class="maincontent"><?php echo $row4['articletext']; ?></p>
  
  <h2>øvrig information</h2>
  
  <div class="headcontainer">
  <div class="articlehead">stand:</div>
  <div class="nofloat"><?php echo $row4['stand']; ?></div>
  </div>
  
  <div class="headcontainer">
  <div class="articlehead">pris:</div>
  <div class="nofloat"><?php echo $price ?></div>
  </div>
  
  <h2>billeder</h2>
  <?php 
  $billeder = 0;
  
  $sql = "SELECT id FROM images where sub_id = 'a' and id = ".$_GET['article'];
  $res2 = $mysql_read->query($sql);
  $row42 = $res2->fetch_assoc();

  if ($row42) {
  	echo "<div class='showpicturefield'><img alt=\"billede 1\" src=\"/pictures/".$row4['aid']."a.jpg\"/></div>";
  	$billeder++;
  }

  $sql = "SELECT id FROM images where sub_id = 'b' and id = ".$_GET['article'];
  $res2 = $mysql_read->query($sql);
  $row42 = $res2->fetch_assoc();
	
  if ($row42) {
  	echo "<br/><br/><div class='showpicturefield'><img alt=\"billede 2\" src=\"/pictures/".$row4['aid']."b.jpg\"/></div>";
    $billeder++;
  }

  $sql = "SELECT id FROM images where sub_id = 'c' and id = ".$_GET['article'];
  $res2 = $mysql_read->query($sql);
  $row42 = $res2->fetch_assoc();
	
  if ($row42) {
  	echo "<br/><br/><div class='showpicturefield'><img alt=\"billede 3\" src=\"/pictures/".$row4['aid']."c.jpg\"/></div>";
  	$billeder++;
  }

	if ($billeder == 0) {
		echo "<p class='maincontent'>Der er ikke tilknyttet nogle billeder til denne annonce.</p>";
		echo "<br/>";
	}
?>
  
<h2>kontakt</h2>
<?php
if ($row4['deleted'] != 'n') { ?>
<div class="headcontainer">
 <div class="deletedmessage">***VÆR OPMÆRKSOM***<br/>Denne annonce er SLETTET og er ikke længere aktiv.<br/>Men fortvivl ikke, vi mange andre annoncer. <br/>Du kan blot klikke <a class="deletedmessagelink" href="/annoncer/alle/p0.html">her</a> for at se de seneste annoncer.</div>
</div>
<?php }

/*
else if (!$_SESSION['loggedin']) {
	echo "<div class=\"headcontainer\"><p class=\"maincontent\">Du skal være oprettet som bruger og være logget ind for at se kontakt informationer. Hvis du ikke er oprettet som bruger kan du i løbet af få minutter blive oprettet. Dette er gratis!</p></div>";
}*/

else { ?>

<?php
$pos = strpos($row4['contact_type'], "n");
if ($pos !== false) { ?>
  <div class="headcontainer">
  <div class="articlehead">navn:</div>
  <div class="nofloat"><?php echo $row4['firstname']." ".$row4['lastname']; ?></div>
  </div>
<?php }

$pos = strpos($row4['contact_type'], "s");
if ($pos !== false) { ?>
  <div class="headcontainer">
  <div class="articlehead">adresse:</div>
  <div class="nofloat"><?php echo $row4['address']; ?></div>
  </div>

  <div class="headcontainer">
  <div class="articlehead">postnummer:</div>
  <div class="nofloat"><?php echo $row4['zip']; ?></div>
  </div>
<?php }

$pos = strpos($row4['contact_type'], "c");
if ($pos !== false) { ?>
  <div class="headcontainer">
  <div class="articlehead">by:</div>
  <div class="nofloat"><?php echo $row4['city']; ?></div>
  </div>
<?php }

$pos = strpos($row4['contact_type'], "p");
if ($pos !== false) { ?>
  <div class="headcontainer">
  <div class="articlehead">telefonnummer:</div>
  <div class="nofloat"><?php echo $row4['phone']; ?></div>
  </div>
<?php }

$pos = strpos($row4['contact_type'], "a");
if ($pos !== false) { ?>
  <div class="headcontainer">
  <div class="articlehead">telefonnummer 2:</div>
  <div class="nofloat"><?php echo $row4['phone2']; ?></div>
  </div>
<?php }

$pos = strpos($row4['contact_type'], "e");
if ($pos !== false) { ?>
  <div class="headcontainer">
  <div class="articlehead">email:</div>
  <div class="nofloat"><?php echo $row4['email']; ?></div>
  </div>
<?php }

}
mysqli_close($mysql_read);
?>


<?php include("bottom.inc.php"); ?>
