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
minipucchi
New Member
New Member


Joined: Jul 09, 2006
Posts: 9

PostPosted: Tue Aug 08, 2006 6:48 am Reply with quote

I wanna do something like this site.

Only registered users can see links on this board! Get registered or login!

Quote:
ONLY REGISTERED USERS CAN VIEW THE REST OF THIS POST (INCLUDED DOWNLOAD LINKS). PLEASE REGISTER NOW TO DISCOVER INSIDE,THIS 'S COMPLETELY FREE.
IF YOU REGISTERED ALREADY, CLICK HERE TO LOGIN.


Any ideas how? ^^
 
View user's profile Send private message
kguske
Site Admin


Joined: Jun 04, 2004
Posts: 6383

PostPosted: Tue Aug 08, 2006 1:26 pm Reply with quote

If you're up for the coding task, you can copy the logic that determines whether a visitor can see a module, but put it inside the module, rather than in the modules.php or mainfile.php.

_________________
I google, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
minipucchi
PostPosted: Tue Aug 08, 2006 3:21 pm Reply with quote

darn.. but i'm not good with php coding... can any one here able to help me out?

Thanks in advance ^^!!
 
hitwalker
Sells PC To Pay For Divorce


Joined:
Posts: 5661

PostPosted: Wed Aug 09, 2006 10:03 am Reply with quote

ok here we go......

Edit the file modules/News/article.php with a decent text editor ...


just before the lines:

Code:
 if ($save AND is_user($user)) {


    cookiedecode($user);

    $db->sql_query("UPDATE ".$user_prefix."_users SET umode='$mode', uorder='$order',
thold='$thold' where uid='$cookie[0]'");

    getusrinfo($user);

    $info = base64_encode("$userinfo[user_id]:$userinfo[username]:

$userinfo[user_password]:$userinfo[storynum]:$userinfo[umode]:

$userinfo[uorder]:$userinfo[thold]:$userinfo[noscore]");

    setcookie("user","$info",time()+$cookieusrtime);

}





insert the following:

Code:
if (!is_user($user) AND !is_admin($admin)) {


$pagetitle = "- "._ACCESSDENIED."";

include("header.php");

title("$sitename: "._ACCESSDENIED."");

OpenTable();

echo "<center><b>"._RESTRICTEDAREA."</b><br><br>"

.""._MODULEUSERS."";

$sql = "SELECT mod_group FROM ".$prefix."_modules WHERE title='$name'";


$result = $db->sql_query($sql);

$row = $db->sql_fetchrow($result);

if ($row[mod_group != 0]) {

$sql = "SELECT name FROM ".$prefix."_groups WHERE id='$row[mod_group]'";


$result = $db->sql_query($sql);

$row = $db->sql_fetchrow($result);

echo ""._ADDITIONALYGRP.": <b>$row[name]</b><br><br>";

}

echo ""._GOBACK."";

CloseTable();

include("footer.php");

die();

}



The displaying of the whole article takes place after you click on the "Read more..." link.
If you examine the url of that link (right-click on it and choose "Copy link location" or a similar menu item from your browser's context menu, then insert the copied url with Ctrl+V in the browser's URL field), you will see that it is of the form:
Only registered users can see links on this board! Get registered or login!

The "file" url parameter ("file= article" in the above url) tells the modules.php file to execute the file "article.php" of the module whose name was passed with the "name" url parameter ("name=News" in the above URL, i.e. the News module).
So the displaying of the whole article text is done in the article.php file of the News module, which is exactly the modules/News/article.php file.

To restrict acces to registered users only, we have to use a similar code as the one used in modules.php.
If you open modules.php, you will see large blocks of code that do nothing else than check whether the user is registered or not (or
is an administrator or not) and restrict access accordingly.
You can find the relevant code blocks if you search for the text constants _ACCESSDENIED and _RESTRICTEDAREA.

The code block to be inserted in modules/news/article.php is taken verbatim from
modules.php, where it forms a part of an IF...THEN...ELSE statement:


Code:
} elseif ($view == 1 AND !is_user($user) AND !is_admin($admin)) {


$pagetitle = "- "._ACCESSDENIED."";

include("header.php");

title("$sitename: "._ACCESSDENIED."");

OpenTable();

echo "<center><b>"._RESTRICTEDAREA."</b><br><br>"


.""._MODULEUSERS."";

$sql = "SELECT mod_group FROM
".$prefix."_modules WHERE title='$name'";

$result = $db->sql_query($sql);

$row = $db->sql_fetchrow($result);

if ($row[mod_group != 0]) {

$sql = "SELECT name FROM ".$prefix."_groups
WHERE id='$row[mod_group]'";

$result = $db->sql_query($sql);

$row = $db->sql_fetchrow($result);

echo ""._ADDITIONALYGRP.": <b>$row[name]</b><br><br>";


}

echo ""._GOBACK."";

CloseTable();

include("footer.php");

die();

}


You just have to take away the $view == 1 check and change the "elseif" to an "if".
 
View user's profile Send private message
minipucchi
PostPosted: Thu Aug 10, 2006 7:04 am Reply with quote

thanks.. but i'm using NSN News? I dont know how to edit it in NSN News.
Sorry to trouble you again!!
 
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 ©