Generated by WP YouTube Lyte' ); } return true; } function lyte_str_ends_in($haystack,$needle) { $needleLength = strlen($needle); $haystackLength = strlen($haystack); $lastPos=strrpos($haystack,$needle); if ($lastPos === $haystackLength - $needleLength) { return true; } else { return false; } } function lyte_get_thumb($thumbUrl) { global $lyte_thumb_error; if (function_exists("curl_init")) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $thumbUrl); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); $str = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ( !$err && $str != "" ) { return $str; } else { $lyte_thumb_error .= "curl err: ".$err."/ "; } } else { $lyte_thumb_error .= "no curl/ "; } // if no curl or if curl error $resp = file_get_contents($thumbUrl); return $resp; } function lyte_thumb_fallback() { global $origThumbURL, $lyte_thumb_error, $lyte_thumb_report_err; // if for any reason we can't show a local thumbnail, we redirect to the original one if ( strpos( $origThumbURL, "http" ) !== 0) { $origThumbURL = "https:".$origThumbURL; } if ( $lyte_thumb_report_err ) { header('X-lyte-error: '.$lyte_thumb_error); } header('HTTP/1.1 301 Moved Permanently'); header('Location: '. $origThumbURL ); }