Jump to content
TNG Community
Georgson

Accessing db from subfolder - simple question

Recommended Posts

Georgson

Hi

I'm a total newbie, sorry if this is answered somewhere else!

I have uploaded a Lightroom photo album to a subfolder, and I would like to restrain access to the album.  I want only registered users to have access, and i'm just looking for some help to access the database from the subfolder to check if the user is logged in or not.

What changes must I make to get tng_db_connect work from the subfolder?

<?php

include($rootpath."tng_begin.php");
include($rootpath."templateconfig.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;    
if( $currentuser ) {
        echo "<p><strong>{$text['welcome']}, $currentuserdesc.</strong></p>\n";
    }

/!- define variables -->

$notloggedin = "Permission denied.<br />
    Do login to see all data and photos.<br />If you are family member/relative, please do <a href='/wp-tng-registration/'><strong>Register </strong></a>
or <a href='/contact-us/'><b>Contact Me</b></strong></a> for more details";
$loggedin = "Welcome to the family photo album.<br />
If you have any additional information, please do  share by <a href='/contact-us/'><b>Contact Me</b></strong></a> ";

<!-- Dispaly variable -->
echo $loggedin;
    echo $notloggedin;
    
?>

Share this post


Link to post
Share on other sites
Ken Roy

While your question might appear to be a "simple question", access rights for TNG Users is a complex issue.  I would refrain from modifying the tng_db_connect script since it controls your database access does not have anything to do with folder locations. 

The above is offered only to prevent you from crippling your TNG database access.

 

Share this post


Link to post
Share on other sites
Georgson

Thank you for your kind and swift response.

Da you have any suggestions for me?  Would there be any global varaibles within range?

Share this post


Link to post
Share on other sites
Ken Roy

Maybe I misunderstood your question.  If you are writing your own PHP module to control access to your Adobe Lightroom album, you need to look at the TNG Wiki Getting Started Guide

The articles on User pages might be helpful.  The TNG historytemplate.php file is meant to be executed from a subfolder so it should provide the correct $cms['tngpath'] variable setup to access the TNG files from a subfolder.

Share this post


Link to post
Share on other sites
Georgson

Thank you, I'll take a look! 

I've just dived into the TNG without reading anything.  Maybe at this time, it won't be so confusing with all the TNG-terms...  :-)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×