Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Products URL within admin


16 replies to this topic

#1 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 09:06

Having a strange problem and hopefully someone can help.
I have just created a category "African Travel Tours & Packages" for my website www.nontando.com.
I need to setup a product url for each travel package (so I have used the product url link within admin) so that it takes the user to another page.
I have been testing it using my home page, www.nontando.com and it works fine in admin when I test it, yet when you click the link on my live website, I get this error.
Warning: Cannot modify header information - headers already sent by (output started at /mnt/r0109/d39/s22/b00b868a/www/includes/classes/breadcrumb.php:46) in /mnt/r0109/d39/s22/b00b868a/www/includes/functions/general.php on line 143

It happens, regardless of what link I have created.

Thanks, Gary

Edited by bksbeat, 18 June 2011, 09:07.


#2 GemRock

  • Community Member
  • 2,069 posts
  • Real Name:Ken
  • Gender:Male
  • Location:UK

Posted 18 June 2011, 09:25

it looks like there s at least one blank line at the very top of the file breadcrumb.php, jusy before/above the first <?php
there s a known short coming in the redirect function in the generals.php, it should be replace by some javascripts.

ken
commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).
over 20 years of computer programming experience.

#3 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 09:33

View PostGemRock, on 18 June 2011, 09:25, said:

it looks like there s at least one blank line at the very top of the file breadcrumb.php, jusy before/above the first <?php
there s a known short coming in the redirect function in the generals.php, it should be replace by some javascripts.

ken

Thanks Ken. I am not sure what I should be changing. This is my breadcrumbs.php. I did make a change to it recently to accomdate for Google breadcrumbs. If you can take a quick browse thru this file, and if you spot anything that would be much appreciated. Regards, Gary



<?php
/*
$Id: breadcrumb.php,v 1.3 2003/02/11 00:04:50 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright © 2003 osCommerce

Released under the GNU General Public License
*/

class breadcrumb {
var $_trail;

function breadcrumb() {
$this->reset();
}

function reset() {
$this->_trail = array();
}

function add($title, $link = '') {
$this->_trail[] = array('title' => $title, 'link' => $link);
}

function trail($separator = ' - ') {
$trail_string = '';

for ($i=0, $n=sizeof($this->_trail); $i<$n; $i++) {
if (isset($this->_trail[$i]['link']) && tep_not_null($this->_trail[$i]['link'])) {
$trail_string .= '<li><a href="' . $this->_trail[$i]['link'] . '" class="headerNavigation">' . $this->_trail[$i]['title'] . '</a>';
} else {
$trail_string .= '<li>' . $this->_trail[$i]['title'];
}

if (($i+1) < $n) $trail_string .= $separator;
$trail_string .= '</li>';
}

return $trail_string;
}
}
?>

#4 GemRock

  • Community Member
  • 2,069 posts
  • Real Name:Ken
  • Gender:Male
  • Location:UK

Posted 18 June 2011, 10:22

when you posted the file in the way you did above then the blank line(s), if any, would have been lost. if you were looking at the local copy of the file, then try to upload and replace the one on the server.
RE redirect function javascript, you need to post it here to see if it has been modified, using the "insert code snippet" forum function (the icon looks like <>).
i dont use the addon you mentioned in your pm so no comment.
Ken
commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).
over 20 years of computer programming experience.

#5 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 10:35

View PostGemRock, on 18 June 2011, 10:22, said:

when you posted the file in the way you did above then the blank line(s), if any, would have been lost. if you were looking at the local copy of the file, then try to upload and replace the one on the server.
RE redirect function javascript, you need to post it here to see if it has been modified, using the "insert code snippet" forum function (the icon looks like <>).
i dont use the addon you mentioned in your pm so no comment.
Ken

I have replaced the local copy of breadcrumbs.php to the server - a few times now
I have used the code snippet - Hopefully I have done this right.

<?php
/*
  $Id: redirect.php,v 1.10 2003/06/05 23:31:31 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  switch ($HTTP_GET_VARS['action']) {
    case 'banner':
      $banner_query = tep_db_query("select banners_url from " . TABLE_BANNERS . " where banners_id = '" . (int)$HTTP_GET_VARS['goto'] . "'");
      if (tep_db_num_rows($banner_query)) {
        $banner = tep_db_fetch_array($banner_query);
        tep_update_banner_click_count($HTTP_GET_VARS['goto']);

        tep_redirect($banner['banners_url']);
      }
      break;

    case 'url':
      if (isset($HTTP_GET_VARS['goto']) && tep_not_null($HTTP_GET_VARS['goto'])) {
        $check_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_url = '" . tep_db_input($HTTP_GET_VARS['goto']) . "' limit 1");
        if (tep_db_num_rows($check_query)) {
          tep_redirect('http://' . $HTTP_GET_VARS['goto']);
        }
      }
      break;

    case 'manufacturer':
      if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
        $manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and languages_id = '" . (int)$languages_id . "'");
        if (tep_db_num_rows($manufacturer_query)) {
// url exists in selected language
          $manufacturer = tep_db_fetch_array($manufacturer_query);

          if (tep_not_null($manufacturer['manufacturers_url'])) {
            tep_db_query("update " . TABLE_MANUFACTURERS_INFO . " set url_clicked = url_clicked+1, date_last_click = now() where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and languages_id = '" . (int)$languages_id . "'");

            tep_redirect($manufacturer['manufacturers_url']);
          }
        } else {
// no url exists for the selected language, lets use the default language then
          $manufacturer_query = tep_db_query("select mi.languages_id, mi.manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " mi, " . TABLE_LANGUAGES . " l where mi.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and mi.languages_id = l.languages_id and l.code = '" . DEFAULT_LANGUAGE . "'");
          if (tep_db_num_rows($manufacturer_query)) {
            $manufacturer = tep_db_fetch_array($manufacturer_query);

            if (tep_not_null($manufacturer['manufacturers_url'])) {
              tep_db_query("update " . TABLE_MANUFACTURERS_INFO . " set url_clicked = url_clicked+1, date_last_click = now() where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and languages_id = '" . (int)$manufacturer['languages_id'] . "'");

              tep_redirect($manufacturer['manufacturers_url']);
            }
          }
        }
      }
      break;
  }

  tep_redirect(tep_href_link(FILENAME_DEFAULT));
?>


#6 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 10:41

<?php
/*
  $Id: breadcrumb.php,v 1.3 2003/02/11 00:04:50 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  class breadcrumb {
    var $_trail;

    function breadcrumb() {
      $this->reset();
    }

    function reset() {
      $this->_trail = array();
    }

    function add($title, $link = '') {
      $this->_trail[] = array('title' => $title, 'link' => $link);
    }

    function trail($separator = ' - ') {
      $trail_string = ''; 

      for ($i=0, $n=sizeof($this->_trail); $i<$n; $i++) { 
        if (isset($this->_trail[$i]['link']) && tep_not_null($this->_trail[$i]['link'])) { 
          $trail_string .= '<li><a href="' . $this->_trail[$i]['link'] . '" class="headerNavigation">' . $this->_trail[$i]['title'] . '</a>'; 
        } else { 
          $trail_string .= '<li>' . $this->_trail[$i]['title']; 
        } 

        if (($i+1) < $n) $trail_string .= $separator; 
        $trail_string .= '</li>'; 
      } 

      return $trail_string; 
    } 
  } 
?> 

Edited by bksbeat, 18 June 2011, 10:48.


#7 GemRock

  • Community Member
  • 2,069 posts
  • Real Name:Ken
  • Gender:Male
  • Location:UK

Posted 18 June 2011, 11:10

i was referring to the redirect function (tep_redirect) in general.php, not the redirect.php file.
ken

Edited by GemRock, 18 June 2011, 11:15.

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).
over 20 years of computer programming experience.

#8 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 11:17

View PostGemRock, on 18 June 2011, 11:10, said:

i was referring to the redirect function (tep_redirect) in general.php, not the redirect.php file.
ken

sorry about that...here we go (I have never changed this file)

// Redirect to another page or site
  function tep_redirect($url) {
    if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { 
      tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
    }


#9 GemRock

  • Community Member
  • 2,069 posts
  • Real Name:Ken
  • Gender:Male
  • Location:UK

Posted 18 June 2011, 11:26

it looks slightly different from mine but anyway try to replace it with:
  function tep_redirect($url) {
	global $logger;
		if (!headers_sent()) {
		header('Location: ' . $url);
		exit();
	} else {
 		echo '<script type="text/javascript">';
 		echo 'window.location.href="'.$url.'";';
 		echo '</script>';
 		echo '<noscript>';
 		echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
 		echo '</noscript>';
	}
  }
it always works for me, hope works for you as well. Good luck.
Ken
commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).
over 20 years of computer programming experience.

#10 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 11:47

View PostGemRock, on 18 June 2011, 11:26, said:

it looks slightly different from mine but anyway try to replace it with:
  function tep_redirect($url) {
	global $logger;
		if (!headers_sent()) {
		header('Location: ' . $url);
		exit();
	} else {
 		echo '<script type="text/javascript">';
 		echo 'window.location.href="'.$url.'";';
 		echo '</script>';
 		echo '<noscript>';
 		echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
 		echo '</noscript>';
	}
  }
it always works for me, hope works for you as well. Good luck.
Ken



I am getting this error now.
Parse error: syntax error, unexpected '}' in /mnt/r0109/d39/s22/b00b868a/www/includes/functions/general.php on line 160
I removed the bracket on line 160 (that is the very last bracket re. code I have sent you now) and I still get the same error.


// Redirect to another page or site
  function tep_redirect($url) { 
        global $logger; 
                if (!headers_sent()) { 
                header('Location: ' . $url); 
                exit(); 
        } else { 
                echo '<script type="text/javascript">'; 
                echo 'window.location.href="'.$url.'";'; 
                echo '</script>'; 
                echo '<noscript>'; 
                echo '<meta http-equiv="refresh" content="0;url='.$url.'" />'; 
                echo '</noscript>'; 
        } 
  }

  
  
  

    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
        $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
      }
    }

    header('Location: ' . $url);

    tep_exit();
  }

Edited by bksbeat, 18 June 2011, 11:49.


#11 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 12:10

Ken, I got it to work. Not sure of the consequnces but I removed one of the latter two brackets from the code you had sent and seems to be working?
Thanks so much for your help and patience...Much appreciated..Cheers, Gary

#12 GemRock

  • Community Member
  • 2,069 posts
  • Real Name:Ken
  • Gender:Male
  • Location:UK

Posted 18 June 2011, 12:11

you didnt follow what i said. I said "replace", not in addition to, nor place it above or below etc.
Ken
ps

anyway, since it works now, leave it what it is. but on SSL pages if you get the same error then this code also need to be modified in the same way :
    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
        $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
      }
    }

    header('Location: ' . $url);

    tep_exit();

Edited by GemRock, 18 June 2011, 12:19.

commercial support - unProtected channel, not to be confused with the forum with same name - open to everyone who need some professional help: either PM/email me, or go to my website (URL can be found in my profile).
over 20 years of computer programming experience.

#13 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 12:28

View PostGemRock, on 18 June 2011, 12:11, said:

you didnt follow what i said. I said "replace", not in addition to, nor place it above or below etc.
Ken
ps

anyway, since it works now, leave it what it is. but on SSL pages if you get the same error then this code also need to be modified in the same way :
    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
        $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
      }
    }

    header('Location: ' . $url);

    tep_exit();


Ken, I did replace. I took out the original code re. redirect and replaced it with yours. Gary

#14 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 12:48

View Postbksbeat, on 18 June 2011, 12:28, said:

Ken, I did replace. I took out the original code re. redirect and replaced it with yours. Gary


Bad news....I have similar errors now when I try and log into an account. Flashed on the screen but it seemed like a similar error re. breadcrumb,

#15 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 12:55

View Postbksbeat, on 18 June 2011, 12:48, said:

Bad news....I have similar errors now when I try and log into an account. Flashed on the screen but it seemed like a similar error re. breadcrumb,
Im not sure what is going on here. Requested a new password to logon...now I am not receiving anything.....this was always working

#16 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 14:08

View Postbksbeat, on 18 June 2011, 12:55, said:

Im not sure what is going on here. Requested a new password to logon...now I am not receiving anything.....this was always working




Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /mnt/r0109/d39/s22/b00b868a/www/includes/classes/breadcrumb.php:46) in /mnt/r0109/d39/s22/b00b868a/www/includes/functions/sessions.php on line 97

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/r0109/d39/s22/b00b868a/www/includes/classes/breadcrumb.php:46) in /mnt/r0109/d39/s22/b00b868a/www/includes/functions/sessions.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /mnt/r0109/d39/s22/b00b868a/www/includes/classes/breadcrumb.php:46) in /mnt/r0109/d39/s22/b00b868a/www/includes/functions/general.php on line 143


/ Redirect to another page or site
  function tep_redirect($url) { 
        global $logger; 
                if (!headers_sent()) { 
                header('Location: ' . $url); 
                exit(); 
        } else { 
                echo '<script type="text/javascript">'; 
                echo 'window.location.href="'.$url.'";'; 
                echo '</script>'; 
                echo '<noscript>'; 
                echo '<meta http-equiv="refresh" content="0;url='.$url.'" />'; 
                echo '</noscript>'; 
        } 
  


    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
        $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
      }
    }

    header('Location: ' . $url);

    tep_exit();
  }


<?php
/*
  $Id: sessions.php,v 1.19 2003/07/02 22:10:34 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  if (STORE_SESSIONS == 'mysql') {
    if (!$SESS_LIFE = get_cfg_var('session.gc_maxlifetime')) {
      $SESS_LIFE = 1440;
    }

    function _sess_open($save_path, $session_name) {
      return true;
    }

    function _sess_close() {
      return true;
    }

    function _sess_read($key) {
      $value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "' and expiry > '" . time() . "'");
      $value = tep_db_fetch_array($value_query);

      if (isset($value['value'])) {
        return $value['value'];
      }

      return false;
    }

    function _sess_write($key, $val) {
      global $SESS_LIFE;

      $expiry = time() + $SESS_LIFE;
      $value = $val;

      $check_query = tep_db_query("select count(*) as total from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
      $check = tep_db_fetch_array($check_query);

      if ($check['total'] > 0) {
        return tep_db_query("update " . TABLE_SESSIONS . " set expiry = '" . tep_db_input($expiry) . "', value = '" . tep_db_input($value) . "' where sesskey = '" . tep_db_input($key) . "'");
      } else {
        return tep_db_query("insert into " . TABLE_SESSIONS . " values ('" . tep_db_input($key) . "', '" . tep_db_input($expiry) . "', '" . tep_db_input($value) . "')");
      }
    }

    function _sess_destroy($key) {
      return tep_db_query("delete from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($key) . "'");
    }

    function _sess_gc($maxlifetime) {
      tep_db_query("delete from " . TABLE_SESSIONS . " where expiry < '" . time() . "'");

      return true;
    }

    session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
  }

  function tep_session_start() {
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;

    $sane_session_id = true;

    if (isset($HTTP_GET_VARS[tep_session_name()])) {
      if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_GET_VARS[tep_session_name()]) == false) {
        unset($HTTP_GET_VARS[tep_session_name()]);

        $sane_session_id = false;
      }
    } elseif (isset($HTTP_POST_VARS[tep_session_name()])) {
      if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_POST_VARS[tep_session_name()]) == false) {
        unset($HTTP_POST_VARS[tep_session_name()]);

        $sane_session_id = false;
      }
    } elseif (isset($HTTP_COOKIE_VARS[tep_session_name()])) {
      if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_COOKIE_VARS[tep_session_name()]) == false) {
        $session_data = session_get_cookie_params();

        setcookie(tep_session_name(), '', time()-42000, $session_data['path'], $session_data['domain']);

        $sane_session_id = false;
      }
    }

    if ($sane_session_id == false) {
      tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
    }

    return session_start();
  }

  function tep_session_register($variable) {
    global $session_started;

    if ($session_started == true) {
      return session_register($variable);
    } else {
      return false;
    }
  }

  function tep_session_is_registered($variable) {
    return session_is_registered($variable);
  }

  function tep_session_unregister($variable) {
    return session_unregister($variable);
  }

  function tep_session_id($sessid = '') {
    if (!empty($sessid)) {
      return session_id($sessid);
    } else {
      return session_id();
    }
  }

  function tep_session_name($name = '') {
    if (!empty($name)) {
      return session_name($name);
    } else {
      return session_name();
    }
  }

  function tep_session_close() {
    if (PHP_VERSION >= '4.0.4') {
      return session_write_close();
    } elseif (function_exists('session_close')) {
      return session_close();
    }
  }

  function tep_session_destroy() {
    return session_destroy();
  }

  function tep_session_save_path($path = '') {
    if (!empty($path)) {
      return session_save_path($path);
    } else {
      return session_save_path();
    }
  }

  function tep_session_recreate() {
    if (PHP_VERSION >= 4.1) {
      $session_backup = $_SESSION;

      unset($_COOKIE[tep_session_name()]);

      tep_session_destroy();

      if (STORE_SESSIONS == 'mysql') {
        session_set_save_handler('_sess_open', '_sess_close', '_sess_read', '_sess_write', '_sess_destroy', '_sess_gc');
      }

      tep_session_start();

      $_SESSION = $session_backup;
      unset($session_backup);
    }
  }
?>


#17 bksbeat

  • Community Member
  • 138 posts
  • Real Name:Gary

Posted 18 June 2011, 15:45

RESOLVED! It was a space at the breadcrumb.php file - wow!