PDA

View Full Version : Problem with URL generated by PHP application



Meowhoo
12-09-2003, 07:35 AM
Hi - I've sent this in via the support form today. I still didn't get any automatic reply . Does anyone know if the support form is working at all?

Here is the problem - maybe I can get help through here -

I have installed a PHP script called PhpAdsNew (can be found at www.phpadsnew.com). I am having a strange problem when operating this script from its admin panel. When I click certain links/buttons, I get a "page not found" error message. Looking at the address bar I can see that it's trying to access a very strange looking non-existent URL that looks like this -
http://www.thecatsite.com/adserver/admin/ite/adserver/admin/zone-invocation.php

For some reason, it ads "/ite/" and then repeats "adserver/admin" in the URL. There is not directory called ite anywhere. I searched the files running this application and the string "ite" is nowhere to be found. So, I'm guessing this is a server issue, maybe something to do with the PHP settings.

The Admin Guide contains references to the PHP settings required. Not sure if this is relevant or not - if you need it - there's the link to the administrator Guide for this application -
http://www.thecatsite.com/adserver/administrator-guide.pdf

As I've said, I have talked this over with Westhost represantative by the name of Mike yesterday of livechat support. It hasn't been fixed - not sure where he got with it. In the support form I also supplied links to the admin interface along with a username and a password and instructions on how to reproduce the error message.

I need help with this - I need to set up this system asap as I have advertisers waiting for it to be activated.

Thanks.

wildjokerdesign
12-09-2003, 11:05 AM
Hmmm... I just downloaded the program and installed it on my test site. I could not get the error to reproduce. I pretty much just let the program install with defaults without changeing to much. On the test account I have Mod_php installed, MySQLs and PerlMySQL. I don't think the last effects this program but those are the possibilities that I can think of that this program would need.

I have thought of trying to re-install it? As long as you do not wipe the database your user info and stuff should still be there. Simply point it to the same database or create a new database and if you can get it working you could then use phpMyAdmin to move the old database info in.

It does not look like it is a server issue since I seems to be working on my account but I did not work with it much or add users or banners.

If you want to PM me with how to create the error I can try to recreate it on my copy. I did access the zone-invocation.php on mine with no errors that I could find.

Meowhoo
12-10-2003, 12:53 AM
Thanks for the quick reply - I wil pm you with instructions on how to recreate the error message. The DB is pretty much empty - just some tests I'm running there - nothing on the site yet.

wildjokerdesign
12-10-2003, 11:36 AM
Ok my installation is not doing this but Meowhoo's is. I can't find any diffrence in how we set up the program. The form "action" is filled in with this
$HTTP_SERVER_VARS['PHP_SELF'] Anyone know of a Site Application that would affect this variable. I read this at faqts.com's knowledge base
As of PHP 4.2.0 the default for the PHP directive register_globals
went from on to off. This is a MAJOR change in PHP. It also
affects SERVER variables such as PHP_SELF.

So, in regards to PHP_SELF, $PHP_SELF will ONLY exist if
register_globals is on. Regardless of the setting you can always
use either:

$_SERVER['PHP_SELF']
$HTTP_SERVER_VARS['PHP_SELF']

Just thought maybe this info would register an idea with someone.

wildjokerdesign
12-10-2003, 12:10 PM
Just noticed something your url is catsite.com the last three letters in your domain are "ite". This must be where it is getting it from. In my pm to you I had you check the url setting in the config file. Where you able to see what that was set to? Is there maybe a space before "ite" in that setting? Not sure if this will affect it but worth a check.

FZ
12-10-2003, 12:25 PM
Sounds like a PHP bug I had when I was on 1.0 - are you on 1.0, Meowhoo? If so, then this is probably the same PHP bug I had - it was adding a few random characters to my form action (I was also using PHP_SELF). I think WestHost was aware of the problem and quickly fixed it - maybe they missed your server? Anyway, if you can, you should try replacing all occurrences of PHP_SELF with the actual full URL of the page that it is supposed to go to, and then see if it works.

wildjokerdesign
12-10-2003, 12:57 PM
I bet Fayez is correct. I did not even think to ask if you where on 1.0 or not. I think you should be able to check this by creating a php page that has this in it and then accessing it.
<?PHP echo($HTTP_SERVER_VARS['PHP_SELF']); ?>

I think you might get the same added "ite" and that would let you know it is maybe what Fayez is refering to. I kept thinking it had to maybe be a setting in the config but may not.

If you can't get an autoreply from support ticket you might want to post your problem up in( http://forums.westhost.com/phpBB2/viewtopic.php?t=1312 )that is the new outstanding issues thread.

Meowhoo
12-10-2003, 01:37 PM
Thanks guys- I just created the PHP file and it seems to be working. Got this in the page -
: PHP/4.3.1

Does this mean it wasn't the PHP_SELF? I'm clueless when it comes to PHP - I honestly don't know. Will look into the other stuff now (if I can - have to get my two boys to sleep first).

Meowhoo
12-10-2003, 01:41 PM
I just checked the config file as well - no spaces that I can see in the URL -

// The URL to your phpAds-installation
$phpAds_config['url_prefix'] = 'http://www.thecatsite.com/adserver';

FZ
12-10-2003, 01:47 PM
Weird - that isn't what it is supposed to show you. It is supposed to show you the "address" of the file. For example, if you uploaded it in yoursite.com/directory/testing/php/thisfile.php then "/directory/testing/php/thisfile.php" is what should show up when you go to the page in your browser. Try this with a test file put in the same directory as your PHP script, and see if it comes out alright or with the "ite" error in it or not...

jalal
12-10-2003, 01:51 PM
If there is nothing in the database then it would be a good idea to do a clean install.

Is the application MySQL based? In that case, have a look in the database with PhpMyAdmin and make sure that there are no mistakes in any URL's that are entered. If the base dir or base url variable have been messed up then there is no way to connect to make the changes so you will have to use PhpMyAdmin.

Another, slightly unlikely, possibility is a corrupted file. It looks like it could be an error in string concatenation and possibly a messed up bit of code could be the cause. This is where a reinstall would help.

Meowhoo
12-10-2003, 01:51 PM
I think you're on to something here Fayez - I uploaded the file to the adserver/admin directory and this is the result -
ite/adserver/admin/test.php

You can see it here -
http://www.thecatsite.com/adserver/admin/test.php

And BTW - I'm on a dedicated server.

jalal
12-10-2003, 01:57 PM
Try creating a file with:

<?php phpinfo(); ?>

in it. That will show us what all the variables are set to.

Meowhoo
12-10-2003, 02:07 PM
Gotta go now - baby is crying. A friend of mine is looking into it at the moment and this is what he came up with - (quoting from our MSN window) -
The length of the PHP_SELF is evidently limited to somewhere around 40 chars, so it truncates the begining of the string, leaving you with the end of it.
The problem is probably because the point from which PHP_SELF starts calculating the path of the current file is not set in your environment.
If it is'nt set at all, it'll probably take the whole path, and that should cause the error that we see.
It should, however be set to the ad-program's path, or something like that, so that the file's path generated by PHP_SELF will start from there and not from the begining of the whole path.

End of quote :)

He's checking into it right now and I have to run as my little 4 weeks old is crying... Thanks again everyone!

Anne

wildjokerdesign
12-10-2003, 03:30 PM
jalal,
The application is MySQL based but there are no refrences to urls in the config table at all the only refrence to url is in the config file that Meowhoo has checked and it is set the same as on my installation.

In refrence to Meowhoo's last post about the PHP_SELF being set. Would the install program for this have set that or is that something it would not able to set. I don't remember refrence to it when I installed but was going through the install real fast.

I just checked the test.php link and I get simply
/adserver/admin/test.php

jalal
12-10-2003, 03:49 PM
I checked the link about an hour ago and I got the malformed link.
I just checked it again and I got the same result as you did.

Very strange.
Maybe it has been fixed meanwhile... :)

Meowhoo
12-10-2003, 11:51 PM
Sorry guys - the reason is that I changed the code in the test file to -
<?PHP echo($_SERVER['PHP_SELF']); ?>

As my friend wanted to check something out.

wildjokerdesign
12-11-2003, 09:08 AM
Since that returns correctly I think you should be able to replace the orginals with it. The ones I remember for sure are in the lib-setting.inc and lib-invocation.inc located in the admin directory. Look for something like this:

<form name='generate' action='".$HTTP_SERVER_VARS['PHP_SELF']."' method='POST'> The "generate" will be diffrent in each file. It may not be the best fix but may get you going.

Meowhoo
12-11-2003, 09:15 AM
Ok - problem fixed! :D

This is what my friend added to the config file -



// --------------------------------------------------------
// Arnon 11/12/03: Patch to solve improper behaviure of $HTTP_SERVER_VARS['PHP_SELF'] :
$HTTP_SERVER_VARS['PHP_SELF'] = $_SERVER['PHP_SELF']; // Use the value from $_SERVER['PHP_SELF'], which seems to work fine.
// --------------------------------------------------------


Now all I have to do is figure out how to add a cron job. Apparently it isn't working like it's supposed to be. I searched the forums and I see others are having problems as well so I'll just contact support again.

A big thank you to all of you who tried to help me here!!! It was very nice of you all and it did help a lot!!!

wildjokerdesign
12-11-2003, 09:26 AM
Well how do you like that a fix that covers all the files no matter what they are. Now why didn't I think of that? :)

FZ
12-11-2003, 02:12 PM
Glad to hear you got it working. Seems it was the PHP_SELF bug after all ;)