| Author |
Message |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Tue Feb 24, 2004 2:44 pm |
|
Raven has a great script to allow all visitors to view downloads but restrict actual download of files to registered users only. Is it possible to have this same option but for subscribed users only(as in PHPNuke 7.10) please?
TIA |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Wed Feb 25, 2004 8:44 pm |
|
I haven't tried it yet, so ....
Find this code around line 1146 or so in Downloads/index.php | Code: | | if (!is_user($user)&&in_array($lid,$lidArray)&&!is_admin($admin)) { | and modify it to | Code: | | if (!paid()&&!is_admin($admin)) { |
|
|
|
|
 |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Thu Feb 26, 2004 1:35 am |
|
Thank You Raven, will test and report back  |
|
|
|
 |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Thu Feb 26, 2004 2:22 am |
|
Got this far... in /modules/Downloads/index.php...around line 1117
| Code: | function getit($lid) {
// Add a new line of code for each $lid to block for Registered Users only
$lidArray[] = 9999; // EXAMPLE!!!
$lidArray[] = 1; // EXAMPLE!!!
global $prefix, $dbi, $user, $admin;
if (!is_user($user)&&in_array($lid,$lidArray)&&!is_admin($admin)) {
$pagetitle = "- "._ACCESSDENIED."";
include("header.php");
title("$sitename: "._ACCESSDENIED."");
OpenTable();
echo "<center><b>"._RESTRICTEDAREA."</b><br><br>"
.""._MODULESSUBSCRIBER."";
if ($subscription_url != "") {
echo "<br>"._SUBHERE."";
}
echo "<br><br>"._GOBACK."";
CloseTable();
include("footer.php");
die();
} |
But it produces this
| Quote: | You are trying to access a restricted area.
We are Sorry but this section of our site is for Subscribed Users Only.
[ Go Back ] | and not this
| Quote: | You are trying to access a restricted area.
We are Sorry but this section of our site is for Subscribed Users Only.
You can subscribe to our services from here
[ Go Back ] |
Subscription url is quoted on config.php.
Your first suggestion did not have any affect.
Any advice gratefully received  |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Feb 26, 2004 1:37 pm |
|
Make sure that the module is active for All Visitors. Then try this | Code: | function getit($lid) {
global $prefix, $dbi, $user, $admin;
$lid = intval($lid);
$hits = intval($hits);
if (!paid()&&!is_admin($admin)) {
$pagetitle = "- "._ACCESSDENIED."";
include("header.php");
title("$sitename: "._ACCESSDENIED."");
OpenTable();
echo "<center><b>"._RESTRICTEDAREA."</b><br><br>"
.""._MODULESSUBSCRIBER.""
.""."<br>"._SUBHERE.""
.""."<br>"._GOBACK."";
CloseTable();
include("footer.php");
die();
}
sql_query("update ".$prefix."_downloads_downloads set hits=hits+1 WHERE lid=$lid", $dbi);
update_points(17);
$result = sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE lid='$lid'", $dbi);
list($url) = sql_fetch_row($result, $dbi);
Header("Location: $url");
} |
|
|
|
|
 |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Thu Feb 26, 2004 2:27 pm |
|
Looks great Raven, thanks, but where does
| Code: | // Add a new line of code for each $lid to block for Registered Users only
$lidArray[] = 9999; // EXAMPLE!!!
$lidArray[] = 1; // EXAMPLE!!!
|
fit in so that individual files are available for subscribed users only, or have I missed something in your coding please  |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Thu Feb 26, 2004 2:34 pm |
|
You don't need that any longer because to download you must be a subscriber which means you already are registered. |
|
|
|
 |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Fri Feb 27, 2004 1:13 am |
|
| Quote: | | You don't need that any longer because to download you must be a subscriber which means you already are registered. |
Why did I doubt you. Your last set of code works perfectly.
Carrying this on a stage further, if possible please, what code would need to be added so that majority of files in downloads are for all users only, but maybe only 2 or 3 download files are available just to subscribers? TIA |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Fri Feb 27, 2004 5:17 am |
|
Try this. It's very early here and I haven't tested it
| Code: | function getit($lid) {
// Add a new line of code for each $lid to block for Registered Users only
$lidArray[] = 9999; // EXAMPLE!!!
$lidArray[] = 1; // EXAMPLE!!!
global $prefix, $dbi, $user, $admin;
$lid = intval($lid);
$hits = intval($hits);
if (in_array($lid,$lidArray)&&!paid()&&!is_admin($admin)) {
$pagetitle = "- "._ACCESSDENIED."";
include("header.php");
title("$sitename: "._ACCESSDENIED."");
OpenTable();
echo "<center><b>"._RESTRICTEDAREA."</b><br><br>"
.""._MODULESSUBSCRIBER.""
.""."<br>"._SUBHERE.""
.""."<br>"._GOBACK."";
CloseTable();
include("footer.php");
die();
}
sql_query("update ".$prefix."_downloads_downloads set hits=hits+1 WHERE lid=$lid", $dbi);
update_points(17);
$result = sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE lid='$lid'", $dbi);
list($url) = sql_fetch_row($result, $dbi);
Header("Location: $url");
} |
|
Last edited by Raven on Fri Feb 27, 2004 5:54 am; edited 1 time in total |
|
|
 |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Fri Feb 27, 2004 5:49 am |
|
| Code: | | if (in_array($lid,$lidArray&&!paid()&&!is_admin($admin)) { |
Think that line above is not quite correct with the following showing
| Quote: | parse error on line 1124
|
|
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 16987 Location: Kansas
|
Posted:
Fri Feb 27, 2004 5:53 am |
|
| Code: | | if (in_array($lid,$lidArray)&&!paid()&&!is_admin($admin)) { |
|
|
|
|
 |
dezina Theme Guru

Joined: Dec 26, 2002 Posts: 57 Location: UK
|
Posted:
Fri Feb 27, 2004 6:05 am |
|
Perfect now.. Thank You  |
|
|
|
 |
|
|
|
|