diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php index 5703ebf..c845117 100644 --- a/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php +++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php @@ -85,4 +85,36 @@ function fopen_fetch_image($url) { return $image; } +if ( !defined( 'DECODE_ENCODE_KEY' ) ) + define( 'DECODE_ENCODE_KEY', 'asong2u' ); + +function bp_dedication_encode($string) { + $key = sha1($key); + $strLen = strlen($string); + $keyLen = strlen($key); + for ($i = 0; $i < $strLen; $i++) { + $ordStr = ord(substr($string,$i,1)); + if ($j == $keyLen) { $j = 0; } + $ordKey = ord(substr($key,$j,1)); + $j++; + $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); + } + return $hash; +} + +function bp_dedication_decode($string) { + $key = sha1($key); + $strLen = strlen($string); + $keyLen = strlen($key); + for ($i = 0; $i < $strLen; $i+=2) { + $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); + if ($j == $keyLen) { $j = 0; } + $ordKey = ord(substr($key,$j,1)); + $j++; + $hash .= chr($ordStr - $ordKey); + } + return $hash; +} + + ?> diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-notifications.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-notifications.php index 9cd9cfe..3255e2e 100644 --- a/wp-content/plugins/bp-dedication/includes/bp-dedication-notifications.php +++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-notifications.php @@ -14,7 +14,11 @@ function bp_dedication_send_dedication_notification( $post_id, $to_user_id, $fro /* Now we need to construct the URL's that we are going to use in the email */ $sender_profile_link = bp_core_get_userlink($from_user_id, false, true); $sender_new_dedication_link = bp_core_get_userlink($to_user_id, false, true) . $bp->dedications->slug . '/new-dedication/user/' . $from_user_id; - $post_link = get_permalink($post_id); + + $enc_link = bp_dedication_encode(get_permalink($post_id)); + + $post_link = get_option('siteurl') . '/index.php'; + $post_link = add_query_arg('refid', $enc_link, $post_link); /* Set up and send the message */ $to = $reciever_ud->user_email; diff --git a/wp-content/themes/score/functions.php b/wp-content/themes/score/functions.php index dba8edb..08b0dd9 100644 --- a/wp-content/themes/score/functions.php +++ b/wp-content/themes/score/functions.php @@ -194,9 +194,9 @@ function gp_enqueue_scripts() { if (!is_admin()) { wp_enqueue_script('jquery'); - wp_enqueue_script('jqueryui'); + //wp_enqueue_script('jqueryui'); - //wp_enqueue_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array('jquery')); + wp_enqueue_script('jqueryui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array('jquery')); if (is_singular()) wp_enqueue_script('comment-reply'); @@ -215,10 +215,10 @@ function gp_enqueue_scripts() { wp_enqueue_script('froogaloop', get_template_directory_uri() . '/lib/scripts/videoslider/js/froogaloop.min.js', array('jquery')); wp_enqueue_script('apPlaylistManager', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apPlaylistManager.min.js', array('jquery')); - wp_enqueue_script('apYoutubePlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apYoutubePlayer.js', array('jquery')); - wp_enqueue_script('apVimeoPlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apVimeoPlayer.js', array('jquery')); - //wp_enqueue_script('videoGallery', get_template_directory_uri().'/lib/scripts/videoslider/js/jquery.videoGallery.min.js', array('jquery')); - wp_enqueue_script('videoGallery', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.videoGallery.js', array('jquery')); + wp_enqueue_script('apYoutubePlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apYoutubePlayer.min.js', array('jquery')); + wp_enqueue_script('apVimeoPlayer', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.apVimeoPlayer.min.js', array('jquery')); + wp_enqueue_script('videoGallery', get_template_directory_uri().'/lib/scripts/videoslider/js/jquery.videoGallery.min.js', array('jquery')); + //wp_enqueue_script('videoGallery', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.videoGallery.js', array('jquery')); wp_enqueue_script('mousewheel', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.mousewheel.js', array('jquery')); //wp_enqueue_script('sharrre', get_template_directory_uri() . '/lib/scripts/videoslider/js/jquery.sharrre-1.3.0.min.js', array('jquery')); @@ -624,4 +624,65 @@ function cutstr($str, $length, $ellipsis=''){ } + +function add_fs_var($public_query_vars) { + $public_query_vars[] = 'fs'; + return $public_query_vars; +} +add_filter('query_vars', 'add_fs_var'); + + +function play_video_on_full_screen() { + $fs = get_query_var('fs'); + return ($fs == '1'); +} + +if(!function_exists('_log')){ + function _log( $message ) { + if( WP_DEBUG === true ){ + if( is_array( $message ) || is_object( $message ) ){ + error_log( print_r( $message, true ) ); + } else { + error_log( $message ); + } + } + } +} + +function make_encoded_dedications_visible_for_nonusers($visibility) { + if(isset($_COOKIE['refid'])) { + setcookie('refid','',time()-3600, SITECOOKIEPATH); + $_COOKIE['refid'] = null; + unset( $_COOKIE['refid'] ); + // Puede ser visible + return false; + } else { + return $visibility; + } +} +add_filter('pbp_login_required_check', 'make_encoded_dedications_visible_for_nonusers', 1); + +function gp_encoded_dedication_redirect_for_nonusers($current_uri, $redirect_to) { + wp_parse_str($_SERVER['QUERY_STRING'], $args); + if (key_exists('refid', $args)) { + setcookie("refid", 1, time()+60, SITECOOKIEPATH); // Cookie con 1 minuto de validez + $decoded_url = bp_dedication_decode($args['refid']); + return add_query_arg('fs', 1, $decoded_url); + } + else return $current_uri; +} +add_filter('pbp_redirect_login_page', 'gp_encoded_dedication_redirect_for_nonusers', 1, 2); + + +function gp_encoded_dedication_redirect_for_users() { + if ( true == is_user_logged_in() ) { + wp_parse_str($_SERVER['QUERY_STRING'], $args); + if (key_exists('refid', $args)) { + $decoded_url = bp_dedication_decode($args['refid']); + wp_redirect(add_query_arg('fs', 1, $decoded_url)); + } + } +} +add_action('wp', 'gp_encoded_dedication_redirect_for_users', 2); + ?> \ No newline at end of file diff --git a/wp-content/themes/score/header.php b/wp-content/themes/score/header.php index 18a0817..5bb67a0 100644 --- a/wp-content/themes/score/header.php +++ b/wp-content/themes/score/header.php @@ -78,10 +78,10 @@