<?
session_start();
require '../includes/init.php';
require '../includes/connect.php';


  $linkDB = new ConnectDatabase();
$sql="";
$nome ="";
$row ="";
$strTitolo ="No se ha encontrado ningún resultado.";

if (isset($_GET['post']) ) {

   
        $idArt = $_GET['post'];
        $idArt = mysqli_real_escape_string($linkDB, $idArt);
        //echo $idArt;
        $sql = 'select titolo,replace(replace(replace(corpo,"\r\n","<br>"),"\n\n","</p><br><br><strong>"),"\n","</strong><br><p>") as corpo,codice_categ  from articoli_'.$site_lang.' where id=?;';
  


      if($stmt = $linkDB->prepare($sql)){
      
          $stmt->bind_param("i", $idArt); // "is" means that $id is bound as an integer and $label as a string
          
          $stmt->execute();
          
          $stmt->bind_result($strTitolo, $strCorpo,$codice_categ);
      
        while ($stmt->fetch()) {
        $strTitolo=$strTitolo;
        $strCorpo=$strCorpo;
        $codice_categ=$codice_categ;
        }
    
          $stmt->close();
     
      }else{

        http_response_code(404);

      }
}else{

  header("Location: blog");

}

function setFlashMessage($message, $type = 'Servinfo')
{

    $_SESSION['flash_message'] = [
        'message' => $message,
        'type' => $type
    ];
}
// Displaying flash messages

//setFlashMessage("Accesso Riuscito;");


?>
<!DOCTYPE html>
<html lang="<?echo $site_lang;?>">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title> <?echo $strTitolo;?> | LaBakeca.eu</title>
  <meta content="" name="description">
  <meta content="" name="keywords">

    <?require '../includes/inc_head.php';?>
<style type="text/css">
  p.blur-text{
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
  }
p.fade-out {
   position: relative;
}
p.fade-out:after {
   content: "";
   height: 50%;
   width: 100%;
   position: absolute;
   bottom: 0;
   left: 0;
   background: linear-gradient(to bottom, rgba(255,255,255,0), #fff);
}
#paywall-wrapper {
   padding: 35px;
   border-radius: 5px;
   position: relative;
   margin-bottom: 30px;
   box-shadow: 0px 0px 20px -1px rgba(0,0,0,0.20);
}
   #paywall-wrapper * {
      text-align: center;
   }
      #paywall-wrapper .btn {
         left: 50%;
         transform: translateX(-50%);
         position: relative;
      }

.header.sticked {
  background-color: transparent;
}
      #progress-bar-wrapper {

   width: 100%;
   height: 80px;
   background-color: transparent;
   position: fixed;
   top: 0;
   z-index: 1;
}
   #progress-bar {
      height: 100%;
      background-color: var(--color-tertiary-light);
      width: 0;
}

#content-area {
   position: relative;
   width: 100%;
   max-width: 1200px;
   margin: 0 auto;
   padding: 30px 30px 0px 30px;
   border: 1px solid #ccc;
   margin-top: 100px;
   margin-bottom: 50px
}
</style>

               

</head>

<body>

  <!-- ======= Header ======= -->
  <?require'../includes/inc_topbar.php'?>
  <main id="main">
    <!-- ======= Breadcrumbs ======= -->
    <div class="breadcrumbs">
      <div class="container">

        <div class="d-flex justify-content-between align-items-center">
          <h2>Blog Details</h2>
          <ol>
            <li><a href="index">Home</a></li>
            <li><a href="blog">Blog</a></li>
            <li><?echo $strTitolo;?></li>
          </ol>
        </div>

      </div>
    </div><!-- End Breadcrumbs -->

    <!-- ======= Blog Details Section ======= -->
    <section id="blog" class="blog">
  <div id="progress-bar-wrapper">
    <div id="progress-bar"></div>
  </div>
      <div class="container" data-aos="fade-up">
<?
if (isset($_SESSION['flash_message'])) {
    echo '<div class="' . $_SESSION['flash_message']['type'] . '">' . $_SESSION['flash_message']['message'] . '</div>';
    unset($_SESSION['flash_message']);
}
?>
        <div class="row g-5">

          <div class="col-lg-8">

            <article class="blog-details" id="content-area">

              <div class="post-img">
                <img src="/assets/img/compressed/<?echo $idArt;?>.png" alt="" class="img-fluid">
              </div>

              <h2 class="title"><?echo $strTitolo;?></h2>

              <div class="meta-top">
                <ul>
                  <li class="d-flex align-items-center"><i class="bi bi-person"></i> <a href="blog-details">John Doe</a></li>
                  <li class="d-flex align-items-center"><i class="bi bi-clock"></i> <a href="blog-details"><time datetime="2020-01-01">Jan 1, 2022</time></a></li>
                </ul>
              </div><!-- End meta top -->

              <div class="content">
   
                <?
                if(isset($_SESSION['ospite']) and !empty($_SESSION['ospite'])){
                  echo '<p>';
                    echo $strCorpo;
                  echo '</p>';
                }else{
                  echo '<p class="fade-out" style="margin-bottom:1rem;">';
                    echo substr($strCorpo,0,777);

                  echo '</p>';
                  echo '<div id="paywall-wrapper">';
                    echo '<h4>Obtain access to this article</h4>
   <p>Register for <strong>free</strong> and join the community now!</p>
   <a class="btn" href="/signup/signup/index">Register <em>free</em> in a matter of seconds!</a>';
                  echo '</div>';

                }
                ?>

                <?if(1==2){?>
                <p>
                  Sit repellat hic cupiditate hic ut nemo. Quis nihil sunt non reiciendis. Sequi in accusamus harum vel aspernatur. Excepturi numquam nihil cumque odio. Et voluptate cupiditate.
                </p>

                <blockquote>
                  <p>
                    Et vero doloremque tempore voluptatem ratione vel aut. Deleniti sunt animi aut. Aut eos aliquam doloribus minus autem quos.
                  </p>
                </blockquote>

                <p>
                  Sed quo laboriosam qui architecto. Occaecati repellendus omnis dicta inventore tempore provident voluptas mollitia aliquid. Id repellendus quia. Asperiores nihil magni dicta est suscipit perspiciatis. Voluptate ex rerum assumenda dolores nihil quaerat.
                  Dolor porro tempora et quibusdam voluptas. Beatae aut at ad qui tempore corrupti velit quisquam rerum. Omnis dolorum exercitationem harum qui qui blanditiis neque.
                  Iusto autem itaque. Repudiandae hic quae aspernatur ea neque qui. Architecto voluptatem magni. Vel magnam quod et tempora deleniti error rerum nihil tempora.
                </p>

                <h3>Et quae iure vel ut odit alias.</h3>
                <p>
                  Officiis animi maxime nulla quo et harum eum quis a. Sit hic in qui quos fugit ut rerum atque. Optio provident dolores atque voluptatem rem excepturi molestiae qui. Voluptatem laborum omnis ullam quibusdam perspiciatis nulla nostrum. Voluptatum est libero eum nesciunt aliquid qui.
                  Quia et suscipit non sequi. Maxime sed odit. Beatae nesciunt nesciunt accusamus quia aut ratione aspernatur dolor. Sint harum eveniet dicta exercitationem minima. Exercitationem omnis asperiores natus aperiam dolor consequatur id ex sed. Quibusdam rerum dolores sint consequatur quidem ea.
                  Beatae minima sunt libero soluta sapiente in rem assumenda. Et qui odit voluptatem. Cum quibusdam voluptatem voluptatem accusamus mollitia aut atque aut.
                </p>
                <img src="/assets/img/compressed/blog-inside-post.jpg" class="img-fluid" alt="">

                <h3>Ut repellat blanditiis est dolore sunt dolorum quae.</h3>
                <p>
                  Rerum ea est assumenda pariatur quasi et quam. Facilis nam porro amet nostrum. In assumenda quia quae a id praesentium. Quos deleniti libero sed occaecati aut porro autem. Consectetur sed excepturi sint non placeat quia repellat incidunt labore. Autem facilis hic dolorum dolores vel.
                  Consectetur quasi id et optio praesentium aut asperiores eaque aut. Explicabo omnis quibusdam esse. Ex libero illum iusto totam et ut aut blanditiis. Veritatis numquam ut illum ut a quam vitae.
                </p>
                <p>
                  Alias quia non aliquid. Eos et ea velit. Voluptatem maxime enim omnis ipsa voluptas incidunt. Nulla sit eaque mollitia nisi asperiores est veniam.
                </p>
              <?}?>
              </div><!-- End post content -->

              <div class="meta-bottom">
                <i class="bi bi-folder"></i>
                <ul class="cats">
                  <li><a href="#">Business</a></li>
                </ul>

                <i class="bi bi-tags"></i>
                <ul class="tags">
                  <li><a href="#">Creative</a></li>
                  <li><a href="#">Tips</a></li>
                  <li><a href="#">Marketing</a></li>
                </ul>
              </div><!-- End meta bottom -->

            </article><!-- End blog post -->
          <?if(1==2){?>

            <div class="post-author d-flex align-items-center">
              <img src="/assets/img/compressed/blog-author.jpg" class="rounded-circle flex-shrink-0" alt="">
              <div>
                <h4>Jane Smith</h4>
                <div class="social-links">
                  <a href="https://twitters.com/#"><i class="bi bi-twitter"></i></a>
                  <a href="https://facebook.com/#"><i class="bi bi-facebook"></i></a>
                  <a href="https://instagram.com/#"><i class="biu bi-instagram"></i></a>
                </div>
                <p>
                  Itaque quidem optio quia voluptatibus dolorem dolor. Modi eum sed possimus accusantium. Quas repellat voluptatem officia numquam sint aspernatur voluptas. Esse et accusantium ut unde voluptas.
                </p>
              </div>
            </div><!-- End post author -->

            <div class="comments">

              <h4 class="comments-count">8 Comments</h4>

              <div id="comment-1" class="comment">
                <div class="d-flex">
                  <div class="comment-img"><img src="/assets/img/compressed/comments-1.jpg" alt=""></div>
                  <div>
                    <h5><a href="">Georgia Reader</a> <a href="#" class="reply"><i class="bi bi-reply-fill"></i> Reply</a></h5>
                    <time datetime="2020-01-01">01 Jan,2022</time>
                    <p>
                      Et rerum totam nisi. Molestiae vel quam dolorum vel voluptatem et et. Est ad aut sapiente quis molestiae est qui cum soluta.
                      Vero aut rerum vel. Rerum quos laboriosam placeat ex qui. Sint qui facilis et.
                    </p>
                  </div>
                </div>
              </div><!-- End comment #1 -->

              <div id="comment-2" class="comment">
                <div class="d-flex">
                  <div class="comment-img"><img src="/assets/img/compressed/comments-2.jpg" alt=""></div>
                  <div>
                    <h5><a href="">Aron Alvarado</a> <a href="#" class="reply"><i class="bi bi-reply-fill"></i> Reply</a></h5>
                    <time datetime="2020-01-01">01 Jan,2022</time>
                    <p>
                      Ipsam tempora sequi voluptatem quis sapiente non. Autem itaque eveniet saepe. Officiis illo ut beatae.
                    </p>
                  </div>
                </div>

                <div id="comment-reply-1" class="comment comment-reply">
                  <div class="d-flex">
                    <div class="comment-img"><img src="/assets/img/compressed/comments-3.jpg" alt=""></div>
                    <div>
                      <h5><a href="">Lynda Small</a> <a href="#" class="reply"><i class="bi bi-reply-fill"></i> Reply</a></h5>
                      <time datetime="2020-01-01">01 Jan,2022</time>
                      <p>
                        Enim ipsa eum fugiat fuga repellat. Commodi quo quo dicta. Est ullam aspernatur ut vitae quia mollitia id non. Qui ad quas nostrum rerum sed necessitatibus aut est. Eum officiis sed repellat maxime vero nisi natus. Amet nesciunt nesciunt qui illum omnis est et dolor recusandae.

                        Recusandae sit ad aut impedit et. Ipsa labore dolor impedit et natus in porro aut. Magnam qui cum. Illo similique occaecati nihil modi eligendi. Pariatur distinctio labore omnis incidunt et illum. Expedita et dignissimos distinctio laborum minima fugiat.

                        Libero corporis qui. Nam illo odio beatae enim ducimus. Harum reiciendis error dolorum non autem quisquam vero rerum neque.
                      </p>
                    </div>
                  </div>

                  <div id="comment-reply-2" class="comment comment-reply">
                    <div class="d-flex">
                      <div class="comment-img"><img src="/assets/img/compressed/comments-4.jpg" alt=""></div>
                      <div>
                        <h5><a href="">Sianna Ramsay</a> <a href="#" class="reply"><i class="bi bi-reply-fill"></i> Reply</a></h5>
                        <time datetime="2020-01-01">01 Jan,2022</time>
                        <p>
                          Et dignissimos impedit nulla et quo distinctio ex nemo. Omnis quia dolores cupiditate et. Ut unde qui eligendi sapiente omnis ullam. Placeat porro est commodi est officiis voluptas repellat quisquam possimus. Perferendis id consectetur necessitatibus.
                        </p>
                      </div>
                    </div>

                  </div><!-- End comment reply #2-->

                </div><!-- End comment reply #1-->

              </div><!-- End comment #2-->

              <div id="comment-3" class="comment">
                <div class="d-flex">
                  <div class="comment-img"><img src="/assets/img/compressed/comments-5.jpg" alt=""></div>
                  <div>
                    <h5><a href="">Nolan Davidson</a> <a href="#" class="reply"><i class="bi bi-reply-fill"></i> Reply</a></h5>
                    <time datetime="2020-01-01">01 Jan,2022</time>
                    <p>
                      Distinctio nesciunt rerum reprehenderit sed. Iste omnis eius repellendus quia nihil ut accusantium tempore. Nesciunt expedita id dolor exercitationem aspernatur aut quam ut. Voluptatem est accusamus iste at.
                      Non aut et et esse qui sit modi neque. Exercitationem et eos aspernatur. Ea est consequuntur officia beatae ea aut eos soluta. Non qui dolorum voluptatibus et optio veniam. Quam officia sit nostrum dolorem.
                    </p>
                  </div>
                </div>

              </div><!-- End comment #3 -->

              <div id="comment-4" class="comment">
                <div class="d-flex">
                  <div class="comment-img"><img src="/assets/img/compressed/comments-6.jpg" alt=""></div>
                  <div>
                    <h5><a href="">Kay Duggan</a> <a href="#" class="reply"><i class="bi bi-reply-fill"></i> Reply</a></h5>
                    <time datetime="2020-01-01">01 Jan,2022</time>
                    <p>
                      Dolorem atque aut. Omnis doloremque blanditiis quia eum porro quis ut velit tempore. Cumque sed quia ut maxime. Est ad aut cum. Ut exercitationem non in fugiat.
                    </p>
                  </div>
                </div>

              </div><!-- End comment #4 -->

              <div class="reply-form">

                <h4>Leave a Reply</h4>
                <p>Your email address will not be published. Required fields are marked * </p>
                <form action="">
                  <div class="row">
                    <div class="col-md-6 form-group">
                      <input name="name" type="text" class="form-control" placeholder="Your Name*">
                    </div>
                    <div class="col-md-6 form-group">
                      <input name="email" type="text" class="form-control" placeholder="Your Email*">
                    </div>
                  </div>
                  <div class="row">
                    <div class="col form-group">
                      <input name="website" type="text" class="form-control" placeholder="Your Website">
                    </div>
                  </div>
                  <div class="row">
                    <div class="col form-group">
                      <textarea name="comment" class="form-control" placeholder="Your Comment*"></textarea>
                    </div>
                  </div>
                  <button type="submit" class="btn btn-primary">Post Comment</button>

                </form>

              </div>
            </div><!-- End blog comments -->
          <?}?>
          </div>

          <div class="col-lg-4">

            <div class="sidebar">

              <div class="sidebar-item search-form">
                <h3 class="sidebar-title">Search</h3>
                <form action="" class="mt-3">
                  <input type="text">
                  <button type="submit"><i class="bi bi-search"></i></button>
                </form>
              </div><!-- End sidebar search formn-->

              <div class="sidebar-item categories">
                <?$sql = "select id,codice as cod_cat ,ucase(categ_".$site_lang.") as txt_catUPPER,categ_".$site_lang." as txt_cat,qta from codice_articoli  order by rand() limit 6;";

#echo $sql;
if ($stmt = $linkDB->query($sql)) {

  unset($vettcat);
  unset($vettcatTitle);
  unset($vettidcat);
  unset($vettqta);
  unset($vettcod);
  while ($row = mysqli_fetch_array($stmt)) {
    $vettcat[$iCat] = $row['txt_cat'];
    $vettcatTitle[$iCat] = $row['txt_catUPPER'];
    $vettidcat[$iCat] = $row['id'];
    $vettqta[$iCat] = $row['qta'];
    $vettcod[$iCat] = $row['cod_cat'];

    $iCat++;
  }

  mysqli_free_result($stmt);

}?>
                <h3 class="sidebar-title"> <?if ($site_lang == "en") {?>
                                    Categories:
                                    <?} elseif ($site_lang == "es") {?>
                                    Categorías:
                                    <?} else {?>
                                    Categorie:
                                    <?}?></h3>
                <ul class="mt-3">
          <?
  for ($i = 1; $i < $iCat; $i++) {
    echo "<li><a href='/" . $site_lang . "/blog/" . $vettcod[$i] . "'>" . $vettcat[$i] . "<span>(" . $vettqta[$i] . ")</span></a></li>";

  }
  ?>
                </ul>
              </div><!-- End sidebar categories-->

              <div class="sidebar-item recent-posts">
                <h3 class="sidebar-title">Recent Posts</h3>

                <div class="mt-3">

<?

$sql = "select id,SUBSTRING_INDEX(titolo, ':', 1) as titolo from articoli_".$site_lang." where codice_categ=$codice_categ order by rand() limit 4;";
$iArt=0;
#echo $sql;
if ($stmt = $linkDB->query($sql)) {

  unset($vettDd);
  unset($vettTitolo);

  while ($row = mysqli_fetch_array($stmt)) {
    $vettId[$iArt] = $row['id'];
    $vettTitolo[$iArt] = $row['titolo'];
    $iArt++;
  }

  mysqli_free_result($stmt);



  for ($i = 0; $i < $iArt; $i++) {
                 echo '<div class="post-item mt-3">
                    <img src="/assets/img/compressed/'.$vettId[$i].'.png" alt="" class="flex-shrink-0">
                    <div>
                      <h4><a href="blog-details?post='.$vettId[$i].'">'.$vettTitolo[$i].'</a></h4>
                      <time datetime="2024-05-'.rand(1,31).'">May '.rand(1,31).', 2024</time>
                    </div>
                  </div><!-- End recent post item-->';
  }
}
  ?>

                </div>

              </div><!-- End sidebar recent posts-->

              <div class="sidebar-item tags">
                <h3 class="sidebar-title">Tags</h3>
                <ul class="mt-3">
                  <li><a href="#">App</a></li>
                  <li><a href="#">IT</a></li>
                  <li><a href="#">Business</a></li>
                  <li><a href="#">Mac</a></li>
                  <li><a href="#">Design</a></li>
                  <li><a href="#">Office</a></li>
                  <li><a href="#">Creative</a></li>
                  <li><a href="#">Studio</a></li>
                  <li><a href="#">Smart</a></li>
                  <li><a href="#">Tips</a></li>
                  <li><a href="#">Marketing</a></li>
                </ul>
              </div><!-- End sidebar tags-->

            </div><!-- End Blog Sidebar -->

          </div>
        </div>

      </div>
    </section><!-- End Blog Details Section -->

  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
    <footer id="footer" class="footer">
        <?require '../includes/inc_footer_'.$site_lang.'.php';?>
        <?require '../includes/inc_footer_copyright.php';?>
    </footer><!-- End Footer -->
    <a href="#" class="scroll-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
    <div id="preloader"></div>
    <!-- Vendor JS Files -->
    <? require '../includes/inc_script.php'?>

<script type="text/javascript">
  
  const progressBar = document.getElementById("progress-bar");
const contentArea = document.getElementById("content-area");

function updateProgressBar() {  
   const contentAreaHeight = contentArea.offsetHeight - window.innerHeight + 100;
   const scrolled = window.scrollY;   
   const scrollPercentage = (scrolled / contentAreaHeight) * 100;   
   progressBar.style.width = scrollPercentage + "%";
}

window.addEventListener("scroll", updateProgressBar);
window.addEventListener("resize", updateProgressBar);
</script>
</body>


</html>