<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentarios en: WiiCR, convierte tu Wii en un Media Center</title>
	<atom:link href="http://laventanamuerta.net/wiicr-convierte-tu-wii-en-un-media-center/feed/" rel="self" type="application/rss+xml" />
	<link>http://laventanamuerta.net/wiicr-convierte-tu-wii-en-un-media-center/</link>
	<description>GNU/Linux y Software Libre para el día a día.</description>
	<lastBuildDate>Sat, 19 May 2012 16:53:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>Por: Rubia</title>
		<link>http://laventanamuerta.net/wiicr-convierte-tu-wii-en-un-media-center/comment-page-1/#comment-12538</link>
		<dc:creator>Rubia</dc:creator>
		<pubDate>Sat, 20 Nov 2010 22:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://laventanamuerta.net/wiicr-convierte-tu-wii-en-un-media-center/#comment-12538</guid>
		<description>e echo todo hasta el final y me sale esto nose si sera lo normal...



#!/usr/bin/perl

# license = gpl
# author = jacob jarick, mem.namefix@gmail.com , mem on #wiidev @ efnet

#--------------------------------------------------------------------------------------------------------------
# includes
#--------------------------------------------------------------------------------------------------------------

use CGI qw /:standard -nosticky/;
use Cwd;
use warnings;
use File::Copy;
use FindBin;


#--------------------------------------------------------------------------------------------------------------
# variables
#--------------------------------------------------------------------------------------------------------------

our $dir = $0;

$dir =~ s/\\/\//g;
$dir =~ s/^(.*)\/(.*?)$/$1/;

our %conf = &amp;read_config();
our $theme = $conf{&#039;theme&#039;};

do &quot;$dir/config.pl&quot; or die &quot;ERROR: couldnt load $dir/config.pl&quot;;


$version = &quot;0.3a&quot;;
$wd	= cwd();
$i_wd	= $wd; 		# inital wd, needed for memcoder etc

$mf_ext = &quot;avi&#124;mpeg&#124;mpg&#124;mov&#124;flv&#124;dat&#124;asf&#124;wmv&#124;mp4&#124;ogm&#124;mkv&#124;vob&quot;;

$file 		= param(&#039;file&#039;);
$name		= param(&#039;name&#039;);
$action 		= param(&#039;action&#039;);
$our_wd		= param(&#039;our_wd&#039;);
$new_theme	= param(&#039;theme&#039;);

$ico_pic 	= &quot;$theme_dir/ico_img.png&quot;;
$ico_mp3 	= &quot;$theme_dir/ico_mp3.png&quot;;
$ico_vid 	= &quot;$theme_dir/ico_vid.png&quot;;
$ico_zip 	= &quot;$theme_dir/ico_zip.png&quot;;
$ico_dir 	= &quot;$theme_dir/ico_dir.png&quot;;
$ico_txt 	= &quot;$theme_dir/ico_txt.png&quot;;
$ico_home	= &quot;$theme_dir/ico_home.png&quot;;
$ico_up		= &quot;$theme_dir/ico_up.png&quot;;
$ico_bin		= &quot;$theme_dir/ico_bin.png&quot;;
$ico_play	= &quot;$theme_dir/ico_play.png&quot;;
$ico_del		= &quot;$theme_dir/ico_del.png&quot;;
$ico_config	= &quot;$theme_dir/ico_config.png&quot;;
$ico_links	= &quot;$theme_dir/ico_links.png&quot;;
$ico_forward	= &quot;$theme_dir/ico_fwd.png&quot;;
$ico_back	= &quot;$theme_dir/ico_back.png&quot;;
$ico_flash	= &quot;$theme_dir/ico_flash.png&quot;;
$background	= &quot;$theme_dir/background.jpg&quot;;

our @drives_data = ();
our @table_data = ();
our @info = ();
our @html = &amp;readf(&quot;$theme_local_dir/main.html&quot;);

$date = localtime(time());


#--------------------------------------------------------------------------------------------------------------
# code
#--------------------------------------------------------------------------------------------------------------

print &quot;Content-type: text/html\n\n&quot;;

if($our_wd)
{
	chdir $our_wd;
	$wd = $our_wd;
}
else
{
	$our_wd = cwd;
}

#--------------------------------------------------------------------------------------------------------------
# get drives data ready.

@drives_data = &amp;readf(&quot;$tpl_local_dir/drives_header.tpl&quot;);
@tmp = &amp;readf(&quot;$tpl_local_dir/drives_body.tpl&quot;);

for $d(@drives)
{
	@tmp2 = @tmp;
	for $line(@tmp2)
	{
		$line =~ s/&lt;&gt;/$d/ig;
		push @drives_data, $line;
	}
}
push @drives_data, &amp;readf(&quot;$tpl_local_dir/drives_footer.tpl&quot;);

#--------------------------------------------------------------------------------------------------------------
# get link_buttons data ready.

my @link_buttons = &amp;readf(&quot;$tpl_local_dir/link_buttons.tpl&quot;);
for(@link_buttons)
{
	s/&lt;&gt;/$theme_dir/ig;
	s/&lt;&gt;/$cgi_dir/ig;
	s/&lt;&gt;/$wiicr_dir/ig;
}

#$vars_data = &quot;&lt;!-- VARS \n\$file = $file\n\$action = $action\n\$our_wd = $our_wd\n--&gt;\n&quot;;

#--------------------------------------------------------------------------------------------------------------
# respond to cgi requests

if(!$action)
{
	@info = &amp;lsdir;
}

elsif($action eq &quot;favs&quot;)
{
	@info = &amp;readf(&quot;$tpl_local_dir/favs_header.tpl&quot;);
	@favs = &amp;readf(&quot;$favourites&quot;);
	@tmp = &amp;readf(&quot;$tpl_local_dir/favs_body.tpl&quot;);
	for(@favs)
	{
		chomp;
		@tmp2 = @tmp;
		($name, $file) = split(/\t+/);
		for(@tmp2)
		{
			s/&lt;&gt;/$file/ig;
			s/&lt;&gt;/$name/ig;
			s/&lt;&gt;/$ico_dir/ig;
		}
		push @info, @tmp2;
	}
	push @info, &amp;readf(&quot;$tpl_local_dir/favs_footer.tpl&quot;);
}

elsif($action eq &quot;vidplay&quot;)
{
	$count = param(&#039;count&#039;);
	$count++;
	$file = &quot;$count&quot;.&quot;default.flv&quot;;
	$tmpdur = $duration + $refresh_delay;
	
	if(! -f &quot;$flv_local_dir/$file&quot;)
	{
		@info = &amp;readf(&quot;$tpl_local_dir/error.tpl&quot;);
		for(@info)
		{
			$tmp = &quot;video file: $file doesnt existAssuming Video Ended.&quot;;
			s/&lt;&gt;/$tmp/ig;
		}
	}
	else
	{
		@info = &amp;readf(&quot;$tpl_local_dir/vidplay.tpl&quot;);
		for(@info)
		{
			s/&lt;&gt;/$cgi_dir/ig;
			s/&lt;&gt;/$file/ig;
			s/&lt;&gt;/$count/ig;
			s/&lt;&gt;/$tmpdur/ig;
			s/&lt;&gt;/$theme_dir/ig;
			s/&lt;&gt;/@link_buttons/ig;
		}
		print @info;
		exit 1;
	}
}

elsif($action =~ /^vidiframe/i)
{
	my $count = $action;
	$count =~ s/^vidiframe//;
	print &quot;\$count = $count&quot;;
	$count++;
	print &quot;\$count = $count&quot;;
	$file = &quot;$count&quot;.&quot;default.flv&quot;;
	$tmpdur = $duration + $refresh_delay;

	@info = &amp;readf(&quot;$tpl_local_dir/vidiframe.tpl&quot;);

	if(! -f &quot;$flv_local_dir/$file&quot;)
	{
		@info = &amp;readf(&quot;$tpl_local_dir/error.tpl&quot;);
		for(@info)
		{
			$tmp = &quot;video file: $file doesnt existAssuming Video Ended.&quot;;
			s/&lt;&gt;/$tmp/ig;
		}
	}
	else
	{
		print &quot;$file = $file$count&quot;;
		@info = &amp;readf(&quot;$tpl_local_dir/vidiframe.tpl&quot;);
		for(@info)
		{
			s/&lt;&gt;/$cgi_dir/ig;
			s/&lt;&gt;/$file/ig;
			s/&lt;&gt;/$count/ig;
			s/&lt;&gt;/$tmpdur/ig;
			s/&lt;&gt;/$theme_dir/ig;
		}
		print @info;
		exit 1;
	}
}

elsif($action eq &quot;config&quot;)
{

	@info = &amp;readf(&quot;$tpl_local_dir/config.tpl&quot;);
	@tmp = &amp;read_dir(&quot;$wiicr_local_dir/themes&quot;);
	
	my @combo = (&quot;&quot;);
	for(@tmp)
	{
		if($_ eq &quot;.&quot; &#124;&#124; $_ eq &quot;..&quot;)
		{
			next;
		}
		push @combo, &quot;$_&quot;;
		
	}
	push @combo, &quot;&quot;;
	for(@info)
	{
		s/&lt;&gt;/$cgi_dir/ig;
		s/&lt;&gt;/@combo/ig;
	}
}

elsif($action eq &quot;theme&quot;)
{
	@tmp = &amp;readf(&quot;$wiicr_local_dir/config.dat&quot;);
	open(FILE, &quot;&gt;$wiicr_local_dir/config.dat&quot;) or die &quot;&quot;;
	for(@tmp)
	{
		chomp;
		if(/^theme\s+=/i)
		{
			print FILE &quot;theme = $new_theme\n&quot;;
		}
		else
		{
			print FILE &quot;$_\n&quot;;
		}
	}
	close(FILE);

	@info 		= &amp;readf(&quot;$tpl_local_dir/msg.tpl&quot;);
	@msg 		= (&quot;Changing themes now&quot;);
	$goto_url	= &quot;$cgi_dir/index.pl&quot;;
	
	for(@info)
	{
		s/&lt;&gt;/$goto_url/ig;
		s/&lt;&gt;/@msg/ig;
	}

}

elsif($action eq &quot;pls_del&quot;)
{
	open(FILE, &quot;&gt;$mp3_pls&quot;) or die &quot;&quot;;
	close(FILE);
	open(FILE, &quot;&gt;$mp3_txt&quot;) or die &quot;&quot;;
	close(FILE);

	@info 		= &amp;readf(&quot;$tpl_local_dir/msg.tpl&quot;);
	@msg 		= (&quot;Playlist Cleared, returning to config menu.&quot;);
	$goto_url	= &quot;$cgi_dir/index.pl?action=config&quot;;
	
	for(@info)
	{
		s/&lt;&gt;/$goto_url/ig;
		s/&lt;&gt;/@msg/ig;
	}

}

elsif($action eq &quot;pls_update&quot;)
{
	&amp;update_mp3_pls;
	@info 		= &amp;readf(&quot;$tpl_local_dir/msg.tpl&quot;);
	@msg 		= (&quot;Playlist Updated, returning to config menu.&quot;);
	$goto_url	= &quot;$cgi_dir/index.pl?action=config&quot;;
	
	for(@info)
	{
		s/&lt;&gt;/$goto_url/ig;
		s/&lt;&gt;/@msg/ig;
	}

}

elsif($action eq &quot;jobs_del&quot;)
{
	opendir(DIR, &quot;$work_dir&quot;) or die &quot;couldnt open dir: \&quot;$work_dir\&quot; to read\n&quot;;
	@dir = readdir(DIR);
	close(DIR);
	
	for(@dir)
	{
		if($_ !~ /\.(bat&#124;sh)$/i)
		{
			next;
		}
	}

	@info 		= &amp;readf(&quot;$tpl_local_dir/msg.tpl&quot;);
	@msg 		= (&quot;Jobs cleared, returning to config menu.&quot;);
	$goto_url	= &quot;$cgi_dir/index.pl?action=config&quot;;
	
	for(@info)
	{
		s/&lt;&gt;/$goto_url/ig;
		s/&lt;&gt;/@msg/ig;
	}

}

elsif($action eq &quot;playlist&quot;)
{
	@info = ();
	push @info, &amp;readf(&quot;$tpl_local_dir/playlist_header.tpl&quot;);
	@tmp = &amp;lsmp3dir;
	push @info, @tmp;
	push @info, &amp;readf(&quot;$tpl_local_dir/playlist_footer.tpl&quot;);
}

elsif($action eq &quot;delete&quot;)
{
	@info =  &amp;readf(&quot;$tpl_local_dir/playlist_del.tpl&quot;);
	for(@info)
	{
		s/&lt;&gt;/$name/ig;
		s/&lt;&gt;/$file/ig;
		s/&lt;&gt;/$ico_config/ig;
		s/&lt;&gt;/$cgi_dir/ig;
	}
	@tmp = &amp;readf(&quot;$mp3_txt&quot;);
	open(FILE, &quot;&gt;$mp3_txt&quot;) or die &quot;couldnt open $mp3_txt to update&quot;;

	$c = 0;
	for(@tmp)
	{
		chomp;
		if(/$file$/)
		{
			$c++;
			next;
		}
		if($c != $file)
		{
			print FILE &quot;$_\n&quot;;
		}
	$c++;
	}
	&amp;update_mp3_pls;	
}

elsif($action eq &quot;drive&quot;)
{
	chdir $file;
	chdir &quot;/&quot;;
	$wd = cwd();
	@info = &amp;lsdir;
}

elsif($action eq &quot;file&quot; and -d $file)
{
	chdir $file;
	$wd = cwd();
	@info = &amp;lsdir;
}

elsif($action eq &quot;file&quot; and $file =~ /\.swf$/ig)
{
	@info = &amp;lsdir;

	@info 		= &amp;readf(&quot;$tpl_local_dir/msg.tpl&quot;);
	@msg 		= (&quot;Trying to load $file.&quot;);

	$loc 		= &quot;&quot;;
	$loc 		= &quot;$our_wd/$file&quot;;
	$loc		= CGI::escapeHTML($loc);

	$goto_url	= &quot;$cgi_dir/fileget.php?loc=&quot;.$loc;

	for(@info)
	{
		s/&lt;&gt;/$goto_url/ig;
		s/&lt;&gt;/@msg/ig;
	}
}

elsif($action eq &quot;file&quot; &amp;&amp; -f $file &amp;&amp; $file =~ /\.(txt&#124;bat&#124;ini&#124;nfo)$/i)
{
	@file = &amp;readf(&quot;$file&quot;);
	@info = &amp;readf(&quot;$tpl_local_dir/txt_display.tpl&quot;);
	for(@info)
	{
		s/&lt;&gt;/@file/ig;
	}
	
}

elsif($action eq &quot;links&quot;)
{
	@info = &amp;readf(&quot;$links&quot;);
	for(@info)
	{
		$_ =~ s/^\s*-\s*//;
		$_ =~ s/^b$//i;
		$_ =~ s/(.*)\t+(.*)/&lt;a href=&quot;$2&quot; rel=&quot;nofollow&quot;&gt;$1\n/;
	}
}

elsif($action eq &quot;file&quot; &amp;&amp; -f $file &amp;&amp; $file =~ /\.(jpg&#124;gif&#124;png&#124;jpeg)$/i)
{
	my $loc=&quot;$wd/$file&quot;;
	$loc = CGI::escapeHTML($loc);
	@tmp = &amp;read_dir(&quot;$our_wd&quot;);
	@tmp2 = ();
	for(@tmp)
	{
		if(/\.(jpg&#124;gif&#124;png&#124;jpeg)$/i)
		{
			push @tmp2, $_;
		}
	}
	
	$file_forward = $file_back = $tmp2[0];
	
	$count = 1;
	my $s = scalar @tmp2;
	for(@tmp2)
	{
		if(/^$file$/)
		{
			if($count == $s)
			{
				$file_forward = $tmp2[0];
			}
			else
			{
				$file_forward = $tmp2[($count)];
			}
			if($count == 0)
			{
				$file_back = $tmp2[($s - 1)];
			}
			else
			{
				$file_back = $tmp2[($count - 2)];
			}
		}
		$count++;
	}
	
	@info = &amp;readf(&quot;$tpl_local_dir/pic_display.tpl&quot;);
	for(@info)
	{
		s/&lt;&gt;/$ico_back/ig;
		s/&lt;&gt;/$ico_forward/ig;
		s/&lt;&gt;/$loc/ig;
		s/&lt;&gt;/$our_wd/ig;
		s/&lt;&gt;/$file/ig;
		s/&lt;&gt;/$file_back/ig;
		s/&lt;&gt;/$file_forward/ig;				
	}
	
}

elsif($action eq &quot;file&quot; &amp;&amp; -f $file &amp;&amp; $file =~ /\.(mp3&#124;m3u&#124;pls)$/i)
{
	@info = &amp;readf(&quot;$tpl_local_dir/mp3.tpl&quot;);
	for(@info)
	{
		s/&lt;&gt;/$theme_dir/ig;
		s/&lt;&gt;/$ico_play/ig;
	}

	if($file =~ /mp3$/i)
	{
		$t = &quot;$our_wd\/$file\n&quot;;
	}
	else
	{	# assuming playlist
	
		$t = &quot;&quot;;
		@tmp = &amp;readf(&quot;$our_wd/$file&quot;);
		chomp (@tmp);
		if($file =~ /\.m3u$/i)
		{
			for (@tmp)
			{
				if(/^#/)
				{
					next;
				}
				s/\\/\//g;
				if(!/^(\/&#124;\w:)/)
				{
					$_ = &quot;$our_wd/$_&quot;;
				}
				$t .= &quot;$_\n&quot;;
			}
		}
		else
		{
			# assume pls
			$t = &quot;&quot;;
			for(@tmp)
			{
				if(!/^File/i)
				{
					next;
				}
				s/\\/\//g;
				s/^File\d+\=//ig;
						
				print &quot;&lt;!-- $_ --&gt;\n&quot;;	
				if(!/^(\/&#124;\w:)/i)
				{
					$_ = &quot;$our_wd/$_&quot;;
				}
				$t .= &quot;$_\n&quot;;
			}
		}
	}

	open(FILE, &quot;&gt;&gt;$mp3_txt&quot;) or die &quot;ERROR couldnt open $mp3_txt&quot;;
	print FILE $t;
	close(FILE);

	&amp;update_mp3_pls;	
}

elsif($action eq &quot;file&quot; and -f $file &amp;&amp; $file =~ /\.($mf_ext)$/i)
{
	$cmd = &quot;\&quot;$perl_exe\&quot; \&quot;$cgi_local_dir/encode.pl\&quot; \&quot;$our_wd\/$file\&quot;&quot;;
	$rand = rand();
	open(FILE, &quot;&gt;&gt;$work_dir/$rand.bat&quot;);
	print FILE &quot;$cmd\n&quot;;
	close(FILE);

	@info = &amp;readf(&quot;$tpl_local_dir/encoding.tpl&quot;);
	for(@info)
	{
		s/&lt;&gt;/$ico_play/ig;
		s/&lt;&gt;/$theme_dir/ig;
	}
}

elsif($action eq &quot;file&quot; and !-f $file)
{
	$cwd = cwd();
	$error_msg = &quot;sorry we cant see $file in current directory: $cwd&quot;;
	@info = &amp;readf(&quot;$tpl_local_dir/error.tpl&quot;);
	for(@info)
	{
		s/&lt;&gt;/$error_msg/ig;
	}
}

#--------------------------------------------------------------------------------------------------------------
# Done everything, file in template and print webpage



for (@html)
{
	s/&lt;&gt;/@drives_data/ig;
	s/&lt;&gt;/@info/ig;
	s/&lt;&gt;/$date/ig;
	s/&lt;&gt;/$theme_dir/ig;
	s/&lt;&gt;/$vars_data/ig;
	s/&lt;&gt;/$background/ig;
	s/&lt;&gt;/$version/ig;
	s/&lt;&gt;/$cgi_dir/ig;
	s/&lt;&gt;/$wiicr_dir/ig;
	s/&lt;&gt;/@link_buttons/ig;
}

print @html;
exit 1;

#--------------------------------------------------------------------------------------------------------------
# subroutines
#--------------------------------------------------------------------------------------------------------------

sub read_dir_s
{
	my $d = shift;
	my @dl_1 = ();
	my @dl_2 = ();
	my @dl_3 = ();
	my @dl_4 = ();


	opendir(DIR, &quot;$d&quot;) or nf_error(&quot;sub readdir cant open directory $d, $!&quot;);
	@dl_1 = readdir(DIR);
       	closedir DIR;

	for(@dl_1) 
	{
		if($_ eq &quot;.&quot;) 
		{
			next;
		}
		push @dl_2, $_;
	}

	for(@dl_2)
	{
		if(-d $_)
		{
			push @dl_3, $_;
		}
		else
		{
			push @dl_4, $_;
		}
	}
	
	@dl_3 = sort(@dl_3);
	@dl_4 = sort(@dl_4);
	
	push @dl_3, @dl_4;

        return @dl_3;
}

#--------------------------------------------------------------------------------------------------------------

sub lsdir 
{
	my @dir = &amp;read_dir_s(&quot;.&quot;);
	my @data = ();
	my @tmp = ();
	my @tmp2 = ();
	my $file = &quot;&quot;;
	
	@tmp = &amp;readf(&quot;$tpl_local_dir/dir_header.tpl&quot;);
	for(@tmp)
	{
		s/&lt;&gt;/$wd/ig;
	}
	
	push @data, @tmp;
	
	for(@dir)
	{
		if(!$_)
		{
			next;
		}
		$ico_tmp = $ico_bin;
		
		if(-d $_ &amp;&amp; $_ eq &quot;..&quot;)
		{
			$ico_tmp = $ico_up;
		}		
		elsif(-d $_)
		{
			$ico_tmp = $ico_dir;
		}		
		elsif(/\.(txt&#124;ini&#124;nfo)$/i)
		{
			$ico_tmp = $ico_txt;
		}		
		elsif(/\.(mp3&#124;m3u&#124;pls)$/i)
		{
			$ico_tmp = $ico_mp3;
		}		
		elsif(/\.swf$/i)
		{
			$ico_tmp = $ico_flash;
		}		
		elsif(/\.(jpg&#124;jpeg&#124;gif&#124;png&#124;bmp)$/i)
		{
			$ico_tmp = $ico_pic;
		}		
		elsif(/\.($mf_ext)$/i)
		{
			$ico_tmp = $ico_vid;
		}
		elsif(/\.(zip&#124;ace&#124;tar&#124;gz&#124;rar&#124;r\d{2})$/i)
		{
			$ico_tmp = $ico_zip;
		}		
		
		$file = $_;

		@tmp = &amp;readf(&quot;$tpl_local_dir/dir_body.tpl&quot;);
		for(@tmp)
		{
			s/&lt;&gt;/$file/ig;
			s/&lt;&gt;/$ico_tmp/ig;
			s/&lt;&gt;/$wd/ig;
			
		}
		
		push @data, @tmp;
	}
	push @data, &amp;readf(&quot;$tpl_local_dir/dir_footer.tpl&quot;);
	
	return @data;
}

#--------------------------------------------------------------------------------------------------------------
sub lsmp3dir
{
	my @mp3_list = &amp;readf(&quot;$mp3_txt&quot;);
	my @data = ();
	my @tmp = &amp;readf(&quot;$tpl_local_dir/playlist_body.tpl&quot;);

	my $c = 0;
	for(@mp3_list)
	{
		if(!$_)
		{
			$c++;
			next;
		}

		$name = $_;
		$name =~ s/.*\/(.*?\.mp3)$/$1/ig;
		@tmp2 = @tmp;
		for(@tmp2)
		{
			s/&lt;&gt;/$wd/ig;
			s/&lt;&gt;/$c/ig;
			s/&lt;&gt;/$name/ig;			
			s/&lt;&gt;/$ico_del/ig;
		}
		push @data, @tmp2;
		$c++;
	}
	return @data;
}


#--------------------------------------------------------------------------------------------------------------

sub readf 
{
        my $file = $_[0];

        open(FILE, &quot;$file&quot;) or die(&quot;ERROR: Couldnt open $file to read.\n&quot;);
        my @file = ;
        close(FILE);

        return @file;
        
        return 1;
}

#--------------------------------------------------------------------------------------------------------------
# update_mp3_pls

# Note: its only xml code in this sub, 0 html.

sub update_mp3_pls 
{
	my @tmp 		= &amp;readf(&quot;$mp3_txt&quot;);
	my $tmp2 	= &quot;&quot;;
	my $file		= &quot;&quot;;

	@tmp = &amp;uniq_arr(@tmp);
	
	open(FILE, &quot;&gt;$mp3_pls&quot;);
	print FILE
	&quot;\n\t\n\n&quot;;
	for(@tmp)
	{
		chomp;
		$_ =~ s/\n&#124;\r//;
		$_ =~ s/\s+$//;
		$_ =~ s/^\s+//;

		if($_ !~ /\.mp3$/i)
		{
			next;
		}
		if(/\&#039;/)	# atm we dont handle &#039; well (seems only win32)
		{
			next;
		}
		if(/^\/\//)	# we also dont handle network paths right now.
		{
			next;
		}
		if( !-f $_)
		{
			next;
		}
		$file = $_;
		$file =~ s/^.*\///ig;
		$file =~ s/\.mp3$//ig;
		$_ = CGI::escapeHTML($_);

		print FILE 
		&quot;\t\n\t\t$file\n\t\t\n\t\t$wiicr_dir/fileget.php?loc=$_\n\t\n\n&quot;;
	}
	
	print FILE 
	&quot;\t\n\n&quot;;
	close(FILE);

	return 1;
}

sub uniq_arr
{
	my @list = @_;

	my %seen = ();
	my @uniqu = grep { ! $seen{$_} ++ } @list;
	
	return @uniqu;
}

sub read_config
{
	my %conf;
	
	my @tmp = &amp;readf(&quot;$dir/config.dat&quot;);
	for(@tmp)
	{
		chomp;                  # no newline
		s/#.*//;                # no comments
		s/^\s+//;               # no leading white
		s/\s+$//;               # no trailing white
		next unless length;     # anything left?
		my ($var, $value) = split(/\s*=\s*/, $_, 2);
		$conf{$var} = $value;		
	}

	return %conf;
}

sub read_dir
{
	my $d = shift;
	
	opendir(DIR, &quot;$d&quot;) or die &quot;ERROR: read_dir couldnt open \&quot;$d\&quot;&quot;;
	my @data = readdir(DIR);
	close(DIR);
	
	return @data;
	
}

1;</description>
		<content:encoded><![CDATA[<p>e echo todo hasta el final y me sale esto nose si sera lo normal&#8230;</p>
<p>#!/usr/bin/perl</p>
<p># license = gpl<br />
# author = jacob jarick, <a href="mailto:mem.namefix@gmail.com">mem.namefix@gmail.com</a> , mem on #wiidev @ efnet</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# includes<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>use CGI qw /:standard -nosticky/;<br />
use Cwd;<br />
use warnings;<br />
use File::Copy;<br />
use FindBin;</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# variables<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>our $dir = $0;</p>
<p>$dir =~ s/\\/\//g;<br />
$dir =~ s/^(.*)\/(.*?)$/$1/;</p>
<p>our %conf = &amp;read_config();<br />
our $theme = $conf{&#8216;theme&#8217;};</p>
<p>do &#8220;$dir/config.pl&#8221; or die &#8220;ERROR: couldnt load $dir/config.pl&#8221;;</p>
<p>$version = &#8220;0.3a&#8221;;<br />
$wd	= cwd();<br />
$i_wd	= $wd; 		# inital wd, needed for memcoder etc</p>
<p>$mf_ext = &#8220;avi|mpeg|mpg|mov|flv|dat|asf|wmv|mp4|ogm|mkv|vob&#8221;;</p>
<p>$file 		= param(&#8216;file&#8217;);<br />
$name		= param(&#8216;name&#8217;);<br />
$action 		= param(&#8216;action&#8217;);<br />
$our_wd		= param(&#8216;our_wd&#8217;);<br />
$new_theme	= param(&#8216;theme&#8217;);</p>
<p>$ico_pic 	= &#8220;$theme_dir/ico_img.png&#8221;;<br />
$ico_mp3 	= &#8220;$theme_dir/ico_mp3.png&#8221;;<br />
$ico_vid 	= &#8220;$theme_dir/ico_vid.png&#8221;;<br />
$ico_zip 	= &#8220;$theme_dir/ico_zip.png&#8221;;<br />
$ico_dir 	= &#8220;$theme_dir/ico_dir.png&#8221;;<br />
$ico_txt 	= &#8220;$theme_dir/ico_txt.png&#8221;;<br />
$ico_home	= &#8220;$theme_dir/ico_home.png&#8221;;<br />
$ico_up		= &#8220;$theme_dir/ico_up.png&#8221;;<br />
$ico_bin		= &#8220;$theme_dir/ico_bin.png&#8221;;<br />
$ico_play	= &#8220;$theme_dir/ico_play.png&#8221;;<br />
$ico_del		= &#8220;$theme_dir/ico_del.png&#8221;;<br />
$ico_config	= &#8220;$theme_dir/ico_config.png&#8221;;<br />
$ico_links	= &#8220;$theme_dir/ico_links.png&#8221;;<br />
$ico_forward	= &#8220;$theme_dir/ico_fwd.png&#8221;;<br />
$ico_back	= &#8220;$theme_dir/ico_back.png&#8221;;<br />
$ico_flash	= &#8220;$theme_dir/ico_flash.png&#8221;;<br />
$background	= &#8220;$theme_dir/background.jpg&#8221;;</p>
<p>our @drives_data = ();<br />
our @table_data = ();<br />
our @info = ();<br />
our @html = &amp;readf(&#8220;$theme_local_dir/main.html&#8221;);</p>
<p>$date = localtime(time());</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# code<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>print &#8220;Content-type: text/html\n\n&#8221;;</p>
<p>if($our_wd)<br />
{<br />
	chdir $our_wd;<br />
	$wd = $our_wd;<br />
}<br />
else<br />
{<br />
	$our_wd = cwd;<br />
}</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# get drives data ready.</p>
<p>@drives_data = &amp;readf(&#8220;$tpl_local_dir/drives_header.tpl&#8221;);<br />
@tmp = &amp;readf(&#8220;$tpl_local_dir/drives_body.tpl&#8221;);</p>
<p>for $d(@drives)<br />
{<br />
	@tmp2 = @tmp;<br />
	for $line(@tmp2)<br />
	{<br />
		$line =~ s/&lt;&gt;/$d/ig;<br />
		push @drives_data, $line;<br />
	}<br />
}<br />
push @drives_data, &amp;readf(&#8220;$tpl_local_dir/drives_footer.tpl&#8221;);</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# get link_buttons data ready.</p>
<p>my @link_buttons = &amp;readf(&#8220;$tpl_local_dir/link_buttons.tpl&#8221;);<br />
for(@link_buttons)<br />
{<br />
	s/&lt;&gt;/$theme_dir/ig;<br />
	s/&lt;&gt;/$cgi_dir/ig;<br />
	s/&lt;&gt;/$wiicr_dir/ig;<br />
}</p>
<p>#$vars_data = &#8220;<!-- VARS \n\$file = $file\n\$action = $action\n\$our_wd = $our_wd\n-->\n&#8221;;</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# respond to cgi requests</p>
<p>if(!$action)<br />
{<br />
	@info = &amp;lsdir;<br />
}</p>
<p>elsif($action eq &#8220;favs&#8221;)<br />
{<br />
	@info = &amp;readf(&#8220;$tpl_local_dir/favs_header.tpl&#8221;);<br />
	@favs = &amp;readf(&#8220;$favourites&#8221;);<br />
	@tmp = &amp;readf(&#8220;$tpl_local_dir/favs_body.tpl&#8221;);<br />
	for(@favs)<br />
	{<br />
		chomp;<br />
		@tmp2 = @tmp;<br />
		($name, $file) = split(/\t+/);<br />
		for(@tmp2)<br />
		{<br />
			s/&lt;&gt;/$file/ig;<br />
			s/&lt;&gt;/$name/ig;<br />
			s/&lt;&gt;/$ico_dir/ig;<br />
		}<br />
		push @info, @tmp2;<br />
	}<br />
	push @info, &amp;readf(&#8220;$tpl_local_dir/favs_footer.tpl&#8221;);<br />
}</p>
<p>elsif($action eq &#8220;vidplay&#8221;)<br />
{<br />
	$count = param(&#8216;count&#8217;);<br />
	$count++;<br />
	$file = &#8220;$count&#8221;.&#8221;default.flv&#8221;;<br />
	$tmpdur = $duration + $refresh_delay;</p>
<p>	if(! -f &#8220;$flv_local_dir/$file&#8221;)<br />
	{<br />
		@info = &amp;readf(&#8220;$tpl_local_dir/error.tpl&#8221;);<br />
		for(@info)<br />
		{<br />
			$tmp = &#8220;video file: $file doesnt existAssuming Video Ended.&#8221;;<br />
			s/&lt;&gt;/$tmp/ig;<br />
		}<br />
	}<br />
	else<br />
	{<br />
		@info = &amp;readf(&#8220;$tpl_local_dir/vidplay.tpl&#8221;);<br />
		for(@info)<br />
		{<br />
			s/&lt;&gt;/$cgi_dir/ig;<br />
			s/&lt;&gt;/$file/ig;<br />
			s/&lt;&gt;/$count/ig;<br />
			s/&lt;&gt;/$tmpdur/ig;<br />
			s/&lt;&gt;/$theme_dir/ig;<br />
			s/&lt;&gt;/@link_buttons/ig;<br />
		}<br />
		print @info;<br />
		exit 1;<br />
	}<br />
}</p>
<p>elsif($action =~ /^vidiframe/i)<br />
{<br />
	my $count = $action;<br />
	$count =~ s/^vidiframe//;<br />
	print &#8220;\$count = $count&#8221;;<br />
	$count++;<br />
	print &#8220;\$count = $count&#8221;;<br />
	$file = &#8220;$count&#8221;.&#8221;default.flv&#8221;;<br />
	$tmpdur = $duration + $refresh_delay;</p>
<p>	@info = &amp;readf(&#8220;$tpl_local_dir/vidiframe.tpl&#8221;);</p>
<p>	if(! -f &#8220;$flv_local_dir/$file&#8221;)<br />
	{<br />
		@info = &amp;readf(&#8220;$tpl_local_dir/error.tpl&#8221;);<br />
		for(@info)<br />
		{<br />
			$tmp = &#8220;video file: $file doesnt existAssuming Video Ended.&#8221;;<br />
			s/&lt;&gt;/$tmp/ig;<br />
		}<br />
	}<br />
	else<br />
	{<br />
		print &#8220;$file = $file$count&#8221;;<br />
		@info = &amp;readf(&#8220;$tpl_local_dir/vidiframe.tpl&#8221;);<br />
		for(@info)<br />
		{<br />
			s/&lt;&gt;/$cgi_dir/ig;<br />
			s/&lt;&gt;/$file/ig;<br />
			s/&lt;&gt;/$count/ig;<br />
			s/&lt;&gt;/$tmpdur/ig;<br />
			s/&lt;&gt;/$theme_dir/ig;<br />
		}<br />
		print @info;<br />
		exit 1;<br />
	}<br />
}</p>
<p>elsif($action eq &#8220;config&#8221;)<br />
{</p>
<p>	@info = &amp;readf(&#8220;$tpl_local_dir/config.tpl&#8221;);<br />
	@tmp = &amp;read_dir(&#8220;$wiicr_local_dir/themes&#8221;);</p>
<p>	my @combo = (&#8220;&#8221;);<br />
	for(@tmp)<br />
	{<br />
		if($_ eq &#8220;.&#8221; || $_ eq &#8220;..&#8221;)<br />
		{<br />
			next;<br />
		}<br />
		push @combo, &#8220;$_&#8221;;</p>
<p>	}<br />
	push @combo, &#8220;&#8221;;<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/$cgi_dir/ig;<br />
		s/&lt;&gt;/@combo/ig;<br />
	}<br />
}</p>
<p>elsif($action eq &#8220;theme&#8221;)<br />
{<br />
	@tmp = &amp;readf(&#8220;$wiicr_local_dir/config.dat&#8221;);<br />
	open(FILE, &#8220;&gt;$wiicr_local_dir/config.dat&#8221;) or die &#8220;&#8221;;<br />
	for(@tmp)<br />
	{<br />
		chomp;<br />
		if(/^theme\s+=/i)<br />
		{<br />
			print FILE &#8220;theme = $new_theme\n&#8221;;<br />
		}<br />
		else<br />
		{<br />
			print FILE &#8220;$_\n&#8221;;<br />
		}<br />
	}<br />
	close(FILE);</p>
<p>	@info 		= &amp;readf(&#8220;$tpl_local_dir/msg.tpl&#8221;);<br />
	@msg 		= (&#8220;Changing themes now&#8221;);<br />
	$goto_url	= &#8220;$cgi_dir/index.pl&#8221;;</p>
<p>	for(@info)<br />
	{<br />
		s/&lt;&gt;/$goto_url/ig;<br />
		s/&lt;&gt;/@msg/ig;<br />
	}</p>
<p>}</p>
<p>elsif($action eq &#8220;pls_del&#8221;)<br />
{<br />
	open(FILE, &#8220;&gt;$mp3_pls&#8221;) or die &#8220;&#8221;;<br />
	close(FILE);<br />
	open(FILE, &#8220;&gt;$mp3_txt&#8221;) or die &#8220;&#8221;;<br />
	close(FILE);</p>
<p>	@info 		= &amp;readf(&#8220;$tpl_local_dir/msg.tpl&#8221;);<br />
	@msg 		= (&#8220;Playlist Cleared, returning to config menu.&#8221;);<br />
	$goto_url	= &#8220;$cgi_dir/index.pl?action=config&#8221;;</p>
<p>	for(@info)<br />
	{<br />
		s/&lt;&gt;/$goto_url/ig;<br />
		s/&lt;&gt;/@msg/ig;<br />
	}</p>
<p>}</p>
<p>elsif($action eq &#8220;pls_update&#8221;)<br />
{<br />
	&amp;update_mp3_pls;<br />
	@info 		= &amp;readf(&#8220;$tpl_local_dir/msg.tpl&#8221;);<br />
	@msg 		= (&#8220;Playlist Updated, returning to config menu.&#8221;);<br />
	$goto_url	= &#8220;$cgi_dir/index.pl?action=config&#8221;;</p>
<p>	for(@info)<br />
	{<br />
		s/&lt;&gt;/$goto_url/ig;<br />
		s/&lt;&gt;/@msg/ig;<br />
	}</p>
<p>}</p>
<p>elsif($action eq &#8220;jobs_del&#8221;)<br />
{<br />
	opendir(DIR, &#8220;$work_dir&#8221;) or die &#8220;couldnt open dir: \&#8221;$work_dir\&#8221; to read\n&#8221;;<br />
	@dir = readdir(DIR);<br />
	close(DIR);</p>
<p>	for(@dir)<br />
	{<br />
		if($_ !~ /\.(bat|sh)$/i)<br />
		{<br />
			next;<br />
		}<br />
	}</p>
<p>	@info 		= &amp;readf(&#8220;$tpl_local_dir/msg.tpl&#8221;);<br />
	@msg 		= (&#8220;Jobs cleared, returning to config menu.&#8221;);<br />
	$goto_url	= &#8220;$cgi_dir/index.pl?action=config&#8221;;</p>
<p>	for(@info)<br />
	{<br />
		s/&lt;&gt;/$goto_url/ig;<br />
		s/&lt;&gt;/@msg/ig;<br />
	}</p>
<p>}</p>
<p>elsif($action eq &#8220;playlist&#8221;)<br />
{<br />
	@info = ();<br />
	push @info, &amp;readf(&#8220;$tpl_local_dir/playlist_header.tpl&#8221;);<br />
	@tmp = &amp;lsmp3dir;<br />
	push @info, @tmp;<br />
	push @info, &amp;readf(&#8220;$tpl_local_dir/playlist_footer.tpl&#8221;);<br />
}</p>
<p>elsif($action eq &#8220;delete&#8221;)<br />
{<br />
	@info =  &amp;readf(&#8220;$tpl_local_dir/playlist_del.tpl&#8221;);<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/$name/ig;<br />
		s/&lt;&gt;/$file/ig;<br />
		s/&lt;&gt;/$ico_config/ig;<br />
		s/&lt;&gt;/$cgi_dir/ig;<br />
	}<br />
	@tmp = &amp;readf(&#8220;$mp3_txt&#8221;);<br />
	open(FILE, &#8220;&gt;$mp3_txt&#8221;) or die &#8220;couldnt open $mp3_txt to update&#8221;;</p>
<p>	$c = 0;<br />
	for(@tmp)<br />
	{<br />
		chomp;<br />
		if(/$file$/)<br />
		{<br />
			$c++;<br />
			next;<br />
		}<br />
		if($c != $file)<br />
		{<br />
			print FILE &#8220;$_\n&#8221;;<br />
		}<br />
	$c++;<br />
	}<br />
	&amp;update_mp3_pls;<br />
}</p>
<p>elsif($action eq &#8220;drive&#8221;)<br />
{<br />
	chdir $file;<br />
	chdir &#8220;/&#8221;;<br />
	$wd = cwd();<br />
	@info = &amp;lsdir;<br />
}</p>
<p>elsif($action eq &#8220;file&#8221; and -d $file)<br />
{<br />
	chdir $file;<br />
	$wd = cwd();<br />
	@info = &amp;lsdir;<br />
}</p>
<p>elsif($action eq &#8220;file&#8221; and $file =~ /\.swf$/ig)<br />
{<br />
	@info = &amp;lsdir;</p>
<p>	@info 		= &amp;readf(&#8220;$tpl_local_dir/msg.tpl&#8221;);<br />
	@msg 		= (&#8220;Trying to load $file.&#8221;);</p>
<p>	$loc 		= &#8220;&#8221;;<br />
	$loc 		= &#8220;$our_wd/$file&#8221;;<br />
	$loc		= CGI::escapeHTML($loc);</p>
<p>	$goto_url	= &#8220;$cgi_dir/fileget.php?loc=&#8221;.$loc;</p>
<p>	for(@info)<br />
	{<br />
		s/&lt;&gt;/$goto_url/ig;<br />
		s/&lt;&gt;/@msg/ig;<br />
	}<br />
}</p>
<p>elsif($action eq &#8220;file&#8221; &amp;&amp; -f $file &amp;&amp; $file =~ /\.(txt|bat|ini|nfo)$/i)<br />
{<br />
	@file = &amp;readf(&#8220;$file&#8221;);<br />
	@info = &amp;readf(&#8220;$tpl_local_dir/txt_display.tpl&#8221;);<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/@file/ig;<br />
	}</p>
<p>}</p>
<p>elsif($action eq &#8220;links&#8221;)<br />
{<br />
	@info = &amp;readf(&#8220;$links&#8221;);<br />
	for(@info)<br />
	{<br />
		$_ =~ s/^\s*-\s*//;<br />
		$_ =~ s/^b$//i;<br />
		$_ =~ s/(.*)\t+(.*)/<a href="$2" rel="nofollow">$1\n/;<br />
	}<br />
}</p>
<p>elsif($action eq &#8220;file&#8221; &amp;&amp; -f $file &amp;&amp; $file =~ /\.(jpg|gif|png|jpeg)$/i)<br />
{<br />
	my $loc=&#8221;$wd/$file&#8221;;<br />
	$loc = CGI::escapeHTML($loc);<br />
	@tmp = &amp;read_dir(&#8220;$our_wd&#8221;);<br />
	@tmp2 = ();<br />
	for(@tmp)<br />
	{<br />
		if(/\.(jpg|gif|png|jpeg)$/i)<br />
		{<br />
			push @tmp2, $_;<br />
		}<br />
	}</p>
<p>	$file_forward = $file_back = $tmp2[0];</p>
<p>	$count = 1;<br />
	my $s = scalar @tmp2;<br />
	for(@tmp2)<br />
	{<br />
		if(/^$file$/)<br />
		{<br />
			if($count == $s)<br />
			{<br />
				$file_forward = $tmp2[0];<br />
			}<br />
			else<br />
			{<br />
				$file_forward = $tmp2[($count)];<br />
			}<br />
			if($count == 0)<br />
			{<br />
				$file_back = $tmp2[($s - 1)];<br />
			}<br />
			else<br />
			{<br />
				$file_back = $tmp2[($count - 2)];<br />
			}<br />
		}<br />
		$count++;<br />
	}</p>
<p>	@info = &amp;readf(&#8220;$tpl_local_dir/pic_display.tpl&#8221;);<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/$ico_back/ig;<br />
		s/&lt;&gt;/$ico_forward/ig;<br />
		s/&lt;&gt;/$loc/ig;<br />
		s/&lt;&gt;/$our_wd/ig;<br />
		s/&lt;&gt;/$file/ig;<br />
		s/&lt;&gt;/$file_back/ig;<br />
		s/&lt;&gt;/$file_forward/ig;<br />
	}</p>
<p>}</p>
<p>elsif($action eq &#8220;file&#8221; &amp;&amp; -f $file &amp;&amp; $file =~ /\.(mp3|m3u|pls)$/i)<br />
{<br />
	@info = &amp;readf(&#8220;$tpl_local_dir/mp3.tpl&#8221;);<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/$theme_dir/ig;<br />
		s/&lt;&gt;/$ico_play/ig;<br />
	}</p>
<p>	if($file =~ /mp3$/i)<br />
	{<br />
		$t = &#8220;$our_wd\/$file\n&#8221;;<br />
	}<br />
	else<br />
	{	# assuming playlist</p>
<p>		$t = &#8220;&#8221;;<br />
		@tmp = &amp;readf(&#8220;$our_wd/$file&#8221;);<br />
		chomp (@tmp);<br />
		if($file =~ /\.m3u$/i)<br />
		{<br />
			for (@tmp)<br />
			{<br />
				if(/^#/)<br />
				{<br />
					next;<br />
				}<br />
				s/\\/\//g;<br />
				if(!/^(\/|\w:)/)<br />
				{<br />
					$_ = &#8220;$our_wd/$_&#8221;;<br />
				}<br />
				$t .= &#8220;$_\n&#8221;;<br />
			}<br />
		}<br />
		else<br />
		{<br />
			# assume pls<br />
			$t = &#8220;&#8221;;<br />
			for(@tmp)<br />
			{<br />
				if(!/^File/i)<br />
				{<br />
					next;<br />
				}<br />
				s/\\/\//g;<br />
				s/^File\d+\=//ig;</p>
<p>				print &#8220;<!-- $_ -->\n&#8221;;<br />
				if(!/^(\/|\w:)/i)<br />
				{<br />
					$_ = &#8220;$our_wd/$_&#8221;;<br />
				}<br />
				$t .= &#8220;$_\n&#8221;;<br />
			}<br />
		}<br />
	}</p>
<p>	open(FILE, &#8220;&gt;&gt;$mp3_txt&#8221;) or die &#8220;ERROR couldnt open $mp3_txt&#8221;;<br />
	print FILE $t;<br />
	close(FILE);</p>
<p>	&amp;update_mp3_pls;<br />
}</p>
<p>elsif($action eq &#8220;file&#8221; and -f $file &amp;&amp; $file =~ /\.($mf_ext)$/i)<br />
{<br />
	$cmd = &#8220;\&#8221;$perl_exe\&#8221; \&#8221;$cgi_local_dir/encode.pl\&#8221; \&#8221;$our_wd\/$file\&#8221;";<br />
	$rand = rand();<br />
	open(FILE, &#8220;&gt;&gt;$work_dir/$rand.bat&#8221;);<br />
	print FILE &#8220;$cmd\n&#8221;;<br />
	close(FILE);</p>
<p>	@info = &amp;readf(&#8220;$tpl_local_dir/encoding.tpl&#8221;);<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/$ico_play/ig;<br />
		s/&lt;&gt;/$theme_dir/ig;<br />
	}<br />
}</p>
<p>elsif($action eq &#8220;file&#8221; and !-f $file)<br />
{<br />
	$cwd = cwd();<br />
	$error_msg = &#8220;sorry we cant see $file in current directory: $cwd&#8221;;<br />
	@info = &amp;readf(&#8220;$tpl_local_dir/error.tpl&#8221;);<br />
	for(@info)<br />
	{<br />
		s/&lt;&gt;/$error_msg/ig;<br />
	}<br />
}</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# Done everything, file in template and print webpage</p>
<p>for (@html)<br />
{<br />
	s/&lt;&gt;/@drives_data/ig;<br />
	s/&lt;&gt;/@info/ig;<br />
	s/&lt;&gt;/$date/ig;<br />
	s/&lt;&gt;/$theme_dir/ig;<br />
	s/&lt;&gt;/$vars_data/ig;<br />
	s/&lt;&gt;/$background/ig;<br />
	s/&lt;&gt;/$version/ig;<br />
	s/&lt;&gt;/$cgi_dir/ig;<br />
	s/&lt;&gt;/$wiicr_dir/ig;<br />
	s/&lt;&gt;/@link_buttons/ig;<br />
}</p>
<p>print @html;<br />
exit 1;</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# subroutines<br />
#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>sub read_dir_s<br />
{<br />
	my $d = shift;<br />
	my @dl_1 = ();<br />
	my @dl_2 = ();<br />
	my @dl_3 = ();<br />
	my @dl_4 = ();</p>
<p>	opendir(DIR, &#8220;$d&#8221;) or nf_error(&#8220;sub readdir cant open directory $d, $!&#8221;);<br />
	@dl_1 = readdir(DIR);<br />
       	closedir DIR;</p>
<p>	for(@dl_1)<br />
	{<br />
		if($_ eq &#8220;.&#8221;)<br />
		{<br />
			next;<br />
		}<br />
		push @dl_2, $_;<br />
	}</p>
<p>	for(@dl_2)<br />
	{<br />
		if(-d $_)<br />
		{<br />
			push @dl_3, $_;<br />
		}<br />
		else<br />
		{<br />
			push @dl_4, $_;<br />
		}<br />
	}</p>
<p>	@dl_3 = sort(@dl_3);<br />
	@dl_4 = sort(@dl_4);</p>
<p>	push @dl_3, @dl_4;</p>
<p>        return @dl_3;<br />
}</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>sub lsdir<br />
{<br />
	my @dir = &amp;read_dir_s(&#8220;.&#8221;);<br />
	my @data = ();<br />
	my @tmp = ();<br />
	my @tmp2 = ();<br />
	my $file = &#8220;&#8221;;</p>
<p>	@tmp = &amp;readf(&#8220;$tpl_local_dir/dir_header.tpl&#8221;);<br />
	for(@tmp)<br />
	{<br />
		s/&lt;&gt;/$wd/ig;<br />
	}</p>
<p>	push @data, @tmp;</p>
<p>	for(@dir)<br />
	{<br />
		if(!$_)<br />
		{<br />
			next;<br />
		}<br />
		$ico_tmp = $ico_bin;</p>
<p>		if(-d $_ &amp;&amp; $_ eq &#8220;..&#8221;)<br />
		{<br />
			$ico_tmp = $ico_up;<br />
		}<br />
		elsif(-d $_)<br />
		{<br />
			$ico_tmp = $ico_dir;<br />
		}<br />
		elsif(/\.(txt|ini|nfo)$/i)<br />
		{<br />
			$ico_tmp = $ico_txt;<br />
		}<br />
		elsif(/\.(mp3|m3u|pls)$/i)<br />
		{<br />
			$ico_tmp = $ico_mp3;<br />
		}<br />
		elsif(/\.swf$/i)<br />
		{<br />
			$ico_tmp = $ico_flash;<br />
		}<br />
		elsif(/\.(jpg|jpeg|gif|png|bmp)$/i)<br />
		{<br />
			$ico_tmp = $ico_pic;<br />
		}<br />
		elsif(/\.($mf_ext)$/i)<br />
		{<br />
			$ico_tmp = $ico_vid;<br />
		}<br />
		elsif(/\.(zip|ace|tar|gz|rar|r\d{2})$/i)<br />
		{<br />
			$ico_tmp = $ico_zip;<br />
		}		</p>
<p>		$file = $_;</p>
<p>		@tmp = &amp;readf(&#8220;$tpl_local_dir/dir_body.tpl&#8221;);<br />
		for(@tmp)<br />
		{<br />
			s/&lt;&gt;/$file/ig;<br />
			s/&lt;&gt;/$ico_tmp/ig;<br />
			s/&lt;&gt;/$wd/ig;</p>
<p>		}</p>
<p>		push @data, @tmp;<br />
	}<br />
	push @data, &amp;readf(&#8220;$tpl_local_dir/dir_footer.tpl&#8221;);</p>
<p>	return @data;<br />
}</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
sub lsmp3dir<br />
{<br />
	my @mp3_list = &amp;readf(&#8220;$mp3_txt&#8221;);<br />
	my @data = ();<br />
	my @tmp = &amp;readf(&#8220;$tpl_local_dir/playlist_body.tpl&#8221;);</p>
<p>	my $c = 0;<br />
	for(@mp3_list)<br />
	{<br />
		if(!$_)<br />
		{<br />
			$c++;<br />
			next;<br />
		}</p>
<p>		$name = $_;<br />
		$name =~ s/.*\/(.*?\.mp3)$/$1/ig;<br />
		@tmp2 = @tmp;<br />
		for(@tmp2)<br />
		{<br />
			s/&lt;&gt;/$wd/ig;<br />
			s/&lt;&gt;/$c/ig;<br />
			s/&lt;&gt;/$name/ig;<br />
			s/&lt;&gt;/$ico_del/ig;<br />
		}<br />
		push @data, @tmp2;<br />
		$c++;<br />
	}<br />
	return @data;<br />
}</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>sub readf<br />
{<br />
        my $file = $_[0];</p>
<p>        open(FILE, &#8220;$file&#8221;) or die(&#8220;ERROR: Couldnt open $file to read.\n&#8221;);<br />
        my @file = ;<br />
        close(FILE);</p>
<p>        return @file;</p>
<p>        return 1;<br />
}</p>
<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
# update_mp3_pls</p>
<p># Note: its only xml code in this sub, 0 html.</p>
<p>sub update_mp3_pls<br />
{<br />
	my @tmp 		= &amp;readf(&#8220;$mp3_txt&#8221;);<br />
	my $tmp2 	= &#8220;&#8221;;<br />
	my $file		= &#8220;&#8221;;</p>
<p>	@tmp = &amp;uniq_arr(@tmp);</p>
<p>	open(FILE, &#8220;&gt;$mp3_pls&#8221;);<br />
	print FILE<br />
	&#8220;\n\t\n\n&#8221;;<br />
	for(@tmp)<br />
	{<br />
		chomp;<br />
		$_ =~ s/\n|\r//;<br />
		$_ =~ s/\s+$//;<br />
		$_ =~ s/^\s+//;</p>
<p>		if($_ !~ /\.mp3$/i)<br />
		{<br />
			next;<br />
		}<br />
		if(/\&#8217;/)	# atm we dont handle &#8216; well (seems only win32)<br />
		{<br />
			next;<br />
		}<br />
		if(/^\/\//)	# we also dont handle network paths right now.<br />
		{<br />
			next;<br />
		}<br />
		if( !-f $_)<br />
		{<br />
			next;<br />
		}<br />
		$file = $_;<br />
		$file =~ s/^.*\///ig;<br />
		$file =~ s/\.mp3$//ig;<br />
		$_ = CGI::escapeHTML($_);</p>
<p>		print FILE<br />
		&#8220;\t\n\t\t$file\n\t\t\n\t\t$wiicr_dir/fileget.php?loc=$_\n\t\n\n&#8221;;<br />
	}</p>
<p>	print FILE<br />
	&#8220;\t\n\n&#8221;;<br />
	close(FILE);</p>
<p>	return 1;<br />
}</p>
<p>sub uniq_arr<br />
{<br />
	my @list = @_;</p>
<p>	my %seen = ();<br />
	my @uniqu = grep { ! $seen{$_} ++ } @list;</p>
<p>	return @uniqu;<br />
}</p>
<p>sub read_config<br />
{<br />
	my %conf;</p>
<p>	my @tmp = &amp;readf(&#8220;$dir/config.dat&#8221;);<br />
	for(@tmp)<br />
	{<br />
		chomp;                  # no newline<br />
		s/#.*//;                # no comments<br />
		s/^\s+//;               # no leading white<br />
		s/\s+$//;               # no trailing white<br />
		next unless length;     # anything left?<br />
		my ($var, $value) = split(/\s*=\s*/, $_, 2);<br />
		$conf{$var} = $value;<br />
	}</p>
<p>	return %conf;<br />
}</p>
<p>sub read_dir<br />
{<br />
	my $d = shift;</p>
<p>	opendir(DIR, &#8220;$d&#8221;) or die &#8220;ERROR: read_dir couldnt open \&#8221;$d\&#8221;";<br />
	my @data = readdir(DIR);<br />
	close(DIR);</p>
<p>	return @data;</p>
<p>}</p>
<p>1;</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Por: Rubia</title>
		<link>http://laventanamuerta.net/wiicr-convierte-tu-wii-en-un-media-center/comment-page-1/#comment-12537</link>
		<dc:creator>Rubia</dc:creator>
		<pubDate>Sat, 20 Nov 2010 19:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://laventanamuerta.net/wiicr-convierte-tu-wii-en-un-media-center/#comment-12537</guid>
		<description>Hola me a salido un error en el add on me dice que no encuentra el archivo setup_tomcat.bat o algo parecido que hago? te dejo mi mail espero respusta ando loca intentando ver pelis en mi wii!!!</description>
		<content:encoded><![CDATA[<p>Hola me a salido un error en el add on me dice que no encuentra el archivo setup_tomcat.bat o algo parecido que hago? te dejo mi mail espero respusta ando loca intentando ver pelis en mi wii!!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

