ragnarokx Posted July 7, 2010 Share Posted July 7, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/ Share on other sites More sharing options...
trq Posted July 7, 2010 Share Posted July 7, 2010 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? Not really. Most people however would place 'include' files into a sub directory or something but nothing is set in stone. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082215 Share on other sites More sharing options...
ragnarokx Posted July 7, 2010 Author Share Posted July 7, 2010 The problem is there are a lot of files. I'm trying to install Vanilla forum software but I don't know which files are directly called by users.. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082221 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2010 Share Posted July 7, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082231 Share on other sites More sharing options...
ragnarokx Posted July 7, 2010 Author Share Posted July 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082234 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2010 Share Posted July 7, 2010 And it's running as a perl module, so you can't set it up on a per-directory basis, right? That figures. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082238 Share on other sites More sharing options...
trq Posted July 7, 2010 Share Posted July 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082244 Share on other sites More sharing options...
ragnarokx Posted July 7, 2010 Author Share Posted July 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082247 Share on other sites More sharing options...
trq Posted July 7, 2010 Share Posted July 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1082252 Share on other sites More sharing options...
ragnarokx Posted July 15, 2010 Author Share Posted July 15, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1086220 Share on other sites More sharing options...
trq Posted July 15, 2010 Share Posted July 15, 2010 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). Quote Link to comment https://forums.phpfreaks.com/topic/206948-directly-vs-indirectly-called/#findComment-1086229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.