Jump to content

[SOLVED] require_once() with AJAX?


MasterACE14

Recommended Posts

Hello,

 

I have my script setup like the following...

<?php // main file
// include GET engine
require_once("C:\wamp\www\GETengine\index.php");
// start
require_once("start.php");
require_once("includes.php");
// HTML compression
if($config['htmlcompress'] == 1)
ob_start( 'ob_gzhandler' );
?>

<!-- HTML... header.. left panel etc -->

<div id="content">

</div>

 

in the #content div, a PHP file is loaded with the use of AJAX depending on what link was clicked. However what I have at the top with the 3 require_once()'s

they aren't included in whatever PHP file is loaded in the #content div.

 

Is there a way so I can include those 3 files in each page loaded in #content, without actually copy & pasting that into each individual PHP file?

 

Any help/info/suggestions are appreciated.

 

Regards, Ace

Link to comment
Share on other sites

I've just changed the files so require_once is called within the scripts like you suggested.

// include GET engine
require_once("../GETengine-1.0.0/index.php");
// start
require_once("../start.php");
require_once("../includes.php");

 

that works fine for the last 2. But for the GET engine I'm getting a error I haven't encountered before :S

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The given path is not a directory.' in C:\wamp\www\newcf\GETengine-1.0.0\includes\functions.php:51 Stack trace: #0 C:\wamp\www\newcf\gamefunctions.php(2): getDirectoryTree('gamefunctions') #1 C:\wamp\www\newcf\includes.php(2): require_once('C:\wamp\www\new...') #2 C:\wamp\www\newcf\lib\home.php(6): require_once('C:\wamp\www\new...') #3 {main} thrown in C:\wamp\www\newcf\GETengine-1.0.0\includes\functions.php on line 51
Link to comment
Share on other sites

throw new InvalidArgumentException('The given path is not a directory.');

 

It's apart of the Get Directory Tree function.

  function getDirectoryTree($path, $directorySeparator = "/", $startPath = null)
  {
      if (!is_dir($path)) {
          throw new InvalidArgumentException('The given path is not a directory.');
      }
      if (null === $startPath) {
          $startPath = $path;
      }
      $startPathLength = strlen($startPath) + 1;
      $items = array();
      foreach (new DirectoryIterator($path) as $item) {
          if ($item->isDot())
              continue;
          if ($item->isDir()) {
              $items = array_merge($items, getDirectoryTree($item->getPathname(), $directorySeparator, $startPath));
          }
          else {
              $name = substr($item->getPathName(), $startPathLength);
              if ($directorySeparator !== DIRECTORY_SEPARATOR) {
                  $name = str_replace(DIRECTORY_SEPARATOR, $directorySeparator, $name);
              }
              $items[] = $name;
          }
      }
      return $items;
  }  

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.