Jump to content

another header error


digitalgod

Recommended Posts

hey guys,

I keep getting this header error

Warning: Cannot modify header information - headers already sent by (output started at /cart/plugins/szukanie/szukanie.php:156) in /cart/actions_client/orders.php on line 50

line 50 in orders.php has a header redirect and session_start is at the very begining of the file

so I'm guessing that the problem is from szukanie.php but I can't seem to see what's causing the error...

here's the content of szukanie.php

[code]
<?php

if( !function_exists( 'listProductsSearch' ) ){
  /**
  * List products and return content
  * @return string
  * @param string $sFile
  * @param string $sOption
  * @param mixed  $mValue
  * @param int    $iList
  */
  function listProductsSearch( $sFile = 'products_list.tpl', $sOption = 'list', $mValue = null, $iList = null ){

    if( !isset( $_GET['iPage'] ) || !is_numeric( $_GET['iPage'] ) || $_GET['iPage'] < 1 ) $_GET['iPage'] = 1;
    $iStatus = throwStatus( );
    if( !isset( $iList ) )
     {
     if( $iStatus == 1 ) $iList = PRODUCTS_LIST;
     else $iList = ADMIN_LIST;
     }
    if( $sOption == 'search' ){
      if (isset($mValue[1])) $aData = dbListProductsSearchExtended ( $iStatus, array(trim( $mValue[0] ), $mValue[1], $mValue[2], $mValue[3]), $iList );
      if (isset($mValue[1])) $sPage = $_GET['p'].'&amp;sSearchWord='.$_GET['sSearchWord'].'&Category='.$mValue[1].'&fPriceFrom='.$mValue[2].'&fPriceTo='.$mValue[3];
    }

    if( isset( $aData ) && is_array( $aData ) )
      $content = throwProductsData( $sFile, $aData, $sPage, $iList );
    else
      $content = $_GET['tpl']->tbHtml( $sFile, 'NOT_FOUND' );

    return $content;
  } // end function listProductsSearch
}

function show_categories ($iStatus)
   {
   $aFile =  file( DB_CATEGORIES );
   $iCount = count( $aFile );
   $kategorie =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    if( $aExp[3] >= $iStatus )
     {
     $kategorie[$aExp[0]] = $aExp[1];
     if( is_numeric( $aExp[2] ) && $aExp[2] > 0 ) {$kategorie[$aExp[0]] = $kategorie[$aExp[2]].' '.$kategorie[$aExp[0]]; }
     }
    }
   return $kategorie;
   }

function show_products_ex ()
   {
   $aFile =  file(DB_PRODUCTS_EXT);
   $iCount = count( $aFile );
   $produkty_ex =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    if (isset($aExp[1])) {$produkty_ex[$aExp[0]] = $aExp[1];}
    if (!isset($aExp[1])) {$produkty_ex[$aExp[0]] = "";}
    }
   return $produkty_ex;
   }


function show_products_categories ()
   {
   $aFile =  file(DB_PRODUCTS_CATEGORIES);
   $iCount = count( $aFile );
   $produkty_kategorie =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    $produkty_kategorie[$aExp[1]] = $aExp[0];
    }
   return $produkty_kategorie;
   }


function show_prices_promo ()
   {
   $aFile =  file(DB_PRODUCT_ATTRIBUTES);
   $iCount = count( $aFile );
   $produkty_ceny_promo =  null;
   for( $i = 1; $i < $iCount; $i++ )
    {
    $aExp = explode( '$', $aFile[$i]);
    $produkty_ceny_promo[$aExp[0]] = $aExp[2];
    }
   return $produkty_ceny_promo;
   }


if( !function_exists( 'dbListProductsSearchExtended' ) ){
  /**
  * Return array of products list, search by word
  * @return array
  * @param int    $iStatus
  * @param string $sWord
  * @param int    $iList
  */
  function dbListProductsSearchExtended( $iStatus, $sWord, $iList ){
    global $oFF;
    $aCategories = dbThrowProductsCategories( );
    $kategorie = show_categories (0);
    $produkty_ex = show_products_ex ();
    $produkty_kategorie = show_products_categories ();
    $produkty_ceny_promo = show_prices_promo ();
    return $oFF->throwFileArrayFunctionPages( DB_PRODUCTS, null, $_GET['iPage'], $iList, 'dbListProductsSearchCheckExtended', Array( $iStatus, $aCategories, $sWord[0], $kategorie, $produkty_ex, $produkty_kategorie, $sWord[1], $produkty_ceny_promo, $sWord[2], $sWord[3]) );
  } // end function dbListProductsSearchExtended
}



if( !function_exists( 'dbListProductsSearchCheckExtended' ) ){
  /**
  * Checking data of products
  * @return bool
  * @param array  $aData
  * @param array  $aCheck
  */
  function dbListProductsSearchCheckExtended( $aData, $aCheck ){
  $fPrice = $aData[2];
  if (isset($aCheck[7][$aData[0]]) && is_numeric($aCheck[7][$aData[0]])) $fPrice = $aCheck[7][$aData[0]];
  if (isset($aCheck[8]) && is_numeric($aCheck[8])) {$fPriceFrom = $aCheck[8];} else {$fPriceFrom = '0';}
  if (isset($aCheck[9]) && is_numeric($aCheck[9])) {$fPriceTo = $aCheck[9];} else {$fPriceTo = '';}
  if( is_array( $aData ) &&  isset( $aCheck[1][$aData[0]] ) && $aData[4] >= $aCheck[0] )
      {
      if (($aCheck[2] == '') || ($aCheck[2] != '' && stristr( implode( ' ', $aData ).' '.$aCheck[3][$aCheck[1][$aData[0]][0]].' '.$aCheck[4][$aData[0]], $aCheck[2] )))
       {
       if (($aCheck[6] == '') || (($aCheck[6] != '') && ($aCheck[5][$aData[0]] == $aCheck[6])))
        {
        if ((($fPriceTo == '') || (($fPriceTo != '') && ($fPrice <= $fPriceTo))) && ($fPrice >= $fPriceFrom))
         {
         return true;
         }
        else return null;
        }
       else return null;
       }
      else return null;
      }
    else
      return null;
  } // end function dbListProductsSearchCheckExtended
}


function ShowSearchExtendedForm ( $sFile = 'extended_search.tpl' )
{
global $tpl;
return $tpl->tbHtml( $sFile, 'EXTENDED_SEARCH_FORM' );
}

?> [/code]
Link to comment
https://forums.phpfreaks.com/topic/23288-another-header-error/
Share on other sites

orders.php

[code=php:0]
<?php
session_start( );

if( !isset( $_SESSION['iCustomer'] ) )
  $_SESSION['iCustomer'] = time( ).rand( 100, 999 );

require_once DIR_CORE.'couriers-'.$config['db_type'].'.php';
require_once DIR_CORE.'couriers.php';

require_once DIR_CORE.'orders-'.$config['db_type'].'.php';
require_once DIR_CORE.'orders.php';

require_once DIR_CORE.'products-'.$config['db_type'].'.php';
require_once DIR_CORE.'products.php';

if( $a == 'Basket' ){
  if( isset( $sOption ) ){
    if( isset( $_SESSION['iOrderSession'] ) )
      $iOrder = $_SESSION['iOrderSession'];
    else{
      $_SESSION['iOrderSession'] = $iOrder = throwOrderIdTemp( $_SESSION['iCustomer'], 'add' );
    }

    if( $sOption == 'add' ){
      if( isset( $iProduct ) && is_numeric( $iProduct ) && isset( $iQuantity ) && is_numeric( $iQuantity ) && $iQuantity >= 1 && $iQuantity < 1000 ){
        addOrderProduct( $iProduct, $iQuantity, $iOrder );
      }
      // added for not showing basket after clicking add to basket
      echo "<script type='text/javascript' language='javascript'>
      history.go(-1);
      </script>";
      exit;
      // end
      // original code
      header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersBasket' );
      exit;
      // original code
    }
    elseif( $sOption == 'del' ){
      if( isset( $iElement ) && is_numeric( $iElement ) )
        delOrderElement( $iOrder, $iElement );
    }
    elseif( $sOption == 'save' ){
      if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){
        saveOrderProducts( $_POST );
      }

      if( isset( $_POST['sSave'] ) ){
        header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' );
        exit;
      }
    }
  }
  else{
    if( isset( $_SESSION['iOrderSession'] ) )
      $iOrder = $_SESSION['iOrderSession'];
  }
  if( isset( $iOrder ) && is_numeric( $iOrder ) )
    $content .= listBasket( $iOrder );
  else
    $content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' );
}
elseif( $a == 'Delivery' ){
  if( isset( $_SESSION['iOrderSession'] ) )
    $iOrder = $_SESSION['iOrderSession'];

  if( isset( $iOrder ) && is_numeric( $iOrder ) ){
    if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' ){
      if( checkOrderFields( $_POST ) === true && checkOrderProducts( $iOrder ) === true ){
        saveOrder( $iOrder, $_POST );
//--------- Start PayPal Code
$aData = throwOrder( $iOrder );
listBasket( $iOrder);
$aData['fSummary'] = sprintf( '%01.2f', $aData['fCourierPrice'] + $aList['fSummary'] );
if( $aData['fCourierPrice'] > 0 ){
$content .= $tpl->tbHtml( 'messages.tpl', 'ORDER_PAYPAL' );
}
else
//-------- End PayPal Code
        $content .= $tpl->tbHtml( 'messages.tpl', 'ORDER_SAVED' );
        unset( $_SESSION['iOrderSession'] );
      }
      else
        $content .= $tpl->tbHtml( 'messages.tpl', 'FORM_ERROR' );
    }
    else{
      if( checkOrderProducts( $iOrder ) === true ){
        $sCourierSelect = listCouriers( 'couriers_select.tpl' );
        $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'FORM' );
        $content .= listBasket( $iOrder, 'orders_delivery.tpl' );
        $content .= $tpl->tbHtml( 'orders_delivery.tpl', 'COURIER' );
      }
      else
        $content .= $tpl->tbHtml( 'messages.tpl', 'NOT_EXISTS' );
    }
  }
  else
    $content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' );
}
elseif( $a == 'Print' && isset( $iOrder ) && is_numeric( $iOrder ) ){
  $aData = throwOrder( $iOrder );
  if( isset( $aData ) && is_array( $aData ) && $aData['iClient'] == $_SESSION['iCustomer'] && $aData['iStatus'] > 0 ){

    $aData['sComment']  = ereg_replace( '\|n\|', "<br />" , $aData['sComment'] );

    $content .= $tpl->tbHtml( 'orders_print.tpl', 'SHOW' );
    if( checkOrderProducts( $iOrder ) === true ){
      $content .= listBasket( $iOrder, 'orders_print.tpl' );
      $aData['fSummary'] = tPrice( $aData['fCourierPrice'] + $aList['fSummary'] );
      $content .= $tpl->tbHtml( 'orders_print.tpl', 'COURIER' );
    }
  }
  else{
    $content .= $tpl->tbHtml( 'messages.tpl', 'ERROR' );
  }
}
else
  $content .= $tpl->tbHtml( 'messages.tpl', 'ERROR' );
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/23288-another-header-error/#findComment-105584
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.