Protect PHP Files Outside the Install Directory

Have you made a modification to Quadodo? Do you think that function/class you wrote will make you the most popular code monkey here? Post it now!

Protect PHP Files Outside the Install Directory

Postby Josh on Sun Feb 14, 2010 5:26 pm

There's usually a need to protect PHP files outside of the directory Quadodo was originally installed in.

For example, say QLS was installed in the root of the site and is accessible as follows:
Code: Select all
/login.php
/register.php
/...

...but wait! Your organizational requirements/skillz are waaay beyond simply putting everything in the root. You decide to use folders, only to find that QLS doesn't seem to have any effect on the new test files. Low and behold, the solution to your problems! :D
Code: Select all
// you're in /something/else/here/
$main_directory = str_replace('/something/else/here', dirname(__FILE__));
define('QUADODO_IN_SYSTEM', true);
require_once($main_directory . '/header.php');

Just use that at the top of any new PHP file you want to protect, being careful to CHANGE the folder location.
Josh
Site Admin
 
Posts: 476
Joined: Mon Nov 05, 2007 7:30 pm
Location: California

Re: Protect PHP Files Outside the Install Directory

Postby b.beev on Wed Feb 24, 2010 10:30 am

I'm trying to do this, but I'm not getting how this works.

This is what i have..

<?php
$main_directory = str_replace('../../../includes/header.php', dirname(__FILE__));
define('QUADODO_IN_SYSTEM', true);
require_once($main_directory . 'page.php');
?>

But when I go to the page, I can still view it...

My login folder is set up at the root and the page I want to protect is located in a different folder. Maybe I'm reading this wrong, but I thought I could protect that page.
Is this possible?
b.beev
New
 
Posts: 12
Joined: Thu Oct 30, 2008 8:52 pm

Re: Protect PHP Files Outside the Install Directory

Postby b.beev on Wed Feb 24, 2010 1:51 pm

I forgot to add that I'm getting the You don't have the correct permissions to view this page
b.beev
New
 
Posts: 12
Joined: Thu Oct 30, 2008 8:52 pm

Re: Protect PHP Files Outside the Install Directory

Postby dragonfire on Sat Mar 06, 2010 11:49 pm

I'm trying to do this, but I'm not getting how this works.

This is what i have..

<?php
$main_directory = str_replace('../../../includes/header.php', dirname(__FILE__));
define('QUADODO_IN_SYSTEM', true);
require_once($main_directory . 'page.php');
?>

But when I go to the page, I can still view it...

My login folder is set up at the root and the page I want to protect is located in a different folder. Maybe I'm reading this wrong, but I thought I could protect that page.
Is this possible?


<?php
$main_directory = str_replace('../../../includes/header.php', dirname(__FILE__));
define('QUADODO_IN_SYSTEM', true);
require_once($main_directory . 'page.php');
?>

instead try

<?php
$main_directory = str_replace('../../../includes/header.php', dirname(__FILE__));
define('QUADODO_IN_SYSTEM', true);
require_once($main_directory . 'header.php');
?>

I forgot to add that I'm getting the You don't have the correct permissions to view this page


You have to allow your account to have access in the QLS Admin Panel

Hope that helps :roll:
I'm just trying to help people. Because i like the script.
User avatar
dragonfire
A Regular
 
Posts: 93
Joined: Sat Oct 03, 2009 8:58 pm
Location: USA


Return to User Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron