PDA

View Full Version : CHDIR question


Boofo
09-24-2005, 08:24 AM
I have this piece of code in my chat.php file which is in the forums/chat directory. When a guest tries to view the chat they get a no permission error like it is supposed to do. But for some reason, the header takes up half the page and it doesn't show the header image. It is looking for the header in the chat/images directory which doesn't exist. How can I avoid that when they get a no permission error?

// ######################### REQUIRE BACK-END ############################
chdir('./../');
require_once('./global.php');
// ######################## START MAIN SCRIPT ############################
// Guests cannot access RealChat Rooms
if ($vbulletin->userinfo['userid'] == '0')
{
print_no_permission();
}

Boofo
09-25-2005, 04:21 AM
No one has any ideas on how to fix this? :(

Zachery
09-25-2005, 06:09 AM
I have this piece of code in my chat.php file which is in the forums/chat directory. When a guest tries to view the chat they get a no permission error like it is supposed to do. But for some reason, the header takes up half the page and it doesn't show the header image. It is looking for the header in the chat/images directory which doesn't exist. How can I avoid that when they get a no permission error?

// ######################### REQUIRE BACK-END ############################
chdir('./../');
require_once('./global.php');
// ######################## START MAIN SCRIPT ############################
// Guests cannot access RealChat Rooms
if ($vbulletin->userinfo['userid'] == '0')
{
print_no_permission();
}


You can fix this one of two ways bob, either use full and complete paths in the HTML (not the php ;))

Or

use some nifty replaces in your html to replace links in the header and footer template

vBa CMPS/ Gallery / Links does the latter.

Boofo
09-25-2005, 06:14 AM
You can fix this one of two ways bob, either use full and complete paths in the HTML (not the php ;))

Or

use some nifty replaces in your html to replace links in the header and footer template

vBa CMPS/ Gallery / Links does the latter.

I'm only using templates for this. Sorry, I don't understand what I should change or where. :(

Boofo
09-27-2005, 11:16 AM
Anyone else have any ideas how to fix this? It's all I need to finish up and release a RealChat vB integration hack.

jugo
09-27-2005, 12:10 PM
try changing this:


chdir('./../');


to this


chdir('../');


May not fix your issue but it's definitely prettier and cleaner.

Boofo
09-27-2005, 12:17 PM
You're right, it didn't fix the problem. It is still looking for all the images in /chat/images instead of just /images. :(

Zachery
09-27-2005, 12:22 PM
You're right, it didn't fix the problem. It is still looking for all the images in /chat/images instead of just /images. :(

Bob you need to supply full image paths in your header / footer templates along with full urls to the actual files

OR

use php to string replace on said templates like vBa CMPS / Gallery / Links Directory does

Boofo
09-27-2005, 12:24 PM
Ok, how do I use string replace in a template?

sabret00the
09-27-2005, 12:30 PM
$template_name = str_replace(
array(
'/chat/images'
),
array(
'/images'
),
$template_name);

put that after the template eval but before the final template eval of the page (the print_output one).

Marco van Herwaarden
09-27-2005, 12:39 PM
Ok, how do I use string replace in a template?
Just use my Dynamic Template technigue, you know how to do that.

Boofo
09-27-2005, 12:44 PM
$template_name = str_replace(
array(
'/chat/images'
),
array(
'/images'
),
$template_name);

put that after the template eval but before the final template eval of the page (the print_output one).

I don't do a template eval before the print_output one. Here's what I have:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'chat');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array(
'chatmain',
'appletbit',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
chdir('../');
require_once('./global.php');
// ######################## START MAIN SCRIPT ############################
// Guests cannot access RealChat Rooms
if ($vbulletin->userinfo['userid'] == '0')
{
print_no_permission();
}
eval('print_output("' . fetch_template('chatmain') . '");');
?>