Koozali.org: home of the SME Server

PHP Problem?

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« on: March 17, 2007, 06:28:21 PM »
I've been using SME since version 5.5 to host a couple of small websites.  I then upgraded to version 6, and am now running version 7.1.2

My problem is that some PHP scripts which we were using for a simple bulletin board no longer work under version 7.  They are simple scripts, in an i-bay, with PHP etc. enabled for that i-bay.

I have reinstalled an old pc with version 6.0 (straignt from CD - no updates - and created the i-bay, transferred everything to this machine, and everything works perfectly.

Although I've used SME for several years now, my 'behind the scenes' knowledge is very small.  The beauty of SME for me is that everything just works like you want it to - I've never needed to know too much.

My question is - if these scripts worked with earlier versions (5.5 & 6), why don't they work in 7?  Is it a PHP problem or a SME problem?

I have looked all day on the forum and I can't find anything.  Hopefully I'm posting this in the right place.

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
PHP Problem?
« Reply #1 on: March 17, 2007, 10:41:29 PM »
Well the first thing i would do is to check what version of php runs on sme 6 and what on sme 7.
"It should just work" if it doesn't report it. Thanks!

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #2 on: March 17, 2007, 10:58:03 PM »
Thanks for your reply.

How do I do this?

How will this help me?

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
PHP Problem?
« Reply #3 on: March 17, 2007, 11:34:58 PM »
Well this should give you some info about php changes (what php developers changed in their code).
Some commands don't work on your script so this should at least let you know why. Let's say that the devs decided to shorten codes in the newer versions.

You would check and then search for changes on their webpage.

Well i go to software installer in server manager pannel and then click on remove and check for php version there (i know that there is a way to do this trough shh but this is the fastest way for me).

So i would do that in both versions and then go to http://www.php.net/ChangeLog-4.php and check for changes that were made and could mess with my script.
"It should just work" if it doesn't report it. Thanks!

Offline william_syd

  • *****
  • 1,608
  • +0/-0
  • Nothing to see here.
    • http://www.magicwilly.info
Re: PHP Problem?
« Reply #4 on: March 18, 2007, 12:06:20 AM »
Quote from: "dave simmons"


My problem is that some PHP scripts which we were using for a simple bulletin board no longer work under version 7.  They are simple scripts, in an i-bay, with PHP etc. enabled for that i-bay.



What errors are you getting ?
Regards,
William

IF I give advise.. It's only if it was me....

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #5 on: March 18, 2007, 12:21:22 AM »
I'm not getting any error messages - just a blank (white) screen.  This is on a screen where people can post messages to a bulletin board.

When they fill in all (3) fields and click on 'post' the screen goes white and nothing else happens.  Their message doesn't get posted.  WHat should happen is that their message gets written away to a text file (it's not a big site!) and they get a screen saying 'thank you'.

It works fine on SME 6.0 - it's only on version 7 that it won't work.

Hope this helps.  Thank you for your reply.

Offline william_syd

  • *****
  • 1,608
  • +0/-0
  • Nothing to see here.
    • http://www.magicwilly.info
PHP Problem?
« Reply #6 on: March 18, 2007, 12:34:05 AM »
Try enabling php errors.

This post will show how...
http://forums.contribs.org/index.php?topic=35635.msg156439#msg156439
Regards,
William

IF I give advise.. It's only if it was me....

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #7 on: April 01, 2007, 06:38:13 PM »
Okay, sorry for the long delay.  I've now made the changes you suggested, and here is the result:

Parse error: parse error, unexpected '}' in /home/e-smith/files/ibays/wpsa/html/gastenboek/guestbook.php on line 222

What does this mean?

Please note - nothing has changed in the php files, only upgraded to version 7 of the system.

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #8 on: April 01, 2007, 06:58:40 PM »
PS  Have removed the offending bracket in line 222.  I don't now get the error message, the program continues to show the bulletin board - as it should - but the new message isn't added.  It adds a blank message - the text and the name of the person posting aren't shown.  The messages should be written away to a simple text file (it's not a big bulletin board), but the text file is unchanged.  

I repeat, everything works perfectly on all earlier versions of the server (5 & 6).  Its only on version 7 that it won't work.  It's a shame because all the other improvements (especially spam filtering) are brilliant.

Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
PHP Problem?
« Reply #9 on: April 01, 2007, 07:39:52 PM »
Add the bracket again, because with the bracket your script run ok.
Then:
Code: [Select]
db accounts setprop <ibayname> PHPBaseDir /home/e-smith/files/ibays/<ibayname>/:/tmp
signal-event ibay-modify <ibayname>


Ofcourse <ibayname> is the name of the ibay you have used for your script.

Also, make sure you have the correct permission in the folder of your script. Review the install instruction of the script. When you migrate maybe the permission are not the same.
The best method for my when migrate from one server to other is compressing the old and expanding in the new server. This method hold the same permission. To acomplish this, in the old server, under the root instalation of your script, open midnigh commander (mc). Then push F2 and choose compress tar.gz.
The copy this file to the new server, decompress and all the permissions are the same.

Other issue is the use of .htaccess. If the script use .htaccess file for some function you need to enable in the ibay.

Code: [Select]
db accounts setprop <ibayname> AllowOverride All
signal-event ibay-modify <ibayname>

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #10 on: April 01, 2007, 07:49:23 PM »
Hi Normando,

Thanks for your answer.

The scripts didn't run fine with the bracket in place  All we got was a white screen.  Then, by activating the PHP errors (as detailed in another post), we got the error message 'Parse error: parse error, unexpected '}' in /home/e-smith/files/ibays/wpsa/html/gastenboek/guestbook.php on line 222'.

Removing the bracket allowed the php program to run further, it just didn't add anything to the bulletin board or the file where the messages are stored.

In answer to your advice about how to migrate, I carried out a backup of the old server using the backup feature in server-manager, and the used the restore function on the newly-installed version 7 server (same machine).

The web site worked perfectly on earlier versions of the server, and we haven't changed anything, only the server version.

Thanks again for your post, any further advice would be very much appreciated.  If I haven't given enough (or the right) information please ask.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
PHP Problem?
« Reply #11 on: April 01, 2007, 09:08:24 PM »
First of all provide version numbers of the php version you are/were using. you can do this by issuing the php -v command on the server shell. This way we know what we are talking about and can determine what changes are causes by the different versions of php and what is caused by the system.

I find it hard that no changes to the code where made and that the parser now complains about a bracket, this is no normal behavior, are you sure you did not change anything? Do you have the original source to try and compare/reinstall?

Could it be that register_globals was on on the old server and is not on the newer version? It could also be that your scripts are not compatible with the newer global variables, somewhere (I don't know the version number, I believe 4.3) PHP changed serveral globals like $HTTP_POST_VAR to $_POST, this holds not only for $_POST but for a handfull others as well.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #12 on: April 01, 2007, 09:38:47 PM »
Hi Cactus,

Thanks for your reply.  I am 100% sure that we didn't change anything in the PHP scripts.  All we did was back up the old server and restore to the new (using the backup/restore function in server-manager).

The PHP version on the new machine is 4.3.9  I don't know what it was on the old machine (I only have the one machine, so I have overwritten the old install).   When I first identified the problem I did a reinstall of SME 6 on the machine and restored my backup to that.  Then everything worked fine, so it really is something which has changed from the one system to the other.  I don't really want to reinstall SME6 again to identify which version of PHP was installed.  It was whatever shipped with version 6 of SME.

Basically we went from an standard installed SME 6 to an standard installed SME.

What is register_globals?  Sorry - I am a complete novice.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
PHP Problem?
« Reply #13 on: April 01, 2007, 10:15:59 PM »
Quote from: "dave simmons"
What is register_globals?  Sorry - I am a complete novice.
Register globals means that some variables are known all throughout the environment (the php environment in this case), they are registered as global, and can be accessed from every where in the source code. More information can be found on the php website: http://www.php.net/register_globals  (I noticed that his was changed in PHP version 4.2).

Unfortunately I do not know the sourcecode, so I can not help you to much at the moment. Is it code from a well-known program or has it been written for/by you? Perhaps you can provide (a fragment) of the code so we/I can perhaps help you debug the problem.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Rob65

PHP Problem?
« Reply #14 on: April 07, 2007, 07:33:34 PM »
Dave,

are you passing variables through your URL (e.g. page.php?id=2). If that is true you are depending on the register_globals setting.

You need to set "register_globals = On" in the /etc/php.ini file. Beware: this file can begenerated from the SME templates, so this setting should be copied in the template (/etc/e-smith/templates/etc/php.ini/40DataHandling) .

Other settings that may be interesting to change:

$allowOverride = "all";
$followSymLinks = "enabled";

in etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess40ibays

This allows the use of the .htaccess file (able to override all default settings) and the use of symbolic links (as used by e.g. typo3)

I just did this two days ago and happened to have my notes still on my PC.

Good luck!

Rob

Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
PHP Problem?
« Reply #15 on: April 08, 2007, 12:10:39 AM »
Quote from: "Rob65"

Other settings that may be interesting to change:

$allowOverride = "all";
$followSymLinks = "enabled";

in etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess40ibays


Don't modify the template file. Instead use the DB variables:

http://wiki.contribs.org/DB_Variables_Configuration#Apache_server_ibay_specific_.28httpd-e-smith.29

Rob65

PHP Problem?
« Reply #16 on: April 08, 2007, 08:00:44 AM »
Quote from: "PicsOne"

Don't modify the template file. Instead use the DB variables:

http://wiki.contribs.org/DB_Variables_Configuration#Apache_server_ibay_specific_.28httpd-e-smith.29


I searched a bit to find out how to do this but could not find it.

Thanks for the info,

Rob

Offline Normando

  • *
  • 841
  • +2/-1
    • Unixlan
PHP Problem?
« Reply #17 on: April 08, 2007, 08:26:10 AM »
You are welcome.

Code: [Select]
db accounts setprop ibayname AllowOverride all
db accounts setprop ibayname FollowSymLinks enabled
signal-event ibay-modify ibayname

Offline dave simmons

  • ****
  • 125
  • +0/-0
PHP Problem?
« Reply #18 on: April 10, 2007, 05:20:59 PM »
At last - that's fixed it!

Thanks Rob

Offline dave simmons

  • ****
  • 125
  • +0/-0
Re: PHP Problem?
« Reply #19 on: December 01, 2008, 04:21:46 PM »
Curses - it's broken again!

Situation - very simple php contact form.  Fill in max 10 fields, press on send.  You get a thank you screen and can go further, I get an e-mail with the info from the fields which are filled in.

It's stopped working again, but differently this time. When it broke last time, instead of getting the "thank you" screen, there was just a white screen, and no e-mail was sent.  Thanks to the advice posted by colleagues on the forum, we managed to fix it.

Now it's stopped working again.  I don't know exactly when - if you're not a veterinarian interested in poultry disease this site won't be high on your list of places to visit. 

Joking aside, we get maybe 4 or 5 contacts per year.  In June it worked fine! 

The situation now is slightly different.  Now if someone fills in the fields and presses "send", they DO get through to the thank you screen, and an e-mail is sent, BUT the e-mail is blank - the data entered on the web form doesn't get sent with the e-mail.

The server WAS SME 7.3 when I noticed the problem (Friday).  I have now carried out the update to 7.4 but this has not helped.  I have also tried the things previously suggested in this thread.

I appreciate that this is strictly-speaking probably not a SME problem, but it was working and now it's not.  Nothing has changed in the website code - it was done for us by someone who's unfortunately not around any more - it just works and we leave it alone.  The only changes are the updates to the server.

I would be grateful for any suggestions.

Dave

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: PHP Problem?
« Reply #20 on: December 01, 2008, 07:56:06 PM »
I appreciate that this is strictly-speaking probably not a SME problem, but it was working and now it's not.  Nothing has changed in the website code - it was done for us by someone who's unfortunately not around any more - it just works and we leave it alone.  The only changes are the updates to the server.
Not to spoil you with the technical details but perhaps the origin might be somewhere in your code.
I guess I can help you but I think we need to know a little more on the script. Perhaps you can put it on the net somehow for instance on http://pastebin.com/ so PHP coders, like me can have a look at it (If there are passwords in there be sure to remove them).
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline thomasch

  • *
  • 232
  • +0/-0
Re: PHP Problem?
« Reply #21 on: December 02, 2008, 03:05:28 AM »
Not to spoil you with the technical details but perhaps the origin might be somewhere in your code.
I guess I can help you but I think we need to know a little more on the script. Perhaps you can put it on the net somehow for instance on http://pastebin.com/ so PHP coders, like me can have a look at it (If there are passwords in there be sure to remove them).

What a spoil. This is another reason why I love SMEServer.
Lots of great and helpful people here.

thomas

Offline dave simmons

  • ****
  • 125
  • +0/-0
Re: PHP Problem?
« Reply #22 on: December 02, 2008, 11:57:58 AM »
Not to spoil you with the technical details but perhaps the origin might be somewhere in your code.
I guess I can help you but I think we need to know a little more on the script. Perhaps you can put it on the net somehow for instance on http://pastebin.com/ so PHP coders, like me can have a look at it (If there are passwords in there be sure to remove them).

Hi Cactus,

Thanks for your kind offer.  I have (hopefully) made a site wpsa.pastebin.com.  I have copied the whole contents of a file on our web server called wpsamaillid.php over to this site.  If it's not there, or you need something else, please let me know.

Thank you once again.

Dave

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: PHP Problem?
« Reply #23 on: December 02, 2008, 12:01:38 PM »
If it's not there, or you need something else, please let me know.
It seems not to be there... you can also send it by e-mail, it should be in my profile.Oops, it is there, too quick to jump the gun.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline dave simmons

  • ****
  • 125
  • +0/-0
Re: PHP Problem?
« Reply #24 on: December 02, 2008, 12:40:17 PM »
Ho Cactus,

Have been looking myself, and it seems that the php script is called from a page called contact.html

I have pasted this also in case the fault lies there.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: PHP Problem?
« Reply #25 on: December 02, 2008, 01:02:37 PM »
Ho Cactus,

Have been looking myself, and it seems that the php script is called from a page called contact.html

I have pasted this also in case the fault lies there.
Thanks, but I suspect the problem is in the first script you pasted in pastebin, it relies on the deprecated register_globals function which is turned off by default since PHP 4.2.0. I have send you an e-mail with a quick and dirty work around, which does not require to enable that option again.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline dave simmons

  • ****
  • 125
  • +0/-0
Re: PHP Problem?
« Reply #26 on: December 02, 2008, 01:12:07 PM »
Hi Cactus,

Thanks for the response.  Haven't received a mail.  Did you send it to the hotmail id in my profile?

Maybe you could send to info(at)wpsa.be please

Thank you once again

Offline dave simmons

  • ****
  • 125
  • +0/-0
Re: PHP Problem?
« Reply #27 on: December 02, 2008, 05:16:35 PM »
Hi Cactus,

Found your modifications on Pastebin.

Added them in and it works again.

You are a star!

Thank you.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: PHP Problem?
« Reply #28 on: December 02, 2008, 05:18:22 PM »
Found your modifications on Pastebin.
You should also have received a copy on the e-mailadress you requested some hours ago as well as on your profile e-mailaddress.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline dave simmons

  • ****
  • 125
  • +0/-0
Re: PHP Problem?
« Reply #29 on: December 02, 2008, 06:51:05 PM »
Cactus,

FYI your mails don't seem to be coming in.