Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6333855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:32:47+00:00 2026-05-24T18:32:47+00:00

how can i inlude a class file from my parent domain to be used

  • 0

how can i inlude a class file from my parent domain to be used in a subdomain on my server?

for example, I have a class file that handles user authentication along with some important methods. How can I use that authentication class on a subdomain?

my folder structure is

parent domain

/home/<domain>/public_html/

subdomain

/home/<domain>/public_html/users/cluster_1/<sub>

When I make a new subdomain I have a template index.php that is copied onto the

/home/<domain>/public_html/users/cluster_1/<sub>/index.php

in the index.php i want to include my authentication class so that I can do some more stuff based on the data returned by its methods.

i know that i cannot include http requests and also I do not want to use dirname(dirname(__FILE__) because if the user alters that they can see the server folder structure for the domain.

I tried an fopen but i couldn’t get that to include my class, and also i tried a cURL like this

function get_data($url) {
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
$returned_content = get_data('http://domain.com/api/ApiClient.php');

is there an elegant way to include my ApiClient.php class file and even if the user changes the PHP code for them not to see folder structure information that is thrown by the PHP errors.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:32:49+00:00Added an answer on May 24, 2026 at 6:32 pm

    Sorry, nope, not really.

    While it would actually be possible to download PHP code over HTTP and have it run locally, it’s strongly discouraged because of the security implications: one little bug in your including system or one little bug in the code-server and suddenly you’re running malicious code from an unchecked source. There’s a good reason why they disable that behaviour by default.

    If your users can edit and run their own (unchecked) PHP code, there’s no sense in being hesitant about your users seeing you directory structure: unless you secured your setup (which it doesn’t sound like) they could find out that structure right now. Just by using the appropriate functions to walk directories.

    I’d just use the direct inclusion approach.

    require MAIN_CLASS_PATH . '/api/ApiClient.php';
    

    If you really really want them to be unaware of the parent domain:

    • Move the shared classes into a separate project and thus a separate directory (say /home/$user/shared/api
    • Secure the subdomains by setting PHP’s open_basedir and disabling functions like exec() (which can be used to circumvent open_basedir)
    • Include from /home/$user/shared/api from both your Parent domain and your Subdomain.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a class that can be added to a Layout file,
maybe you can help me get this right. I have a class that is
So I am making a class which handles my file uploading from a form.
I have a class file (header and cpp) that I made, that I want
I have two classes as follows in a header file template<size_t N> class Parent{
Is there anyway I can modify this code example #include <stdlib.h> #include <iostream> class
I have a problem in compiling a qt example from c++ GUI programming with
I have a .h file with the following declarations: class Foo{ public: inline int
I am trying to program an App that fetches files from a server. I
I have a CStdDlg thats inherits from a CDialog class. In the CStdDlg dialog,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.