picture_clones();
$filename = "$pictureStorepath/$md5_pic";
if (is_file($filename) && file_exists($filename) && is_readable($filename) && filesize($filename) >10 ) {
return "https://www.buzzerstar.com/p/bilder/image.php?s=".$md5_pic;
}
$temp = tempnam("/tmp", 'temp');
if (!($f = @fopen($temp, 'w'))) {
$temp = "/tmp/" . uniqid('temp');
if (!($f = @fopen($temp, 'w'))) {
trigger_error("file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING);
return false;
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
//curl_setopt($ch,CURLOPT_SSLVERSION,3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $pictureUri);
curl_setopt($ch, CURLOPT_TIMEOUT,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FILE, $f);
curl_exec($ch);
if(curl_errno($ch)){
// echo 'Class Image - Line 54 -> error:' . curl_error($ch);
return $pictureUri;
}
curl_close($ch);
fclose($f);
if (!rename($temp, $filename)) {
unlink($filename);
rename($temp, $filename);
}
chmod($filename, 0755);
return "https://www.buzzerstar.com/p/bilder/image.php?s=".$md5_pic; //substr($md5_pic, 0, 9);
}
public function getExtraContent(){
$conn = new Connection();
$config = new Config();
$ResultContent = "";
$table = $config->sql_tablename_extracontent();
$pdo = $conn->prepareQuery();
$stmt = $pdo->prepare("SELECT * FROM $table WHERE 1=1 ORDER BY RAND() LIMIT 9;");
$stmt->execute();
$count = 0;
$div_reset = "";
while($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
$p_picturelink = trim($rows["p_picturelink"]);
$p_title = $this->clear_description($rows["p_title"]);
$p_shortcode = trim($rows["p_shortcode"]);
$p_picturelink_sid = md5($p_picturelink);
if ($count == 3 ){
$count = 0;
// $ResultContent .= "
";
}
$ResultContent .=<<
END;
$count++;
} // while($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
return $ResultContent;
}
public function getDeepLinkContent(){#new
$RelatedMoreContent = "";
$ResultsArray = array();
$cache = new FileCache();
$key = 'getContent:RandomContent';
if (!$content = $cache->fetch($key)) {
$content = $this->get_html('https://www.buzzerstar.net/api.php?r=1');
$cache->store($key,$content,10000); // 1 tag cache
}
$ResultsArray = explode("\n",$content);
$count = count($ResultsArray);
for ( $ArrayCount=0; $ArrayCount<=2; $ArrayCount++ ) {
$rand_f1 = rand(1,8);
$rand_f2 = rand(10,60);
list( $shortcode,$headline,$keywords,$linkingcode ) = explode('###', $ResultsArray[$ArrayCount] );
$RelatedMoreContent .=<<
$rand_f1:$rand_f2
BuzzerStar.NET presents: $headline
END;
} // for
return $RelatedMoreContent;
}
public function get_html($url) {#new
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public function GetNewRelatedContent($searchInputFromShowPHP){
$search = new Search();
$SearchContent = $search->SphinxSearch( $searchInputFromShowPHP );
$RelatedMoreContent = "";
$imageRetArray = $this->getScreenResolutionFromUA($startpage);
$x = $imageRetArray["x"];
$y = $imageRetArray["y"];
$fontsize = $imageRetArray["fontsize"];
$picQuality = $imageRetArray["picQuality"];
for ( $ArrayCount=1; $ArrayCount<=7; $ArrayCount++ ) {
$rand_f1 = rand(1,8);
$rand_f2 = rand(10,60);
list( $headline,$shortcode,$article1,$pic_desc) = explode('#####', $SearchContent[$ArrayCount] );
if (strlen($headline)<10){
break 1;
}
$shortcode = trim($shortcode);
$headline = trim($headline);
$pic_desc = trim($pic_desc);
//$article = substr($article1,0,125).' ...';
$articleLink = "https://www.buzzerstar.com/".$this->makeArticleLink($shortcode);
$sentences = preg_split("/[!?.]/", $article1, -1, PREG_SPLIT_NO_EMPTY);
$RelatedMoreContent .=<<
$rand_f1:$rand_f2
$sentences[0]. $sentences[1].
$pic_desc.
END;
}
$MoreDeepLinks = $this->getDeepLinkContent();
return "$RelatedMoreContent $MoreDeepLinks";
}
public function getSpecialInlineCSS($css_path){
$css = new Minifier();
$buffer = "";
$buffer .= file_get_contents($css_path);
// Minifier anwenden
$buffer = $css->minifyCSS($buffer);
//Remove comments
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
//Remove space after colons
$buffer = str_replace(": ", ":", $buffer);
//Remove whitespace
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return "";
}
public function getIndexNewInlineCSS(){
$css = new Minifier();
$buffer = "";
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/style.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/style-color3.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/bootstrap.css");
/* //$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/font-awesome.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/superfish.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/megafish.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/jquery.navgoco.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/owl.carousel.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/owl.theme.css");
*/
// Minifier anwenden
$buffer = $css->minifyCSS($buffer);
//Remove comments
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
//Remove space after colons
$buffer = str_replace(": ", ":", $buffer);
//Remove whitespace
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return "";
}
public function getNewInlineCSS(){
$css = new Minifier();
$buffer = "";
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/style.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/style-color3.css");
//$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/font-awesome.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/superfish.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/megafish.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/jquery.navgoco.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/owl.carousel.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/owl.theme.css");
/*
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/bootstrap.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/font-awesome.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/superfish.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/megafish.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/jquery.navgoco.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/owl.carousel.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css-new/owl.theme.css");
*/
// Minifier anwenden
$buffer = $css->minifyCSS($buffer);
//Remove comments
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
//Remove space after colons
$buffer = str_replace(": ", ":", $buffer);
//Remove whitespace
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return "";
}
public function getInlineCSS(){
$buffer = "";
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css/basic-style.css");
$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css/normalize.css");
//$buffer .= file_get_contents("/home/www/wwwbuzzerstar/css/cssDroid.css");
//Remove comments
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
//Remove space after colons
$buffer = str_replace(": ", ":", $buffer);
//Remove whitespace
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return "";
}
//http://darcyclarke.me/development/get-image-for-youtube-or-vimeo-videos-from-url/
public function getLinks($text){
// The Regular Expression filter
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\/\S*)?/";
// Check if there is a url in the text
if(preg_match($reg_exUrl, $text, $url)) {
return array(1,$url[0]);
// make the urls hyper links
// echo preg_replace($reg_exUrl, "{$url[0]} ", $text);
} else {
// if no urls in the text just return the text
return array(0,0);
}
return array(0,0);
}
public function getScreenResolutionFromUA(){
$returnvalues = array();
$detect = new Mobile_Detect;
$deviceTypeMobile = $detect->isMobile();
$deviceTypeTablet = $detect->isTablet();
//320x240, 480x320, 800x480, 960x480, 1024x800, and 1024x768
$picQuality = 75;
if (strpos($startpage, '1') !== FALSE){
$x = 320;
$y = 260;
$xImage = 320;
$yImage = 260;
$fontsize = 9;
$picQuality = 55;
} elseif (strpos($startpage, '2') !== FALSE){
$x = 60;
$y = 75;
$xImage = 60;
$yImage = 75;
$fontsize = 7;
$picQuality = 55;
} elseif ($deviceTypeTablet === TRUE){
// we have a tablet device
$x = 540;
$y = 320;
$xImage = 460;
$yImage = 320;
$fontsize = 12;
$picQuality = 70;
} elseif ($deviceTypeMobile === TRUE){
// we have a mobile device
$x = 320;
$y = 260;
$xImage = 420;
$yImage = 360;
$fontsize = 10;
$picQuality = 80;
} else {
// we have a desktop device
$x = 640;
$y = 480;
$xImage = 620;
$yImage = 480;
/*
$xImage = 540;
$yImage = 430;
*/
$fontsize = 15;
$picQuality = 89;
}
/*
if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "google")){
$x = 480;
$y = 320;
$xImage = 480;
$yImage = 320;
$fontsize = 12;
$picQuality = 65;
}
*/
$returnvalues["x"] = $x;
$returnvalues["y"] = $y;
$returnvalues["xImage"] = $xImage;
$returnvalues["yImage"] = $yImage;
$returnvalues["fontsize"] = $fontsize;
$returnvalues["picQuality"] = $picQuality;
return $returnvalues;
}
// embedding code:
public function request_headers() {
$arh = array();
$rx_http = '/\AHTTP_/';
foreach($_SERVER as $key => $val) {
if( preg_match($rx_http, $key) ) {
$arh_key = preg_replace($rx_http, '', $key);
$rx_matches = array();
// do some nasty string manipulations to restore the original letter case
// this should work in most cases
$rx_matches = explode('_', $arh_key);
if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) {
foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val);
$arh_key = implode('-', $rx_matches);
}
$arh[$arh_key] = $val;
}
}
return( $arh );
}
public function clear_description($description_text){
$description_text = trim(substr($description_text, 0, 142));
$description_text = str_replace(array('ä','ö','ü','ß','Ä','Ö','Ü',' '),array('ae','oe','ue','ss','Ae','Oe','Ue',' '),$description_text);
$description_text = strip_tags($description_text);
$trans = array('-' => ' ');
$description_text = strtr($description_text, $trans);
$description_text = preg_replace("/[^a-zA-Z0-9\s\.\!\?\,\;]/", '', $description_text);
return $description_text;
}
public function clear_string($str, $how = ' '){
$search = array("ä", "ö", "ü", "ß", "Ä", "Ö",
"Ü", "&", "é", "á", "ó",
" :)", " :D", " :-)", " :P",
" :O", " ;D", " ;)", " ^^",
" :|", " :-/", ":)", ":D",
":-)", ":P", ":O", ";D", ";)",
"^^", ":|", ":-/", "(", ")", "[", "]",
"<", ">", "!", "\"", "§", "$", "%", "&",
"/", "(", ")", "=", "?", "`", "´", "*", "'",
"_", ":", ";", "²", "³", "{", "}",
"\\", "~", "#", "+", ".", ",",
"=", ":", "=)");
$replace = array("ae", "oe", "ue", "ss", "Ae", "Oe",
"Ue", "und", "e", "a", "o", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "");
$str = str_replace($search, $replace, $str);
//$str = strtolower(preg_replace("/[^a-zA-Z0-9]+/", trim($how), $str));
return $str;
}
public function sendKontaktformularMail($nachricht){
$empfaenger = 'sebastian.enger@gmail.com';
$betreff = 'Neue Kontaktanfrage über das BuzzerStar.com Kontaktformular am '.date("d-m-Y h:i:sa");
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$header .= 'To: Sebastian Enger '. "\r\n";
$header .= 'From: BuzzerStar-New Article ' . "\r\n";
mail($empfaenger, $betreff, $nachricht, $header);
} // public function sendKontaktformularMail($nachricht){
public function getTextBetweenTags($string, $start, $end){
$start = trim($start);
$end = trim($end);
$result = array();
$string = " ".trim($string);
$offset = 0;
while(true){
$ini = strpos($string,$start,$offset);
if ($ini == 0)
break;
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
$result[] = trim(substr($string,$ini,$len));
$offset = $ini+$len;
}
return $result;
}
public function autolink($str, $attributes=array()) {
$attrs = '';
foreach ($attributes as $attribute => $value) {
$attrs .= " {$attribute}=\"{$value}\"";
}
$str = ' ' . $str;
$str = preg_replace(
'`([^"=\'>])((http|https|ftp|mailto)://[^\s<]+[^\s<\.)])`i',
'$1[Externer Link]',
$str
);
$str = substr($str, 1);
return $str;
}
/*
public function autolink($str, $attributes=array()) {
$attrs = '';
foreach ($attributes as $attribute => $value) {
$attrs .= " {$attribute}=\"{$value}\"";
}
$str = ' ' . $str;
$str = preg_replace(
'`([^"=\'>])((http|https|ftp|mailto)://[^\s<]+[^\s<\.)])`i',
'$1$2',
$str
);
$str = substr($str, 1);
return $str;
}
*/
public function getNavigationContent($searchInputFromShowPHP){
//echo "Search for $searchInputFromShowPHP
";
$search = new Search();
$SearchContent = $search->SphinxSearch( $searchInputFromShowPHP );
// echo "DEBUG: Sphinx Intelligent Related Result Count:" . count($SearchContent). "
getScreenResolutionFromUA($startpage);
$x = $imageRetArray["x"];
$y = $imageRetArray["y"];
$fontsize = $imageRetArray["fontsize"];
$picQuality = $imageRetArray["picQuality"];
$MyAdContent =<<
Gönn dir endlich mal wieder was und geh Shoppen!
Klickt euch bei Amazon rein und gönnt euch endlich mal wieder was. Ihr habt es euch verdient. Als Fan von BuzzerStar solltest Du auch mal wieder an Dich denken - Du bist der wichtigste Mensch der Welt.
END;
if (count($SearchContent) >= 1){
$ReturnHTMLContent =<<
-
END;
$myccount = 0;
$random = rand(0,4);
for ( $ArrayCount=0; $ArrayCount<=4; $ArrayCount++ ) {
list( $headline,$shortcode, $article1 ) = explode('#####', $SearchContent[$ArrayCount] );
$shortcode = trim($shortcode);
$headline = trim($headline);
$article = substr($article1,0,125).' ...';
$articleLink = "https://www.buzzerstar.com/".$this->makeArticleLink($shortcode);
if ( $myccount == 0 ){
$ReturnHTMLContent .= "- ";
}
if ( $myccount == 2 ){
$ReturnHTMLContent .= "
";
$myccount = 0;
}
// if ($random == $ArrayCount){
// $ReturnHTMLContent .= $MyAdContent;
// }
$ReturnHTMLContent .=<<
$headline
$article
END;
} // for ( $ArrayCount=0; $ArrayCount<=count($SearchContent) - 1; $ArrayCount++ ) {
$ReturnHTMLContent .= "
";
$myccount++;
return $ReturnHTMLContent;
} else { // if (count($SearchContent) >= 1){
$config = new Config();
$conn = new Connection();
$pdo = $conn->prepareQuery();
$table = $config->sql_tablename_publish_de();
$stmt1 = $pdo->query("SELECT id FROM $table WHERE id>0 LIMIT 5000;");
$randomMax = $stmt1->rowCount();
$docids = array();
mt_srand ((double)microtime()*1000000);
for ($i=0;$i<=5;$i++){
array_push($docids,mt_rand(1,$randomMax));
}
$SqlQuery = "SELECT p_headline,p_shortcode,p_picture_1_description FROM $table WHERE";
for ($i=0;$i<=count($docids) - 1;$i++){
if ($i>0){
$SqlQuery .= "\"$docids[$i]\",";
} elseif($i<=0){
$SqlQuery .= " `id` IN (\"$docids[$i]\",";
};
};
$SqlQuery = substr($SqlQuery,0,(strlen($SqlQuery)-1));
$SqlQuery .=") AND p_isonline=1 ORDER BY p_timestamp DESC LIMIT 5;";
$stmt2 = $pdo->prepare($SqlQuery); // AND p_online=1
$stmt2->execute();
$ReturnHTMLContent =<<
END;
$myccount = 0;
while($rows = $stmt2->fetch(PDO::FETCH_ASSOC)) {
$headline = $rows["p_headline"];
$shortcode = $rows["p_shortcode"];
$picdescr = $rows["p_picture_1_description"];
$headline_print = substr($headline,0,85).' ...';
//$picdescr_print = substr($picdescr,0,45).' ...';
$articleLink = "https://www.buzzerstar.com/".$this->makeArticleLink($shortcode);
if ( $myccount == 0 ){
$ReturnHTMLContent .= "- ";
}
if ( $myccount == 2 ){
$ReturnHTMLContent .= "
";
$myccount = 0;
}
$myccount++;
$ReturnHTMLContent .=<<
$headline_print
END;
} // while($rows = $stmt2->fetch(PDO::FETCH_ASSOC)) {
$ReturnHTMLContent .= "
";
$stmt = null;
$pdo = null;
return $ReturnHTMLContent;
} // else if count sphinxsearch
}
public function ogTagsYoutubeVideo($string){
if (stripos($string,'&') === TRUE ){
list($string,$tmp) = explode('&',$string);
}
list($yt,$yt_ID) = explode('v=',$string);
//return "https://www.youtube.com/v/$yt_ID?version=3&autohide=1";
return "https://www.youtube.com/embed/$yt_ID";
}
public function buildCategoryLink($id){
$idName = $this->categoryIDtoName($id);
return "https://www.buzzerstar.com/kategorie/".ucfirst($idName);
}
public function categoryIDtoName($category_id){
$config = new Config();
$catg_array = $config->array_category();
if (is_numeric($category_id)){
return $catg_array[$category_id];
} else {
return 1; // fallback
}
}
public function categoryNametoID($category_id){
$config = new Config();
$catg_array = $config->array_category();
if ( !is_numeric($category_id)) {
return array_search(strtolower($category_id),array_map('strtolower',$catg_array));
} else {
return $catg_array[$category_id];
}
}
public function getPostForCategory($id){
$config = new Config();
$conn = new Connection();
$pdo = $conn->prepareQuery();
$table = $config->sql_tablename_publish_de();
$catg_array = $config->array_category();
if ( !is_numeric($id)) {
//$id = array_search($id, $catg_array);
$id = array_search(strtolower($id),array_map('strtolower',$catg_array));
}
$stmt = $pdo->prepare("SELECT * FROM $table WHERE id>0 AND p_isonline=1 AND p_category=:p_category ORDER BY p_timestamp DESC;");
$stmt->bindValue(':p_category', $id, PDO::PARAM_INT);
$stmt->execute();
$retVal = $stmt->rowCount();
$stmt = null; // doing this is mandatory for connection to get closed
$pdo = null;
$stmt = null;
$pdo = null;
if (!is_numeric($retVal)){
return 0;
} else {
return $retVal;
}
}
public function sendmyMail($autor, $headline){
$empfaenger = 'sebastian.enger@gmail.com';
// Betreff
$betreff = 'Neuer Artikel auf BuzzerStar fertig zur Administration '.date("d-m-Y h:i:sa");
// Nachricht
$nachricht =<<
$betreff
Betreff: $betreff
Autor: $autor
Schlagzeile: $headline