Forums / All Other Contributions/Addons / trouble with a (paid for) admin mod after upgrading to PHP 5.4

trouble with a (paid for) admin mod after upgrading to PHP 5.4

Views: 1,501

Results 1 to 10 of 10
5 Mar 2014, 3:56 AM
#1
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

trouble with a (paid for) admin mod after upgrading to PHP 5.4

Recently we got upgraded to php5.4 and have had some problems with accessing anything on the server. Found out that removing the php.ini file from the server fixed the issue but this one is not wanting to comply.

This mod is for vendors to access the backend of the store to input their product information and images and when going to the link you should get a login box:
http://fantasiesrealm.com/market/privatearea/login.php

instead we get this error message on the page I also have gone to the cache folder both in main store folder and the private area folder but there is nothing in there.

I have gone to creator and left a work ticket about it in case he has a clue too.

Fatal error: Cannot redeclare date_diff() in market/privatearea/includes/functions/general.php on line 3058

5 Mar 2014, 11:19 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,733
Plugin Contributions:
56

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

date-diff (http://us3.php.net/manual/en/function.date-diff.php) is a new function in PHP 5.3. The authors of your code just wanted to make it work for PHP prior to 5.3. You can remove this function now that it's built-in to PHP.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

5 Mar 2014, 8:56 PM
#3
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

swguy:

date-diff (http://us3.php.net/manual/en/function.date-diff.php) is a new function in PHP 5.3. The authors of your code just wanted to make it work for PHP prior to 5.3. You can remove this function now that it's built-in to PHP.

so I just need to go to his file listed in the error message and delete that line to fix it? yay, cause his solution is --and I quote--a temporary solution since all hosts will go to php5.4 soon, downgrade or find new host. That is not acceptable and his upgrades are not free or cheaper than original cost for package.

5 Mar 2014, 9:12 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

The date_diff() function was removed from Zen Cart's /admin/includes/functions/general.php file in v1.3.9 (actually renamed to zc_date_diff), so that means your mod is written for v1.3.8 or older.

The BEST way to deal with this is to compare YOUR general.php against the real general.php for your ZC version, and take any new functions out of that file and put them into a new file at /admin/includes/functions**/extra_functions/my_mod_functions.php
**
And of course remove or rename that date_diff() function so that it doesn't clash with PHP's reserved function names.

If your mod has altered existing functions in the general.php file, then you'll need to verify that they're legitimate and if so keep those specific changes where necessary.

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

5 Mar 2014, 9:26 PM
#5
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

ok, trial and error for me...sorry

I ended up removing this entire section from his general.php file:

////
// compute the days between two dates
  function date_diff($date1, $date2) {
  //$date1  today, or any other day
  //$date2  date to check against

    $d1 = explode("-", $date1);
    $y1 = $d1[0];
    $m1 = $d1[1];
    $d1 = $d1[2];

    $d2 = explode("-", $date2);
    $y2 = $d2[0];
    $m2 = $d2[1];
    $d2 = $d2[2];

    $date1_set = mktime(0,0,0, $m1, $d1, $y1);
    $date2_set = mktime(0,0,0, $m2, $d2, $y2);

    return(round(($date2_set-$date1_set)/(60*60*24)));
  }

The log in page and the area it lets you into now works again.

Thanks

5 Mar 2014, 9:34 PM
#6
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

DrByte:

The date_diff() function was removed from Zen Cart's /admin/includes/functions/general.php file in v1.3.9 (actually renamed to zc_date_diff), so that means your mod is written for v1.3.8 or older.

The BEST way to deal with this is to compare YOUR general.php against the real general.php for your ZC version, and take any new functions out of that file and put them into a new file at /admin/includes/functions**/extra_functions/my_mod_functions.php
**
And of course remove or rename that date_diff() function so that it doesn't clash with PHP's reserved function names.

If your mod has altered existing functions in the general.php file, then you'll need to verify that they're legitimate and if so keep those specific changes where necessary.

Thank you Dr. Byte, I ended up removing the bit of code I listed in the post above from his general.php file.

I had compared the file in stores original includes/functions/functions.general.php with his in privatearea/includes/functions/general.php

Both files had that exact same line in them so I was totally stumped and of course his naming it just general and not like the one in the originals folder stumped me also.

Course by now you know I stump very easy.

I was thinking of going thru his files and comparing them to the store files then just adding his codes to the "new edited" files but I is just a big chicken and thought I might kill my store.

I may do that in the test store though if I get real brave

5 Mar 2014, 9:39 PM
#7
drbyte avatar

drbyte

Sensei

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

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

When you're talking about "private area", I assume you're actually talking about the "admin" folder, right?

Remember, Zen Cart has the following files with similar but distinctly different filenames, and different contents in each:
/admin/includes/functions/general.php
/includes/functions/functions_general.php

Don't assume the files are the same. They're not. So be careful not to mix things up when you're working with mods that touch those files.

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

5 Mar 2014, 9:50 PM
#8
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

DrByte:

When you're talking about "private area", I assume you're actually talking about the "admin" folder, right?

Remember, Zen Cart has the following files with similar but distinctly different filenames, and different contents in each:
/admin/includes/functions/general.php
/includes/functions/functions_general.php

Don't assume the files are the same. They're not. So be careful not to mix things up when you're working with mods that touch those files.

No sugar, PrivateArea is the actual name for this paid mod which allows vendors to go into an admin section just for them with permissions to add product/pricing/gc's or coupons/sales etc

And that is the one that would not allow them to log in there anymore

When the php was first updated a few days ago...we had trouble with several of our forums and store but once removing he php.ini file from the server then that straightened out and logging in was again an ability.

This upgrade has been an experience for sure but everything seems to work fine, just gave problem for a bit.

5 Mar 2014, 10:07 PM
#9
drbyte avatar

drbyte

Sensei

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

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

Okay. If your PrivateArea directory is a completely separate highly-modified partial set of old ZC files, then I really can't comment on them.

But remember, if that PrivateArea stuff was based on old ZC files (evidently 1.3.8 or older judging from what you've said here) then you really should be keeping those up-to-date as you upgrade your real Zen Cart store. If you don't, then the old code in PrivateArea may stop working because of incompatibility with the new ZC database structures, or worse it might even corrupt your real ZC data.

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

5 Mar 2014, 10:17 PM
#10
darkangel avatar

darkangel

Totally Zenned

Join Date:
Oct 2007
Location:
Emporia, Kansas
Posts:
1,729
Plugin Contributions:
0

Re: trouble with a (paid for) admin mod after upgrading to PHP 5.4

Yes than you I will be doing that as soon as i can afford it. Unfortunately sales are down and the vendors are not using it as much as in the beginning...not one thing its another, such is life.