Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hello.

I am new to php but familiar enough to recognize the right lines to go to -

 

so I installed the psxml contribution and thought it was working fine (I know nothing about ups other than when I go buy something I notice shipping can be more expensive then the thing)

 

but my client informed me that the prices for shipping were wrong and they differed from the price the ups website gave for the same item of the same weight.

 

so I've tried to re-install the UPS XML Rates v1.1.2 for osCommerce 2.2 MS2

 

and am now coming up with this error in the admin:

 

Fatal error: Cannot redeclare class xmldocument in /home/hunbrothers/www/www/the_shop/admin/includes/classes/xmldocument.php on line 19

 

I've been searching the forum for a few hours and cannot seem to find this error and frankly there is so much here my little head hurts.

 

can anyone help?

 

of point me in the right direction?

 

 

thanks

Peacepole1

Posted

it means you have the class xmldocument in twice, you need to remove one of them. easiest is probably at line 19 . . .

 

rates ups give are different per account, and your settings may not be right to pull the discounts ups gives

Posted
it means you have  the class xmldocument in twice, you need to remove one of them.  easiest is probably at line 19 . . .

 

rates ups give are different per account, and your settings may not be right to pull the discounts ups gives

 

much thanks for your speedy reply -

 

here is the code fromthe xmldocument mentioned in the error

when I take out class xmldocument

 

the error changes to the same but mentioning the exact next line and on...:

 

<?php
/*
   $Id: xmldocument.php,v 1.5 2003/06/27 01:03:03 torinwalker Exp $
   
   Written by Torin Walker
   [email protected]
   
   Generic XML Document support for when there is none.
   
   Copyright(c) 2003 by Torin Walker, All rights reserved.
   
   Released under the GNU General Public License
*/

define("ELEMENT", 0);
define("TEXTELEMENT", 1);

//*****************
class XMLDocument {
   var $root;
   var $children;

   function XMLDocument() {
   }

   function createElement($name) {
       $node = new Node();
       $node->setName($name);
       $node->setType(ELEMENT);
       return $node;
   }

   function createTextElement($text) {
       $node = new Node();
       $node->setType(TEXTELEMENT);
       $node->setValue($text);
       return $node;
   }

   function getRoot() {
       return $this->root;
   }

   function setRoot($node) {
       $this->root = $node;
   }

   function toString() {
       if ($this->root) {
           return $this->root->toString();
       } else {
           return "DOCUMENT ROOT NOT SET";
       }
   }

   function getValueByPath($path) {
       $pathArray = split("/", $path);
       if ($pathArray[0] == $this->root->getName()) {
           //print_r("Looking for " . $pathArray[0] . "<br>");
           array_shift($pathArray);
           $newPath = implode("/", $pathArray);
           return $this->root->getValueByPath($newPath);
       }
   }
}

//*********
class Node {
   var $name;
   var $type;
   var $text;
   var $parent;
   var $children;
   var $attributes;

   function Node() {
       $this->children = array();
       $this->attributes = array();
   }

   function getName() {
       return $this->name;
   }

   function setName($name) {
       $this->name = $name;
   }

   function setParent(&$node) {
       $this->parent =& $node;
   }

   function &getParent() {
       return $this->parent;
   }

   function &getChildren() {
       return $this->children;
   }

   function getType() {
       return $this->type;
   }

   function setType($type) {
       $this->type = $type;
   }

   function getElementByName($name) {
       for ($i = 0; $i < count($this->children); $i++) {
           if ($this->children[$i]->getType() == ELEMENT) {
               if ($this->children[$i]->getName() == $name) {
                   return $this->children[$i];
               }
           }
       }
       return null;
   }

   function getElementsByName($name) {
       $elements = array();
       for ($i = 0; $i < count($this->children); $i++) {
           if ($this->children[$i]->getType() == ELEMENT) {
               if ($this->children[$i]->getName() == $name) {
                   $elements[] = $this->children[$i];
               }
           }
       }
       return $elements;
   }

   function getValueByPath($path) {
       $pathArray = split('/', $path);
       $node = $this;
       for ($i = 0; $i < count($pathArray); $i++) {
           //print_r("Looking for " . $pathArray[$i] ."<br>");
           if ($node->getChildren()) {
               for ($j = 0; $j < count($node->getChildren()); $j++) {
                   if ($node->children[$j]->getType() == ELEMENT) {
                       if ($node->children[$j]->getName() == $pathArray[$i]) {
                           //print_r("Found " . $pathArray[$i] ."<br>");
                           $node = $node->children[$j];
                       }
                   }
               }
           }
       }
       return $node->getValue();
   } 

   function getText() {
       return $this->text();
   }

   function setValue($text) {
       $this->text = $text;
   }

   function getValue() {
       $value = NULL;
       if ($this->getType() == ELEMENT) {
           for ($i = 0; $i < count($this->children); $i++) {
               $value .= $this->children[$i]->getValue();
           }
       } elseif ($this->getType() == TEXTELEMENT) {
           $value .= $this->text;
       }
       return $value;
   }

   function setAttribute($name, $value) {
       $attributes[$name] = $value;
   }

   function getAttribute($name) {
       return $attributes[$name];
   }

   function addNode(&$node) {
       $this->children[] =& $node;
       $node->parent =& $this;
   }

   function parentToString($node) {
       while($node->parent) {
           //print_r("Node " . $node->name . " has parent<br>");
           $node = $node->parent;
       }
       //print_r("Node contents from root: " . $node->toString() . "<br>");
   }

   function toString() {
       $string = NULL;    
       //print_r("toString child count " . $this->name . " contains " . count($this->children) . "<br>");    
       if ($this->type == ELEMENT) {
           $string .= '{' . $this->name . '}';
           for ($i = 0; $i < count($this->children); $i++) {
               $string .= $this->children[$i]->toString();
           }
           $string .= '{/' . $this->name . '}';
       } else {
           $string .= $this->getValue();
       }
       return $string;
   }
}

//**************
class XMLParser {
   var $xp;
   var $document;
   var $current;
   var $error;

   function XMLParser() {
       $this->document = new XMLDocument();
       $this->error = array();
   }
   
   function setDocument($document) {
       $this->document = $document;
   }
   
   function getDocument() {
       return $this->document;
   }
   
   function destruct(){
       xml_parser_free($this->xp);
   }
   
   // return 1 for an error, 0 for no error
   function hasErrors() {
       if (sizeof($this->error) > 0) {
           return 1;
       } else {
           return 0;
       }
   }

   // return array of error messages
   function getError() {
       return $this->error;
   }

   // process xml start tag
   function startElement($xp, $name, $attrs) {
       //print_r("Found Start Tag: " . $name . "<br>");
       $node =& $this->document->createElement($name);
       if ($this->document->getRoot()) {
           $this->current->addNode($node);
       } else {
           $this->document->root =& $node;
       }
       $this->current =& $node;
   }

   // process xml end tag
   function endElement($xp, $name){
       //print_r("Found End Tag: " . $name . "<br>");
       if ($this->current->getParent()) {
           $this->current =& $this->current->getParent();
       }
   }

   // process data between xml tags
   function dataHandler($xp, $text) {
       //print_r("Adding Data: \"" . $text . "\"<br>");
       $node =& $this->document->createTextElement($text);
       $this->current->addNode($node);
   }

   // parse xml document from string
   function parse($xmlString) {
       if(!($this->xp = @xml_parser_create())) {
           $this->error['description'] = 'Could not create xml parser';
       }
       if(!$this->hasErrors()) {
           if(!@xml_set_object($this->xp, $this)) {
               $this->error['description'] = 'Could not set xml parser for object';
           }
       }
       if(!$this->hasErrors()) {
           if(!@xml_set_element_handler($this->xp, 'startElement', 'endElement')) {
               $this->error['description'] = 'Could not set xml element handler';
           }
       }
       if(!$this->hasErrors()) {
           if(!@xml_set_character_data_handler($this->xp, 'dataHandler')) {
               $this->error['description'] = 'Could not set xml character handler';
           }
       } 
       xml_parser_set_option($this->xp, XML_OPTION_CASE_FOLDING, false);    
       if (!$this->hasErrors()) {
           if(!@xml_parse($this->xp, $xmlString)) {
               $this->error['description'] = xml_error_string(xml_get_error_code($this->xp));
               $this->error['line'] = xml_get_current_line_number($this->xp);
           }
       }
   }
}
?>

 

 

could it be another duplicate document elsewhere?

Posted

yes it could be, i use windows grep to search for code, works great and quick

Posted
yes it could be, i use windows grep to search for code, works great and quick

 

 

thanks....

 

the files are on a unix server (if that makes any difference)

 

I'll go back through the changes I made - the read me file is pretty extensive - so it's a chance I add some lines instead of pasting over...

 

 

besides I just found an email from my client - while I've been mucking the soup up over here he's been mucking it up over there! :lol:

Posted
if on unix, you can use the unix grep command

 

this is a new one to me -

I log on through a control panel or ftp

 

is this grep possible through one of those means?

Posted

no. you shouldnt be making any changes to the code on the server, should be local, that way you download the whole site once, and then copy it to another directory for backup. make code change, then send back to the site. if it is wrong, send your backup to the site.

once correct, send copy to the backup.

Posted
no.  you shouldnt be making any changes to the code on the server, should be local, that way you download the whole site once, and then copy it to another directory for backup.  make code change, then send back to the site.  if it is wrong, send your backup to the site.

once correct, send copy to the backup.

 

oh. :blush:

 

well by magic I back-tracked and logged on to the phpmyadmin

 

and went to the page to see the error and "poof" the page minus any error

 

 

now I'm going to check through the costumer panel -

 

oh

as an aside

it turns out my client and his wife figured out that somehow they had an outdated xml key so the pricing was off from that end and they updated the key themselves and changed some product weights and were getting the results they desired..

 

until I - mighty code man - went in.... :D

 

anyway - again thanks! this is the first forum response I've gotten so quick from one of these gnu things! and it really makes a difference at 1 am to know your not alone!!!

Posted

just make sure u abackup and that the owner knows what they are doing

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...