Make mainpage private | Plikli Customization | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Make mainpage private
Avatar
Hiro
Member
Members
Forum Posts: 13
Member Since:
January 31, 2019
sp_UserOfflineSmall Offline
1
January 31, 2019 - 7:23 am
sp_Permalink sp_Print

Hi, I was wondering if it is possible to require users to be logged in to view the main page?

Avatar
redwine
Admin
Forum Posts: 324
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline
2
January 31, 2019 - 4:34 pm
sp_Permalink sp_Print

Hello Hiro and welcome to Plikli Community!

Yes, it is possible. However, I am not sure what would be the impact on search engines crawler, I guess they will no longer be able to crawl the page for indexing. You have to research it.

1- Open /index.php
2- Go to LINE 32 and hit enter to have a new line ( right after the line include(mnminclude.'smartyvariables.php'); )
3- Paste the following code :

if($main_smarty->get_template_vars('user_authenticated') === false) {
header("Location: $my_plikli_base/login.php");
}

Save the file.

Now, if a visitor comes to the Home page, if they are not authenticated, they will be redirect to the login page where they can login or create an account.

Avatar
Hiro
Member
Members
Forum Posts: 13
Member Since:
January 31, 2019
sp_UserOfflineSmall Offline
3
February 6, 2019 - 1:27 am
sp_Permalink sp_Print

I added this code to index.php, and noticed that other pages were available while not logged in. I then added it to advancedsearch.php, cloud.php, live.php, new.php, rssfeeds.php, story.php, and topusers.php and it seems to be working great now, thanks! Are there any other pages I should add it to to prevent non logged in users from viewing content?

Also, I'd like to hide the categories from non logged in users. I tried changing categories.tpl using a the inverse code as yours, but I think I must have messed up the syntax because everything below the nav bar disappeared and I got an error in the admin panel.

Anyhow, thanks again for your help. Do you have a Monero wallet address for donations?

Avatar
redwine
Admin
Forum Posts: 324
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline
4
February 6, 2019 - 2:04 am
sp_Permalink sp_Print

"I added this code to index.php, and noticed that other pages were available while not logged in."

In your original post, you just mentioned that you want people to be logged to view the main page. Here is your post:

"Hi, I was wondering if it is possible to require users to be logged in to view the main page?"

Instead of doing all this mess, why don't you tell me waht exactly do you want visitors (not logged in) to view, nothing unless logged in or what?

I am moving this topic to Customization forum, because it is no more just support.

Avatar
Hiro
Member
Members
Forum Posts: 13
Member Since:
January 31, 2019
sp_UserOfflineSmall Offline
5
February 9, 2019 - 8:47 am
sp_Permalink sp_Print

Yes, I am making a private site so I want people to only be able to view content if they're logged in.

Avatar
redwine
Admin
Forum Posts: 324
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline
6
February 9, 2019 - 2:45 pm
sp_Permalink sp_Print

You have to insert this function call in every file belonging to a page you only want logged in users to access.

force_authentication();

you insert it after all the includes at the top of the page. Example:

include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
include(mnminclude.'tags.php');
include(mnminclude.'search.php');
include(mnminclude.'smartyvariables.php');

force_authentication();

The files you might want to restrict are in the top and bottom (footer) navigation bars, and obviously the user file.

user profiles:
/user.php

Top navigation bar:
/index.php
/new.php
/groups.php

Footer navigation bar:
/advancedsearch.php
/live.php
/cloud.php
/rssfeeds.php

Avatar
Hiro
Member
Members
Forum Posts: 13
Member Since:
January 31, 2019
sp_UserOfflineSmall Offline
7
February 9, 2019 - 10:44 pm
sp_Permalink sp_Print

This seems to be working great. What template file would I need to edit to prevent the story categories from showing for logged out users?

Avatar
redwine
Admin
Forum Posts: 324
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline
8
February 9, 2019 - 10:59 pm
sp_Permalink sp_Print

Edit /templates/bootstrap/categories.tpl

add this at the top of the page, right before the div container

{if $user_authenticated eq 1}

and at the bottom of the page, after the closing div tag, add this:

{/if}

Forum Timezone: Asia/Beirut

Most Users Ever Online: 16

Currently Online:
6 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

john: 47

Nishant kumar: 33

Mosage: 25

Punk: 23

Martin Gold: 22

Felipe: 21

Hiro: 13

StaticMove: 13

yami: 13

Cesar: 12

Newest Members:

Quinta

arun bhanot

Oliva Mutia

Jasa Seo Terbaik

bhawanaconsultancy

gamus

abbslaw

Aniruddh Nishad

Quid Slots

sk1212

Forum Stats:

Groups: 1

Forums: 8

Topics: 109

Posts: 655

 

Member Stats:

Guest Posters: 0

Members: 114

Moderators: 0

Admins: 1

Administrators: redwine