Forums / General Questions / Need some help diagnosing functions_general,php errors

Need some help diagnosing functions_general,php errors

Views: 2,236

Results 21 to 29 of 29
12 Feb 2013, 7:24 PM
#21
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Need some help diagnosing functions_general,php errors

DrByte:

... and that part is fully redundant because the test for $exclude_array already handles those names.

Do I need to change it then??

Phil Rogers
A problem shared is a problem solved.

12 Feb 2013, 7:29 PM
#22
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Need some help diagnosing functions_general,php errors

I don't think it hurts anything, just unnecessary. I did wonder why those names needed to be spelled out instead of being put in the exclude array.

12 Feb 2013, 7:43 PM
#23
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need some help diagnosing functions_general,php errors

While I have some expertise on the thread, I have found one little annoyance with my set up.

As well as the dynamic filter, I have the listing sorter enabled also. I am finding that they both work together but ONLY if you sort first then filter.

if you filter first then sort it looses the filter, sets the sort, then you have to apply the filter again.

Any idea if it would be possible to some how to allow sorting of the filtered results? or would that be a ridiculas amount of custom coding?

Phil Rogers
A problem shared is a problem solved.

12 Feb 2013, 7:58 PM
#24
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Need some help diagnosing functions_general,php errors

gjh42:

I don't think it hurts anything, just unnecessary. I did wonder why those names needed to be spelled out instead of being put in the exclude array.

It's leftover from the old code in that plugin, which hasn't been upgraded.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Feb 2013, 8:19 PM
#25
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need some help diagnosing functions_general,php errors

oh balls...

ok well I just enabled the sorters that are part of column grid layout and it works.. so its obviously the drop down version I used from another post that is causing it to stop working :o(

i'm using this:
http://www.zen-cart.com/showthread.php?56118-Sort-by-price-with-column-display/page10&highlight=sort

is the code flawed?

Phil Rogers
A problem shared is a problem solved.

18 Feb 2013, 1:58 AM
#26
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Need some help diagnosing functions_general,php errors

Design75:

This is how the merged result looks like, including Glenn's fix.

function zen_get_all_get_params($exclude_array = '', $search_engine_safe = true) {

if (!is_array($exclude_array)) $exclude_array = array();
$exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
$get_url = '';
if (is_array($_GET) && (sizeof($_GET) > 0)) {
  reset($_GET);
  while (list($key, $value) = each($_GET)) {

// bof dynamic filter 1 of 3
if ( (!in_array($key, $exclude_array)) && (is_string($value) && strlen($value) > 0 || is_array($value) && array_filter($value) ) && ($key != 'main_page') && ($key != zen_session_name()) && ($key != 'error') && ($key != 'x') && ($key != 'y') ) {
// eof dynamic filter 1 of 3
// bof dynamic filter 2 of 3
if (is_array($value)) {
foreach($value as $arr){
$get_url .= zen_sanitize_string($key) . '[]=' . rawurlencode(stripslashes($arr)) . '&';
}
} else {
// eof dynamic filter 2 of 3
$get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
// bof dynamic filter 3 of 3
}
// eof dynamic filter 3 of 3

    }
  }
}
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);

return $get_url;

}


@philip et al,
Do you mind testing out this cleaned up variation?  I've taken a look at its impact on core code, but not with the plugins you're integrating it for, so feedback from that angle is what's most needed.  If you can also test it with the products-notification stuff on checkout_success pages, that'd be appreciated also.
(If this all tests correctly, we'll look at merging it into core so future plugin integration will be simpler because this will be able to be skipped.)

```php
  function zen_get_all_get_params($exclude_array = array(), $search_engine_safe = true) {
    if (!is_array($exclude_array)) $exclude_array = array();
    $exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
    $get_url = '';
    if (is_array($_GET) && (sizeof($_GET) > 0)) {
      reset($_GET);
      while (list($key, $value) = each($_GET)) {
        if (!in_array($key, $exclude_array)) {
          if (!is_array($value)) {
            if (is_string($value) && strlen($value) > 0) {
              $get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
            }
          } else {
            foreach(array_filter($value) as $arr){
              $get_url .= zen_sanitize_string($key) . '[]=' . rawurlencode(stripslashes($arr)) . '&';
            }
          }
        }
      }
    }
    while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
    while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);

    return $get_url;
  }

and /includes/classes/shopping_cart.php line 1904-1906:```php
// zen_redirect(zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action', 'notify', 'main_page'))));
// zen_redirect(zen_href_link(FILENAME_ACCOUNT_NOTIFICATIONS, zen_get_all_get_params(array('action', 'notify', 'main_page'))));
zen_redirect(zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action', 'notify', 'main_page'))));

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Feb 2013, 6:20 AM
#27
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need some help diagnosing functions_general,php errors

Will do, ill let you know the outcome as soon as I get around to it

Phil Rogers
A problem shared is a problem solved.

22 Feb 2013, 3:47 PM
#28
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need some help diagnosing functions_general,php errors

DrByte:

@philip et al,
Do you mind testing out this cleaned up variation? I've taken a look at its impact on core code, but not with the plugins you're integrating it for, so feedback from that angle is what's most needed. If you can also test it with the products-notification stuff on checkout_success pages, that'd be appreciated also.
(If this all tests correctly, we'll look at merging it into core so future plugin integration will be simpler because this will be able to be skipped.)

function zen_get_all_get_params($exclude_array = array(), $search_engine_safe = true) {
if (!is_array($exclude_array)) $exclude_array = array();
$exclude_array = array_merge($exclude_array, array(zen_session_name(), 'main_page', 'error', 'x', 'y'));
$get_url = '';
if (is_array($_GET) && (sizeof($_GET) > 0)) {
reset($_GET);
while (list($key, $value) = each($_GET)) {
if (!in_array($key, $exclude_array)) {
if (!is_array($value)) {
if (is_string($value) && strlen($value) > 0) {
$get_url .= zen_sanitize_string($key) . '=' . rawurlencode(stripslashes($value)) . '&';
}
} else {
foreach(array_filter($value) as $arr){
$get_url .= zen_sanitize_string($key) . '[]=' . rawurlencode(stripslashes($arr)) . '&';
}
}
}
}
}
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);
while (strstr($get_url, '&&')) $get_url = str_replace('&&', '&', $get_url);

return $get_url;

}



above tested ok. haven't tested the second part. I don't use product notifications maybe someone that does could test that bit? does it only have an effect if you do use product notifications?

Phil Rogers
A problem shared is a problem solved.

22 Feb 2013, 6:35 PM
#29
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Need some help diagnosing functions_general,php errors

Yes, the second part is necessary in case you ever use the product-notification feature, especially on the checkout-success page.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.