Jump to content

[SOLVED] php include file calls another file


HawkCode

Recommended Posts

Hi,

 

I have a php file included in many differant files at all differant levels in the directory structure.

 

The problem I have is if a condition is met, it passes control to another php file in the same directory.

 

However that file is not found by all files in the other directorys.

 

 

home/file1.php    <---------- Includes inc/file2.php  ----> inc/file2.php

 

home/file2.php passes control to inc/file2.php >>>>> This works

 

 

 

home/dir1/file1a.php  <---------- Includes inc/file2.php  ----> ../inc/file2.php

 

home/file2.php passes control to inc/file2.php >>>>> This doesn't work.

 

How can I have the include file's call to files in the same directory no matter where the file that included it is?

 

Thanks

 

 

 

 

I'm getting this error: /var/www/localhost/htdocs/AccessControl/Login.php was not found on this server.

 

Here's the line:

$MM_restrictGoTo = $_SERVER['DOCUMENT_ROOT'] . "/AccessControl/Login.php";

 

 

This works:

$MM_restrictGoTo = "AccessControl/Login.php";

 

THe file including it is in directory above AccessControl

 

THanks

 

 

 

I tried  using Absolute path using this:

 

define ("ROOT", dirname(__FILE__));

 

Got this error:

 

The requested URL /var/www/aspe.org/htdocs/AccessControl/Login.php was not found on this server.

 

This is the code calling it:

if ($MinAccessLevel > 0) {
    $MM_restrictGoTo = ROOT . "/AccessControl/Login.php";
    if (!((isset($_SESSION['LoginID'])) && (isAuthorized("",$MinAccessLevel, $_SESSION['LoginID'], $_SESSION['AccessLevel'])))) {
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
      $MM_referrer .= "?" . $QUERY_STRING;
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
    
        header(sprintf("Location: %s", $MM_restrictGoTo . SID ));
      exit;
    }  

 

This is code that was generated by Dreamweaver and I copied it.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.