Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Decoded by http://www.phpdecoder.wordpress.com
- function mlvl_http_api_curl( $handle ){
- curl_setopt( $handle,CURLOPT_CAINFO,MLVL_INC .'/cacert.pem');
- }
- add_action( 'http_api_curl','mlvl_http_api_curl');
- function mlvl_enqueue_scripts(){
- wp_enqueue_script( 'jquery');
- if( !mlvl_get_options( 'fbapp_id'))
- return;
- wp_register_script( 'jquery-countdown',MLVL_URL.'scripts/jquery.countdown.js');
- wp_enqueue_script( 'jquery-countdown');
- wp_register_style( 'mlvl-style',MLVL_URL .'scripts/mlvl.css');
- wp_enqueue_style( 'mlvl-style');
- }
- add_action( 'wp_enqueue_scripts','mlvl_enqueue_scripts');
- # parse newsletter form code and extract required field.
- # @ajax call.
- function mlvl_parse_embed_url_ajax(){
- @error_reporting( 0 );
- header( 'Content-type: application/json');
- if( !isset( $_POST['url'] ))
- die( json_encode( array( 'error'=>'Invalid request.')));
- $url = stripslashes( $_POST['url'] );
- require_once( MLVL_DIR ."lib/Embed.class.php");
- $AE = new Embed();
- if( !$AE->parseUrl( $url ))
- die( json_encode( array( 'error'=>'Invalid video url provided.')));
- $AE->setParam( 'wmode','transparent');
- die( json_encode( array( 'attrb'=>$AE->getObjectAttribs(),'embed'=>$AE->getEmbedCode() )));
- }
- add_action( 'wp_ajax_mlvl_parse_embed_url','mlvl_parse_embed_url_ajax');
- add_action( 'wp_ajax_nopriv_mlvl_parse_embed_url','mlvl_parse_embed_url_ajax');
- function mlvl_head(){
- if( !mlvl_get_options( 'fbapp_id'))
- return;
- ;echo '<script type="text/javascript">
- ';
- $urlinfo = parse_url( get_bloginfo('wpurl'));
- echo "var mlvl_domain = '".untrailingslashit( $urlinfo['host'] ) ."';\n";
- echo "var mlvl_path = '".trailingslashit( $urlinfo['path'] ) ."';\n";
- ;echo '
- function mlvl_setCookie(name,value,days){
- var date = new Date();
- date.setDate(date.getDate() + days);
- var cookie_var = name + "=" + encodeURIComponent( value );
- cookie_var += "; expires=" + date.toUTCString();
- cookie_var += "; path=" + mlvl_path;
- cookie_var += "; domain=" + mlvl_domain;
- document.cookie = cookie_var;
- }
- window.fbAsyncInit = function(){
- FB.init({ appId: \'';echo mlvl_get_options( 'fbapp_id');;echo '\', status: true, channelUrl: \'';echo MLVL_URL;;echo 'channel.html\' });
- };
- </script>
- <div id="fb-root"></div>
- <script type="text/javascript">
- (function() {
- var e = document.createElement(\'script\');
- e.type = \'text/javascript\';
- e.src = document.location.protocol + \'//connect.facebook.net/en_US/all.js\';
- e.async = true;
- document.getElementById(\'fb-root\').appendChild(e);
- }());
- </script>
- <script type="text/javascript">var switchTo5x=true;</script>
- <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
- <script type="text/javascript">stLight.options({publisher: "ur-53228887-8dce-d0ad-2cb5-3a15648554f"});</script>
- ';
- }
- add_action( 'wp_head','mlvl_head');
- function mlvl_shortcode( $atts,$content ){
- extract( shortcode_atts( array(
- 'video_url'=>'',
- 'width'=>'',
- 'height'=>'',
- 'overlay'=>MLVL_URL.'images/patterns/default_.png',
- 'overlay_radius'=>'0px',
- 'overlay_opacity'=>'0.5',
- 'overlay_padding'=>'0px',
- 'action_text'=>'',
- 'action_text_color'=>'white',
- 'action_text_size'=>'12',
- 'action_text_pleft'=>'100px',
- 'action_text_ptop'=>'20px',
- 'action_text_weight'=>'400',
- 'action_text_align'=>'center',
- 'action_text_width'=>'200px',
- 'share_button'=>MLVL_URL.'images/buttons/unlock1.png',
- 'share_button_pleft'=>'100px',
- 'share_button_ptop'=>'180px',
- 'countdown_time'=>'0',
- 'countdown_pleft'=>'100px',
- 'countdown_ptop'=>'130px',
- 'share_title'=>( is_singular()) ?the_title('','',false) : get_bloginfo( 'name'),
- 'share_link'=>( is_singular()) ?get_permalink() : home_url( '/'),
- 'invites'=>'1',
- 'multiunlock'=>'0',
- 'social_buttons'=>'0',
- 'subscription_method'=>'',
- 'subscription_form_data'=>''
- ),$atts ));
- $multiunlock = (bool) $multiunlock;
- $social_buttons = (bool) $social_buttons;
- require_once( MLVL_DIR ."lib/Embed.class.php");
- $AE = new Embed();
- if( !$AE->parseUrl( $video_url ))
- return '';
- $AE->setWidth( $width );
- $AE->setHeight( $height );
- $AE->setParam( 'wmode','transparent');
- $locked = true;
- if( isset( $_COOKIE['mlvlmu'] ))
- $locked = false;
- $unlocked_videos = isset( $_COOKIE['mlvluv'] ) ?explode( ";",$_COOKIE['mlvluv'] ) : array();
- if( $locked &&!empty( $unlocked_videos ) &&in_array( md5( $video_url ),$unlocked_videos ))
- $locked = false;
- $UID = get_the_ID() .rand( 0,1000000000 );
- if( $multiunlock ){
- $unlocked_js = '
- mlvl_setCookie("mlvlmu", "1", 100);
- jQuery(".mlvl_overlay, .mlvl_action_text, .mlvl_countdown_wrap, .mlvl_share_button_wrap").remove();
- jQuery(".mlvl_socialbar_wrap, .mlvl_content_reveal_wrap").show();
- ';
- }
- else{
- if( isset( $_COOKIE['mlvluv'] ))
- $new_cookie = md5( $video_url ) .";".$_COOKIE['mlvluv'];
- else
- $new_cookie = md5( $video_url );
- $unlocked_js='
- mlvl_setCookie("mlvluv", "'.$new_cookie .'", 100);
- jQuery("#mlvideo-'.$UID .' .mlvl_overlay, #mlvideo-'.$UID .' .mlvl_action_text, #mlvideo-'.$UID .' .mlvl_countdown_wrap, #mlvideo-'.$UID .' .mlvl_share_button_wrap").remove();
- jQuery("#mlvideo-'.$UID .' .mlvl_socialbar_wrap, #mlvideo-'.$UID .' .mlvl_content_reveal_wrap").show();
- ';
- }
- $subscription_js = "";
- if( isset( $subscription_method ) &&in_array( $subscription_method,array( 'getresponse','mailchimp','icontact','aweber')) &&!empty( $subscription_form_data )){
- $subscription_form_data = maybe_unserialize( base64_decode( $subscription_form_data ));
- $subscription_js .= "// Do Subscribe Call\n";
- $subscription_js .= "\t\t\t\t\t\t\tFB.api('/me?fields=name,username,email', function(response){\n";
- $subscription_js .= "\t\t\t\t\t\t\tvar args = ".json_encode( $subscription_form_data ).";\n";
- $subscription_js .= "\t\t\t\t\t\t\targs.name = response.name;\n";
- $subscription_js .= "\t\t\t\t\t\t\targs.email = response.email;\n";
- $subscription_js .= "\t\t\t\t\t\t\tjQuery.post( '".admin_url( "admin-ajax.php") ."', {\"action\":\"mlvl_subscribe\", \"service\":\"$subscription_method\", \"args\":args});\n";
- $subscription_js .= "});\n\n";
- }
- $invites = (int) $invites;
- $width = (int) $width;
- $height = (int) $height;
- $countdown_time = intval( $countdown_time );
- if( !isset( $action_text_color ) ||!preg_match( '/^#[a-f0-9]{6}$/i',$action_text_color ))
- $action_text_color = "#FFF";
- $result = "<div class=\"mlvl_video\" style=\"width:{$width}px; min-height:{$height}px;\" id=\"mlvideo-$UID\">\n";
- if( $locked ){
- if( !empty( $action_text )){
- $result .= "\t<div class=\"mlvl_action_text\" style=\"
- width: {$action_text_width};
- left: {$action_text_pleft};
- top: {$action_text_ptop};
- color: {$action_text_color};
- font-size: {$action_text_size}px;
- font-weight: {$action_text_weight};
- text-align: {$action_text_align};
- \">\n";
- $result .= "\t\t$action_text\n";
- $result .= "\t</div>\n";
- }
- if( $countdown_time ){
- $result .= "\t<div class=\"mlvl_countdown_wrap\" style=\"
- left: {$countdown_pleft};
- top: {$countdown_ptop};
- color: {$action_text_color};
- text-align: center;
- \"></div><!--.mlvl_countdown_wrap-->\n";
- $result .= "\t<script type=\"text/javascript\">\n";
- $result .= "\t\tvar newYear = new Date();\n";
- $result .= "\t\tnewYear = new Date( newYear.getTime() + ( $countdown_time * 1000 ));\n";
- $result .= "\t\tjQuery(\"#mlvideo-$UID .mlvl_countdown_wrap\").countdown({until: newYear, format:'MS', compact: true});\n";
- $result .= "\t</script>\n";
- }
- $result .= "\t<div class=\"mlvl_share_button_wrap\" style=\"
- left: {$share_button_pleft};
- top: {$share_button_ptop};
- \">\n";
- $result .= "\t\t<a href=\"javascript:void(0);\" onclick=\"MLFBconnect_{$UID}();\">\n";
- $result .= "\t\t\t<img src=\"$share_button\" alt=\"Share with your facebook friends to unlock this Video\" />\n";
- $result .= "\t\t</a>\n";
- $result .= "\t</div>\n";
- $result .= "<div class=\"mlvl_overlay\" style=\"
- width:{$width}px;
- height:{$height}px;
- padding:{$overlay_padding};
- background:url({$overlay});
- border-radius: {$overlay_radius}; -moz-border-radius: {$overlay_radius}; -khtml-border-radius: {$overlay_radius};
- opacity: {$overlay_opacity};
- left: -{$overlay_padding};
- top: -{$overlay_padding};
- \"></div>\n";
- $result .= '
- <script type="text/javascript">
- function MLFBconnect_'.$UID.'(){
- FB.login(function(FB_response){
- if( FB_response.status === "connected" ){
- '.$subscription_js .'
- FB.ui({
- method: "apprequests",
- message: "'.$share_title.'",
- data: "'.base64_encode( $share_link ) .'"
- },
- function(response){
- if( response && response.to && response.to.length >= '.$invites.' ){
- '.$unlocked_js .'
- }else{
- alert("Invite atleast '.$invites.' friends to unlock & watch this video !!");
- }
- });
- }
- else{
- alert( "Connect your facebook account to unlock & watch this video !!" );
- }
- },
- {scope: "email"});
- }
- </script>';
- }
- # Video Object
- $result .= "<div style=\"
- width:{$width}px;
- height:{$height}px;\"
- class=\"mlvl_embed_wrap\"
- >{$AE->getEmbedCode()}</div>";
- if( !empty( $content )){
- $result .= "\t<div style=\"display:".( $locked ?'none':'block').";\" class=\"mlvl_content_reveal_wrap\">\n";
- $result .= "\t\t<a href=\"javascript:void(0);\" title=\"Close\" class=\"mlvl_content_reveal_remove\" onclick=\"jQuery(this).parent().remove();\">x</a>\n";
- $result .= "\t\t$content\n";
- $result .= "\t</div>\n";
- }
- if( $social_buttons ){
- $result .= "<div style=\"display:".( $locked ?'none':'block').";\" class=\"mlvl_socialbar_wrap\">\n";
- $result .= "<span class='st_sharethis_hcount' displayText='ShareThis'></span>\n";
- $result .= "<span class='st_facebook_hcount' displayText='Facebook'></span>\n";
- $result .= "<span class='st_twitter_hcount' displayText='Tweet'></span>\n";
- $result .= "<span class='st_linkedin_hcount' displayText='LinkedIn'></span>\n";
- $result .= "<span class='st_email_hcount' displayText='Email'></span>\n";
- $result .= "</div>\n";
- }
- $result .= "</div><!--#mlvideo-$UID-->\n";
- return $result;
- }
- add_shortcode( 'mlvl','mlvl_shortcode');
- function mlvl_guess_url( $exclude_vars = array('m,e,n'),$exclude_structure = array()){
- $schema = is_ssl() ?'https://': 'http://';
- $url = $schema .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI'];
- if( !empty( $exclude_vars ) &&!is_array( $exclude_vars )){
- $exclude_vars = explode( ',',$exclude_vars );
- $exclude_vars = array_unique( $exclude_vars );
- }
- if( !empty( $exclude_structure ))
- $url = preg_replace('#/('.implode('|',$exclude_structure ).')#i','',$url );
- if( !empty( $exclude_vars ))
- $url = remove_query_arg( $exclude_vars,$url );
- return $url;
- }
- # get plugin options
- function mlvl_get_options( $key = null ){
- $mlvl_options = get_option( 'mlvl_options');
- if( !$mlvl_options )
- return false;
- if( !$key )
- return $mlvl_options;
- if( !is_array( $key ) &&!array_key_exists( $key,$mlvl_options ))
- return false;
- if( is_array( $key )){
- $return = array();
- foreach( $key as $k ){
- $return[$k] = array_key_exists( $k,$mlvl_options ) ?$mlvl_options[$k] : '';
- }
- }
- else{
- $return = $mlvl_options[$key];
- }
- if( $return == ''||!isset( $return ) ||empty( $return ) ||false == $return ){
- if( is_array( $key ))
- return array();
- else
- return '';
- }
- return $return;
- }
- # update plugin options.
- function mlvl_update_options( $options = array(),$newonly = false ){
- if( empty( $options ))
- return;
- if( !is_array( $options ))
- $options = (array) $options;
- if( !$newonly ){
- $old_options = mlvl_get_options();
- $options = wp_parse_args( $options,$old_options );
- }
- update_option( 'mlvl_options',$options );
- return $options;
- }
- function mlvl($a){
- echo '<pre>';print_r($a);echo '</pre>'."\n\n\n";
- }
- ?>
Add Comment
Please, Sign In to add comment