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 .=<< $p_title 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 .=<<

$headline
$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 .=<<

$pic_desc
$rand_f1:$rand_f2

$headline

$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 =<<

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 .=<< $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 .=<< 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


END; $header = 'MIME-Version: 1.0' . "\r\n"; $header .= 'Content-type: text/html; charset=utf-8' . "\r\n"; // zusätzliche Header $header .= 'To: Sebastian Enger '. "\r\n"; $header .= 'From: BuzzerStar-New Article ' . "\r\n"; // verschicke die E-Mail mail($empfaenger, $betreff, $nachricht, $header); } // public function sendmail($autor, $headline){ public function getDuration(){ $minute = rand(1,6); $seconds = rand(10,60); return "PT".$minute."M".$seconds."S"; } public function makeArticleLink($shortcode){ // $search = array('https://www.heftig.co/', 'http://www.heftig.co/', 'https://heftig.co/', 'http://heftig.co/', 'http://','https://','http://','heftig.co','www','/' ); // $replace = array('', '', '', '', '','', '', '', '', ''); $config = new Config(); $conn = new Connection(); $pdo = $conn->prepareQuery(); $table = $config->sql_tablename_publish_de(); $stmt = $pdo->prepare("SELECT p_headline FROM $table WHERE p_shortcode=:shortcode AND p_isonline='1' LIMIT 1"); // AND $stmt->bindValue(':shortcode', $shortcode, PDO::PARAM_STR); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); // $p_headline = str_ireplace($search, $replace, trim($rows[0]["p_canonical"])); $p_headline = preg_replace('/\s{1,}-\s{1,}/', ' ', trim($rows[0]["p_headline"])); //$p_headline = str_replace('-','',$p_headline); $words = implode(' ', array_slice(explode(' ', $p_headline), 0, 18)); $words = str_replace(array('ä','ö','ü','ß','Ä','Ö','Ü','-'),array('ae','oe','ue','ss','Ae','Oe','Ue',''),$words); $words = trim($words); $words = str_replace(' ','-',$words); $words = strtolower(preg_replace('/[^a-zA-Z0-9-]/', '', trim($words))); $stmt = null; // doing this is mandatory for connection to get closed $pdo = null; return "$words-$shortcode.html"; } public function GetLanguageFromString($string){ /* try{ $l = new Text_LanguageDetect(); $l->setNameMode(2); //return 2-letter language codes only $result = $l->detect($string, 4); //return array_keys(strtolower($result[0])); $ret = array_keys($result)[0]; return strtolower($ret); //print_r($result) ; } catch (Text_LanguageDetect_Exception $e) { } */ return "de"; } public function file_put_contents_atomic($filename, $content) { define("FILE_PUT_CONTENTS_ATOMIC_TEMP", dirname(__FILE__)."/cache"); define("FILE_PUT_CONTENTS_ATOMIC_MODE", 0755); if (!is_dir(FILE_PUT_CONTENTS_ATOMIC_TEMP)) { mkdir( FILE_PUT_CONTENTS_ATOMIC_TEMP, 0755, true ); } $temp = tempnam(FILE_PUT_CONTENTS_ATOMIC_TEMP, 'temp'); if (!($f = @fopen($temp, 'w'))) { $temp = FILE_PUT_CONTENTS_ATOMIC_TEMP . DIRECTORY_SEPARATOR . uniqid('temp'); if (!($f = @fopen($temp, 'w'))) { trigger_error("file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING); return false; } } fwrite($f, $content); fclose($f); if (!rename($temp, $filename)) { unlink($filename); rename($temp, $filename); } chmod($filename, FILE_PUT_CONTENTS_ATOMIC_MODE); return true; } public function randomString(){ $internLength = 1024; $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $str = ""; for ($i = 0; $i < $internLength; $i++) { $str .= $chars[mt_rand(0, strlen($chars) - 1)]; } return md5(uniqid(rand(), true).$str.mt_rand()); } public function uniqueID($in){ $config = new Config(); //set the random id length $random_id_length = $config->max_unique_id(); $chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $md5c = md5($in); $c = uniqid(rand(), true); //generate a random id encrypt it and store it in $rnd_id $rnd_id = md5(uniqid(rand(),true).mt_rand(0, strlen($chars) - 1).$chars.$in.$md5c.$c.time()); //to remove any slashes that might have come $rnd_id = strip_tags(stripslashes($rnd_id)); //Removing any . or / and reversing the string $rnd_id = str_replace(".","",$rnd_id); $rnd_id = strrev(str_replace("/","",$rnd_id)); //finally I take the first $random_id_length characters from the $rnd_id return substr($rnd_id,0,$random_id_length); } public function alphaID($in, $to_num = false, $pad_up = false, $pass_key_in){ $out = ''; $index = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $base = strlen($index); if ($pass_key_in !== null) { // Although this function's purpose is to just make the // ID short - and not so much secure, // with this patch by Simon Franz (http://blog.snaky.org/) // you can optionally supply a password to make it harder // to calculate the corresponding numeric ID for ($n = 0; $n < strlen($index); $n++) { $i[] = substr($index, $n, 1); } $pass_hash = hash('sha512',$pass_key_in); $pass_hash = (strlen($pass_hash) < strlen($index) ? hash('sha512', $pass_key) : $pass_hash); for ($n = 0; $n < strlen($index); $n++) { $p[] = substr($pass_hash, $n, 1); } array_multisort($p, SORT_DESC, $i); $index = implode($i); } if ($to_num) { // Digital number <<-- alphabet letter code $len = strlen($in) - 1; for ($t = $len; $t >= 0; $t--) { $bcp = bcpow($base, $len - $t); $out = $out + strpos($index, substr($in, $t, 1)) * $bcp; } if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $out -= pow($base, $pad_up); } } } else { // Digital number -->> alphabet letter code if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $in += pow($base, $pad_up); } } for ($t = ($in != 0 ? floor(log($in, $base)) : 0); $t >= 0; $t--) { $bcp = bcpow($base, $t); $a = floor($in / $bcp) % $base; $out = $out . substr($index, $a, 1); $in = $in - ($a * $bcp); } } return strtolower($out); } public function stripHtml($string){ $config = new Config(); $sql_code = array ( 'SELECT', 'UPDATE', 'DELETE', 'INSERT', 'VALUES', 'FROM', 'LEFT', 'JOIN', 'WHERE', 'LIMIT', 'ORDER BY', 'DESC' ); $content = strip_tags($string,$config->allow_content_tags()); //$content = preg_replace('/<[^>]*>/', '', $content); $content = str_ireplace($sql_code,'',$content); return trim($content); } public function isVideoLink($string){ $video_title = ""; $SSDTube = new SSDTube(); $SSDTube->identify($string); $video_title = $SSDTube->title; if ( strlen($video_title)>=5||preg_match('/(\w{5,})/ig',$video_title)){ return 1; } else { return 0; } //$regYoutube = "/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/i"; //$regYoutube = "/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/"; //$regVimeo = "/^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/"; //$regDailymotion = "/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/"; //$regMetacafe = "/^.*(metacafe\.com)(\/watch\/)(\d+)(.*)/i"; /* if (preg_match($regYoutube,$string) ){ return 1; } else { return 0; } */ } /** * Replace accented characters with non accented * * @param $str * @return mixed * @link http://myshadowself.com/coding/php-function-to-convert-accented-characters-to-their-non-accented-equivalant/ */ function removeAccents($str) { /* error_reporting(E_ALL); ini_set('display_errors', 1); echo "HTML ENTETIES: " . htmlentities($str, ENT_COMPAT, 'UTF-8') . "



"; if (preg_match('/(ä|ü|ö|ß)/i', htmlentities($str, ENT_COMPAT, 'UTF-8'))) { echo 'Filename contains umlauts: '; } */ //$clean1 = mb_convert_encoding($str, 'ISO-8859-1','UTF-8'); $clean1 = mb_convert_encoding($str, 'UTF-8'); $clean2 = filter_var($clean1, FILTER_SANITIZE_STRING); //return preg_replace('/[^A-Za-z0-9 _\-\+\&\.\?\,\;öäüß]/iu','', $clean2 ); //reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? $some_string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. '|[\x00-\x7F][\x80-\xBF]+'. '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', '',$clean2 ); //reject overly long 3 byte sequences and UTF-16 surrogates and replace with ? $some_string2 = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. '|\xED[\xA0-\xBF][\x80-\xBF]/S','', $some_string ); return $some_string2; /* $strAAA = $this->valid_utf8_bytes($str); print_r($strAAA); return preg_replace('/[^\pL\pN\pP\pS\pZ]/u', '', $strAAA); */ } function valid_utf8_bytes($str) { $return = ''; $length = strlen($str); $invalid = array_flip(array("\xEF\xBF\xBF" /* U-FFFF */, "\xEF\xBF\xBE" /* U-FFFE */)); for ($i=0; $i < $length; $i++) { $c = ord($str[$o=$i]); if ($c < 0x80) $n=0; # 0bbbbbbb elseif (($c & 0xE0) === 0xC0) $n=1; # 110bbbbb elseif (($c & 0xF0) === 0xE0) $n=2; # 1110bbbb elseif (($c & 0xF8) === 0xF0) $n=3; # 11110bbb elseif (($c & 0xFC) === 0xF8) $n=4; # 111110bb else continue; # Does not match for ($j=++$n; --$j;) # n bytes matching 10bbbbbb follow ? if ((++$i === $length) || ((ord($str[$i]) & 0xC0) != 0x80)) continue 2 ; $match = substr($str, $o, $n); if ($n === 3 && isset($invalid[$match])) # test invalid sequences continue; $return .= $match; } return $return; } } ?>