Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2693

phpBB Custom Coding • Read external html files from a directory

$
0
0
I'm not able to read all files from an html directory using PHP file.

I have created an php file named one.php using the below php code to read the html files from my forum directory where the phpbb is installed.

Using phpbb forum discussions i was able to find some related code to check if user is registered and then display the html file.

Code:

 <?php    define('IN_PHPBB', true);    $phpbb_root_path = './';    $phpEx = substr(strrchr(__FILE__, '.'), 1);    include($phpbb_root_path . 'common.' . $phpEx);         // Start session management    $user->session_begin();    $auth->acl($user->data);    $user->setup();    if($user->data['is_registered'])    {        echo "Welcome " . $user->data['username']; //User is already logged inheader('Content-Type: text/html');readfile('https://mywebsite.in/forum/folder1/index.html');    }    else if(isset($_POST['login']))    {        $username = request_var('username', '', true);        $password = request_var('password', '', true);        $autologin = (!empty($_POST['autologin'])) ? true : false;        $result = $auth->login($username, $password, $autologin);        if ($result['status'] == LOGIN_SUCCESS)        {            //User was successfully logged into phpBB            $redirect = request_var('redirect', "{$phpbb_root_path}/index.$phpEx");            // append/replace SID            $redirect = reapply_sid($redirect);            meta_refresh(0, $redirect);            trigger_error('You have been logged in');        }        else        {            echo 'Bad Login ' . $username; //User's login failed        }    }    else    {        echo '            Please log in:<br />            <form method="POST" action="_SELF">            <p>Username: <input type="text" name="username" size="40"><br />            Password: <input type="password" name="password" size="40"><br />            Remember Me?: <input type="checkbox" name="autologin"><br />            <input type="submit" value="Submit" name="login"></p>            </form>';    }    ?>
The html folder is named folder1 and it is stored in the path forum/folder1 and in this folder i have an index.html and several other sub folders.
the one.php file is stored in forum/one.php.
Now when i type the url : https://mywebsite.in/forum/one.php it does not pull up all the contents of the html folder.
I get error in developer tab stating content missing. (mywebsite.in/forum/files/....)
but the path must point out to mywebsite.in/forum/folder1/files/...)

Im just a beginner here. Please if someone can help me. I was trying all day but could not find out the fix for this.

Inshort...i want to read external html files which may have other folders along with to display the page correctly and this access must only be for registered users.
if i run the html file directly the webpage loads correctly but when i try to call it using php code, im not able to get the same output.
im trying to read the contents of the html page so that the exact link will be hidden from the users.

kind regards.

Statistics: Posted by meetgilli — Thu Jan 25, 2024 1:37 pm



Viewing all articles
Browse latest Browse all 2693

Trending Articles