Welcome! » Log In » Create A New Profile

cadkins29@gmail.com

Posted by Chris_Pspace 
Chris_Pspace
cadkins29@gmail.com
March 12, 2009 12:42PM

Ok if anyone has a playlist.us filter I would appreciate posting one. :)

(All links removed as the forum keeps telling me I'm posting spam)

I figured out how to get the YouTube filter working without too much effort, but trying to use it as a template for a Playlist.us playlist filter isn't working for me.

Here's what I tried so far, as you can probably see I have no idea what I'm doing. :)

Originally I used this:

$config->set('Filter', 'Playlist', true);

Unfortunately it didn't seem to work so I searched in the forum for 'Playlist' and saw that someone had taken on this project once before so rather than use the above config I used the following taken from that thread:

$config->set('Filter', 'Custom', array(new HTMLPurifier_Filter_Playlist()));

So currently here is the top few lines in the file I am taking user input from: Again please tell me what I do not need to include, etc.

include("purify/library/HTMLPurifier.auto.php");
$config = HTMLPurifier_Config::createDefault();
$config->set('Filter', 'YouTube', true);
$config->set('Filter', 'Custom', array(new HTMLPurifier_Filter_Playlist()));
$purifier = new HTMLPurifier($config);

I also created a file called Playlist.php and used YouTube.php as a template. It seems no matter what I try I'm still not making any progress at all. What happens is all object tags, etc. are filtered out. I am left with a few image and link references but nothing in regards to the object.

Here's the original code that should be filtered:

<div style="text-align: center; margin-left: auto; visibility:visible; margin-right: auto; width:450px;">
<object width="435" height="270">
<param name="movie" value="  .profileplaylist.us/mc/mp3player_new.swf">
</param>
<param name="allowscriptaccess" value="never"></param> <param name="wmode" value="transparent">
</param>
<param name="flashvars" value="config=http%3A%2F%2F .indimusic.us%2Fext%2Fpc%2Fconfig_black.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2F .indimusic.us%2Floadplaylist.php%3Fplaylist%3D27578280"></param> <embed style="width:435px; visibility:visible; height:270px;" allowScriptAccess="never" src="  .profileplaylist.us/mc/mp3player_new.swf" flashvars="config=http%3A%2F%2F .indimusic.us%2Fext%2Fpc%2Fconfig_black.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=  .indimusic.us/loadplaylist.php?playlist=27578280" width="435" height="270" name="mp3player" wmode="transparent" type="application/x-shockwave-flash" border="0"/> </object> <br/> <a href="  .profileplaylist.us"><img src="  .profileplaylist.us/mc/images/create_black.jpg" border="0" alt="Get a playlist!"/></a> <a href="  .mysocialgroup.us/standalone/27578280" target="_blank"><img src="  .profileplaylist.us/mc/images/launch_black.jpg" border="0" alt="Standalone player"/></a> <a href="  .mysocialgroup.us/download/27578280"><img src="  .profileplaylist.us/mc/images/get_black.jpg" border="0" alt="Get Ringtones"/></a> </div>

As I said, I'm clueless. :)

Here is what my Playlist.php file consists of:

<?php

class HTMLPurifier_Filter_Playlist extends HTMLPurifier_Filter
{

    public $name = &#039;Playlist&#039;;

    public function preFilter($html, $config, $context) {
        $pre_regex = &#039;#<div[^>]+>.+?&#039;.
            &#039;  .indimusic.us/loadplaylist.php?playlist=([A-Za-z0-9\-_]+).+"</div>#s&#039;;
        $pre_replace = &#039;<span class="playlist-embed">\1</span>&#039;;
        return preg_replace($pre_regex, $pre_replace, $html);
    }

    public function postFilter($html, $config, $context) {
        $post_regex = &#039;#<span class="playlist-embed">([A-Za-z0-9\-_]+)</span>#&#039;;
        return preg_replace_callback($post_regex, array($this, &#039;postFilterCallback&#039;), $html);
    }

    protected function armorUrl($url) {
        return str_replace(&#039;--&#039;, &#039;-&#45;&#039;, $url);
    }

    protected function postFilterCallback($matches) {
        $url = $this->armorUrl($matches[1]);

            return&#039;<div style="text-align: center; margin-left: auto; visibility:visible; margin-right: auto; width:450px;"> &#039;.
			&#039;<object width="435" height="270"> &#039;.
			&#039;<param name="movie" value="  .profileplaylist.us/mc/mp3player_new.swf">&#039;.
			&#039;</param> &#039;.
			&#039;<param name="allowscriptaccess" value="never"></param> <param name="wmode" value="transparent">&#039;.
			&#039;</param> &#039;.
			&#039;<param name="flashvars" value="config=http%3A%2F%2F .indimusic.us%2Fext%2Fpc%2Fconfig_black.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2F .indimusic.us%2Floadplaylist.php%3Fplaylist%3D&#039;.$url.&#039;%26t%3D1236868403&amp;wid=os"></param> <embed style="width:435px; visibility:visible; height:270px;" allowScriptAccess="never" src="  .profileplaylist.us/mc/mp3player_new.swf" flashvars="config=http%3A%2F%2F .indimusic.us%2Fext%2Fpc%2Fconfig_black.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=  .indimusic.us/loadplaylist.php?playlist=&#039;.$url.&#039;&t=1236868403&amp;wid=os" width="435" height="270" name="mp3player" wmode="transparent" type="application/x-shockwave-flash" border="0"/> </object> <br/> <a href="  .profileplaylist.us"><img src="  .profileplaylist.us/mc/images/create_black.jpg" border="0" alt="Get a playlist!"/></a> <a href="  .mysocialgroup.us/standalone/&#039;.$url.&#039;" target="_blank"><img src="  .profileplaylist.us/mc/images/launch_black.jpg" border="0" alt="Standalone player"/></a> <a href="  .mysocialgroup.us/download/&#039;.$url.&#039;"><img src="  .profileplaylist.us/mc/images/get_black.jpg" border="0" alt="Get Ringtones"/></a> </div>&#039;;

    }
}

// vim: et sw=4 sts=4

Oh and you may notice the div tags above but I also tried using the object tags. I don't think I completely understand what is happening enough to make this work. The user input is filtered and the output to the browser has no object tags or anything to associate the flash player.

I also attempted to create a Filter.Playlist.txt file because I saw one for YouTube and figured I would try to match what was done with Youtube. Can anyone help point me in a better direction so my users can once again use Project Playlist? :) Thanks in advance!!!

Chris

Re: cadkins29@gmail.com
March 12, 2009 02:02PM

%Filter.Custom is the correct way to load filters for now (in the next version, there should be better support for custom configuration directives).

I haven't run your code yet, but it seems to me that it might be helpful to build up the regex, bit by bit, instead of trying to do the whole kaboodle at once. There are numerous utilities out there that can help you do this.

Re: cadkins29@gmail.com
March 14, 2009 06:33PM

his code is using flashvars as it's a playlist.. so it's not going to work even with a filter until the flashvars is added to purifier (from the patch that's being worked on in the internals frum)

Re: cadkins29@gmail.com
March 14, 2009 07:00PM

Oh, good call.

I suppose you could hack it by inserting the information inside the span tag...

Chris_Pspace
Re: cadkins29@gmail.com
April 29, 2009 09:05PM

How would I go about using the span tag to achieve my goal? I will introduce any way that functions properly to my users in order to once again allow users to post Playlist code. I would even be open to the idea of users simply entering their specific ID# for their particular playlist and have the code generated in the profile using their ID# for their playlist, but I don't know how this can be done using HTML Purifier. Any more help would be GREATLY appreciated!! :)

Chris

Re: cadkins29@gmail.com
April 29, 2009 09:23PM

The basic idea is that, since you need to have the flashvars stored somewhere so that when you replace the span tag with the full object tag, you can stick them back in there, and you also need to make sure they don't get filtered out, one way to fix this is to somehow match flashvars when you do your initial regex, and place them as the contents of the span tag.

Matching for the flashvars is slightly non-trivial, unfortunately.

Chris_Pspace
Playlist filter
May 02, 2009 10:06PM

Ok well I think I actually found some code that they tell you to use if your site doesn't use FLASHVARS that still gets filtered out. I'm sure I need to build a custom filter like for youtube because it looks like the object is being filtered out. I tried this yet again and once again crashed hard with the filter wiping out other variables basically erasing my profile, whoops. :)


<object width="435" height="270" data="http://www.profileplaylist.net/mc/mp3player_new.swf?config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fconfig_site_noautostart.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2Fwww.indimusic.us%2Floadplaylist.php%3Fplaylist%3D56704178%26t%3D1241315722&amp;wid=os"> <param name="bgcolor" value="#e8e8e8"/> <param name="movie" value="http://www.profileplaylist.net/mc/mp3player_new.swf?config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fconfig_site_noautostart.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2Fwww.indimusic.us%2Floadplaylist.php%3Fplaylist%3D56704178%26t%3D1241315722&amp;wid=os"/> </object> <br/> <a href="http://www.profileplaylist.net"><img src="http://www.profileplaylist.net/mc/images/create_site.jpg" border="0" alt="Get a playlist!"/></a> <a href="http://www.mysocialgroup.com/standalone/56704178" target="_blank"><img src="http://www.profileplaylist.net/mc/images/launch_site.jpg" border="0" alt="Standalone player"/></a> <a href="http://www.mysocialgroup.com/download/56704178"><img src="http://www.profileplaylist.net/mc/images/get_site.jpg" border="0" alt="Get Ringtones!"/></a> </div>
Chris_Pspace
Re: Playlist filter
May 02, 2009 10:10PM

I tried using the following code in the PlayList.php file but something's wrong because everything gets filtered including perfectly good text. I keep trying and trying to understand regex but am having a lot of trouble understanding it.

Anyone want to write a PlayList.php file for me or help me go through it a little bit? As I said my attempt is leading to problems with everything being wiped out.

Without the filter at all, everything after the closing object tag is fine but the entire object tag and attributes are wiped out.

Here's the PlayList.php code I have so far as I used Youtube.php as a template:

<?php

class HTMLPurifier_Filter_PlayList extends HTMLPurifier_Filter
{

    public $name = &#039;PlayList&#039;;

    public function preFilter($html, $config, $context) {
        $pre_regex = &#039;#<object[^>]+>.+?&#039;.
            &#039;http://www.indimusic.us/loadplaylist.php?playlist%3D([0-9]+).+?</object>#s&#039;;
        $pre_replace = &#039;<span class="playlist-embed">\1</span>&#039;;
        return preg_replace($pre_regex, $pre_replace, $html);
    }

    public function postFilter($html, $config, $context) {
        $post_regex = &#039;#<span class="playlist-embed">\1</span>#&#039;;
        return preg_replace_callback($post_regex, array($this, &#039;postFilterCallback&#039;), $html);
    }

    protected function armorUrl($url) {
        return str_replace(&#039;--&#039;, &#039;-&#45;&#039;, $url);
    }

    protected function postFilterCallback($matches) {
        $url = $this->armorUrl($matches[1]);
return &#039;<object width="435" height="270">&#039;.
&#039;<param name="movie" value="http://www.profileplaylist.net/mc/mp3player_new.swf"></param> &#039;.
&#039;<param name="allowscriptaccess" value="never"></param>&#039;.
&#039;<param name="wmode" value="transparent"></param> &#039;.
&#039;<param name="flashvars" value="config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fconfig_black.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2Fwww.indimusic.us%2Floadplaylist.php%3Fplaylist%3D&#039;.$url.&#039;&amp;wid=os"></param> <embed style="width:435px; visibility:visible; height:270px;" allowScriptAccess="never" src="http://www.profileplaylist.net/mc/mp3player_new.swf" flashvars="config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fconfig_black.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http://www.indimusic.us/loadplaylist.php?playlist=&#039;.$url.&#039;&amp;wid=os" width="435" height="270" name="mp3player" wmode="transparent" type="application/x-shockwave-flash" border="0"/> </object> &#039;;

    }
}

// vim: et sw=4 sts=4
Chris_Pspace
Re: Playlist filter
May 02, 2009 10:21PM

Can someone please help me make a playlist filter to accept the type of code below and do the following three main steps:

1. Verify object contains profileplaylist.net or whatever. 2. Extract the playlist ID (example mine below is 56704178) 3. Rewrite using the correct code and stick in ID


<object width="435" height="270" data="http://www.profileplaylist.net/mc/mp3player_new.swf?config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fconfig_site_noautostart.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2Fwww.indimusic.us%2Floadplaylist.php%3Fplaylist%3D56704178%26t%3D1241315722&amp;wid=os"> <param name="bgcolor" value="#e8e8e8"/> <param name="movie" value="http://www.profileplaylist.net/mc/mp3player_new.swf?config=http%3A%2F%2Fwww.indimusic.us%2Fext%2Fpc%2Fconfig_site_noautostart.xml&amp;mywidth=435&amp;myheight=270&amp;playlist_url=http%3A%2F%2Fwww.indimusic.us%2Floadplaylist.php%3Fplaylist%3D56704178%26t%3D1241315722&amp;wid=os"/> </object> <br/> <a href="http://www.profileplaylist.net"><img src="http://www.profileplaylist.net/mc/images/create_site.jpg" border="0" alt="Get a playlist!"/></a> <a href="http://www.mysocialgroup.com/standalone/56704178" target="_blank"><img src="http://www.profileplaylist.net/mc/images/launch_site.jpg" border="0" alt="Standalone player"/></a> <a href="http://www.mysocialgroup.com/download/56704178"><img src="http://www.profileplaylist.net/mc/images/get_site.jpg" border="0" alt="Get Ringtones!"/></a> </div>

Can anyone help?

There was an author here who made such a filter but the link to his code is invalid and no response to my email to him as of yet. I tried to post the url to his post but the forum filter is marking it spam.

Re: Playlist filter
May 03, 2009 04:09AM

Ok, take this in steps.

First, write the regex to parse out the object code. You do this, but you also need to assign the entire thing to a variable, so you can the playlist ID. Use this with a subpattern match.

In the callback, regex the subpattern match to grab the playlist ID. Place this inside the callback's return value.

The pre_regex is not currently callback'ized, so you'll have to do that.

Sorry, you do not have permission to post/reply in this forum.