Jump to content

Recommended Posts

I have a webpage hosted on my university's server. Because of a strange configuration, for PHP code to be executed "#!/usr/bin/php" must be the first line in the file. However this only applies to PHP files that are directly called, not files that are called by other files. My question is: is there a way for me to easily identify if a PHP file is being directly called or called by another file, perhaps by looking at the code?

Link to comment
https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/
Share on other sites

I don't know really if this would even work, but can you set an auto_prepend_file, or auto_prepend_string value in php.ini? Maybe automatically prepending the string '#!/usr/bin/php' would work?

I don't know really if this would even work, but can you set an auto_prepend_file, or auto_prepend_string value in php.ini? Maybe automatically prepending the string '#!/usr/bin/php' would work?

 

Unfortunately I don't have access to php.ini - my university IT won't let me touch it. I've tried putting "AddHandler x-httpd-php5 .php" in my .htaccess file to get around adding "#!/usr/bin/php" to my PHP files, but the AddHandler just causes the PHP code to dump, making the browser download the PHP file instead of displaying it.

Even when php is installed as a cgi (which your obviously is) it shouldn't require the shebang line. I would be speaking to the server admins, it is quite obviously a misconfiguration.

 

I've talked to IT about that, and I was told the misconfiguration will not be fixed until their PHP version is upgraded from 5.1 to 5.2, which won't be until next year. I'm trying to finish my pre-medical fraternity's website before school starts but this stupid PHP config is making it very difficult. Unfortunately I don't know PHP to be able to read these files and figure out which need the shebang line. I'm learning as I go.

Well, there really isn't any shortcuts I'm afraid. If 'vanilla' was using a MVC approach you might have more luck but most forums aren't that well designed.

 

It looks like Vanilla forums does use a MVC approach: http://code.google.com/p/vanilla-mvc/

 

How can I use this information to discover files that are requested vs files that are used in the processing of other files?

I think that is a completely different project to the vanilla you are using.

 

But anyway, a true mvc only has one access point (typically index.php). All other files are required from there. That would mean the shebang would only need to go within the one file (index.php).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.