[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4493: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression'
 OpenForum.dk • Vis emne - Warning: Cannot modify header information

Warning: Cannot modify header information

Generelle spørgsmål og debat.

Redaktør: Redaktionen

Warning: Cannot modify header information

Indlægaf MartinLM » 2009-12-2 02:02

hej derude...

når jeg importere varer får jeg denne fejl melding:

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/web/webx/x.dk/admin/includes/application_top.php:5)
in /usr/home/web/webx/x.dk/admin/csv_import.php on line 101

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/web/webx/x.dk/admin/includes/application_top.php:5)
in /usr/home/web/webx/x.dk/admin/csv_import.php on line 102

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/web/webx/x.dk/admin/includes/application_top.php:5)
in /usr/home/web/webx/x.dk/admin/csv_import.php on line 103

jeg har læst lidt rundt omkring og der skulle eftersigene være en fejl i scriptet.. evt et "mellemrum" et sted men jeg kan ikke lige se fejlen..


de omtalte filer ser sådan ud:

<?php
/*
$Id: application_top.php,v 1.2 2005/12/02 12:42:30 olby Exp $

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

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

// start the timer for the page parse time log
define('PAGE_PARSE_START_TIME', microtime());

// set the level of error reporting
error_reporting(E_ALL & ~E_NOTICE);

// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
if (function_exists('ini_get')) {
ini_get('register_globals') or exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.');
}

// Set the local configuration parameters - mainly for developers
if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// include server parameters
require('includes/configure.php');

if (strlen(DB_SERVER) < 1) {
if (is_dir('install')) {
header('Location: install/index.php');
}
}

// define the project version
define('PROJECT_VERSION', 'SDweb|DK');

// set the type of request (secure or not)
$request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';

// set php_self in the local scope
if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];

if ($request_type == 'NONSSL') {
define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG);
} else {
define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG);
}

// include the list of project filenames
require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout
define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// include the database functions
require(DIR_WS_FUNCTIONS . 'database.php');

// make a connection to the database... now
tep_db_connect() or die('Unable to connect to database server!');

// set the application parameters
$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
while ($configuration = tep_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
}

// if gzip_compression is enabled, start to buffer the output
if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {
if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
if (PHP_VERSION >= '4.0.4') {
ob_start('ob_gzhandler');
} else {
include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
ob_start();
ob_implicit_flush();
}
} else {
ini_set('zlib.output_compression_level', GZIP_LEVEL);
}
}

// set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
if (strlen(getenv('PATH_INFO')) > 1) {
$GET_array = array();
$PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
$vars = explode('/', substr(getenv('PATH_INFO'), 1));
for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
if (strpos($vars[$i], '[]')) {
$GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
} else {
$HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
}
$i++;
}

if (sizeof($GET_array) > 0) {
while (list($key, $value) = each($GET_array)) {
$HTTP_GET_VARS[$key] = $value;
}
}
}
}

// define general functions used application-wide
require(DIR_WS_FUNCTIONS . 'general.php');
require(DIR_WS_FUNCTIONS . 'html_output.php');

// set the cookie domain
$cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
$cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);

// include cache functions if enabled
if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');

// include shopping cart class
require(DIR_WS_CLASSES . 'shopping_cart.php');

// include navigation history class
require(DIR_WS_CLASSES . 'navigation_history.php');

// some code to solve compatibility issues
require(DIR_WS_FUNCTIONS . 'compatibility.php');

// check if sessions are supported, otherwise use the php3 compatible session class
if (!function_exists('session_start')) {
define('PHP_SESSION_NAME', 'osCsid');
define('PHP_SESSION_PATH', $cookie_path);
define('PHP_SESSION_DOMAIN', $cookie_domain);
define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

include(DIR_WS_CLASSES . 'sessions.php');
}

// Use ImageMagic for creating thumbs
define('USE_IMAGEMAGIC', 'false');

// define how the session functions will be used
require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path
tep_session_name('osCsid');
tep_session_save_path(SESSION_WRITE_DIRECTORY);

// set the session cookie parameters
if (function_exists('session_set_cookie_params')) {
session_set_cookie_params(0, $cookie_path, $cookie_domain);
} elseif (function_exists('ini_set')) {
ini_set('session.cookie_lifetime', '0');
ini_set('session.cookie_path', $cookie_path);
ini_set('session.cookie_domain', $cookie_domain);
}

// set the session ID if it exists
if (isset($HTTP_POST_VARS[tep_session_name()])) {
tep_session_id($HTTP_POST_VARS[tep_session_name()]);
} elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) {
tep_session_id($HTTP_GET_VARS[tep_session_name()]);
}

// start the session
$session_started = false;
if (SESSION_FORCE_COOKIE_USE == 'True') {
tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
tep_session_start();
$session_started = true;
}
} elseif (SESSION_BLOCK_SPIDERS == 'True') {
$user_agent = strtolower(getenv('HTTP_USER_AGENT'));
$spider_flag = false;

if (tep_not_null($user_agent)) {
$spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
if (tep_not_null($spiders[$i])) {
if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
$spider_flag = true;
break;
}
}
}
}

if ($spider_flag == false) {
tep_session_start();
$session_started = true;
}
} else {
tep_session_start();
$session_started = true;
}

// set SID once, even if empty
$SID = (defined('SID') ? SID : '');

// verify the ssl_session_id if the feature is enabled
if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) {
$ssl_session_id = getenv('SSL_SESSION_ID');
if (!tep_session_is_registered('SSL_SESSION_ID')) {
$SESSION_SSL_ID = $ssl_session_id;
tep_session_register('SESSION_SSL_ID');
}

if ($SESSION_SSL_ID != $ssl_session_id) {
tep_session_destroy();
tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
}
}

// verify the browser user agent if the feature is enabled
if (SESSION_CHECK_USER_AGENT == 'True') {
$http_user_agent = getenv('HTTP_USER_AGENT');
if (!tep_session_is_registered('SESSION_USER_AGENT')) {
$SESSION_USER_AGENT = $http_user_agent;
tep_session_register('SESSION_USER_AGENT');
}

if ($SESSION_USER_AGENT != $http_user_agent) {
tep_session_destroy();
tep_redirect(tep_href_link(FILENAME_LOGIN));
}
}

// verify the IP address if the feature is enabled
if (SESSION_CHECK_IP_ADDRESS == 'True') {
$ip_address = tep_get_ip_address();
if (!tep_session_is_registered('SESSION_IP_ADDRESS')) {
$SESSION_IP_ADDRESS = $ip_address;
tep_session_register('SESSION_IP_ADDRESS');
}

if ($SESSION_IP_ADDRESS != $ip_address) {
tep_session_destroy();
tep_redirect(tep_href_link(FILENAME_LOGIN));
}
}

// create the shopping cart & fix the cart if necesary
if (tep_session_is_registered('cart') && is_object($cart)) {
if (PHP_VERSION < 4) {
$broken_cart = $cart;
$cart = new shoppingCart;
$cart->unserialize($broken_cart);
}
} else {
tep_session_register('cart');
$cart = new shoppingCart;
}

// include currencies class and create an instance
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

// include the mail classes
require(DIR_WS_CLASSES . 'mime.php');
require(DIR_WS_CLASSES . 'email.php');

// set the language
if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
if (!tep_session_is_registered('language')) {
tep_session_register('language');
tep_session_register('languages_id');
}

include(DIR_WS_CLASSES . 'language.php');
$lng = new language();

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
$lng->set_language($HTTP_GET_VARS['language']);
} else {
$lng->get_browser_language();
}

$language = $lng->language['directory'];
$languages_id = $lng->language['id'];
}

// include the language translations
require(DIR_WS_LANGUAGES . $language . '.php');

// currency
if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
if (!tep_session_is_registered('currency')) tep_session_register('currency');

if (isset($HTTP_GET_VARS['currency'])) {
if (!$currency = tep_currency_exists($HTTP_GET_VARS['currency'])) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
} else {
$currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}
}

// navigation history
if (tep_session_is_registered('navigation')) {
if (PHP_VERSION < 4) {
$broken_navigation = $navigation;
$navigation = new navigationHistory;
$navigation->unserialize($broken_navigation);
}
} else {
tep_session_register('navigation');
$navigation = new navigationHistory;
}
$navigation->add_current_page();

// Shopping cart actions
if (isset($HTTP_GET_VARS['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
if ($session_started == false) {
tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
}

if (DISPLAY_CART == 'true') {
$goto = FILENAME_SHOPPING_CART;
$parameters = array('action', 'cPath', 'products_id', 'pid');
} else {
$goto = basename($PHP_SELF);
if ($HTTP_GET_VARS['action'] == 'buy_now') {
$parameters = array('action', 'pid', 'products_id');
} else {
$parameters = array('action', 'pid');
}
}
switch ($HTTP_GET_VARS['action']) {
// customer wants to update the product quantity in their shopping cart
case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {
$cart->remove($HTTP_POST_VARS['products_id'][$i]);
} else {
if (PHP_VERSION < 4) {
// if PHP3, make correction for lack of multidimensional array.
reset($HTTP_POST_VARS);
while (list($key, $value) = each($HTTP_POST_VARS)) {
if (is_array($value)) {
while (list($key2, $value2) = each($value)) {
if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
$id2[$var[1]][$var[2]] = $value2;
}
}
}
}
$attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';
} else {
$attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
}
$cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
// customer adds a product from the products page
case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
//++++ QT Pro: Begin Changed code
$attributes=array();
if (isset($HTTP_POST_VARS['attrcomb']) && (preg_match("/^\d{1,10}-\d{1,10}(,\d{1,10}-\d{1,10})*$/",$HTTP_POST_VARS['attrcomb']))) {
$attrlist=explode(',',$HTTP_POST_VARS['attrcomb']);
foreach ($attrlist as $attr) {
list($oid, $oval)=explode('-',$attr);
if (is_numeric($oid) && $oid==(int)$oid && is_numeric($oval) && $oval==(int)$oval)
$attributes[$oid]=$oval;
}
}
if (isset($HTTP_POST_VARS['id']) && is_array($HTTP_POST_VARS['id'])) {
foreach ($HTTP_POST_VARS['id'] as $key=>$val) {
if (is_numeric($key) && $key==(int)$key && is_numeric($val) && $val==(int)$val)
$attributes=$attributes + $HTTP_POST_VARS['id'];
}
}

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+1, $attributes);
//++++ QT Pro: End Changed Code

}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
// performed by the 'buy now' button in product listings and review page
case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) {
if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
} else {
$cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
case 'notify' : if (tep_session_is_registered('customer_id')) {
if (isset($HTTP_GET_VARS['products_id'])) {
$notify = $HTTP_GET_VARS['products_id'];
} elseif (isset($HTTP_GET_VARS['notify'])) {
$notify = $HTTP_GET_VARS['notify'];
} elseif (isset($HTTP_POST_VARS['notify'])) {
$notify = $HTTP_POST_VARS['notify'];
} else {
tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
}
if (!is_array($notify)) $notify = array($notify);
for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['count'] < 1) {
tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
}
}
tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
} else {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
break;
case 'notify_remove' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
$check = tep_db_fetch_array($check_query);
if ($check['count'] > 0) {
tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
}
tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
} else {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}
break;
case 'cust_order' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
} else {
$cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
}
}

// include the who's online functions
require(DIR_WS_FUNCTIONS . 'whos_online.php');
tep_update_whos_online();

// include the password crypto functions
require(DIR_WS_FUNCTIONS . 'password_funcs.php');

// include validation functions (right now only email address)
require(DIR_WS_FUNCTIONS . 'validations.php');

// split-page-results
require(DIR_WS_CLASSES . 'split_page_results.php');

// infobox
require(DIR_WS_CLASSES . 'boxes.php');

// auto activate and expire banners
require(DIR_WS_FUNCTIONS . 'banner.php');
tep_activate_banners();
tep_expire_banners();

// auto expire special products
require(DIR_WS_FUNCTIONS . 'specials.php');
tep_expire_specials();

// calculate category path
if (isset($HTTP_GET_VARS['cPath'])) {
$cPath = $HTTP_GET_VARS['cPath'];
} elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
$cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
} else {
$cPath = '';
}

if (tep_not_null($cPath)) {
$cPath_array = tep_parse_category_path($cPath);
$cPath = implode('_', $cPath_array);
$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
} else {
$current_category_id = 0;
}

// include the breadcrumb class and start the breadcrumb trail
require(DIR_WS_CLASSES . 'breadcrumb.php');
$breadcrumb = new breadcrumb;

$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
if (isset($cPath_array)) {
for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
$categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
if (tep_db_num_rows($categories_query) > 0) {
$categories = tep_db_fetch_array($categories_query);
$breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
} else {
break;
}
}
} elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
$manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
if (tep_db_num_rows($manufacturers_query)) {
$manufacturers = tep_db_fetch_array($manufacturers_query);
$breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
}
}

// add the products model to the breadcrumb trail
if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($model_query)) {
$model = tep_db_fetch_array($model_query);
$breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
}

// initialize the message stack for output messages
require(DIR_WS_CLASSES . 'message_stack.php');
$messageStack = new messageStack;

// set which precautions should be checked
define('WARN_INSTALL_EXISTENCE', 'true');
define('WARN_CONFIG_WRITEABLE', 'true');
define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
define('WARN_SESSION_AUTO_START', 'true');
define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');
?>


og



<?php
require('includes/application_top.php');

/*
register globals emulation
*/
if(!intval(ini_get('register_globals')) || !isset($action)) {
foreach($HTTP_GET_VARS as $k => $v) {
if(!isset($$k)) {
$$k = $v;
}
}

foreach($HTTP_POST_VARS as $k => $v) {
if(!isset($$k)) {
$$k = $v;
}
}
}

if(!isset($action)) {
$action = '';
}

/***************************** SETTINGS ********************************/

/* Configuration file */
define('CSV_IMPORT_FOLDER', 'csv_import/');
define('CSV_IMPORT_INI_FILE', CSV_IMPORT_FOLDER . 'csv_import.ini');
$config = parse_ini_file(CSV_IMPORT_INI_FILE, true);

/*
CORRECT_FIELDS_COUNT
true: it corrects the field count if there's a mismatch (last fields missing)
false: it skips the import if there's a field count mismatch
*/
define("CORRECT_FIELDS_COUNT", (isset($config["settings"]["correct_fields_count"]) && $config["settings"]["correct_fields_count"] == 1));

/*
upload folder, must have write permissions
*/
define('CSV_IMPORT_UPLOAD_FOLDER', CSV_IMPORT_FOLDER . $config["settings"]["csv_upload_folder"] . '/');
define('CSV_IMPORT_PHP_FILE', basename($PHP_SELF));
define('CSV_DEBUG', (isset($config["settings"]["debug"]) && $config["settings"]["debug"]));

switch($action) {
case 'config':
define('CSV_IMPORT_INI_COMMENTS_FILE', CSV_IMPORT_FOLDER . 'csv_import.comments.ini');
$comments = parse_ini_file(CSV_IMPORT_INI_COMMENTS_FILE, true);
break;

case 'config_save':
if($h = fopen(CSV_IMPORT_INI_FILE . '.tmp', 'wb')) {
foreach($_POST['config'] as $section => $values) {
fwrite($h, "\n\n[$section]\n");
foreach($values as $key => $value) {
fwrite($h, "\n$key = \"" . str_replace('"', "", trim(stripslashes($value))) . "\"");
}
}

copy(CSV_IMPORT_INI_FILE . '.tmp', CSV_IMPORT_INI_FILE);
@unlink(CSV_IMPORT_INI_FILE . '.tmp');
csv_import_message(CSV_ACTION_DONE, 'success');
tep_redirect(CSV_IMPORT_PHP_FILE . '?action=config');
}
break;

case 'delete':
@unlink(CSV_IMPORT_UPLOAD_FOLDER.$file);
tep_redirect(CSV_IMPORT_PHP_FILE);
break;

case 'upload':
$file = new upload('csvfile', CSV_IMPORT_UPLOAD_FOLDER, '777', array('csv','txt'));
tep_redirect(CSV_IMPORT_PHP_FILE);
break;

case 'empty':
if((bool)$config['settings']['allow_empty_db']) {
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_ATTRIBUTES . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_DESCRIPTION . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_NOTIFICATIONS . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_OPTIONS . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_OPTIONS_VALUES . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . '`');
tep_db_query('TRUNCATE `' . TABLE_PRODUCTS_TO_CATEGORIES . '`');

csv_import_exit(CSV_ACTION_DONE, 'success');
}
else {
tep_redirect(CSV_IMPORT_PHP_FILE);
}
break;

case 'view':
$file = CSV_IMPORT_UPLOAD_FOLDER . $file;
if(file_exists($file)) {
$size = filesize($file);
header("Content-type: application/x-octet-stream");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=$file");
readfile($file);
exit();
}
break;

case 'import':
/* BINDINGS */
$bindings = array();
$bindings['products'] = $config["products"];
$bindings['products_description'] = $config["products_description"];
$bindings['categories'] = $config["categories"];
$bindings['manufacturers'] = $config["manufacturers"];

/* COLUMN HEADERS */
$csv_headers_tmp = explode($config["csv"]["columns_headers_delimiter"], $config["csv"]["columns_headers"]);

$csv_headers = array();
foreach($csv_headers_tmp as $h) {
$csv_headers[] = trim($h);
}

/* FIELDS COUNT */
$csv_fields_count = count($csv_headers);

/* LANGUAGES */
$installed_languages = tep_db_query('SELECT languages_id, code FROM ' . TABLE_LANGUAGES);

$languages_ids = array();
while($l_row = tep_db_fetch_array($installed_languages)) {
$languages_ids[$l_row['code']] = $l_row['languages_id'];
}

/* FILE CHECKING */
$file = CSV_IMPORT_UPLOAD_FOLDER . basename($GLOBALS['file']);

if(!is_file($file)) {
csv_import_exit(sprintf(CSV_INVALID_FILE_ERROR, $file));
}

if(!is_readable($file)) {
csv_import_exit(sprintf(CSV_FILE_READ_PERMISSIONS_ERROR, $file));
}

decode_bindings($bindings);

/* CSV PREPROCESSING */
require(CSV_IMPORT_FOLDER . 'data_parsing.php');

$handle = fopen($file,"r");
$csv = array();
$row = 1;
$delimiter = (empty($config["csv"]["delimiter"]) ? "\t":$config["csv"]["delimiter"]);
$enclosure = (empty($config["csv"]["enclosure"]) ? '"':$config["csv"]["enclosure"]);

while(($data = fgetcsv($handle, 10000, $delimiter, $enclosure)) !== false) {
$row_fields_count = count($data);

if($row == 1 && !$csv_fields_count) {
$csv_fields_count = $row_fields_count;
}
elseif($row > 1 && $row_fields_count != $csv_fields_count) {
if(CORRECT_FIELDS_COUNT && abs($row_fields_count - $csv_fields_count) <= (int)$config['settings']['correct_fields_radius']) {
$data = array_pad($data, $csv_fields_count, "");
}
else {
csv_import_exit(sprintf(CSV_FIELDS_MATCH_ERROR,$row), 'error');
}
}

if($row > 1) {
parse_csv_data($data);
$csv[] = $data;
}

$row++;
}

fclose($handle);

csv_import($csv);
csv_import_exit(CSV_IMPORT_DONE, 'success');
break;
}

function decode_bindings(&$bindings) {
global $config, $languages_ids;

$descriptions = $bindings['products_description'];
$bindings['products_description'] = array();

// names decoding
$products_names_codes = explode(',', $descriptions['products_name']);
foreach($products_names_codes as $v) {
list($code, $col) = explode(':', $v);
$bindings['products_description'][trim($code)]['products_name'] = trim($col);
}

// descriptions decoding
$products_descriptions_codes = explode(',', $descriptions['products_description']);
foreach($products_descriptions_codes as $v) {
list($code, $col) = explode(':', $v);
$bindings['products_description'][trim($code)]['products_description'] = trim($col);
}

foreach($languages_ids as $lang => $lang_id) {
if(isset($bindings['products_description'][$lang]) && (!isset($bindings['products_description'][$lang]['products_name']) || !isset($bindings['products_description'][$lang]['products_description']))) {
unset($bindings['products_description'][$lang]);
}
}
}

function csv_import(&$data) {
global $bindings, $languages_ids, $config;

$n = count($data);
$skipped = array();
$categories_cache = array();
for($i = 0; $i < $n; $i++) {
foreach($data[$i] as $col => $value) {
$data[$i][$col] = trim($value);
}

$fields = array();
foreach($bindings['products'] as $field => $pos) {
$fields[$field] = tep_db_input($data[$i][$pos]);
}

// categories
$cId = array();
$categories = trim($data[$i][$bindings['categories']['categories_id']]);

$categories = explode($config['csv']['categories_delimiter'], $categories);
foreach($categories as $c) {
$c = trim($c);

// category by ID
if(is_numeric($c)) {
$category_check_flag = tep_db_fetch_array(tep_db_query('SELECT COUNT(*) AS total FROM ' . TABLE_CATEGORIES . ' WHERE categories_id = ' . $c));
if((int)$category_check_flag['total']) {
$cId[] = $c;
}
}
// category by name
else {
$subcats = explode($config['csv']['categories_subcat_delimiter'], $c);
foreach($subcats as $k => $v) {
if(!empty($v)) {
$subcats[$k] = trim($v);
}
}

$key = md5(strtolower(implode($config['csv']['categories_subcat_delimiter'], $subcats)));
if(!isset($categories_cache[$key])) {
$c_parent_id = 0;
$category_language = (!empty($config['csv']['categories_language']) ? $config['csv']['categories_language']:DEFAULT_LANGUAGE);

if(isset($languages_ids[$category_language])) {
$category_language = $languages_ids[$category_language];
}
else {
$category_language = $languages_ids[DEFAULT_LANGUAGE];
}

$c_error = false;
foreach($subcats as $sc) {
$subcat_query = tep_db_query("SELECT c.categories_id FROM " . TABLE_CATEGORIES . " c INNER JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd ON c.categories_id = cd.categories_id WHERE language_id = '$category_language' AND categories_name = '$sc' AND parent_id = '$c_parent_id'");
if($subcat_query != null && tep_db_num_rows($subcat_query) == 1) {
$fetched = tep_db_fetch_array($subcat_query);
$c_parent_id = (int)$fetched['categories_id'];
}
elseif((bool)$config['settings']['auto_add_categories']) {
$m_fields = array();
$m_values = array();

$m_fields[] = "`parent_id`";
$m_values[] = "'" . (int)$c_parent_id . "'";

$m_fields[] = "`date_added`";
$m_values[] = "'".strftime('%Y-%m-%d %H:%M:%S',time())."'";

$new_category_query = 'INSERT INTO ' . TABLE_CATEGORIES . ' ('.implode(',',$m_fields).') VALUES('.implode(',',$m_values).')';

if(!tep_db_query($new_category_query)) {
csv_import_message(sprintf(CSV_CATEGORY_INSERT_ERROR, $i, $sc), 'error');
$skipped[$i] = $data[$i];
continue;
}

$c_parent_id = tep_db_insert_id();

foreach($languages_ids as $lang => $lang_id) {
$m_fields = array(
'`categories_id`',
'`language_id`',
'`categories_name`',
);

$m_values = array(
"'$c_parent_id'",
"'$lang_id'",
"'$sc'",
);

$new_category_language_query = tep_db_query('INSERT INTO ' . TABLE_CATEGORIES_DESCRIPTION . ' ('.implode(',',$m_fields).') VALUES('.implode(',',$m_values).')');
}
}
else {
$c_error = true;
break;
}
}

if($c_error) {
continue;
}

$categories_cache[$key] = $c_parent_id;
}

$cId[] = $categories_cache[$key];
}
}

if(empty($cId)) {
csv_import_message(sprintf(CSV_UNKNOWN_CATEGORY_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}

// tax class
if(isset($bindings['products']['products_tax_class_id']) && !empty($data[$i][$bindings['products']['products_tax_class_id']])) {
$tax_class_id = 0;
$tax_class = tep_db_input($data[$i][$bindings['products']['products_tax_class_id']]);
if(is_numeric($tax_class)) {
$tax_class_check = tep_db_query('SELECT tax_class_id FROM ' . TABLE_TAX_CLASS . ' WHERE tax_class_id = \'' . (int)$tax_class . '\'');
if(tep_db_num_rows($tax_class_check) == 1) {
$fetched = tep_db_fetch_array($tax_class_check);
$tax_class_id = (int)$fetched['tax_class_id'];
}
}
else {
$tax_class_check = tep_db_query('SELECT tax_class_id FROM ' . TABLE_TAX_CLASS . ' WHERE tax_class_title = \'' . $tax_class . '\'');
$tax_class_count = tep_db_num_rows($tax_class_check);

if($tax_class_count == 0) {
$m_fields = array();
$m_values = array();

$m_fields[] = "`tax_class_title`";
$m_values[] = "'" . $tax_class . "'";

$m_fields[] = "`tax_class_description`";
$m_values[] = "'" . $tax_class . "'";

$m_fields[] = "`date_added`";
$m_values[] = "'".strftime('%Y-%m-%d %H:%M:%S',time())."'";

$tax_class_query = 'INSERT INTO ' . TABLE_TAX_CLASS . ' (' . implode(',', $m_fields) . ') VALUES(' . implode(',', $m_values) . ')';

if(!tep_db_query($tax_class_query)) {
csv_import_message(sprintf(CSV_TAX_CLASS_INSERT_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}

$tax_class_id = tep_db_insert_id();
}
elseif($tax_class_count == 1) {
$tax_class_query = tep_db_fetch_array($tax_class_check);
$tax_class_id = $tax_class_query['tax_class_id'];
}
else {
csv_import_message(sprintf(CSV_TAX_CLASS_INSERT_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}
}

if($tax_class_id) {
$fields['products_tax_class_id'] = $tax_class_id;
}
}

// manufacturer
if(isset($bindings['manufacturers']['manufacturers_id']) && !empty($data[$i][$bindings['manufacturers']['manufacturers_id']])) {

$manufacturer_id = 0;
$manufacturer = tep_db_input($data[$i][$bindings['manufacturers']['manufacturers_id']]);
if(is_numeric($manufacturer)) {
$manufacturer_check = tep_db_query('SELECT manufacturers_id FROM ' . TABLE_MANUFACTURERS . ' WHERE manufacturers_id = \'' . (int)$manufacturer . '\'');
if(tep_db_num_rows($manufacturer_check) == 1) {
$fetched = tep_db_fetch_array($manufacturer_check);
$manufacturer_id = (int)$fetched['manufacturers_id'];
}
}
else {
$manufacturer_check = tep_db_query('SELECT manufacturers_id FROM ' . TABLE_MANUFACTURERS . ' WHERE manufacturers_name = \'' . $manufacturer . '\'');
$manufacturers_count = tep_db_num_rows($manufacturer_check);

if($manufacturers_count == 0) {
$m_fields = array();
$m_values = array();

$m_fields[] = "`manufacturers_name`";
$m_values[] = "'" . $manufacturer . "'";

$m_fields[] = "`date_added`";
$m_values[] = "'".strftime('%Y-%m-%d %H:%M:%S',time())."'";

$manufacturers_query = 'INSERT INTO '.TABLE_MANUFACTURERS.' ('.implode(',',$m_fields).') VALUES('.implode(',',$m_values).')';

if(!tep_db_query($manufacturers_query)) {
csv_import_message(sprintf(CSV_MANUFACTURER_INSERT_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}

$manufacturer_id = tep_db_insert_id();

foreach($languages_ids as $lang => $lang_id) {
$m_fields = array();
$m_values = array();
if(isset($manufacturers_info_fields) && count($manufacturers_info_fields) > 0) {
$m_lang_fields = $manufacturers_info_fields[$lang];
foreach($m_lang_fields as $field => $pos) {
$m_fields[] = "`$field`";
$m_values[] = "'".tep_db_input($data[$i][$pos])."'";
}
}

$m_fields[] = '`manufacturers_id`';
$m_values[] = "'$manufacturer_id'";

$m_fields[] = '`languages_id`';
$m_values[] = "'$lang_id'";

$products_query = 'INSERT INTO '.TABLE_MANUFACTURERS_INFO.' ('.implode(',',$m_fields).') VALUES('.implode(',',$m_values).')';
if(!tep_db_query($products_query)) {
csv_import_message(sprintf(CSV_MANUFACTURER_INSERT_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}
}
}
elseif($manufacturers_count == 1) {
$manufacturers_query = tep_db_fetch_array($manufacturer_check);
$manufacturer_id = $manufacturers_query['manufacturers_id'];
}
else {
csv_import_message(sprintf(CSV_MANUFACTURER_INSERT_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}
}

if($manufacturer_id) {
$fields['manufacturers_id'] = $manufacturer_id;
}
}

// Now it can update the products using products_model fields as unique ID -----------------------------------------
//if(isset($bindings['products']['products_model'])) {
$model_check = 0;
if(isset($bindings['products']['products_model']) && !empty($data[$i][$bindings['products']['products_model']])) {
$model_check_query = tep_db_query('SELECT COUNT(*) AS total FROM ' . TABLE_PRODUCTS . ' p WHERE p.products_model = \'' . $data[$i][$bindings['products']['products_model']] . '\'');
$model_check = tep_db_fetch_array($model_check_query);
$model_check = intval($model_check['total']);
}

if($model_check === 0) {
$fields['products_date_added'] = strftime('%Y-%m-%d %H:%M:%S',time());
$fields['products_status'] = (isset($config['settings']['products_default_status']) ? (int)$config['settings']['products_default_status']:0);

if((bool)$config['settings']['import_images_urls'] && isset($fields['products_image']) && !empty($fields['products_image'])) {
if(preg_match('/^http:\/\//', $fields['products_image'])) {
$image_url = $fields['products_image'];
$fields['products_image'] = basename($fields['products_image']);
}
elseif(preg_match('/\|http:\/\//', $fields['products_image'])) {
$params = explode($config['settings']['image_name_delimiter'], $fields['products_image']);
$image_url = trim($params[1]);
$fields['products_image'] = trim($params[0]);
}
}

$quoted_fields = array();
$quoted_values = array();
foreach($fields as $key => $value) {
$quoted_fields[] = "`$key`";
$quoted_values[] = "'$value'";
}

$products_query = 'INSERT INTO ' . TABLE_PRODUCTS.' (' . implode(',', $quoted_fields) . ') VALUES(' . implode(',', $quoted_values) . ')';

if(!tep_db_query($products_query)) {
csv_import_message(sprintf(CSV_PRODUCT_INSERT_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}

$product_id = tep_db_insert_id();

foreach($cId as $c_id) {
tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (`products_id`,`categories_id`) VALUES ('.$product_id.','.$c_id.')');
}

foreach($languages_ids as $lang => $lang_id) {
if(isset($bindings['products_description'][$lang])) {
$description_fields = array();
$description_values = array();
$lang_fields = $bindings['products_description'][$lang];

foreach($lang_fields as $field => $col) {
$description_fields[] = "`$field`";
$description_values[] = "'".tep_db_input($data[$i][$col])."'";
}

if(!tep_db_query('INSERT INTO '.TABLE_PRODUCTS_DESCRIPTION.' (`products_id`,`language_id`,'.implode(',',$description_fields).") VALUES ('$product_id','$lang_id',".implode(',',$description_values).")")) {
csv_import_message(sprintf(CSV_LANGUAGES_DESCRIPTION_INSERT_ERROR,$i), 'error');
}
}
else {
if(!tep_db_query("INSERT INTO ".TABLE_PRODUCTS_DESCRIPTION." (`products_id`,`language_id`) VALUES ('$product_id','$lang_id')")) {
csv_import_message(sprintf(CSV_LANGUAGES_DESCRIPTION_INSERT_ERROR,$i), 'error');
}
}
}

if(isset($image_url)) {
get_image_from_url($image_url, $fields['products_image']);
}
}
elseif($model_check === 1) {
$fields['products_last_modified'] = strftime('%Y-%m-%d %H:%M:%S',time());
$model_id_query = tep_db_query('SELECT products_id FROM ' . TABLE_PRODUCTS . ' p WHERE p.products_model = \'' . $data[$i][$bindings['products']['products_model']] . '\'');
$product_id = tep_db_fetch_array($model_id_query);
$product_id = intval($product_id['products_id']);

$fields['products_image'] = basename($fields['products_image']);

$expressions = array();
foreach($fields as $key => $value) {
$expressions[] = "`$key` = '$value'";
}

$products_query = 'UPDATE ' . TABLE_PRODUCTS . ' SET ' . implode(',', $expressions) . ' WHERE products_id = \'' . $product_id . '\'';

if(!tep_db_query($products_query)) {
csv_import_message(sprintf(CSV_PRODUCT_UPDATE_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}

tep_db_query("DELETE FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = '$product_id'");
foreach($cId as $c_id) {
tep_db_query('INSERT INTO '.TABLE_PRODUCTS_TO_CATEGORIES.' (`products_id`,`categories_id`) VALUES ('.$product_id.','.$c_id.')');
}

foreach($languages_ids as $lang => $lang_id) {
if(isset($bindings['products_description'][$lang])) {
$description_couples = array();
$lang_fields = $bindings['products_description'][$lang];
foreach($lang_fields as $field => $col) {
$description_couples[] = $field . "= '" . tep_db_input($data[$i][$col]) . "'";
}

if(!tep_db_query('UPDATE ' . TABLE_PRODUCTS_DESCRIPTION . ' SET ' . implode(',',$description_couples) . " WHERE products_id = $product_id AND language_id = $lang_id")) {
csv_import_message(sprintf(CSV_LANGUAGES_DESCRIPTION_INSERT_ERROR,$i), 'error');
}
}
}
}
else {
csv_import_message(sprintf(CSV_PRODUCT_MULTIPLE_MODELS_ERROR,$i), 'error');
$skipped[$i] = $data[$i];
continue;
}
//}

if(!empty($skipped)) {
$log_file = CSV_IMPORT_UPLOAD_FOLDER.'log_'.strftime('%d%m%y_%H%M%S',time()).'.csv';

$csv_rows = array();
foreach($skipped as $row) {
$fields = array();
foreach($row as $field) {
$fields[] = '"'.str_replace('<br />','',$field).'"';
}
$csv_rows[] = implode("\t",$fields);
}

$fp = fopen($log_file, 'w');
fwrite($fp, implode("\n",$csv_rows));
fclose($fp);

csv_import_message(sprintf(CSV_SKIPPED_ROWS_SAVED,$log_file), 'warning');
}
}
}

function get_image_from_url($url, $filename) {
if(function_exists('curl_init')) {

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$out = curl_exec($ch);
curl_close($ch);

if($out === false) {
return false;
}

if($handle = fopen(DIR_FS_CATALOG_IMAGES . $filename, 'wb')) {
fwrite($handle, $out);
fclose($handle);
}

return true;
}

csv_import_message(CSV_CURL_MISSING_CANT_IMPORT_REMOTE_IMAGE, 'warning');
return false;
}

function csv_import_message($message, $type) {
if(CSV_DEBUG) {
echo $type . ": " . $message;
return;
}
elseif($type == "debug") {
return;
}

if(isset($_SESSION)) {
global $messageToStack;
if(isset($_SESSION['messageToStack'])) {
$messageToStack = $_SESSION['messageToStack'];
}
else {
$messageToStack = array();
}

$messageToStack[] = array('text' => $message, 'type' => $type);
$_SESSION['messageToStack'] = $messageToStack;
}
else {
global $messageStack;
$messageStack->add_session($message, $type);
}
}

function csv_import_exit($message, $type) {
csv_import_message($message, $type);

if(CSV_DEBUG) {
echo "<br/><br/><a href=\"".CSV_IMPORT_PHP_FILE."\">" . CSV_GO_BACK . "</a>";
exit();
}

tep_redirect(CSV_IMPORT_PHP_FILE);
}

function debug() {
$args = func_get_args();

echo "<pre>";
foreach($args as $arg) {
echo print_r($arg, true) . "\n";
}
echo "</pre>";
}

if(!is_dir(CSV_IMPORT_UPLOAD_FOLDER) || !is_readable(CSV_IMPORT_UPLOAD_FOLDER) || !is_writable(CSV_IMPORT_UPLOAD_FOLDER)) {
$messageStack->add(sprintf(CSV_FOLDER_ERROR, CSV_IMPORT_UPLOAD_FOLDER));
}

if(preg_match('/^config/', $action) && !is_writable(CSV_IMPORT_INI_FILE)) {
$messageStack->add(sprintf(CSV_INI_NOT_WRITABLE_ERROR, CSV_IMPORT_INI_FILE));
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<style type="text/css">
a.button {
font-weight:bold;
text-align:center;
padding:2px 5px;
border:1px solid black;
background-color:#555;
text-decoration:none;
color:#fff;
}

td.file_column {
background:#eee;
padding:2px 3px;
font-family:Tahoma, Verdana, Arial, sans-serif;
font-size:12px;
}
pre {
margin:0;
border:0;
padding:0;
}
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php');?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top">
<table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table>
</td>
<td width="100%" valign="top">
<!-- body_text //-->
<?php if($action != 'config') { ?>
<br/>
<form name="csvimport" action="<?php echo CSV_IMPORT_PHP_FILE; ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="upload"/>
<table>
<tr>
<td><b><?php echo CSV_FILE; ?></b></td>
<td><input name="csvfile" type="file" accept="text/plain"/></td>
<td><input type="submit" value="<?php echo CSV_UPLOAD; ?>"/></td>
</tr>
</table>
</form>
<hr/>
<a class="button" href="<?php echo CSV_IMPORT_PHP_FILE; ?>?action=config"><?php echo CSV_CONFIGURATION; ?></a>
<?php if((bool)$config['settings']['allow_empty_db']) { ?>
<a class="button" href="?action=empty" onclick="return confirm('<?php echo CSV_CONFIRM_EMPTY; ?>');" title="<?php echo CSV_EMPTY_CATALOG; ?>"><?php echo CSV_EMPTY_CATALOG; ?></a>
<br/>
<br/>
<?php } ?>
<?php
if($handle = @opendir(CSV_IMPORT_UPLOAD_FOLDER)) {
?>
<table>
<tr>
<th width="200" align="left"><?php echo CSV_LOADED_FILES; ?></th>
<th></th>
<th></th>
<th></th>
</tr>
<?php
while (false !== ($file = readdir($handle))) {
if($file != '.' && $file != '..') {
?>
<tr>
<td class="file_column"><?php echo $file; ?></td>
<td>
<a class="button" href="?action=view&amp;file=<?php echo $file; ?>" title="<?php echo CSV_VIEW; ?>"><?php echo CSV_VIEW; ?></a>
</td>
<td>
<a class="button" href="?action=import&amp;file=<?php echo $file; ?>" onclick="return confirm('<?php echo CSV_CONFIRM_IMPORT; ?>');" title="<?php echo CSV_IMPORT; ?>"><?php echo CSV_IMPORT; ?></a>
</td>
<td>
<a class="button" href="?action=delete&amp;file=<?php echo $file; ?>" onclick="return confirm('<?php echo CSV_CONFIRM_DELETE; ?>');" title="<?php echo CSV_DELETE; ?>"><?php echo CSV_DELETE; ?></a>
</td>
</tr>
<?php
}
}

closedir($handle);
?>
</table>
<?php
}
?>
<br/>
<br/>
<div style="border:1px solid #aaa;padding:5px;font-size:13px;background:#eee;"><pre><?php echo CSV_USE_MODE; ?></pre></div>
<br/>
<?php } else { ?>
<br/>
<a class="button" href="<?php echo CSV_IMPORT_PHP_FILE; ?>"><?php echo CSV_GO_BACK; ?></a>
<br/>
<br/>

<form action="<?php echo CSV_IMPORT_PHP_FILE; ?>" method="post">
<input type="hidden" name="action" value="config_save"/>
<table>
<?php foreach($config as $section => $values) { ?>
<tr><td colspan="3"><h1><?php echo $section; ?></h1></td></tr>
<?php foreach($values as $key => $value) { ?>
<tr><td><?php echo $key ?>:</td><td><?php if(strlen($value) > 100) { ?><textarea name="config[<?php echo $section ?>][<?php echo $key ?>]" rows="5" cols="50"><?php echo $value ?></textarea><?php } else { ?><input name="config[<?php echo $section ?>][<?php echo $key ?>]" size="<?php echo strlen($value) ?>" type="text" value="<?php echo $value ?>"/><?php } ?></td><td><?php echo (isset($comments[$section][$key]) ? $comments[$section][$key]:'') ?></td></tr></div>
<?php } ?>
<?php } ?>
</table>
<input type="submit" value="Save"/>
</form>
<?php } ?>
<!-- body_text_eof //-->
</td>
</tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>

</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>




ved god det virker lidt uoverskueligt men jeg kan simpelthen ikke finde fejlen..

er der nogen der kan hjælpe mig?
Senest rettet af MartinLM 2009-12-2 11:07, rettet i alt 1 gang.
MartinLM
Novice
Novice
 
Indlæg: 7
Tilmeldt: 2009-12-1 22:35

Re: Warning: Cannot modify header information

Indlægaf pertho » 2009-12-2 08:11

Prøv søgefunktionen.
Den fejl er omtalt i mange emner.
pertho
VIP medlem
VIP medlem
 
Indlæg: 2136
Tilmeldt: 2007-08-16 22:25

Re: Warning: Cannot modify header information

Indlægaf MartinLM » 2009-12-2 10:17

har som nævnt læst en del om den omtalte fejl og hvor den kunne ligge og hvad den kunne skyldes... men jeg kan dog stadig ikke se i mine php-filer hvor fejlen skulle ligge
MartinLM
Novice
Novice
 
Indlæg: 7
Tilmeldt: 2009-12-1 22:35

Re: Warning: Cannot modify header information

Indlægaf MartinLM » 2009-12-2 15:10

slet ingen der kan hjælpe mig?
MartinLM
Novice
Novice
 
Indlæg: 7
Tilmeldt: 2009-12-1 22:35

Re: Warning: Cannot modify header information

Indlægaf Kennith » 2010-01-10 02:15

Fejlen opstår fordi der er såkaldte whitespaces i de pågældende filer. Et whitespace er et mellemrum eller en tom linje og fejlen kommer når der er det enten i starten af filen eller når det er i slutningen af filen.
Hvis du har spørgsmål til Unique Free så stil dem her viewforum.php?f=53
Brugeravatar
Kennith
VIP medlem
VIP medlem
 
Indlæg: 2511
Tilmeldt: 2007-04-30 01:15
Geografisk sted: Aalborg


Tilbage til Generel debat

Hvem er online

Brugere der læser dette forum: Ingen tilmeldte og 16 gæster

cron