Sinisterly
Conversion from joomla plugin to standalone function - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: PHP (https://sinister.ly/Forum-PHP)
+--- Thread: Conversion from joomla plugin to standalone function (/Thread-Conversion-from-joomla-plugin-to-standalone-function)



Conversion from joomla plugin to standalone function - Cyberuben - 03-17-2013

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);?


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&amp;type=xml&amp;postroll_url=http%3A%2F%2Fpages.etology.com%2Fxml%2F65246.php&amp;location=http://files.youporn.com/r/9/player/postroll.swf&amp;width=$dwidth&amp;height=$dheight&amp;showdigits=total&amp;bufferlength=0&amp;usekeys=false&amp;autostart=".$dautostart."&amp;streamscript=lighttpd&amp;recommendations_url=%2Fwatch_postroll%2F".$mov_id."%3Fajax%3D1%26nocache%3D1&amp;eventmode=false&amp;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; } }



RE: Conversion from joomla plugin to standalone function - The Alchemist - 03-18-2013

The PHP code says :
Quote:class plgContentyouporn extends JPlugin

Which means there's another class associated with plgContentyyouporn named JPlugin.
Maybe I could help you if you could get that class too here.


RE: Conversion from joomla plugin to standalone function - zomgwtfbbq - 03-18-2013

PHP 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&amp;type=xml&amp;postroll_url=http%3A%2F%2Fpages.etology.com%2Fxml%2F65246.php&amp;location=http://files.youporn.com/r/9/player/postroll.swf&amp;width=$dwidth&amp;height=$dheight&amp;showdigits=total&amp;bufferlength=0&amp;usekeys=false&amp;autostart=".$dautostart."&amp;streamscript=lighttpd&amp;recommendations_url=%2Fwatch_postroll%2F".$mov_id."%3Fajax%3D1%26nocache%3D1&amp;eventmode=false&amp;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\">
You just need to fill in the correct variables, I'm not going to check how a youporn video url looks like with my wife around. Wink But the embed code is already there and the way to get the category is also there. You just need to get the variables mov_id and cat_id. The other variables can be changed according to how you want the player to look and where it should start in the movie.