Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Admin Fatal Error


Guest

Recommended Posts

I use vdeck and just installed osCommerce earlier today. I have been unable to access the admin interface. The following is the error message I keep getting. I am not sure what to do and would appreciate any suggestions.

 

Fatal error: Cannot re-assign $this in /home/cedarshi/public_html/osCommerce/catalog/admin/includes/classes/upload.php on line 31

 

Thank you!

Link to comment
Share on other sites

In /catalog/admin/includes/classes/upload.php

 

Find this code (about 30 lines down):

 

// self destruct
$this = null;

 

Alter it to say this:

 

// self destruct
// $this = null;
unset($this);

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Thank you for such a quick response. I made the change you suggested and then got this next Parse Error:

 

Parse error: syntax error, unexpected '&' in /home/cedarshi/public_html/osCommerce/catalog/admin/includes/classes/upload.php on line 17

 

 

I've included the code below for the upload.php.

 

<?php

/*

$Id: upload.php,v 1.2 2003/06/20 00:18:30 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

class upload {

var $file, $filename, $destination, $permissions, $extensions, $tmp_filename, $message_location;

 

function upload($file = '', $destination = '', $permissions = '777', $extensions = '') {

$this->set_file($file); $this->set_destination($destination); $this->set_permissions($permissions); $this->set_extensions($extensions); $this->set_output_messages('direct'); if (tep_not_null($this->file) && tep_not_null($this->destination)) { $this->set_output_messages('session'); if ( ($this->parse() == true) && ($this->save() == true) ) { return true; } else { // self destruct //$this = null; unset($this); return false; } } } function parse() { global $messageStack; if (isset($_FILES[$this->file])) { $file = array('name' => $_FILES[$this->file]['name'], 'type' => $_FILES[$this->file]['type'], 'size' => $_FILES[$this->file]['size'], 'tmp_name' => $_FILES[$this->file]['tmp_name']); } elseif (isset($GLOBALS['HTTP_POST_FILES'][$this->file])) { global $HTTP_POST_FILES; $file = array('name' => $HTTP_POST_FILES[$this->file]['name'], 'type' => $HTTP_POST_FILES[$this->file]['type'], 'size' => $HTTP_POST_FILES[$this->file]['size'], 'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']); } else { $file = array('name' => (isset($GLOBALS[$this->file . '_name']) ? $GLOBALS[$this->file . '_name'] : ''), 'type' => (isset($GLOBALS[$this->file . '_type']) ? $GLOBALS[$this->file . '_type'] : ''), 'size' => (isset($GLOBALS[$this->file . '_size']) ? $GLOBALS[$this->file . '_size'] : ''), 'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : '')); } if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) { if (sizeof($this->extensions) > 0) { if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) { if ($this->message_location == 'direct') { $messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error'); } else { $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error'); } return false; } } $this->set_file($file); $this->set_filename($file['name']); $this->set_tmp_filename($file['tmp_name']); return $this->check_destination(); } else { if ($this->message_location == 'direct') { $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning'); } else { $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning'); } return false; } } function save() { global $messageStack; if (substr($this->destination, -1) != '/') $this->destination .= '/'; if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) { chmod($this->destination . $this->filename, $this->permissions); if ($this->message_location == 'direct') { $messageStack->add(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success'); } else { $messageStack->add_session(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success'); } return true; } else { if ($this->message_location == 'direct') { $messageStack->add(ERROR_FILE_NOT_SAVED, 'error'); } else { $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error'); } return false; } } function set_file($file) { $this->file = $file; } function set_destination($destination) { $this->destination = $destination; } function set_permissions($permissions) { $this->permissions = octdec($permissions); } function set_filename($filename) { $this->filename = $filename; } function set_tmp_filename($filename) { $this->tmp_filename = $filename; } function set_extensions($extensions) { if (tep_not_null($extensions)) { if (is_array($extensions)) { $this->extensions = $extensions; } else { $this->extensions = array($extensions); } } else { $this->extensions = array(); } } function check_destination() { global $messageStack; if (!is_writeable($this->destination)) { if (is_dir($this->destination)) { if ($this->message_location == 'direct') { $messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error'); } else { $messageStack->add_session(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error'); } } else { if ($this->message_location == 'direct') { $messageStack->add(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error'); } else { $messageStack->add_session(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error'); } } return false; } else { return true; } } function set_output_messages($location) { switch ($location) { case 'session': $this->message_location = 'session'; break; case 'direct': default: $this->message_location = 'direct'; break; } } } ?>

Link to comment
Share on other sites

You're going to have to get the file in a more readable format before I can help...

:blush:

 

Download it to your PC, and open it with Wordpad, then copy/paste it into your next post.

 

That usually works.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

You're going to have to get the file in a more readable format before I can help...

:blush:

 

Download it to your PC, and open it with Wordpad, then copy/paste it into your next post.

 

That usually works.

 

 

It doesn't look to me like it helped. I guess I don't really know how it should look. This is the way it was in the file manager on vdeck and the way it looked after I downloaded to the pc and opened with wordpad. If it is still too much to try I will understand.

 

<?php

/*

$Id: upload.php,v 1.2 2003/06/20 00:18:30 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

class upload {

var $file, $filename, $destination, $permissions, $extensions, $tmp_filename, $message_location;

 

function upload($file = '', $destination = '', $permissions = '777', $extensions = '') {

$this->set_file($file); $this->set_destination($destination); $this->set_permissions($permissions); $this->set_extensions($extensions); $this->set_output_messages('direct'); if (tep_not_null($this->file) && tep_not_null($this->destination)) { $this->set_output_messages('session'); if ( ($this->parse() == true) && ($this->save() == true) ) { return true; } else { // self destruct //$this = null; unset($this); return false; } } } function parse() { global $messageStack; if (isset($_FILES[$this->file])) { $file = array('name' => $_FILES[$this->file]['name'], 'type' => $_FILES[$this->file]['type'], 'size' => $_FILES[$this->file]['size'], 'tmp_name' => $_FILES[$this->file]['tmp_name']); } elseif (isset($GLOBALS['HTTP_POST_FILES'][$this->file])) { global $HTTP_POST_FILES; $file = array('name' => $HTTP_POST_FILES[$this->file]['name'], 'type' => $HTTP_POST_FILES[$this->file]['type'], 'size' => $HTTP_POST_FILES[$this->file]['size'], 'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']); } else { $file = array('name' => (isset($GLOBALS[$this->file . '_name']) ? $GLOBALS[$this->file . '_name'] : ''), 'type' => (isset($GLOBALS[$this->file . '_type']) ? $GLOBALS[$this->file . '_type'] : ''), 'size' => (isset($GLOBALS[$this->file . '_size']) ? $GLOBALS[$this->file . '_size'] : ''), 'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : '')); } if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) { if (sizeof($this->extensions) > 0) { if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) { if ($this->message_location == 'direct') { $messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error'); } else { $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error'); } return false; } } $this->set_file($file); $this->set_filename($file['name']); $this->set_tmp_filename($file['tmp_name']); return $this->check_destination(); } else { if ($this->message_location == 'direct') { $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning'); } else { $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning'); } return false; } } function save() { global $messageStack; if (substr($this->destination, -1) != '/') $this->destination .= '/'; if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) { chmod($this->destination . $this->filename, $this->permissions); if ($this->message_location == 'direct') { $messageStack->add(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success'); } else { $messageStack->add_session(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success'); } return true; } else { if ($this->message_location == 'direct') { $messageStack->add(ERROR_FILE_NOT_SAVED, 'error'); } else { $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error'); } return false; } } function set_file($file) { $this->file = $file; } function set_destination($destination) { $this->destination = $destination; } function set_permissions($permissions) { $this->permissions = octdec($permissions); } function set_filename($filename) { $this->filename = $filename; } function set_tmp_filename($filename) { $this->tmp_filename = $filename; } function set_extensions($extensions) { if (tep_not_null($extensions)) { if (is_array($extensions)) { $this->extensions = $extensions; } else { $this->extensions = array($extensions); } } else { $this->extensions = array(); } } function check_destination() { global $messageStack; if (!is_writeable($this->destination)) { if (is_dir($this->destination)) { if ($this->message_location == 'direct') { $messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error'); } else { $messageStack->add_session(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error'); } } else { if ($this->message_location == 'direct') { $messageStack->add(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error'); } else { $messageStack->add_session(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error'); } } return false; } else { return true; } } function set_output_messages($location) { switch ($location) { case 'session': $this->message_location = 'session'; break; case 'direct': default: $this->message_location = 'direct'; break; } } } ?>

Link to comment
Share on other sites

It's all hosed up.

:huh:

 

I think Vdeck through you a curve...

 

Hope you have a backup copy somewhere...

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

This is what mine looks like:

 

<?php
/*
 $Id: upload.php,v 1.2 2003/06/20 00:18:30 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class upload {
var $file, $filename, $destination, $permissions, $extensions, $tmp_filename, $message_location;

function upload($file = '', $destination = '', $permissions = '777', $extensions = '') {
  $this->set_file($file);
  $this->set_destination($destination);
  $this->set_permissions($permissions);
  $this->set_extensions($extensions);

  $this->set_output_messages('direct');

  if (tep_not_null($this->file) && tep_not_null($this->destination)) {
	$this->set_output_messages('session');

	if ( ($this->parse() == true) && ($this->save() == true) ) {
	  return true;
	} else {
	  return false;
	}
  }
}

function parse() {
  global $messageStack;

  if (isset($_FILES[$this->file])) {
	$file = array('name' => $_FILES[$this->file]['name'],
				  'type' => $_FILES[$this->file]['type'],
				  'size' => $_FILES[$this->file]['size'],
				  'tmp_name' => $_FILES[$this->file]['tmp_name']);
  } elseif (isset($GLOBALS['HTTP_POST_FILES'][$this->file])) {
	global $HTTP_POST_FILES;

	$file = array('name' => $HTTP_POST_FILES[$this->file]['name'],
				  'type' => $HTTP_POST_FILES[$this->file]['type'],
				  'size' => $HTTP_POST_FILES[$this->file]['size'],
				  'tmp_name' => $HTTP_POST_FILES[$this->file]['tmp_name']);
  } else {
	$file = array('name' => (isset($GLOBALS[$this->file . '_name']) ? $GLOBALS[$this->file . '_name'] : ''),
				  'type' => (isset($GLOBALS[$this->file . '_type']) ? $GLOBALS[$this->file . '_type'] : ''),
				  'size' => (isset($GLOBALS[$this->file . '_size']) ? $GLOBALS[$this->file . '_size'] : ''),
				  'tmp_name' => (isset($GLOBALS[$this->file]) ? $GLOBALS[$this->file] : ''));
  }

  if ( tep_not_null($file['tmp_name']) && ($file['tmp_name'] != 'none') && is_uploaded_file($file['tmp_name']) ) {
	if (sizeof($this->extensions) > 0) {
	  if (!in_array(strtolower(substr($file['name'], strrpos($file['name'], '.')+1)), $this->extensions)) {
		if ($this->message_location == 'direct') {
		  $messageStack->add(ERROR_FILETYPE_NOT_ALLOWED, 'error');
		} else {
		  $messageStack->add_session(ERROR_FILETYPE_NOT_ALLOWED, 'error');
		}

		return false;
	  }
	}

	$this->set_file($file);
	$this->set_filename($file['name']);
	$this->set_tmp_filename($file['tmp_name']);

	return $this->check_destination();
  } else {
	if ($this->message_location == 'direct') {
	  $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning');
	} else {
	  $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning');
	}

	return false;
  }
}

function save() {
  global $messageStack;

  if (substr($this->destination, -1) != '/') $this->destination .= '/';

  if (move_uploaded_file($this->file['tmp_name'], $this->destination . $this->filename)) {
	chmod($this->destination . $this->filename, $this->permissions);

	if ($this->message_location == 'direct') {
	  $messageStack->add(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success');
	} else {
	  $messageStack->add_session(SUCCESS_FILE_SAVED_SUCCESSFULLY, 'success');
	}

	return true;
  } else {
	if ($this->message_location == 'direct') {
	  $messageStack->add(ERROR_FILE_NOT_SAVED, 'error');
	} else {
	  $messageStack->add_session(ERROR_FILE_NOT_SAVED, 'error');
	}

	return false;
  }
}

function set_file($file) {
  $this->file = $file;
}

function set_destination($destination) {
  $this->destination = $destination;
}

function set_permissions($permissions) {
  $this->permissions = octdec($permissions);
}

function set_filename($filename) {
  $this->filename = $filename;
}

function set_tmp_filename($filename) {
  $this->tmp_filename = $filename;
}

function set_extensions($extensions) {
  if (tep_not_null($extensions)) {
	if (is_array($extensions)) {
	  $this->extensions = $extensions;
	} else {
	  $this->extensions = array($extensions);
	}
  } else {
	$this->extensions = array();
  }
}

function check_destination() {
  global $messageStack;

  if (!is_writeable($this->destination)) {
	if (is_dir($this->destination)) {
	  if ($this->message_location == 'direct') {
		$messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error');
	  } else {
		$messageStack->add_session(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $this->destination), 'error');
	  }
	} else {
	  if ($this->message_location == 'direct') {
		$messageStack->add(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error');
	  } else {
		$messageStack->add_session(sprintf(ERROR_DESTINATION_DOES_NOT_EXIST, $this->destination), 'error');
	  }
	}

	return false;
  } else {
	return true;
  }
}

function set_output_messages($location) {
  switch ($location) {
	case 'session':
	  $this->message_location = 'session';
	  break;
	case 'direct':
	default:
	  $this->message_location = 'direct';
	  break;
  }
}
 }
?>

 

Don't know if it's compatible with your install or not...

:unsure:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

It's a good idea to make a backup copy of osC files before attempting edits.

 

Gives you something to fall back on should things "go south" on you...

;)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

It's a good idea to make a backup copy of osC files before attempting edits.

 

Gives you something to fall back on should things "go south" on you...

;)

 

I did find about three different lines that the syntax was slightly different and changed those. Then I completely removed the

 

// self destruct

$this = null;

 

Now I can access the admin interface.

 

I appreciate your help. Will I see problems from removing the "self destruct...."? I am hoping I will be safe in that

 

Thank you,

Link to comment
Share on other sites

Removing those lines will be OK

 

Just glad I could help.

;)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...