SHARE
TWEET

Decoded

a guest Jan 12th, 2013 140 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //Decoded by http://www.phpdecoder.wordpress.com
  3. function mlvl_http_api_curl( $handle ){
  4. curl_setopt( $handle,CURLOPT_CAINFO,MLVL_INC .'/cacert.pem');
  5. }
  6. add_action( 'http_api_curl','mlvl_http_api_curl');
  7. function mlvl_enqueue_scripts(){
  8. wp_enqueue_script( 'jquery');
  9. if( !mlvl_get_options( 'fbapp_id'))
  10. return;
  11. wp_register_script( 'jquery-countdown',MLVL_URL.'scripts/jquery.countdown.js');
  12. wp_enqueue_script( 'jquery-countdown');
  13. wp_register_style( 'mlvl-style',MLVL_URL .'scripts/mlvl.css');
  14. wp_enqueue_style( 'mlvl-style');
  15. }
  16. add_action( 'wp_enqueue_scripts','mlvl_enqueue_scripts');
  17. # parse newsletter form code and extract required field.
  18. # @ajax call.
  19. function mlvl_parse_embed_url_ajax(){
  20. @error_reporting( 0 );
  21. header( 'Content-type: application/json');
  22. if( !isset( $_POST['url'] ))
  23. die( json_encode( array( 'error'=>'Invalid request.')));
  24. $url = stripslashes( $_POST['url'] );
  25. require_once( MLVL_DIR ."lib/Embed.class.php");
  26. $AE = new Embed();
  27. if( !$AE->parseUrl( $url ))
  28. die( json_encode( array( 'error'=>'Invalid video url provided.')));
  29. $AE->setParam( 'wmode','transparent');
  30. die( json_encode( array( 'attrb'=>$AE->getObjectAttribs(),'embed'=>$AE->getEmbedCode() )));
  31. }
  32. add_action( 'wp_ajax_mlvl_parse_embed_url','mlvl_parse_embed_url_ajax');
  33. add_action( 'wp_ajax_nopriv_mlvl_parse_embed_url','mlvl_parse_embed_url_ajax');
  34. function mlvl_head(){
  35. if( !mlvl_get_options( 'fbapp_id'))
  36. return;
  37. ;echo '<script type="text/javascript">
  38. ';
  39. $urlinfo = parse_url( get_bloginfo('wpurl'));
  40. echo "var mlvl_domain = '".untrailingslashit( $urlinfo['host'] ) ."';\n";
  41. echo "var mlvl_path = '".trailingslashit( $urlinfo['path'] ) ."';\n";
  42. ;echo '
  43. function mlvl_setCookie(name,value,days){
  44.         var date = new Date();
  45.         date.setDate(date.getDate() + days);
  46.  
  47.         var cookie_var = name + "=" + encodeURIComponent( value );
  48.         cookie_var += "; expires=" + date.toUTCString();
  49.         cookie_var += "; path=" + mlvl_path;
  50.         cookie_var += "; domain=" + mlvl_domain;
  51.         document.cookie = cookie_var;
  52. }
  53.  
  54.  
  55. window.fbAsyncInit = function(){
  56.         FB.init({ appId: \'';echo mlvl_get_options( 'fbapp_id');;echo '\', status: true, channelUrl: \'';echo MLVL_URL;;echo 'channel.html\' });
  57. };
  58. </script>
  59. <div id="fb-root"></div>
  60. <script type="text/javascript">
  61. (function() {
  62.    var e = document.createElement(\'script\');
  63.    e.type = \'text/javascript\';
  64.    e.src = document.location.protocol + \'//connect.facebook.net/en_US/all.js\';
  65.    e.async = true;
  66.    document.getElementById(\'fb-root\').appendChild(e);
  67. }());
  68. </script>
  69. <script type="text/javascript">var switchTo5x=true;</script>
  70. <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
  71. <script type="text/javascript">stLight.options({publisher: "ur-53228887-8dce-d0ad-2cb5-3a15648554f"});</script>
  72.         ';
  73. }
  74. add_action( 'wp_head','mlvl_head');
  75. function mlvl_shortcode( $atts,$content ){
  76. extract( shortcode_atts( array(
  77. 'video_url'=>'',
  78. 'width'=>'',
  79. 'height'=>'',
  80. 'overlay'=>MLVL_URL.'images/patterns/default_.png',
  81. 'overlay_radius'=>'0px',
  82. 'overlay_opacity'=>'0.5',
  83. 'overlay_padding'=>'0px',
  84. 'action_text'=>'',
  85. 'action_text_color'=>'white',
  86. 'action_text_size'=>'12',
  87. 'action_text_pleft'=>'100px',
  88. 'action_text_ptop'=>'20px',
  89. 'action_text_weight'=>'400',
  90. 'action_text_align'=>'center',
  91. 'action_text_width'=>'200px',
  92. 'share_button'=>MLVL_URL.'images/buttons/unlock1.png',
  93. 'share_button_pleft'=>'100px',
  94. 'share_button_ptop'=>'180px',
  95. 'countdown_time'=>'0',
  96. 'countdown_pleft'=>'100px',
  97. 'countdown_ptop'=>'130px',
  98. 'share_title'=>( is_singular()) ?the_title('','',false) : get_bloginfo( 'name'),
  99. 'share_link'=>( is_singular()) ?get_permalink() : home_url( '/'),
  100. 'invites'=>'1',
  101. 'multiunlock'=>'0',
  102. 'social_buttons'=>'0',
  103. 'subscription_method'=>'',
  104. 'subscription_form_data'=>''
  105. ),$atts ));
  106. $multiunlock = (bool) $multiunlock;
  107. $social_buttons = (bool) $social_buttons;
  108. require_once( MLVL_DIR ."lib/Embed.class.php");
  109. $AE = new Embed();
  110. if( !$AE->parseUrl( $video_url ))
  111. return '';
  112. $AE->setWidth( $width );
  113. $AE->setHeight( $height );
  114. $AE->setParam( 'wmode','transparent');
  115. $locked = true;
  116. if( isset( $_COOKIE['mlvlmu'] ))
  117. $locked = false;
  118. $unlocked_videos = isset( $_COOKIE['mlvluv'] ) ?explode( ";",$_COOKIE['mlvluv'] ) : array();
  119. if( $locked &&!empty( $unlocked_videos ) &&in_array( md5( $video_url ),$unlocked_videos ))
  120. $locked = false;
  121. $UID = get_the_ID() .rand( 0,1000000000 );
  122. if( $multiunlock ){
  123. $unlocked_js = '
  124.                         mlvl_setCookie("mlvlmu", "1", 100);
  125.                         jQuery(".mlvl_overlay, .mlvl_action_text, .mlvl_countdown_wrap, .mlvl_share_button_wrap").remove();
  126.                         jQuery(".mlvl_socialbar_wrap, .mlvl_content_reveal_wrap").show();
  127.                 ';
  128. }
  129. else{
  130. if( isset( $_COOKIE['mlvluv'] ))
  131. $new_cookie = md5( $video_url ) .";".$_COOKIE['mlvluv'];
  132. else
  133. $new_cookie = md5( $video_url );
  134. $unlocked_js='
  135.                         mlvl_setCookie("mlvluv", "'.$new_cookie .'", 100);
  136.                         jQuery("#mlvideo-'.$UID .' .mlvl_overlay, #mlvideo-'.$UID .' .mlvl_action_text, #mlvideo-'.$UID .' .mlvl_countdown_wrap, #mlvideo-'.$UID .' .mlvl_share_button_wrap").remove();
  137.                         jQuery("#mlvideo-'.$UID .' .mlvl_socialbar_wrap, #mlvideo-'.$UID .' .mlvl_content_reveal_wrap").show();
  138.                 ';
  139. }
  140. $subscription_js = "";
  141. if( isset( $subscription_method ) &&in_array( $subscription_method,array( 'getresponse','mailchimp','icontact','aweber')) &&!empty( $subscription_form_data )){
  142. $subscription_form_data = maybe_unserialize( base64_decode( $subscription_form_data ));
  143. $subscription_js .= "// Do Subscribe Call\n";
  144. $subscription_js .= "\t\t\t\t\t\t\tFB.api('/me?fields=name,username,email', function(response){\n";
  145. $subscription_js .= "\t\t\t\t\t\t\tvar args = ".json_encode( $subscription_form_data ).";\n";
  146. $subscription_js .= "\t\t\t\t\t\t\targs.name = response.name;\n";
  147. $subscription_js .= "\t\t\t\t\t\t\targs.email = response.email;\n";
  148. $subscription_js .= "\t\t\t\t\t\t\tjQuery.post( '".admin_url( "admin-ajax.php") ."', {\"action\":\"mlvl_subscribe\", \"service\":\"$subscription_method\", \"args\":args});\n";
  149. $subscription_js .= "});\n\n";
  150. }
  151. $invites = (int) $invites;
  152. $width = (int) $width;
  153. $height = (int) $height;
  154. $countdown_time = intval( $countdown_time );
  155. if( !isset( $action_text_color ) ||!preg_match( '/^#[a-f0-9]{6}$/i',$action_text_color ))
  156. $action_text_color = "#FFF";
  157. $result = "<div class=\"mlvl_video\" style=\"width:{$width}px; min-height:{$height}px;\" id=\"mlvideo-$UID\">\n";
  158. if( $locked ){
  159. if( !empty( $action_text )){
  160. $result .= "\t<div class=\"mlvl_action_text\" style=\"
  161.                                 width: {$action_text_width};
  162.                                 left: {$action_text_pleft};
  163.                                 top: {$action_text_ptop};
  164.                                 color: {$action_text_color};
  165.                                 font-size: {$action_text_size}px;
  166.                                 font-weight: {$action_text_weight};
  167.                                 text-align: {$action_text_align};
  168.                         \">\n";
  169. $result .= "\t\t$action_text\n";
  170. $result .= "\t</div>\n";
  171. }
  172. if( $countdown_time ){
  173. $result .= "\t<div class=\"mlvl_countdown_wrap\" style=\"
  174.                                 left: {$countdown_pleft};
  175.                                 top: {$countdown_ptop};
  176.                                 color: {$action_text_color};
  177.                                 text-align: center;
  178.                         \"></div><!--.mlvl_countdown_wrap-->\n";
  179. $result .= "\t<script type=\"text/javascript\">\n";
  180. $result .= "\t\tvar newYear = new Date();\n";
  181. $result .= "\t\tnewYear = new Date( newYear.getTime() + ( $countdown_time * 1000 ));\n";
  182. $result .= "\t\tjQuery(\"#mlvideo-$UID .mlvl_countdown_wrap\").countdown({until: newYear, format:'MS', compact: true});\n";
  183. $result .= "\t</script>\n";
  184. }
  185. $result .= "\t<div class=\"mlvl_share_button_wrap\" style=\"
  186.                         left: {$share_button_pleft};
  187.                         top: {$share_button_ptop};
  188.                 \">\n";
  189. $result .= "\t\t<a href=\"javascript:void(0);\" onclick=\"MLFBconnect_{$UID}();\">\n";
  190. $result .= "\t\t\t<img src=\"$share_button\" alt=\"Share with your facebook friends to unlock this Video\" />\n";
  191. $result .= "\t\t</a>\n";
  192. $result .= "\t</div>\n";
  193. $result .= "<div class=\"mlvl_overlay\" style=\"
  194.                         width:{$width}px;
  195.                         height:{$height}px;
  196.                         padding:{$overlay_padding};
  197.                         background:url({$overlay});
  198.                         border-radius: {$overlay_radius}; -moz-border-radius: {$overlay_radius}; -khtml-border-radius: {$overlay_radius};
  199.                         opacity: {$overlay_opacity};
  200.                         left: -{$overlay_padding};
  201.                         top: -{$overlay_padding};
  202.                         \"></div>\n";
  203. $result .= '
  204.                         <script type="text/javascript">
  205.                                 function MLFBconnect_'.$UID.'(){
  206.                                         FB.login(function(FB_response){
  207.                                                 if( FB_response.status === "connected" ){
  208.  
  209.                                                         '.$subscription_js .'
  210.  
  211.                                                         FB.ui({
  212.                                                                 method: "apprequests",
  213.                                                                 message: "'.$share_title.'",
  214.                                                                 data: "'.base64_encode( $share_link ) .'"
  215.                                                         },
  216.                                                         function(response){
  217.                                                                 if( response && response.to && response.to.length >= '.$invites.' ){
  218.                                                                         '.$unlocked_js .'
  219.                                                                 }else{
  220.                                                                         alert("Invite atleast '.$invites.' friends to unlock & watch this video !!");
  221.                                                                 }
  222.                                                         });
  223.                                                 }
  224.                                                 else{
  225.                                                         alert( "Connect your facebook account to unlock & watch this video !!" );
  226.                                                 }
  227.                                         },
  228.                                         {scope: "email"});
  229.                                 }
  230.                 </script>';
  231. }
  232. # Video Object
  233. $result .= "<div style=\"
  234.                 width:{$width}px;
  235.                 height:{$height}px;\"
  236.                 class=\"mlvl_embed_wrap\"
  237.         >{$AE->getEmbedCode()}</div>";
  238. if( !empty( $content )){
  239. $result .= "\t<div style=\"display:".( $locked ?'none':'block').";\" class=\"mlvl_content_reveal_wrap\">\n";
  240. $result .= "\t\t<a href=\"javascript:void(0);\" title=\"Close\" class=\"mlvl_content_reveal_remove\" onclick=\"jQuery(this).parent().remove();\">x</a>\n";
  241. $result .= "\t\t$content\n";
  242. $result .= "\t</div>\n";
  243. }
  244. if( $social_buttons ){
  245. $result .= "<div style=\"display:".( $locked ?'none':'block').";\" class=\"mlvl_socialbar_wrap\">\n";
  246. $result .= "<span class='st_sharethis_hcount' displayText='ShareThis'></span>\n";
  247. $result .= "<span class='st_facebook_hcount' displayText='Facebook'></span>\n";
  248. $result .= "<span class='st_twitter_hcount' displayText='Tweet'></span>\n";
  249. $result .= "<span class='st_linkedin_hcount' displayText='LinkedIn'></span>\n";
  250. $result .= "<span class='st_email_hcount' displayText='Email'></span>\n";
  251. $result .= "</div>\n";
  252. }
  253. $result .= "</div><!--#mlvideo-$UID-->\n";
  254. return $result;
  255. }
  256. add_shortcode( 'mlvl','mlvl_shortcode');
  257. function mlvl_guess_url( $exclude_vars = array('m,e,n'),$exclude_structure = array()){
  258. $schema = is_ssl() ?'https://': 'http://';
  259. $url = $schema .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI'];
  260. if( !empty( $exclude_vars ) &&!is_array( $exclude_vars )){
  261. $exclude_vars = explode( ',',$exclude_vars );
  262. $exclude_vars = array_unique( $exclude_vars );
  263. }
  264. if( !empty( $exclude_structure ))
  265. $url = preg_replace('#/('.implode('|',$exclude_structure ).')#i','',$url );
  266. if( !empty( $exclude_vars ))
  267. $url = remove_query_arg( $exclude_vars,$url );
  268. return $url;
  269. }
  270. # get plugin options
  271. function mlvl_get_options( $key = null ){
  272. $mlvl_options = get_option( 'mlvl_options');
  273. if( !$mlvl_options )
  274. return false;
  275. if( !$key )
  276. return $mlvl_options;
  277. if( !is_array( $key ) &&!array_key_exists( $key,$mlvl_options ))
  278. return false;
  279. if( is_array( $key )){
  280. $return = array();
  281. foreach( $key as $k ){
  282. $return[$k] = array_key_exists( $k,$mlvl_options ) ?$mlvl_options[$k] : '';
  283. }
  284. }
  285. else{
  286. $return = $mlvl_options[$key];
  287. }
  288. if( $return == ''||!isset( $return ) ||empty( $return ) ||false == $return ){
  289. if( is_array( $key ))
  290. return array();
  291. else
  292. return '';
  293. }
  294. return $return;
  295. }
  296. # update plugin options.
  297. function mlvl_update_options( $options = array(),$newonly = false ){
  298. if( empty( $options ))
  299. return;
  300. if( !is_array( $options ))
  301. $options = (array) $options;
  302. if( !$newonly ){
  303. $old_options = mlvl_get_options();
  304. $options = wp_parse_args( $options,$old_options );
  305. }
  306. update_option( 'mlvl_options',$options );
  307. return $options;
  308. }
  309. function mlvl($a){
  310. echo '<pre>';print_r($a);echo '</pre>'."\n\n\n";
  311. }
  312. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top