Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old February 7th, 2005, 01:17 AM
sven4077 sven4077 is offline
New Member
 
Join Date: Feb 2005
Posts: 6
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.
Reply With Quote
  #2  
Old February 7th, 2005, 02:59 AM
faction688's Avatar
faction688 faction688 is offline
New Member
 
Join Date: Jan 2005
Age: 20
Posts: 11
Post

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
Reply With Quote
  #3  
Old February 7th, 2005, 03:47 AM
sven4077 sven4077 is offline
New Member
 
Join Date: Feb 2005
Posts: 6
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'] . '&nbsp;x&nbsp;</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);
?>
This really wouldnt help, I dont think. What it does (should do really) is show shopping cart contents. I also have include('/absolute/path/root/shop/includes/application_top.php'); However I have the configure.php file set up to use the subdomain info for the set up. So what I'm thinking is part of one of the scripts checks where the script is being accessed from, and if its not from the same folder, it resets the session.
Reply With Quote
  #4  
Old February 7th, 2005, 03:40 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,023
Blog Entries: 1
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
Reply With Quote
  #5  
Old February 7th, 2005, 08:26 PM
sven4077 sven4077 is offline
New Member
 
Join Date: Feb 2005
Posts: 6
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.
Reply With Quote
  #6  
Old February 7th, 2005, 08:29 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,023
Blog Entries: 1
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
Reply With Quote
  #7  
Old February 7th, 2005, 09:09 PM
sven4077 sven4077 is offline
New Member
 
Join Date: Feb 2005
Posts: 6
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/');
 
?>
The application_top.php, which is file that needs to be included in order to work properly can be found at www.eveningstarbotanicals.com/apptop.txt. Note that the file is quite big, around 500+ lines of code, thats why its not posted.
Reply With Quote
  #8  
Old February 7th, 2005, 09:17 PM
degsy's Avatar
degsy degsy is offline
Cyber Tech Help Moderator
 
Join Date: Jul 2001
Location: North-East, UK
Posts: 22,023
Blog Entries: 1
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
Reply With Quote
  #9  
Old February 7th, 2005, 09:29 PM
sven4077 sven4077 is offline
New Member
 
Join Date: Feb 2005
Posts: 6
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.
Reply With Quote
Reply

Bookmarks

Topic Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:10 PM.

[ RSS ]