I found another great widget, which displays a random Apple Movie trailer, complete with movie poster.
Sadly, I ran into exactly the same problem that I did with the APOD widget - use of url file access functions is strictly verboten on my web host. So, here is the modded version of the widget to use cURL:
<?php
/*
Plugin Name: Apple Trailer Sidebar Widget
Description: Adds a sidebar widget that shows the latest movie trailers from apple.com
Author: Patrick Queisler
Version: 1.1
Author URI: <a href="http://www.sosuechtig.de</p>
<p>Version" title="http://www.sosuechtig.de</p>
<p>Version">http://www.sosuechtig.de</p>
<p>Version</p></a> 1.1 - Erich Beyrent [http://www.beyrent.net]: added cURL functions to fetch the data from Apple
*/
function widget_appletrailer_init() {
if ( !function_exists('register_sidebar_widget') )
return;
function widget_appletrailer($args) {
extract($args);
$options = get_option('widget_appletrailer');
$title = $options['title'];
echo $before_widget . $before_title . $title . $after_title;
function appledotcom_parser(){
$myfile = '';
$lines = <a href="http://twitter.com/file">@file</a>("http://wdirect.apple.com/trailers/home/externalA.js");
if($lines)
{
foreach ($lines as $line_num=> $line)
{
$myfile .= stripslashes($line);
}
}
else
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://wdirect.apple.com/trailers/home/externalA.js");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$myfile = curl_exec($ch);
curl_close ($ch);
}
$out = eregi_replace("href=\"/trailers/","target=\"_blank\" href=\"http://www.apple.com/trailers/",$myfile);
return $out;
}
function get_trailer(){
echo "<center><script language=\"JavaScript\" type=\"text/javascript\">";
echo appledotcom_parser();
echo "loadRandomD();
</script></center>";
}
get_trailer();
echo $after_widget;
}
function widget_appletrailer_control() {
$options = get_option('widget_appletrailer');
if ( !is_array($options) )
$options = array('title'=>'');
if ( $_POST['appletrailer-submit'] ) {
$options['title'] = strip_tags(stripslashes($_POST['appletrailer-title']));
update_option('widget_appletrailer', $options);
}
$title = htmlspecialchars($options['title'], ENT_QUOTES);
echo '<p style="text-align:right;"><label for="appletrailer-title">Title: <input style="width: 200px;" id="appletrailer-title" name="appletrailer-title" type="text" value="'.$title.'" /></label></p>';
echo '<input type="hidden" id="appletrailer-submit" name="appletrailer-submit" value="1" />';
}
register_sidebar_widget('Apple Trailer', 'widget_appletrailer');
register_widget_control('Apple Trailer', 'widget_appletrailer_control', 300, 100);
}
add_action('plugins_loaded', 'widget_appletrailer_init');
?>
Apple, beyrent, curl, movie, php, plugin, security, trailers, widget, wordpress, Apple, curl, movie, php, plugin, security, trailers, widget, wordpress
Recent comments
18 hours 36 min ago
1 week 6 days ago
1 week 6 days ago
1 week 6 days ago
1 week 6 days ago
1 week 6 days ago
2 weeks 1 day ago
4 weeks 1 day ago
10 weeks 3 days ago
16 weeks 6 days ago