<?php

require_once("/home/www/wwwbuzzerstar/p/bilder/libraryConfig.inc.php"); 
require_once("/home/www/wwwbuzzerstar/p/bilder/libraryConnection.inc.php"); 
require_once("/home/www/wwwbuzzerstar/p/bilder/libraryFunctions.inc.php");
require_once("/home/www/wwwbuzzerstar/p/bilder/librarySSDTube.php"); 
require_once("/home/www/wwwbuzzerstar/p/bilder/librarymobile/Mobile_Detect.php");
require_once("/home/www/wwwbuzzerstar/p/bilder/libraryTexts.inc.php");
require_once("/home/www/wwwbuzzerstar/p/bilder/libraryIP.inc.php");

class HTML {
	
	public function DetailpageGenerateContent($shortcode){
		
		$ReturnHtmlString	= "";
		$sliderHTMLContent	= "";
		$sentences_content	= "";
				
		$func	 			= new Functions();
		$conn 				= new Connection();
		$config 			= new Config();
		$SSDTube 			= new SSDTube();
		$ip					= new IP();
		
		$linkingcode_twittr	= "https://www.buzzerstar.com/p/fun/show.php?a=$shortcode";
		$linkingcode		= "https://www.buzzerstar.com/p/fun/".$func->makeArticleLink($shortcode);
		$imageRetArray 		= $func->getScreenResolutionFromUA();
		$x 					= $imageRetArray["xImage"];
		$y 					= $imageRetArray["yImage"];
		$fontsize 			= $imageRetArray["fontsize"];
		$picQuality 		= $imageRetArray["picQuality"];
		$isGoogleBot		= $ip->isValidGoogleCrawler();
		
		$table 				= $config->sql_tablename_publish_de();
		$table_img			= $config->sql_tablename_pictures();
		$shortcode_passkey 	= $config->shortcode_passkey();
		$pdo				= $conn->prepareQuery();
		$picpath			= $config->picture_storepath();

		$stmt 				= $pdo->prepare("SELECT * FROM $table WHERE p_shortcode=:shortcode LIMIT 1");
		$stmt->bindValue(':shortcode', $shortcode, PDO::PARAM_STR);
		$stmt->execute();
		$rows 				= $stmt->fetchAll(PDO::FETCH_ASSOC);
			
		// video:
		$video_youtube_uri 	= $rows[0]["p_videolink"];
		$SSDTube->identify($video_youtube_uri);
		$EmbeddedVideo 		= $SSDTube->embed;
		$tumbnailVideoImg	= $SSDTube->thumbnail;
		$VideoAuthor		= $SSDTube->author;
		$video_duration		= $func->getDuration();
		$video_title		= $SSDTube->title;
		$video_description	= $SSDTube->description;
		$video_width		= $SSDTube->width;
		$video_height		= $SSDTube->height;
		$video_youtube_embed	= $SSDTube->youtube_embed;
		$youtube_watch		= $SSDTube->youtube_watch;
		$tmp_http_yt_video 	= $func->ogTagsYoutubeVideo($video_youtube_uri);
		
		// category
		$category_id		= $rows[0]["p_category"];
		$catg_array			= $config->array_category();
		$category			= $catg_array[$category_id];

		$slidercontent		= json_decode($rows[0]["p_slidercontent"], true);
		$pic_link			= $slidercontent[array_rand($slidercontent)];
		$pic_link			= str_ireplace("http", "https", $pic_link);
		
		$headline			= $func->removeAccents($rows[0]["p_headlineraw"]);
		$article			= $rows[0]["p_articletext"];
		$picture_desc		= $func->removeAccents($rows[0]["p_description"]);
		$headline_social	= $func->clear_description($headline);
		
		$article			= str_ireplace("http://cdn.heftig.co", "https://cdn.heftig.co", $func->removeAccents($article));
		
		$sentences 			= array();
		$sentences 			= preg_split("/[!?.] /", $func->stripHtml($article), -1, PREG_SPLIT_NO_EMPTY);
		
		$plista_time 		= time() - 24*60*60;
		$text_plista		= $func->removeAccents($func->stripHtml($sentences[0]));
		
		for($i=2; $i<=count($sentences); $i++){
			if (strlen($sentences[$i])>1){
				$sentences_content	.= $sentences[$i].". ";
			}
		}
   
		$monate = array(1=>"Januar",
                2=>"Februar",
                3=>"M&auml;rz",
                4=>"April",
                5=>"Mai",
                6=>"Juni",
                7=>"Juli",
                8=>"August",
                9=>"September",
                10=>"Oktober",
                11=>"November",
                12=>"Dezember");
		
		list($pre_date,)	= explode(" ",$rows[0]["p_timestamp"]);
		$monat 				= date("n",strtotime($pre_date));
		$date_month			= $monate[$monat];
		$date_day 			= date("j", strtotime($pre_date));
		$date_year 			= date("Y", strtotime($pre_date));
	
		$tagcode = <<<LIST
		<ul>
			<li lang="de">Heftig.co</li>
			<li lang="de">Krass</li>
			<li lang="de">Unglaublich</li>
			<li lang="de">Viral</li>
			<li lang="de">$picture_desc</li>
		</ul>
LIST;

		// related content
		$RelatedMoreContent = $func->GetNewRelatedContent($picture_desc." | ".$headline." | ".$article);
		
		// copyright
		$copyYear 			= 2012; 
		$curYear 			= date('Y'); 
		$year 				= $copyYear . (($copyYear != $curYear) ? '-' . $curYear : '');
		$copy 				= "&copy;$year BuzzerStar.com - M.Sc. Sebastian Enger. All Rights Reserved.";
		
		if ( $isGoogleBot != 1 ){
			$plista_time = time() - 24*60*60;
			$PlistaWerbungString =<<<END
				<p>
				<div data-widget="plista_widget_standard_3"></div>
				<script type="text/javascript">
					if (!window.PLISTA) {
						 window.PLISTA = {
							publickey: '804fac8ee1819a4c447c6a2f',
							item: {
								objectid: '$shortcode', 
								title: '$headline', 
								text: '$sentences[0]. $sentences[1].', 
								url: '$linkingcode', 
								img: '$pic_link', 
								category: 'News',
								created_at: $plista_time
							},
						categories: ['Sport', 'Auto', 'Unterhaltung'] //optional: additional categories
					};
				(function(){var n='script',d=document,s=d.createElement(n),s0=d.getElementsByTagName(n)[0];s.async='async';s.type='text/javascript';s.src=(d.location.protocol==='https:'?'https:':'http:')+'//static.plista.com/async.js';s0.parentNode.insertBefore(s,s0)}());
				}
				</script>
			</p>
END;
			$FirstloadWerbungString =<<<END
			<p>
				<a href="http://www.firstload.com/affiliate/log.php?log=53007" target="_blank" rel="nofollow"><img src="/images/load/fl.gif" width="468" height="60" border="0" /></a>
			</p>
END;
		}
		
		$sliderHTMLContent  = "";
		/// Hier den Slider aufbauen: Start:
		$slidercontent		= json_decode($rows[0]["p_slidercontent"], true);
						
		$sliderHTMLContent	 .= <<<END
			<div class="entry-thumb">
				<div class="owl-carousel owl-carousel-7">			
END;
		
		$plista_time = time() - 24*60*60;
		
		// if (count($slidercontent)>1){ show slider - else not
		for ($i=0;$i<=count($slidercontent);$i++){	
			if (strlen($slidercontent[$i]) > 4){	
				$sliderHTMLContent	 .= <<<END
					<div class="item">
						<figure itemtype="http://schema.org/ImageObject"><img class="lazy" src="https://www.buzzerstar.com/images/grey.png" data-original="$slidercontent[$i]" itemprop="image" alt="Bildbeschreibung $picture_desc" title="Bildbeschreibung $picture_desc" />
						<figcaption id="figurecaption">$picture_desc</figcaption>
						</figure>
					</div>	
END;
			} // if (array_key_exists($i,$sliderExplode)){	
		} // for ($i=0;$i<=count($sliderExplode);$i++){	

			$sliderHTMLContent	 .= <<<END
					</div>
						</div> 	
END;

		echo "Count Slidercontent: " . count($slidercontent);
		if (count($slidercontent)<=1){
			$sliderHTMLContent = "";
		}
		
		/// Hier den Slider aufbauen: ENDE		
		$ReturnHtmlString .=<<<END
		<div id="main-content" class="mb-20">
			<div class="wrapper">
				<div class="row">	
					<div class="kopa-main-col">
                    <div class="widget">
                        <div class="pd-20 kopa-entry-post">
                            <article class="entry-item">
                                <p class="entry-categories style-s"><a href="https://www.buzzerstar.com/kategorie/$category">$category</a></p>
                                <h1 class="entry-title"><b><strong>$headline</strong></b></h1>
                                </div>
								<blockquote class="kopa-blockquote style2">
                                    <p><b>$text_plista.</b></p>
									
									<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
										<ins class="adsbygoogle"
											 style="display:block"
											 data-ad-client="ca-pub-8441004200831936"
											 data-ad-slot="1845200008"
											 data-ad-format="auto"></ins>
									<script>
									(adsbygoogle = window.adsbygoogle || []).push({});
									</script>												
                                </blockquote>
							<!--	
								<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">
									$EmbeddedVideo
									<h2><span itemprop="name">$video_title</span></h2>
									<meta itemprop="duration" content="$video_duration" />
									<meta itemprop="thumbnailURL" content="$tumbnailVideoImg" />
									<meta itemprop="contentURL" content="$youtube_watch" />						
									<meta itemprop="embedURL" content="$video_youtube_embed" />
									<span itemprop="description">$video_description</span>
									<meta itemprop="height" content="$video_height" />
									<meta itemprop="width" content="$video_width" />
									<p />
								</div>
							-->
								<br />
								$PlistaWerbungString
								<br />
								<blockquote class="kopa-blockquote style2">
                                    <p>$article</p>
                                </blockquote>
								<br />
								$sliderHTMLContent
							 </article>
							</div>
							<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
									<ins class="adsbygoogle"
										 style="display:block"
										 data-ad-client="ca-pub-8441004200831936"
										 data-ad-slot="1845200008"
										 data-ad-format="auto"></ins>
								<script>
								(adsbygoogle = window.adsbygoogle || []).push({});
								</script>	
						
							$PlistaWerbungString
							
							<br />	
							<div class="kopa-tag-box">
								<span><b>Erzähl es deinen Freunden:</b></span><p />
								(Klick eines der bunten Icons unter diesem Text<br>
								zum teilen mit deinen Freunden auf Facebook,<br> Twitter oder WhatsApp!)
							</div>	
							<div class="kopa-social-links pull-left style4">
								<ul class="clearfix">
									<li><a href="https://www.facebook.com/sharer/sharer.php?u=$linkingcode" title="Diesen Artikel auf Facebook teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Facebook-icon.png" title="In Facebook teilen" itemprop="image" alt="mit Facebook teilen" width="32" height="32"></figure></a></li>
									<li><a href="https://twitter.com/home?status=$linkingcode_twittr" title="Diesen Artikel auf Twitter teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Twitter-icon.png" title="In Twitter teilen" itemprop="image" alt="mit Twitter teilen" width="32" height="32"></figure></a></li>
									<li><a href="https://plus.google.com/share?url=$linkingcode" title="Diesen Artikel auf Google Plus teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Google-Plus-icon.png" title="In Google Plus teilen" itemprop="image" alt="mit Google Plus teilen" width="32" height="32"></figure></a></li>
									<li><a href="WhatsApp://send?text=Coole News: $headline_social %20-%20 $linkingcode" title="Den Artikel via WhatsApp deinen Freunden schicken" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Whatsapp-icon.png" title="In WhatsApp teilen" itemprop="image" alt="mit WhatsApp teilen" width="32" height="32"></figure></a></li>
									<li><a href="https://pinterest.com/pin/create/button/?url=$linkingcode&media=$pic_link&description=$headline_social" title="Auf Pinterest teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Pinterest-icon.png" title="In Pinterest teilen" itemprop="image" alt="mit Pinterest teilen" width="32" height="32"></figure></a></li>
									<li><a href="https://www.stumbleupon.com/submit?url=$linkingcode&title=$headline_social" title="Deine Freunde auf Stumbleupon informieren" rel="nofollow" target="_blank"><figure><img src="/images/social-new/StumbleUpon-icon.png" title="In Stumbleupon teilen" itemprop="image" alt="mit Stumbleupon teilen" width="32" height="32"></figure></a></li>
									<li><a href="mailto:HierdieEmail@DeinesFreundesEintragen.com?Subject=Schau%20dir%20www.BuzzerStar.com%20an%20-%20lauter%20lustige%20Videos%20und%20coole%20News&Body=Hi,hier ist der Link: $linkingcode . Viel Spaß auf www.BuzzerStar.com!" title="Deinen Freunden eine Email senden" target="_blank"><figure><img src="/images/social-new/email-icon.png" title="Freunde via Email von BuzzerStar erzählen" itemprop="image" alt="Freunde mittels Email mitteilen" width="32" height="32"></figure></a></li>
									<li><a href="https://www.buzzerstar.com/rss.php" title="RSS Feed abonnieren" target="_blank"><figure><img src="/images/social-new/Rss-icon.png" title="RSS laden" itemprop="image" alt="mit Feedly RSS abonnieren" width="32" height="32"></figure></a></li>
								</ul>
							</div>
                            <div class="kopa-tag-box">
								<br /><br />
								<span>Tags dieser News</span>
								$tagcode
								<span class="entry-date"><i class="fa fa-clock-o"></i>&nbsp;$date_day. $date_month $date_year</span>
								<br /><br />
								$FirstloadWerbungString
                            </div>
						</div>
                    </div>
					 <div class="widget kopa-article-list-widget article-list-23">
                        <h3 class="widget-title style3"> Noch mehr <span>coole Artikel</span></h3>
                        <div class="pd-20">
							<ul class="clearfix">
								$RelatedMoreContent
							</ul>
                        </div>
                    </div>
                    <!-- widget -->             
                </div>
            <!-- kopa-main-col -->   			
        </div>
        <!-- wrapper -->
    </div>
    <!-- main-content -->
	<footer id="kopa-footer">
		<a href="/post.php" target="_blank">
			<figure itemtype="http://schema.org/ImageObject"><img class="lazy" src="https://www.buzzerstar.com/images/grey.png" data-original="https://www.buzzerstar.com/i.php?s=f8971b2e9" itemprop="image" alt="Coole Artikel auf BuzzerStar schreiben und gratis Guthaben und Gutscheinkarten absahnen" title="Amazon, Zalando, iTunes, Playstore, Value Steam Gutscheine" width="640" height="480" />
				<figcaption><b>Coole Bilder: Bekloppte und Coole News Artikel auf BuzzerStar schreiben und Gutscheinkarten absahnen!</b></figcaption>
			</figure>
			</a>
		<div class="wrapper clearfix">
			<span id="copyright">
				<article id="articletext">		
					<cite>"Hackers - Heroes of the Computer Revolution!"</cite>
					<p />
					$copy
				</article>	
			</span>
		</div>	
        <!-- wrapper -->
    </footer>
    <!-- kopa-footer -->		
END;
				
		$ReturnContentArray = array("keywords"=>"$keyword_meta, $category, news, neuigkeiten, bild, heftig, cool","articletext"=>$article, "headline"=>$headline, "returncontent" =>$ReturnHtmlString, "video_yt_beautify_ssl" => $tmp_http_yt_video, "category" => $category, "headline" =>$headline,"image"=>$pic_link);
				
		return $ReturnContentArray;
	}
	
	public function StartpageGenerateNews($page){
		
		$PageNext	 		= $page + 1;
		
		$ReturnHtmlString	= "";
		
		$conn 				= new Connection();
		$config 			= new Config();
		$func	 			= new Functions();
		$ip					= new IP();
		
		$pdo				= $conn->prepareQuery();
		$table 				= $config->sql_tablename_publish_de();
		$table_img			= $config->sql_tablename_pictures();
		$shortcode_passkey 	= $config->shortcode_passkey();
		$pdo				= $conn->prepareQuery();
		$picpath			= $config->picture_storepath();
		$maxPageCount 		= $config->index_max_results();
		
		$imageRetArray 		= $func->getScreenResolutionFromUA();
		$x 					= $imageRetArray["xImage"];
		$y 					= $imageRetArray["yImage"];
		$fontsize 			= $imageRetArray["fontsize"];
		$picQuality 		= $imageRetArray["picQuality"];
		
		$isGoogleBot		= $ip->isValidGoogleCrawler();
		$page 				= $func->stripHtml($_REQUEST['p']);
		//$extraContent		= $func->getExtraContent();
		$plista_time 		= time() - 24*60*60;
		
		if (!is_numeric($page) || !isset($page) || empty($page) || strlen($page) <= 0 ){
			$page = 0;
		}
		
		$monate = array(1=>"Januar",
                2=>"Februar",
                3=>"M&auml;rz",
                4=>"April",
                5=>"Mai",
                6=>"Juni",
                7=>"Juli",
                8=>"August",
                9=>"September",
                10=>"Oktober",
                11=>"November",
                12=>"Dezember");
				
		if ( $isGoogleBot != 1 ){
			$plista_time = time() - 24*60*60;
			$PlistaWerbungString =<<<END
				<div data-widget="plista_widget_standard_3"></div>
						<script type="text/javascript">
						 if (!window.PLISTA) {
							 window.PLISTA = {
								publickey: '804fac8ee1819a4c447c6a2f',
								
						};
						(function(){var n='script',d=document,s=d.createElement(n),s0=d.getElementsByTagName(n)[0];s.async='async';s.type='text/javascript';s.src=(d.location.protocol==='https:'?'https:':'http:')+'//static.plista.com/async.js';s0.parentNode.insertBefore(s,s0)}());
						}
						</script>
						<br />
END;
		}
		
		
		$from 			= ( $maxPageCount * $page );
		$stmt 			= $pdo->prepare("SELECT * FROM $table WHERE id>0 ORDER BY RAND() DESC LIMIT $from, $maxPageCount;");
		$stmt->execute();
		
		$ReturnHtmlString .=<<<END
			<div id="main-content" class="mb-20">
        <div class="wrapper">
			<h3 class="widget-title style3"><span>Die coolsten News auf BuzzerStar</span></h3>
           
			<div class="widget-area-18">
                <div class="widget xkopa-ads-1-widget">	
					<p>
						$PlistaWerbungString
							<br />
							<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
								<ins class="adsbygoogle"
									 style="display:block"
									 data-ad-client="ca-pub-8441004200831936"
									 data-ad-slot="1845200008"
									 data-ad-format="auto"></ins>
							<script>
							(adsbygoogle = window.adsbygoogle || []).push({});
							</script>
						<br />	
					</p>
                </div>   
            </div>

            <!-- widget-area-18 -->

            <div class="row">
                <div class="widget-area-28 kopa-col-1">
                    <!-- widget --> 
					<div class="widget kopa-masonry-6-widget">
					<!--	<h3 class="widget-title style3"><span>Die coolsten News auf BuzzerStar</span></h3> -->
							<ul class="kopa-masonry-wrap">
END;
		
		$row_count 		= 0;
		$all_row_count 	= 0;
		while($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
			
			$row_count++;
			$all_row_count++;
/*
			echo "Original: ". $rows["p_headline"]." ---> ".mb_detect_encoding($rows["p_headline"])."-<br />";
			echo "Manipulated: ". $func->removeAccents($rows["p_headline"])." ---> ".mb_detect_encoding($func->removeAccents($rows["p_headline"]))."-<br /><br />";
*/
			
			$headline			= $func->removeAccents($rows["p_headline"]);
			$timestamp			= $rows["p_timestamp"];
		//	$article			= $func->removeAccents();
			$author				= "Facebook/BuzzerStar";
		//	$backlink			= $rows["p_sourcelink"];
			$shortcode			= $rows["p_shortcode"];
		/*	
			$slidercontent		= json_decode($rows[0]["p_slidercontent"], true);
			$pic_link			= $slidercontent[array_rand($slidercontent)];
			$pic_link			= str_ireplace("http", "https", $pic_link);
		*/
			$pic_link			= str_ireplace("http", "https", $rows["p_picture1"]);
		
			$category_id		= $rows["p_category"];
			$pic_descr			= $func->removeAccents($rows["p_description"]);
			$catg_array			= $config->array_category();
			$category			= $catg_array[$category_id];
			$categoryLink		= $func->buildCategoryLink($category_id);
			$linkingcode		= "https://www.buzzerstar.com/p/fun/".$func->makeArticleLink($shortcode);
			$linkingcode_twittr	= "https://www.buzzerstar.com/p/fun/show.php?a=$shortcode";
	
			list($pre_date,)	= explode(" ",$timestamp);
			$monat 				= date("n",strtotime($pre_date));
			$date_month			= $monate[$monat];
			$date_day 			= date("j", strtotime($pre_date));
			$date_year 			= date("Y", strtotime($pre_date));

			$article			= str_ireplace("http://cdn.heftig.co", "https://cdn.heftig.co", $func->removeAccents($rows["p_articletext"]));
			
			$sentences 			= array();
			$sentences 			= preg_split("/[!?.] /", $func->stripHtml($article), -1, PREG_SPLIT_NO_EMPTY);
			$text_plista		= $func->removeAccents($func->stripHtml($sentences[0]));
			
			$imageFiller	=<<<FIN
				<figure itemtype="http://schema.org/ImageObject"><img class="lazy" src="https://www.buzzerstar.com/images/grey.png" data-original="$pic_link" width="$x" height="$y" itemprop="image" alt="$pic_descr" title="$pic_descr" /><figurecaption id="figcaptStart"><strong>$pic_descr</strong></figurecaption></figure>
FIN;
					
			$ReturnHtmlString .=<<<END
                            <li class="ms-item6" >
                                <article class="entry-item">
                                    <div class="pd-20">
                                        <div class="entry-thumb style1">
											<h5><a href="$categoryLink">$category</a></h5>
                                        </div>
										<div class="entry-content">
                                           <summary><h3 class="entry-title"><a itemprop="description" href="$linkingcode" title="$pic_descr: $headline">$headline</a></h3></summary>
                                           <a href="$linkingcode">$imageFiller</a>
										   <div class="entry-meta">
                                                <a>
                                                    <div class="entry-author">
                                                        <span>$author</span>
                                                    </div>
                                                </a>
												&nbsp;|&nbsp;
                                                <span class="entry-date"><i class="fa fa-clock-o"> $date_day. $date_month $date_year</i></span>
                                            </div>
                                            <p>$text_plista .<p /> 
										</div>
                                    </div>
                                    <footer class="entry-footer">
                                        <div class="kopa-social-links pull-left style4">
                                            <ul class="clearfix">
												<li><a href="https://www.facebook.com/sharer/sharer.php?u=$linkingcode" title="Diesen Artikel auf Facebook teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Facebook-icon.png" title="In Facebook teilen" itemprop="image" alt="mit Facebook teilen" width="32" height="32"></figure></a></li>
												<li><a href="https://twitter.com/home?status=$linkingcode_twittr" title="Diesen Artikel auf Twitter teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Twitter-icon.png" title="In Twitter teilen" itemprop="image" alt="mit Twitter teilen" width="32" height="32"></figure></a></li>
												<li><a href="https://plus.google.com/share?url=$linkingcode" title="Diesen Artikel auf Google Plus teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Google-Plus-icon.png" title="In Google Plus teilen" itemprop="image" alt="mit Google Plus teilen" width="32" height="32"></figure></a></li>
												<li><a href="WhatsApp://send?text=Coole News: $headline %20-%20 $linkingcode" title="Den Artikel via WhatsApp deinen Freunden schicken" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Whatsapp-icon.png" title="In WhatsApp teilen" itemprop="image" alt="mit WhatsApp teilen" width="32" height="32"></figure></a></li>
												<li><a href="https://pinterest.com/pin/create/button/?url=$linkingcode&media=$pic_link&description=$headline" title="Auf Pinterest teilen" class="fa" rel="nofollow" target="_blank"><figure><img src="/images/social-new/Pinterest-icon.png" title="In Pinterest teilen" itemprop="image" alt="mit Pinterest teilen" width="32" height="32"></figure></a></li>
												<li><a href="https://www.stumbleupon.com/submit?url=$linkingcode&title=$headline" title="Deine Freunde auf Stumbleupon informieren" rel="nofollow" target="_blank"><figure><img src="/images/social-new/StumbleUpon-icon.png" title="In Stumbleupon teilen" itemprop="image" alt="mit Stumbleupon teilen" width="32" height="32"></figure></a></li>
												<li><a href="mailto:HierdieEmail@DeinesFreundesEintragen.com?Subject=Schau%20dir%20www.BuzzerStar.com%20an%20-%20lauter%20lustige%20Videos%20und%20coole%20News&Body=Hi,hier ist der Link: $linkingcode . Viel Spaß auf www.BuzzerStar.com!" title="Deinen Freunden eine Email senden" target="_blank"><figure><img src="/images/social-new/email-icon.png" title="Freunde via Email von BuzzerStar erzählen" itemprop="image" alt="Freunde mittels Email mitteilen" width="32" height="32"></figure></a></li>
												<li><a href="https://www.buzzerstar.com/rss.php" title="RSS Feed abonnieren" target="_blank"><figure><img src="/images/social-new/Rss-icon.png" title="RSS laden" itemprop="image" alt="mit Feedly RSS abonnieren" width="32" height="32"></figure></a></li>
											</ul>
										</div>
                                    </footer>       
                                </article>
								<div class="clear"></div>
                            </li>
END;
		
			/*Anweisung muss vor Hautpanweisung $ReturnHtmlString .=<<<END stehen */
			if ( $row_count > 1){
				$ReturnHtmlString .=<<<END
					</ul>
						</div>
						<div class="widget kopa-masonry-6-widget">
							<ul class="kopa-masonry-wrap">
END;
			}
						
			if ( $row_count > 1){
				$row_count 	= 0;
			}
						
		} // while($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
		
		$copyYear 			= 2012; 
		$curYear 			= date('Y'); 
		$year 				= $copyYear . (($copyYear != $curYear) ? '-' . $curYear : '');
		$copy 				= "&copy;$year BuzzerStar.com - M.Sc. Sebastian Enger. All Rights Reserved.";
		
		$ReturnHtmlString .=<<<END
			</ul>
			<div class="kopa-loadmore"><a href="https://www.buzzerstar.com/p/fun/?p=$PageNext" class="url" itemprop="url" rel="next"><b>Ich will noch mehr News lesen!</b></a></div>
						
					</div>
				</div>
				<br />
				<a href="/post.php" target="_blank">
					<figure itemtype="http://schema.org/ImageObject"><img class="lazy" src="https://www.buzzerstar.com/images/grey.png" data-original="https://www.buzzerstar.com/i.php?s=f8971b2e9" itemprop="image" alt="Coole Artikel auf BuzzerStar schreiben und gratis Guthaben und Gutscheinkarten absahnen" title="Amazon, Zalando, iTunes, Playstore, Value Steam Gutscheine" />
						<figcaption><strong>Coole Bilder: Gleich News und Artikel auf BuzzerStar.com schreiben, Gutscheinkarten für Amazon, Valve Steam, Playstation Plus Card, Zalando oder Apple iTunes absahnen!</strong></figcaption>
					</figure>
				</a>
				</div>
               <!-- widget-area-29 -->
            </div>
            <!-- row --> 
        </div>
        <!-- wrapper -->
    </div>
	
	 <footer id="kopa-footer">
        <div class="wrapper clearfix">
			<p id="copyright">
				<article id="articletext">
					Auf der Open Source Plattform Sourceforge und Google Code haben wir weitere Programme und Tools hinterlegt, die wir während der Entwicklung
					von BuzzerStar kreiert haben. Ihr könnt sie kostenfrei herunterladen, die Lizenzen entsprechen dem GNU Lesser General Public License. Diese Tools zusammen garantieren kurze Zugriffszeiten, realisieren <b>Responsive Images bzw. Adaptive Images</b> und Webdesign. 
					<br /><br />
					<cite>"Hackers - Heroes of the Computer Revolution!"</cite>
					<br /><br />
					$copy
				</article>	
			</p>
		</div>	
        <!-- wrapper -->
    </footer>
    <!-- kopa-footer -->
END;
	
		$stmt 				= null; // doing this is mandatory for connection to get closed
		$pdo 				= null;

		return $ReturnHtmlString;
		
	} // public function StartpageGenerateNews($page){
		
	
	public function StartpageGenerateHeader($show_headline){
		
		$func	 			= new Functions();
		$config 			= new Config();
		$LinkableCatgID 	= $config->category_to_show();
		$category_content	= "";
		$category_content_mobile = "";
		$headline_content	= "";
		
		if ($show_headline==1){
			$headline_content .=<<<END
					<h1 id="white">Humorvolles, Witziges, Verrücktes und kostenlose Spiele aus aller Welt. Teile es mit deinen Freunden!</h1>
END;
		}
		
		$category_content_mobile .=<<<END
<li><a href="https://www.buzzerstar.com/trending/" title="Navigiere zur BuzzerStar Kategorie Trending News" class="url" itemprop="url"><span itemprop="title">Beliebtesten News</span></a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
END;

$category_content .=<<<END
<li><a href="https://www.buzzerstar.com/trending/" title="Navigiere zur BuzzerStar Kategorie News Trends" class="url" itemprop="url"><span itemprop="title">Beliebtesten News</span></a></li>
END;

		foreach ($LinkableCatgID as $keyCatg ){
			$linkableCodeCatg 	= $func->buildCategoryLink($keyCatg);
			$catgName 			= $func->categoryIDtoName($keyCatg);
			
			$category_content_mobile .=<<<END
<li><a href="$linkableCodeCatg" title="Navigiere zur BuzzerStar Kategorie $catgName" class="url" itemprop="url">$catgName</a></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
END;

$category_content .=<<<END
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="$linkableCodeCatg" title="Navigiere zur BuzzerStar Kategorie $catgName" class="url" itemprop="url"><span itemprop="title">$catgName</span></a></li>
END;
}
	$mystring = <<<EOT
		<header class="kopa-header">
        <!-- kopa-header-middle -->
        <div class="kopa-header-bottom">
            <div class="wrapper">
                <div class="header-bottom-wrap">
					<div class="kopa-logo">
						<a href="/p/fun/" title="BuzzerStar.COM Startseite"><figure itemtype="http://schema.org/ImageObject"><img src="/images/logo_startpage.png" itemprop="image" alt="BuzzerStar Charakter" title="BuzzerStar Logo"></figure></a>
					</div>
					$headline_content
                    <nav class="kopa-main-nav" itemprop="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
                        <meta itemprop="name" content="Breadcrumb"/>
						<meta itemprop="description" content="Brotkrumennavigation für BuzzerStar.COM"/>
						
						<ul class="main-menu sf-menu" itemprop="itemListElement">
                            <li class="current-menu-item" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
                                <a href="https://www.buzzerstar.com/p/fun/" itemprop="url"><span itemprop="title">Startseite</span></a>
                            </li>
                            <li>
                                <a>Spiele, Fun & Witze</a>
                                <ul class="sub-menu" itemprop="itemListElement">
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/witze/" itemprop="url" target="_self" title="Witze auf BuzzerStar"><span itemprop="title">Witze</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/spiele/mahjong/" itemprop="url" target="_self" title="Gratis Mahjong auf BuzzerStar spielen"><span itemprop="title">Mahjong</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/spiele/sudoku/" itemprop="url" target="_self" title="Spiele Sudoku kostenlos auf BuzzerStar"><span itemprop="title">Sudoku</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.net/" itemprop="url" target="_blank" title="BuzzerStar.NET - Viral News"><img src="/images/en.png" alt="BuzzerStar in English" title="Latest Buzz on the Net" />
									- BuzzerStar.NET</a></li>
                                </ul>
                            </li>
							<li>
                                <a>News</a>
                                <ul class="sub-menu" itemprop="itemListElement">
                                    $category_content
                                </ul>
                            </li>
                            <li>
                                <a>Information</a>
                                <ul class="sub-menu" itemprop="itemListElement">
                                    <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/post.php" itemprop="url" target="_blank"><span itemprop="title">Selbst News schreiben</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/rss.php" itemprop="url" target="_blank"><span itemprop="title">RSS Feed</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/newsticker/" itemprop="url" target="_blank"><span itemprop="title">NewsTicker</span></a></li>
                                    <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/imprint.php" itemprop="url" rel="nofollow" target="_blank"><span itemprop="title">Impressum</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/privacy-policy.php" itemprop="url" rel="nofollow" target="_blank"><span itemprop="title">Datenschutz</span></a></li>
									<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="https://www.buzzerstar.com/development/" itemprop="url" target="_blank"><span itemprop="title">Perl & CPan Software</span></a></li>
                                </ul>
                            </li>
							<li>
								<a>Suche</a>
                                <ul class="sub-menu">
                                    <li> 
										<form class="search-form clearfix">
											<input type="reset" id="reset" value="Löschen" /><p />
											<span class="fa fa-search"><input type="text" class="searchclass search-text search" id="searchid" placeholder="Suchbegriff eingeben: " /></span>
											<div id="result"></div>
										</form>
									</li>
                                </ul>
                            </li>
                        </ul>                
                    </nav>
                    <!--/end main-nav-->

                    <nav class="main-nav-mobile">
						<a class="pull">Menu<i class="fa fa-caret-down"></i></a>
                        <ul class="main-menu-mobile">
							<li class="current-menu-item"  >
                                <a href="https://www.buzzerstar.com/" itemprop="url">Startseite</a>
                            </li>
                            <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
							<li>
                                <a>Spiele, Fun & Witze</a>
                                <ul class="sub-menu" style="color: #000000;" >
                                    <li  ><a href="https://www.buzzerstar.com/witze/" itemprop="url" target="_self" title="Witze auf BuzzerStar">Witze</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
									<li  ><a href="https://www.buzzerstar.com/spiele/mahjong/" itemprop="url" target="_self" title="Gratis Mahjong auf BuzzerStar spielen">Mahjong</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
									<li  ><a href="https://www.buzzerstar.com/spiele/sudoku/" itemprop="url" target="_self" title="Spiele Sudoku kostenlos auf BuzzerStar">Sudoku</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
									<li  ><a href="https://www.buzzerstar.net/" itemprop="url" target="_blank" title="BuzzerStar.NET - Viral News"><img src="/images/en.png" alt="BuzzerStar in English" title="Latest Buzz on the Net" />
									- BuzzerStar.NET</a></li>
                                </ul>
                            </li>
							<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
							<li>
                                <a>Kategorien</a>
                                <ul class="sub-menu" style="color: #000000;">
                                    $category_content_mobile
                                </ul>
                            </li>
							<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
							<li>
                                <a>Information</a>
                                <ul class="sub-menu" style="color: #000000;">
                                    <li><a href="https://www.buzzerstar.com/post.php" itemprop="url" rel="nofollow" target="_blank">News posten</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
									<li  ><a href="https://www.buzzerstar.com/rss.php" itemprop="url" target="_blank">RSS Feed</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
									<li  ><a href="https://www.buzzerstar.com/newsticker/" itemprop="url" target="_blank">NewsTicker</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
                                    <li  ><a href="https://www.buzzerstar.com/imprint.php" itemprop="url" rel="nofollow" target="_blank">Impressum</a></li>
									<li  >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
									<li  ><a href="https://www.buzzerstar.com/privacy-policy.php" itemprop="url" rel="nofollow" target="_blank">Datenschutz</a></li>
                                </ul>
                            </li>
							<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
							<li>
                                <a>Suche</a>
                                <ul class="sub-menu" style="color: #000000;">
                                    <li> 
										<form class="search-form clearfix">
											<input type="reset" id="reset" value="Löschen" /><p />
											<input type="text" class="searchclass search-text search" id="searchid" placeholder="Suchbegriff eingeben: " />
											<div id="result"></div>
										</form>
									</li>
                                </ul>
                            </li>
                        </ul>                
                    </nav>
				   
				   
                    <!--/end main-nav-->
					<!-- search-form -->
                    <!--search-box-->
                </div>
                <!-- header-bottom-wrap -->
				        <!-- search-form -->
                    </div>
                    <!--search-box-->
                </div>
                <!-- header-bottom-wrap -->
            </div>
            <!-- wrapper -->
        </div>
        <!-- kopa-header-bottom -->
    </header>
    <!-- kopa-page-header -->
EOT;
		return $mystring;
	}
}
?>