|
#1
|
|||
|
|||
|
Making PHP think page is in a specific directory
Ok, heres my problem. I have a php script in a page in the main folder. In order for it to work properly it must think its in a specific subfolder. The tricky part is, I'm using that folder as a subdomain root, and the path needs to be set up so it thinks its in subdomain.domain.com/, instead of domain.com/subdomain('s folder). The problem I assume I will get is "failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden". I got that error when I was fooling with it trying to get it work, and trying include('http://subdomain.domain.com/test.php');. I dont even know where to start with this, lol. Any help is appreciated.
|
|
#2
|
||||
|
||||
|
I really hate to be the one to tell you this but I don't beleive there is a way to get the file to think it is in a different directory... A little more detail about what the script does, or a copy of the file, and I may be able to help you a little more, but otherwise I don't beleive it is possible...
Sorry about that... -Faction |
|
#3
|
|||
|
|||
|
Well the script in the folder I need it to be in, is the OsCommerce storefront script. You can check it out at www.oscommerce.com. My script in a nut shell is just:
Code:
<table width="85" height="62" align="right" cellpadding="0" bgcolor="#F8F8F9">
<td class="headerNavigation" align="right" nowrap> <?php echo '<a class="ShoppingCartLink" href="' . tep_href_link(FILENAME_SHOPPING_CART).'">'. HEADER_TITLE_CART_CONTENTS . ': </a>';?>
</td>
<td class="headerNavigation" align="left"> <font size="-1"><?php echo $cart->
count_contents(); ?> </font></td>
<td class="headerNavigation" align="left"><font size="-1"> <?php echo $currencies->
format($cart->show_total()); ?></font> </td>
<td class="headerNavigation" align="right">
<?php
if ($cart->count_contents() > 0) {
if (preg_match("/checkout/", $PHP_SELF)) {
// do nothing
} else {
echo '<a href="'. tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'). '" >'. HEADER_TITLE_CHECKOUT .'</a>';
}
}
?>
</td>
</tr>
<tr>
<td height="18" colspan="4" align="right" nowrap class="headerNavigation">
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);
new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART));
$cart_contents_string = '';
if ($cart->count_contents() > 0) {
$cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">';
if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
$cart_contents_string .= '<span class="newItemInCart">';
} else {
$cart_contents_string .= '<span class="infoBoxContents">';
}
$cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id']) . '">';
if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
$cart_contents_string .= '<span class="newItemInCart">';
} else {
$cart_contents_string .= '<span class="infoBoxContents">';
}
$cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>';
if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
tep_session_unregister('new_products_id_in_cart');
}
}
$cart_contents_string .= '</table>';
} else {
$cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
}
$info_box_contents = array();
$info_box_contents[] = array('text' => $cart_contents_string);
if ($cart->count_contents() > 0) {
$info_box_contents[] = array('text' => tep_draw_separator());
$info_box_contents[] = array('align' => 'right',
'text' => $currencies->format($cart->show_total()));
}
new infoBox($info_box_contents);
?>
|
|
#4
|
||||
|
||||
|
The first error you posted was a forbidden rather than cannot find.
You may have to check the permissions on the file/folder or server setup to fix that. You are correct that you should use the absolute server paths as they bypass your domain/subdomain problem.
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#5
|
|||
|
|||
|
The Forbidden/Cannot access error was my attempt at doing include('http://subdomain.domain.com/includes/application_top.php');. I do not get any errors when using the absolute paths, sorry for the mix up. The problem with using the absolute paths is that oscommerce doesnt like it when its not in the scripts directory so it doesnt create the same session variables, I think.
|
|
#6
|
||||
|
||||
|
can you give a break down of the directory structure and the errors produced by the script.
Is there a config file as there is nothing in your code about creating sessions.
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#7
|
|||
|
|||
|
root folder contents:
index.php products.php oscommerce (folder) oscommerce folder contents: index.php product_info.php [a bunch of product stuff, unimportant, so not shown] includes (folder) includes folder contents: application_top.php application_bottom.php configure.php [more unimportant files, so not shown] I have my server set up so that the oscommerce folder is a subdmain root folder. The script I use to access the shopping cart contents is NOT in the oscommerce folder (that works), the shopping cart script is in the main root folder. The config file for variable names, and server name setup is (edited for security, only DB stuff is removed): Code:
<?php /* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ // Define the webserver and path parameters // * DIR_FS_* = Filesystem directories (local/physical) // * DIR_WS_* = Webserver directories (virtual/URL) define('HTTP_SERVER', 'http://shop.eveningstarbotanicals.com'); // eg, http://localhost - should not be empty for productive servers define('HTTPS_SERVER', 'https://shop.eveningstarbotanicals.com'); // eg, https://localhost - should not be empty for productive servers define('ENABLE_SSL', true); // secure webserver for checkout procedure? define('HTTP_COOKIE_DOMAIN', 'shop.eveningstarbotanicals.com'); define('HTTPS_COOKIE_DOMAIN', 'shop.eveningstarbotanicals.com'); define('HTTP_COOKIE_PATH', '/'); define('HTTPS_COOKIE_PATH', '/'); define('DIR_WS_HTTP_CATALOG', '/'); define('DIR_WS_HTTPS_CATALOG', '/'); define('DIR_WS_IMAGES', 'images/'); define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/'); define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/'); define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/'); define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/'); define('DIR_FS_CATALOG', '/var/www/html/oscommerce/'); define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/'); define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/'); ?> |
|
#8
|
||||
|
||||
|
Why not have the apptop file in the same folder as the script?
Apart from that i'm not sure. Is it your webserver or is it hosted? Have you asked the webhost about it?
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#9
|
|||
|
|||
|
The problem is, I'm not getting ANY errors whatsoever. And I get the same problem with the apptop script in the same folder. I'm just going to have the script run from the folder that it works in. Its not the one I want it to be in, but I can work with it. Thanks for all your input.
|
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 02:10 PM.
[
RSS ]








