FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » FUDforum Installation Issues » Failure loading avatars
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Failure loading avatars [message #34461] Wed, 01 November 2006 12:53 Go to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
Hi. I've done an extensive search for this but can't seem to find anything related to my setup...

I can't upload avatars from a local file on my machine. When I try, I get the message: "The specified url does not contain a valid image". The file I'm loading is a jpg and is only 3k large. I've also tried loading a gif.

This is with configuration pretty much out of the box.

This is my config:

- FUDforum 2.6.0 (FUDeGW) on eGroupWare version 1.2.105. This is all on an
  • FUDforum 2.6.0 (FUDeGW)
  • eGroupWare version 1.2.105
  • XP Pro Box (sp2)
  • XAMPP for Windows Version 1.5.4a
    • PHP 5.1.6
    • Apache 2.2.3
    • MySQL 5.0.24a-community-nt


The Apache server is running under the SYSTEM identity so should have all privileges needed.


Any help greatly appreciated.
Re: Failure loading avatars [message #34475 is a reply to message #34461] Fri, 03 November 2006 14:39 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
Pretty quiet on here at the moment!

Been doing some more digging, and I'm getting further, but it's still not working properly. (Please bear with me on this long posting).

The reason I was getting the "Specified url does not contain a valid image" was because of the default value of upload_tmp_dir in php.ini which xampp set during install - the directory separators were \ rather than / or \\ so were being treated as escape characters.

The net effect was that the full path returned by the "tmp_name" element of the $_FILES array was a path missing separators, so obviously no url was found.

I fixed this by changing the upload_tmp_dir to use forward slashes, and then, at least, the code got as far as safe_tmp_copy in register.php. This was where I hit the next snag. is_uploaded_file always returns false, and therefore move_uploaded_file always failed. I couldn't overcome this without a change to code (very reluctant to do that but I can't see another way of doing it), so I made this code change:
	if (!move_uploaded_file($source, ($name = tempnam($GLOBALS['TMP'], $prefx.'_')))) {
		if (!copy($source, $name))
			return;
	}


Sort of negates the whole point of move_uploaded_file so I'm more than willing to take advice here.

HOWEVER - that then leads to my latest stumbling block. Now the avatar will not copy to the custom_avatars folder - I always get this error:

Warning: copy(D:\Work\PHP\egroupware/fudforum/3814588639/images/custom_avatars/) [function.copy]: failed to open stream: Permission denied in D:\Work\PHP\egroupware\fudforum\3814588639\theme\default\register.php on line 1657

(Please ignore the line number poss not corresponding to yours - I've got loads of echos in there to try to work out what's going wrong)

The offending line is this one:
copy($TMP . basename($common_av_name), $WWW_ROOT_DISK . $av_path);


My echo statements tell me this:
- The source file exists
- The target folder exists

I have also successfully been able to copy it to a file name generated by tempnam($GLOBALS['TMP'], $prefx.'_').

The Apache process runs under the windows SYSTEM account and this has full control access to the custom_avatars folder. I have even run SysInternals FileMon and this shows no permission problems from the OS side.


But now I'm completely stuck. I'm pulling my hair out and would greatly appreciate some help. Apologies for the long post.
Re: Failure loading avatars [message #34506 is a reply to message #34475] Sun, 05 November 2006 17:44 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
What are the permissions of the source & destination directories? Make sure that all users on the system are allowed to write to them.
Also you may need to convert \ to /.


FUDforum Core Developer
Re: Failure loading avatars [message #34518 is a reply to message #34506] Mon, 06 November 2006 08:24 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
It's not a permissions thing....

If you look at the error message above, you'll note that the copy is to a directory, not a file (D:\Work\PHP\egroupware/fudforum/3814588639/images/custom_avatars/)

This is why it's failing. And the reason it's not a destination filename, is that the tempnam function doesn't seem to do what it's meant to do. When called with these parameters:

tempnam($GLOBALS['TMP'], $prefx.'_')


where $GLOBALS['TMP'] is
d:/work/php/egroupware/default/files/fudforum/3814588639/tmp/
and $prefx is 4.jpg_

The output is d:/work/php/egroupware/default/files/fudforum/3814588639/tmp/\4.j158.tmp

Ignore the strange /\ - you'll notice the prefix has been truncated. So when later the original filename (4.jpg) is attempted to be extracted, it fails, as there is no underscore to look for.

So there appears to be a bug in tempnam.
Re: Failure loading avatars [message #34522 is a reply to message #34518] Mon, 06 November 2006 08:46 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
Unbelievable - this is actually a deliberate Windows implementation of tempnam, apparently because of the DOS 8.3 naming convention.

I have now come up with this workaround - and I hope that someone can offer me a better alternative as I really wanted to do all of this without modifying any FUDForum source - I implement my own tempnam function (called tempname) and call that:

function tempname($dir, $prefix)
{
	$i = 0;
	while (is_file($dir.$prefix.$i."tmp"))
		$i++;
		
	return $dir.$prefix.$i."tmp";
}
Re: Failure loading avatars [message #34536 is a reply to message #34522] Mon, 06 November 2006 17:54 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
What version of PHP are you using?

FUDforum Core Developer
Re: Failure loading avatars [message #34538 is a reply to message #34536] Mon, 06 November 2006 18:05 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
My full system config is in the opening post - PHP 5.1.6
Re: Failure loading avatars [message #34541 is a reply to message #34538] Mon, 06 November 2006 18:12 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The weird backslash \ is added by PHP since it always adds the system's default directory separator to the generated URL. My suggestion would be that you try to use something other then _ as a separator in the hope win32 keeps it. Perhaps a - or alike.

FUDforum Core Developer
Re: Failure loading avatars [message #34543 is a reply to message #34541] Mon, 06 November 2006 18:27 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
From what I read it's standard tempnam behaviour only to use the first 3 chars of the prefix - the separator is more of a minor annoyance than anything more serious.

However the fudforum code looks for the underscore to get the original file name when copying across the temporary avatar to the custom_avatars folder.
Re: Failure loading avatars [message #34572 is a reply to message #34543] Tue, 07 November 2006 17:02 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
tempnam's separator length depends on the OS, in most cases there are no length restrictions.

FUDforum Core Developer
Re: Failure loading avatars [message #34582 is a reply to message #34572] Wed, 08 November 2006 05:33 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
Is it worth then coming up with a less version specific implementation of the code then? There are 3 snags that I have hit in my WAMP installation mentioned above:


  1. is_uploaded_file returns false for an uploaded file therefore move_uploaded_file fails
  2. tempnam can't be used for temporary file names on Windows OSs
  3. the column alias "reads" in some selects causes a syntax error in MySQL 5 as READS is a reserved word


(btw - I think fudForum is a fantastic product and unbelievably well-featured.)
Re: Failure loading avatars [message #34594 is a reply to message #34582] Wed, 08 November 2006 17:51 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
1) That would be a PHP problem if it is indeed the case.
2) Fixed in FUDforum's code.
3) This is fixed in FUDforum code.


FUDforum Core Developer
Re: Failure loading avatars [message #34596 is a reply to message #34594] Wed, 08 November 2006 18:08 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
Thanks Ilia - that's what I call service! Very Happy Looking forward to the updated version of the code.
Re: Failure loading avatars [message #34620 is a reply to message #34596] Fri, 10 November 2006 11:37 Go to previous messageGo to next message
steenbras is currently offline  steenbras   South Africa
Messages: 9
Registered: November 2006
Karma: 0
Junior Member
Hi again Ilia.

There's something I just don't understand... whenever I rebuild the theme I have to apply the change that renames the "reads" alias. I have changed the code in setup/base/src/forumsel.inc.t to this:
	$c = q('SELECT f.id, f.name, c.name, c.id, CASE WHEN '.$GLOBALS['usr']->last_read.' < m.post_stamp AND (fr.last_view IS NULL OR m.post_stamp > fr.last_view) THEN 1 ELSE 0 END AS rreads


but for some reason the old statement keeps getting resurrected in msg.php, thread.php, threadt.php and tree.php - always goes back to this:

	$c = q('SELECT f.id, f.name, c.name, c.id, CASE WHEN '.$GLOBALS['usr']->last_read.' < m.post_stamp AND (fr.last_view IS NULL OR m.post_stamp > fr.last_view) THEN 1 ELSE 0 END AS reads


I've even tried changing them manually to use a different alias, but a rebuild always resets it. There's no other occurrence of that statement that I can see.

[Updated on: Fri, 10 November 2006 11:37]

Report message to a moderator

Re: Failure loading avatars [message #34629 is a reply to message #34620] Fri, 10 November 2006 16:01 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You are modifying the base sources, which are only used when the forum is installed. You need to find the generated src/ directory and adjust the forumsel.inc.t file in it.

FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Only the rights to create new forums
Next Topic: Restoring FUDforum Fails
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 01:38:46 GMT 2024

Total time taken to generate the page: 0.02298 seconds