PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Download Count Vs. Page View

s2Member Plugin. A Membership plugin for WordPress®.

Download Count Vs. Page View

Postby drbyte » December 29th, 2011, 10:59 pm

Hi Guys

Is there a way to stop download counts if the actual video has not been viewed?

Using this:

Code: Select all
"url_to_storage_source" => true, "check_user" => true, "count_against_user" => true); ?>


NOTE:
If count_against_user is set to false, the video will become publicly viewable

Site scenario:

membership levels: A, B, C

A- Unlimited streaming via rmtp
B- Unlimited streaming via rmpt + 10 video downloads per/mo
C- Unlimited streaming via rmpt + 20 video downloads per/mo

and so forth

Now, when I click on the post that have the video/rtmp/jwplayer + the url to download the file, it counts as 1 Download and that's even before I do anything (Downloading the file or even play it)

I am assuming that using rtmp/S3/CloudFront, the Url generated acts as 1 available download.

Now, each post I view counts the same till all available downloads are exhausted and member get locked out.

I could use if_user_can but that's a messy code especially having more than 4 levels.

Any ideas!!

Thank You

Sam

Updates:

Well, It seems that removing count_against_user" => true from

Code: Select all
"url_to_storage_source" => true, "check_user" => true, "count_against_user" => true); ?>


will do the trick as long you have
Code: Select all
check_user" => true


Sam

Update 2:

After couple of tries, the JWPlayer player disappears when the count reach it's limits

Any Ideas of how to keep the Player and just limit the number of downloads
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Download Count Vs. Page View

Postby drbyte » December 30th, 2011, 2:30 am

Jason

Is there any future plans to incorporate Reset Download Restrictions button to the user profile?

Thank you
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Download Count Vs. Page View

Postby drbyte » December 30th, 2011, 3:29 am

I think there is a count conflict having the streaming player and the download link on the same page.

Sometimes, even when the download limit has been exceeded, on some pages you can still see the Player. Sometimes, in IE9 when you click on the download link, it takes you to an error page. Sometimes it takes you to the download exceed page.

I am not sure but I will keep testing and post back

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Download Count Vs. Page View

Postby Jason Caldwell » December 30th, 2011, 11:21 pm

If count_against_user is set to false, the video will become publicly viewable

Updates:
Well, It seems that removing count_against_user" => true from
Code: Select all
"url_to_storage_source" => true, "check_user" => true, "count_against_user" => true); ?>

will do the trick as long you have
Code: Select all
check_user" => true

Update 2:
After couple of tries, the JWPlayer player disappears when the count reach it's limits
Any Ideas of how to keep the Player and just limit the number of downloads

Can I see the code that you ended up with please?

Also, please keep this in mind while testing.
SNAG-0002.png
SNAG-0002.png (15.15 KiB) Viewed 309 times

( click image to enlarge )
SNAG-0000.png


Is there any future plans to incorporate Reset Download Restrictions button to the user profile?
Yes, this is on our list. s2Member is currently undergoing a rewrite to make it more powerful at a fundamental level, but we are also working from a master TODO list, and this is on it. In the mean time, it's possible to reset the counters via PHP, by deleting the meta key.
Code: Select all
<?php
delete_user_option 
($user_id, "s2member_file_download_access_log");
?>
s2Member will regenerate this automatically upon their next download.

Sometimes, even when the download limit has been exceeded, on some pages you can still see the Player. Sometimes, in IE9 when you click on the download link, it takes you to an error page. Sometimes it takes you to the download exceed page.
Sorry, it's difficult to troubleshoot things like this, because there are just so many variables at play. For instance, browser cache could be a factor. By default, s2Member will NOT allow browser caching on file downloads. However, with CloudFront, the ball is entirely in your court with this. See screenshot below. Also, it's possible that you're generating links differently (i.e. with or without check_user?). If you can give me a specific path to follow in reproducing this, I'll be happy to investigate it further though. Code samples perhaps.

( click image to enlarge )
SNAG-0001.png
I also recommend sending Cache-Control headers via Amazon S3 Metadata.
See: http://www.mnot.net/cache_docs/
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Download Count Vs. Page View

Postby drbyte » December 31st, 2011, 12:58 am

Hi Jason

Thank you

Here's what I have

Code: Select all
<?php
$cfg = array ("file_download" => get_post_meta(get_the_ID(), "movie", true), "check_user" => true); ?>

<?php if (($mp4 = s2member_file_download_url ($cfg, "get-streamer-array"))) { ?>

<script type="text/javascript">
        jwplayer("jw-container").setup({modes: /* JW Player. */
        [
            /* First try real-time streaming with Flash player. */
            {type: "flash", provider: "rtmp", src: "/jwplayer/player.swf",
                config: {streamer: "<?php echo $mp4["streamer"]; ?>", file: "<?php echo $mp4["file"]; ?>"}},
       
        ],
      autostart: false,
      controlbar: "bottom",
      skin: "new/glow.zip",
        /* Set video dimensions. */ width: 750, height: 480
        });
    </script>

<?php } else /* Access is denied to the current User. */ { ?>
<?php } ?>


and

Code: Select all
https://site.com?s2member_file_download=<?php echo get_post_meta($post->ID, "movie", $single = true); ?>


The were so many requests to have the videos available to download. So I came up with

A. Unlimited streaming Only for level 1
B Unlimited streaming + 10 downloads $/mo Level 2
C Unlimited streaming + 20 downloads $/mo Level 3

And so forth

But what ended up happening is cloudfront issuing an valid link to the media and count it as 1 download. So if the member is browsing the site, they are loosing download counts and or if the member reaches the download limits, JWplayer disappears

Now, it's not a secret that anybody in level 1 can look at the source code and take the rtmp file name and use this
Code: Select all
/?s2member_file_download=example-file.zip
to download it

The only way to protect it is by limiting the numbers of downloads per member. But doing so, it will limit the unlimited streaming too.

Now, if there is a way to instead of showing the file name, S2 issues an temp file name just for the download option which expires once the download is finished or if the person waited for a period of time to download it.

As far the unlimited streaming plus an option to download, I am stuck..

Code: Select all
    <?php
    delete_user_option ($user_id, "s2member_file_download_access_log");
    ?>


Very Handy, thank you

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Download Count Vs. Page View

Postby Jason Caldwell » December 31st, 2011, 9:01 am

Hi Sam. Hope you're having a wonderful New Year's Eve!

I apologize in advance if I've missing something here, but it looks like what you've got covers all the bases you're dealing with already. I'll explain below.

You said:
As far the unlimited streaming plus an option to download, I am stuck..

It looks like you've already accomplished this to me. Your initial call to s2member_file_download_url($cfg, "get-streamer-array"), includes only the check_user directive, and it excludes the count_against_user directive, leaving it at the default value of false. This means that your Members must have access to the file, but streaming the videos is not counting against them (i.e. they get unlimited streaming).

Your direct link to download the video is fine also. Upon clicking this link, a file download WILL be tabulated against them, and that's what you want, correct?
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Download Count Vs. Page View

Postby drbyte » January 2nd, 2012, 12:28 pm

Hi Jason

Happy New Year

My code is correct but it's not working as it suppose to.

Here is the problem.

When removing the count form the JWPlayer, it's not suppose to count, but it's limited to what the download restriction are set to. For example, if Level 1 set to 2 movies per 1 day, when the member view 2 movies per the JWPalyer (rtmp), the next time they try to log in, they can't play anything because the whole player disappears. That's has nothing to do with the download option, just the JW Player with rmtp only option.

Now, when I have the second option on, which is the download link, once the member reaches the limit, the player disappear and the download link rejects the request. I am not sure why the player disappear since it's not suppose to count. I tried it many times but kept getting the same results.

So, my question is, is JWplayer restricted by the download restriction when it's set not to count how many times it's been viewed? It's suppose to only check membership level in this case.

Thank You

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Download Count Vs. Page View

Postby Jason Caldwell » January 2nd, 2012, 10:35 pm

Hi Sam. Thanks for the follow-up.

Crystal clear now. I see what the issue is. With "check_user" true, s2Member DOES still check the User's account, including their Download Limitations. It does NOT count the file against them, but it does check to make sure they've not already exceeded their limit. This is part of the "check_user" routine, and I think it should remain that way.

That being said... Since your site is counting direct file downloads, this is interfering with unlimited streaming in a negative way. I just took a look at s2Member's source code to see if I could provide you with a Hook/Filter to make this possible. There's not a good one to use for this yet. However, there is a simple hack you can make to s2Member's source code (one line), that will make this possible for you.

Open this file:
/s2member/includes/classes/files-in.inc.php at line #222
find this snippet...
Code: Select all
if($user_previous_file_downloads >= $user_file_downloads["allowed"] 
Change it to:
Code: Select all
if($updating_user_counter && $user_previous_file_downloads >= $user_file_downloads["allowed"] 
* I'll see what we can do in a future release to make this easier to deal with. Something more intutive that allows one to configure this behavior, or possibly another function parameter (i.e. check_user_counter).
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Download Count Vs. Page View

Postby drbyte » January 3rd, 2012, 4:07 am

Hi Jason

Thank you..I tried the code but it does not seems to work. I tried multiple times but it seems to be stuck and I think i know what's causing it. the member id that i was using was already over the limit of downloads so basically browsing was not possible using that member ID. I have to flush the logs first and this

Code: Select all
<?php
    delete_user_option ($user_id, "s2member_file_download_access_log");
    ?>


is not working somehow.

I tired creating a new user and it seems to be holding but there is a small problem when it comes from upgrading and downgrading the member using different levels. So If a member on Level 6 with unlimited streaming and 60 downloads per month downgrading the membership to level 1, they would not be able to get the unlimited streaming unless I delete the download logs.

This would work check_user_counter and would be a plus to get it working.

I may suggest Jason, It may be a good idea to keep the check user separate from member download restriction so if the member upgrade or downgrade wont face any issues.

This might be a good idea too if the actual file name get encrypted and have a short expiration time not a date. So if the member requests a file to be downloaded, it gives them the link without them needing to know the actual file name or the link it's coming from and if they don't download it right away, they would have to regenerate the link. They get like 3 tires per day to download the link other wise it will count as one download and they loose it.!!!

something like $secret = '66743tw69hd5s84hw6'; defined by S2member backend

To me, it's easier said than done...My IQ with this kind of stuff is way too far below yours, so all what I can do is day dream these kind of stuff. :)

Thank you again, looking forward to any new changes.

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010

Re: Download Count Vs. Page View

Postby Jason Caldwell » January 5th, 2012, 12:18 am

Hi Sam. Thanks for the follow-up.
~ I got your email regarding Wowza also, thank you.

Code: Select all
<?php
delete_user_option 
($user_id, "s2member_file_download_access_log");
?>
Just to make sure, you are setting the value of $user_id, correct?

Code: Select all
<?php
$user_id 
= 123;
delete_user_option ($user_id, "s2member_file_download_access_log");
?>


This would work check_user_counter and would be a plus to get it working.
I'll see what I can do about this for a future release.

So If a member on Level 6 with unlimited streaming and 60 downloads per month downgrading the membership to level 1, they would not be able to get the unlimited streaming unless I delete the download logs.
s2Member automatically resets this log each time a promotion or demotion occurs, including Subscription Modifications. So unless you need to purge it on-demand for a specific User, you shouldn't need to worry about this aspect.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Download Count Vs. Page View

Postby drbyte » January 5th, 2012, 12:22 pm

Thank you

I will try the code tonight. Yes I did not specify any IDs :roll:

Sam
User avatar
drbyte
Experienced User
Experienced User
 
Posts: 269
Joined: May 6, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 1 guest

cron