post attachments don't work [message #31297] |
Sat, 15 April 2006 05:19 |
newnumbertwo
Messages: 38 Registered: June 2004
Karma: 0
|
Member |
|
|
So at one time long ago, attachments used to work on our FudForum install, but they haven't worked for quite a while, and I'm not sure why.
I've tried posting attachments via the web and the maillist.php script; neither works although all the settings -- "Allow Mailing List Attachments" is yes; "Max Attachment Size" is set to 2048k; "Max Number of file Attachments" is set to 2 -- are set properly.
Monitoring errors/fud_log, errors/sql_log, and the httpd access_log/error_log show no errors or any indication of file upload failure. Attachment attempts have been tried from several different browsers so I don't think it's that either.
I can, however, upload files through the administrative interface so I'm not quite sure what the problem is. FUDforum/files is world-writable (just for testing) but I still can't seem to upload via posts.
Any ideas?
TIA
Also, there are no entries in File Filter, so everything should be allowed.
[Updated on: Sat, 15 April 2006 05:31] Report message to a moderator
|
|
|
Re: post attachments don't work [message #31303 is a reply to message #31297] |
Sat, 15 April 2006 16:40 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
The fact that neither works implies a common problem. Who is the owner of the files/ directory? Does accessing of old file attachements work?
FUDforum Core Developer
|
|
|
|
|
|
|
|
Re: post attachments don't work [message #31347 is a reply to message #31327] |
Tue, 18 April 2006 14:06 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Looks fine and I was able to download that particular attachment. Do you have php error logging enabled, perhaps some PHP error occurs and because forum does not display php errors on screen we cannot see it.
FUDforum Core Developer
|
|
|
Re: post attachments don't work [message #32338 is a reply to message #31347] |
Wed, 21 June 2006 16:25 |
newnumbertwo
Messages: 38 Registered: June 2004
Karma: 0
|
Member |
|
|
I know it's been a while since we last visited this topic, but I'd like to return and see if we can figure out a fix to it.
First, a couple words about our server install and how PHP is installed and used by apache. The server, a RHEL box, does not use the site-wide installed PHP, but rather, uses a custom apache and PHP compiled and installed just for use with this web server. We run several web servers on virtual interfaces in this manner.
If I go to our web site, and pull up a page with <? php phpinfo(); ?> in it, I'm told that the php.ini file is expected to be found at:
/websites/sitename/apps/lib/php.ini
Previously, we didn't have a php.ini there, so I copied the php.ini-recommended from the src directory to this expected location. Then, I edited php.ini and set:
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors_max_len = 0
html_errors = Off
error_log = /websites/sitename/logs/php_error.log
After touching the /websites/sitename/logs/php_error.log file, and then setting the uid/gid to the same uid/gid that apache runs under, I restarted the server.
After this, I thought I might try doing a bit of debugging via variable printing to the php_error.log. I come from a Perl development background, and an invaluable trick I've employed for a long time is to use Perl's Data::Dumper module and print variables to STDERR like so:
print STDERR Dumper($variable);
This will print out the current state of the existing variable to the defined httpd error log.
Thinking that something similar could be accomplished with PHP and FudForum, I then edited FUDForum/src/attach.inc.t, and added the following line to the safe_attachment_copy function:
var_dump($loc);
I rebuilt the theme, grepped for my new debugging statement in htdocs/forums/, saw that it was there, and then tried to attach a file, thinking that I'd get some kind of debugging output in my php_error.log. However, nothing happened, and no entry was written, not var_dump or any other php debugging message.
I guess my questions at this point are,
1. Is this method of trying to print debugging statements, and variable states, out to an error log going to work?
2. Am I in the right area for trying to figure out why my post attachments aren't working, i.e the safe_attachment_copy function in attach.inc.t ?
This is very frustrating for our users, not being able to use attachments, as they frequently need to upload a screenshot or file of code to illustrate a problem they're having with our software.
Any suggestions on this debugging process or how to fix this problem would be most appreciated.
|
|
|
Re: post attachments don't work [message #32347 is a reply to message #32338] |
Wed, 21 June 2006 18:34 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
var_dump() dumps the data to screen not to the error log, so you won't find it inside the log file. If you want to write to a file, do something like this:
<?php $fp = fopen("log_file", "a");
fwrite($fp, var_export($variable, true));
fclose($fp); ?>
attach.inc.t is a "source" file, the file that actually runs is a the compiled file "attach.inc", so after editing attach.inc.t you need to go into the theme editor and rebuild the theme.
From the last run we know files are being uploaded, but the forum cannot seem to download them? You may want to check the "referer upload check option" in the forum settings and turn it off if it is enabled. Also, you may want to add debug code to getfile.php.t which is responsible for the actual file download.
FUDforum Core Developer
|
|
|
Re: post attachments don't work [message #32362 is a reply to message #32347] |
Thu, 22 June 2006 06:47 |
newnumbertwo
Messages: 38 Registered: June 2004
Karma: 0
|
Member |
|
|
Quote: |
If you want to write to a file, do something like this:
|
This has been working. Thanks for the pointer. I'm using this code in various places, mostly to see where I'm at in the program execution.
Quote: |
attach.inc.t is a "source" file, the file that actually runs is a the compiled file "attach.inc", so after editing attach.inc.t you need to go into the theme editor and rebuild the theme.
|
Right -- I've been doing this.
Quote: |
From the last run we know files are being uploaded, but the forum cannot seem to download them?
|
Sort of. I can definitely see the files after they're uploaded to the server, but after hitting the "upload file" button, they're not showing up in the post.
What looks like is happening is, the attachment isn't being written to the fud26_attach table. From using debugging statements, and trying to follow the code the best I can, I can see that we get all the way to the attach_add function, which I think is supposed to do the insertion.
The function gets the variables passed in correctly. $at comes in looking like this:
array (
'name' => 'readme.txt',
'type' => 'text/plain',
'tmp_name' => '/tmp/phpnmAY5m',
'error' => 0,
'size' => 177,
)
$owner is getting set to the proper UID, but when the actual insertion statement runs:
$id = db_qid("INSERT INTO {SQL_TABLE_PREFIX}attach (location,message_id,original_name,owner,attach_opt,mime_type,fsize) SEL\
ECT '', 0, "._esc($at['name']).", ".$owner.", ".$attach_opt.", id, ".$at['size']." FROM {SQL_TABLE_PREFIX}mime WHERE fl_ext IN('', \
"._esc(substr(strrchr($at['name'], '.'), 1)).") ORDER BY fl_ext DESC LIMIT 1");
$id is always returned as '0'.
I'm not sure if this makes a difference or not, but there's nothing in the fud26_mime table. Could this be what's causing a value of 0 to be returned for the ID when I try to do a file upload?
Also, I looked at the mime_type column in the fud26_attach table for the attachments that did make it (long ago), and they all have a value of 0. However, these old attachments show up fine in the old posts.
Any idea what's happening here? I think I'm pretty close to figuring this out...
P.S. Here's the SQL statement that's being executed:
INSERT INTO fud26_attach (location,message_id,original_name,owner,attach_opt,mime_type,fsize) SELECT '', 0, 'readme.txt', 2543, 0, id, 177 FROM fud26_mime WHERE fl_ext IN('', 'txt') ORDER BY fl_ext DESC LIMIT 1
Which, when executed from the mysql shell, doesn't insert a row either. I'm not quite sure I understand the SQL that's being executed here either, or where the "location" is coming from (I know what it's supposed to be, I just can't figure out how it's being determined in this context).
[Updated on: Thu, 22 June 2006 06:58] Report message to a moderator
|
|
|
Re: post attachments don't work [message #32367 is a reply to message #32362] |
Thu, 22 June 2006 18:28 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Ok, well it looks like you found your problem, the mime table is empty, so the select returns no records, causing the file not to be inserted into the attach table. The solution at the minimum is to insert a single entry into that table where the value of the fl_ext column is ''.
FUDforum Core Developer
|
|
|
Re: post attachments don't work [message #33361 is a reply to message #32367] |
Mon, 28 August 2006 16:36 |
newnumbertwo
Messages: 38 Registered: June 2004
Karma: 0
|
Member |
|
|
ilia | Ok, well it looks like you found your problem, the mime table is empty, so the select returns no records, causing the file not to be inserted into the attach table. The solution at the minimum is to insert a single entry into that table where the value of the fl_ext column is ''.
|
Sorry it's taken me so long to revisit this topic. I went on vacation shortly after my last post, and have had other priorities since I got back.
That being said, I tried populating the fud26_mime table with a couple entries (including one for GIF files), and attachments still are not working.
I tried creating an entry with an attachment (a GIF file), no luck. I then tried to edit that entry to add a GIF file, again, didn't work.
Since I've got query logging turned on in MySQL, I can show you the sequence of events (the attach attempt via edit) as far as MySQL goes. Maybe you could take a look and let me know what you think is wrong:
750151 Query SELECT t.forum_id, t.replies, t.thread_opt, t.root_msg_id, t.orderexpiry, m.subject FROM fud26_
thread t INNER JOIN fud26_msg m ON t.root_msg_id=m.id WHERE t.id=19641
750151 Query SELECT id, name, max_attach_size, forum_opt, max_file_attachments, post_passwd, message_thresho
ld FROM fud26_forum WHERE id=7
750151 Query SELECT group_cache_opt, 1 as md FROM fud26_group_cache WHERE user_id IN(2543,2147483647) AND re
source_id=7 ORDER BY user_id ASC LIMIT 1
750151 Query INSERT INTO fud26_attach (location,message_id,original_name,owner,attach_opt,mime_type,fsize) S
ELECT '', 0, 'dog.gif', 2543, 0, id, 5073 FROM fud26_mime WHERE fl_ext IN('', 'gif') ORDER BY fl_ext DESC LIMIT 1
750151 Query SELECT with_str, replace_str FROM fud26_replace WHERE replace_str IS NOT NULL AND with_str IS N
OT NULL AND LENGTH(replace_str)>0
750151 Query LOCK TABLES fud26_fl_7 WRITE
750151 Query UNLOCK TABLES
750151 Query UPDATE fud26_msg SET
file_id=70000,
foff=10316402,
length=42,
mlist_msg_id='11034(dot)44f316e4(at)test(dot)com',
file_id_preview=0,
offset_preview=0,
length_preview=0,
updated_by=2543,
msg_opt=0,
attach_cnt=1,
poll_id=0,
update_stamp=1156782395,
icon=NULL ,
poll_cache=NULL,
subject='testing'
WHERE id=69684
750151 Query SELECT orderexpiry, thread_opt, root_msg_id FROM fud26_thread WHERE id=19641
750151 Query UPDATE fud26_thread SET thread_opt=0, orderexpiry=1000000000 WHERE id=19641
750151 Query SELECT seq FROM fud26_tv_7 ORDER BY seq DESC LIMIT 1
750151 Query SELECT fud26_thread.id FROM fud26_tv_7
INNER JOIN fud26_thread ON fud26_thread.id=fud26_tv_7.thread_id
INNER JOIN fud26_msg ON fud26_thread.root_msg_id=fud26_msg.id
WHERE fud26_tv_7.id>1078
AND fud26_tv_7.iss>0
AND fud26_thread.thread_opt>=2
AND (fud26_msg.post_stamp+fud26_thread.orderexpiry)<=1156782395
750151 Query DELETE FROM fud26_thread WHERE forum_id=7 AND moved_to>0 AND last_post_date<1156523195
750151 Query LOCK TABLES fud26_tv_7 WRITE, fud26_thread READ, fud26_msg READ
750151 Query SET @seq=0
750151 Query DELETE FROM fud26_tv_7
750151 Query INSERT INTO fud26_tv_7 (thread_id,iss,seq) SELECT fud26_thread.id, (thread_opt & (2|4)), (@seq:
=@seq+1) FROM fud26_thread
INNER JOIN fud26_msg ON fud26_thread.root_msg_id=fud26_msg.id
WHERE forum_id=7 AND fud26_msg.apr=1
ORDER BY (CASE WHEN thread_opt>=2 THEN (4294967294 + fud26_thread.last_post_date) ELSE fud26_thread.last_post_date
END) ASC
060828 10:26:36 750151 Query UNLOCK TABLES
750151 Query DELETE FROM fud26_index WHERE msg_id=69684
750151 Query DELETE FROM fud26_title_index WHERE msg_id=69684
750151 Query INSERT IGNORE INTO fud26_search (word) VALUES ('testing'),('this'),('test'),('see'),('attachmen
ts'),('work')
750151 Query INSERT INTO fud26_title_index (word_id, msg_id) SELECT id, 69684 FROM fud26_search WHERE word I
N('testing')
750151 Query INSERT INTO fud26_index (word_id, msg_id) SELECT id, 69684 FROM fud26_search WHERE word IN('tes
ting','this','test','see','attachments','work')
750151 Query DELETE FROM fud26_attach WHERE message_id=69684
750151 Query SELECT a.id, a.original_name, a.fsize, a.dlcount, COALESCE(m.icon, 'unknown.gif') FROM fud26_at
tach a LEFT JOIN fud26_mime m ON a.mime_type=m.id WHERE message_id=69684 AND attach_opt=0
750151 Query UPDATE fud26_ses SET data=NULL WHERE id=625014
750151 Quit
I'd be glad to provide any additional log output if need be, or run queries against the db to provide you with more debugging data.
Thanks again.
Update Found the problem! Entries in fl_ext were preceded with a . (dot). Updating the table to remove the . in front of gif, et al did the trick.
FWIW, I got a SQL error when trying to add an 'Unknown' mime type without a file extension.
[Updated on: Mon, 28 August 2006 16:41] Report message to a moderator
|
|
|
|
Re: post attachments don't work [message #33404 is a reply to message #33369] |
Wed, 30 August 2006 21:55 |
newnumbertwo
Messages: 38 Registered: June 2004
Karma: 0
|
Member |
|
|
ilia |
What was the SQL error?
|
I sorted it out. I wasn't quite sure what you meant when you asked me to insert a single entry of ''. for fl_ext (a dot? nothing? space character?) but figured out that entering a space character would do the trick. The SQL error was related to trying to create an entry in the fud26_mime table without a value for fl_ext (obvious as the column had a restraint of NOT NULL in the table definition). Inserting a space as a value did the trick, although I'm all ears (er, eyes) if it should be something else.
That being said, I'm not completely out of the water yet. I've stated before that our install integrates Fud with Mailman mailing lists. While I can make a post via the forum and attach an attachment via the web interface, posts that come in via the mailing list are missing their attachments when they make it to the forum. The attachment does make it to list recipients though. This used to work. I imported over 30,000 messages, attachments included, before we launched the site, but at some point it just stopped working.
I'm not sure what the problem is. Attachments are turned on in the mailing list config in Fud. Here's the mysql log entries for the maillist.php insertion:
1079123 Connect test@localhost on
1079123 Init DB qatestfud
1079123 Query SELECT * FROM fud26_mlist WHERE id=7
1079123 Query SELECT id, forum_opt, message_threshold, (max_attach_size * 1024) AS max_attach_size, max_file_attachments FROM fud26_forum WHERE id=7
1079123 Query SELECT lang, locale FROM fud26_themes WHERE theme_opt=1|2 LIMIT 1
1079123 Query SELECT id FROM fud26_msg WHERE mlist_msg_id='44F60607(dot)9000808(at)test(dot)com'
1079123 Query SELECT id FROM fud26_users WHERE email='test(at)test(dot)com'
1079123 Query SELECT with_str, replace_str FROM fud26_replace WHERE replace_str IS NOT NULL AND with_str IS NOT NULL AND LENGTH(replace_str)>0
1079123 Query LOCK TABLES fud26_fl_7 WRITE
1079123 Query UNLOCK TABLES
1079123 Query INSERT INTO fud26_msg (
1079123 Query INSERT INTO
1079123 Query UPDATE fud26_msg SET thread_id=19650 WHERE id=69694
1079123 Query SELECT
1079123 Query UPDATE fud26_msg SET apr=1 WHERE id=69694
1079123 Query SELECT MAX(id),count(*) FROM fud26_msg WHERE poster_id=2543 AND apr=1
060830 15:41:33 1079123 Query SELECT id FROM fud26_level WHERE post_count <= 332 ORDER BY post_count DESC LIMIT 1
1079123 Query UPDATE fud26_users SET u_last_post_id=69694, posted_msg_count=332, level_id=1 WHERE id=2543
1079123 Query SELECT seq FROM fud26_tv_7 ORDER BY seq DESC LIMIT 1
1079123 Query SELECT fud26_thread.id FROM fud26_tv_7
1079123 Query DELETE FROM fud26_thread WHERE forum_id=7 AND moved_to>0 AND last_post_date<1156714892
1079123 Query LOCK TABLES fud26_tv_7 WRITE
1079123 Query SELECT seq,iss FROM fud26_tv_7 ORDER BY seq DESC LIMIT 1
1079123 Query INSERT INTO fud26_tv_7 (thread_id,iss,seq) VALUES(19650,0,1137)
1079123 Query UNLOCK TABLES
1079123 Query UPDATE fud26_forum SET post_count=post_count+1, thread_count=thread_count+1, last_post_id=69694 WHERE id=7
1079123 Query INSERT IGNORE INTO fud26_search (word) VALUES ('test'),('blah')
1079123 Query INSERT INTO fud26_title_index (word_id, msg_id) SELECT id, 69694 FROM fud26_search WHERE word IN('test','blah')
1079123 Query INSERT INTO fud26_index (word_id, msg_id) SELECT id, 69694 FROM fud26_search WHERE word IN('test','blah')
1079123 Query SELECT u.email
1079123 Query SELECT p.total_votes, p.name AS poll_name, m.reply_to, m.subject, m.id, m.post_stamp, m.poster_id, m.foff, m.length, m.file_id, u.alias, m.attach_cnt, m.attach_cache, m.poll_cache FROM fud26_msg m LEFT JOIN fud26_users u ON m.poster_id=u.id LEFT JOIN fud26_poll p ON m.poll_id=p.id WHERE m.id=69694 AND m.apr=1
1079123 Quit
There's nothing popping up in FUDForum/errors/fud_errors, sql_errors or errors/.mlist. Honestly, I'm not seeing anything attachment related in the SQL log. The version of maillist.php I'm running is 1.63.
Any ideas?
thx
|
|
|
|
|
|
|
Re: post attachments don't work [message #33446 is a reply to message #33438] |
Fri, 01 September 2006 20:06 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Attachments are stored in memory, since entire message is there, but you are referring to the right section of the code in terms of attachment handling.
FUDforum Core Developer
|
|
|
|
Re: post attachments don't work [message #33454 is a reply to message #33451] |
Fri, 01 September 2006 20:15 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
The first thing I'd try it to put a print statement inside the loop bellow
// Handle File Attachments
to see if any attachments are being parsed out. If there are any the next step would be to put some debug prints inside the add_attachment() to see if that gets called.
FUDforum Core Developer
|
|
|
Re: post attachments don't work [message #33508 is a reply to message #33454] |
Tue, 05 September 2006 08:44 |
newnumbertwo
Messages: 38 Registered: June 2004
Karma: 0
|
Member |
|
|
It does not look like the script is recognizing that the email has an attachment, but I'm not sure why. I've checked the structure of the email immediately before it's piped into the maillist.php script, and it definitely has the attachment.
It identifies itself with the Content-Type: header:
Content-Type: multipart/mixed; boundary="------------000506090801060606070709"
(for example)
I see a "case 'multipart/mixed':" line in the function decode_body, and from sticking in debugging errors, I can see that this Content-type is parsed properly, and that the condition '$this->body_sc > 1' is met (line 155), but once it goes into the routine to "// look if message has any attached files" (line 170), it doesn't find any attached files.
When I print out $this->body_s[$i]->headers['content-disposition']
instead of 'attachment' I get 'inline' (line 172).
What's going on here?
[Updated on: Tue, 05 September 2006 08:45] Report message to a moderator
|
|
|
|