Jetzt Amazon Prime 30 Tage kostenlos testen'; $prime_ad_EN = 'Jetzt Amazon Prime 30 Tage kostenlos testen'; $max_ad_results = 2; $current_count = 0; $RelatedMoreContent = ""; $RelatedMoreContent =<<setReturnType(AmazonECS::RETURN_TYPE_ARRAY); //create the amazon object (array) $response = $amazonEcs->category($category)->responseGroup('Small,Images,Offers')->search($search); //check that there are items in the response if (isset($response['Items']['Item']) ) { //loop through each item foreach ($response['Items']['Item'] as $result) { //check that there is a ASIN code - for some reason, some items are not //correctly listed. Im sure there is a reason for it, need to check. if (isset($result['ASIN'])) { //store the ASIN code in case we need it $asin = $result['ASIN']; //check that there is a URL. If not - no need to bother showing //this one as we only want linkable items if (isset($result['DetailPageURL']) && $current_count < $max_ad_results ) { $current_count++; $add_text = ""; $detailurl = $result['DetailPageURL']; $title = $result['ItemAttributes']['Title']; $image = $result['MediumImage']['URL']; $hi = $result['SmallImage']['Height'][_]; $wi = $result['SmallImage']['Width'][_]; $ma = $result['ItemAttributes']['Manufacturer']; $pg = $result['ItemAttributes']['ProductGroup']; $lp = $result['OfferSummary']['LowestUsedPrice']['FormattedPrice']; $lnp = $result['OfferSummary']['LowestNewPrice']['FormattedPrice']; $pr = $result['Offer']['OfferListing']['IsEligibleForPrime']; $pr_sav = $result['Offer']['OfferListing']['PercentageSaved']; if (strlen($lp) <= 1){ $lp = $lnp; } if ($pr == 1){ $add_text = "- als Prime Kunde profitierst du von $pr_sav Prozent Ersparnis!"; } $title_amp = $this->clear_description($title); if (strlen($image) >= 10 && strlen($hi) >=2 && strlen($wi) >=2){ $RelatedMoreContent .=<<
$title_amp ($pg von $ma für $lp $add_text)
END; } // if (strlen($image) >= 10 && strlen($hi) >=2 && strlen($wi) >=2){ } // if (isset($result['DetailPageURL']) } // if (isset($result['ASIN'])) { } // foreach ($response['Items']['Item'] as $result) { } else { //display that nothing was found - should no results be found //echo "

No Amazon suggestions found

"; } // return $RelatedMoreContent; } // public function getAmazonContentAMP($search){ public function getAmazonContent($search){ return 1; $prime_ad_DE = 'Jetzt Amazon Prime 30 Tage kostenlos testen'; $prime_ad_EN = 'Try Amazon Prime 30 days completly free of charge (Amazon Video, Music, Delivery)'; $max_ad_results = 3; $current_count = 0; $RelatedMoreContent = ""; $RelatedMoreContent =<< $prime_ad_EN END; /* //set up a container for the details - this could be a DIV echo "

"; //create the URL link echo ""; //if there is a small image - show it if (isset($result['MediumImage']['URL'] )) { echo ""; } //$result['MediumImage']['Height'] //$result['MediumImage']['Width'] //$result['ItemAttributes']['Manufacturer'] //$result['ItemAttributes']['ProductGroup'] //$result['LowestUsedPrice']['FormattedPrice'] // if there is a title - show it if (isset($result['ItemAttributes']['Title'])) { echo $result['ItemAttributes']['Title'] . "
"; } //close the paragraph echo "

"; */ } } } } else { //display that nothing was found - should no results be found //echo "

No Amazon suggestions found

"; } // $RelatedMoreContent .=<< END; return $RelatedMoreContent; } // public function getAmazonContent($search){ public function pushPictureToKeyCDN($shortcode){ $config = new Config(); $cdn_ftpusername = $config->cdn_ftpusername(); $cdn_ftppassword = $config->cdn_ftppassword(); $cdn_ftppath = $config->cdn_ftppath(); $cdn_ftpserver = $config->cdn_ftpserver(); //$ftp = new FTP($cdn_ftpusername, $cdn_ftppassword, $cdn_ftpserver, $cdn_ftppath); $pictureUri = "https://cdn.onetopp.com/image/$shortcode.png"; $filename = "/tmp/$shortcode.png"; unlink($filename); //echo "Downloading image to cdn.buzzerstar.com\n
"; $f = @fopen($filename, 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $pictureUri); curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,50); curl_setopt($ch, CURLOPT_USERAGENT, "cdn.buzzerstar.com Image Loader v0.1"); 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 Function - pushPictureToKeyCDN() -> error:' . curl_error($ch); echo "Error Downloading : ^$pictureUri^
"; } curl_close($ch); fclose($f); //echo "PNGCrush Image to cdn.buzzerstar.com\n
"; exec("/usr/local/bin/pngquant --quality=65-88 --speed 1 $filename -o $filename --force"); chmod($filename, 0755); //echo "FTP Upload to cdn: $cdn_ftppath/$shortcode.png this file: $filename\n
"; //$ftp->upload("$cdn_ftppath/$shortcode.png",$filename); $conn_id = ftp_connect($cdn_ftpserver); // Login mit Benutzername und Passwort $login_result = ftp_login($conn_id, $cdn_ftpusername, $cdn_ftppassword); // Datei hochladen ftp_chdir($conn_id, $cdn_ftppath); if (ftp_put($conn_id, "$shortcode.png", $filename, FTP_BINARY)) { // echo "$filename erfolgreich hochgeladen\n"; } else { echo "Ein Fehler trat beim Hochladen von $filename auf -> Manuell auf CDN kopieren : $pictureUri
\n"; } //var_dump($conn_id); // Verbindung schließen ftp_close($conn_id); return 1; } /** * Simple PHP function to split text by given number of sentences with given length each. * * @param string $long_string String of text * @param int $max_length Maximum length of each sentence. Default: 150 * @param int $max_sentences Maximum number of sentences to return. Default: 10 * @param string $encoding Encoding of input string. Default: 'UTF-8' * * @return array */ public function text_to_sentences($long_string, $max_length = 150, $max_sentences = 2, $encoding = 'UTF-8'){ // If total string length less than given max length of sentence - // returns array of this string. $string_length = mb_strlen($long_string, $encoding); if ($string_length <= $max_length) { return [$long_string]; } // If string contains only one word - // returns array of this word. $words_array = explode(' ', $long_string); //array_push($words_array,"..."); if (count($words_array) < 2) { return $words_array; } // If length of the first word of string is greater than given max length of sentence - // cuts length of word down to max length and returns array of this word. $first_word = $words_array[0]; if (mb_strlen($first_word, $encoding) > $max_length) { return [mb_substr($first_word, 0, $max_length, $encoding)]; } $sentences_array = []; $ended_word = 0; // Gathers sentences for ($sentence = 0; $sentence < $max_sentences; $sentence++) { $short_string = ''; foreach ($words_array as $word_number => $current_word) { $expected_length = mb_strlen($short_string . ' ' . $current_word, $encoding); if ($expected_length > $max_length) { break; } $short_string .= $current_word . ' '; $ended_word = $word_number + 1; } $sentences_array[] = $short_string; $words_array = array_slice($words_array, $ended_word); if (!$words_array) { break; } } // Returns array of sentences return $sentences_array; } public function getJavaScriptInlineContent(){ $buffer = ""; $buffer .= file_get_contents("/home/www/wwwbuzzerstar/js-new/jquery-buzzerstar2016.js"); // return ""; } public function getDeepLinkContent(){#new return; $RelatedMoreContent = ""; $ResultsArray = array(); $RelatedMoreContent =<<
END; 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){ return; $search = new Search(); $SearchContent = $search->SphinxSearch( $searchInputFromShowPHP ); //echo "Sphinx in: $searchInputFromShowPHP"; //print_r($SearchContent); $re = '/# Split sentences on whitespace between them. (?<= # Begin positive lookbehind. [.!?] # Either an end of sentence punct, | [.!?][\'"] # or end of sentence punct and quote. ) # End positive lookbehind. (? END; return $RelatedMoreContent; } public function getIndexNewInlineCSS(){ $css = new Minifier(); $buffer = ""; $buffer .= file_get_contents("/home/www/blog.onetop.com/cssv3/main.min.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 ""; } //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 = 55; if (strpos($startpage, '1') !== FALSE){ $x = 320; $y = 260; $xImage = 320; $yImage = 260; $fontsize = 9; $picQuality = 35; } elseif (strpos($startpage, '2') !== FALSE){ $x = 60; $y = 75; $xImage = 60; $yImage = 75; $fontsize = 7; $picQuality = 35; } elseif ($deviceTypeTablet === TRUE){ // we have a tablet device $x = 540; $y = 320; $xImage = 460; $yImage = 320; $fontsize = 12; $picQuality = 45; } elseif ($deviceTypeMobile === TRUE){ // we have a mobile device $x = 320; $y = 260; $xImage = 420; $yImage = 360; $fontsize = 10; $picQuality = 41; } else { // we have a desktop device $x = 640; $y = 480; $xImage = 620; $yImage = 480; /* $xImage = 540; $yImage = 430; */ $fontsize = 15; $picQuality = 53; } /* 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}\""; } $parse = parse_url($str); $str = ' ' . $str; $domainname = $parse['host']; $str = preg_replace( '`([^"=\'>])((http|https|ftp|mailto)://[^\s<]+[^\s<\.)])`i', '$1[Link: $domainname]", $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 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://blog.onetopp.com/trends/".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){ $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 = trim($rows[0]["p_headline"]); $p_headline = preg_replace('/\s{1,}-\s{1,}/', ' ', trim($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){ return "en"; } public function file_put_contents_atomic($filename, $content) { define("FILE_PUT_CONTENTS_ATOMIC_TEMP", dirname(__FILE__)."/cache"); define("FILE_PUT_CONTENTS_ATOMIC_MODE", 0777); if (!is_dir(FILE_PUT_CONTENTS_ATOMIC_TEMP)) { mkdir( FILE_PUT_CONTENTS_ATOMIC_TEMP, 0777, 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; } */ } // HTML Minifier public function minify_html($input) { if(trim($input) === "") return $input; // Remove extra white-spaces between HTML attributes $input = preg_replace_callback('#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#s', function($matches) { return '<' . $matches[1] . preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; }, $input); // Minify inline CSS declarations if(strpos($input, ' style=') !== false) { $input = preg_replace_callback('#\s+style=([\'"]?)(.*?)\1(?=[\/\s>])#s', function($matches) { return ' style=' . $matches[1] . minify_css($matches[2]) . $matches[1]; }, $input); } return preg_replace( array( // Remove HTML comments except IE comments '#\s*(<\!--(?=\[if).*?-->)\s*|\s*<\!--.*?-->\s*#s', // Do not remove white-space after image and // input tag that is followed by a tag open '#(<(?:img|input)(?:\/?>|\s[^<>]*?\/?>))\s+(?=\<[^\/])#s', // Remove two or more white-spaces between tags '#(<\!--.*?-->)|(>)\s{2,}|\s{2,}(<)|(>)\s{2,}(<)#s', // Proofing ... // o: tag open, c: tag close, t: text // If ` ` remove white-space // If ` ` keep white-space // If ` ` remove white-space // If ` ` remove white-space // If ` ...` remove white-spaces // If ` ...` remove white-spaces // If ` ...` remove white-spaces // If ` ...` remove white-spaces // If `abc ` keep white-space // If ` abc` remove white-space // If `abc ` remove white-space // If ` abc` keep white-space // TODO: If `abc ...` keep one white-space // If ` ...abc` remove white-spaces // If `abc ...` remove white-spaces // TODO: If ` ...abc` keep one white-space '#(<\!--.*?-->)|(<(?:img|input)(?:\/?>|\s[^<>]*?\/?>))\s+(?!\<\/)#s', // o+t | o+o '#(<\!--.*?-->)|(<[^\/\s<>]+(?:>|\s[^<>]*?>))\s+(?=\<[^\/])#s', // o+o '#(<\!--.*?-->)|(<\/[^\/\s<>]+?>)\s+(?=\<\/)#s', // c+c '#(<\!--.*?-->)|(<([^\/\s<>]+)(?:>|\s[^<>]*?>))\s+(<\/\3>)#s', // o+c '#(<\!--.*?-->)|(<[^\/\s<>]+(?:>|\s[^<>]*?>))\s+(?!\<)#s', // o+t '#(<\!--.*?-->)|(?!\>)\s+(<\/[^\/\s<>]+?>)#s', // t+c '#(<\!--.*?-->)|(?!\>)\s+(?=\<[^\/])#s', // t+o '#(<\!--.*?-->)|(<\/[^\/\s<>]+?>)\s+(?!\<)#s', // c+t '#(<\!--.*?-->)|(\/>)\s+(?!\<)#', // o+t // Replace `   ` with `   ` '#(?<= )( ){2}#', // Proofing ... '#(?<=\>) (?!\s| |<\/)#', '#(?<=--\>)(?:\s| )+(?=\<)#' ), array( '$1', '$1 ', '$1$2$3$4$5', '$1$2 ', // o+t | o+o '$1$2', // o+o '$1$2', //c+c '$1$2$4', // o+c '$1$2', // o+t '$1$2', // t+c '$1$2 ', // t+o '$1$2 ', // c+t '$1$2 ', // o+t ' $1', ' ', "" ), trim($input)); } // CSS Minifier => http://ideone.com/Q5USEF + improvement(s) public function minify_css($input) { if(trim($input) === "") return $input; return preg_replace( array( // Remove comments '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)#s', // Remove unused white-spaces '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~+]|\s*+-(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` '#(?<=[:\s])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', // Replace `:0 0 0 0` with `:0` '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', // Replace `background-position:0` with `background-position:0 0` '#(background-position):0(?=[;\}])#si', // Replace `0.6` with `.6`, but only when preceded by `:`, `-`, `,` or a white-space '#(?<=[:\-,\s])0+\.(\d+)#s', // Minify string value '#(\/\*(?>.*?\*\/))|(?.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', // Minify HEX color code '#(?<=[:\-,\s]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', // Remove empty selectors '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' ), array( '$1', '$1$2$3$4$5$6$7', '$1', ':0', '$1:0 0', '.$1', '$1$3', '$1$2$4$5', '$1$2$3', '$1$2' ), trim($input)); } // JavaScript Minifier public function minify_js($input) { if(trim($input) === "") return $input; return preg_replace( array( // '#(?[\s\S]*?\*\/)\s*|\s*(?.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\.,;]|[gimuy]))|\s*([+\-\=\/%\(\)\{\}\[\]<>\|&\?\!\:;\.,])\s*#s', // Remove the last semicolon '#;+\}#', // Replace `true` with `!0` // '#\btrue\b#', // Replace `false` with `!1` // '#\bfalse\b#', // Minify object attribute except JSON attribute. From `{'foo':'bar'}` to `{foo:'bar'}` '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', // --ibid. From `foo['bar']` to `foo.bar` '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' ), array( // '\\u0022', // '\\u0027', '$1', '$1$2', '}', // '!0', // '!1', '$1$3', '$1.$3' ), trim($input)); } } ?>