<?php require_once 'protect.php'; ?>
<div class="menustyle<?php echo $menunr ?> bordercolor1">
<div class="divmenustyle divmenu<?php echo $menunr ?> bordercolor1">
<?php echo $$menutext1 ?>
<?php
$result80 = $mysqli->query("SELECT insert_id, page, name, type FROM categories WHERE promote LIKE '%$menupromote%' AND lang_id=$lang ORDER BY priority, level");
while($row = $result80->fetch_array()) {
$menucatid=$row['insert_id'];
$menupage=$row['page'];
$menucategory=$row['name'];
$mtypec=$row['type'];

$result81 = $mysqli->query("SELECT id FROM categories WHERE parent=$menucatid AND lang_id=$lang AND publish='yes'");
$nrowscat = mysqli_num_rows($result81);

$result82 = $mysqli->query("SELECT id FROM items WHERE category_id=$menucatid AND lang_id=$lang AND publish='yes'");
$nrows = mysqli_num_rows($result82);
?>
<div class="boxmenu">
<div class="titlesmenu"><?php if ($nrows>0) {?><a href="<?php echo $menupage ?>"><?php echo $menucategory ?></a><?php } else { ?><?php echo $menucategory ?><?php } ?></div>
<?php if ($nrowscat>0) {?>
<?php
$result83 = $mysqli->query("SELECT page, name FROM categories WHERE parent=$menucatid AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result83->fetch_array()) {	
$menupage2=$row['page'];
$menucategory2=$row['name'];
?>
<div class="titlesmenu2"><a href="<?php echo $menupage2 ?>"><?php echo $menucategory2 ?></a></div>
<?php } ?>
<?php } ?>
<?php
$result84 = $mysqli->query("SELECT * FROM items WHERE category_id=$menucatid AND promote LIKE '%$menupromote%' AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result84->fetch_array()) {	
$iid=$row['insert_id'];
$pageid=$row['page_id'];
$pageitem=$row['page'];
if ($itempage==1) { $siteitem=$pageitem; }
$pagesiteitem=$siteitem.".".$pageid;
if ($mtypec==1) { $pagesiteitem=$menupage; }
$nname=$row['name'];
$ntext1=$row['details'];
$ntext = mb_substr(strip_tags($ntext1), 0, 90, 'UTF-8');
if (strlen($ntext1)>90) {
$ntext = substr($ntext, 0, strrpos($ntext, ' '));
}
$nurl=$row['url'];
$nimage=$row['image'];
$navailable=$row['available'];
$nshowpage=$row['showpage'];
?>
<div class="boxmenuitem">
<?php if ($nimage==1) { ?>
<a <?php if ($nurl AND $nshowpage==0) { ?>href="<?php echo $nurl ?>" target="_blank"<?php }else if ($nshowpage==1){ ?>href="<?php echo $pagesiteitem ?>"<?php } ?>><img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>items/<?php echo $iid ?>.jpg&amp;nwidth=200" class="img-menu" alt="<?php echo $nname ?>" title="<?php echo $nname ?>"></a>
<?php } ?>
<div class="mspace"><a <?php if ($nurl AND $nshowpage==0) { ?>href="<?php echo $nurl ?>" target="_blank"<?php }else if ($nshowpage==1){ ?>href="<?php echo $pagesiteitem ?>"<?php } ?> class="linksmenu"><?php echo $nname ?></a></div>
<div><?php echo $ntext ?> <?php if (strlen($ntext1)>90) { ?>...<?php } ?></div>
<?php if ($nshowpage==1) { ?><div class="mboxcart"><a href="<?php echo $pagesiteitem ?>" class="button button1"><?php echo $textmore ?></a></div><?php } ?>
<?php if ($reviewsitem==1) { 
$resultrev = $mysqli->query("SELECT id FROM members WHERE item_id=$iid AND publish='yes'");
$nrrowsrev = mysqli_num_rows($resultrev);
?><div class="floatright margtop10 color2"><?php if ($nrrowsrev>0) { ?>
<span class="icon fa-comments-o"></span> <?php echo $nrrowsrev ?>
<?php } ?></div><?php } ?>
<div class="cleared"></div>
</div>
<?php } ?>
</div>
<?php } ?>
<?php echo $$menutext2 ?>
<?php
$result85 = $mysqli->query("SELECT * FROM items WHERE category_id NOT IN (SELECT insert_id FROM categories WHERE promote LIKE '%$menupromote%' AND lang_id=$lang) AND promote LIKE '%$menupromote%' AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result85->fetch_array()) {	
$iid=$row['insert_id'];
$categoryid=$row['category_id'];
$pageid=$row['page_id'];
$pageitem=$row['page'];
if ($itempage==1) { $siteitem=$pageitem; }
$pagesiteitem=$siteitem.".".$pageid;
if ($mtypec==1) { $pagesiteitem=$menupage; }
$nname=$row['name'];
$ntext1=$row['details'];
$ntext = mb_substr(strip_tags($ntext1), 0, 90, 'UTF-8');
if (strlen($ntext1)>90) {
$ntext = substr($ntext, 0, strrpos($ntext, ' '));
}
$nurl=$row['url'];
$nimage=$row['image'];
$navailable=$row['available'];
$nshowpage=$row['showpage'];

$result86 = $mysqli->query("SELECT type FROM categories WHERE insert_id=$categoryid AND lang_id=$lang");
$row = $result86->fetch_array();
$mtypec=$row['type'];
?>
<div class="boxmenuitem">
<?php if ($nimage==1) { ?>
<a <?php if ($nurl AND $nshowpage==0) { ?>href="<?php echo $nurl ?>" target="_blank"<?php }else{ ?>href="<?php echo $pagesiteitem ?>"<?php } ?>><img src="<?php echo $codepath ?>includes/image.php?image=<?php echo $imagepath ?>items/<?php echo $iid ?>.jpg&amp;nwidth=200" class="img-menu" alt="<?php echo $nname ?>" title="<?php echo $nname ?>"></a>
<?php } ?>
<div class="mspace"><a <?php if ($nurl AND $nshowpage==0) { ?>href="<?php echo $nurl ?>" target="_blank"<?php }else{ ?>href="<?php echo $pagesiteitem ?>"<?php } ?> class="linksmenu"><?php echo $nname ?></a></div>
<div><?php echo $ntext ?> <?php if (strlen($ntext1)>90) { ?>...<?php } ?></div>
<?php if ($nshowpage==1) { ?><div class="mboxcart"><a href="<?php echo $pagesiteitem ?>" class="button button1"><?php echo $textmore ?></a></div><?php } ?>
<?php if ($reviewsitem==1) { 
$resultrev = $mysqli->query("SELECT id FROM members WHERE item_id=$iid AND publish='yes'");
$nrrowsrev = mysqli_num_rows($resultrev);
?><div class="floatright margtop10 color2"><?php if ($nrrowsrev>0) { ?>
<span class="icon fa-comments-o"></span> <?php echo $nrrowsrev ?>
<?php } ?></div><?php } ?>
<div class="cleared"></div>
</div>
<?php } ?>
<?php echo $$menutext3 ?>
</div>
</div>
