From the category archives:

PHP

Zen Cart UPS XML does not work with zones

by Caroline on April 2, 2007

You’re here because you want to run UPS XML for Zen Cart with zones. It configures ok if you have no zones set, but as soon as you add a zone it displays the “unconfigured” yellow icon.

The admin and the catalog both use the same code to determine if a UPS rate exists. The problem is, the admin doesn’t care about where that zone is, but the shipping checkout wants it to match the recipient’s zone. So by definition the admin can never be configured because it never matches an empty “order” zone, there’s no concept of an order on the admin end but the admin will not mark the UPS xml as “configured” until it matches this ghost zone.

It might configure ok in your store, but only if it’s set to “no zone,” which means it’ll show up for any destination whether you want it to or not. As soon as you try to add a zone it refuses to configure.

The fact is that whole paragraph of code was off, I wonder if people are using this module successfully. There’s NO WAY you could ever have configured it to do zones!

Change includes/modules/shipping/upsxml.php (upsxml.php,v 1.1.4 2004/12/19) right after the curl code setup to the following:

if (($this->enabled == true) && ((int)MODULE_SHIPPING_UPSXML_RATES_ZONE > 0)) {
$this->enabled=false;
if (empty($order->delivery['country']['id'])) {
$admin=true; }else{$admin=false;
}
/*
$check = $db->Execute(”select zone_id from ” . TABLE_ZONES_TO_GEO_ZONES . ” where geo_zone_id = ‘” . MODULE_SHIPPING_UPSXML_RATES_ZONE . “‘ and zone_country_id = ‘” . $order->delivery['country']['id'] . “‘ order by zone_id”);
*/
if ($admin) {
$sql = “select zone_id from ” . TABLE_ZONES_TO_GEO_ZONES . ” where geo_zone_id = ‘” . MODULE_SHIPPING_UPSXML_RATES_ZONE.”‘”;
} else {
$sql = “select zone_id from ” . TABLE_ZONES_TO_GEO_ZONES . ” where zone_id=’”. $order->delivery['zone_id'] . “‘ and geo_zone_id = ‘” . MODULE_SHIPPING_UPSXML_RATES_ZONE . “‘”;
}

$check = $db->Execute($sql);
if (!$check->EOF) {
$this->enabled = true;
}
}

{ 0 comments }

Programmatically determine Joomla homepage

by Caroline on March 17, 2007

If both mod_rewrite and 301’s are out in full force the home page is not going to be identifiable by a Server query_string containing “frontpage.” To determine if the current code is on the home page:

$s = filter_var($_REQUEST['QUERY_STRING'], FILTER_SANITIZE_SPECIAL_CHARS);
if (empty($s)) {

//you’re on the home page

}

{ 0 comments }

WAMP PHP 5 curl trick

by Caroline on March 7, 2007

WAMP 5 does not activate curl via the php settings/extensions options. After that menu is checked open php.ini and uncomment extension=php_curl.dll, then restart WAMP services.

{ 0 comments }

VirtueMart Authorize.net Code Changes

by Caroline on February 26, 2007

VirtueMart does not automate Authorize.net test mode. It doesn’t read classes/payment/ps_authorize.cfg.php AN_TEST_REQUEST to see if it should send test mode to Authorize.Net. A quick fix, alter

FILE CHANGE classes/ps_checkout.php lines 24, 159, 484
line 24:
define (TESTMODE,true);

Lines 159, 484, call validate with TESTMODE rather than hard-coded “false.”
159:
if ( !$this->validate_payment_method( $d, TESTMODE )) {
484:
if (!$this->validate_payment_method($d, TESTMODE)) { //Change false to true to Let the user play with the VISA Testnumber

{ 0 comments }

The Joomla You Are Not Authorized to View This Resource error has many causes. You will not find this one in any standard Joomla forum.

I added a titletag column to the jos_content table. I used it in components/com_content/content.php to set a custom title tag per content item.

 

$query = “SELECT a.id, a.title, a.title_alias, a.titletag, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,” . “n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access, a.hits,” . “n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups” . $voting['select'] . “n FROM #__content AS a” . “n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id” . “n INNER JOIN #__categories AS cc ON cc.id = a.catid” . “n INNER JOIN #__sections AS s ON s.id = a.sectionid” . “n LEFT JOIN #__users AS u ON u.id = a.created_by” . “n LEFT JOIN #__groups AS g ON a.access = g.id” . $voting['join'] . $where . “n ORDER BY $order_pri $order_sec” ;

$database->setQuery( $query, $limitstart, $limit );

$rows = $database->loadObjectList();

// Dynamic Page Title

// ctb 9/26/06 added meta key words to title

$titletag=$rows[0]->titletag;

if (strlen($titletag)< =0) {$titletag=$rows[0]->metakey;

} $mainframe->SetPageTitle( $menu->name .” ” . $rows[0]->titletag);

Then I copied content.php to a site that did not have the $titletag hack. The result was a home page (com_frontpage) that displayed “You are not authorized to view this item” for each of the home page items.

{ 0 comments }

VirtueMart Product Details Page SEO Title Tags

by Caroline on September 27, 2006

 In administrator/components/com_virtuemart/html/shop.product_details.php, add the category name to the page title

{ 0 comments }

Answers the question:
How to redirect domains given tools .htaccess, parked domain redirect and Joomla component 404sef.

If you use Joomla and care at all about search engine rankings you’ll have to use a SEF translation of some kind. I chose 404sef and I’m grateful for what it does. Here’s how to get around something it doesn’t do, which is handling non-primary domains.
It will make Search Enging Friendly links for the current domain, but if you redirect a different domain to the 404Sef’d one the component will cough up a hair ball.

Setup:

  1. Joomla 1.0.10
  2. Siteground.com hosting cpanel with parked domains
  3. Global config: SEF on
  4. SEF404 config: SEF on
  5. secondary domains that need to redirect in a search engine friendly way to http://www.bombshelters.com/:

biologicalprotection.com
biologicalshelter.com
biologicalshelter.us
biologicalshelters.com
biologicalshelters.us
blastshelters.com
blastshelters.us
bombshelter.us
chemicalprotection.us
combatshelter.com
disastershelter.com
falloutshelter.us
governmentprotection.com
nbcshelter.com
nbcshelter.us
nuclearprotection.us
nuclearshelter.us
nuclearshelters.com
radiusdefense.com
radiusengineering.us
radiusengineeringinternational.com
radiusengineeringintl.com
radiusshelters.com
saferoomprotection.us
shelterengineering.com
shelterprotection.us
sheltersystems.us
survivalshelter.us
survivalshelters.us
undergroundshelter.us
undergroundshelterengineering.com
undergroundshelters.com
undergroundshelters.us
wmdprotection.us
Setup secondary domains to resolve to primary domain

These domains are all registered on network solutions. I changed the primary and secondary name servers on all of them to the siteground name server for bombshelters.com. Then on cpanel for bombshelters.com I used the “parked domains” tool to point each of the domains to bombshelters.com.

This worked, and then broken suddenly tonight. It actually probably broke when I installed 404SEF I just didn’t realize it.

Symptoms

I guess I had 404SEF off when I redirected the domains to the bombshelters.com name server because m initial tests worked great. You’d type undergroundshelter.us and the browser would display bombshelters.com content under the undergroundshelter.us address bar. When I tried that tonight I got “this page cannot be displayed.”

The pubic_html errorlog pointed to:

[24-Jul-2006 00:58:57] PHP Warning: strpos() []: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83

[23-Jul-2006 23:04:24] PHP Fatal error: Call to undefined function: sefreltoabs() in /home/bombshel/public_html/components/com_content/content.html.php on line 584

Things that don’t fix the problem

  1. Turning off 404SEF: it fixes the problem but creates the old problem of unfriendly URLs
  2. Ensuring the strpos delimiter (and target) are not empty on sef404.php:
  3. [24-Jul-2006 00:58:57] PHP Warning: strpos() [function.strpos]: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83

    bold line below is line 83

    if (!empty($pathdata) && (!empty($sefconfig->suffix)))

    {
    if (strpos($pathdata,$sefconfig->suffix) !== false)
    $path_array[$x] = str_replace($sefconfig->suffix,”",$pathdata);
    $x++;
    }

    This is fine as far as it goes, it’s good to test inputs before assuming they have content, but it addresses a symptom, not a problem.

  4. Similar to #2, defining sefRelAbs function against its will

]: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83]: Empty delimiter. in /home/bombshel/public_html/components/com_sef/sef404.php on line 83content.html.php:
if (!function_exists(’sefRelToAbs’))
{
function sefRelToAbs($string) {}
}
What does work

In .htaccess rewrite any domain that is not http://www.bombshelters.com/ to be http://www.bombshelters.com/. Works for “bombshelters.com” (without www), “falloutshelter.us,” and etc. secondary domains.
RewriteCond %{HTTP_HOST} !bombshelters.com$ [NC]
RewriteRule ^(.*)$ http://bombshelters.com/$1 [L,R=301]

Big thank you to http://enarion.net/web/apache/htaccess/redirect-www-and-no-www/

 

{ 0 comments }

Upgrade phpadsnew

by Caroline on April 26, 2006

*PHP Post Warning*

Backup yourdomain_banners database
Backup /var/www/html/banners

Unzip phpadsnew 2.8 zip locally
FTP to /var/www/html/banners_208

Run examdiff pro to merge the old config.inc.php with the 2.08 config.inc.php. If you just copy the old config.inc.php into the new installation directory some variables will not be defined and the site will fail.
Put the new config.inc.php in
/var/www/html/banners/config.inc.php to banners_208
Make sure config.inc.php is writable.

/etc/php.ini:
file_uploads: on
magic_quotes_sybase: off
register_long_arrays: on [THIS IS NOT IN OUR PHP.INI, it's a php 5 thing]

Run
http://www.yourdomain.com/banners_208
Rename banners to banners_201
Rename banners_208 to banners
“Lock” config.inc.php (-rw-r–r-)

Your version of phpAdsNew is up-to-date. There are currently no updates available.
You are currently using phpAdsNew 2.0.8 running on Apache, PHP 4.3.9 and MySQL 4.1.12.

{ 0 comments }