PDA

Click to See Complete Forum and Search --> : Very Urgent, Help Appreciated!


Minolwen
Jan 21st, 2009, 08:19 AM
http://www.merkamericaco.com/ is the full address.

http://merkamericaco.com/ results in an odd error.

Once you hit "Buy Now" on any product you get the following:

Headers sent in file: /home/merkamericaco/public_html/index.php on line: 1

Here is the code:

<?php

/**
* define path to application files
*/
define( 'APPS_FILES', '../apps_files' );

require APPS_FILES . '/config/config.php';

require APPS_FILES . '/init.php';

RPC_Db::addConnection( 'default', $config['database']['default'] );

RPC_Registry::set( 'config', $config );

$router = new RPC_Controller_Router_Rewrite();

$http_host = explode( '.', $_SERVER['HTTP_HOST'] );

if( $_SERVER['SERVER_PORT'] != '443' )
{
if( $http_host[0] != 'secure' && substr( $_SERVER['SERVER_NAME'], 0, 3 ) != 'www' )
{
header( 'Location: http://www.' . $_SERVER['SERVER_NAME'] . '' . @$_SERVER['REQUEST_URI'] );
exit;
}
}

if( $http_host[0] == 'secure' )
{
if( $_SERVER['SERVER_PORT'] != '443' )
{
header( 'Location: ' . WEB_ADDRESS );
exit;
}
$url = $_SERVER['REQUEST_URI'];
if( trim( $url, '/' ) != 'checkout/payment' &&
trim( $url, '/' ) != 'g/callback' &&
trim( $url, '/' ) != 'checkout/index' &&
trim( $url, '/' ) != 'checkout/data' &&
trim( $url, '/' ) != 'checkout/login' &&
trim( $url, '/' ) != 'checkout/register' &&
trim( $url, '/' ) != 'checkout/finish' )
{
header( 'Location: ' . WEB_ADDRESS . '/' . trim( $url, '/' ) );
exit;
}
}
else
{
if( $_SERVER['SERVER_PORT'] == '443' )
{
header( 'Location: ' . WEB_ADDRESS );
exit;
}

$router->rewrite( '^([a-zA-Z0-9\-\_]+)\/c([0-9]+)$', '/category/index/params/id/$2' );
$router->rewrite( '^([a-zA-Z0-9\-\_]+)\/p([0-9]+)$', '/product/index/params/id/$2' );
$router->rewrite( '^([a-zA-Z0-9\-\_]+)\/o([0-9]+)$', '/product/offer/params/id/$2' );
$router->rewrite( '^page\/([a-zA-Z0-9\-]+)$', '/page/view/params/url/$1' );
$router->rewrite( '^admin$', '/admin/auth/login', true );
}

$dispatcher = new RPC_Controller_Dispatcher( PATH_ROOT . DS . 'application' . DS . 'controllers' );

$front = new RPC_Controller_Front( $dispatcher, $router );
try { $front->dispatch(); }
catch( Exception $e ) { if( strpos( $e->getMessage(), 'does not exist' ) !== false ) { header( 'Location: /page_not_found.html' ); exit; } }

RPC_Db::factory()->disconnect();

?>


Obviously this is a major problem for me and I would greatly appreciate any help. If it helps, the person who touched it last said they changed the

false ) { header( 'Location: /page_not_found.html' ); exit; } }

line but changed it back when they noticed a problem.

ngreenwood6
Jan 21st, 2009, 08:38 AM
well, first off in order for it to be accessible without the www you need to register that with your nameserver. Did it ever work without the www? The error you are getting is because you are sending headers when headers already exist. By quickly glancing at your code you should not be getting that error if the product exists so there may be more wrong than you think.

Minolwen
Jan 21st, 2009, 08:56 AM
Yes, I have always accessed parts of my website without www..

Just today it started with these odd messages and that one error message. I notice that these messages only ever show up if you type an incorrect URL, other than when you click buy now on the shopping cart.

ngreenwood6
Jan 21st, 2009, 09:04 AM
What error message are you getting when you access it without the www. I only get a blank screen. Who is your webhost?

Minolwen
Jan 21st, 2009, 09:21 AM
When I try without www. I do not get an error message, I get:



kfcSmitty
Jan 21st, 2009, 10:12 AM
Copy all of the contents out of the file, paste it into notepad and re-save the file.

It looks like they probably saved it as unicode and it added some "invisible" characters to the beginning. That would explain the header issues you're receiving, since it would print out those characters before the header was sent.

visualAd
Jan 21st, 2009, 07:02 PM
The bytes at the beginning of a unicode file at known as the byte order mark or BOM. Unfortunately version of PHP < 6 can do not interpret unicode files.

Save the file as ASCII and it should be ok.