Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
dezina
Theme Guru



Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Tue Feb 24, 2004 2:44 pm Reply with quote

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
 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Wed Feb 25, 2004 8:44 pm Reply with quote

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)) {
 
View user's profile Send private message
dezina







PostPosted: Thu Feb 26, 2004 1:35 am Reply with quote

Thank You Raven, will test and report back Wink
 
dezina







PostPosted: Thu Feb 26, 2004 2:22 am Reply with quote

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 Confused
 
Raven







PostPosted: Thu Feb 26, 2004 1:37 pm Reply with quote

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







PostPosted: Thu Feb 26, 2004 2:27 pm Reply with quote

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 Embarassed
 
Raven







PostPosted: Thu Feb 26, 2004 2:34 pm Reply with quote

You don't need that any longer because to download you must be a subscriber which means you already are registered.
 
dezina







PostPosted: Fri Feb 27, 2004 1:13 am Reply with quote

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. Wink 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







PostPosted: Fri Feb 27, 2004 5:17 am Reply with quote

Try this. It's very early here and I haven't tested it Smile
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







PostPosted: Fri Feb 27, 2004 5:49 am Reply with quote

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







PostPosted: Fri Feb 27, 2004 5:53 am Reply with quote

Code:
if (in_array($lid,$lidArray)&&!paid()&&!is_admin($admin)) {
 
dezina







PostPosted: Fri Feb 27, 2004 6:05 am Reply with quote

Perfect now.. Thank You Very Happy
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©