1 (edited by Goldex 2008-04-20 19:15)

Topic: Move forum from "/forum/" to "/"? [Solved by Smartys]

Hi,


Is it possible to simply move the forum directory to a different level?

http://www.website.com/forum/index.php (etc.) >> http://www.website.com/index.php (etc.).

And do I have to change some stuff in PHPMyAdmin and config.php?


Greets, Goldex - sorry for my bad English.

2 (edited by yemgi 2008-04-20 15:01)

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

change o_base_url in the config table via phpMyAdmin and empty the content of the cache folder

3 (edited by Goldex 2008-04-20 16:00)

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

Okay, thanks! smile

Also, when I have my default site index (index.php) in the root directory, is there a way to change the forum index.php (to forum.php or something) so I wouldn't have to change the site? Or is there a way to get it the same as $_GET['view'] == 'forum'?

Anyway, I just bought this up: The reason why I want to change the directory is so that I can include the login data on normal webpages aswell. This is on my index.php (site):

<?php
define('PUN_ROOT', './forum/');
define('PUN_TURN_OFF_MAINT', 1);

if($pun_user['is_guest'] == "TRUE")
    {
    echo "Welkom! <a href=\"/forum/login.php\">Log in</a> of <a href=\"/forum/register.php\">registreer</a>.";
    }
else
    {
    echo "Welkom, <strong>".pun_htmlspecialchars($pun_user['username'])."</strong>!<br><br>";
    }
?></td>
      <td><div align="right">
        <?php
define('PUN_ROOT', './forum/');
define('PUN_TURN_OFF_MAINT', 1);

if($pun_user['is_guest'] == "TRUE")
    {
    }
else
    {
    echo "<a href=\"/forum/profile.php?id=".pun_htmlspecialchars($pun_user['id'])."\">Profiel</a> - <a href=\"/forum/message_list.php\">Berichten</a>";
    }
?>

I also have a script on the same page (index.php) that lets me include other pages (for example, index.php?page=apagelol):

<?
if(empty($_GET['page'])) {
  include("neus.php");
} else {
  if(eregi("http://",$_GET['page'])) {
    echo "Het is niet toegestaan externe pagina's in te voegen.";
  } elseif(file_exists($_GET['page'].".html")) {
    include($_GET['page'].".html");
  } elseif(file_exists($_GET['page'].".php")) {
    include($_GET['page'].".php");
  } else {
    echo "404 error, pagina niet gevonden.";
  }
}
?>

But when I use these two codes together, the first one gets an error. This does not happen when I put this page in the PunBB forum directory (modified it, of course). So is there a way to get it anyway, or do I have to 'fuse' my forum and site directories?

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

Goldex: You can rename your index.php to whatever you want, you just have to search through all the files for references to index.php and update them as well.
The first script you posted is wrong, please review http://punbb.org/docs/dev.html#integration
The second script is a huge security risk and allows an attacker to execute arbitrary PHP on your site.

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

Smartys wrote:

Goldex: You can rename your index.php to whatever you want, you just have to search through all the files for references to index.php and update them as well.

Are you talking about the PunBB index.php? smile

Smartys wrote:

The first script you posted is wrong, please review http://punbb.org/docs/dev.html#integration

Thanks for the link! I did forgot to mention I put the following in the head of my index.php page:

<?php define('PUN_ROOT', './forum/'); ?>
<?php include_once PUN_ROOT.'forum/include/common.php'; ?>

I'm not sure if this would work, given the fact that it's "include once" instead of "require" and I'm also not sure if I have to remove the 'forum/' in the same line (sorry, I'm a big n00b with PunBB coding). Also, do I have to include the code in the link you gave me multiple times for multiple PHP-includes? (this one)

define('PUN_ROOT', './forums/');
require PUN_ROOT.'include/common.php';
Smartys wrote:

The second script is a huge security risk and allows an attacker to execute arbitrary PHP on your site.

Thanks for the notification, I'll get after that once I'm done with this! wink

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

Are you talking about the PunBB index.php? smile

Yes

I'm not sure if this would work, given the fact that it's "include once" instead of "require" and I'm also not sure if I have to remove the 'forum/' in the same line (sorry, I'm a big n00b with PunBB coding). Also, do I have to include the code in the link you gave me multiple times for multiple PHP-includes? (this one)

common.php should be included/required once in a page, you should not be prepending forum to your path since PUN_ROOT already takes care of that (that's just basic concatenation of strings). smile

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

Ah, okay! Thanks Smartys! smile You are a great help!

So I finally managed to get everything right. However, there seems to be a problem when I include a PHP-page. It works fine when I include a html-page, but with a PHP-page it automaticly blocks off the PunBB integration-script. Is this a standard PHP-issue or is this a PunBB's problem (ergo: my fault)?

Fatal error: Cannot redeclare check_cookie() (previously declared in /~website~/www/forum/include/functions.php:28) in /~website~/www/forum/include/functions.php on line 112

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

You should not include common.php or functions.php twice (or try including both: including common.php includes functions.php).

Re: Move forum from "/forum/" to "/"? [Solved by Smartys]

Smartys wrote:

You should not include common.php or functions.php twice (or try including both: including common.php includes functions.php).

Oh god, I totally forgot about that file. I thought I was including a php generator script, but I was infact including the dynamic news script which had the common.php on it aswell. God, I feel so stupid! >_< Thank you, thank you so much! Everything works fine now! smile