TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-26-2008, 08:50 PM   #1 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default Ftp file mode problem - spaces in files

I do a lot of work with files obtained via ftp. I have a lot of problems with the files being in the wrong mode and when they are uploaded back to the server, the site fails because the file isn't formatted correctly. It gives the Header Already Sent message, due to extra spaces at the end of the file. Another problem this causes is the introduction of spaces between the lines. A file might start off with
Code:
<?php
line 1
line 2
line 3
but ends up with
Code:
<?php

line 1

line 2

line 3
I've seen some files with 10 empty lines between each line.

I've searched all over and found a few programs that will convert the files to dos mode, and that helps a little. But the conversion can only be one at a time and I've had instances of close to 100 files that had to be edited, so that really isn't a solution.

I've tried setting my ftp program to passive and non-passive mode, and have used other ftp programs. The problem isn't consistent but will eventually occur no matter what I try. I talked to the authors of one of the ftp programs and he said the ftp programs couldn't cause that. That it was the server that wasn't writing the file in the correct way.

So I'm wondering if anyone knows of a fix for this, or at least a way to quickly convert the files. From what I've seen on the web, it is a common problem but no one seems to have a solution. Does anyone have any suggestions?
benton is offline  
Reply With Quote
Old 10-27-2008, 04:35 PM   #2 (permalink)
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

One thing to check: are you transferring in ASCII or Binary mode?

You should probably try binary if you are not now.
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote
Old 10-28-2008, 03:11 AM   #3 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

Thanks for the reply. The ftp programs are set to automatic detection. If I set it to binary, won't that cause a problem with files that should be in ascii, like php files?
benton is offline  
Reply With Quote
Old 10-28-2008, 04:06 PM   #4 (permalink)
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

Here is a link to a good post talking about this issue. And another specifically about Dreamweaver.

What OS are you using? What OS is on the web server? Do others upload to this server?

Maybe someone else is uploading incorrectly. Maybe their transfer method or FTP program is incorrectly set.

It does appear that ASCII is the correct method, but you may need to make sure the line endings are set correctly in your editor to match the server.
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote
Old 11-02-2008, 03:18 AM   #5 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

I had found other posts on the web regarding the cause of the problem, although the one you provided explains it better than the ones I found. But I was hoping others had experienced it and had a way around it. The servers I work on are almost always Linux but a few are Windows. Others are uploading to the servers so I'm sure it is probably their editors causing it. I have asked a number of them what they are using and DreamWeaver is the one that causes the most damage, although others have said they use both text and php editors so it doesn't seem to matter.

I was really looking for a way to strip the blank lines and extra spaces at the end of the files and to convert the line feeds to dos mode. Although, on thinking about it, that is probably not something easily done with php since it really should be a stand-alone app.

If I find a solution I will post back here in case anyone else has the same problem. I do appreciate your input and thank you for replying.
benton is offline  
Reply With Quote
Old 11-02-2008, 03:34 AM   #6 (permalink)
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

Would attaching one of the files be an issue? Someone may be able to provide a script to help you out...

It would help to be able to look at one of the files to be sure.
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote
Old 11-05-2008, 11:20 PM   #7 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

I had to wait until one came along since I can't create one that fails myself. The attached file will cause a headers already sent message. If the extra lines at the end are deleted, the message goes away. Also notice all of the extra blank lines in the file.
Attached Files
File Type: php database.php (4.1 KB, 133 views)
benton is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:19 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design