Jump to content

3.0.3 UPS Module gone whacko


Guest

Recommended Posts

Hi,

I upgraded to 303 (I know, I know...). Actually seemed to be fine until checking out. Client uses UPS only so have to use that. Get to step 4 and get this error:

Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 175

Warning: fopen(http://www.ups.com/using/services/rave/qcostcgi.cgi?accept_UPS_license_agreement=yes&10_action=3&13_product=1DA&14_origCountry=US&15_origPostal=38801&19_destPostal=38803&22_destCountry=US&23_weight=2&47_rateChart=Regular+Daily+Pickup&48_container=00&49_residential=1): failed to open stream: Permission denied in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 175

Warning: feof(): supplied argument is not a valid stream resource in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 176

Warning: fgets(): supplied argument is not a valid stream resource in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 177

Warning: feof(): supplied argument is not a valid stream resource in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 176

Warning: fgets(): supplied argument is not a valid stream resource in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 177

Warning: feof(): supplied argument is not a valid stream resource in /home/nnstyle/public_html/style/modules/shipping/UPS/ups.php on line 176

Notice the repetition? IT KEEPS GOING. The errors for lines 176 and 177 REPEAT ad infinitum until the browser crashes (tried it in Firefox and MSIE). Just keeps on looping.

Here's the code from the ups.php module:

class Ups {



    function upsProduct($prod){

       /*



     1DM == Next Day Air Early AM

     1DA == Next Day Air

     1DP == Next Day Air Saver

     2DM == 2nd Day Air Early AM

     2DA == 2nd Day Air

     3DS == 3 Day Select

     GND == Ground

     STD == Canada Standard

     XPR == Worldwide Express

     XDM == Worldwide Express Plus

     XPD == Worldwide Expedited

      

    */

      $this->upsProductCode = $prod;

    }

    

    function origin($postal, $country){

      $this->originPostalCode = $postal;

      $this->originCountryCode = $country;

    }



    function dest($postal, $country){

      $this->destPostalCode = $postal;

          $this->destCountryCode = $country;

    }



    function rate($foo){

      switch($foo){

        case "RDP":

          $this->rateCode = "Regular+Daily+Pickup";

          break;

        case "OCA":

          $this->rateCode = "On+Call+Air";

          break;

        case "OTP":

          $this->rateCode = "One+Time+Pickup";

          break;

        case "LC":

          $this->rateCode = "Letter+Center";

          break;

        case "CC":

          $this->rateCode = "Customer+Counter";

          break;

      }

    }



    function container($foo){

          switch($foo){

        case "CP":            // Customer Packaging

          $this->containerCode = "00";

          break;

        case "ULE":        // UPS Letter Envelope

          $this->containerCode = "01";        

          break;

        case "UT":            // UPS Tube

          $this->containerCode = "03";

          break;

        case "UEB":            // UPS Express Box

          $this->containerCode = "21";

          break;

        case "UW25":        // UPS Worldwide 25 kilo

          $this->containerCode = "24";

          break;

        case "UW10":        // UPS Worldwide 10 kilo

          $this->containerCode = "25";

          break;

      }

    }

    

    function weight($foo){

      $this->packageWeight = $foo;

    }



    function rescom($foo){

          switch($foo){

        case "RES":            // Residential Address

          $this->resComCode = "1";

          break;

        case "COM":            // Commercial Address

          $this->resComCode = "0";

          break;

          }

    }



	function getOpt($sum,$productCode,$desc){

	

	global $i, $optNo, $cart, $basket, $shipKey;

	

  if($sum>0){

  

  $shippingPrice = "<option value='".$shipKey."'";

  

  if($shipKey ==$basket['shipKey']){

 	 $shippingPrice .= " selected='selected'";

 	 $basket = $cart->setVar("UPS ".$desc,"shipMethod");

 	 $basket = $cart->setVar($sum,"shipCost");

  }

  

  $shippingPrice .= ">(UPS ".$desc.") ".priceFormat($sum)."</option>\r\n";

  

  $shipKey++;

  

  return $shippingPrice;

  

  } else {

  

  return FALSE;

  

  }

  

	}





    function getQuote(){

      $upsAction = "3"; // You want 3.  Don't change unless you are sure.

      $url = join("&",

               array("http://www.ups.com/using/services/rave/qcostcgi.cgi?accept_UPS_license_agreement=yes",

                     "10_action=$upsAction",

                     "13_product=$this->upsProductCode",

                     "14_origCountry=$this->originCountryCode",

                     "15_origPostal=$this->originPostalCode",

                     "19_destPostal=$this->destPostalCode",

                     "22_destCountry=$this->destCountryCode",

                     "23_weight=$this->packageWeight",

                     "47_rateChart=$this->rateCode",

                     "48_container=$this->containerCode",

                     "49_residential=$this->resComCode"

           )

                );

    

      $fp = fopen($url, "r");

      while(!feof($fp)){

        $result = fgets($fp, 500);

  

  if(ereg("Origin postal code must have five digits",$result)){

 	 echo "Origin postal code must have five digits to use UPS. Please update this in the module settings.";

 	 exit;

  } elseif(ereg("Unsupported country specified",$result)){

 	 echo "Unsupported country specified to use UPS. Please update this in the general settings.";

 	 exit;

  }

    

        $result = explode("%", $result);

        $errcode = substr($result[0], -1);

        switch($errcode){

          case 3:

            $returnval = $result[8];

                break;

          case 4:

            $returnval = $result[8];

            break;

          case 5:

            $returnval = $result[1];

            break;

          case 6:

            $returnval = $result[1];

            break;

        }

      }

  

      fclose($fp);

          if(! $returnval) { $returnval = "error"; }

      return $returnval;

    }

  }



?>

Thanks in advance for the help. I have a hugely irate client right and .... well, you know. :rolleyes:

Link to comment
Share on other sites

put this in a blank php file, upload it, and go to it in your browser. does it work?

<?

$url="http://www.ups.com/using/services/rave/qcostcgi.cgi?accept_UPS_license_agreement=yes&10_action=3&13_product=1DA&14_origCountry=US&15_origPostal=38801&19_destPostal=38803&22_destCountry=US&23_weight=2&47_rateChart=Regular+Daily+Pickup&48_container=00&49_residential=1";

$fp = fopen($url, "r");

while(!feof($fp)){

	$result = fgets($fp, 500);

	echo $result;

}

fclose($fp);

?>

Link to comment
Share on other sites

I don't think so. My programmer is on vacation and the client needs this fixed asap, so I'm trying, with my very limited coding knowledge to figure it out...

There is a definite difference in the coding.

The old coding was:

	function getOpt($sum,$productCode,$desc){

	

	global $i, $optNo, $cart, $basket;

	

  if($sum>0){

  

  $shippingPrice = "<option value='".$i.$productCode."|".$sum."'";

  

  if($i.$productCode == $optNo){

 	 $shippingPrice .= "selected='selected'";

 	 $basket = $cart->setVar("UPS ".$desc,"shipMethod");

  }

  

  $shippingPrice .= ">(UPS ".$desc.") ".priceFormat($sum)."</option>\r\n";

  

  return $shippingPrice;

  

  } else {

  

  return FALSE;

  

  }

  

	}





    function getQuote(){

      $upsAction = "3"; // You want 3.  Don't change unless you are sure.

      $url = join("&",

               array("http://www.ups.com/using/services/rave/qcostcgi.cgi?accept_UPS_license_agreement=yes",

                     "10_action=$upsAction",

                     "13_product=$this->upsProductCode",

                     "14_origCountry=$this->originCountryCode",

                     "15_origPostal=$this->originPostalCode",

                     "19_destPostal=$this->destPostalCode",

                     "22_destCountry=$this->destCountryCode",

                     "23_weight=$this->packageWeight",

                     "47_rateChart=$this->rateCode",

                     "48_container=$this->containerCode",

                     "49_residential=$this->resComCode"

           )

                );

      $fp = fopen($url, "r");

      while(!feof($fp)){

        $result = fgets($fp, 500);

        $result = explode("%", $result);

        $errcode = substr($result[0], -1);

        switch($errcode){

          case 3:

            $returnval = $result[8];

                break;

          case 4:

            $returnval = $result[8];

            break;

          case 5:

            $returnval = $result[1];

            break;

          case 6:

            $returnval = $result[1];

            break;

        }

      }

      fclose($fp);

          if(! $returnval) { $returnval = "error"; }

      return $returnval;

    }

  }

I see several areas of changes, but I don't know what the h they mean. I could try replacing the old file, but will that interfere with other upgraded functionalities??

Thanks!

Link to comment
Share on other sites

I tried the blank test page and got the same results including the crashed browser. (except of course it was on lines 4 and 5 this time)

Just for fun I also put the UPS url in and got:

UPSOnLine3%1DA%38801%US%38803%US%102%2%19.16%0.00%19.16%10:30 A.M.%

don't know if that has any bearing....

Link to comment
Share on other sites

Yeah, that's a problem on your server then. And this is the exact same server you used previously? (the old code still has fopen() in it y'see so I'm unsure why it's not working now)

Do you control the server? can you restart apache?

./httpd restart

or similar

Link to comment
Share on other sites

try this for a laugh, see if it's specific to that url. make this file into fopentest.php and upload it into the folder your OLD shop was in (if it still exists).

<?

isset($_GET['url']) ? $url= $_GET['url'] : $url = 'http://www.google.co.uk';



$fp = fopen($url, "r");

while(!feof($fp)){

	$result = fgets($fp, 500);

	echo $result;

}

fclose($fp);

?>




then try 
http://www.<yoursite>.com/fopentest.php?url=http://www.seloc.org

Link to comment
Share on other sites

THANK YOU THANK YOU!!!

Restarting Apache worked. The cart is working again.

I thank you, my client thanks you and George M. Cohan thanks you. (if you don't get the reference, rent Yankee Doodle Dandy with James Cagney)

Did I say thank you! :rolleyes:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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...