PDA

View Full Version : Php!


Kylecool
5-5-02, 08:48 PM
Ok, I'm installing a php script on this guy's website who is hosted with you guys. I did the #!/usr/local/bin/php at the top of all the pages, are there are like 50 files. PAIN IN THE BUTT. Why don't you just get real PHP? Anyways, It doesn't work because they all include some pages so it parses it twice with that code and doesnt work. Can I just use .htaccess? I tried

AddHandler #!/usr/local/bin/php .php
AddHandler application/x-httpd-php .php

But it doesn't work. Please help me. :)

-Kyle

GirlsOnBikes
5-5-02, 09:06 PM
So you're saying they are trying to include PHP pages into PHP pages?
I believe that if you leave off the PHP path in the include files (like header.php, footer.php, etc), that it should work.

You don't need to put any PHP path on any files that are "included" on another page because the PHP should be processed once the file is included.

I'm not sure if that makes sense, or even helps, but hopefully it does.

Kylecool
5-5-02, 09:12 PM
I tried it. It inclues like gen_header.php, etc. It doesn't work. Thats why I need to know whats wrong with that .htaccess so I can upload it and why you guys can't just install the REAL PHP. Not the cheapo version? It's FREE.

-Kyle

GirlsOnBikes
5-5-02, 09:21 PM
Kyle,
Dont' start bad mouthing PowWeb. They will hunt you down and kill you :)
What I personally do is make my header/footer files in html, but I don't include the <html> or <body> tags, then just <php include blahblah.html> those files.
I do have some php code in my header file, and everything is working fine for me.
I'm not sure about the .htaccess stuff. I don't have anything in my .htaccess files relating to PHP.
Check out my header file, and hopefully that might help:
http://www.girls-on-bikes.com/includes/header.html

(You will notice that my banner does not show up because it is called via a PHP command, and the .html isn't being parsed by the PHP app, but when you go to my regular site, which PHP includes that file, the banner does show up)

Kylecool
5-5-02, 09:28 PM
The included files are php. :) I'm not saying powweb is bad, nor good, just saying that php is easy to install and I've done it before on many servers. If they are so big, I don't see why they can't install real php.

-Kyle

GirlsOnBikes
5-5-02, 09:31 PM
I understand that the files you want to include are PHP. :)
What I'm saying is simply name them .html, then include them.
Could you possibly provide a link to the include file so that I could test it out? Or actually provide me with the raw file (not parsed out).
If you want, you can Private Message me with it incase you don't want to share it with everybody on the forum :)
Thanks

Kylecool
5-5-02, 09:33 PM
You can't because they are PHP files. It's a BBS!!!!! Trust me, I work for a webhosting company and a BBS company.

-Kyle

GirlsOnBikes
5-5-02, 09:35 PM
So you don't want to provide me with the file so I can even test it?

Kylecool
5-5-02, 09:37 PM
The files are located at phpbb.com. :) Good luck, it's a pain installing here because of the including stuff. If it is included twice, it shows on the generated page.

-Kyle

GirlsOnBikes
5-5-02, 09:45 PM
Well, I was just able to succesfully include a PHP file within a PHP file, where both had php code in them.

test2.php (equivalent to a header file, no chmoding):
<?
$date_time_array = getdate (time());
echo $date_time_array[ "weekday"];
?>

test3.php (chmoded to 755):
#!/usr/local/bin/php
<html>
<!-- Creation date: 5/5/2002 -->
<head>
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="Silver Storm">
<meta name="generator" content="AceHTML 5 Pro">
</head>
<body>
<?php include("/www/n/nivek9991/htdocs/includes/test2.php") ?>
</body>
</html>

Does this help?

Kylecool
5-5-02, 09:50 PM
You see, some files may be accessed directly and include a php file while other ones may access another one that can be accessed directly so you have the code twice and it's messed up. Why can't powweb just install real php?

-Kyle

GirlsOnBikes
5-5-02, 09:54 PM
Well, then it sounds like you are SOL because PowWeb isn't going to change their PHP installation :)
Sorry I couldn't help.

Kylecool
5-5-02, 10:08 PM
Yes, it just sucks bad. :( I think the client may be moving.

-Kyle

Mirzabah
5-5-02, 11:11 PM
Originally posted by Kylecool
You see, some files may be accessed directly and include a php file while other ones may access another one that can be accessed directly so you have the code twice and it's messed up.I've installed phpBB myself. It is not necessary (nor desirable) to insert the "#!/usr/local/bin/php" line at the top of every file. There are some very clear instructions for installing phpBB on powweb here: http://powhelp.mywebthing.com/viewtopic.php?t=15. The only problem is that on the admin page you get some unwanted "#!/usr/local/bin/php" strings in the menu on the admin left of the page. It's harmless and it doesn't affect normal forum users. The instructions are slightly out of date - a couple of the files named have been merged into a single file (admin_authgroup.php and admin_authuser.php IIRC, you should be able to figure it out easily enough).Originally posted by Kylecool
Why can't powweb just install real php?They have installed "real" PHP. They just installed it in CGI mode. Changing it now would break their customer's existing scripts. Can you imagine how people would react if powweb said to all of their customers "we're going to make a change tomorrow that will at the very least result in unattractive text appearing on your pages and may even prevent your pages from appearing at all. We suggest you fix your scripts now. If you don't receive this message until after we've made the change, then your website has been f***ed for the last week or two. So sorry."

Yes it sucks. Yes they were idiots for installing PHP in CGI mode in the first place. But they're not going to fix it no matter how much you or anybody else whinges, so build a bridge and get over it. For US$7.77 a month I can live with a minor nuisance like this.

sophiespo
5-5-02, 11:13 PM
FYI, PowWeb is running "real" php. It works. Lots of users have absolutely no problems with it, its all a question of understanding what you have to do to work with it. GirlsOnBikes tried to explain what you have to do to understand it, and he was right in saying that PowWeb isnt going to change their php installation. They have their reasons for running it like this, all of which benefit us in the long run.

Kylecool
5-5-02, 11:19 PM
Yes it sucks. Yes they were idiots for installing PHP in CGI mode in the first place.

Yes it does. Php is php, it sucks to see it in CGI mode. When you pay for a host, you want to get what it says. We don't want the #! thing on the admin pages, we want smooth just how it should be. You could give 1 month notice to users. It's much better I must say.

-Kyle

sophiespo
5-5-02, 11:27 PM
When you pay for a host, you want to get what it says.

They say that they run PHP in CGI mode. Its all over the FAQs. They also say that you have to add the line to certain files, and that you have to chmod the files to 755. You should have read the FAQs before you signed up so that you knew what you were getting into. Thats what they are there for.

Kylecool
5-5-02, 11:40 PM
Usually you check out the site, then buy. It's not for me, for a client. ;) I can't put it in because certain files are included (php ones) and it doesn't look good with that code on top of pages and in some cases is just messed up.

-Kyle

MannInc
5-6-02, 12:00 AM
PHP here is run in CGI mode for security reasons. My entire site is PHP based and using the shebang line doesn't really cause any problems.

As PHP here is in CGI mode, remember to always upload the php files in ASCII mode and CHMOD to 755.

PowWeb is in no way an "idiot" for installing PHP this way. Personally I'd have installed it the exact same way if these were my servers. While adding the line might seem like a real pain, PHP in CGI mode is actually much more secure than having it run in regular mode.

The only php files that require the shebang line at the top are those that are called directly by the browser. If a PHP file is used as a header/footer and included, it doesn't need it. You will still need to upload in ASCII mode and CHMOD it to 755.

Kylecool
5-6-02, 12:03 AM
Yes I know, but..... Some pages that you can run individually (like a forum file) are sometimes also INCLUDED on pages so it would be sometimes called by itself and sometimes included, so it doesn't work. See what I am saying?

-Kyle

MannInc
5-6-02, 12:13 AM
Something like that might cause some issues. I'm not entirely sure how to go about making those files work under both situations.

Might I ask what Forum program you're trying to install? We might be able to point you to a possible solution.

Kylecool
5-6-02, 12:18 AM
PHPBB. I am a moderator there. I install PhpBB for free and I installed it 2 days ago on one of your clients domains (domain available upon request to authorized personnel only). It went smooth and it was easy as hell. I didn't have to insert code or anything. This site I'm doing now is a pain.

-Kyle

mjenove
5-6-02, 12:23 AM
Originally posted by Kylecool
You can't because they are PHP files. It's a BBS!!!!! Trust me, I work for a webhosting company and a BBS company.

-Kyle
Kyle,

I had nothing but respect for you until I read this post. You can name those files any damn thing you want; when it comes to brass tacks, they are all the same damn things: ASCII files. Apache wants to see the PHP extension so that it knows how to process the file: includes can be called what ever you want to. The fact: it's all just ASCII.

Now, I'm not just here to blow smoke... I ran into the same problem you did: "I want to be able to call a page by itself, and include it in other pages, too." Well, what happens when you do that? Multiple <title> tags, for one, not to mention extra <html>, <head>, & <body> tags, too. My solution:

Say you have:

article.php

that you may want to include with:

frontPage.php

.

I do this:

*** article.php ***
#!/usr/local/bin/php
<html><head><title>TITLE!!!</title></head><body>
<?php
include('articleContents.WTF');
?>
</body></html>
*** /article.php ***

*** frontPage.php ***
#!/usr/local/bin/php
<html><head><title>FRONT PAGE!!!</title></head><body>
<h1>All the News</h1>
<h2>... not fit to print</h2>
<?php
include('articleContents.WTF');
// include as many *Contents.WTF as you choose
?>
</body></html>
*** /frontPage.html ***

*** articleContents.WTF ***
// what ever your pretty heart desires
*** /articleContents.WTF ***

You know what WTF stands for? What ever you desire... hell, you don't even need to have an extension.

Now, RTFFaq, and have a nice day.

-matt

Kylecool
5-6-02, 12:28 AM
Yes, I'm going to do some more messing around tonight. Thanks for all your help. :) Sorry if I made anyone mad or uncomfortable, I am just stressed out lately.

-Kyle

mjenove
5-6-02, 12:29 AM
Originally posted by Kylecool
Yes I know, but..... Some pages that you can run individually (like a forum file) are sometimes also INCLUDED on pages so it would be sometimes called by itself and sometimes included, so it doesn't work. See what I am saying?

-Kyle

If you have a file that you are both displaying by itself, and as an include, you are breaking HTML specs at some point. Any file with a valid DOCTYPE declaration should have one:

* <html></html> pair
* <head></head> pair
* <body></body> pair

So there's no way you are sending a file out on the web, and including it on a web page, with out breaking the standards somewhere.

-matt

Kylecool
5-6-02, 12:31 AM
Yea, but the included files aren't html, they are php with variables and stuff like that. It's strange, but I'll try to do it. :)

-Kyle

Mirzabah
5-6-02, 12:46 AM
Originally posted by mjenove
So there's no way you are sending a file out on the web, and including it on a web page, with out breaking the standards somewhere.Wrong. Kyle's problem is that phpBB does in fact include some pages that are also called directly - without breaking any standards at all. The files involved are in the administrative code and "sense" whether they are included and will adjust their output accordingly, eg:<?php
if (isset ($some_variable))
echo "<p>File is included</p>" ;
else
{
?>
<html>
<head>...</head>
<body>...</body>
</html>
<?php
}
?>Including the so-called shebang line in a file like this will cause it to echo "#!/usr/local/bin/php" to the output at the point of inclusion in the including file.

But Kyle, as both sophiespo and I have pointed out, it is only the administrative code that is built this way. If you follow the instructions in the link I gave you, you will only see the shebang line on the administrative page it won't adversely affect normal use of your client's forums in any way. And the visible manifestation of the shebang line on the administration pages, while unattractive, is harmless.

If it really bothers you, you can hack into the phpBB code and instead of linking directly to the offending files, link to a wrapper. But personally I think it's far more trouble than it's worth.

Cheers,
Mirzabah.

MannInc
5-6-02, 12:54 AM
Originally posted by Mirzabah
Including the so-called shebang line

It's kind of a funny name, but that's actually what Apache calls it. As you can see, I've copied the below directly from Apache's httpd.conf file:

"Apache parses all CGI scripts for the shebang line by default."

If I had PHP installed on top of Apache (still need to reinstall after my last win reinstall), it would also parse PHP scripts for the shebang line

shebang - sounds like the sound a gun makes, hence it's name. It referers to the "firing" line that kicks off the program to run either CGI or PHP :)

Kylecool
5-6-02, 12:54 AM
Yes, I'll probably do that.

-Kyle

New2This
5-6-02, 06:31 PM
I succesfully installed a phpbb forum on my powweb site ( http://secfanatics.com/phpBB2/index.php )..
Its really not that hard to do but it is a pain. Just takes a little time to set up. I used the same tutorial shown above. Ill do anything i can to help you out.

middleground
5-8-02, 02:01 PM
Just an FYI- one can always copy the files to be included to another name, and modify the code to include the renamed files (which would not have the shebang in them).