Conversion from joomla plugin to standalone function 03-17-2013, 04:26 PM
#1
Hey,
I have successfully decrypted a Joomla plugin that allows you to embed a youporn video and autoplay it. The thing is, I don't have enough PHP knowledge to transform a class into a standalone plugin, as it uses a few Joomla things, which I'm totally not familiar with.
Could someone help me and convert it to a standalone script where I can simply call it using a function as playVideo($url);?
I have successfully decrypted a Joomla plugin that allows you to embed a youporn video and autoplay it. The thing is, I don't have enough PHP knowledge to transform a class into a standalone plugin, as it uses a few Joomla things, which I'm totally not familiar with.
Could someone help me and convert it to a standalone script where I can simply call it using a function as playVideo($url);?
PHP Code:
class plgContentyouporn extends JPlugin
{
function plgContentyouporn( &$subject, $params )
{
parent::__construct( $subject, $params );
}
function onContentPrepare( $context, &$row, &$params, $limitstart )
{
// [[[ Load plugin params info
$dheight = $this->params->def( 'dheight', 300 );
$dwidth = $this->params->def( 'dwidth', 400 );
$dfullscreen = $this->params->def( 'dfullsceen', true );
$dautostart = $this->params->def( 'dautostart', true );
// ]]] Load plugin params info
$output = $row->text;
$regex = "#{youporn}(.*?){/youporn}#s";
preg_match_all( $regex, $output, $matches );
$count = count( $matches[0] );
if ( $count ) {
for ( $i=0; $i < $count; $i++ ) {
$youpornAddress = $matches[1][$i];
if (!function_exists('startsWith')) {
function startsWith($str,$needle,$case=true) {
if($case){return (strcmp(substr($str, 0, strlen($needle)),$needle)===0);}
return (strcasecmp(substr($str, 0, strlen($needle)),$needle)===0);
}
}
if ( startsWith( $youpornAddress, "http://" )) {
if (! startsWith( $youpornAddress, "http://www." )) {
$youpornAdd = substr($youpornAddress, 7, (strlen($youpornAddress) -1));
$youpornAddress = "http://www.".$youpornAdd;}
}
if ( startsWith( $youpornAddress, "www" )) { $youpornAddress = "http://".$youpornAddress; }
if ( !startsWith( $youpornAddress, "http://www." )) { $youpornAddress = "http://www.".$youpornAddress; }
if ( startsWith( $youpornAddress, "http://www.youporn.com" )) {
// Let's take a look for the category ID
$cat_id = null;
if ($address = fopen( $youpornAddress, 'r' )) {
$content = null;
$go = true;
while ( $go && $line = fread( $address, 1024 )) {
if ( strpos( $line, 'so.addVariable(\'file\', encodeURIComponent(' ) ) {
$line = explode( "?", $line );
$line = explode( "/", $line[0] );
$arsize = count( $line ) -1;
$cat_id = $line[$arsize];
$go = false;
}
}
} else {
if ( empty( $cat_id )) {
$replacement = "<b><font color=\"red\">ERROR: No category ID found</font></b><br />";
exit;
}
else {
$replacement = "<b><font color=\"red\">ERROR: No content found!</font></b><br />";
exit;
}
}
// Let's get the movie ID
if (! empty( $cat_id )) {
$mov_id = explode("/", $youpornAddress);
// Generate the embedded code
$replacement = "<!-- BEGIN youporn plugin v1.0 http://heinelt.info BEGIN -->
<embed
width=\"$dwidth\"
height=\"$dheight\"
flashvars=\"file=http%3A%2F%2Fdownload.youporn.com%2Fdownload%2F".$cat_id."%3Fxml%3D1&type=xml&postroll_url=http%3A%2F%2Fpages.etology.com%2Fxml%2F65246.php&location=http://files.youporn.com/r/9/player/postroll.swf&width=$dwidth&height=$dheight&showdigits=total&bufferlength=0&usekeys=false&autostart=".$dautostart."&streamscript=lighttpd&recommendations_url=%2Fwatch_postroll%2F".$mov_id."%3Fajax%3D1%26nocache%3D1&eventmode=false&debugmode=false\"
allowscriptaccess=\"always\"
wmode=\"transparent\"
allowfullscreen=\"".$dfullscreen."\"
quality=\"high\"
name=\"mpl\"
id=\"mpl\"
style=\"\"
src=\"http://files.youporn.com/r/9/player/postroll.swf\"
type=\"application/x-shockwave-flash\">
<!-- END youporn plugin v1.0 http://heinelt.info END -->";
}
}
else {
$replacement = "<b><font color=\"red\">ERROR:</font> URL <a href=\"$youpornAddress\" target=\"_blank\" >'$youpornAddress'</a> not valid! </b><br />";
}
$row->text = preg_replace( $regex, $replacement, $row->text, 1);
}
unset($youpornAddress);
}
return true;
}
}